Skip to content

Scalar assignment issue#38

Merged
davidfee5 merged 2 commits into
masterfrom
scalar
Jul 3, 2026
Merged

Scalar assignment issue#38
davidfee5 merged 2 commits into
masterfrom
scalar

Conversation

@davidfee5

Copy link
Copy Markdown
Member

Recent versions of numpy treat the right-hand side of an assignment as a sequence/array instead of a clean scalar, so a few assignments were failing. The matrix operations are now explicitly scalar. This addresses #37.

Copilot AI review requested due to automatic review settings July 3, 2026 16:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes NumPy (newer versions) scalar-assignment incompatibilities in LTS post-processing/solving logic by ensuring certain matrix-expression results are converted to true Python scalars before being assigned into scalar array elements, addressing the ValueError: setting an array element with a sequence reported in #37.

Changes:

  • Convert sigma_tau[...] assignments to explicitly extract a scalar from the intermediate matrix product result before calling sqrt(...).
  • Convert conf_int_baz[...] / conf_int_vel[...] assignments to explicitly extract scalars from sig_theta / diff(...) expressions.
  • Minor formatting adjustment to the np.errstate(...) call.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +728 to +730
sigma_tau_value = tau[weights, jj, :].T @ residuals
sigma_tau_value = sigma_tau_value / (m_w - dimension_number)
sigma_tau[jj] = np.sqrt(float(np.asarray(sigma_tau_value).squeeze()))
Comment on lines +760 to +761
conf_int_baz[jj] = 0.5 * float(np.asarray(sig_theta).squeeze())
conf_int_vel[jj] = 0.5 * float(np.asarray(np.abs(np.diff(1 / eExtrm[:2]))).squeeze())
Comment on lines +938 to +943
sigma_tau_value = self.tau[:, jj, :].T @ residuals
sigma_tau_value = sigma_tau_value / (
self.co_array_num - self.dimension_number
)

self.sigma_tau[jj] = np.sqrt(float(np.asarray(sigma_tau_value).squeeze()))
Comment on lines +970 to +971
self.conf_int_baz[jj] = 0.5 * float(np.asarray(sig_theta).squeeze())
self.conf_int_vel[jj] = 0.5 * float(np.asarray(np.abs(np.diff(1 / eExtrm[:2]))).squeeze())
@davidfee5

Copy link
Copy Markdown
Member Author

Thanks copilot! ;) I think these are just cosmetic and informational, so am going to keep what I have and just merge.

@davidfee5
davidfee5 merged commit 992c308 into master Jul 3, 2026
1 check passed
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