Пример #1
0
 def test_converter_inplace(self):
     for c in (ScaleConverter(20.0), OffsetConverter(20.0, 2)):
         fun1 = lambda x, y: c.from_reference(c.to_reference(x, y), y)
         fun2 = lambda x, y: c.to_reference(c.from_reference(x, y), y)
         for fun, (inplace, comp) in itertools.product(
             (fun1, fun2),
             ((True, self.assertIs), (False, self.assertIsNot))):
             a = np.ones((1, 10))
             ac = np.ones((1, 10))
             r = fun(a, inplace)
             np.testing.assert_allclose(r, ac)
             comp(a, r)
Пример #2
0
 def test_offset_converter(self):
     c = OffsetConverter(20.0, 2)
     self.assertFalse(c.is_multiplicative)
     self.assertFalse(c.is_logarithmic)
     self.assertEqual(c.from_reference(c.to_reference(100)), 100)
     self.assertEqual(c.to_reference(c.from_reference(100)), 100)
Пример #3
0
 def test_offset_converter(self):
     c = OffsetConverter(20., 2)
     self.assertEqual(c.from_reference(c.to_reference(100)), 100)
     self.assertEqual(c.to_reference(c.from_reference(100)), 100)
Пример #4
0
 def test_offset_converter(self):
     c = OffsetConverter(20.0, 2)
     assert not c.is_multiplicative
     assert not c.is_logarithmic
     assert c.from_reference(c.to_reference(100)) == 100
     assert c.to_reference(c.from_reference(100)) == 100
Пример #5
0
 def test_offset_converter(self):
     c = OffsetConverter(20., 2)
     self.assertEqual(c.from_reference(c.to_reference(100)), 100)
     self.assertEqual(c.to_reference(c.from_reference(100)), 100)