Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update _criterion.pyx #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions deepforest/tree/_criterion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cdef class Criterion:

cdef int init(self, const DOUBLE_t[:, ::1] y, DOUBLE_t* sample_weight,
double weighted_n_samples, SIZE_t* samples, SIZE_t start,
SIZE_t end) nogil except -1:
SIZE_t end) except -1 nogil:
"""Placeholder for a method which will initialize the criterion.

Returns -1 in case of failure to allocate memory (and raise MemoryError)
Expand All @@ -69,22 +69,22 @@ cdef class Criterion:

pass

cdef int reset(self) nogil except -1:
cdef int reset(self) except -1 nogil:
"""Reset the criterion at pos=start.

This method must be implemented by the subclass.
"""

pass

cdef int reverse_reset(self) nogil except -1:
cdef int reverse_reset(self) except -1 nogil:
"""Reset the criterion at pos=end.

This method must be implemented by the subclass.
"""
pass

cdef int update(self, SIZE_t new_pos) nogil except -1:
cdef int update(self, SIZE_t new_pos) except -1 nogil:
"""Updated statistics by moving samples[pos:new_pos] to the left child.

This updates the collected statistics by moving samples[pos:new_pos]
Expand Down Expand Up @@ -268,7 +268,7 @@ cdef class ClassificationCriterion(Criterion):

cdef int init(self, const DOUBLE_t[:, ::1] y,
DOUBLE_t* sample_weight, double weighted_n_samples,
SIZE_t* samples, SIZE_t start, SIZE_t end) nogil except -1:
SIZE_t* samples, SIZE_t start, SIZE_t end) except -1 nogil:
"""Initialize the criterion at node samples[start:end] and
children samples[start:start] and samples[start:end].

Expand Down Expand Up @@ -333,7 +333,7 @@ cdef class ClassificationCriterion(Criterion):
self.reset()
return 0

cdef int reset(self) nogil except -1:
cdef int reset(self) except -1 nogil:
"""Reset the criterion at pos=start

Returns -1 in case of failure to allocate memory (and raise MemoryError)
Expand All @@ -360,7 +360,7 @@ cdef class ClassificationCriterion(Criterion):
sum_right += self.sum_stride
return 0

cdef int reverse_reset(self) nogil except -1:
cdef int reverse_reset(self) except -1 nogil:
"""Reset the criterion at pos=end

Returns -1 in case of failure to allocate memory (and raise MemoryError)
Expand All @@ -387,7 +387,7 @@ cdef class ClassificationCriterion(Criterion):
sum_right += self.sum_stride
return 0

cdef int update(self, SIZE_t new_pos) nogil except -1:
cdef int update(self, SIZE_t new_pos) except -1 nogil:
"""Updated statistics by moving samples[pos:new_pos] to the left child.

Returns -1 in case of failure to allocate memory (and raise MemoryError)
Expand Down Expand Up @@ -729,7 +729,7 @@ cdef class RegressionCriterion(Criterion):

cdef int init(self, const DOUBLE_t[:, ::1] y, DOUBLE_t* sample_weight,
double weighted_n_samples, SIZE_t* samples, SIZE_t start,
SIZE_t end) nogil except -1:
SIZE_t end) except -1 nogil:
"""Initialize the criterion at node samples[start:end] and
children samples[start:start] and samples[start:end]."""
# Initialize fields
Expand Down Expand Up @@ -770,7 +770,7 @@ cdef class RegressionCriterion(Criterion):
self.reset()
return 0

cdef int reset(self) nogil except -1:
cdef int reset(self) except -1 nogil:
"""Reset the criterion at pos=start."""
cdef SIZE_t n_bytes = self.n_outputs * sizeof(double)
memset(self.sum_left, 0, n_bytes)
Expand All @@ -781,7 +781,7 @@ cdef class RegressionCriterion(Criterion):
self.pos = self.start
return 0

cdef int reverse_reset(self) nogil except -1:
cdef int reverse_reset(self) except -1 nogil:
"""Reset the criterion at pos=end."""
cdef SIZE_t n_bytes = self.n_outputs * sizeof(double)
memset(self.sum_right, 0, n_bytes)
Expand All @@ -792,7 +792,7 @@ cdef class RegressionCriterion(Criterion):
self.pos = self.end
return 0

cdef int update(self, SIZE_t new_pos) nogil except -1:
cdef int update(self, SIZE_t new_pos) except -1 nogil:
"""Updated statistics by moving samples[pos:new_pos] to the left."""

cdef double* sum_left = self.sum_left
Expand Down Expand Up @@ -1013,7 +1013,7 @@ cdef class MAE(RegressionCriterion):

cdef int init(self, const DOUBLE_t[:, ::1] y, DOUBLE_t* sample_weight,
double weighted_n_samples, SIZE_t* samples, SIZE_t start,
SIZE_t end) nogil except -1:
SIZE_t end) except -1 nogil:
"""Initialize the criterion at node samples[start:end] and
children samples[start:start] and samples[start:end]."""

Expand Down Expand Up @@ -1061,7 +1061,7 @@ cdef class MAE(RegressionCriterion):
self.reset()
return 0

cdef int reset(self) nogil except -1:
cdef int reset(self) except -1 nogil:
"""Reset the criterion at pos=start

Returns -1 in case of failure to allocate memory (and raise MemoryError)
Expand Down Expand Up @@ -1093,7 +1093,7 @@ cdef class MAE(RegressionCriterion):
weight)
return 0

cdef int reverse_reset(self) nogil except -1:
cdef int reverse_reset(self) except -1 nogil:
"""Reset the criterion at pos=end

Returns -1 in case of failure to allocate memory (and raise MemoryError)
Expand Down Expand Up @@ -1122,7 +1122,7 @@ cdef class MAE(RegressionCriterion):
weight)
return 0

cdef int update(self, SIZE_t new_pos) nogil except -1:
cdef int update(self, SIZE_t new_pos) except -1 nogil:
"""Updated statistics by moving samples[pos:new_pos] to the left

Returns -1 in case of failure to allocate memory (and raise MemoryError)
Expand Down