ns_sdn.exceptions#
The error hierarchy every module raises from.
Three subclasses, one per kind of fix. DimensionError means the
geometry of an input is wrong (reshape the data);
SpecificationError means the content of a choice is wrong
(change the argument); NumericalError means the arithmetic could
not be carried out (look at the numbers). Each also derives from the
matching builtin, so code written against ValueError and
RuntimeError keeps working, and all share NSSDNError, so one
except clause catches anything the package raises. The shape mirrors
cultivars.exceptions so a caller handling one package’s errors
handles the other’s without a second clause.
Every message names the argument, states the rule it broke and quotes the
offending value, in that order, so a traceback is enough to fix the call:
k must be at least 1; got 0.
Exception |
Builtin base |
Raised when |
|---|---|---|
|
A series is not one-dimensional or is too short; covariates, a time grid or future covariates have the wrong length or width. |
|
|
An option is outside its |
|
|
Data contain |
Example
>>> import numpy as np
>>> from ns_sdn.spectral_decomposition import NSSDN
>>> try:
... NSSDN(np.arange(50.0), k=0)
... except NSSDNError as error:
... print(type(error).__name__)
SpecificationError
The builtin bases are kept, so generic handlers still work:
>>> issubclass(DimensionError, ValueError), issubclass(NumericalError, RuntimeError)
(True, True)
>>> try:
... NSSDN(np.ones((4, 2)))
... except ValueError as error:
... print(error)
endog must be one-dimensional; got shape (4, 2).
Exceptions#
An input has the wrong rank, length, or alignment. |
|
Base class for every exception raised by ns-sdn. |
|
A computation could not be carried out: non-finite data, a diverged fit. |
|
A specification choice is outside its admissible set. |