@@ -1489,6 +1489,21 @@ def test_fillvalue_exotic_dtype(self):
14891489 control = np .array ((0 , 0 , 0 ), dtype = "int, float, float" ).astype (ndtype )
14901490 assert_equal (_check_fill_value (0 , ndtype ), control )
14911491
1492+ def test_fillvalue_datetime_timedelta (self ):
1493+ # Test default fillvalue for datetime64 and timedelta64 types.
1494+ # See issue #4476, this would return '?' which would cause errors
1495+ # elsewhere
1496+
1497+ for timecode in ("as" , "fs" , "ps" , "ns" , "us" , "ms" , "s" , "m" ,
1498+ "h" , "D" , "W" , "M" , "Y" ):
1499+ control = numpy .datetime64 ("NaT" , timecode )
1500+ test = default_fill_value (numpy .dtype ("<M8[" + timecode + "]" ))
1501+ assert_equal (test , control )
1502+
1503+ control = numpy .timedelta64 ("NaT" , timecode )
1504+ test = default_fill_value (numpy .dtype ("<m8[" + timecode + "]" ))
1505+ assert_equal (test , control )
1506+
14921507 def test_extremum_fill_value (self ):
14931508 # Tests extremum fill values for flexible type.
14941509 a = array ([(1 , (2 , 3 )), (4 , (5 , 6 ))],
0 commit comments