Skip to content

Commit b7daf26

Browse files
authored
Rename disable_bounds_check to check_bounds (#4378)
* Rename disable_bounds_check to bounds_check. * Remove trailing white space. * Rename bounds_check to check_bounds as per @ricardoV94 * Set default check_bounds to True. * bounds_check -> check_bounds. * Wording.
1 parent 37239fc commit b7daf26

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

RELEASE-NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ It also brings some dreadfully awaited fixes, so be sure to go through the chang
1616
- Removed `theanof.set_theano_config` because it illegally changed Theano's internal state (see [#4329](https://github.com/pymc-devs/pymc3/pull/4329)).
1717

1818
### New Features
19-
- Option to `disable_bounds_check=True` when instantiating `pymc3.Model()` for faster sampling for models that cannot violate boundary constraints (which are most of them; see [#4377](https://github.com/pymc-devs/pymc3/pull/4377)).
19+
- Option to set `check_bounds=False` when instantiating `pymc3.Model()`. This turns off bounds checks that ensure that input parameters of distributions are valid. For correctly specified models, this is unneccessary as all parameters get automatically transformed so that all values are valid. Turning this off should lead to faster sampling (see [#4377](https://github.com/pymc-devs/pymc3/pull/4377)).
2020
- `OrderedProbit` distribution added (see [#4232](https://github.com/pymc-devs/pymc3/pull/4232)).
2121
- `plot_posterior_predictive_glm` now works with `arviz.InferenceData` as well (see [#4234](https://github.com/pymc-devs/pymc3/pull/4234))
2222

pymc3/distributions/dist_math.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def bound(logp, *conditions, **kwargs):
7272
# If called inside a model context, see if bounds check is disabled
7373
try:
7474
model = modelcontext(kwargs.get("model"))
75-
if model.disable_bounds_check:
75+
if not model.check_bounds:
7676
return logp
7777
except TypeError: # No model found
7878
pass

pymc3/model.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -809,11 +809,11 @@ class Model(Factor, WithMemoization, metaclass=ContextMeta):
809809
temporarily in the model context. See the documentation
810810
of theano for a complete list. Set config key
811811
``compute_test_value`` to `raise` if it is None.
812-
disable_bounds_check: bool
813-
Disable checks that ensure that input parameters to distributions
814-
are in a valid range. If your model is built in a way where you
815-
know your parameters can only take on valid values you can disable
816-
this for increased speed.
812+
check_bounds: bool
813+
Ensure that input parameters to distributions are in a valid
814+
range. If your model is built in a way where you know your
815+
parameters can only take on valid values you can set this to
816+
False for increased speed.
817817
818818
Examples
819819
--------
@@ -900,14 +900,12 @@ def __new__(cls, *args, **kwargs):
900900
instance._theano_config = theano_config
901901
return instance
902902

903-
def __init__(
904-
self, name="", model=None, theano_config=None, coords=None, disable_bounds_check=False
905-
):
903+
def __init__(self, name="", model=None, theano_config=None, coords=None, check_bounds=True):
906904
self.name = name
907905
self.coords = {}
908906
self.RV_dims = {}
909907
self.add_coords(coords)
910-
self.disable_bounds_check = disable_bounds_check
908+
self.check_bounds = check_bounds
911909

912910
if self.parent is not None:
913911
self.named_vars = treedict(parent=self.parent.named_vars)

pymc3/tests/test_dist_math.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def test_bound():
6060
assert np.prod(bound(logp, cond).eval()) == -np.inf
6161

6262

63-
def test_bound_disabled():
64-
with pm.Model(disable_bounds_check=True):
63+
def test_check_bounds_false():
64+
with pm.Model(check_bounds=False):
6565
logp = tt.ones(3)
6666
cond = np.array([1, 0, 1])
6767
assert np.all(bound(logp, cond).eval() == logp.eval())

0 commit comments

Comments
 (0)