mirror of
https://github.com/ml-explore/mlx.git
synced 2025-10-19 08:29:35 +08:00
Add isfinite
(#1318)
* isfinite * remove reduce test since fix is not complete
This commit is contained in:
@@ -374,6 +374,16 @@ class TestOps(mlx_tests.MLXTestCase):
|
||||
result = mx.isinf(x)
|
||||
self.assertEqual(result.tolist(), [False, False, False])
|
||||
|
||||
def test_isfinite(self):
|
||||
x = mx.array([0.0, float("inf"), float("nan")])
|
||||
self.assertEqual(mx.isfinite(x).tolist(), [True, False, False])
|
||||
|
||||
x = x.astype(mx.float16)
|
||||
self.assertEqual(mx.isfinite(x).tolist(), [True, False, False])
|
||||
|
||||
x = x.astype(mx.bfloat16)
|
||||
self.assertEqual(mx.isfinite(x).tolist(), [True, False, False])
|
||||
|
||||
def test_tri(self):
|
||||
for shape in [[4], [4, 4], [2, 10]]:
|
||||
for diag in [-1, 0, 1, -2]:
|
||||
|
Reference in New Issue
Block a user