Co-authored-by: Pat O'Reilly <patrick.oreilly256@gmail.com>
Co-authored-by: dsleo <leooleds@gmail.com>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Co-authored-by: Felipe Breve Siola <felipe.breve-siola@klarna.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Tim Head <betatim@gmail.com>
* fixed a cross-platform endian issue
* removed a duplicated dtype checking
* Trigger [arm64] CI
* added an entry to doc/whats_new/v0.24.rst
* moved my fix entry to sklearn.tree section
* Update sklearn/tree/_tree.pyx
Added comments
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
* code simplified
* fixed a typo in sklearn/tree/_tree.pyx
* Update doc/whats_new/v0.24.rst
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
* updated doc/whats_new/v0.24.rst
* Update sklearn/tree/_tree.pyx
Added a space after "if", to be PEP8 compliant.
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
* Update sklearn/tree/_tree.pyx
Co-authored-by: Qi Zhang <q.zhang@ibm.com>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
* Fix undefined behavior in _tree.pyx and _quad_tree.pyx
Accessing a member through a null pointer is undefined behavior, even if
no actual memory access is performed (like in this case, where it was
used only for offset computation). See the following link for an
explanation:
https://software.intel.com/content/www/us/en/develop/blogs/null-pointer-dereferencing-causes-undefined-behavior.html
The current approach will also fail when building with tools like ubsan
(undefined behavior sanitizer).
The standard way to compute offsets of struct members is the offsetof
macro but it seems it's not supported by Cython so I've used the
approach described here:
https://mail.python.org/pipermail/cython-devel/2013-April/003505.html
* Simplify definitions of types for numpy.
According to
9e9cdb0192 (issuecomment-638998985)
these dictionaries with offsets are there for old numpy versions and
they are no longer needed. We can use instead an approach similar to
https://github.com/scikit-learn/scikit-learn/pull/15097/files#diff-b071106a87a03ee4e9149e3f0a2b1180L187
I have verified that tests keep passing and that the undefined behavior
that motivated this pull request in the first place is still fixed.
* Document the new numpy type definition approach.
Added a brief comment and a link to stackoverflow thread that explain
why the simpler approach to define numpy types works.
* Fix typo 'dtyle'->'dtype'
* simplify apply_dense with memoryviews
* change more Xs to memviews in splitter
* remove commented out lines
* trying to remove y_stride
* float->dtype_t
* criterion has no more y_stride
* remove redundant constructs and handle const y input
* fix criterion docstring for y's dtype
* revert docstring for y
* formatting: no space between type name and [:, :]
* remove redundant X
* more cleanup on criterion
* address comment
* fix the issue with max_depth and BestFirstTreeBuilder
* fix the test
* fix max_depth overshoot in BFS expansion
* fix forest tests
* remove the warning, add whats_new entry
* remove extra line
* add affected classes to changed classes
* add other affected estimators to the whats_new changed models
* shorten whats_new changed models entry
* FIX MAE reg. criterion: Use safe_realloc to avoid memory leak
* Release GIL in safe_realloc and clean up scaffolding
* As gil is released in safe_realloc, no need of a with gil block
* Use except * to propagate error in all cdef functions
* Don't use except * for functions that return python objects
* Don't use except * for the comparison function passed to qsort
* Omissions and Errors
* Use safe_realloc now that gil is released there
* Fix realloc size
* Acquire GIL only if we need to raise
* Use except * more judiciously; Release gil only when raising; Add comments to clarify
* Actually that was unneeded; realloc will also allocate for the first time
* StackRecord*, PriorityHeapRecord* to fused type realloc_ptr; Use safe_realloc
* Use except -1 to propagate exceptions. This should avoid overheads
* Fix docstrings and add return 0 to reset methods
* TYPO
* REVIEW Remove redundant MemoryError raising calls