From 62a0870123005dde934157d53fe72d6fd27f6a62 Mon Sep 17 00:00:00 2001 From: Taher Chegini Date: Fri, 17 Jan 2025 20:18:58 -0500 Subject: [PATCH] MNT: Rename types based on python's convention. [skip ci] --- src/pynldas2/_utils.py | 3 +-- src/pynldas2/pynldas2.py | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/pynldas2/_utils.py b/src/pynldas2/_utils.py index 9a9df2d..e6fa28f 100644 --- a/src/pynldas2/_utils.py +++ b/src/pynldas2/_utils.py @@ -17,13 +17,12 @@ from pyproj import Transformer from pyproj.exceptions import CRSError as ProjCRSError from rioxarray.exceptions import OneDimensionalRaster -from shapely import MultiPolygon, Polygon, ops +from shapely import Polygon, ops from pynldas2.exceptions import DownloadError, InputRangeError, InputTypeError if TYPE_CHECKING: from numpy.typing import NDArray - from shapely import Polygon CRSType = int | str | pyproj.CRS PolyType = Polygon | tuple[float, float, float, float] diff --git a/src/pynldas2/pynldas2.py b/src/pynldas2/pynldas2.py index 30407d6..b7c3522 100644 --- a/src/pynldas2/pynldas2.py +++ b/src/pynldas2/pynldas2.py @@ -9,7 +9,7 @@ import re import warnings from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, TypeVar, Union +from typing import TYPE_CHECKING, Any, Callable, TypeVar from urllib.parse import urlencode import numpy as np @@ -55,11 +55,11 @@ def wrapper_decorator(*args: tuple[Any, ...], **kwargs: dict[str, Any]) -> T: if TYPE_CHECKING: from collections.abc import Iterable, Sequence - import pyproj - from shapely import MultiPolygon, Polygon + from pyproj import CRS + from shapely import Polygon - DF = TypeVar("DF", pd.DataFrame, xr.Dataset) - CRSType = Union[int, str, pyproj.CRS] + CRSType = int | str | CRS + Dataset = TypeVar("Dataset", pd.DataFrame, xr.Dataset) # Default snow params from https://doi.org/10.5194/gmd-11-1077-2018 T_RAIN = 2.5 # degC @@ -174,7 +174,7 @@ def snow_func( return clm -def separate_snow(clm: DF, t_rain: float = T_RAIN, t_snow: float = T_SNOW) -> DF: +def separate_snow(clm: Dataset, t_rain: float = T_RAIN, t_snow: float = T_SNOW) -> Dataset: """Separate snow based on :footcite:t:`Martinez_2010`. Parameters