From 3cf7e422685f3fbc704512dbb83e32dce58c215c Mon Sep 17 00:00:00 2001 From: Zebedee Nicholls Date: Thu, 12 Sep 2024 17:05:45 +0200 Subject: [PATCH] Finish off mypy --- src/openscm_calibration/exceptions.py | 4 ++-- src/openscm_calibration/matplotlib_utils.py | 2 +- src/openscm_calibration/scmdata_utils.py | 7 ++++--- stubs/emcee/backends.pyi | 10 +++++++++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/openscm_calibration/exceptions.py b/src/openscm_calibration/exceptions.py index d7f12f4..3ef5dcf 100644 --- a/src/openscm_calibration/exceptions.py +++ b/src/openscm_calibration/exceptions.py @@ -149,9 +149,9 @@ class AlignmentError(ValueError): def __init__( # noqa: PLR0913 self, name_left: str, - val_left: pd.DataFrame | pd.Series, + val_left: pd.DataFrame | pd.Series[Any], name_right: str, - val_right: pd.DataFrame | pd.Series, + val_right: pd.DataFrame | pd.Series[Any], extra_context: str | None = None, ) -> None: """ diff --git a/src/openscm_calibration/matplotlib_utils.py b/src/openscm_calibration/matplotlib_utils.py index 1a26b28..aafd82c 100644 --- a/src/openscm_calibration/matplotlib_utils.py +++ b/src/openscm_calibration/matplotlib_utils.py @@ -71,7 +71,7 @@ def get_fig_axes_holder_from_mosaic( ) fig, axes = plt.subplot_mosaic( - mosaic=mosaic, + mosaic=mosaic, # type: ignore # matplotlib's type hints are unclear **kwargs, ) holder = IPython.display.display(fig, display_id=True) # type: ignore diff --git a/src/openscm_calibration/scmdata_utils.py b/src/openscm_calibration/scmdata_utils.py index 1977e0d..df5a59f 100644 --- a/src/openscm_calibration/scmdata_utils.py +++ b/src/openscm_calibration/scmdata_utils.py @@ -20,7 +20,7 @@ def scmrun_as_dict( Parameters ---------- inp - :obj:`scmdata.run.BaseScmRun` to group + [scmdata.run.BaseScmRun][] to group groups Metadata keys to use to make the groups @@ -30,11 +30,12 @@ def scmrun_as_dict( Returns ------- - Grouped ``inp`` + : + Grouped `inp` """ res = {} for inp_g in inp.groupby(groups): - key = separator.join([inp_g.get_unique_meta(g, True) for g in groups]) + key = str(separator.join([str(inp_g.get_unique_meta(g, True)) for g in groups])) res[key] = inp_g return res diff --git a/stubs/emcee/backends.pyi b/stubs/emcee/backends.pyi index b0f422d..3218b61 100644 --- a/stubs/emcee/backends.pyi +++ b/stubs/emcee/backends.pyi @@ -4,4 +4,12 @@ import numpy as np import numpy.typing as nptype class Backend: - def get_chain(self, **kwargs: Any) -> nptype.NDArray[np.floating[Any]]: ... + iteration: int + def get_autocorr_time( + self, discard: int = 0, thin: int = 1, **kwargs: Any + ) -> nptype.NDArray[np.floating[Any]]: ... + def get_chain( + self, **kwargs: Any + ) -> nptype.NDArray[np.floating[Any] | np.integer[Any]]: ... + # Dimensionality of type hint would be helpful, anyway... + def get_log_prob(self, **kwargs: Any) -> nptype.NDArray[np.floating[Any]]: ...