Skip to content

Preserve MicroSeries weights in NumPy operations and reverse divmod - #323

Merged
juaristi22 merged 4 commits into
mainfrom
fix/ufunc-divmod-weights
Sep 17, 2026
Merged

juaristi22 merged 4 commits into
mainfrom
fix/ufunc-divmod-weights

Conversation

@juaristi22

@juaristi22 juaristi22 commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Binary NumPy operations with a pandas Series now preserve aligned, independent MicroSeries weights, and both results of divmod(Series, MicroSeries) retain their weights. For the examples in #322, weighted sums are 204 for maximum, 22 for the quotient and 15 for the remainder.

The handler preserves pandas values, names, index order, attributes and errors, and rejects rows whose weights cannot be identified. Calls with higher-priority Series subclasses that inherit pandas' handler complete in both operand orders, including explicit output buffers. Reordered inputs preserve pandas' output order so positional masks write to the same rows. Distinct custom ufunc handlers continue to receive delegated calls.

Operations that would introduce unknown or ambiguous row weights now reject the result before writing explicit output buffers. This preserves the caller's values and any separate output buffer when validation fails, including when the output aliases the weighted input. Valid reordered and masked outputs retain pandas' behavior.

Validation after rebasing onto main with merged #320 and #321: 835 full-suite tests and 621 affected tests pass on each of pandas 2.3.1 and 3.0.5. Eighteen additional regression cases cover rejection before writes, valid aliased outputs and custom-handler delegation. Independent verification passes 38 rejection/output checks and 58 dispatch checks per environment.

The final commit also passes 58 callback/output acceptance cases, 35 prior repair cases and 180 exact-arithmetic interaction cases per environment. These include replicate callbacks that catch a rejected NumPy call and continue calculating, preserving the expected variance of 121 and standard error of 11.

Closes #322.

@juaristi22
juaristi22 marked this pull request as ready for review September 17, 2026 08:52
@juaristi22
juaristi22 force-pushed the fix/ufunc-divmod-weights branch from b9694bc to 1ea0557 Compare September 17, 2026 10:48
@juaristi22
juaristi22 merged commit 0094eec into main Sep 17, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve MicroSeries weights in np.maximum and plain-Series-left divmod

1 participant