Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): add compatibility with python3.13 and remove python3.8 #372

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
2b8ecf5
chore(deps): add compatibility with python3.13 and remove python3.8
IlyesDemineExtVeolia Jan 27, 2025
b7caba2
chore(deps): add compatibility with python3.13 and remove python3.8
IlyesDemineExtVeolia Jan 27, 2025
a42ca46
chore(deps): add compatibility with python3.13 and remove python3.8
IlyesDemineExtVeolia Jan 27, 2025
3676e1a
chore(deps): add compatibility with python3.13 and remove python3.8
IlyesDemineExtVeolia Jan 27, 2025
4121da7
chore(deps): add compatibility with python3.13 and remove python3.8
IlyesDemineExtVeolia Jan 27, 2025
34c181d
chore(deps): add compatibility with python3.13 and remove python3.8
IlyesDemineExtVeolia Jan 27, 2025
52fef6b
chore(deps): add compatibility with python3.13 and remove python3.8 a…
IlyesDemineExtVeolia Jan 27, 2025
bb01903
chore(deps): add compatibility with python3.13 and remove python3.8 a…
IlyesDemineExtVeolia Jan 27, 2025
d888d93
chore(deps): add compatibility with python3.13 and remove python3.8 a…
IlyesDemineExtVeolia Jan 27, 2025
cc9594a
chore(deps): add compatibility with python3.13 and remove python3.8 a…
IlyesDemineExtVeolia Jan 27, 2025
827f6da
chore(deps): add compatibility with python3.13 and remove python3.8 a…
IlyesDemineExtVeolia Jan 27, 2025
a65d911
chore(deps): add compatibility with python3.13 and remove python3.8 a…
IlyesDemineExtVeolia Jan 27, 2025
98239e2
chore(deps): add compatibility with python3.13 and remove python3.8 a…
IlyesDemineExtVeolia Jan 27, 2025
537eed1
chore(deps): add compatibility with python3.13 and remove python3.8 a…
IlyesDemineExtVeolia Jan 27, 2025
da34560
chore(deps): add compatibility with python3.13 and remove python3.8 a…
IlyesDemineExtVeolia Jan 27, 2025
4ef71a8
chore(deps): add compatibility with python3.13 and remove python3.8 a…
IlyesDemineExtVeolia Jan 27, 2025
ea42a04
chore(deps): add compatibility with python3.13 and remove python3.8 a…
IlyesDemineExtVeolia Jan 27, 2025
51c585f
Update README.md
Lyessi78 Jan 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.13
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
pip install poetry poetry-plugin-export
poetry self add poetry-plugin-export
poetry export --with dev > requirements.txt
pip install -r requirements.txt
- name: Lint with flake8
Expand All @@ -39,7 +40,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- uses: codecov/codecov-action@v3
Expand All @@ -50,7 +51,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
pip install poetry poetry-plugin-export
poetry self add poetry-plugin-export
poetry install --with dev
- name: Test with pytest
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
python-version: '3.13'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
[![Documentation Status](https://readthedocs.org/projects/pygam/badge/?version=latest)](https://pygam.readthedocs.io/en/latest/?badge=latest)
[![PyPI version](https://badge.fury.io/py/pygam.svg)](https://badge.fury.io/py/pygam)
[![codecov](https://codecov.io/gh/dswah/pygam/branch/master/graph/badge.svg)](https://codecov.io/gh/dswah/pygam)
[![python38](https://img.shields.io/badge/python-3.8-blue.svg)](https://badge.fury.io/py/pygam)
[![python39](https://img.shields.io/badge/python-3.9-blue.svg)](https://badge.fury.io/py/pygam)
[![python310](https://img.shields.io/badge/python-3.10-blue.svg)](https://badge.fury.io/py/pygam)
[![python311](https://img.shields.io/badge/python-3.11-blue.svg)](https://badge.fury.io/py/pygam)
[![python312](https://img.shields.io/badge/python-3.12-blue.svg)](https://badge.fury.io/py/pygam)
[![python313](https://img.shields.io/badge/python-3.13-blue.svg)](https://badge.fury.io/py/pygam)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1208723.svg)](https://doi.org/10.5281/zenodo.1208723)


Expand Down
4 changes: 2 additions & 2 deletions gen_imgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def gen_basis_fns():

plt.figure()
fig, ax = plt.subplots(2, 1)
ax[0].plot(XX, gam._modelmat(XX, term=0).A)
ax[0].plot(XX, gam._modelmat(XX, term=0).toarray())
ax[0].set_title('b-Spline Basis Functions')

ax[1].scatter(X, y, facecolor='gray', edgecolors='none')
ax[1].plot(XX, gam._modelmat(XX).A * gam.coef_)
ax[1].plot(XX, gam._modelmat(XX).toarray() * gam.coef_)
ax[1].plot(XX, gam.predict(XX), 'k')
ax[1].set_title('Fitted Model')
fig.tight_layout()
Expand Down
1,174 changes: 630 additions & 544 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pygam/pygam.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ def _initial_estimate(self, y, modelmat):

# solve the linear problem
return np.linalg.solve(
load_diagonal(modelmat.T.dot(modelmat).A), modelmat.T.dot(y_)
load_diagonal(modelmat.T.dot(modelmat).toarray()), modelmat.T.dot(y_)
)

# not sure if this is faster...
Expand Down Expand Up @@ -780,7 +780,7 @@ def _pirls(self, X, Y, weights):
self._on_loop_start(vars())

WB = W.dot(modelmat[mask, :]) # common matrix product
Q, R = np.linalg.qr(WB.A)
Q, R = np.linalg.qr(WB.toarray())

if not np.isfinite(Q).all() or not np.isfinite(R).all():
raise ValueError(
Expand Down Expand Up @@ -1401,7 +1401,7 @@ def _get_quantiles(
idxs = self.terms.get_coef_indices(term)
cov = self.statistics_['cov'][idxs][:, idxs]

var = (modelmat.dot(cov) * modelmat.A).sum(axis=1)
var = (modelmat.dot(cov) * modelmat.toarray()).sum(axis=1)
if prediction:
var += self.distribution.scale

Expand Down
2 changes: 1 addition & 1 deletion pygam/terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ def _build_marginal_constraints(self, i, coef, constraint_lam, constraint_l2):
)

# now enter it into the composite
composite_C[tuple(np.meshgrid(slice_, slice_))] = slice_C.A
composite_C[tuple(np.meshgrid(slice_, slice_))] = slice_C.toarray()

return sp.sparse.csc_matrix(composite_C)

Expand Down
18 changes: 9 additions & 9 deletions pygam/tests/test_penalties.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ def test_single_spline_penalty():
monotonic_ and convexity_ should be 0.
"""
coef = np.array(1.0)
assert np.alltrue(derivative(1, coef).A == 0.0)
assert np.alltrue(l2(1, coef).A == 1.0)
assert np.alltrue(monotonic_inc(1, coef).A == 0.0)
assert np.alltrue(monotonic_dec(1, coef).A == 0.0)
assert np.alltrue(convex(1, coef).A == 0.0)
assert np.alltrue(concave(1, coef).A == 0.0)
assert np.alltrue(none(1, coef).A == 0.0)
assert np.all(derivative(1, coef).toarray() == 0.0)
assert np.all(l2(1, coef).toarray() == 1.0)
assert np.all(monotonic_inc(1, coef).toarray() == 0.0)
assert np.all(monotonic_dec(1, coef).toarray() == 0.0)
assert np.all(convex(1, coef).toarray() == 0.0)
assert np.all(concave(1, coef).toarray() == 0.0)
assert np.all(none(1, coef).toarray() == 0.0)


def test_wrap_penalty():
Expand All @@ -43,12 +43,12 @@ def test_wrap_penalty():

fit_linear = True
p = wrap_penalty(none, fit_linear, linear_penalty=linear_penalty)
P = p(n, coef).A
P = p(n, coef).toarray()
assert P.sum() == linear_penalty

fit_linear = False
p = wrap_penalty(none, fit_linear, linear_penalty=linear_penalty)
P = p(n, coef).A
P = p(n, coef).toarray()
assert P.sum() == 0.0


Expand Down
8 changes: 4 additions & 4 deletions pygam/tests/test_terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ def der1(*args, **kwargs):

# check all the dimensions
for i in range(3):
P = term._build_marginal_penalties(i).A
P = term._build_marginal_penalties(i).toarray()
C = term._build_marginal_constraints(
i, -np.arange(term.n_coefs), constraint_lam=1, constraint_l2=0
).A
).toarray()

assert (P == C).all()

Expand Down Expand Up @@ -362,11 +362,11 @@ def test_compose_penalties(self):
term = SplineTerm(feature=0, penalties=['auto', 'none'])

# penalties should be equivalent
assert (term.build_penalties() == base_term.build_penalties()).A.all()
assert (term.build_penalties() == base_term.build_penalties()).toarray().all()

# multitple penalties should be additive, not multiplicative,
# so 'none' penalty should have no effect
assert np.abs(term.build_penalties().A).sum() > 0
assert np.abs(term.build_penalties().toarray()).sum() > 0

def test_compose_constraints(self, hepatitis_X_y):
"""we should be able to compose penalties
Expand Down
8 changes: 4 additions & 4 deletions pygam/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

if sparse:
return L.T # upper triangular factorization
return L.T.A # upper triangular factorization
return L.T.toarray() # upper triangular factorization

Check warning on line 67 in pygam/utils.py

View check run for this annotation

Codecov / codecov/patch

pygam/utils.py#L67

Added line #L67 was not covered by tests

else:
msg = (
Expand All @@ -78,7 +78,7 @@
warnings.warn(msg)

if sp.sparse.issparse(A):
A = A.A
A = A.toarray()

try:
L = sp.linalg.cholesky(A, lower=False)
Expand Down Expand Up @@ -951,10 +951,10 @@
raise ValueError('both arguments must have the same number of samples')

if sp.sparse.issparse(a):
a = a.A
a = a.toarray()

if sp.sparse.issparse(b):
b = b.A
b = b.toarray()

tensor = a[..., :, None] * b[..., None, :]

Expand Down
40 changes: 19 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,33 @@ authors = ["Daniel Servén Marín", "Charlie Brummitt"]
license = "Apache-2.0"
readme = "README.md"

[tool.poetry.requires-plugins]
poetry-plugin-export = "^1.8"

[tool.poetry.dependencies]
python = ">=3.8.1, <3.13"
numpy = [
{ version = ">=1.24.2,<1.25", python = "<3.9,>=3.8" },
{ version = ">=1.25", python = "<3.13,>=3.9" },
]
progressbar2 = "^4.2.0"
scipy = [
{ version = ">=1.10.1,<1.11", python = "<3.9,>=3.8" },
{ version = ">=1.11.1,<1.12", python = "<3.13,>=3.9" }
]
python = ">=3.10, <3.14"
numpy = "^2.1.0"
progressbar2 = "^4.5.0"
scipy = "1.15.*"

[tool.poetry.group.dev.dependencies]
pandas = ">=1.6"
pytest = "^7.2.2"
flake8 = "^6.0.0"
codecov = "^2.1.12"
pytest-cov = "^4.0.0"
mock = "^5.0.1"
nbsphinx = "^0.9.0"
sphinx-rtd-theme = "^1.2.0"
pandas = "^2.2.3"
pytest = "^8.3.4"
flake8 = "^7.1.1"
codecov = "^2.1.13"
pytest-cov = "^6.0.0"
mock = "^5.1.0"
nbsphinx = "^0.9.6"
sphinx-rtd-theme = "^3.0.2"
sphinxcontrib-napoleon = "^0.7"
ipython = "^8.11.0"
black = "^23.1.0"
ipython = "^8.31.0"
black = "^24.10.0"
pyzmq="^26.2.0"

[tool.black]
line-length = 88
skip-string-normalization = true
target-version = ['py39']
target-version = ['py313']
include = '\.pyi?$'
exclude = '''
/(
Expand Down