Skip to content

Commit 99221d6

Browse files
committed
implementing the suggested changes
1 parent 415b042 commit 99221d6

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

pymc/distributions/distribution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def __new__(
521521
# finally, observed, to determine the shape of the variable.
522522
if kwargs.get("size") is None and kwargs.get("shape") is None:
523523
if dims is not None:
524-
kwargs["shape"] = model.shape_from_dims(dims)
524+
kwargs["shape"] = model.symbolic_shape_from_dims(dims)
525525
elif observed is not None:
526526
kwargs["shape"] = tuple(observed.shape)
527527

pymc/model/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ def dim_lengths(self) -> dict[str, TensorVariable]:
922922
"""
923923
return self._dim_lengths
924924

925-
def shape_from_dims(self, dims):
925+
def symbolic_shape_from_dims(self, dims):
926926
shape = []
927927
if len(set(dims)) != len(dims):
928928
raise ValueError("Can not contain the same dimension name twice.")

pymc/util.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,41 @@
3333

3434
from pymc.exceptions import BlockModelAccessError
3535

36-
# User-facing coordinate types
3736
CoordValue: TypeAlias = Sequence[Hashable] | np.ndarray | None
37+
# User-provided values for a single coordinate dimension.
38+
3839
Coords: TypeAlias = Mapping[str, CoordValue]
40+
# Mapping from dimension name to its coordinate values.
3941

40-
# Internal strong coordinate types
4142
StrongCoordValue: TypeAlias = tuple[Hashable, ...] | None
43+
# Normalized coordinate values stored internally.
44+
4245
StrongCoords: TypeAlias = Mapping[str, StrongCoordValue]
46+
# Mapping from dimension name to normalized coordinate values.
4347

44-
# Internal strong dimension/shape types
4548
StrongDims: TypeAlias = tuple[str, ...]
49+
# Tuple of dimension names after validation.
50+
4651
StrongShape: TypeAlias = tuple[int, ...]
52+
# Fully-resolved numeric shape used internally.
4753

48-
# User-provided shape before processing
4954
Shape: TypeAlias = int | TensorVariable | Sequence[int | Variable]
55+
# User-provided shape specification before normalization.
5056

51-
# User-provided dims before processing
5257
Dims: TypeAlias = str | Sequence[str | None]
58+
# User-provided dimension names before normalization.
5359

54-
# User-provided dims that may include ellipsis (...)
5560
DimsWithEllipsis: TypeAlias = str | EllipsisType | Sequence[str | None | EllipsisType]
61+
# User-provided dimension names that may include ellipsis.
5662

57-
# User-provided size before processing
5863
Size: TypeAlias = int | TensorVariable | Sequence[int | Variable]
64+
# User-provided size specification before normalization.
5965

60-
# Strong / normalized versions used internally
6166
StrongDimsWithEllipsis: TypeAlias = Sequence[str | EllipsisType]
62-
StrongSize: TypeAlias = TensorVariable | tuple[int | Variable, ...]
63-
"""
64-
Type alias groups:
67+
# Normalized dimension names that may include ellipsis.
6568

66-
- User-facing types (Coords, CoordValue, Shape, Dims, Size) represent the flexible inputs
67-
accepted from users when defining models.
68-
69-
- Strong/internal types (StrongCoords, StrongDims, StrongShape, StrongSize, etc.) represent
70-
normalized, fully-validated forms used internally after processing.
71-
72-
These distinctions allow looser user input while keeping strict internal consistency.
73-
"""
69+
StrongSize: TypeAlias = TensorVariable | tuple[int | Variable, ...]
70+
# Normalized symbolic size used internally.
7471

7572

7673
class _UnsetType:

0 commit comments

Comments
 (0)