Skip to content

Preserve aligned Series weights and isolate reset-index weights - #321

Merged
juaristi22 merged 1 commit into
mainfrom
fix/weighted-operation-metadata
Sep 17, 2026
Merged

juaristi22 merged 1 commit into
mainfrom
fix/weighted-operation-metadata

Conversation

@juaristi22

Copy link
Copy Markdown
Collaborator

MicroSeries binary operations now retain weights with their row labels when pandas aligns operands. For values [10, 20], labels ['b', 'a'], and weights [1, 9], adding values [2, 1] at labels ['a', 'b'] now produces the weighted total 22 * 9 + 11 * 1 = 209; the operators previously returned 121 by reapplying weights positionally. Named arithmetic and comparison methods consistently use the calling MicroSeries' weights across pandas 2 and 3. Explicit reverse dispatch preserves weighted results when a plain pandas Series appears on the left.

MicroDataFrame.reset_index now copies weight storage on pandas 2, so changing a result's weights cannot change its source's weighted statistics. Regression tests cover both mutation directions, drop and in-place variants, and partial MultiIndex resets. Existing safeguards continue to reject unknown or ambiguous row weights.

Validation:

  • Full suite: 543 tests passed on pandas 2.3.1 and pandas 3.0.5.
  • Independent verification: 53 focused checks passed in each environment.
  • After formatting: 157 binary-operation tests passed in each environment; executable syntax unchanged.
  • Combined with Estimate variance from replicate weights #320 at commit 058f8db: 593 full-suite tests and 30 interaction tests passed in each environment.
  • make lint and the towncrier draft passed.

Related #170. A warning for mismatched input weights remains a separate enhancement.

@juaristi22
juaristi22 marked this pull request as ready for review September 16, 2026 12:54
@juaristi22
juaristi22 merged commit e2de85a 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.

1 participant