Skip to content

[MAINT] Remove deprecated implementation of properties in extension class in tree/ #26295

@adam2392

Description

@adam2392

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions