|
2 | 2 |
|
3 | 3 | from collections import defaultdict
|
4 | 4 | from datetime import datetime, timedelta
|
5 |
| -from decimal import Decimal |
6 | 5 | import math
|
7 | 6 | import sys
|
8 | 7 |
|
@@ -834,61 +833,6 @@ def test_union_dt_as_obj(self):
|
834 | 833 | tm.assert_contains_all(self.strIndex, secondCat)
|
835 | 834 | tm.assert_contains_all(self.dateIndex, firstCat)
|
836 | 835 |
|
837 |
| - def test_add(self): |
838 |
| - index = self.strIndex |
839 |
| - expected = Index(self.strIndex.values * 2) |
840 |
| - tm.assert_index_equal(index + index, expected) |
841 |
| - tm.assert_index_equal(index + index.tolist(), expected) |
842 |
| - tm.assert_index_equal(index.tolist() + index, expected) |
843 |
| - |
844 |
| - # test add and radd |
845 |
| - index = Index(list('abc')) |
846 |
| - expected = Index(['a1', 'b1', 'c1']) |
847 |
| - tm.assert_index_equal(index + '1', expected) |
848 |
| - expected = Index(['1a', '1b', '1c']) |
849 |
| - tm.assert_index_equal('1' + index, expected) |
850 |
| - |
851 |
| - def test_sub_fail(self): |
852 |
| - index = self.strIndex |
853 |
| - pytest.raises(TypeError, lambda: index - 'a') |
854 |
| - pytest.raises(TypeError, lambda: index - index) |
855 |
| - pytest.raises(TypeError, lambda: index - index.tolist()) |
856 |
| - pytest.raises(TypeError, lambda: index.tolist() - index) |
857 |
| - |
858 |
| - def test_sub_object(self): |
859 |
| - # GH#19369 |
860 |
| - index = pd.Index([Decimal(1), Decimal(2)]) |
861 |
| - expected = pd.Index([Decimal(0), Decimal(1)]) |
862 |
| - |
863 |
| - result = index - Decimal(1) |
864 |
| - tm.assert_index_equal(result, expected) |
865 |
| - |
866 |
| - result = index - pd.Index([Decimal(1), Decimal(1)]) |
867 |
| - tm.assert_index_equal(result, expected) |
868 |
| - |
869 |
| - with pytest.raises(TypeError): |
870 |
| - index - 'foo' |
871 |
| - |
872 |
| - with pytest.raises(TypeError): |
873 |
| - index - np.array([2, 'foo']) |
874 |
| - |
875 |
| - def test_rsub_object(self): |
876 |
| - # GH#19369 |
877 |
| - index = pd.Index([Decimal(1), Decimal(2)]) |
878 |
| - expected = pd.Index([Decimal(1), Decimal(0)]) |
879 |
| - |
880 |
| - result = Decimal(2) - index |
881 |
| - tm.assert_index_equal(result, expected) |
882 |
| - |
883 |
| - result = np.array([Decimal(2), Decimal(2)]) - index |
884 |
| - tm.assert_index_equal(result, expected) |
885 |
| - |
886 |
| - with pytest.raises(TypeError): |
887 |
| - 'foo' - index |
888 |
| - |
889 |
| - with pytest.raises(TypeError): |
890 |
| - np.array([True, pd.Timestamp.now()]) - index |
891 |
| - |
892 | 836 | def test_map_identity_mapping(self):
|
893 | 837 | # GH 12766
|
894 | 838 | # TODO: replace with fixture
|
@@ -1008,22 +952,6 @@ def test_append_empty_preserve_name(self, name, expected):
|
1008 | 952 | result = left.append(right)
|
1009 | 953 | assert result.name == expected
|
1010 | 954 |
|
1011 |
| - def test_add_string(self): |
1012 |
| - # from bug report |
1013 |
| - index = Index(['a', 'b', 'c']) |
1014 |
| - index2 = index + 'foo' |
1015 |
| - |
1016 |
| - assert 'a' not in index2 |
1017 |
| - assert 'afoo' in index2 |
1018 |
| - |
1019 |
| - def test_iadd_string(self): |
1020 |
| - index = pd.Index(['a', 'b', 'c']) |
1021 |
| - # doesn't fail test unless there is a check before `+=` |
1022 |
| - assert 'a' in index |
1023 |
| - |
1024 |
| - index += '_x' |
1025 |
| - assert 'a_x' in index |
1026 |
| - |
1027 | 955 | @pytest.mark.parametrize("second_name,expected", [
|
1028 | 956 | (None, None), ('name', 'name')])
|
1029 | 957 | @pytest.mark.parametrize("sort", [True, False])
|
@@ -2146,36 +2074,6 @@ def test_string_index_repr_with_unicode_option_compat(self, index,
|
2146 | 2074 | result = unicode(index) # noqa
|
2147 | 2075 | assert result == expected
|
2148 | 2076 |
|
2149 |
| - @pytest.mark.parametrize('dtype', [np.int64, np.float64]) |
2150 |
| - @pytest.mark.parametrize('delta', [1, 0, -1]) |
2151 |
| - def test_addsub_arithmetic(self, dtype, delta): |
2152 |
| - # GH 8142 |
2153 |
| - delta = dtype(delta) |
2154 |
| - index = pd.Index([10, 11, 12], dtype=dtype) |
2155 |
| - result = index + delta |
2156 |
| - expected = pd.Index(index.values + delta, dtype=dtype) |
2157 |
| - tm.assert_index_equal(result, expected) |
2158 |
| - |
2159 |
| - # this subtraction used to fail |
2160 |
| - result = index - delta |
2161 |
| - expected = pd.Index(index.values - delta, dtype=dtype) |
2162 |
| - tm.assert_index_equal(result, expected) |
2163 |
| - |
2164 |
| - tm.assert_index_equal(index + index, 2 * index) |
2165 |
| - tm.assert_index_equal(index - index, 0 * index) |
2166 |
| - assert not (index - index).empty |
2167 |
| - |
2168 |
| - def test_iadd_preserves_name(self): |
2169 |
| - # GH#17067, GH#19723 __iadd__ and __isub__ should preserve index name |
2170 |
| - ser = pd.Series([1, 2, 3]) |
2171 |
| - ser.index.name = 'foo' |
2172 |
| - |
2173 |
| - ser.index += 1 |
2174 |
| - assert ser.index.name == "foo" |
2175 |
| - |
2176 |
| - ser.index -= 1 |
2177 |
| - assert ser.index.name == "foo" |
2178 |
| - |
2179 | 2077 | def test_cached_properties_not_settable(self):
|
2180 | 2078 | index = pd.Index([1, 2, 3])
|
2181 | 2079 | with pytest.raises(AttributeError, match="Can't set attribute"):
|
|
0 commit comments