Skip to content

Commit 27159c4

Browse files
committed
Re-add NoDataError handling
1 parent ca961c0 commit 27159c4

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

cmdstanpy/utils/stancsv.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,19 @@ def csv_bytes_list_to_numpy(
6969
try:
7070
import polars as pl
7171

72-
out: npt.NDArray[np.float64] = (
73-
pl.read_csv(
74-
io.BytesIO(b"".join(csv_bytes_list)),
75-
has_header=includes_header,
76-
schema_overrides=[pl.Float64] * num_cols,
77-
infer_schema=False,
72+
try:
73+
out: npt.NDArray[np.float64] = (
74+
pl.read_csv(
75+
io.BytesIO(b"".join(csv_bytes_list)),
76+
has_header=includes_header,
77+
schema_overrides=[pl.Float64] * num_cols,
78+
infer_schema=False,
79+
)
80+
.to_numpy()
81+
.astype(np.float64)
7882
)
79-
.to_numpy()
80-
.astype(np.float64)
81-
)
83+
except pl.exceptions.NoDataError:
84+
return np.empty((0,))
8285
except ImportError:
8386
with warnings.catch_warnings():
8487
warnings.filterwarnings("ignore")

0 commit comments

Comments
 (0)