Skip to content

Commit 819aff1

Browse files
Use -1 for dynamic dimensions
1 parent d47398a commit 819aff1

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

mcbackend/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
pass
2121

2222

23-
__version__ = "0.3.0"
23+
__version__ = "0.4.0"

mcbackend/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ def is_rigid(nshape: Optional[Shape]):
3232
This "nullable shape" is interpreted as follows:
3333
- ``[]`` indicates scalar shape (rigid: True).
3434
- ``[2, 3]`` indicates a matrix with 2 rows and 3 columns (rigid: True).
35-
- ``[2, 0]`` indicates a matrix with 2 rows and dynamic number of columns (rigid: False).
35+
- ``[2, -1]`` indicates a matrix with 2 rows and dynamic number of columns (rigid: False).
3636
- ``None`` indicates dynamic dimensionality (rigid: False).
3737
"""
3838
if nshape is None:
3939
return False
40-
if any(s == 0 for s in nshape):
40+
if any(s == -1 for s in nshape):
4141
return False
4242
return True
4343

mcbackend/meta.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mcbackend/test_backend_numpy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_targets(self):
2121
variables=[
2222
Variable("tensor", "int8", (3, 4, 5)),
2323
Variable("scalar", "float64", ()),
24-
Variable("changeling", "uint16", (3, 0)),
24+
Variable("changeling", "uint16", (3, -1)),
2525
],
2626
)
2727
run = imb.init_run(rm)
@@ -56,7 +56,7 @@ def test_growing(self):
5656
Variable(
5757
"B",
5858
"float32",
59-
(0,),
59+
(-1,),
6060
),
6161
],
6262
)

mcbackend/test_core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from datetime import datetime, timezone
22

33
import numpy
4-
import pytest
54

65
from mcbackend.meta import ChainMeta, RunMeta, Variable
76
from mcbackend.test_utils import make_runmeta
@@ -12,9 +11,10 @@
1211
def test_is_rigid():
1312
assert core.is_rigid([])
1413
assert core.is_rigid([1, 2])
14+
assert core.is_rigid([1, 0])
1515
assert not core.is_rigid(None)
16-
assert not core.is_rigid((0,))
17-
assert not core.is_rigid([1, 0, 2])
16+
assert not core.is_rigid((-1,))
17+
assert not core.is_rigid([1, -1, 2])
1818
pass
1919

2020

mcbackend/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def make_draw(variables: Sequence[Variable]):
5757
for var in variables:
5858
dshape = tuple(
5959
# A pre-registered dim length of 0 means that it's random!
60-
s or random.randint(0, 10)
60+
(random.randint(0, 10) if s == -1 else s)
6161
for s in var.shape
6262
)
6363
if "float" in var.dtype:
@@ -215,7 +215,7 @@ def test__get_slicing(self, slc: slice):
215215
# "B" are dynamically shaped to cover the edge cases.
216216
rmeta = RunMeta(
217217
variables=[Variable("A", "uint8"), Variable("M", "str", [2, 3])],
218-
sample_stats=[Variable("B", "uint8", [2, 0])],
218+
sample_stats=[Variable("B", "uint8", [2, -1])],
219219
data=[],
220220
)
221221
run = self.backend.init_run(rmeta)

protobufs/meta.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ message Variable {
2525
// The default value, an empty sequence, corresponds to scalar shape.
2626
// Note that for variables of dynamic dimensionality, ``undefined_ndim=True``
2727
// can be set to render ``shape`` and ``dims`` meaningless.
28-
repeated uint64 shape = 3;
28+
repeated int64 shape = 3;
2929
// Names of the variable's dimensions.
3030
// The default value, an empty sequence, corresponds to undefined dimension names
3131
// and applies to scalar variables, and variables where ``undefined_ndim=True``.

0 commit comments

Comments
 (0)