MCPcopy Index your code
hub / github.com/ray-project/ray / test_tensor_array_concat

Function test_tensor_array_concat

python/ray/data/tests/test_tensor_extension.py:729–743  ·  view source on GitHub ↗
(a1, a2, tensor_format_context)

Source from the content-addressed store, hash-verified

727
728@pytest.mark.parametrize("a1,a2", pytest_tensor_array_concat_arr_combinations)
729def test_tensor_array_concat(a1, a2, tensor_format_context):
730 ta1 = TensorArray(a1)
731 ta2 = TensorArray(a2)
732 ta = TensorArray._concat_same_type([ta1, ta2])
733 assert len(ta) == a1.shape[0] + a2.shape[0]
734 assert ta.dtype.element_dtype == ta1.dtype.element_dtype
735 if a1.shape[1:] == a2.shape[1:]:
736 assert ta.dtype.element_shape == a1.shape[1:]
737 np.testing.assert_array_equal(ta.to_numpy(), np.concatenate([a1, a2]))
738 else:
739 assert ta.dtype.element_shape == (None,) * (len(a1.shape) - 1)
740 for arr, expected in zip(
741 ta.to_numpy(), np.array([e for a in [a1, a2] for e in a], dtype=object)
742 ):
743 np.testing.assert_array_equal(arr, expected)
744
745
746@pytest.mark.parametrize("a1,a2", pytest_tensor_array_concat_arr_combinations)

Callers

nothing calls this directly

Calls 3

TensorArrayClass · 0.90
_concat_same_typeMethod · 0.45
to_numpyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…