Skip to content

Commit

Permalink
Replace cpdef variables with cdef variables. (rapidsai#5145)
Browse files Browse the repository at this point in the history
This PR fixes some warnings in the cuml Python build that will become errors in Cython 3. Examples follow:
```
cuml/python/cuml/decomposition/pca.pyx:334:14: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
cuml/python/cuml/decomposition/pca.pyx:587:14: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
cuml/python/cuml/decomposition/pca.pyx:683:14: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
cuml/python/cuml/decomposition/tsvd.pyx:282:14: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
cuml/python/cuml/decomposition/tsvd.pyx:398:14: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
cuml/python/cuml/decomposition/tsvd.pyx:450:14: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
cuml/python/cuml/decomposition/pca_mg.pyx:94:14: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
cuml/python/cuml/decomposition/tsvd_mg.pyx:77:14: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
cuml/python/cuml/fil/fil.pyx:82:10: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
cuml/python/cuml/fil/fil.pyx:83:10: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
```

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - William Hicks (https://github.com/wphicks)
  - Carl Simon Adorf (https://github.com/csadorf)

URL: rapidsai#5145
  • Loading branch information
bdice authored Feb 2, 2023
1 parent 3d72079 commit 96f45f3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions python/cuml/decomposition/pca.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class PCA(UniversalBase,
return algo_map[algorithm]

def _build_params(self, n_rows, n_cols):
cpdef paramsPCA *params = new paramsPCA()
cdef paramsPCA *params = new paramsPCA()
params.n_components = self.n_components_
params.n_rows = n_rows
params.n_cols = n_cols
Expand Down Expand Up @@ -582,7 +582,7 @@ class PCA(UniversalBase,
cdef uintptr_t _trans_input_ptr = X_m.ptr

# todo: check n_cols and dtype
cpdef paramsPCA params
cdef paramsPCA params
params.n_components = self.n_components_
params.n_rows = n_rows
params.n_cols = self.n_features_in_
Expand Down Expand Up @@ -678,7 +678,7 @@ class PCA(UniversalBase,
cdef uintptr_t input_ptr = X_m.ptr

# todo: check dtype
cpdef paramsPCA params
cdef paramsPCA params
params.n_components = self.n_components_
params.n_rows = n_rows
params.n_cols = n_cols
Expand Down
2 changes: 1 addition & 1 deletion python/cuml/decomposition/pca_mg.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class PCAMG(BaseDecompositionMG, PCA):
return algo_map[algorithm]

def _build_params(self, n_rows, n_cols):
cpdef paramsPCAMG *params = new paramsPCAMG()
cdef paramsPCAMG *params = new paramsPCAMG()
params.n_components = self.n_components_
params.n_rows = n_rows
params.n_cols = n_cols
Expand Down
6 changes: 3 additions & 3 deletions python/cuml/decomposition/tsvd.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class TruncatedSVD(UniversalBase,
return algo_map[algorithm]

def _build_params(self, n_rows, n_cols):
cpdef paramsTSVD *params = new paramsTSVD()
cdef paramsTSVD *params = new paramsTSVD()
params.n_components = self.n_components
params.n_rows = n_rows
params.n_cols = n_cols
Expand Down Expand Up @@ -395,7 +395,7 @@ class TruncatedSVD(UniversalBase,
convert_to_dtype=(dtype if convert_dtype
else None))

cpdef paramsTSVD params
cdef paramsTSVD params
params.n_components = self.n_components
params.n_rows = n_rows
params.n_cols = self.n_features_in_
Expand Down Expand Up @@ -447,7 +447,7 @@ class TruncatedSVD(UniversalBase,
else None),
check_cols=self.n_features_in_)

cpdef paramsTSVD params
cdef paramsTSVD params
params.n_components = self.n_components
params.n_rows = n_rows
params.n_cols = self.n_features_in_
Expand Down
2 changes: 1 addition & 1 deletion python/cuml/decomposition/tsvd_mg.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class TSVDMG(BaseDecompositionMG, TruncatedSVD):
super(TSVDMG, self).__init__(**kwargs)

def _build_params(self, n_rows, n_cols):
cpdef paramsTSVDMG *params = new paramsTSVDMG()
cdef paramsTSVDMG *params = new paramsTSVDMG()
params.n_components = self.n_components_
params.n_rows = n_rows
params.n_cols = n_cols
Expand Down
4 changes: 2 additions & 2 deletions python/cuml/fil/fil.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ cdef class TreeliteModel():
handle : ModelHandle
Opaque pointer to Treelite model
"""
cpdef ModelHandle handle
cpdef bool owns_handle
cdef ModelHandle handle
cdef bool owns_handle

def __cinit__(self, owns_handle=True):
"""If owns_handle is True, free the handle's model in destructor.
Expand Down

0 comments on commit 96f45f3

Please sign in to comment.