From 3b8cc7fa85719bfe8bc742e457c7ddaef737dc55 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 15:28:13 -0300 Subject: [PATCH 1/6] pandas 2.0 support --- erddapy/core/url.py | 18 +++++++++++++----- pyproject.toml | 1 + requirements.txt | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/erddapy/core/url.py b/erddapy/core/url.py index 37d4b72c..474d6a72 100644 --- a/erddapy/core/url.py +++ b/erddapy/core/url.py @@ -9,7 +9,9 @@ import httpx import pytz -from pandas._libs.tslibs.parsing import parse_time_string +from pandas._libs.tslibs.parsing import ( + py_parse_datetime_string as _py_parse_datetime_string, +) ListLike = Union[List[str], Tuple[str]] OptionalStr = Optional[str] @@ -113,7 +115,11 @@ def _check_substrings(constraint): return any([True for substring in substrings if substring in str(constraint)]) -def parse_dates(date_time: Union[datetime, str]) -> float: +def parse_dates( + date_time: Union[datetime, str], + dayfirst=False, + yearfirst=False, +) -> float: """ Parse dates to ERDDAP internal format. @@ -123,9 +129,11 @@ def parse_dates(date_time: Union[datetime, str]) -> float: """ if isinstance(date_time, str): - # pandas returns a tuple with datetime, dateutil, and string representation. - # we want only the datetime obj. - parse_date_time = parse_time_string(date_time)[0] + parse_date_time = _py_parse_datetime_string( + date_time, + dayfirst=dayfirst, + yearfirst=yearfirst, + ) else: parse_date_time = date_time diff --git a/pyproject.toml b/pyproject.toml index 37c48144..c89cb572 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ dependencies = {file = ["requirements.txt"]} [tool.setuptools_scm] write_to = "erddapy/_version.py" write_to_template = "__version__ = '{version}'" +tag_regex = "^(?Pv)?(?P[^\\+]+)(?P.*)?$" [tool.pytest.ini_options] markers = [ diff --git a/requirements.txt b/requirements.txt index 67762a5d..4538e721 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ httpx -pandas>=0.20.3 +pandas>=2 pytz From 6a34222856346347a04ea0a19e8f4a387a9d7fd8 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 16:37:41 -0300 Subject: [PATCH 2/6] avoid https://github.com/jupyter/nbconvert/issues/1970 --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 963ada17..660dcd8c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,6 +5,7 @@ geopandas interrogate joblib jupyter +nbconvert<7.3.0 nbsphinx netcdf4 pendulum>=2.0.1 From 0e3c70b9a94aae184b608985570ae41ef4652c02 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 17:05:08 -0300 Subject: [PATCH 3/6] don't rely on internal func --- erddapy/core/url.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/erddapy/core/url.py b/erddapy/core/url.py index 474d6a72..8446f4ed 100644 --- a/erddapy/core/url.py +++ b/erddapy/core/url.py @@ -9,9 +9,7 @@ import httpx import pytz -from pandas._libs.tslibs.parsing import ( - py_parse_datetime_string as _py_parse_datetime_string, -) +from pandas import to_datetime ListLike = Union[List[str], Tuple[str]] OptionalStr = Optional[str] @@ -129,11 +127,11 @@ def parse_dates( """ if isinstance(date_time, str): - parse_date_time = _py_parse_datetime_string( + parse_date_time = to_datetime( date_time, dayfirst=dayfirst, yearfirst=yearfirst, - ) + ).to_pydatetime() else: parse_date_time = date_time From b9cc333a28e50e9fe0d7c48328c1d7c64ad58892 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 17:25:21 -0300 Subject: [PATCH 4/6] test up to 1.5.3 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4538e721..06e57b73 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ httpx -pandas>=2 +pandas>=1.5.3 pytz From 517f20eaaed731d877b19dc25606216ff8ac7798 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 5 Apr 2023 15:27:04 -0300 Subject: [PATCH 5/6] tested range --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 06e57b73..5ac97ab3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ httpx -pandas>=1.5.3 +pandas>=0.25.2,<3 pytz From a2631e3da0b140892d470f9396af465db01e7f25 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Thu, 6 Apr 2023 11:25:50 -0300 Subject: [PATCH 6/6] let's try to reduce the scope of the warn-errors --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c89cb572..f28981b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ markers = [ "serial: marks tests that cannot be run in parallel (deselect with '-m \"not serial\"')", ] filterwarnings = [ - "error", + "error:::erddapy.*", "ignore::UserWarning", "ignore::RuntimeWarning", ]