Skip to content

Add optimization test with FD derivatives#487

Open
ewu63 wants to merge 16 commits into
mainfrom
add-opt-FD-test
Open

Add optimization test with FD derivatives#487
ewu63 wants to merge 16 commits into
mainfrom
add-opt-FD-test

Conversation

@ewu63

@ewu63 ewu63 commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Purpose

Addresses part of #256.

Expected time until merged

A few days.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (non-backwards-compatible fix or feature)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Documentation update
  • Maintenance update
  • Other (please describe)

Testing

Checklist

  • I have run ruff check and ruff format to make sure the Python code adheres to PEP-8 and is consistently formatted
  • I have formatted the Fortran code with fprettify or C/C++ code with clang-format as applicable
  • I have run unit and regression tests which pass locally with my changes
  • I have added new tests that prove my fix is effective or that my feature works
  • I have added necessary documentation

@ewu63
ewu63 requested a review from marcomangano as a code owner June 16, 2026 05:51
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 78 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.22%. Comparing base (20cfa02) to head (55b30c0).

Files with missing lines Patch % Lines
tests/test_optProb.py 0.00% 78 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #487       +/-   ##
===========================================
- Coverage   82.99%   54.22%   -28.78%     
===========================================
  Files           1        1               
  Lines         147      225       +78     
===========================================
  Hits          122      122               
- Misses         25      103       +78     

☔ 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.

@marcomangano

Copy link
Copy Markdown
Collaborator

Which one should be merged first between this PR and #486 ? Both add the same two new files, does it make sense attach them to one PR over the other?

@ewu63

ewu63 commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

This is on top of #486, let's wait for that one first.

@marcomangano
marcomangano requested a review from A-CGray July 2, 2026 16:51

@A-CGray A-CGray left a comment

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.

Same overall comment as #486, can you add docstrings for new tests explaining what they are testing?

Also, is there a preferred order in which we should merge this and #486 ?

Comment on lines +48 to +51
# Complex step divides by the imaginary part of the step, so a purely
# real step would silently yield NaN gradients.
if self.sensType == "cs" and np.imag(self.sensStep) == 0:
raise ValueError(f"The complex step size must have a nonzero imaginary part, got {self.sensStep}.")

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.

The docstring says that sensStep is the step size, and should be a float. So we need to either

  1. Update the docstring
  2. Change the implementation so that we take in a float and do self.sensStep = 1j * sensStep when using complex-step

Option 2 would be my slight preference.

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.

Also, if we keep the implementation as is and update the docstring, shouldn't we also check that sensStep is purely imaginary (i.e np.real(self.sensStep) == 0?)

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.

3 participants