From 794de72cf9d4c10b3731984e5400911150001ad3 Mon Sep 17 00:00:00 2001 From: Jonathan <47629418+Jonathan43@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:48:26 +0200 Subject: [PATCH] Update _criterion.pyx The keyword 'nogil' should appear at the end of the function signature line. Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython. --- deepforest/tree/_criterion.pyx | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/deepforest/tree/_criterion.pyx b/deepforest/tree/_criterion.pyx index 32bfe7d..dbc2d4d 100644 --- a/deepforest/tree/_criterion.pyx +++ b/deepforest/tree/_criterion.pyx @@ -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) @@ -69,7 +69,7 @@ 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. @@ -77,14 +77,14 @@ cdef class Criterion: 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] @@ -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]. @@ -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) @@ -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) @@ -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) @@ -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 @@ -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) @@ -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) @@ -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 @@ -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].""" @@ -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) @@ -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) @@ -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)