@@ -1488,6 +1488,19 @@ def test_construction_with_dtype(self):
1488
1488
result = CategoricalIndex (idx , categories = idx , ordered = True )
1489
1489
tm .assert_index_equal (result , expected , exact = True )
1490
1490
1491
+ def test_disallow_set_ops (self ):
1492
+
1493
+ # GH 10039
1494
+ # set ops (+/-) raise TypeError
1495
+ idx = pd .Index (pd .Categorical (['a' , 'b' ]))
1496
+
1497
+ self .assertRaises (TypeError , lambda : idx - idx )
1498
+ self .assertRaises (TypeError , lambda : idx + idx )
1499
+ self .assertRaises (TypeError , lambda : idx - ['a' ,'b' ])
1500
+ self .assertRaises (TypeError , lambda : idx + ['a' ,'b' ])
1501
+ self .assertRaises (TypeError , lambda : ['a' ,'b' ] - idx )
1502
+ self .assertRaises (TypeError , lambda : ['a' ,'b' ] + idx )
1503
+
1491
1504
def test_method_delegation (self ):
1492
1505
1493
1506
ci = CategoricalIndex (list ('aabbca' ), categories = list ('cabdef' ))
@@ -3882,6 +3895,12 @@ def test_difference(self):
3882
3895
# - API change GH 8226
3883
3896
with tm .assert_produces_warning ():
3884
3897
first - self .index [- 3 :]
3898
+ with tm .assert_produces_warning ():
3899
+ self .index [- 3 :] - first
3900
+ with tm .assert_produces_warning ():
3901
+ self .index [- 3 :] - first .tolist ()
3902
+ with tm .assert_produces_warning ():
3903
+ first .tolist () - self .index [- 3 :]
3885
3904
3886
3905
expected = MultiIndex .from_tuples (sorted (self .index [:- 3 ].values ),
3887
3906
sortorder = 0 ,
0 commit comments