Skip to content

Commit

Permalink
Review: simplify the assginment
Browse files Browse the repository at this point in the history
  • Loading branch information
JQGoh committed Dec 16, 2024
1 parent 0ad8caa commit 8d213a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 3 additions & 4 deletions nbs/core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1549,8 +1549,8 @@
" }\n",
" for attr in ['prediction_intervals', '_cs_df']:\n",
" # conformal prediction related attributes was not available < 1.7.6\n",
" if hasattr(self, attr):\n",
" config_dict[attr] = getattr(self, attr, None)\n",
" config_dict[attr] = getattr(self, attr, None)\n",
" \n",
"\n",
" if save_dataset:\n",
" config_dict.update(\n",
Expand Down Expand Up @@ -1651,8 +1651,7 @@
" setattr(neuralforecast, attr, config_dict.get(attr, default))\n",
" # only restore attribute if available\n",
" for attr in ['prediction_intervals', '_cs_df']:\n",
" if attr in config_dict.keys():\n",
" setattr(neuralforecast, attr, config_dict[attr])\n",
" setattr(neuralforecast, attr, config_dict.get(attr, None))\n",
"\n",
" # Dataset\n",
" if dataset is not None:\n",
Expand Down
6 changes: 2 additions & 4 deletions neuralforecast/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,8 +1537,7 @@ def save(
}
for attr in ["prediction_intervals", "_cs_df"]:
# conformal prediction related attributes was not available < 1.7.6
if hasattr(self, attr):
config_dict[attr] = getattr(self, attr, None)
config_dict[attr] = getattr(self, attr, None)

if save_dataset:
config_dict.update(
Expand Down Expand Up @@ -1644,8 +1643,7 @@ def load(path, verbose=False, **kwargs):
setattr(neuralforecast, attr, config_dict.get(attr, default))
# only restore attribute if available
for attr in ["prediction_intervals", "_cs_df"]:
if attr in config_dict.keys():
setattr(neuralforecast, attr, config_dict[attr])
setattr(neuralforecast, attr, config_dict.get(attr, None))

# Dataset
if dataset is not None:
Expand Down

0 comments on commit 8d213a6

Please sign in to comment.