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: remove Python 3.8 support #16

Merged
merged 10 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pypi-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]

name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
Expand Down
29 changes: 15 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exclude: '^docs/conf.py'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
Expand All @@ -17,26 +17,27 @@ repos:
- id: mixed-line-ending
args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows

- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
additional_dependencies: [tomli]
args: [--in-place, --wrap-descriptions=120, --wrap-summaries=120]
# --config, ./pyproject.toml
# - repo: https://github.com/PyCQA/docformatter
# rev: master
# hooks:
# - id: docformatter
# additional_dependencies: [tomli]
# args: [--in-place, --wrap-descriptions=120, --wrap-summaries=120]
# # --config, ./pyproject.toml

- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
language_version: python3
# - repo: https://github.com/psf/black
# rev: 24.8.0
# hooks:
# - id: black
# language_version: python3

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.8
rev: v0.8.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

## If like to embrace black styles even in the docs:
# - repo: https://github.com/asottile/blacken-docs
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Changelog

## Version 0.3.0

- chore: Remove Python 3.8 (EOL)
- precommit: Replace docformatter with ruff's formatter

## Version 0.2.8

- Set dependency for `scipy`. Seems like the hstack and vstack functions
have been updated in 1.13.0+.


## Version 0.2.0 - 0.2.7

- Support multi apply
Expand Down
11 changes: 7 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"sphinx.ext.ifconfig",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx_autodoc_typehints",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -170,10 +171,12 @@ def setup(app):
todo_emit_warnings = True

autodoc_default_options = {
'special-members': True,
'undoc-members': False,
'exclude-members': '__weakref__, __dict__, __str__, __module__, __init__'
}
# 'members': 'var1, var2',
# 'member-order': 'bysource',
"special-members": True,
"undoc-members": True,
"exclude-members": "__weakref__, __dict__, __str__, __module__",
}

autosummary_generate = True
autosummary_imported_members = True
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ furo
# sphinx_rtd_theme
recommonmark
sphinx>=3.2.1
sphinx-autodoc-typehints
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ extend-ignore = ["F821"]
[tool.ruff.pydocstyle]
convention = "google"

[tool.ruff.format]
docstring-code-format = true
docstring-code-line-length = 20

[tool.ruff.per-file-ignores]
"__init__.py" = ["E402", "F401"]

Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ package_dir =
=src

# Require a min/specific Python version (comma-separated conditions)
python_requires = >=3.8
python_requires = >=3.9

# Add here dependencies of your project (line-separated), e.g. requests>=2.2,<3.0.
# Version specifiers like >=2.2,<3.0 avoid problems due to API changes in
Expand All @@ -50,7 +50,8 @@ python_requires = >=3.8
install_requires =
importlib-metadata; python_version<"3.8"
numpy
scipy<1.13.0
scipy<1.13.0; python_version<="3.9"
scipy; python_version>"3.9"


[options.packages.find]
Expand Down
16 changes: 4 additions & 12 deletions src/mopsy/adders.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
__license__ = "MIT"


def append_row(
mat: sp.sparse.spmatrix, row: Union[sp.sparse.spmatrix, np.ndarray]
) -> sp.sparse.spmatrix:
def append_row(mat: sp.sparse.spmatrix, row: Union[sp.sparse.spmatrix, np.ndarray]) -> sp.sparse.spmatrix:
"""A generic append function for sparse matrices.

Args:
Expand All @@ -32,9 +30,7 @@ def append_row(
return sparse_append(mat=mat, row_or_column=row, axis=0)


def append_col(
mat: sp.sparse.spmatrix, col: Union[sp.sparse.spmatrix, np.ndarray]
) -> sp.sparse.spmatrix:
def append_col(mat: sp.sparse.spmatrix, col: Union[sp.sparse.spmatrix, np.ndarray]) -> sp.sparse.spmatrix:
"""A generic append function for sparse matrices.

Args:
Expand Down Expand Up @@ -89,16 +85,12 @@ def sparse_append(
new_mat = None
if axis == 0:
if mat.shape[0] != row_or_column.shape[0]:
raise TypeError(
"Matrix and new row do not have the same shape along the first dimension."
)
raise TypeError("Matrix and new row do not have the same shape along the first dimension.")

new_mat = sp.sparse.vstack([mat, row_or_column])
else:
if mat.shape[1] != row_or_column.shape[0]:
raise TypeError(
"Matrix and new row do not have the same shape along the second dimension."
)
raise TypeError("Matrix and new row do not have the same shape along the second dimension.")

new_mat = sp.sparse.hstack([mat, row_or_column])

Expand Down
7 changes: 1 addition & 6 deletions src/mopsy/mops.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ def groupby_indices(self, group: Sequence) -> dict:
A dictionary with each group name as the key and the values containing
the list of indices that map to it.
"""
return {
k: [x[0] for x in v]
for k, v in groupby(
sorted(enumerate(group), key=lambda x: x[1]), lambda x: x[1]
)
}
return {k: [x[0] for x in v] for k, v in groupby(sorted(enumerate(group), key=lambda x: x[1]), lambda x: x[1])}

def _apply(self, func: Callable[[list], Any], axis: Union[int, bool]):
if self.non_zero:
Expand Down
4 changes: 1 addition & 3 deletions src/mopsy/nops.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ class Nops(Mops):
def __init__(self, mat: np.ndarray, non_zero: bool = False) -> None:
super().__init__(mat, non_zero=non_zero)

def iter(
self, group: Sequence[str] = None, axis: Union[int, bool] = 0
) -> Iterator[Tuple]:
def iter(self, group: Sequence[str] = None, axis: Union[int, bool] = 0) -> Iterator[Tuple]:
"""Iterator over groups and an axis.

Args:
Expand Down
4 changes: 1 addition & 3 deletions src/mopsy/sops.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def iter(self, group: list = None, axis: Union[int, bool] = 0) -> Iterator[Tuple
else:
yield (k, Sops(mat[:, v], self.non_zero))

def _apply(
self, func: Callable[[list], Any], axis: Union[int, bool] = 0
) -> np.ndarray:
def _apply(self, func: Callable[[list], Any], axis: Union[int, bool] = 0) -> np.ndarray:
mat = self.matrix.tocsc() if axis == 0 else self.matrix.tocsr()
if self.non_zero:
# reduction along an axis
Expand Down
Loading