Skip to content

Commit

Permalink
Add tests for sign
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed Aug 11, 2024
1 parent 58a2e6b commit 2d8a88f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,20 @@ def test_min_max(self):
with self.assertRaises(ValueError):
alg.minmax([])

def test_sign(self):
"""Test sign."""

self.assertEqual(alg.sign(-3), -1)
self.assertEqual(alg.sign(3), 1)
self.assertEqual(alg.sign(-0.0), -0.0)
self.assertEqual(math.copysign(1, alg.sign(-0.0)), -1.0)
self.assertEqual(alg.sign(0.0), 0.0)
self.assertEqual(math.copysign(1, alg.sign(0.0)), 1.0)
self.assertTrue(math.isnan(alg.sign(math.nan)))
self.assertEqual(math.copysign(1, alg.sign(-math.nan)), -1)
self.assertTrue(math.isnan(alg.sign(-math.nan)))
self.assertEqual(math.copysign(1, alg.sign(math.nan)), 1)


def test_pprint(capsys):
"""Test matrix print."""
Expand Down

0 comments on commit 2d8a88f

Please sign in to comment.