Skip to content

Support NumPy sign on physical quantities - #297

Open
CAOShurong wants to merge 1 commit into
python-quantities:masterfrom
CAOShurong:fix/dimensionless-sign
Open

CAOShurong wants to merge 1 commit into
python-quantities:masterfrom
CAOShurong:fix/dimensionless-sign

Conversation

@CAOShurong

Copy link
Copy Markdown
Contributor

Fixes #114.

np.sign(3 * pq.um) raises ValueError because the ufunc has no dimensionality rule. The sign of a measured value is dimensionless, so rescaling from millivolts to volts gives the same result. NumPy handles the magnitudes, including complex inputs. Uncertainty propagation for sign remains unsupported.

The regression tests cover scalar and array inputs, rescaling, complex values and out. The full suite passed with NumPy 2.3.5 and 2.5.5.

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.

ValueError: ufunc <ufunc 'sign'> not supported by quantities

1 participant