Skip to content

Commit b8e5ce1

Browse files
committed
Remove implicit modelcontext fallback from shape_from_dims
1 parent 569b99c commit b8e5ce1

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

pymc/distributions/shape_utils.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,26 +164,23 @@ def convert_size(size: Size) -> StrongSize | None:
164164
)
165165

166166

167-
def shape_from_dims(dims: StrongDims, model=None) -> StrongShape:
167+
def shape_from_dims(dims: StrongDims, model: Model) -> StrongShape:
168168
"""Determine shape from a `dims` tuple.
169169
170170
Parameters
171171
----------
172172
dims : array-like
173173
A vector of dimension names or None.
174-
model : pm.Model, optional
175-
The current model on stack. If None, it will be resolved via modelcontext.
174+
model : pm.Model
175+
The current model on stack.
176176
177177
Returns
178178
-------
179179
shape : tuple
180180
Shape inferred from model dimension lengths.
181181
"""
182-
# Lazy import to break circular dependency
183182
if model is None:
184-
from pymc.model.core import modelcontext
185-
186-
model = modelcontext(None)
183+
raise ValueError("model must be provided explicitly to infer shape from dims")
187184

188185
# Dims must be known already
189186
unknowndim_dims = set(dims) - set(model.dim_lengths)

0 commit comments

Comments
 (0)