Skip to content

Commit dbac33b

Browse files
larryshamalamatwiecki
authored andcommitted
Fixing np.bool Depreciation warnings: 3 files (#4673)
* 🐢 Fixed documentation * 🐢 Minor fix on top of grammar fixed in docs * Weibull RandomVariable refactoring: an example * Revert "Weibull RandomVariable refactoring: an example" This reverts commit 685a065. * Fixing np.bool depreciation warnings: 3 files * Changed np.bool_ to bool (+ fixed other places)
1 parent 946cf34 commit dbac33b

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

pymc3/step_methods/hmc/hmc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ class HamiltonianMC(BaseHMC):
3939
{
4040
"step_size": np.float64,
4141
"n_steps": np.int64,
42-
"tune": np.bool,
42+
"tune": bool,
4343
"step_size_bar": np.float64,
4444
"accept": np.float64,
45-
"diverging": np.bool,
45+
"diverging": bool,
4646
"energy_error": np.float64,
4747
"energy": np.float64,
4848
"path_length": np.float64,
49-
"accepted": np.bool,
49+
"accepted": bool,
5050
"model_logp": np.float64,
5151
"process_time_diff": np.float64,
5252
"perf_counter_diff": np.float64,

pymc3/step_methods/hmc/nuts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ class NUTS(BaseHMC):
9494
{
9595
"depth": np.int64,
9696
"step_size": np.float64,
97-
"tune": np.bool,
97+
"tune": bool,
9898
"mean_tree_accept": np.float64,
9999
"step_size_bar": np.float64,
100100
"tree_size": np.float64,
101-
"diverging": np.bool,
101+
"diverging": bool,
102102
"energy_error": np.float64,
103103
"energy": np.float64,
104104
"max_energy_error": np.float64,

pymc3/step_methods/metropolis.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ class Metropolis(ArrayStepShared):
108108
stats_dtypes = [
109109
{
110110
"accept": np.float64,
111-
"accepted": np.bool,
112-
"tune": np.bool,
111+
"accepted": bool,
112+
"tune": bool,
113113
"scaling": np.float64,
114114
}
115115
]
@@ -307,7 +307,7 @@ class BinaryMetropolis(ArrayStep):
307307
stats_dtypes = [
308308
{
309309
"accept": np.float64,
310-
"tune": np.bool,
310+
"tune": bool,
311311
"p_jump": np.float64,
312312
}
313313
]
@@ -669,8 +669,8 @@ class DEMetropolis(PopulationArrayStepShared):
669669
stats_dtypes = [
670670
{
671671
"accept": np.float64,
672-
"accepted": np.bool,
673-
"tune": np.bool,
672+
"accepted": bool,
673+
"tune": bool,
674674
"scaling": np.float64,
675675
"lambda": np.float64,
676676
}
@@ -818,8 +818,8 @@ class DEMetropolisZ(ArrayStepShared):
818818
stats_dtypes = [
819819
{
820820
"accept": np.float64,
821-
"accepted": np.bool,
822-
"tune": np.bool,
821+
"accepted": bool,
822+
"tune": bool,
823823
"scaling": np.float64,
824824
"lambda": np.float64,
825825
}

pymc3/step_methods/mlda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ def __init__(
679679

680680
else:
681681
# otherwise, set it up from scratch.
682-
self.stats_dtypes = [{"accept": np.float64, "accepted": np.bool, "tune": np.bool}]
682+
self.stats_dtypes = [{"accept": np.float64, "accepted": bool, "tune": bool}]
683683

684684
if isinstance(self.step_method_below, MetropolisMLDA):
685685
self.stats_dtypes.append({"base_scaling": np.float64})

pymc3/tests/backend_fixtures.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ def test_append_invalid(self):
6161
with pytest.raises(ValueError):
6262
self.strace.setup(self.draws, self.chain)
6363
with pytest.raises(ValueError):
64-
vars = self.sampler_vars + [{"a": np.bool}]
64+
vars = self.sampler_vars + [{"a": bool}]
6565
self.strace.setup(self.draws, self.chain, vars)
6666
else:
6767
with pytest.raises((ValueError, TypeError)):
68-
self.strace.setup(self.draws, self.chain, [{"a": np.bool}])
68+
self.strace.setup(self.draws, self.chain, [{"a": bool}])
6969

7070
def test_append(self):
7171
if self.sampler_vars is None:
@@ -103,7 +103,7 @@ def setup_method(self):
103103
self.draws, self.chain = 3, 0
104104

105105
def test_bad_dtype(self):
106-
bad_vars = [{"a": np.float64}, {"a": np.bool}]
106+
bad_vars = [{"a": np.float64}, {"a": bool}]
107107
good_vars = [{"a": np.float64}, {"a": np.float64}]
108108
with self.model:
109109
strace = self.backend(self.name)
@@ -185,7 +185,7 @@ def setup_class(cls):
185185
cls.expected_stats[0].append(stats)
186186
cls.expected_stats[1].append(stats)
187187
for key, dtype in vars.items():
188-
if dtype == np.bool:
188+
if dtype == bool:
189189
stats[key] = np.zeros(cls.draws, dtype=dtype)
190190
else:
191191
stats[key] = np.arange(cls.draws, dtype=dtype)

pymc3/tests/test_ndarray_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from pymc3.backends import base, ndarray
2222
from pymc3.tests import backend_fixtures as bf
2323

24-
STATS1 = [{"a": np.float64, "b": np.bool}]
24+
STATS1 = [{"a": np.float64, "b": bool}]
2525

2626
STATS2 = [
2727
{"a": np.float64},

0 commit comments

Comments
 (0)