Skip to content

Add ImputationWarning class. #3670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions pymc3/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
__all__ = ['SamplingError', 'IncorrectArgumentsError', 'TraceDirectoryError']
__all__ = [
"SamplingError",
"IncorrectArgumentsError",
"TraceDirectoryError",
"ImputationWarning",
]


class SamplingError(RuntimeError):
Expand All @@ -8,6 +13,14 @@ class SamplingError(RuntimeError):
class IncorrectArgumentsError(ValueError):
pass


class TraceDirectoryError(ValueError):
'''Error from trying to load a trace from an incorrectly-structured directory,'''
"""Error from trying to load a trace from an incorrectly-structured directory,"""

pass


class ImputationWarning(UserWarning):
"""Warning that there are missing values that will be imputed."""

pass
3 changes: 2 additions & 1 deletion pymc3/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .vartypes import typefilter, discrete_types, continuous_types, isgenerator
from .blocking import DictToArrayBijection, ArrayOrdering
from .util import get_transformed_name
from .exceptions import ImputationWarning

__all__ = [
'Model', 'Factor', 'compilef', 'fn', 'fastfn', 'modelcontext',
Expand Down Expand Up @@ -1341,7 +1342,7 @@ def as_tensor(data, name, model, distribution):
impute_message = ('Data in {name} contains missing values and'
' will be automatically imputed from the'
' sampling distribution.'.format(name=name))
warnings.warn(impute_message, UserWarning)
warnings.warn(impute_message, ImputationWarning)
from .distributions import NoDistribution
testval = np.broadcast_to(distribution.default(), data.shape)[data.mask]
fakedist = NoDistribution.dist(shape=data.mask.sum(), dtype=dtype,
Expand Down