Skip to content

Fix type of dividing by GenericAffExpr with no terms - #4263

Closed
odow wants to merge 2 commits into
masterfrom
od/fix-divide-affexpr
Closed

odow wants to merge 2 commits into
masterfrom
od/fix-divide-affexpr

Conversation

@odow

@odow odow commented Sep 28, 2026

Copy link
Copy Markdown
Member

Replacement for #4262

Co-authored-by: acostarelli <acostarelli@users.noreply.github.com>
@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.95%. Comparing base (00f9391) to head (c0543c1).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4263   +/-   ##
=======================================
  Coverage   99.95%   99.95%           
=======================================
  Files          43       43           
  Lines        6333     6346   +13     
=======================================
+ Hits         6330     6343   +13     
  Misses          3        3           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/nlp_expr.jl

function Base.:/(x::_Constant, y::GenericAffExpr)
if all(iszero, values(y.terms))
return x / y.constant

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is maybe a bit inconsistent with other operations. For instance, when we multiply two affine expression together, we always create a quadratic one, we don't check whether one of them is a constant. So I feel it should be the same here, we should always create a nonlinear one and the user can convert it to constant if needed.

@odow

odow commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

Closing because, on reflection, I agree with @blegat.

@acostarelli you should change your code to not divide by an AffExpr.

@odow odow closed this Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants