Skip to content

Commit d3f956b

Browse files
committed
use non-negative values for I;16 test data to match unsigned semantics
1 parent adacdeb commit d3f956b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

test/test_transforms.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,8 @@ def _get_1_channel_tensor_various_types():
614614
expected_output = img_data_byte.float().div(255.0).numpy()
615615
yield img_data_byte, expected_output, "L"
616616

617-
img_data_short = torch.ShortTensor(1, 4, 4).random_()
618-
expected_output = img_data_short.numpy().view(np.uint16)
617+
img_data_short = torch.ShortTensor(1, 4, 4).random_(0, 32767)
618+
expected_output = img_data_short.numpy().astype(np.uint16)
619619
yield img_data_short, expected_output, "I;16" if sys.byteorder == "little" else "I;16B"
620620

621621
img_data_int = torch.IntTensor(1, 4, 4).random_()
@@ -631,8 +631,8 @@ def _get_2d_tensor_various_types():
631631
expected_output = img_data_byte.float().div(255.0).numpy()
632632
yield img_data_byte, expected_output, "L"
633633

634-
img_data_short = torch.ShortTensor(4, 4).random_()
635-
expected_output = img_data_short.numpy().view(np.uint16)
634+
img_data_short = torch.ShortTensor(4, 4).random_(0, 32767)
635+
expected_output = img_data_short.numpy().astype(np.uint16)
636636
yield img_data_short, expected_output, "I;16" if sys.byteorder == "little" else "I;16B"
637637

638638
img_data_int = torch.IntTensor(4, 4).random_()

0 commit comments

Comments
 (0)