Remainder negative numerator bug fixed (#641)

Co-authored-by: Angelos Katharopoulos <a_katharopoulos@apple.com>
This commit is contained in:
Abdussamet Türker
2024-02-10 03:49:14 +03:00
committed by GitHub
parent b57bd0488d
commit b670485185
7 changed files with 95 additions and 56 deletions

View File

@@ -275,6 +275,20 @@ class TestOps(mlx_tests.MLXTestCase):
self.assertEqual(z.dtype, dt)
self.assertEqual(z.item(), 1)
z = -1 % x
self.assertEqual(z.dtype, dt)
self.assertEqual(z.item(), 1)
z = -1 % -x
self.assertEqual(z.dtype, dt)
self.assertEqual(z.item(), -1)
x = mx.arange(10).astype(dt) - 5
y = x % 5
z = x % -5
self.assertEqual(y.tolist(), [0, 1, 2, 3, 4, 0, 1, 2, 3, 4])
self.assertEqual(z.tolist(), [0, -4, -3, -2, -1, 0, -4, -3, -2, -1])
def test_comparisons(self):
a = mx.array([0.0, 1.0, 5.0])
b = mx.array([-1.0, 2.0, 5.0])