code: def test_dmatrix_numpy_init(self):
      data = np.random.randn(5, 5)
      dm = xgb.DMatrix(data)
      assert dm.num_row() == 5
      assert dm.num_col() == 5
  
      data = np.matrix([[1, 2], [3, 4]])
      dm = xgb.DMatrix(data)
      assert dm.num_row() == 2
      assert dm.num_col() == 2
  
      # 0d array
      self.assertRaises(ValueError, xgb.DMatrix, np.array(1))
      # 1d array
      self.assertRaises(ValueError, xgb.DMatrix, np.array([1, 2, 3]))
      # 3d array
      data = np.random.randn(5, 5, 5)
      self.assertRaises(ValueError, xgb.DMatrix, data)
      # object dtype
      data = np.array([["a", "b"], ["c", "d"]])
      self.assertRaises(ValueError, xgb.DMatrix, data)
  
file_path: turicreate/src/external/xgboost/tests/python/test_basic.py
imports: import numpy
  import xgboost
  import unittest
  import matplotlib
label_desc: Use image node_id 6 for calling the TestBasic obj's underlying member method code with example usage: obj.test_dmatrix_numpy_init() without return types