Skip to content

Commit

Permalink
Drop Python<3.9 according to NEP29 (#704)
Browse files Browse the repository at this point in the history
* Support Python>=3.9 according to NEP 29

* pyupgrade

* Lint

* Fix flake8 hook

* changelog

* Remove 3.8 from classifiers
  • Loading branch information
xhochy committed Oct 10, 2023
1 parent 489538c commit 48e9548
Show file tree
Hide file tree
Showing 31 changed files with 103 additions and 253 deletions.
31 changes: 0 additions & 31 deletions .ci_support/linux_64_numpy1.20python3.8.____cpython.yaml

This file was deleted.

35 changes: 0 additions & 35 deletions .ci_support/linux_aarch64_numpy1.20python3.8.____cpython.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions .ci_support/osx_64_numpy1.20python3.8.____cpython.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions .ci_support/osx_arm64_numpy1.20python3.8.____cpython.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions .ci_support/win_64_numpy1.20python3.8.____cpython.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'
python-version: '3.11'
- name: Install build dependencies
run: python -m pip install setuptools setuptools-scm wheel Cython numpy scikit-learn
- name: Build sdist
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push]

jobs:
pre-commit-checks:
name: Linux - pre-commit checks - Python 3.10
name: Linux - pre-commit checks - Python 3.11
timeout-minutes: 30
runs-on: ubuntu-latest
env:
Expand All @@ -15,10 +15,10 @@ jobs:
uses: mamba-org/setup-micromamba@2b72821d5ad7f6da3c003a3684ce341bf187b46f
- name: Add micromamba to GITHUB_PATH
run: echo "${HOME}/micromamba-bin" >> "$GITHUB_PATH"
- name: Install Python 3.10
- name: Install Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"
- name: Run pre-commit checks
uses: pre-commit/action@v3.0.0

Expand All @@ -31,7 +31,6 @@ jobs:
fail-fast: true
matrix:
include:
- { os: ubuntu-latest, python-version: '3.8' }
- { os: ubuntu-latest, python-version: '3.9' }
- { os: ubuntu-latest, python-version: '3.10' }
- { os: ubuntu-latest, python-version: '3.11' }
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/conda-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ jobs:
fail-fast: false
matrix:
include:
- { conda_build_yml: linux_64_numpy1.20python3.8.____cpython, os: ubuntu-latest, conda-build-args: '' }
- { conda_build_yml: linux_64_numpy1.20python3.9.____cpython, os: ubuntu-latest, conda-build-args: '' }
- { conda_build_yml: linux_64_numpy1.23python3.11.____cpython, os: ubuntu-latest, conda-build-args: '' }
- { conda_build_yml: osx_64_numpy1.20python3.9.____cpython, os: macos-latest, conda-build-args: '' }
- { conda_build_yml: osx_64_numpy1.23python3.11.____cpython, os: macos-latest, conda-build-args: '' }
- { conda_build_yml: osx_arm64_numpy1.20python3.8.____cpython, os: macos-latest, conda-build-args: ' --no-test' }
- { conda_build_yml: osx_arm64_numpy1.21python3.10.____cpython, os: macos-latest, conda-build-args: ' --no-test' }
- { conda_build_yml: win_64_numpy1.20python3.8.____cpython, os: windows-latest, conda-build-args: '' }
- { conda_build_yml: win_64_numpy1.20python3.9.____cpython, os: windows-latest, conda-build-args: '' }
- { conda_build_yml: win_64_numpy1.23python3.11.____cpython, os: windows-latest, conda-build-args: '' }
steps:
- name: Checkout branch
Expand Down
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
- id: black-conda
args:
- --safe
- --target-version=py37
- --target-version=py39
- repo: https://github.com/Quantco/pre-commit-mirrors-flake8
rev: 6.1.0
hooks:
Expand All @@ -19,6 +19,7 @@ repos:
flake8-docstrings=1.6.0,
flake8-print=5.0.0,
pep8-naming=0.13.3,
python<3.12,
]
exclude: (^src/glum_benchmarks/orig_sklearn_fork/|^docs)
- repo: https://github.com/Quantco/pre-commit-mirrors-isort
Expand All @@ -41,9 +42,10 @@ repos:
hooks:
- id: pyupgrade-conda
exclude: ^src/glum_benchmarks/orig_sklearn_fork/
args: [--py39-plus]
- repo: https://github.com/Quantco/pre-commit-mirrors-cython-lint
rev: 0.15.0
hooks:
- id: cython-lint-conda
args: [--no-pycodestyle]
- id: double-quote-cython-strings-conda
- id: double-quote-cython-strings-conda
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
Changelog
=========

2.7.0 - 2023-10-xx
------------------

**Other changes:**

- Require Python>=3.9 in line with `NEP 29 <https://numpy.org/neps/nep-0029-deprecation_policy.html#support-table>`_

2.6.0 - 2023-09-05
------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
license="BSD",
classifiers=[ # Optional
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -78,6 +77,7 @@
if os.environ.get("CONDA_BUILD")
else ["glum", "glum_benchmarks"],
),
python_requires=">=3.9",
install_requires=[
"joblib",
"numexpr",
Expand Down
6 changes: 3 additions & 3 deletions src/glum/_distribution.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABCMeta, abstractmethod
from functools import partial
from typing import Tuple, Union
from typing import Union

import numexpr
import numpy as np
Expand Down Expand Up @@ -318,7 +318,7 @@ def _mu_deviance_derivative(
sample_weight: np.ndarray,
link: Link,
offset: np.ndarray = None,
) -> Tuple[np.ndarray, np.ndarray]:
) -> tuple[np.ndarray, np.ndarray]:
"""Compute ``mu`` and the derivative of the deviance \
with respect to coefficients."""
lin_pred = _safe_lin_pred(X, coef, offset)
Expand Down Expand Up @@ -1157,7 +1157,7 @@ def theta(self, theta):
raise TypeError(f"theta must be an int or float, input was {theta}")
if not theta > 0:
raise ValueError(
"theta must be strictly positive number, input was {}".format(theta)
f"theta must be strictly positive number, input was {theta}"
)

# Prevents upcasting when working with 32-bit data
Expand Down
20 changes: 10 additions & 10 deletions src/glum/_glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import re
import sys
import warnings
from collections.abc import Iterable
from collections.abc import Iterable, Sequence
from itertools import chain
from typing import Any, List, NamedTuple, Optional, Sequence, Tuple, Union, cast
from typing import Any, NamedTuple, Optional, Union, cast

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -126,7 +126,7 @@ def check_array_tabmat_compliant(mat: ArrayLike, drop_first: int = False, **kwar

def check_X_y_tabmat_compliant(
X: ArrayLike, y: Union[VectorLike, sparse.spmatrix], **kwargs
) -> Tuple[Union[tm.MatrixBase, sparse.spmatrix, np.ndarray], np.ndarray]:
) -> tuple[Union[tm.MatrixBase, sparse.spmatrix, np.ndarray], np.ndarray]:
"""
See the documentation for :func:`sklearn.utils.check_X_y`. This function
behaves identically for inputs that are not from the Matrix package and
Expand Down Expand Up @@ -219,7 +219,7 @@ def _check_offset(


def _name_categorical_variables(
categories: Tuple[str], column_name: str, drop_first: bool
categories: tuple[str], column_name: str, drop_first: bool
):
new_names = [
f"{column_name}__{category}" for category in categories[int(drop_first) :]
Expand Down Expand Up @@ -264,7 +264,7 @@ def check_inequality_constraints(
b_ineq: Optional[np.ndarray],
n_features: int,
dtype,
) -> Tuple[Union[None, np.ndarray], Union[None, np.ndarray]]:
) -> tuple[Union[None, np.ndarray], Union[None, np.ndarray]]:
"""Check that the inequality constraints are well-defined."""
if A_ineq is None or b_ineq is None:
return None, None
Expand Down Expand Up @@ -304,7 +304,7 @@ def _standardize(
A_ineq: Optional[np.ndarray],
P1: Union[np.ndarray, sparse.spmatrix],
P2: Union[np.ndarray, sparse.spmatrix],
) -> Tuple[
) -> tuple[
tm.StandardizedMatrix,
np.ndarray,
Optional[np.ndarray],
Expand Down Expand Up @@ -378,7 +378,7 @@ def _unstandardize(
col_stds: Optional[np.ndarray],
intercept: Union[float, np.ndarray],
coef: np.ndarray,
) -> Tuple[Union[float, np.ndarray], np.ndarray]:
) -> tuple[Union[float, np.ndarray], np.ndarray]:
if col_stds is None:
intercept -= np.squeeze(np.squeeze(col_means).dot(np.atleast_1d(coef).T))
else:
Expand Down Expand Up @@ -1429,7 +1429,7 @@ def coef_table(
def wald_test(
self,
R: Optional[np.ndarray] = None,
features: Optional[Union[str, List[str]]] = None,
features: Optional[Union[str, list[str]]] = None,
r: Optional[Sequence] = None,
X=None,
y=None,
Expand Down Expand Up @@ -1638,7 +1638,7 @@ def _wald_test_matrix(

def _wald_test_feature_names(
self,
features: Union[str, List[str]],
features: Union[str, list[str]],
values: Optional[Sequence] = None,
X=None,
y=None,
Expand Down Expand Up @@ -2226,7 +2226,7 @@ def _set_up_and_check_fit_args(
offset: Optional[VectorLike],
solver: str,
force_all_finite,
) -> Tuple[
) -> tuple[
tm.MatrixBase,
np.ndarray,
np.ndarray,
Expand Down

0 comments on commit 48e9548

Please sign in to comment.