MCPcopy
hub / github.com/tinygrad/tinygrad / test_float_bytes

Method test_float_bytes

test/unit/test_tensor_data.py:12–16  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

10 assert lst.tolist() == [170, 187, 204, 221]
11
12 def test_float_bytes(self):
13 lst = Tensor(bytes(struct.pack("ff", 0.234, 0.8585)), dtype=dtypes.float32)
14 assert lst.shape == (2,)
15 assert abs(lst.tolist()[0] - 0.234) < 1e-6
16 assert abs(lst.tolist()[1] - 0.8585) < 1e-6
17
18class TestTensorData(unittest.TestCase):
19 def test_data(self):

Callers

nothing calls this directly

Calls 2

tolistMethod · 0.95
TensorClass · 0.90

Tested by

no test coverage detected