-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Keep attrs in call to astype #2070
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
Conversation
gajomi
commented
Apr 21, 2018
- Possible route to close Keeping attributes when using DataArray.astype #2049 (discussion needed on strategy with variable, docstrings)
- Tests added (for all bug fixes or enhancements)
- Tests passed (for all non-documentation changes)
self.data = duck_array_ops.astype(self.data, | ||
dtype, | ||
casting = casting, | ||
copy = copy) |
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.
E251 unexpected spaces around keyword / parameter equals
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.
thanks @gajomi!
@@ -1458,6 +1458,10 @@ def test_array_interface(self): | |||
bar = Variable(['x', 'y'], np.zeros((10, 20))) | |||
assert_equal(self.dv, np.maximum(self.dv, bar)) | |||
|
|||
def test_astype_attrs(self): | |||
mda = self.mda.astype(bool) |
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.
It would be good to test the datatype converting behavior of astype()
here, too, at least with a few minimal cases. I don't know if we have test coverage for this already.
Hey @gajomi, do you have time to pick this back up? Looks like it just needs a few small changes. |
If anyone would like to pick this up (@gajomi if you're still around!), please do; it's very close and would be a welcome addition |
Oh my... It's been some time since I have logged in to github... I will have to take a look at this over the weekend to see if I can remember where I was on this PR |
Just ran into this issue. If it's really just a matter of expanding tests and resolving conflicts of @gajomi's PR to the current codebase I can take this on, but I don't want to take their credit. Is there an easy way for a non-owner to modify a PR or should I submit a new one? |
Hi @dnowacki-usgs. Feel free to take all the credit! I have ended up swamped at work the last few months and just haven't had the time to get back into this yet. I am guessing easiest way to move forward would be to fork my last commit and open up a new pull request. |
* Recreate @gajomi's #2070 to keep attrs when calling astype() * Accept keep_attrs flag, use apply_ufunc in variable.py, expand tests * Ignore casting if we get a TypeError (indicates sparse <= 0.10.0) * add to whats new * fix dtype test * improve error handling and check if sparse array * test and docstring updates * catch sparse error a bit more elegantly * check using sparse_array_type Co-authored-by: Keewis <[email protected]>