-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
ENH: implement FloatingArray.round() #38866
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
Changes from 1 commit
1df9bf7 192ebad 6403026 253d279 3e0d605 fe19597 b557a50 85e6d4f f79c0cd d1cd6d8 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -130,3 +130,14 @@ def _arith_method(self, other, op): | |
| ) | ||
| | ||
| return self._maybe_mask_result(result, mask, other, op_name) | ||
| | ||
| def _apply(self, func, **kwargs): | ||
| values = self._data[~self._mask] | ||
| Member 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. I don't think you actually need to subset the Of course, if many values are masked, we might be calculating | ||
| values = np.round(values, **kwargs) | ||
| Contributor 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. should be func :-> | ||
| | ||
| data = np.zeros(self._data.shape) | ||
| data[~self._mask] = values | ||
| return type(self)(data, self._mask) | ||
| Member 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. The mask needs to be copied I think? (result should not share a mask with the original array, because otherwise editing one can modify the other. We should probably also test this) Contributor Author 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. That's a good point (and actually the same bug exists already in my implementation of | ||
| | ||
| def round(self, decimals=0): | ||
| return self._apply(np.round, decimals=decimals) | ||
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.
can you add a doc-string