def test_move_exp_nanmean_numeric(): array = np.array([10, 0, np.nan, 10]) result = move_exp_nanmean(array, alpha=0.5) expected = np.array([10.0, 3.3333333, 3.3333333, 8.1818182]) assert_almost_equal(result, expected) result = move_exp_nanmean(array, alpha=0.25) expected = np.array([10.0, 4.2857143, 4.2857143, 7.1653543]) assert_almost_equal(result, expected)
def test_move_exp_nanmean(rand_array, alpha): array = rand_array[0] expected = pd.Series(array).ewm(alpha=alpha).mean() result = move_exp_nanmean(array, alpha) assert_almost_equal(expected, result)
def move_exp_nanmean(array, *, axis, alpha): if isinstance(array, dask_array_type): raise TypeError("rolling_exp is not currently support for dask arrays") import numbagg if axis == (): return array.astype(np.float64) else: return numbagg.move_exp_nanmean(array, axis=axis, alpha=alpha)
def move_exp_nanmean(array, *, axis, alpha): if is_duck_dask_array(array): raise TypeError("rolling_exp is not currently support for dask-like arrays") import numbagg # No longer needed in numbag > 0.2.0; remove in time if axis == (): return array.astype(np.float64) else: return numbagg.move_exp_nanmean(array, axis=axis, alpha=alpha)
def test_move_exp_nanmean_2d(rand_array): expected = pd.DataFrame(rand_array).T.ewm(alpha=0.1).mean().T result = move_exp_nanmean(rand_array, 0.1) assert_almost_equal(expected, result)
def test_tuple_axis_arg(rand_array): result = move_exp_nanmean(rand_array, 0.1, axis=()) assert_equal(result, rand_array)