Skip to content

Commit

Permalink
fix(test_truncate): add test to make sure negative values are correct…
Browse files Browse the repository at this point in the history
…ly truncated with relative precision
  • Loading branch information
ljgray committed Dec 18, 2024
1 parent f8d4956 commit d86f62c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_truncate.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,19 @@ def test_truncate_relative():
)
== np.asarray([32, 32], dtype=np.float64)
).all()

# Check the case where values are negative
assert (
truncate.bit_truncate_relative(
np.asarray([-32.121, 32.5], dtype=np.float32),
0.1,
)
== np.asarray([-32, 32], dtype=np.float32)
).all()
assert (
truncate.bit_truncate_relative(
np.asarray([-32.121, 32.5], dtype=np.float64),
0.1,
)
== np.asarray([-32, 32], dtype=np.float64)
).all()

0 comments on commit d86f62c

Please sign in to comment.