Skip to content

Commit

Permalink
Support imputations with ndarray data
Browse files Browse the repository at this point in the history
closes #4437
  • Loading branch information
michaelosthege committed Jan 24, 2021
1 parent 823906a commit c183d11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Breaking Changes

### New Features
+ Automatic imputations now also works with `ndarray` data (see[#4439](https://github.com/pymc-devs/pymc3/pull/4439)).

### Maintenance
- `math.log1mexp_numpy` no longer raises RuntimeWarning when given very small inputs. These were commonly observed during NUTS sampling (see [#4428](https://github.com/pymc-devs/pymc3/pull/4428)).
Expand Down
8 changes: 7 additions & 1 deletion pymc3/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,13 @@ def pandas_to_array(data):
XXX: When `data` is a generator, this will return a Theano tensor!
"""
if hasattr(data, "values"): # pandas
if isinstance(data, np.ndarray):
mask = np.isnan(data)
if np.any(mask):
ret = np.ma.MaskedArray(data, mask)
else:
ret = data
elif hasattr(data, "values"): # pandas
if data.isnull().any().any(): # missing values
ret = np.ma.MaskedArray(data.values, data.isnull().values)
else:
Expand Down

0 comments on commit c183d11

Please sign in to comment.