Skip to content

Commit

Permalink
Deprecation warning for lists passed into DMatrix (#3970)
Browse files Browse the repository at this point in the history
* Ensure lists cannot be passed into DMatrix

The documentation does not include lists as an allowed type for the data inputted into DMatrix. Despite this, a list can be passed in without an error. This change would prevent a list form being passed in directly.
  • Loading branch information
scwilkinson authored and trivialfis committed Dec 14, 2018
1 parent 53f695a commit fd722d6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python-package/xgboost/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import os
import re
import sys
import warnings

import numpy as np
import scipy.sparse
Expand Down Expand Up @@ -381,6 +382,10 @@ def __init__(self, data, label=None, missing=None,
label = _maybe_dt_array(label)
weight = _maybe_dt_array(weight)

if isinstance(data, list):
warnings.warn('Initializing DMatrix from List is deprecated.',
DeprecationWarning)

if isinstance(data, STRING_TYPES):
self.handle = ctypes.c_void_p()
_check_call(_LIB.XGDMatrixCreateFromFile(c_str(data),
Expand Down

0 comments on commit fd722d6

Please sign in to comment.