_warnings_errors.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Warnings
  2. class DegenerateDataWarning(RuntimeWarning):
  3. """Warns when data is degenerate and results may not be reliable."""
  4. def __init__(self, msg=None):
  5. if msg is None:
  6. msg = ("Degenerate data encountered; results may not be reliable.")
  7. self.args = (msg,)
  8. class ConstantInputWarning(DegenerateDataWarning):
  9. """Warns when all values in data are exactly equal."""
  10. def __init__(self, msg=None):
  11. if msg is None:
  12. msg = ("All values in data are exactly equal; "
  13. "results may not be reliable.")
  14. self.args = (msg,)
  15. class NearConstantInputWarning(DegenerateDataWarning):
  16. """Warns when all values in data are nearly equal."""
  17. def __init__(self, msg=None):
  18. if msg is None:
  19. msg = ("All values in data are nearly equal; "
  20. "results may not be reliable.")
  21. self.args = (msg,)
  22. # Errors
  23. class FitError(RuntimeError):
  24. """Represents an error condition when fitting a distribution to data."""
  25. def __init__(self, msg=None):
  26. if msg is None:
  27. msg = ("An error occured when fitting a distribution to data.")
  28. self.args = (msg,)