Skip to content

Deprecate assert_negative_support #5162

@ricardoV94

Description

@ricardoV94

In a lot of distributions we have a call to assert_negative_support which in V4 is not doing anything because we are not using the output anywhere:

def assert_negative_support(var, label, distname, value=-1e-6):
msg = f"The variable specified for {label} has negative support for {distname}, "
msg += "likely making it unsuitable for this parameter."
return Assert(msg)(var, at.all(at.ge(var, 0.0)))

@classmethod
def dist(cls, sigma=None, tau=None, sd=None, *args, **kwargs):
if sd is not None:
sigma = sd
tau, sigma = get_tau_sigma(tau=tau, sigma=sigma)
assert_negative_support(tau, "tau", "HalfNormal")
assert_negative_support(sigma, "sigma", "HalfNormal")
return super().dist([0.0, sigma], **kwargs)

But we might not want to use this as is, see aesara-devs/aeppl#84

In V3 it seems this was doing some hackish test:

def assert_negative_support(var, label, distname, value=-1e-6):
# Checks for evidence of positive support for a variable
if var is None:
return
try:
# Transformed distribution
support = np.isfinite(var.transformed.distribution.dist.logp(value).tag.test_value)
except AttributeError:
try:
# Untransformed distribution
support = np.isfinite(var.distribution.logp(value).tag.test_value)
except AttributeError:
# Otherwise no direct evidence of non-positive support
support = False
if np.any(support):
msg = f"The variable specified for {label} has negative support for {distname}, "
msg += "likely making it unsuitable for this parameter."
warnings.warn(msg)

Should we just remove the call? If we want to do the kind of V3 check era we should probably do it properly by adding domain information to the RandomVariables instead of doing the -1e-6 logp test.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions