MCPcopy
hub / github.com/scikit-learn/scikit-learn / check_consistent_length

Function check_consistent_length

sklearn/utils/validation.py:439–461  ·  view source on GitHub ↗

Check that all arrays have consistent first dimensions. Checks whether all objects in arrays have the same shape or length. Parameters ---------- *arrays : list or tuple of input objects. Objects that will be checked for consistent length. Examples -------- >>>

(*arrays)

Source from the content-addressed store, hash-verified

437
438
439def check_consistent_length(*arrays):
440 """Check that all arrays have consistent first dimensions.
441
442 Checks whether all objects in arrays have the same shape or length.
443
444 Parameters
445 ----------
446 *arrays : list or tuple of input objects.
447 Objects that will be checked for consistent length.
448
449 Examples
450 --------
451 >>> from sklearn.utils.validation import check_consistent_length
452 >>> a = [1, 2, 3]
453 >>> b = [2, 3, 4]
454 >>> check_consistent_length(a, b)
455 """
456 lengths = [_num_samples(X) for X in arrays if X is not None]
457 if len(set(lengths)) > 1:
458 raise ValueError(
459 "Found input variables with inconsistent numbers of samples: %r"
460 % [int(l) for l in lengths]
461 )
462
463
464def _make_indexable(iterable):

Callers 15

fitMethod · 0.90
calibration_curveFunction · 0.90
fitMethod · 0.90
fitMethod · 0.90
fitMethod · 0.90
resampleFunction · 0.90
_fit_encodings_allMethod · 0.90

Calls 1

_num_samplesFunction · 0.85

Tested by 4

_my_lrapFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…