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)
| 437 | |
| 438 | |
| 439 | def 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 | |
| 464 | def _make_indexable(iterable): |
searching dependent graphs…