Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for pandas 1.5 and 2 and above #102

Merged
merged 8 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ensembleperturbation/perturbation/atcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import numpy
from numpy import floor, interp, sign
from pandas import DataFrame
from pandas.core.common import SettingWithCopyWarning
from pandas.errors import SettingWithCopyWarning
import pint
from pint import Quantity, UnitStrippedWarning
from pint_pandas import PintArray, PintType
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ geopandas = '*'
netcdf4 = '*'
matplotlib = { version = '*', optional = true }
numpy = '*'
pandas = '<1.5.0' # SettingWithCopyWarning issue
pint = '<0.20' # Import error for quantity from `pint-pandas`
pint-pandas = '*'
pandas = '>=1.5'
pint = '<0.21' # ito() issue #105
pint-pandas = '<0.4' # ito() issue #105
pyproj = '>=2.6'
tables = '*'
typepigeon = '*'
Expand Down
9 changes: 6 additions & 3 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from difflib import context_diff
import os
from os import PathLike
from pathlib import Path
Expand Down Expand Up @@ -83,6 +84,8 @@ def check_reference_directory(
del test_lines[line_index], reference_lines[line_index]

cwd = Path.cwd()
assert '\n'.join(test_lines) == '\n'.join(
reference_lines
), f'"{os.path.relpath(test_filename, cwd)}" != "{os.path.relpath(reference_filename, cwd)}"'
diff = context_diff(test_lines, reference_lines, lineterm='')
assert '\n'.join(test_lines) == '\n'.join(reference_lines), (
f'"{os.path.relpath(test_filename, cwd)}" != "{os.path.relpath(reference_filename, cwd)}"\n\n'
+ '\n'.join(diff)
)
9 changes: 5 additions & 4 deletions tests/test_forecast_track_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
from datetime import datetime

import numpy as np
import pandas as pd
from stormevents.nhc import VortexTrack
from stormevents.nhc.atcf import ATCF_FIELDS
Expand All @@ -22,7 +23,7 @@ def test_track_perturber_forecast_time_init():
perturber = VortexPerturber(
storm='al062018', start_date=datetime(2018, 9, 12), end_date=None, file_deck='a',
)
dates = perturber.track.data.track_start_time.unique()
dates = np.array(perturber.track.data.track_start_time.unique())
assert len(dates) == 1
assert pd.to_datetime(dates.item()) == datetime(2018, 9, 12)

Expand All @@ -49,7 +50,7 @@ def test_track_perturber_forecast_time_fromfile():
Path(fo.name), start_date=datetime(2018, 9, 12), file_deck='a',
)

dates = perturber.track.data.track_start_time.unique()
dates = np.array(perturber.track.data.track_start_time.unique())
assert len(dates) == 1
assert pd.to_datetime(dates.item()) == datetime(2018, 9, 12)

Expand All @@ -66,7 +67,7 @@ def test_track_perturber_forecast_time_fromtrack():
perturber = VortexPerturber.from_track(original_track,)
assert perturber.start_date == datetime(2018, 9, 12)

dates = perturber.track.data.track_start_time.unique()
dates = np.array(perturber.track.data.track_start_time.unique())
assert len(dates) == 1
assert pd.to_datetime(dates.item()) == datetime(2018, 9, 12)

Expand Down Expand Up @@ -105,6 +106,6 @@ def test_perturb_tracks_func_forecast_time():
advisories=['OFCL'],
file_deck='a',
)
dates = track.data.track_start_time.unique()
dates = np.array(track.data.track_start_time.unique())
assert len(dates) == 1
assert pd.to_datetime(dates.item()) == datetime(2018, 9, 12)
Loading