def test_circ_mean(self): """Test function circ_mean.""" x = [0.785, 1.570, 3.141, 0.839, 5.934] mu = circ_mean(x) # Compare with the CircStats MATLAB toolbox assert np.round(mu, 3) == 1.013 # Wrong argument with pytest.raises(ValueError): circ_mean(x, w=[0.1, 0.2, 0.3])
def test_circ_mean(self): """Test function circ_mean.""" x = [0.785, 1.570, 3.141, 0.839, 5.934] x_nan = np.array([0.785, 1.570, 3.141, 0.839, 5.934, np.nan]) # Compare with the CircStats MATLAB toolbox assert np.round(circ_mean(x), 3) == 1.013 assert np.round(circ_mean(x_nan), 3) == 1.013 # Binned data np.random.seed(123) nbins = 18 # Number of bins to divide the unit circle angles_bins = np.linspace(-np.pi, np.pi, nbins) # w represents the number of incidences per bins, or "weights". w = np.random.randint(low=0, high=5, size=angles_bins.size) assert round(circ_mean(angles_bins, w), 4) == -2.5355
def assert_circmean(x, low, high, axis=-1): m1 = convert_angles( circmean(x, low=low, high=high, axis=axis, nan_policy='omit'), low, high) m2 = circ_mean(convert_angles(x, low, high), axis=axis) assert (np.round(m1, 4) == np.round(m2, 4)).all()
def test_circ_mean(self): """Test function circ_mean.""" x = [0.785, 1.570, 3.141, 0.839, 5.934] mu = circ_mean(x) # Compare with the CircStats MATLAB toolbox assert np.round(mu, 3) == 1.013