@@ -767,20 +767,24 @@ def test_sub(self):
767767 self .assertRaises (TypeError , lambda : idx .tolist () - idx )
768768
769769 def test_map_identity_mapping (self ):
770+ # GH 12766
770771 for name , cur_index in self .indices .items ():
771- if name == 'tuples' :
772- expected = Index (cur_index .values , tupleize_cols = False )
773- self .assert_index_equal (expected , cur_index .map (lambda x : x ))
774- else :
775- self .assert_index_equal (cur_index , cur_index .map (lambda x : x ))
772+ self .assert_index_equal (cur_index , cur_index .map (lambda x : x ))
776773
777- def test_map_that_returns_tuples_creates_index_not_multi_index (self ):
774+ def test_map_that_returns_tuples_creates_multi_index (self ):
775+ # GH 12766
778776 boolean_index = tm .makeIntIndex (3 ).map (lambda x : (x , x == 1 ))
779- expected = Index ([(0 , False ), (1 , True ), (2 , False )],
780- tupleize_cols = False )
777+ expected = MultiIndex .from_tuples ([(0 , False ), (1 , True ), (2 , False )])
778+ self .assert_index_equal (boolean_index , expected )
779+
780+ def test_map_that_returns_a_length_one_tuple_creates_an_index (self ):
781+ # GH 12766
782+ boolean_index = tm .makeIntIndex (3 ).map (lambda x : (x , ))
783+ expected = Index ([(0 , ), (1 , ), (2 , )])
781784 self .assert_index_equal (boolean_index , expected )
782785
783786 def test_map_that_reduces_multi_index_to_single_index_returns_index (self ):
787+ # GH 12766
784788 first_level = ['foo' , 'bar' , 'baz' ]
785789 multi_index = MultiIndex .from_tuples (lzip (first_level , [1 , 2 , 3 ]))
786790 reduced_index = multi_index .map (lambda x : x [0 ])
0 commit comments