Skip to content

Commit

Permalink
[*] update tests (fix pipeline)
Browse files Browse the repository at this point in the history
  • Loading branch information
tirivo committed Jun 28, 2024
1 parent 9e068ee commit 528b282
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions python/tests/test_storage_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import test_utils

import ctranslate2
import logging

LOGGER = logging.getLogger(__name__)


def _assert_same_array(a, b):
Expand Down Expand Up @@ -37,11 +40,26 @@ def test_storageview_cpu(dtype, name):
with pytest.raises(AttributeError, match="CPU"):
s.__cuda_array_interface__

assert str(s) == " 1 1 1 ... 1 1 1\n[cpu:0 %s storage viewed as 2x4]" % name
expected_output = (
"Data (2D Matrix):"
"\n[[1, 1, 1, 1], "
"\n[1, 1, 1, 1]]"
"\n[device:{}:{}, dtype:{}, storage viewed as {}x{}]"
).format(s.device, s.device_index, name, s.shape[0], s.shape[1])

assert str(s) == expected_output

x[0][2] = 3
x[1][3] = 8
assert str(s) == " 1 1 3 ... 1 1 8\n[cpu:0 %s storage viewed as 2x4]" % name

expected_output = (
"Data (2D Matrix):"
"\n[[1, 1, 3, 1], "
"\n[1, 1, 1, 8]]"
"\n[device:{}:{}, dtype:{}, storage viewed as {}x{}]"
).format(s.device, s.device_index, name, s.shape[0], s.shape[1])

assert str(s) == expected_output

y = np.array(x)
assert test_utils.array_equal(x, y)
Expand Down

0 comments on commit 528b282

Please sign in to comment.