Skip to content

[NumericalOperator] Addition, subtraction, multiplication and division: numpy backend (#61)#69

Closed
ArthurPendragn wants to merge 1 commit into
deem-data:mainfrom
ArthurPendragn:numericalOperator-61
Closed

[NumericalOperator] Addition, subtraction, multiplication and division: numpy backend (#61)#69
ArthurPendragn wants to merge 1 commit into
deem-data:mainfrom
ArthurPendragn:numericalOperator-61

Conversation

@ArthurPendragn
Copy link
Copy Markdown
Contributor

[NumericalOperator] Addition, subtraction, multiplication and division: numpy backend (#61)

  • New ops: ADD, SUBTRACT, MULTIPLY, DIVIDE added to NumericOpType + dispatch
  • Binary extraction: BinOp(+, -, *, /) and CallOp(np.add, np.subtract, np.multiply, np.divide) canonicalize to typed NumericOp with a constant and a reversed flag
  • reversed flag: tracks operand order for asymmetric ops (e.g. 3 - df, 12 / df)
  • Guard against var-op-var: _is_binary_extractable ensures extraction is skipped when both args are DataOp placeholders
  • New tests: process, extraction, round-trip correctness, and var-var guard for all four ops

Closes #61

…n: numpy backend (deem-data#61)

 - New ops: ADD, SUBTRACT, MULTIPLY, DIVIDE added to NumericOpType + dispatch
 - Binary extraction: BinOp(+, -, *, /) and CallOp(np.add, np.subtract, np.multiply, np.divide) canonicalize to typed NumericOp with a constant and a reversed flag
 - reversed flag: tracks operand order for asymmetric ops (e.g. 3 - df, 12 / df)
 - Guard against var-op-var: _is_binary_extractable ensures extraction is skipped when both args are DataOp placeholders
 - New tests: process, extraction, round-trip correctness, and var-var guard for all four ops
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 75.67568% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
stratum/optimizer/ir/_numeric_ops.py 73.52% 11 Missing and 7 partials ⚠️
Flag Coverage Δ
unittests 91.73% <75.67%> (-0.60%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
stratum/optimizer/ir/_ops.py 98.26% <100.00%> (-0.25%) ⬇️
stratum/runtime/_object_size.py 100.00% <100.00%> (ø)
stratum/optimizer/ir/_numeric_ops.py 84.28% <73.52%> (-10.66%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@e-strauss e-strauss closed this in cda04c1 May 20, 2026
@e-strauss
Copy link
Copy Markdown
Collaborator

@ArthurPendragn thanks for the implementation of these binary operators. I merged in your commit together with another commit which adds support for var-op-var , which eliminates the need for the guard and increases the code coverage.

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.

[NumericalOperator] Addition, subtraction, multiplication and division: numpy backend

2 participants