Skip to content

Commit 3298944

Browse files
committed
add shape attribute
1 parent ddf86fc commit 3298944

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

bioimageio/core/tensor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ def ndim(self):
196196
"""Number of tensor dimensions."""
197197
return self._data.ndim
198198

199+
@property
200+
def shape(self):
201+
"""Tuple of tensor axes lengths"""
202+
return self._data.shape
203+
199204
@property
200205
def shape_tuple(self):
201206
"""Tuple of tensor axes lengths"""

tests/test_tensor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,8 @@ def test_crop_and_pad():
6060
def test_some_magic_ops():
6161
tensor = Tensor.from_numpy(np.random.rand(256, 256), dims=None)
6262
assert tensor + 2 == 2 + tensor
63+
64+
65+
def test_shape_attributes():
66+
tensor = Tensor.from_numpy(np.random.rand(1, 2, 25, 26), dims=None)
67+
assert tensor.shape_tuple == tensor.shape

0 commit comments

Comments
 (0)