Skip to content

Commit

Permalink
Raise NotImplementedError rather than return it. (#1732)
Browse files Browse the repository at this point in the history
  • Loading branch information
tillahoffmann committed Feb 7, 2024
1 parent 977cbc2 commit 83ebecc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion numpyro/distributions/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def inv(self):
return inv

def __call__(self, x):
return NotImplementedError
raise NotImplementedError

def _inverse(self, y):
raise NotImplementedError
Expand Down
12 changes: 6 additions & 6 deletions numpyro/distributions/truncated.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def mean(self):
elif isinstance(self.base_dist, Cauchy):
return jnp.full(self.batch_shape, jnp.nan)
else:
return NotImplementedError("mean only available for Normal and Cauchy")
raise NotImplementedError("mean only available for Normal and Cauchy")

@property
def var(self):
Expand All @@ -102,7 +102,7 @@ def var(self):
elif isinstance(self.base_dist, Cauchy):
return jnp.full(self.batch_shape, jnp.nan)
else:
return NotImplementedError("var only available for Normal and Cauchy")
raise NotImplementedError("var only available for Normal and Cauchy")


class RightTruncatedDistribution(Distribution):
Expand Down Expand Up @@ -152,7 +152,7 @@ def mean(self):
elif isinstance(self.base_dist, Cauchy):
return jnp.full(self.batch_shape, jnp.nan)
else:
return NotImplementedError("mean only available for Normal and Cauchy")
raise NotImplementedError("mean only available for Normal and Cauchy")

@property
def var(self):
Expand All @@ -166,7 +166,7 @@ def var(self):
elif isinstance(self.base_dist, Cauchy):
return jnp.full(self.batch_shape, jnp.nan)
else:
return NotImplementedError("var only available for Normal and Cauchy")
raise NotImplementedError("var only available for Normal and Cauchy")


class TwoSidedTruncatedDistribution(Distribution):
Expand Down Expand Up @@ -269,7 +269,7 @@ def mean(self):
elif isinstance(self.base_dist, Cauchy):
return jnp.full(self.batch_shape, jnp.nan)
else:
return NotImplementedError("mean only available for Normal and Cauchy")
raise NotImplementedError("mean only available for Normal and Cauchy")

@property
def var(self):
Expand All @@ -285,7 +285,7 @@ def var(self):
elif isinstance(self.base_dist, Cauchy):
return jnp.full(self.batch_shape, jnp.nan)
else:
return NotImplementedError("var only available for Normal and Cauchy")
raise NotImplementedError("var only available for Normal and Cauchy")


def TruncatedDistribution(base_dist, low=None, high=None, *, validate_args=None):
Expand Down

0 comments on commit 83ebecc

Please sign in to comment.