Skip to content

Commit

Permalink
Merge branch 'main' into dmb_track_priors_in_git
Browse files Browse the repository at this point in the history
  • Loading branch information
damonbayer authored Dec 17, 2024
2 parents 899f4b5 + 2927b03 commit 3e4ef32
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
3 changes: 2 additions & 1 deletion pipelines/collate_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import os
from pathlib import Path

from forecasttools import ensure_listlike
from pypdf import PdfWriter
from utils import ensure_listlike, get_all_forecast_dirs
from utils import get_all_forecast_dirs


def merge_pdfs_and_save(
Expand Down
28 changes: 0 additions & 28 deletions pipelines/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,11 @@
import datetime
import os
import re
from collections.abc import MutableSequence
from pathlib import Path

disease_map_lower_ = {"influenza": "Influenza", "covid-19": "COVID-19"}


def ensure_listlike(x):
"""
Ensure that an object either behaves like a
:class:`MutableSequence` and if not return a
one-item :class:`list` containing the object.
Useful for handling list-of-strings inputs
alongside single strings.
Based on this _`StackOverflow approach
<https://stackoverflow.com/a/66485952>`.
Parameters
----------
x
The item to ensure is :class:`list`-like.
Returns
-------
MutableSequence
``x`` if ``x`` is a :class:`MutableSequence`
otherwise ``[x]`` (i.e. a one-item list containing
``x``.
"""
return x if isinstance(x, MutableSequence) else [x]


def parse_model_batch_dir_name(model_batch_dir_name):
"""
Parse the name of a model batch directory,
Expand Down

0 comments on commit 3e4ef32

Please sign in to comment.