Skip to content

Commit

Permalink
also catch value error
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoralez committed Jan 2, 2024
1 parent 307136a commit 3b387b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion mlforecast/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,8 @@ def update(self, df: DataFrame) -> None:
id_counts = ufp.counts_by_id(df, self.id_col)
try:
sizes = ufp.join(uids, id_counts, on=self.id_col, how="outer_coalesce")
except KeyError:
except (KeyError, ValueError):
# pandas raises key error, polars before coalesce raises value error
sizes = ufp.join(uids, id_counts, on=self.id_col, how="outer")
sizes = ufp.fill_null(sizes, {"counts": 0})
sizes = ufp.sort(sizes, by=self.id_col)
Expand Down
15 changes: 8 additions & 7 deletions nbs/core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,8 @@
" id_counts = ufp.counts_by_id(df, self.id_col)\n",
" try:\n",
" sizes = ufp.join(uids, id_counts, on=self.id_col, how='outer_coalesce')\n",
" except KeyError:\n",
" except (KeyError, ValueError):\n",
" # pandas raises key error, polars before coalesce raises value error\n",
" sizes = ufp.join(uids, id_counts, on=self.id_col, how='outer')\n",
" sizes = ufp.fill_null(sizes, {'counts': 0})\n",
" sizes = ufp.sort(sizes, by=self.id_col)\n",
Expand Down Expand Up @@ -1591,7 +1592,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/Nixtla/mlforecast/blob/main/mlforecast/core.py#L519){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/Nixtla/mlforecast/blob/main/mlforecast/core.py#L462){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"## TimeSeries.fit_transform\n",
"\n",
Expand All @@ -1613,7 +1614,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/Nixtla/mlforecast/blob/main/mlforecast/core.py#L519){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/Nixtla/mlforecast/blob/main/mlforecast/core.py#L462){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"## TimeSeries.fit_transform\n",
"\n",
Expand Down Expand Up @@ -1906,7 +1907,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/Nixtla/mlforecast/blob/main/mlforecast/core.py#L724){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/Nixtla/mlforecast/blob/main/mlforecast/core.py#L656){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"## TimeSeries.predict\n",
"\n",
Expand All @@ -1921,7 +1922,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/Nixtla/mlforecast/blob/main/mlforecast/core.py#L724){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/Nixtla/mlforecast/blob/main/mlforecast/core.py#L656){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"## TimeSeries.predict\n",
"\n",
Expand Down Expand Up @@ -2060,7 +2061,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/Nixtla/mlforecast/blob/main/mlforecast/core.py#L828){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/Nixtla/mlforecast/blob/main/mlforecast/core.py#L760){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"## TimeSeries.update\n",
"\n",
Expand All @@ -2073,7 +2074,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/Nixtla/mlforecast/blob/main/mlforecast/core.py#L828){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/Nixtla/mlforecast/blob/main/mlforecast/core.py#L760){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"## TimeSeries.update\n",
"\n",
Expand Down

0 comments on commit 3b387b4

Please sign in to comment.