@@ -68,15 +68,15 @@ def create_block(typestr, placement, item_shape=None, num_offset=0):
68
68
elif typestr in ('object' , 'string' , 'O' ):
69
69
values = np .reshape (['A%d' % i for i in mat .ravel () + num_offset ],
70
70
shape )
71
- elif typestr in ('bool' ):
71
+ elif typestr in ('b' , ' bool', ):
72
72
values = np .ones (shape , dtype = np .bool_ )
73
73
elif typestr in ('datetime' , 'dt' , 'M8[ns]' ):
74
74
values = (mat * 1e9 ).astype ('M8[ns]' )
75
75
elif typestr in ('timedelta' , 'td' , 'm8[ns]' ):
76
76
values = (mat * 1 ).astype ('m8[ns]' )
77
- elif typestr in ('category' ):
77
+ elif typestr in ('category' , ):
78
78
values = Categorical ([1 ,1 ,2 ,2 ,3 ,3 ,3 ,3 ,4 ,4 ])
79
- elif typestr in ('category2' ):
79
+ elif typestr in ('category2' , ):
80
80
values = Categorical (['a' ,'a' ,'a' ,'a' ,'b' ,'b' ,'c' ,'c' ,'c' ,'d' ])
81
81
elif typestr in ('sparse' , 'sparse_na' ):
82
82
# FIXME: doesn't support num_rows != 10
@@ -751,6 +751,25 @@ def test_equals(self):
751
751
bm2 = BlockManager (bm1 .blocks [::- 1 ], bm1 .axes )
752
752
self .assertTrue (bm1 .equals (bm2 ))
753
753
754
+ def test_equals_block_order_different_dtypes (self ):
755
+ # GH 9330
756
+
757
+ mgr_strings = [
758
+ "a:i8;b:f8" , # basic case
759
+ "a:i8;b:f8;c:c8;d:b" , # many types
760
+ "a:i8;e:dt;f:td;g:string" , # more types
761
+ "a:i8;b:category;c:category2;d:category2" , # categories
762
+ "c:sparse;d:sparse_na;b:f8" , # sparse
763
+ ]
764
+
765
+ for mgr_string in mgr_strings :
766
+ bm = create_mgr (mgr_string )
767
+ block_perms = itertools .permutations (bm .blocks )
768
+ for bm_perm in block_perms :
769
+ bm_this = BlockManager (bm_perm , bm .axes )
770
+ self .assertTrue (bm .equals (bm_this ))
771
+ self .assertTrue (bm_this .equals (bm ))
772
+
754
773
def test_single_mgr_ctor (self ):
755
774
mgr = create_single_mgr ('f8' , num_rows = 5 )
756
775
self .assertEqual (mgr .as_matrix ().tolist (), [0. , 1. , 2. , 3. , 4. ])
0 commit comments