@@ -768,20 +768,24 @@ def test_sub(self):
768
768
self .assertRaises (TypeError , lambda : idx .tolist () - idx )
769
769
770
770
def test_map_identity_mapping (self ):
771
+ # GH 12766
771
772
for name , cur_index in self .indices .items ():
772
- if name == 'tuples' :
773
- expected = Index (cur_index .values , tupleize_cols = False )
774
- self .assert_index_equal (expected , cur_index .map (lambda x : x ))
775
- else :
776
- self .assert_index_equal (cur_index , cur_index .map (lambda x : x ))
773
+ self .assert_index_equal (cur_index , cur_index .map (lambda x : x ))
777
774
778
- def test_map_that_returns_tuples_creates_index_not_multi_index (self ):
775
+ def test_map_that_returns_tuples_creates_multi_index (self ):
776
+ # GH 12766
779
777
boolean_index = tm .makeIntIndex (3 ).map (lambda x : (x , x == 1 ))
780
- expected = Index ([(0 , False ), (1 , True ), (2 , False )],
781
- tupleize_cols = False )
778
+ expected = MultiIndex .from_tuples ([(0 , False ), (1 , True ), (2 , False )])
779
+ self .assert_index_equal (boolean_index , expected )
780
+
781
+ def test_map_that_returns_a_length_one_tuple_creates_an_index (self ):
782
+ # GH 12766
783
+ boolean_index = tm .makeIntIndex (3 ).map (lambda x : (x , ))
784
+ expected = Index ([(0 , ), (1 , ), (2 , )])
782
785
self .assert_index_equal (boolean_index , expected )
783
786
784
787
def test_map_that_reduces_multi_index_to_single_index_returns_index (self ):
788
+ # GH 12766
785
789
first_level = ['foo' , 'bar' , 'baz' ]
786
790
multi_index = MultiIndex .from_tuples (lzip (first_level , [1 , 2 , 3 ]))
787
791
reduced_index = multi_index .map (lambda x : x [0 ])
0 commit comments