-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
Encode/Decode complex fill values #363
Changes from all commits
81368f6
bcc9dea
c71b9cc
a574bea
134f30c
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 |
---|---|---|
|
@@ -977,6 +977,15 @@ def test_dtypes(self): | |
z[:] = a | ||
assert_array_almost_equal(a, z[:]) | ||
|
||
# complex | ||
for dtype in 'c8', 'c16': | ||
z = self.create_array(shape=10, chunks=3, dtype=dtype) | ||
assert z.dtype == np.dtype(dtype) | ||
a = np.linspace(0, 1, z.shape[0], dtype=dtype) | ||
a -= 1j * a | ||
z[:] = a | ||
assert_array_almost_equal(a, z[:]) | ||
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. Given the special treatment required for fill values, would it make sense to add an explicit check that complex data with missing values is handled correctly? I see that the metadata encoding is checked below, but not the actual filling procedure (as far as I can tell). 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. Could you please elaborate a bit on what kind of representation of missing data we are discussing? We handle 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. What I mean is to make sure that missing data (the kind that triggers the a[0] = np.nan However, I might be misunderstanding what 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. AFAIK Edit: IOW this |
||
|
||
# datetime, timedelta | ||
for base_type in 'Mm': | ||
for resolution in 'D', 'us', 'ns': | ||
|
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.
I take it this encoding / decoding of fill values is necessary is necessary because json does not support serialization of complex data types?
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.
That's right.
This will encode to a JSON list, which is nice for readability. Though we could certainly imagine other ways of handling this (e.g. base64 encoded string).
Any preferences?
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.
That seems totally reasonable.