obliquetree 1.0.1__cp310-cp310-win_amd64.whl → 1.0.2__cp310-cp310-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of obliquetree might be problematic. Click here for more details.

obliquetree/_pywrap.py CHANGED
@@ -255,11 +255,12 @@ class BaseTree(TreeClassifier):
255
255
  if not all(isinstance(x, int) for x in categories):
256
256
  raise ValueError("All elements in categories must be integers")
257
257
  if any(x < 0 for x in categories):
258
- raise ValueError("All elements in categories must be non-negative integers")
258
+ raise ValueError(
259
+ "All elements in categories must be non-negative integers"
260
+ )
259
261
  return list(categories)
260
262
  return []
261
263
 
262
-
263
264
  def _validate_use_oblique(self, use_oblique: bool) -> bool:
264
265
  if not isinstance(use_oblique, bool):
265
266
  raise ValueError("use_oblique must be a boolean")
@@ -293,6 +294,16 @@ class BaseTree(TreeClassifier):
293
294
  X = np.asarray(X, order="F", dtype=np.float64)
294
295
  y = np.asarray(y, order="C", dtype=np.float64)
295
296
 
297
+ if X.ndim != 2:
298
+ raise ValueError(
299
+ f"Expected a 2D array for input samples, but got an array with {X.ndim} dimensions."
300
+ )
301
+
302
+ if X.shape[0] != y.shape[0]:
303
+ raise ValueError(
304
+ f"The number of samples in `X` ({X.shape[0]}) does not match the number of target values in `y` ({y.shape[0]})."
305
+ )
306
+
296
307
  # Validate target vector
297
308
  self._validate_target(y)
298
309
 
@@ -411,7 +422,7 @@ class BaseTree(TreeClassifier):
411
422
  raise ValueError(
412
423
  f"Category column index {col_idx} exceeds X dimensions ({X.shape[1]} features)."
413
424
  )
414
-
425
+
415
426
  # Kategorik sütunlardaki değerler negatif olmamalı
416
427
  if (X[:, self.categories] < 0).any():
417
428
  raise ValueError(
@@ -451,6 +462,12 @@ class BaseTree(TreeClassifier):
451
462
  )
452
463
 
453
464
  X = np.asarray(X, order="F", dtype=np.float64)
465
+
466
+ if X.ndim != 2:
467
+ raise ValueError(
468
+ f"Expected a 2D array for input samples, but got an array with {X.ndim} dimensions. "
469
+ )
470
+
454
471
  return super().predict(X)
455
472
 
456
473
 
Binary file