-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Implement unary operators for FloatingArray class #39916
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 17 commits
e40c3c6
9929bc4
1952467
5fdf667
de24336
853bc5d
6a3e07d
03801fc
1b9759d
bb77076
42e8cdf
957edc3
38c610b
eba6e04
be5eb84
9367b1b
3e67655
495ddb7
0162e07
7dda62d
41e42fc
cf2732a
3cc5212
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 |
---|---|---|
|
@@ -257,6 +257,15 @@ def __init__(self, values: np.ndarray, mask: np.ndarray, copy: bool = False): | |
) | ||
super().__init__(values, mask, copy=copy) | ||
|
||
def __neg__(self): | ||
return type(self)(-self._data, self._mask.copy()) | ||
|
||
def __pos__(self): | ||
return self | ||
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. shoulnt' this be the same? (e.g. self.copy()) to preserve semantics 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. @simonjayhawkins noted that we should be consistent with the
|
||
|
||
def __abs__(self): | ||
return type(self)(abs(self._data), self._mask.copy()) | ||
|
||
@classmethod | ||
def _from_sequence( | ||
cls, scalars, *, dtype=None, copy: bool = False | ||
|
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 think @simonjayhawkins already mentioned it as well, but can you move those definitions you added here to the base class
NumericArray
inarrays/numeric.py
instead?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've moved the operator definitions to
arrays/numeric.py