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

Pass args and kwargs to Hessian of objective function #176

Closed
wants to merge 4 commits into from

Conversation

ForceBru
Copy link

  • Now args and kwargs are passed to the Hessian of the objective function. This should fix Objective function not passed extra arguments when Hessian is provided #175.
  • Implemented integration tests to ensure that args and kwargs are passed to the objective, Jacobian and Hessian.
  • Also fixed minor typo in raise ImportError() without a msg and hopefully clarified some error messages.

Comment on lines 121 to 123
raise NotImplementedError(
'jac has to be bool or a function (got {!r})'.format(type(jac))
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

As CyIpopt is now Python>=3.7 can we please make the f-strings instead of using .format()?

Comment on lines 151 to 153
raise NotImplementedError(
'jac of constraints has to be bool or a function (got {!r})'.format(type(con_jac))
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

f-string please.

@@ -270,6 +274,7 @@ def get_constraint_dimensions(constraints, x0):


def get_constraint_bounds(constraints, x0, INF=1e19):
TYPE_EQ, TYPE_INEQ = 'eq', 'ineq'
Copy link
Collaborator

Choose a reason for hiding this comment

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

While this use of tuple unpacking is clever, I personally don't think it's the clearest to read. Can we please split to two assignments over two lines.

Comment on lines 293 to 296
msg = "Invalid constraint type: {!r}. Valid types are {}."
raise ValueError(
msg.format(con['type'], (TYPE_EQ, TYPE_INEQ))
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

f-string please.

Copy link
Collaborator

@brocksam brocksam left a comment

Choose a reason for hiding this comment

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

Great addition, thank you. Especially appreciate the addition of tests for this. To try and keep the code as tidy as possible, please can we try to adhere to PEP8 formatting, particularly separation of top level function and class definitions by two blank lines.

@brocksam
Copy link
Collaborator

Currently blocked by #177.

@moorepants
Copy link
Collaborator

Can you merge in master here so the tests run in CI?

@moorepants
Copy link
Collaborator

Thanks for this @ForceBru. I ended up fixing this more extensively in #197. I'm going to close this one. If you want to bring in any other of the changes you propose here, please open a new PR. Sorry for working in parallel on this, I didn't remember your work when I did mine.

@moorepants moorepants closed this Apr 6, 2023
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.

Objective function not passed extra arguments when Hessian is provided
3 participants