Skip to content

Commit 961afc7

Browse files
msimacekjeremiedbb
andauthored
MNT Avoid numpy array resize refcheck in svmlight format (scikit-learn#31435)
Co-authored-by: Jérémie du Boisberranger <[email protected]>
1 parent 5e7e7bd commit 961afc7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

sklearn/datasets/_svmlight_format_fast.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ def _load_svmlight_file(f, dtype, bint multilabel, bint zero_based,
7878
if n_features and features[0].startswith(qid_prefix):
7979
_, value = features[0].split(COLON, 1)
8080
if query_id:
81-
query.resize(len(query) + 1)
82-
query[len(query) - 1] = np.int64(value)
81+
query = np.append(query, np.int64(value))
8382
features.pop(0)
8483
n_features -= 1
8584

0 commit comments

Comments
 (0)