-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REF: avoid broadcasting of Series to DataFrame in ops for ArrayManager #40482
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 all commits
c4194e9
120010a
5816485
c59d85e
3f64e43
f53bf76
60822ce
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 |
---|---|---|
|
@@ -7061,8 +7061,11 @@ def _dispatch_frame_op(self, right, func: Callable, axis: int | None = None): | |
assert right.index.equals(self.columns) | ||
|
||
right = right._values | ||
# maybe_align_as_frame ensures we do not have an ndarray here | ||
assert not isinstance(right, np.ndarray) | ||
# BlockManager only: maybe_align_as_frame ensures we do not have | ||
# an ndarray here (`assert not isinstance(right, np.ndarray)`) | ||
|
||
if isinstance(right, TimedeltaArray): | ||
right = right._data | ||
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.
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.
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. See #40482 (comment) for the general explanation of in which case this happens. It was not my intention to keep this, I am hoping to find a better solution. 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. Yah I saw that, thought about commenting, but decided that "last time i handled that by reshaping to 2D" wouldn't be something you'd find that helpful. |
||
|
||
with np.errstate(all="ignore"): | ||
arrays = [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,7 +120,10 @@ def _masked_arith_op(x: np.ndarray, y, op): | |
|
||
# mask is only meaningful for x | ||
result = np.empty(x.size, dtype=x.dtype) | ||
mask = notna(xrav) | ||
if isna(y): | ||
mask = np.zeros(x.size, dtype=bool) | ||
else: | ||
mask = notna(xrav) | ||
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 is just an optimization, independent of the broadcasting thing? |
||
|
||
# 1 ** np.nan is 1. So we have to unmask those. | ||
if op is pow: | ||
|
@@ -309,6 +312,7 @@ def na_logical_op(x: np.ndarray, y, op): | |
y = ensure_object(y) | ||
result = libops.vec_binop(x.ravel(), y.ravel(), op) | ||
else: | ||
x = ensure_object(x) | ||
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. if we're doing this both here and on L293, then might as well do it just once after L289 Do we have cases that get here with x not object dtype? |
||
# let null fall thru | ||
assert lib.is_scalar(y) | ||
if not isna(y): | ||
|
Uh oh!
There was an error while loading. Please reload this page.