Skip to content

Fixing np.bool Depreciation warnings: 3 files #4673

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 9 commits into from
May 3, 2021
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
6 changes: 3 additions & 3 deletions pymc3/step_methods/hmc/hmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ class HamiltonianMC(BaseHMC):
{
"step_size": np.float64,
"n_steps": np.int64,
"tune": np.bool,
"tune": bool,
"step_size_bar": np.float64,
"accept": np.float64,
"diverging": np.bool,
"diverging": bool,
"energy_error": np.float64,
"energy": np.float64,
"path_length": np.float64,
"accepted": np.bool,
"accepted": bool,
"model_logp": np.float64,
"process_time_diff": np.float64,
"perf_counter_diff": np.float64,
Expand Down
4 changes: 2 additions & 2 deletions pymc3/step_methods/hmc/nuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ class NUTS(BaseHMC):
{
"depth": np.int64,
"step_size": np.float64,
"tune": np.bool,
"tune": bool,
"mean_tree_accept": np.float64,
"step_size_bar": np.float64,
"tree_size": np.float64,
"diverging": np.bool,
"diverging": bool,
"energy_error": np.float64,
"energy": np.float64,
"max_energy_error": np.float64,
Expand Down
14 changes: 7 additions & 7 deletions pymc3/step_methods/metropolis.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class Metropolis(ArrayStepShared):
stats_dtypes = [
{
"accept": np.float64,
"accepted": np.bool,
"tune": np.bool,
"accepted": bool,
"tune": bool,
"scaling": np.float64,
}
]
Expand Down Expand Up @@ -307,7 +307,7 @@ class BinaryMetropolis(ArrayStep):
stats_dtypes = [
{
"accept": np.float64,
"tune": np.bool,
"tune": bool,
"p_jump": np.float64,
}
]
Expand Down Expand Up @@ -669,8 +669,8 @@ class DEMetropolis(PopulationArrayStepShared):
stats_dtypes = [
{
"accept": np.float64,
"accepted": np.bool,
"tune": np.bool,
"accepted": bool,
"tune": bool,
"scaling": np.float64,
"lambda": np.float64,
}
Expand Down Expand Up @@ -818,8 +818,8 @@ class DEMetropolisZ(ArrayStepShared):
stats_dtypes = [
{
"accept": np.float64,
"accepted": np.bool,
"tune": np.bool,
"accepted": bool,
"tune": bool,
"scaling": np.float64,
"lambda": np.float64,
}
Expand Down
2 changes: 1 addition & 1 deletion pymc3/step_methods/mlda.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def __init__(

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

if isinstance(self.step_method_below, MetropolisMLDA):
self.stats_dtypes.append({"base_scaling": np.float64})
Expand Down
8 changes: 4 additions & 4 deletions pymc3/tests/backend_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ def test_append_invalid(self):
with pytest.raises(ValueError):
self.strace.setup(self.draws, self.chain)
with pytest.raises(ValueError):
vars = self.sampler_vars + [{"a": np.bool}]
vars = self.sampler_vars + [{"a": bool}]
self.strace.setup(self.draws, self.chain, vars)
else:
with pytest.raises((ValueError, TypeError)):
self.strace.setup(self.draws, self.chain, [{"a": np.bool}])
self.strace.setup(self.draws, self.chain, [{"a": bool}])

def test_append(self):
if self.sampler_vars is None:
Expand Down Expand Up @@ -103,7 +103,7 @@ def setup_method(self):
self.draws, self.chain = 3, 0

def test_bad_dtype(self):
bad_vars = [{"a": np.float64}, {"a": np.bool}]
bad_vars = [{"a": np.float64}, {"a": bool}]
good_vars = [{"a": np.float64}, {"a": np.float64}]
with self.model:
strace = self.backend(self.name)
Expand Down Expand Up @@ -185,7 +185,7 @@ def setup_class(cls):
cls.expected_stats[0].append(stats)
cls.expected_stats[1].append(stats)
for key, dtype in vars.items():
if dtype == np.bool:
if dtype == bool:
stats[key] = np.zeros(cls.draws, dtype=dtype)
else:
stats[key] = np.arange(cls.draws, dtype=dtype)
Expand Down
2 changes: 1 addition & 1 deletion pymc3/tests/test_ndarray_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pymc3.backends import base, ndarray
from pymc3.tests import backend_fixtures as bf

STATS1 = [{"a": np.float64, "b": np.bool}]
STATS1 = [{"a": np.float64, "b": bool}]

STATS2 = [
{"a": np.float64},
Expand Down