Skip to content
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

Fix differentiation of Expressions containing native_numeric_types #3017

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

jsiirola
Copy link
Member

Fixes #2986

Summary/Motivation:

Recently, Pyomo changed the Expression object API so that .expr would always return a class derived from NumericValue, but not necessarily the same object each time it was called. As a result, walkers that key off the expression child need to use .arg(0) and not .expr. This PR resolves that bug in the Pyomo reverse_ad walker.

Changes proposed in this PR:

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (4267cbd) 87.92% compared to head (4c13589) 86.72%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3017      +/-   ##
==========================================
- Coverage   87.92%   86.72%   -1.20%     
==========================================
  Files         769      769              
  Lines       89538    89538              
==========================================
- Hits        78727    77654    -1073     
- Misses      10811    11884    +1073     
Flag Coverage Δ
linux 83.98% <100.00%> (-1.20%) ⬇️
osx 74.97% <100.00%> (ø)
other 84.16% <100.00%> (-1.20%) ⬇️
win 82.40% <100.00%> (ø)

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

Files Coverage Δ
pyomo/core/expr/calculus/diff_with_pyomo.py 98.97% <100.00%> (ø)

... and 13 files with indirect coverage changes

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

@jsiirola jsiirola merged commit 12be54c into Pyomo:main Oct 20, 2023
29 of 30 checks passed
@jsiirola jsiirola deleted the ad-named-expr branch October 20, 2023 19:00
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.

Pyomo AD fails with constant Expressions
2 participants