Skip to content

Commit

Permalink
Further test improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
trexfeathers committed Dec 17, 2024
1 parent 519ae5f commit 506dfa9
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ def test_num2date(time_coord, future_date_microseconds, indexing):
if not future_date_microseconds or cf_units_legacy:
expected_microseconds = 0

assert all(r.microsecond == expected_microseconds for r in result)
result_microseconds = np.array([r.microsecond for r in result])
assert_array_equal(result_microseconds, expected_microseconds)


def test_roundup(time_coord, future_date_microseconds):
n_microseconds, coord = time_coord
result = coord.units.num2date(coord.points)

expected_seconds = np.floor(coord.points)
if n_microseconds >= 500000 and not future_date_microseconds:
if n_microseconds >= 500000 and (not future_date_microseconds or cf_units_legacy):
# Legacy cf-units versions round microseconds and ignore the future flag.
expected_seconds += 1

result_seconds = np.array([r.second for r in result])
Expand Down

0 comments on commit 506dfa9

Please sign in to comment.