Skip to content

Fix energy_correction wavelength shape bug#957

Open
psavery wants to merge 3 commits into
masterfrom
fix-energy-correction-wavelength-shape
Open

Fix energy_correction wavelength shape bug#957
psavery wants to merge 3 commits into
masterfrom
fix-energy-correction-wavelength-shape

Conversation

@psavery

@psavery psavery commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Overview

This issue only occurs when a wavelength correction was being applied, via the beam energy correction features.

objFuncFitGrain reshapes tVec_c to (3, 1), so tvec_c[ind] (and tvec_s[ind]) returned a length-1 array rather than a scalar. That made the corrected wavelength a (1,) array, which oscill_angles_of_hkls interpreted as a per-reflection wavelength array (1 value vs N hkls), producing NaN angles and a spurious "Infeasible parameters for hkls" RuntimeError whenever energy_correction was set (even with slope=0). Ravel tvec_c/tvec_s so position is a scalar and the corrected wavelength keeps the input's dimensionality.

Affected Workflows

HEDM

Documentation Changes

None

psavery added 3 commits July 2, 2026 12:33
…elength

This issue only uccrs when a wavelength correction was being applied,
via the beam energy correction features.

objFuncFitGrain reshapes tVec_c to (3, 1), so tvec_c[ind] (and tvec_s[ind])
returned a length-1 array rather than a scalar. That made the corrected
wavelength a (1,) array, which oscill_angles_of_hkls interpreted as a
per-reflection wavelength array (1 value vs N hkls), producing NaN angles and
a spurious "Infeasible parameters for hkls" RuntimeError whenever
energy_correction was set (even with slope=0). Ravel tvec_c/tvec_s so position
is a scalar and the corrected wavelength keeps the input's dimensionality.

Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
getHKLID may return a list, so `active_hklIDs == input_hklID` is a scalar that
np.where() rejects. Wrap it in np.asarray.

Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
apply_correction_to_wavelength now np.ravel()s tvec_s, so the env fixture must
provide a real instr.tvec (np.zeros(3)); a bare MagicMock ravels to an empty
array -> IndexError.

Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.55%. Comparing base (147c547) to head (2c286ef).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #957   +/-   ##
=======================================
  Coverage   73.55%   73.55%           
=======================================
  Files         148      148           
  Lines       22915    22915           
=======================================
  Hits        16855    16855           
  Misses       6060     6060           

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

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