def test_becke_infinite(self): """Test becke transformation when inf generated.""" inf_array = np.linspace(-1, 1, 21) R = BeckeTF.find_parameter(inf_array, 0.1, 1.2) btf = BeckeTF(0.1, R) tf_array = btf.transform(inf_array, trim_inf=True) inv_array = btf.inverse(tf_array) assert_allclose(inv_array, inf_array)
def test_becke_transform(self): """Test becke transformation.""" btf = BeckeTF(0.1, 1.1) tf_array = btf.transform(self.array) single_v = btf.transform(self.num) single_v2 = btf.transform(self.num_2) new_array = btf.inverse(tf_array) assert_allclose(new_array, self.array) assert_allclose(tf_array[0], single_v) assert_allclose(tf_array[-1], single_v2) # test tf and inverse self._transform_and_inverse(-1, 1, btf)
def test_becke_infinite(self): """Test becke transformation when inf generated.""" inf_array = np.linspace(-1, 1, 21) R = BeckeTF.find_parameter(inf_array, 0.1, 1.2) btf = BeckeTF(0.1, R, trim_inf=True) tf_array = btf.transform(inf_array) inv_array = btf.inverse(tf_array) assert_allclose(inv_array, inf_array) # extra test for neg inf # test for number result = btf._convert_inf(-np.inf) assert_almost_equal(result, -1e16) result = btf._convert_inf(np.inf) assert_almost_equal(result, 1e16) # test for array test_array = np.random.rand(5) test_array[3] = -np.inf result = btf._convert_inf(test_array) assert_almost_equal(result[3], -1e16) test_array[3] = np.inf result = btf._convert_inf(test_array) assert_almost_equal(result[3], 1e16)
def test_becke_transform(self): """Test becke transformation.""" btf = BeckeTF(0.1, 1.1) tf_array = btf.transform(self.array) new_array = btf.inverse(tf_array) assert_allclose(new_array, self.array)