Skip to content
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 act/qc/comparison_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def compare_time_series_trends(
sum_diff = np.array([], dtype=float)
time_diff = np.array([], dtype=np.int32)
for tm_shift in range(-1 * time_shift, time_shift + int(time_step), int(time_step)):
time = self_da.time.values.astype('datetime64[s]') + tm_shift
time = self_da.time.values.astype('datetime64[s]') + np.timedelta64(int(tm_shift), 's')
time = time.astype('datetime64[ns]')
self_da_shifted = self_da.assign_coords(time=time)

Expand Down
5 changes: 3 additions & 2 deletions act/utils/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,9 @@ def add_in_nan(time, data):
else:
# For 2D plots need to add a NaN right after and right before the data
# to correctly mitigate streaking with pcolormesh.
time_added_1 = time[corr_i] + 1 # One time step after
time_added_2 = time[corr_i + 1] - 1 # One time step before
unit, _ = np.datetime_data(time.dtype)
time_added_1 = time[corr_i] + np.timedelta64(1, unit) # One time step after
time_added_2 = time[corr_i + 1] - np.timedelta64(1, unit) # One time step before
time = np.insert(time, corr_i + 1, [time_added_1, time_added_2])
data = np.insert(data, corr_i + 1, np.nan, axis=0)
data = np.insert(data, corr_i + 2, np.nan, axis=0)
Expand Down
7 changes: 4 additions & 3 deletions tests/io/test_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path

import numpy as np
import pytest

import act
from act.tests import sample_files
Expand All @@ -13,7 +14,7 @@ def test_read_arm_netcdf():
assert 'rh_mean' in ds.variables.keys()
assert ds.attrs['_arm_standards_flag'] == (1 << 0)

with np.testing.assert_raises(OSError):
with pytest.raises(OSError):
ds = act.io.arm.read_arm_netcdf([])

ds = act.io.arm.read_arm_netcdf([], return_None=True)
Expand Down Expand Up @@ -154,12 +155,12 @@ def test_io_dod():
assert 'moment1' in ds
assert len(ds['base_time'].values) == 1440
assert len(ds['drop_diameter'].values) == 50
with np.testing.assert_warns(UserWarning):
with pytest.warns(UserWarning):
ds2 = act.io.arm.create_ds_from_arm_dod('vdis.b1', dims, scalar_fill_dim='time')
assert 'moment1' in ds2
assert len(ds2['base_time'].values) == 1440
assert len(ds2['drop_diameter'].values) == 50
with np.testing.assert_raises(ValueError):
with pytest.raises(ValueError):
ds = act.io.arm.create_ds_from_arm_dod('vdis.b1', {}, version='1.2')
ds = act.io.arm.create_ds_from_arm_dod(
sample_files.EXAMPLE_DOD, dims, version=1.2, scalar_fill_dim='time', local_file=True
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_datetime_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_dates_between():
start_string = datetime.strptime(start_date, '%Y%m%d').strftime('%Y-%m-%d')
end_string = datetime.strptime(end_date, '%Y%m%d').strftime('%Y-%m-%d')
answer = np.arange(start_string, end_string, dtype='datetime64[D]')
answer = np.append(answer, answer[-1] + 1)
answer = np.append(answer, answer[-1] + np.timedelta64(1, 'D'))
answer = answer.astype('datetime64[s]').astype(int)
answer = [datetime.fromtimestamp(ii, tz=timezone.utc).replace(tzinfo=None) for ii in answer]

Expand Down
Loading