Skip to content

scipp.mod ignores the divisor's units #3402

@g5t

Description

@g5t

The modulus operation is the remainder after floor division and should therefore require compatible units between its dividend and divisor.

For values with compatible units

import scipp
dividend = scipp.scalar(168666898, unit='ns')
divisor = 1 / (14.0 * scipp.Unit('Hz'))

print(f'{dividend % divisor = :c}')

I would expect the modulus to 'just work', but instead the result is dividend % divisor = 0.0 ns

Forcing the values to have the same units produces the expected result

dividend % divisor.to(unit="ms") = 40.857142865657806 ns

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions