Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- `pm.make_shared_replacements` now retains broadcasting information which fixes issues with Metropolis samplers (see [#4492](https://github.com/pymc-devs/pymc3/pull/4492)).

**Release manager** for 3.11.2: Michael Osthege ([@michaelosthege](https://github.com/michaelosthege))
- `pm.intX` did bad job with downcasting integers. It is fixed in [#4569](https://github.com/pymc-devs/pymc3/pull/4569).
Comment thread
ferrine marked this conversation as resolved.
Outdated

## PyMC3 3.11.1 (12 February 2021)

Expand Down
2 changes: 1 addition & 1 deletion pymc3/tests/test_data_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_sample_posterior_predictive_after_set_data(self):
trace = pm.sample(1000, tune=1000, chains=1)
# Predict on new data.
with model:
x_test = [5, 6, 9]
x_test = [5.0, 6.0, 9.0]
pm.set_data(new_data={"x": x_test})
y_test = pm.sample_posterior_predictive(trace)
y_test1 = pm.fast_sample_posterior_predictive(trace)
Expand Down
5 changes: 3 additions & 2 deletions pymc3/tests/test_model_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_pandas_to_array(self, input_dtype):
assert isinstance(theano_output, theano.graph.basic.Variable)
npt.assert_allclose(theano_output.eval(), theano_graph_input.eval())
intX = pm.theanof._conversion_map[theano.config.floatX]
if dense_input.dtype == intX or dense_input.dtype == theano.config.floatX:
if "int" in str(dense_input.dtype) or dense_input.dtype == theano.config.floatX:
assert theano_output.owner is None # func should not have added new nodes
assert theano_output.name == input_name
else:
Expand All @@ -92,7 +92,8 @@ def test_pandas_to_array(self, input_dtype):
if "float" in input_dtype:
assert theano_output.dtype == theano.config.floatX
else:
assert theano_output.dtype == intX
# only cast floats, leave ints as is
assert theano_output.dtype == input_dtype

# Check function behavior with generator data
generator_output = func(square_generator)
Expand Down
3 changes: 3 additions & 0 deletions pymc3/theanof.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def intX(X):
"""
Convert a theano tensor or numpy array to theano.tensor.int32 type.
"""
# check value is already int, do nothing in this case
if (hasattr(X, "dtype") and "int" in str(X.dtype)) or isinstance(X, int):
return X
intX = _conversion_map[theano.config.floatX]
try:
return X.astype(intX)
Expand Down