@@ -528,32 +528,33 @@ def test_as_array_datetime_tz(self):
528
528
assert mgr .get ("g" ).dtype == "datetime64[ns, CET]"
529
529
assert mgr .as_array ().dtype == "object"
530
530
531
- def test_astype (self ):
531
+ @pytest .mark .parametrize ("t" , ["float16" , "float32" , "float64" , "int32" , "int64" ])
532
+ def test_astype (self , t ):
532
533
# coerce all
533
534
mgr = create_mgr ("c: f4; d: f2; e: f8" )
534
- for t in [ "float16" , "float32" , "float64" , "int32" , "int64" ]:
535
- t = np .dtype (t )
536
- tmgr = mgr .astype (t )
537
- assert tmgr .get ("c" ).dtype .type == t
538
- assert tmgr .get ("d" ).dtype .type == t
539
- assert tmgr .get ("e" ).dtype .type == t
535
+
536
+ t = np .dtype (t )
537
+ tmgr = mgr .astype (t )
538
+ assert tmgr .get ("c" ).dtype .type == t
539
+ assert tmgr .get ("d" ).dtype .type == t
540
+ assert tmgr .get ("e" ).dtype .type == t
540
541
541
542
# mixed
542
543
mgr = create_mgr ("a,b: object; c: bool; d: datetime; e: f4; f: f2; g: f8" )
543
- for t in [ "float16" , "float32" , "float64" , "int32" , "int64" ]:
544
- t = np .dtype (t )
545
- tmgr = mgr .astype (t , errors = "ignore" )
546
- assert tmgr .get ("c" ).dtype .type == t
547
- assert tmgr .get ("e" ).dtype .type == t
548
- assert tmgr .get ("f" ).dtype .type == t
549
- assert tmgr .get ("g" ).dtype .type == t
550
-
551
- assert tmgr .get ("a" ).dtype .type == np .object_
552
- assert tmgr .get ("b" ).dtype .type == np .object_
553
- if t != np .int64 :
554
- assert tmgr .get ("d" ).dtype .type == np .datetime64
555
- else :
556
- assert tmgr .get ("d" ).dtype .type == t
544
+
545
+ t = np .dtype (t )
546
+ tmgr = mgr .astype (t , errors = "ignore" )
547
+ assert tmgr .get ("c" ).dtype .type == t
548
+ assert tmgr .get ("e" ).dtype .type == t
549
+ assert tmgr .get ("f" ).dtype .type == t
550
+ assert tmgr .get ("g" ).dtype .type == t
551
+
552
+ assert tmgr .get ("a" ).dtype .type == np .object_
553
+ assert tmgr .get ("b" ).dtype .type == np .object_
554
+ if t != np .int64 :
555
+ assert tmgr .get ("d" ).dtype .type == np .datetime64
556
+ else :
557
+ assert tmgr .get ("d" ).dtype .type == t
557
558
558
559
def test_convert (self ):
559
560
def _compare (old_mgr , new_mgr ):
0 commit comments