Skip to content

Commit

Permalink
test for a time array
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceBalfanz committed Jun 5, 2023
1 parent 55cfc61 commit 73b9d55
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/core/test_timecoord.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,22 @@ def test_it_with_floor_round_fn(self):
pd.to_datetime("04-OCT-2019 10:13:48.538184"),
round_fn="floor"))

def test_it_with_array_round_fn(self):
var = [np.datetime64("2018-09-05 10:35:42.564"),
np.datetime64("2018-09-06 10:35:42.564"),
np.datetime64("2018-09-07 10:35:42.564"),
pd.to_datetime("04-OCT-2019 10:13:48.038184")
]
expected_values = ["2018-09-05T10:35:42Z",
"2018-09-06T10:35:43Z",
"2018-09-07T10:35:43Z",
"2019-10-04T10:13:49Z"]
values = [timestamp_to_iso_string(var[0], round_fn="floor")] +\
list(map(timestamp_to_iso_string, var[1:-1])) +\
[timestamp_to_iso_string(var[-1], round_fn="ceil")]
self.assertEqual(expected_values, values)


# noinspection PyMethodMayBeStatic
def test_it_with_invalid_round_fn(self):
with pytest.raises(ValueError,
Expand Down

0 comments on commit 73b9d55

Please sign in to comment.