-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Closed
Labels
Description
I was using some of the sklearn/tree Cython code and noticed my IDE raised an issue stating that the current implementation of the class properties is deprecated:
scikit-learn/sklearn/tree/_tree.pyx
Lines 594 to 632 in 1882672
| property n_classes: | |
| def __get__(self): | |
| return sizet_ptr_to_ndarray(self.n_classes, self.n_outputs) | |
| property children_left: | |
| def __get__(self): | |
| return self._get_node_ndarray()['left_child'][:self.node_count] | |
| property children_right: | |
| def __get__(self): | |
| return self._get_node_ndarray()['right_child'][:self.node_count] | |
| property n_leaves: | |
| def __get__(self): | |
| return np.sum(np.logical_and( | |
| self.children_left == -1, | |
| self.children_right == -1)) | |
| property feature: | |
| def __get__(self): | |
| return self._get_node_ndarray()['feature'][:self.node_count] | |
| property threshold: | |
| def __get__(self): | |
| return self._get_node_ndarray()['threshold'][:self.node_count] | |
| property impurity: | |
| def __get__(self): | |
| return self._get_node_ndarray()['impurity'][:self.node_count] | |
| property n_node_samples: | |
| def __get__(self): | |
| return self._get_node_ndarray()['n_node_samples'][:self.node_count] | |
| property weighted_n_node_samples: | |
| def __get__(self): | |
| return self._get_node_ndarray()['weighted_n_node_samples'][:self.node_count] | |
| property value: |
See Cython docs https://cython.readthedocs.io/en/stable/src/userguide/extension_types.html#properties.
I propose to change everything to the non-deprecated Python-like property syntax here. If this is acceptable, then I can make a PR.