Skip to content

Commit

Permalink
Merge pull request #3 from MatthewSZhang/cython-final
Browse files Browse the repository at this point in the history
MNT add final decorator in cython
  • Loading branch information
MatthewSZhang authored Aug 20, 2024
2 parents 4d313e1 + 2c3cdf4 commit aed7cad
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
11 changes: 8 additions & 3 deletions fastcan/_cancorr_fast.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
# Fast feature selection with sum squared canoncial correlation coefficents
from libc.stdlib cimport malloc, free
from libc.string cimport memset
from cython cimport floating
from cython cimport floating, final
from cython.parallel import prange
from scipy.linalg.cython_blas cimport isamax, idamax
from sklearn.utils._cython_blas cimport ColMajor, NoTrans
from sklearn.utils._cython_blas cimport _dot, _scal, _nrm2, _gemm, _axpy
from sklearn.utils._typedefs cimport int32_t

@final
cdef unsigned int _bsum(
bint* x,
unsigned int n,
Expand All @@ -23,6 +24,7 @@ cdef unsigned int _bsum(
total += x[i]
return total

@final
cdef int _iamax(
int n,
const floating *x,
Expand All @@ -38,6 +40,7 @@ cdef int _iamax(
else:
return idamax(&n, <double *> x, &incx) - 1

@final
cdef bint _normv(
floating[::1] x, # IN/OUT
) noexcept nogil:
Expand All @@ -58,6 +61,7 @@ cdef bint _normv(
_scal(n_samples, x_norm, &x[0], 1)
return False

@final
cdef void _normm(
floating[::1, :] X, # IN/OUT
bint* m, # IN/OUT
Expand All @@ -84,7 +88,7 @@ cdef void _normm(
x_norm = 1.0/x_norm
_scal(n_samples, x_norm, &X[0, j], 1)


@final
cdef floating _sscvm(
const floating[::1] w, # IN
const floating[::1, :] V, # IN
Expand Down Expand Up @@ -114,6 +118,7 @@ cdef floating _sscvm(
free(r)
return r2

@final
cdef void _mgsvv(
const floating[::1] w, # IN
floating[::1] x, # IN/OUT
Expand All @@ -133,7 +138,7 @@ cdef void _mgsvv(
# x = x - w*r
_axpy(n_samples, -r, &w[0], 1, &x[0], 1)


@final
cpdef int _forward_search(
floating[::1, :] X, # IN/OUT
floating[::1, :] V, # IN
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
'fastcan',
'c', 'cython',
version: '0.1.26',
version: '0.2.1',
license: 'MIT',
meson_version: '>= 1.1.0',
default_options: [
Expand Down
28 changes: 16 additions & 12 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ test-coverage = { cmd = "rm -rf .coverage && pytest --cov-report $FMT --cov=$PAC
[tool.pixi.feature.build.tasks]
build-wheel = "rm -rf dist && python -m build -wnx -Cinstall-args=--tags=runtime,python-runtime,devel"
build-sdist = "rm -rf dist && python -m build --sdist"
rebuild = "uv pip install --no-deps --force-reinstall -e ."
rebuild = "rm -rf build && uv pip install --no-deps --force-reinstall -e ."

[tool.pixi.feature.fmt.tasks]
fmt = { cmd = "black .", cwd = "fastcan" }
Expand Down

0 comments on commit aed7cad

Please sign in to comment.