def test_reverse(self): """Check if it reverses `transform` properly, if possible.""" t = Precision() assert t.reverse(9.0) == 9.0 assert t.reverse(5.0) == 5.0 assert numpy.all( t.reverse([9.0, 5.0]) == numpy.array([9.0, 5.0], dtype=float))
def test_transform(self): """Check if it transforms properly.""" t = Precision(precision=4) assert t.transform(8.654321098) == 8.654 assert t.transform(0.000123456789) == 0.0001235 assert numpy.all( t.transform([8.654321098, 0.000123456789]) == numpy.array( [8.654, 0.0001235], dtype=float))
def test_domain_and_target_type(self): """Check if attribute-like `domain_type` and `target_type` do what's expected. """ t = Precision() assert t.domain_type == "real" assert t.target_type == "real"
def test_repr_format(self): """Check representation of a transformed dimension.""" t = Precision() assert t.repr_format("asfa") == "Precision(4, asfa)"
def test_infer_target_shape(self): """Check if it infers the shape of a transformed `Dimension`.""" t = Precision() assert t.infer_target_shape((5, )) == (5, )
def test_deepcopy(self): """Verify that the transformation object can be copied""" t = Precision() t.transform([2]) copy.deepcopy(t)