Skip to content

Commit 48dcc85

Browse files
Respond to feedback
1 parent 095794d commit 48dcc85

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

pymc/data.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,16 @@ def _dataframe_agnostic_coords(
264264
)
265265

266266
index_dim = dims[0]
267-
if index_dim is not None and index_dim in value.columns:
268-
coords[index_dim] = tuple(value.select(nw.col(index_dim)).to_numpy())
269-
elif index_dim in model.coords:
270-
coords[index_dim] = model.coords[index_dim] # type: ignore[assignment]
271-
else:
272-
raise ValueError(
273-
f"Dimension '{index_dim}' not found in DataFrame columns or model coordinates. Cannot infer "
274-
"index coordinates."
275-
)
267+
if index_dim is not None:
268+
if index_dim in value.columns:
269+
coords[index_dim] = tuple(value.select(nw.col(index_dim)).to_numpy().flatten())
270+
elif index_dim in model.coords:
271+
coords[index_dim] = model.coords[index_dim] # type: ignore[assignment]
272+
else:
273+
raise ValueError(
274+
f"Dimension '{index_dim}' not found in DataFrame columns or model coordinates. Cannot infer "
275+
"index coordinates."
276+
)
276277

277278
if len(dims) > 1:
278279
column_dim = dims[1]
@@ -321,6 +322,7 @@ def determine_dataframe_coords(
321322
return _dataframe_agnostic_coords(value, model=model, dims=dims, coords=coords)
322323

323324
except ImportError:
325+
# Dataframe backends are optional
324326
pass
325327

326328

@@ -364,7 +366,7 @@ def Data(
364366
A value to associate with this variable.
365367
dims : str, tuple of str or tuple of None, optional
366368
Dimension names of the random variables (as opposed to the shapes of these
367-
random variables). Use this when ``value`` is a pandas Series or DataFrame. The
369+
random variables). Use this when ``value`` is a Series or DataFrame. The
368370
``dims`` will then be the name of the Series / DataFrame's columns. See ArviZ
369371
documentation for more information about dimensions and coordinates:
370372
:ref:`arviz:quickstart`.

0 commit comments

Comments
 (0)