Skip to content

Commit f30c6b4

Browse files
committed
Update shape_utils.py
1 parent 18e363a commit f30c6b4

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

pymc/distributions/shape_utils.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -449,20 +449,16 @@ def convert_shape(shape: Shape) -> Optional[WeakShape]:
449449
"""Process a user-provided shape variable into None or a valid shape object."""
450450
if shape is None:
451451
return None
452-
if isinstance(shape, int) or (isinstance(size, TensorVariable) and shape.ndim == 0):
452+
elif isinstance(shape, int) or (isinstance(size, TensorVariable) and shape.ndim == 0):
453453
shape = (shape,)
454454
elif isinstance(shape, TensorVariable) and shape.ndim == 1:
455455
shape = tuple(shape)
456456
elif isinstance(shape, (list, tuple)):
457457
shape = tuple(shape)
458458
else:
459-
raise ValueError(
460-
f"The `shape` parameter must be a tuple, TensorVariable, int or list. Actual: {type(shape)}"
461-
)
459+
raise ValueError(f"The `shape` parameter must be a tuple, TensorVariable, int or list. Actual: {type(shape)}")
462460
if isinstance(shape, tuple) and any(s == Ellipsis for s in shape[:-1]):
463-
raise ValueError(
464-
f"Ellipsis in `shape` may only appear in the last position. Actual: {shape}"
465-
)
461+
raise ValueError(f"Ellipsis in `shape` may only appear in the last position. Actual: {shape}")
466462
return shape
467463

468464

@@ -477,9 +473,7 @@ def convert_size(size: Size) -> Optional[StrongSize]:
477473
elif isinstance(size, (list, tuple)):
478474
size = tuple(size)
479475
else:
480-
raise ValueError(
481-
f"The `size` parameter must be a tuple, TensorVariable, int or list. Actual: {type(size)}"
482-
)
476+
raise ValueError(f"The `size` parameter must be a tuple, TensorVariable, int or list. Actual: {type(size)}")
483477
if isinstance(size, tuple) and Ellipsis in size:
484478
raise ValueError(f"The `size` parameter cannot contain an Ellipsis. Actual: {size}")
485479
return size

0 commit comments

Comments
 (0)