MCPcopy Create free account
hub / github.com/google-deepmind/chex / assert_equal_size

Function assert_equal_size

chex/_src/asserts.py:371–385  ·  view source on GitHub ↗

Checks that all arrays have the same size. Args: inputs: A collection of arrays. Raises: AssertionError: If the size of all arrays do not match.

(inputs: Sequence[Array])

Source from the content-addressed store, hash-verified

369
370@_static_assertion
371def assert_equal_size(inputs: Sequence[Array]) -> None:
372 """Checks that all arrays have the same size.
373
374 Args:
375 inputs: A collection of arrays.
376
377 Raises:
378 AssertionError: If the size of all arrays do not match.
379 """
380 _ai.assert_collection_of_arrays(inputs)
381 size = inputs[0].size
382 expected_sizes = [size] * len(inputs)
383 sizes = [x.size for x in inputs]
384 if sizes != expected_sizes:
385 raise AssertionError(f"Arrays have different sizes: {sizes}")
386
387
388@_static_assertion

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…