Skip to content
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

Bug fix for conflict between dask array and np.where #144

Merged
merged 1 commit into from
Jan 10, 2024
Merged
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
10 changes: 8 additions & 2 deletions lib/eofs/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ def __init__(self, dataset, weights=None, center=True, ddof=1):
if not self._valid_nan(self._data):
raise ValueError('missing values detected in different '
'locations at different times')
nonMissingIndex = np.where(np.logical_not(np.isnan(self._data[0])))[0]
if has_dask:
nonMissingIndex = dask.array.where(np.logical_not(np.isnan(self._data[0])))[0]
else:
nonMissingIndex = np.where(np.logical_not(np.isnan(self._data[0])))[0]
# Remove missing values from the design matrix.
dataNoMissing = self._data[:, nonMissingIndex]
if dataNoMissing.size == 0:
Expand Down Expand Up @@ -741,7 +744,10 @@ def projectField(self, field, neofs=None, eofscaling=0, weighted=True):
if not self._valid_nan(field_flat):
raise ValueError('missing values detected in different '
'locations at different times')
nonMissingIndex = np.where(np.logical_not(np.isnan(field_flat[0])))[0]
if has_dask:
nonMissingIndex = dask.array.where(np.logical_not(np.isnan(self._data[0])))[0] # lee1043 testing
else:
nonMissingIndex = np.where(np.logical_not(np.isnan(field_flat[0])))[0]
try:
# Compute chunk sizes if nonMissingIndex is a dask array, so its
# shape can be compared with eofsNonMissingIndex later.
Expand Down
Loading