File: test_jackknife.py

package info (click to toggle)
python-resample 1.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 1,228 kB
  • sloc: python: 1,542; makefile: 12
file content (27 lines) | stat: -rw-r--r-- 776 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# ruff: noqa: D100 D103
import numpy as np
import pytest
from numpy.testing import assert_equal
from resample.jackknife import resample


def run_resample(n, copy):
    x = np.arange(n)
    r = []
    for b in resample(x, copy=copy):
        r.append(np.mean(b))
    return r


@pytest.mark.benchmark(group="jackknife-100")
@pytest.mark.parametrize("copy", (True, False))
def test_jackknife_resample_100(benchmark, copy):
    result = benchmark(run_resample, 100, copy)
    assert_equal(result, run_resample(100, resample))


@pytest.mark.benchmark(group="jackknife-1000")
@pytest.mark.parametrize("copy", (True, False))
def test_jackknife_resample_1000(benchmark, copy):
    result = benchmark(run_resample, 1000, copy)
    assert_equal(result, run_resample(1000, resample))