-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
ENH: change object-array comparisons to prefer OO->O unfuncs #14800
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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -172,10 +172,11 @@ def test_normal_types(self): | |||||
# (warning is issued a couple of times here) | ||||||
self.assert_deprecated(op, args=(a, a[:-1]), num=None) | ||||||
|
||||||
# Element comparison error (numpy array can't be compared). | ||||||
# ragged array comparison returns True/False | ||||||
a = np.array([1, np.array([1,2,3])], dtype=object) | ||||||
b = np.array([1, np.array([1,2,3])], dtype=object) | ||||||
self.assert_deprecated(op, args=(a, b), num=None) | ||||||
res = op(a, b) | ||||||
assert res.dtype == 'object' | ||||||
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 now returns an object array instead of deprecating. 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.
Suggested change
|
||||||
|
||||||
def test_string(self): | ||||||
# For two string arrays, strings always raised the broadcasting error: | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,7 +99,7 @@ def _replace_nan(a, val): | |
|
||
if a.dtype == np.object_: | ||
# object arrays do not support `isnan` (gh-9009), so make a guess | ||
mask = a != a | ||
mask = (a != a).astype(bool) | ||
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. xref gh-14802 |
||
elif issubclass(a.dtype.type, np.inexact): | ||
mask = np.isnan(a) | ||
else: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4790,7 +4790,11 @@ def all(self, axis=None, out=None, keepdims=np._NoValue): | |
|
||
mask = _check_mask_axis(self._mask, axis, **kwargs) | ||
if out is None: | ||
d = self.filled(True).all(axis=axis, **kwargs).view(type(self)) | ||
r = self.filled(True).all(axis=axis, **kwargs) | ||
if isinstance(r, bool): | ||
d = type(self)(r) | ||
else: | ||
d = r.view(type(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. since 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. Alternatively, could pass |
||
if d.ndim: | ||
d.__setmask__(mask) | ||
elif mask: | ||
|
Uh oh!
There was an error while loading. Please reload this page.