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

Python 3.13 support #174

Merged
merged 16 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
- name: Install cibuildwheel
run: |
pip install --upgrade pip
pip install cibuildwheel==2.15.0
pip install cibuildwheel==2.21.3

- name: Build wheels
env:
CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-* cp312-*'
CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-* cp312-* cp313-*'
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_SKIP: pp* *-musllinux_* *-manylinux_i686 # skip PyPy, musllinux, 32-bit Linux
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false # Allow one of the matrix builds to fail without failing others
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- name: Checkout
Expand Down
16 changes: 8 additions & 8 deletions KDEpy/cutils_ext/cutils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ from libc.math cimport floor
# for nor correctly handle negative indices

# cdivision(True) -> If set to False, Cython will adjust the remainder and
# quotient operators C types to match those of Python ints (which differ
# quotient operators C types to match those of Pyethon ints (which differ
philipp-horstenkamp marked this conversation as resolved.
Show resolved Hide resolved
# when the operands have opposite signs) and raise a ZeroDivisionError
# when the right operand is 0
@cython.boundscheck(False)
Expand Down Expand Up @@ -213,7 +213,7 @@ def iterate_data_ND(double[:, :] data, double[:] result, long[:] grid_num,
grid_num : number of grid points in each dimension
obs_tot : total number of observations (grid points)
binary_flgs : array of shape (dims, 2**dims), counting in binary
this is used to to go every corner point efficiently
this is used to go every corner point efficiently
"""
cdef int obs, result_index, i, dims, corners, j, flg, corner, integer_xi
cdef double corner_value, fraction
Expand All @@ -223,7 +223,7 @@ def iterate_data_ND(double[:, :] data, double[:] result, long[:] grid_num,
obs, dims = data.shape[0], data.shape[1]

# For every dimension, there are two directions to find corners in
corners = 2**dims
corners = int(2**dims)

# Loop through every data point
for i in range(obs):
Expand All @@ -246,11 +246,11 @@ def iterate_data_ND(double[:, :] data, double[:] result, long[:] grid_num,
# Since we use flags to indicate x_1 or x_1 + 1, the following
# code does the job:
result_index = int(x_i[0])
result_index += 0**binary_flgs[corner, 0]
result_index += int(0**binary_flgs[corner, 0])
for j in range(1, dims):
result_index *= grid_num[j]
integer_xi = <int> floor(x_i[j])
result_index += (integer_xi + 0**binary_flgs[corner, j])
result_index += (integer_xi + int(0**binary_flgs[corner, j]))

# (2) The value is found by
# PROD_{i=0} (1 - frac(x[i))**flg * frac(x[i]) ** (1 - flg)
Expand Down Expand Up @@ -281,7 +281,7 @@ def iterate_data_ND_weighted(double[:, :] data, double[:] weights, double[:] res
cdef double[:] x_i

obs, dims = data.shape[0], data.shape[1]
corners = 2**dims
corners = int(2**dims)

for i in range(obs):
x_i = data[i, :]
Expand All @@ -290,11 +290,11 @@ def iterate_data_ND_weighted(double[:, :] data, double[:] weights, double[:] res
for corner in range(corners):

result_index = int(x_i[0])
result_index += 0**binary_flgs[corner, 0]
result_index += int(0**binary_flgs[corner, 0])
for j in range(1, dims):
result_index *= grid_num[j]
integer_xi = <int> floor(x_i[j])
result_index += (integer_xi + 0**binary_flgs[corner, j])
result_index += (integer_xi + int(0**binary_flgs[corner, j]))

corner_value = 1.0
for j in range(dims):
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]

[project.urls]
Expand All @@ -43,5 +44,5 @@ lint = [
]

[build-system]
requires = ["setuptools>=45", "wheel", "cython>=0.29,<1.0.0", "oldest-supported-numpy"]
requires = ["setuptools>=45", "wheel", "cython>=3.0,<4.0", "oldest-supported-numpy"]
build-backend = "setuptools.build_meta"
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
https://github.com/pypa/sampleproject
"""

from Cython.Build import cythonize
import numpy as np
from Cython.Distutils import build_ext
from setuptools import Extension, setup
Expand All @@ -15,5 +16,7 @@
packages=["KDEpy"],
cmdclass={"build_ext": build_ext},
include_dirs=[np.get_include()],
ext_modules=[Extension("KDEpy._cutils", ["KDEpy/cutils_ext/cutils.pyx"])],
ext_modules=cythonize(
[Extension("KDEpy._cutils", ["KDEpy/cutils_ext/cutils.pyx"])],
),
)