mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-04-29 03:00:14 -04:00
update payne_hanek_reduction [pr] (#7455)
This commit is contained in:
@@ -8,14 +8,20 @@ from test.helpers import eval_uop
|
||||
class TestTranscendentalFunctions(unittest.TestCase):
|
||||
def test_payne_hanek_reduction(self):
|
||||
r, q = (eval_uop(u) for u in payne_hanek_reduction(UOp.const(dtypes.float64, 12 * math.pi + 0.1)))
|
||||
# TODO: should r be in [0, pi/2) per doc?
|
||||
np.testing.assert_allclose(r, 0.1 - math.pi / 2)
|
||||
np.testing.assert_equal(q, 1)
|
||||
|
||||
r, q = (eval_uop(u) for u in payne_hanek_reduction(UOp.const(dtypes.float64, 12 * math.pi)))
|
||||
np.testing.assert_allclose(r, 0.0, atol=1e-8)
|
||||
np.testing.assert_equal(q, 4)
|
||||
|
||||
r, q = (eval_uop(u) for u in payne_hanek_reduction(UOp.const(dtypes.float64, 12 * math.pi - 0.1)))
|
||||
np.testing.assert_allclose(r, -0.1)
|
||||
np.testing.assert_equal(q, 4)
|
||||
|
||||
def test_cody_waite_reduction(self):
|
||||
r, q = (eval_uop(u) for u in cody_waite_reduction(UOp.const(dtypes.float64, 12 * math.pi + 0.1)))
|
||||
np.testing.assert_allclose(r, 0.1)
|
||||
# TODO: should q be in [0, 1, 2, 3]?
|
||||
np.testing.assert_equal(q, 12)
|
||||
|
||||
def test_frexp(self):
|
||||
|
||||
Reference in New Issue
Block a user