Skip to content

Commit 8626d48

Browse files
committed
Self-review feedback
1 parent 54c829a commit 8626d48

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

tests/test_particlefile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def setup_pset_execute(*, fieldset: FieldSet, outputdt: timedelta, execute_kwarg
363363
output_file = ParticleFile(name, outputdt=outputdt)
364364

365365
pset.execute(DoNothing, output_file=output_file, **execute_kwargs)
366-
df = pd.read_parquet(name)
366+
df = utils.read_particlefile(name)
367367

368368
return df
369369

@@ -387,8 +387,8 @@ def test_pset_execute_output_time_forwards(fieldset):
387387
dt = np.timedelta64(5, "m")
388388

389389
df = setup_pset_execute(fieldset=fieldset, outputdt=outputdt, execute_kwargs=dict(runtime=runtime, dt=dt))
390-
assert df.time.min() == 0.0
391-
assert df.time.max() == runtime / np.timedelta64(1, "s")
390+
assert df.time.min() == pd.Timestamp(fieldset.time_interval.left)
391+
assert df.time.max() - df.time.min() == runtime
392392

393393

394394
def test_pset_execute_outputdt_backwards(fieldset):

tests/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from parcels import FieldSet, Particle, Variable
1818
from parcels._core.xgrid import _FIELD_DATA_ORDERING, XGrid, get_axis_from_dim_name
1919
from parcels._datasets.structured.generated import simple_UV_dataset
20+
from parcels._typing import PathLike
2021

2122
PROJECT_ROOT = Path(__file__).resolve().parents[1]
2223
TEST_ROOT = PROJECT_ROOT / "tests"
@@ -169,7 +170,9 @@ def assert_cftime_like_particlefile(parquet_path: Path) -> None:
169170
return
170171

171172

172-
def read_particlefile(path: Path, decode_times: bool = True) -> pd.DataFrame:
173+
def read_particlefile(path: PathLike, decode_times: bool = True) -> pd.DataFrame:
174+
path = Path(path)
175+
173176
assert path.suffix == ".parquet", "Only Parquet files are supported"
174177

175178
table = pq.read_table(path)

tests/utils/test_time.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,5 @@ def test_timedelta_to_float_exceptions():
224224

225225
@given(datetime_strategy())
226226
def test_datetime_get_cf_attrs(dt):
227-
_get_cf_attrs(dt)
227+
attrs = _get_cf_attrs(dt)
228+
assert "seconds" in attrs["units"]

0 commit comments

Comments
 (0)