holonomicerrors.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. """ Common Exceptions for `holonomic` module. """
  2. class BaseHolonomicError(Exception):
  3. def new(self, *args):
  4. raise NotImplementedError("abstract base class")
  5. class NotPowerSeriesError(BaseHolonomicError):
  6. def __init__(self, holonomic, x0):
  7. self.holonomic = holonomic
  8. self.x0 = x0
  9. def __str__(self):
  10. s = 'A Power Series does not exists for '
  11. s += str(self.holonomic)
  12. s += ' about %s.' %self.x0
  13. return s
  14. class NotHolonomicError(BaseHolonomicError):
  15. def __init__(self, m):
  16. self.m = m
  17. def __str__(self):
  18. return self.m
  19. class SingularityError(BaseHolonomicError):
  20. def __init__(self, holonomic, x0):
  21. self.holonomic = holonomic
  22. self.x0 = x0
  23. def __str__(self):
  24. s = str(self.holonomic)
  25. s += ' has a singularity at %s.' %self.x0
  26. return s
  27. class NotHyperSeriesError(BaseHolonomicError):
  28. def __init__(self, holonomic, x0):
  29. self.holonomic = holonomic
  30. self.x0 = x0
  31. def __str__(self):
  32. s = 'Power series expansion of '
  33. s += str(self.holonomic)
  34. s += ' about %s is not hypergeometric' %self.x0
  35. return s