Skip to content

Conversation

@jsiirola
Copy link
Member

Fixes #2374 .

Summary/Motivation:

This resolves issues where Initializer did not correctly identify all functions (notably cythonized functions). This updates the logic for processing initialization functions and expands the Initializer() unit tests.

Changes proposed in this PR:

  • Correctly detect cythonized functions as callable functions
  • update Initializer unit tests
  • Fix issue in pyomo.core.__init__.py that was preventing the import of pyomo.core.util

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 May 24, 2022

Codecov Report

Merging #2421 (afca676) into main (622cf52) will increase coverage by 0.00%.
The diff coverage is 88.88%.

@@           Coverage Diff           @@
##             main    #2421   +/-   ##
=======================================
  Coverage   85.89%   85.90%           
=======================================
  Files         617      617           
  Lines       76198    76204    +6     
=======================================
+ Hits        65453    65465   +12     
+ Misses      10745    10739    -6     
Flag Coverage Δ
linux 82.64% <88.88%> (+<0.01%) ⬆️
osx 72.87% <88.88%> (+<0.01%) ⬆️
other 82.83% <88.88%> (+<0.01%) ⬆️
win 79.65% <88.88%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
pyomo/core/__init__.py 100.00% <ø> (ø)
pyomo/core/base/initializer.py 99.50% <88.88%> (+0.01%) ⬆️
examples/pyomobook/test_book_examples.py 96.80% <0.00%> (+0.79%) ⬆️
pyomo/opt/results/container.py 75.75% <0.00%> (+0.90%) ⬆️
pyomo/common/getGSL.py 66.66% <0.00%> (+3.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 622cf52...afca676. Read the comment docs.

try:
_args = inspect.getfullargspec(init.func)
except:
# Inspect doesn't work for some built-in callables (notably
Copy link
Contributor

Choose a reason for hiding this comment

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

Does one of the new tests check against this assumption?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes: test_initializer.py:531 (test_no_argspec)

@jsiirola jsiirola requested a review from mrmundt May 26, 2022 12:22
@mrmundt mrmundt merged commit 5c94188 into Pyomo:main May 26, 2022
@jsiirola jsiirola deleted the initializer-with-cython branch May 27, 2022 14:33
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.

Support cython function to initialize set

2 participants