File tree 2 files changed +7
-0
lines changed 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ def _unpack_netcdf_time_units(units):
127
127
# whitespace. It also ensures that the year is padded with zeros
128
128
# so it will be correctly understood by pandas (via dateutil).
129
129
matches = re .match (r"(.+) since (.+)" , units )
130
+
130
131
if not matches :
131
132
raise ValueError (f"invalid time units: { units } " )
132
133
Original file line number Diff line number Diff line change @@ -823,6 +823,12 @@ def test_encode_cf_datetime_overflow(shape):
823
823
roundtrip = decode_cf_datetime (num , units , calendar )
824
824
np .testing .assert_array_equal (dates , roundtrip )
825
825
826
+ with pytest .raises (ValueError , match = "invalid time units" ):
827
+ encode_cf_datetime (dates , units = "days after 2000-01-01" )
828
+
829
+ with pytest .raises (ValueError , match = "invalid reference date" ):
830
+ encode_cf_datetime (dates , units = "days since NO_YEAR" )
831
+
826
832
827
833
def test_encode_cf_datetime_pandas_min ():
828
834
# GH 2623
You can’t perform that action at this time.
0 commit comments