validate2DInput function

void validate2DInput(
  1. List<List<double>> data
)

Utility functions for validating 2D numerical input for scalers. Checks that input is a non-empty 2D list with consistent row lengths.

Implementation

/// Checks that input is a non-empty 2D list with consistent row lengths.
void validate2DInput(List<List<double>> data) {
  if (data.isEmpty) {
    throw ArgumentError('Input data is empty.');
  }

  final expectedLength = data[0].length;
  for (final row in data) {
    if (row.length != expectedLength) {
      throw ArgumentError('Inconsistent row lengths in 2D data.');
    }
  }
}