Skip to content

Commit

Permalink
Corrected behaviour and added tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
trexfeathers committed Dec 16, 2024
1 parent ce69618 commit fa31ff4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/iris/common/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,7 @@ def _round(date):
result = _num2date_original(
self, time_value, only_use_cftime_datetimes, only_use_python_datetimes
)
if FUTURE.date_microseconds:
if hasattr(result, "shape"):
vfunc = np.vectorize(_round)
result = vfunc(result)
else:
result = _round(result)

else:
if FUTURE.date_microseconds is False:
message = (
"You are using legacy date precision for Iris units - max "
"precision is seconds. In future, Iris will use microsecond "
Expand All @@ -99,6 +92,12 @@ def _round(date):
)
warnings.warn(message, category=FutureWarning)

if hasattr(result, "shape"):
vfunc = np.vectorize(_round)
result = vfunc(result)
else:
result = _round(result)

return result


Expand Down

0 comments on commit fa31ff4

Please sign in to comment.