-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix decode cf with dask #2047
Fix decode cf with dask #2047
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
|
||
from . import ( | ||
IndexerMaker, TestCase, assert_array_equal, raises_regex, requires_netCDF4, | ||
requires_netcdftime, unittest) | ||
requires_netcdftime, unittest, requires_dask) | ||
from .test_backends import CFEncodedDataTest | ||
|
||
B = IndexerMaker(indexing.BasicIndexer) | ||
|
@@ -332,6 +332,17 @@ def test_decode_cf_datetime_transition_to_invalid(self): | |
|
||
assert_array_equal(ds_decoded.time.values, expected) | ||
|
||
@requires_dask | ||
def test_decode_cf_with_dask(self): | ||
import dask | ||
original = Dataset({ | ||
't': ('t', [0, 1, 2], {'units': 'days since 2000-01-01'}), | ||
'foo': ('t', [0, 0, 0], {'coordinates': 'y', 'units': 'bar'}), | ||
'y': ('t', [5, 10, -999], {'_FillValue': -999}) | ||
}).chunk({'t': 1}) | ||
decoded = conventions.decode_cf(original) | ||
assert dask.is_dask_collection(decoded.y.data) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this an appropriate place to test for this? There is no other dask stuff in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a fine place to me. |
||
|
||
|
||
class CFEncodedInMemoryStore(WritableCFDataStore, InMemoryDataStore): | ||
pass | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the offending line which caused the dask arrays to stop being dask arrays. I have simply bypassed it for dask arrays. This didn't break any tests. But can we think of any unforeseen negative consequences? What does
LazilyOuterIndexedArray
do here? I have to admit that I don't understand the details of our new indexing wrappers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LazilyOuterIndexedArray
makes indexing on non-dask arrays lazy. It's not necessary or useful for dask arrays.