@@ -54,7 +54,40 @@ def test_astype_array_b3(self) -> None:
5454 a2 = astype_array (a1 , np .object_ )
5555 self .assertEqual (a2 .dtype , np .dtype (np .object_ ))
5656 self .assertFalse (a2 .flags .writeable )
57- import ipdb ; ipdb .set_trace ()
5857 self .assertEqual (
5958 list (list (a ) for a in a2 ),
6059 [[np .datetime64 ('2021' ), np .datetime64 ('2024' )], [np .datetime64 ('1984' ), np .datetime64 ('1642' )]])
60+
61+ def test_astype_array_b4 (self ) -> None :
62+ a1 = np .array (['2021' , '2024' , '1532' , '1984' , '1642' , '899' ], dtype = np .datetime64 ).reshape ((2 , 3 ))
63+
64+ a2 = astype_array (a1 , np .object_ )
65+ self .assertEqual (a2 .dtype , np .dtype (np .object_ ))
66+ self .assertEqual (a2 .shape , (2 , 3 ))
67+ self .assertFalse (a2 .flags .writeable )
68+ self .assertEqual (
69+ list (list (a ) for a in a2 ),
70+ [[np .datetime64 ('2021' ), np .datetime64 ('2024' ), np .datetime64 ('1532' )],
71+ [np .datetime64 ('1984' ), np .datetime64 ('1642' ), np .datetime64 ('899' )]])
72+
73+ def test_astype_array_c (self ) -> None :
74+ with self .assertRaises (TypeError ):
75+ _ = astype_array ([3 , 4 , 5 ], np .int64 )
76+
77+
78+ def test_astype_array_d1 (self ) -> None :
79+ a1 = np .array ([10 , 20 , 30 ], dtype = np .int64 )
80+ a2 = astype_array (a1 )
81+
82+ self .assertEqual (a2 .dtype , np .dtype (np .float64 ))
83+ self .assertEqual (a2 .shape , (3 ,))
84+ self .assertFalse (a2 .flags .writeable )
85+
86+
87+ def test_astype_array_d2 (self ) -> None :
88+ a1 = np .array ([10 , 20 , 30 ], dtype = np .int64 )
89+ a2 = astype_array (a1 , None )
90+
91+ self .assertEqual (a2 .dtype , np .dtype (np .float64 ))
92+ self .assertEqual (a2 .shape , (3 ,))
93+ self .assertFalse (a2 .flags .writeable )
0 commit comments