File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,7 +88,8 @@ def maybe_promote(dtype: T_dtype) -> tuple[T_dtype, Any]:
8888 # See https://github.com/numpy/numpy/issues/10685
8989 # np.timedelta64 is a subclass of np.integer
9090 # Check np.timedelta64 before np.integer
91- fill_value = np .timedelta64 ("NaT" )
91+ unit , _ = np .datetime_data (dtype )
92+ fill_value = np .timedelta64 ("NaT" , unit )
9293 dtype_ = dtype
9394 elif isdtype (dtype , "integral" ):
9495 dtype_ = np .float32 if dtype .itemsize <= 2 else np .float64
@@ -97,8 +98,9 @@ def maybe_promote(dtype: T_dtype) -> tuple[T_dtype, Any]:
9798 dtype_ = dtype
9899 fill_value = np .nan + np .nan * 1j
99100 elif np .issubdtype (dtype , np .datetime64 ):
101+ unit , _ = np .datetime_data (dtype )
100102 dtype_ = dtype
101- fill_value = np .datetime64 ("NaT" )
103+ fill_value = np .datetime64 ("NaT" , unit )
102104 else :
103105 dtype_ = object
104106 fill_value = np .nan
Original file line number Diff line number Diff line change @@ -102,8 +102,8 @@ def test_inf(obj) -> None:
102102 ("I" , (np .float64 , "nan" )), # dtype('uint32')
103103 ("l" , (np .float64 , "nan" )), # dtype('int64')
104104 ("L" , (np .float64 , "nan" )), # dtype('uint64')
105- ("m " , (np .timedelta64 , "NaT" )), # dtype('<m8')
106- ("M " , (np .datetime64 , "NaT" )), # dtype('<M8')
105+ ("<m8[ns] " , (np .dtype ( "<m8[ns]" ) , "NaT" )), # dtype('<m8[ns] ')
106+ ("<M8[ns] " , (np .dtype ( "<M8[ns]" ) , "NaT" )), # dtype('<M8[ns] ')
107107 ("O" , (np .dtype ("O" ), "nan" )), # dtype('O')
108108 ("p" , (np .float64 , "nan" )), # dtype('int64')
109109 ("P" , (np .float64 , "nan" )), # dtype('uint64')
You can’t perform that action at this time.
0 commit comments