Exemplo n.º 1
0
 def test_tlog(self):
     th = 2
     r = 10 ** 4
     d = np.log10(2 ** 18)
     result = trans.tlog(_xall, th, r, d)
     assert_almost_equal(result[_xall < th], np.log10(th) * 1.0 * r / d, decimal=3)
     self.assertTrue(np.all(result[_xall > th]))
     assert_almost_equal(r, result.max())
Exemplo n.º 2
0
 def test_tlog(self):
     th = 2
     r = 10**4
     d = np.log10(2**18)
     result = trans.tlog(_xall, th, r, d)
     assert_almost_equal(result[_xall < th],
                         np.log10(th) * 1. * r / d,
                         decimal=3)
     self.assertTrue(np.all(result[_xall > th]))
     assert_almost_equal(r, result.max())
Exemplo n.º 3
0
 def test_hlog(self):
     hlpos = trans.hlog(_xpos)
     hlneg = trans.hlog(_xneg)
     assert_almost_equal((hlpos[-1] - _ymax) / _ymax, 0, decimal=2)
     assert_almost_equal(hlpos, -hlneg[::-1])  # check symmetry
     # test that values get larger as b decreases
     hlpos10 = trans.hlog(_xpos, b=10)
     self.assertTrue(np.all(hlpos10 >= hlpos))
     # check that converges to tlog for large values
     tlpos = trans.tlog(_xpos)
     i = np.where(_xpos > 1e4)[0]
     tlpos_large = tlpos[i]
     hlpos_large = hlpos10[i]
     d = (hlpos_large - tlpos_large) / hlpos_large
     assert_almost_equal(d, np.zeros(len(d)), decimal=2)
     # test spline option
     result1 = trans.hlog(_xall, use_spln=True)
     result2 = trans.hlog(_xall, use_spln=False)
     d = (result1 - result2) / result1
     assert_almost_equal(d, np.zeros(len(d)), decimal=2)
Exemplo n.º 4
0
 def test_hlog(self):
     hlpos = trans.hlog(_xpos)
     hlneg = trans.hlog(_xneg)
     assert_almost_equal((hlpos[-1] - _ymax) / _ymax, 0, decimal=2)
     assert_almost_equal(hlpos, -hlneg[::-1])  # check symmetry
     # test that values get larger as b decreases
     hlpos10 = trans.hlog(_xpos, b=10)
     self.assertTrue(np.all(hlpos10 >= hlpos))
     # check that converges to tlog for large values
     tlpos = trans.tlog(_xpos)
     i = np.where(_xpos > 1e4)[0]
     tlpos_large = tlpos[i]
     hlpos_large = hlpos10[i]
     d = (hlpos_large - tlpos_large) / hlpos_large
     assert_almost_equal(d, np.zeros(len(d)), decimal=2)
     # test spline option
     transformation = Transformation(transform='hlog', direction='forward')
     result1 = transformation(_xall, use_spln=True)
     result2 = transformation(_xall, use_spln=False)
     d = (result1 - result2) / result1
     assert_almost_equal(d, np.zeros(len(d)), decimal=2)
Exemplo n.º 5
0
 def test_tlog_inv(self):
     th = 2
     expected = _xall.copy()
     expected[_xall <= th] = th
     result = trans.tlog_inv(trans.tlog(_xall, th=th), th=th)
     assert_almost_equal(result, expected)
Exemplo n.º 6
0
 def test_tlog_inv(self):
     th = 2
     expected = _xall.copy()
     expected[_xall <= th] = th
     result = trans.tlog_inv(trans.tlog(_xall, th=th), th=th)
     assert_almost_equal(result, expected)