From fa908c82844e902008b6d23bdf37154a07c9d9ee Mon Sep 17 00:00:00 2001 From: Zach Sherman <19153455+zssherman@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:13:21 -0600 Subject: [PATCH] MNT: Update code to remove warnings for datetime and pandas. (#878) * MNT: Update code to remove warnings for datetime and pandas. * FIX: Timezone not timedelta. --- act/io/arm.py | 4 ++-- tests/plotting/test_timeseriesdisplay.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/act/io/arm.py b/act/io/arm.py index 893bc84e28..05c9201a87 100644 --- a/act/io/arm.py +++ b/act/io/arm.py @@ -5,7 +5,6 @@ """ import copy -import datetime as dt import glob import json import re @@ -13,6 +12,7 @@ import tempfile import urllib import warnings +from datetime import datetime, timezone from os import PathLike from pathlib import Path, PosixPath @@ -766,7 +766,7 @@ def write_netcdf( except KeyError: pass - current_time = dt.datetime.utcnow().replace(microsecond=0) + current_time = datetime.now(timezone.utc).replace(microsecond=0) history_value = ( f'Written to file by ACT-{act.__version__} ' f'with write_netcdf() at {current_time} UTC' diff --git a/tests/plotting/test_timeseriesdisplay.py b/tests/plotting/test_timeseriesdisplay.py index 464dfb82f5..7b29941ef8 100644 --- a/tests/plotting/test_timeseriesdisplay.py +++ b/tests/plotting/test_timeseriesdisplay.py @@ -690,7 +690,7 @@ def test_xlim_correction_plot(): @pytest.mark.mpl_image_compare(tolerance=10) def test_plot_stripes(): ds = act.io.read_arm_netcdf(sample_files.EXAMPLE_MET_WILDCARD) - ds = ds.resample(time='1H').mean() + ds = ds.resample(time='1h').mean() print(ds) reference_period = ['2019-01-01', '2019-10-02']