Skip to content

wellcast.exceptions

exceptions

Exception classes raised by wellcast.

Every exception derives from WellcastError, so callers can catch all library errors with a single except clause. The concrete classes also derive from the closest built-in exception (ValueError or RuntimeError) so existing code that catches those keeps working.

WellcastError

Bases: Exception

Base class for all wellcast errors.

Examples:

>>> from wellcast.exceptions import FitError, WellcastError
>>> issubclass(FitError, WellcastError)
True

DataValidationError

Bases: WellcastError, ValueError

Input data is missing, malformed or physically impossible.

Raised for example when a required column is absent, a rate is negative, or a water cut falls outside the closed interval [0, 1].

Examples:

>>> from wellcast.exceptions import DataValidationError
>>> try:
...     raise DataValidationError("column 'oil_rate' is missing")
... except ValueError as exc:
...     print(exc)
column 'oil_rate' is missing

FitError

Bases: WellcastError, RuntimeError

A model or curve fit failed to converge or is not yet fitted.

Examples:

>>> from wellcast.exceptions import FitError
>>> isinstance(FitError("no convergence"), RuntimeError)
True

UnitError

Bases: WellcastError, ValueError

A unit is unknown or two units measure different physical quantities.

Examples:

>>> from wellcast.exceptions import UnitError
>>> isinstance(UnitError("cannot convert psi to degF"), ValueError)
True

MissingDependencyError

MissingDependencyError(package: str, extra: str)

Bases: WellcastError, ImportError

An optional dependency needed by the requested feature is not installed.

Parameters:

Name Type Description Default
package str

Name of the missing import, for example "lightgbm".

required
extra str

Name of the wellcast extra that provides it, for example "ml".

required

Examples:

>>> from wellcast.exceptions import MissingDependencyError
>>> print(MissingDependencyError("lightgbm", "ml"))
lightgbm is required for this feature.
Install the ml extra: pip install 'wellcast[ml]'