Skip to content

Extract single element of array before declaring amplitude of adjoint source#3129

Merged
oskooi merged 1 commit intoNanoComp:masterfrom
oskooi:amplitude_numpy_array_fix
Dec 24, 2025
Merged

Extract single element of array before declaring amplitude of adjoint source#3129
oskooi merged 1 commit intoNanoComp:masterfrom
oskooi:amplitude_numpy_array_fix

Conversation

@oskooi
Copy link
Collaborator

@oskooi oskooi commented Dec 24, 2025

A unit test for the adjoint solver (test_two_objfunc of test_adjoint_solver.py) recently started failing during CI for Python 3.11 due to the following line:

self.amplitude = complex(amplitude)

The error is triggered when amplitude is passed to the Source constructor as a Numpy array with a single element. Python's complex function supports 0-dimensional Numpy arrays. The fix simply involves extracting the element of the array before applying the complex function.

(It is not clear why this error was triggered recently and only for Python 3.11.)

@oskooi oskooi added the bug label Dec 24, 2025
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.90%. Comparing base (f29a8c7) to head (bb8e21e).
⚠️ Report is 98 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3129      +/-   ##
==========================================
+ Coverage   73.81%   73.90%   +0.09%     
==========================================
  Files          18       18              
  Lines        5423     5454      +31     
==========================================
+ Hits         4003     4031      +28     
- Misses       1420     1423       +3     
Files with missing lines Coverage Δ
python/source.py 94.11% <100.00%> (+0.03%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oskooi oskooi merged commit 84d0700 into NanoComp:master Dec 24, 2025
5 checks passed
@oskooi oskooi deleted the amplitude_numpy_array_fix branch December 24, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants