Skip to content

Commit 338166d

Browse files
committed
Improve test precision
1 parent 3dd2db6 commit 338166d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/test_block.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44
import pytest
55

6-
from gfloat import decode_block, encode_block
6+
from gfloat import decode_float, decode_block, encode_block, compute_scale_amax
77
from gfloat.formats import *
88

99

@@ -12,9 +12,10 @@ def test_blocks(fi: BlockFormatInfo) -> None:
1212

1313
vals = np.linspace(-37.0, 42.0, 32)
1414

15-
scale = 8.0
15+
scale = compute_scale_amax(fi.etype.emax, vals)
1616
block = list(encode_block(fi, scale, vals / scale))
1717
decoded_vals = list(decode_block(fi, block))
1818

19-
atol = 2 * scale * fi.etype.eps
19+
etype_next_under_max = decode_float(fi.etype, fi.etype.code_of_max - 1).fval
20+
atol = (fi.etype.max - etype_next_under_max) * scale / 2
2021
np.testing.assert_allclose(decoded_vals, vals, atol=atol)

0 commit comments

Comments
 (0)