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

Support kwargs in partial objects passed to Initializer() #2960

Merged
merged 1 commit into from
Aug 21, 2023

Conversation

jsiirola
Copy link
Member

Fixes # .

Summary/Motivation:

@dallan-keylogic pointed out that Initializer() incorrectly maps functools.partial objects to IndexedCallInitializer when all the rule arguments are passed to functools.partial() as keyword arguments. This PR corrects this (and adds a test).

Changes proposed in this PR:

  • Initializer() should detect positional arguments specified as keyword arguments to partial()
  • Add a test of this behavior

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.

@jsiirola jsiirola changed the title Support kwargs in partial objects passed to Initializer Support kwargs in partial objects passed to Initializer() Aug 21, 2023
@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (99dc0f1) 87.83% compared to head (24170c2) 87.83%.
Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2960   +/-   ##
=======================================
  Coverage   87.83%   87.83%           
=======================================
  Files         770      770           
  Lines       89657    89660    +3     
=======================================
+ Hits        78747    78754    +7     
+ Misses      10910    10906    -4     
Flag Coverage Δ
linux 84.86% <100.00%> (-0.01%) ⬇️
osx 74.58% <100.00%> (+<0.01%) ⬆️
other 85.04% <100.00%> (+<0.01%) ⬆️
win 82.12% <100.00%> (+0.01%) ⬆️

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

Files Changed Coverage Δ
pyomo/core/base/initializer.py 98.71% <100.00%> (+0.01%) ⬆️

... and 3 files with indirect coverage changes

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

@jsiirola jsiirola merged commit c569b78 into Pyomo:main Aug 21, 2023
30 checks passed
@jsiirola jsiirola deleted the initializer-partial=kwargs branch August 21, 2023 17:06
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.

2 participants