Skip to content

Commit

Permalink
Function test fails for np.mean (#380)
Browse files Browse the repository at this point in the history
* Function test for np.mean

* linter

* Add 3.10

* Add 3.11

* Change code
  • Loading branch information
gedeck authored Sep 30, 2023
1 parent 7923141 commit 019d0e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

runs-on: ${{ matrix.platform }}

Expand Down
4 changes: 2 additions & 2 deletions pingouin/effsize.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,14 @@ def compute_bootci(
... f"{bt.mean():.4f} ± {bt.std():.4f}")
The bootstrap distribution has 10000 samples. The mean and standard 0.8807 ± 0.1704
"""
from inspect import isfunction
from inspect import isfunction, isroutine
from scipy.stats import norm

# Check other arguments
assert isinstance(confidence, float)
assert 0 < confidence < 1, "confidence must be between 0 and 1."
assert method in ["norm", "normal", "percentile", "per", "cpercentile", "cper"]
assert isfunction(func) or isinstance(func, str), (
assert isfunction(func) or isinstance(func, str) or isroutine(func), (
"func must be a function (e.g. np.mean, custom function) or a string (e.g. 'pearson'). "
"See documentation for more details."
)
Expand Down
8 changes: 8 additions & 0 deletions pingouin/tests/test_effsize.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ def test_compute_boot_esci(self):
assert ci_p[0] == 2.98 and ci_p[1] == 3.21
assert ci_c[0] == 2.98 and round(ci_c[1], 1) == 3.2

# 2.a Univariate function: np.mean
ci_n = compute_bootci(x_m, func=np.mean, method="norm", seed=42)
ci_p = compute_bootci(x_m, func=np.mean, method="per", seed=42)
ci_c = compute_bootci(x_m, func=np.mean, method="cper", seed=42)
assert ci_n[0] == 2.98 and ci_n[1] == 3.21
assert ci_p[0] == 2.98 and ci_p[1] == 3.21
assert ci_c[0] == 2.98 and round(ci_c[1], 1) == 3.2

# 3. Univariate custom function: skewness
from scipy.stats import skew

Expand Down

0 comments on commit 019d0e9

Please sign in to comment.