Skip to content

Conversation

@jokasimr
Copy link
Contributor

@jokasimr jokasimr commented Dec 12, 2025

This PR makes some unit conversions safer by explicitly casting their dtypes.

This is important when converting quantities that are provided by users because if the user provides a value with integer dtype the result of the unit conversion can be unexpected.

For example, if the user provides a SampleRotationOffset: sc.scalar(1, unit='deg') and we convert that to rad then after the conversion the value will be 0 rad. By converting the dtype to whatever the SampleRotation dtype is (almost certainly float) we avoid the error.

This doesn't solve the problem completely, because strictly speaking we don't distinguish between user provided parameters and non-user provided parameters, but it should prevent errors in most common cases.

Should be rebased on main once #186 is merged.

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.

2 participants