Skip to content

Fix NumPy-safe coefficient checks - #14

Open
rogeriojorge wants to merge 1 commit into
mainfrom
fix/d-over-curvature-empty-check
Open

rogeriojorge wants to merge 1 commit into
mainfrom
fix/d-over-curvature-empty-check

Conversation

@rogeriojorge

Copy link
Copy Markdown
Owner

Summary

  • replace empty-list equality checks for coefficient sequences with length-based checks that also work for NumPy arrays
  • fix the three accidental comparison expressions that prevented d_over_curvature_cvals from being assigned
  • initialize or pad the automatic second-order coefficients before building the optimization parameter list, without adding duplicate parameters
  • add regression coverage for set_dofs(), scalar initialization, automatic construction, padding, and NumPy coefficient inputs

Root cause

get_dofs() returns a NumPy vector, and set_dofs() assigns slices of that vector back to coefficient attributes. A subsequent calculation then evaluated expressions such as self.d_over_curvature_cvals == [], which attempt incompatible elementwise broadcasting for a non-empty NumPy array.

The assignment typos in Qic.__init__() and construct_qi_r2() also meant that generated coefficient arrays were silently discarded.

Testing

  • python -m unittest -v qic.tests.test_d_over_curvature on Python 3.11: 5 passed
  • python -m unittest -v qic.tests.test_d_over_curvature on Python 3.12 with NumPy 2.5.2: 5 passed
  • exact issue reproducer: passes and preserves both coefficients and d
  • documented first construct_qi_r2() path: completes as order r2 with B2cQI_deviation_max = 3.2580160791439994e-10
  • full headless suite: 35 tests run with the same three pre-existing numerical-reference failures and one missing-mpi4py import error seen on pristine main; no new failures

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.

1 participant