MCPcopy Create free account
hub / github.com/ml-explore/mlx / test_array_repr_precision

Method test_array_repr_precision

python/tests/test_array.py:600–618  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

598 expected = "array([1-1j], dtype=complex64)"
599
600 def test_array_repr_precision(self):
601 x = mx.array([1.123456789], dtype=mx.float32)
602 expected = "array([1.12346], dtype=float32)"
603 self.assertEqual(str(x), expected)
604
605 with mx.printoptions(precision=4):
606 expected = "array([1.1235], dtype=float32)"
607 self.assertEqual(str(x), expected)
608 mx.set_printoptions(precision=2)
609 expected = "array([1.12], dtype=float32)"
610 self.assertEqual(str(x), expected)
611
612 x = mx.sin(x)
613 expected = "array([0.90], dtype=float32)"
614 self.assertEqual(str(x), expected)
615
616 with mx.printoptions(precision=4):
617 expected = "array([0.9016], dtype=float32)"
618 self.assertEqual(str(x), expected)
619
620 def test_array_to_list(self):
621 types = [mx.bool_, mx.uint32, mx.int32, mx.int64, mx.float32]

Callers

nothing calls this directly

Calls 1

arrayMethod · 0.60

Tested by

no test coverage detected