load_stats(), ids=lambda stat: stat.__class__.__name__) def test_pickling(stat): assert isinstance(pickle.loads(pickle.dumps(stat)), stat.__class__) assert isinstance(copy.deepcopy(stat), stat.__class__) # Check the statistic has a working __str__ and name method assert isinstance(str(stat), str) if isinstance(stat, stats.Univariate): assert isinstance(stat.name, str) @pytest.mark.parametrize( 'stat, func', [(stats.Kurtosis(bias=True), sp_stats.kurtosis), (stats.Kurtosis(bias=False), functools.partial(sp_stats.kurtosis, bias=False)), (stats.Mean(), statistics.mean), (stats.Skew(bias=True), sp_stats.skew), (stats.Skew(bias=False), functools.partial(sp_stats.skew, bias=False)), (stats.Var(ddof=0), np.var), (stats.Var(), functools.partial(np.var, ddof=1))]) def test_univariate(stat, func): # Shut up np.warnings.filterwarnings('ignore') X = [random.random() for _ in range(30)] for i, x in enumerate(X): stat.update(x)
assert isinstance(str(stat), str) if isinstance(stat, stats.Univariate): assert isinstance(stat.name, str) @pytest.mark.parametrize("stat", load_stats(), ids=lambda stat: stat.__class__.__name__) def test_repr_with_no_updates(stat): assert isinstance(repr(stat), str) assert isinstance(str(stat), str) @pytest.mark.parametrize( "stat, func", [ (stats.Kurtosis(bias=True), sp_stats.kurtosis), (stats.Kurtosis(bias=False), functools.partial(sp_stats.kurtosis, bias=False)), (stats.Mean(), statistics.mean), (stats.Skew(bias=True), sp_stats.skew), (stats.Skew(bias=False), functools.partial(sp_stats.skew, bias=False)), (stats.Var(ddof=0), np.var), (stats.Var(), functools.partial(np.var, ddof=1)), ], ) def test_univariate(stat, func): # Shut up np.warnings.filterwarnings("ignore") X = [random.random() for _ in range(30)]