Skip to content

Commit

Permalink
Build and lint updates
Browse files Browse the repository at this point in the history
- Use ruff, move configuration for some things to pyproject.toml.
- Update namespace configuration.
- Deprecate py36 support, add tests for py310, py311.
- Add numba tests for py310, py311.
- Update pre-commit, add ruff.
  • Loading branch information
cgevans committed Aug 1, 2023
1 parent 439df91 commit d9ebd7e
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 25 deletions.
3 changes: 1 addition & 2 deletions .coveragerc
Expand Up @@ -13,8 +13,7 @@ source =
[report]
show_missing = true
precision = 2
exclude_lines =
exclude_lines =
pragma: no cover
@overload
@njit

4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Expand Up @@ -13,14 +13,14 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", pypy3]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", pypy3]
optionals: [none, pandas, numba]
exclude:
- python-version: pypy3
optionals: pandas
- python-version: pypy3
optionals: numba
- python-version: "3.10"
- python-version: "3.11"
optionals: numba
- os: macos-latest
python-version: pypy3
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -16,6 +16,10 @@ develop-eggs
# Installer logs
pip-log.txt


*~
\#*\#

# Unit test / coverage reports
.coverage
.tox
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -15,6 +15,6 @@ repos:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- repo: https://github.com/psf/black
rev: 21.5b2
rev: 23.7.0
hooks:
- id: black
15 changes: 15 additions & 0 deletions pyproject.toml
@@ -0,0 +1,15 @@
[build-system]
requires = ["setuptools>=56", "setuptools_scm[toml]>=3.4.1"]
build-backend = "setuptools.build_meta"

[tool.ruff]
line-length = 120
ignore = ["F405", "F403"]

[tool.mypy]
ignore_missing_imports = true
warn_unused_configs = true
warn_return_any = true

[tool.black]
line-length = 88
1 change: 0 additions & 1 deletion requirements.txt
@@ -1,4 +1,3 @@
numpy
pyerf
typing_extensions>=4.1

1 change: 0 additions & 1 deletion src/scikits/__init__.py

This file was deleted.

18 changes: 8 additions & 10 deletions src/scikits/bootstrap/bootstrap.py
Expand Up @@ -2,7 +2,7 @@
It also provides an algorithm which estimates the probability that the statistics
lies satisfies some criteria, e.g. lies in some interval."""
from __future__ import absolute_import, division, print_function
from __future__ import absolute_import, division, print_function, annotations

from math import ceil, sqrt
from typing import Sequence, cast, overload
Expand Down Expand Up @@ -454,9 +454,7 @@ def ci(
if nvals.ndim == 1:
out = np.abs(statfunction(*tdata) - stat[nvals])[np.newaxis].T # type: ignore
else:
out = np.abs(
statfunction(*tdata) - stat[(nvals, np.indices(nvals.shape)[1:])] # type: ignore
).T.squeeze()
out = np.abs(statfunction(*tdata) - stat[(nvals, np.indices(nvals.shape)[1:])]).T.squeeze() # type: ignore
else:
raise ValueError("Output option {0} is not supported.".format(output))

Expand Down Expand Up @@ -498,17 +496,17 @@ def _ci_abc(
(statfunction(*tdata, weights=p0 - ep * di) for di in di_full), dtype=float
)
t1 = (tp - tm) / (2 * ep)
t2 = (tp - 2 * t0 + tm) / ep ** 2
t2 = (tp - 2 * t0 + tm) / ep**2

sighat = np.sqrt(np.sum(t1 ** 2)) / n
a = (np.sum(t1 ** 3)) / (6 * n ** 3 * sighat ** 3)
delta = t1 / (n ** 2 * sighat)
sighat = np.sqrt(np.sum(t1**2)) / n
a = (np.sum(t1**3)) / (6 * n**3 * sighat**3)
delta = t1 / (n**2 * sighat)
cq = (
statfunction(*tdata, weights=p0 + ep * delta)
- 2 * t0
+ statfunction(*tdata, weights=p0 - ep * delta)
) / (2 * sighat * ep ** 2)
bhat = np.sum(t2) / (2 * n ** 2)
) / (2 * sighat * ep**2)
bhat = np.sum(t2) / (2 * n**2)
curv = bhat / sighat - cq
z0 = nppf(2 * ncdf(a) * ncdf(-curv))
Z = z0 + nppf(alphas)
Expand Down
4 changes: 2 additions & 2 deletions tests/bootstrap_test.py
Expand Up @@ -16,7 +16,7 @@


class TestCI:
def setup(self) -> None:
def setup_method(self) -> None:
self.data = np.array(
[
1.34016346,
Expand Down Expand Up @@ -124,7 +124,7 @@ def test_subsample_indices_fixed(self) -> None:

def test_subsample_size_too_large(self) -> None:
with pytest.raises(ValueError):
indices = boot.subsample_indices(self.data, 1000, 30)
boot.subsample_indices(self.data, 1000, 30)

def test_subsample_indices_notsame(self) -> None:
indices = boot.subsample_indices(np.arange(0, 50), 1000, -1)
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
@@ -1,12 +1,12 @@
[tox]
envlist = {py36,py37,py38,py39}-{pandas,none,numba,pandas-numba},pypy3,black,mypy,report
envlist = {py37,py38,py39,py310,py311}-{pandas,none,numba,pandas-numba},pypy3,black,mypy,report

[tool:pytest]
testpath = tests

[testenv]
setenv =
py{,36,37,38,39}-{pandas,none,numba},pypy3: COVERAGE_FILE = .coverage.{envname}
py{37,38,39,310,311}-{pandas,none,numba},pypy3: COVERAGE_FILE = .coverage.{envname}
commands =
pytest --cov --cov-report=xml --cov-report=term-missing {posargs:-vv}
deps =
Expand All @@ -17,9 +17,9 @@ deps =
!pypy3-pandas: pandas
!pypy3-numba: numba
depends =
{,py36,py37,py38,py39}-{pandas,none,numba,pandas-numba},pypy3: clean
codecov: {,py36,py37,py38,py39}-{pandas,none,numba,pandas-numba},pypy3
report: {,py36,py37,py38,py39}-{pandas,none,numba,pandas-numba},pypy3
{py37,py38,py39,py311}-{pandas,none,numba,pandas-numba},pypy3: clean
codecov: {py37,py38,py39,py311}-{pandas,none,numba,pandas-numba},pypy3
report: {py37,py38,py39,py311}-{pandas,none,numba,pandas-numba},pypy3

[testenv:black]
description = run black with check-only under {basepython}
Expand Down

0 comments on commit d9ebd7e

Please sign in to comment.