Skip to content

Commit

Permalink
Fix cython-lint issues. (#5536)
Browse files Browse the repository at this point in the history
This PR fixes some style issues from `cython-lint` that appear to be blocking CI for PR #5534. It seems that these issues only appear when using `cython>=3`. It is not clear to me why these issues are just now showing up (rather than appearing immediately once Cython 3 was released).

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

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)
  - Simon Adorf (https://github.com/csadorf)

URL: #5536
  • Loading branch information
bdice authored Aug 1, 2023
1 parent 2f85c6a commit 3234b9f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion python/cuml/cluster/hdbscan/prediction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -469,5 +469,5 @@ def approximate_predict(clusterer, points_to_predict, convert_dtype=True):
<float*> prediction_probs_ptr)

clusterer.handle.sync()
return prediction_labels.to_output(output_type="numpy"),\
return prediction_labels.to_output(output_type="numpy"), \
prediction_probs.to_output(output_type="numpy", output_dtype="float32")
8 changes: 4 additions & 4 deletions python/cuml/ensemble/randomforest_common.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ class BaseRandomForestModel(Base):
self.treelite_serialized_model = None

def _get_max_feat_val(self) -> float:
if type(self.max_features) == int:
if isinstance(self.max_features, int):
return self.max_features/self.n_cols
elif type(self.max_features) == float:
elif isinstance(self.max_features, float):
return self.max_features
elif self.max_features == 'sqrt':
return 1/np.sqrt(self.n_cols)
Expand Down Expand Up @@ -302,10 +302,10 @@ class BaseRandomForestModel(Base):
"to fit the estimator")

max_feature_val = self._get_max_feat_val()
if type(self.min_samples_leaf) == float:
if isinstance(self.min_samples_leaf, float):
self.min_samples_leaf = \
math.ceil(self.min_samples_leaf * self.n_rows)
if type(self.min_samples_split) == float:
if isinstance(self.min_samples_split, float):
self.min_samples_split = \
max(2, math.ceil(self.min_samples_split * self.n_rows))
return X_m, y_m, max_feature_val
Expand Down
8 changes: 4 additions & 4 deletions python/cuml/tsa/holtwinters.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class ExponentialSmoothing(Base):
output_type=output_type)

# Total number of Time Series for forecasting
if type(ts_num) != int:
if not isinstance(ts_num, int):
raise TypeError("Type of ts_num must be int. Given: " +
type(ts_num))
if ts_num <= 0:
Expand All @@ -203,7 +203,7 @@ class ExponentialSmoothing(Base):
self.ts_num = ts_num

# Season length in the time series
if type(seasonal_periods) != int:
if not isinstance(seasonal_periods, int):
raise TypeError("Type of seasonal_periods must be int."
" Given: " + type(seasonal_periods))
if seasonal_periods < 2:
Expand All @@ -223,7 +223,7 @@ class ExponentialSmoothing(Base):
"\"additive\" or \"multiplicative\".")

# number of seasons to be used for seasonal seed values
if type(start_periods) != int:
if not isinstance(start_periods, int):
raise TypeError("Type of start_periods must be int. Given: " +
type(start_periods))
if start_periods < 2:
Expand Down Expand Up @@ -390,7 +390,7 @@ class ExponentialSmoothing(Base):
cdef uintptr_t forecast_ptr, level_ptr, trend_ptr, season_ptr
cdef handle_t* handle_ = <handle_t*><size_t>self.handle.getHandle()

if type(h) != int or (type(index) != int and index is not None):
if not isinstance(h, int) or (not isinstance(index, int) and index is not None):
raise TypeError("Input arguments must be of type int."
"Index has type: " + str(type(index))
+ "\nh has type: " + str(type(h)))
Expand Down

0 comments on commit 3234b9f

Please sign in to comment.