8000 minor changes again · scikit-learn/scikit-learn@c9435c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit c9435c9

Browse files
committed
minor changes again
1 parent 04a5437 commit c9435c9

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

sklearn/tree/_tree.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,11 @@ cdef class Tree:
542542
reaching node i.
543543
"""
544544
# Wrap for outside world.
545-
# WARNING: these reference the current `nodes` and `value` buffers, which
545+
# WARNING: these copy the current `nodes` and `value` buffers, which
546546
# must not be freed by a subsequent memory allocation.
547547
# (i.e. through `_resize` or `__setstate__`)
548548
property n_classes:
549549
def __get__(self):
550-
# it's small; copy for memory safety
551550
return sizet_ptr_to_ndarray(self.n_classes, self.n_outputs)
552551

553552
property children_left:

sklearn/tree/_utils.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ cdef inline UINT32_t our_rand_r(UINT32_t* seed) nogil:
6262

6363

6464
cdef inline np.ndarray sizet_ptr_to_ndarray(SIZE_t* data, SIZE_t size):
65-
"""Encapsulate data into a 1D numpy array of intp's."""
65+
"""Return copied data as 1D numpy array of intp's."""
6666
cdef np.npy_intp shape[1]
6767
shape[0] = <np.npy_intp> size
6868
return np.PyArray_SimpleNewFromData(1, shape, np.NPY_INTP, data).copy()

sklearn/tree/tests/test_tree.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,8 @@ def test_criterion_copy():
16211621
n_outputs = 3
16221622
n_classes = np.arange(3)
16231623
n_samples = 100
1624-
for copy_func in [copy.copy, copy.deepcopy]:
1624+
pickle_copy = lambda obj: pickle.loads(pickle.dumps(obj))
1625+
for copy_func in [copy.copy, copy.deepcopy, pickle_copy]:
16251626
for _, typename in CRITERIA_CLF.items():
16261627
criteria = typename(n_outputs, n_classes)
16271628
result = copy_func(criteria).__reduce__()

0 commit comments

Comments
 (0)
0