Skip to content

Commit

Permalink
Add timezone test at temporal matching
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhahn committed Jul 18, 2019
1 parent bcaeea4 commit 3cd2fb0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_temporal_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'''


import pytz
import pytesmo.temporal_matching as tmatching
import pandas as pd
from datetime import datetime
Expand Down Expand Up @@ -244,3 +245,22 @@ def test_matching_tz():
np.nan, np.nan]),
matched.matched_data)
assert len(matched) == 10


def test_timezone_handling():
data = np.arange(5.0)
data[3] = np.nan

match_df = pd.DataFrame({"data": data}, index=pd.date_range(datetime(2007, 1, 1, 0),
"2007-01-05", freq="D", tz="UTC"))
timezone = pytz.timezone("UTC")
ref_df = pd.DataFrame({"matched_data": np.arange(5)},
index=[timezone.localize(datetime(2007, 1, 1, 9)),
timezone.localize(datetime(2007, 1, 2, 9)),
timezone.localize(datetime(2007, 1, 3, 9)),
timezone.localize(datetime(2007, 1, 4, 9)),
timezone.localize(datetime(2007, 1, 5, 9))])
matched = tmatching.matching(ref_df, match_df)

nptest.assert_allclose(np.array([0, 1, 2, 4]), matched.matched_data)
assert len(matched) == 4

0 comments on commit 3cd2fb0

Please sign in to comment.