Skip to content

Commit

Permalink
Merge pull request xarray-contrib#111 from bradyrx/fix_read_only
Browse files Browse the repository at this point in the history
  • Loading branch information
raybellwaves committed Jul 10, 2020
2 parents 8378ba9 + a37ed51 commit 6d463c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Internal Changes
- Add ``black``, ``flake8``, ``isort``, ``doc8`` and ``pre-commit`` for formatting
similar to ``climpred``. `Aaron Spring`_ and `Ray Bell`_

Bug Fixes
---------
- Avoid mutating inputted arrays when `skipna=True`. (:pr:`111`) `Riley X. Brady`_.
- Avoid read-only error that appeared due to not copying input arrays when dealing
with NaNs. (:pr:`111`) `Riley X. Brady`_.


xskillscore v0.0.15 (2020-03-24)
================================
Expand Down
2 changes: 2 additions & 0 deletions xskillscore/core/np_deterministic.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def _match_nans(a, b, weights):
pairwise locations.
"""
if np.isnan(a).any() or np.isnan(b).any():
# Avoids mutating original arrays and bypasses read-only issue.
a, b = a.copy(), b.copy()
# Find pairwise indices in a and b that have nans.
idx = np.logical_or(np.isnan(a), np.isnan(b))
a[idx], b[idx] = np.nan, np.nan
Expand Down

0 comments on commit 6d463c5

Please sign in to comment.