Esempio n. 1
0
def test_convert_int64_box_message():
    box = Int64Box(
        low=Int64Tensor(value=[1, 2], shape=[1, 2]),
        high=Int64Tensor(value=[2, 3], shape=[1, 2]),
    )
    converted_box = py_converters.convert_box_message(box)
    assert isinstance(converted_box, Box)
    assert converted_box.dtype == np.int64
    assert np.array_equal(box.low.shape, converted_box.shape)
    assert np.array_equal(box.high.shape, converted_box.shape)
    assert np.array_equal(box.low.value, converted_box.low.flatten())
    assert np.array_equal(box.high.value, converted_box.high.flatten())
Esempio n. 2
0
def test_convert_double_box_message():
    box = DoubleBox(
        low=DoubleTensor(value=[1, 2], shape=[1, 2]),
        high=DoubleTensor(value=[2, 3], shape=[1, 2]),
    )
    converted_box = py_converters.convert_box_message(box)
    assert isinstance(converted_box, Box)
    assert converted_box.dtype == float
    assert np.array_equal(box.low.shape, converted_box.shape)
    assert np.array_equal(box.high.shape, converted_box.shape)
    assert np.array_equal(box.low.value, converted_box.low.flatten())
    assert np.array_equal(box.high.value, converted_box.high.flatten())
Esempio n. 3
0
def test_convert_byte_box_message():
    box = ByteBox(
        low=ByteTensor(value=bytes([1, 2]), shape=[1, 2]),
        high=ByteTensor(value=bytes([2, 3]), shape=[1, 2]),
    )
    converted_box = py_converters.convert_box_message(box)
    assert isinstance(converted_box, Box)
    assert converted_box.dtype == np.int8
    assert np.array_equal(box.low.shape, converted_box.shape)
    assert np.array_equal(box.high.shape, converted_box.shape)
    assert np.array_equal(box.low.value, bytes(converted_box.low.flatten()))
    assert np.array_equal(box.high.value, bytes(converted_box.high.flatten()))