def test__compare_distributions_multiple_returns(self): known = np.array([[1, 1, 1], [2, 2, 2], [3, 3, 3]]) def f(x): return np.array([1, 2, 3]) test = _compare_distributions(f, self.pop, 3, mode='matched', num_iter=3) npt.assert_array_equal(known, test)
def test__compare_distributions_matched_mode(self): # Sets the known value known_mean = 0.162195 known_std = 0.121887 known_shape = (100,) # Tests the sample value test = _compare_distributions(self.f, self.pop, self.num_p, mode='matched', num_iter=100) npt.assert_allclose(known_mean, test.mean(), rtol=0.1, atol=0.02) npt.assert_allclose(known_std, test.std(), rtol=0.1, atol=0.02) self.assertEqual(known_shape, test.shape)
def test__compare_distributions_all_mode(self): known = np.ones((100))*0.0026998 test = _compare_distributions(self.f, self.samps, 1, num_iter=100) npt.assert_allclose(known, test, 5)
def test__compare_distributions_sample_counts_error(self): with self.assertRaises(ValueError): _compare_distributions(self.f, [self.pop[0][:5], self.pop[1]], 1, counts=25)
def test__compare_distributions_matched_length_error(self): with self.assertRaises(ValueError): _compare_distributions(self.f, [np.ones((5)), np.zeros((6))], mode="matched")
def test__compare_distributions_count_error(self): with self.assertRaises(ValueError): _compare_distributions(self.f, self.samps, counts=[1, 2, 3], num_iter=100)
def test__compare_distributions_mode_error(self): with self.assertRaises(ValueError): _compare_distributions(self.f, self.samps, mode='fig')