|
34 | 34 | period_range,
|
35 | 35 | )
|
36 | 36 | import pandas._testing as tm
|
37 |
| -from pandas.core.algorithms import safe_sort |
38 | 37 | from pandas.core.indexes.api import (
|
39 | 38 | Index,
|
40 | 39 | MultiIndex,
|
@@ -108,23 +107,6 @@ def test_constructor_copy(self, index):
|
108 | 107 | # arr = np.array(5.)
|
109 | 108 | # pytest.raises(Exception, arr.view, Index)
|
110 | 109 |
|
111 |
| - def test_constructor_corner(self): |
112 |
| - # corner case |
113 |
| - msg = ( |
114 |
| - r"Index\(\.\.\.\) must be called with a collection of some " |
115 |
| - "kind, 0 was passed" |
116 |
| - ) |
117 |
| - with pytest.raises(TypeError, match=msg): |
118 |
| - Index(0) |
119 |
| - |
120 |
| - @pytest.mark.parametrize("index_vals", [[("A", 1), "B"], ["B", ("A", 1)]]) |
121 |
| - def test_construction_list_mixed_tuples(self, index_vals): |
122 |
| - # see gh-10697: if we are constructing from a mixed list of tuples, |
123 |
| - # make sure that we are independent of the sorting order. |
124 |
| - index = Index(index_vals) |
125 |
| - assert isinstance(index, Index) |
126 |
| - assert not isinstance(index, MultiIndex) |
127 |
| - |
128 | 110 | @pytest.mark.parametrize("na_value", [None, np.nan])
|
129 | 111 | @pytest.mark.parametrize("vtype", [list, tuple, iter])
|
130 | 112 | def test_construction_list_tuples_nan(self, na_value, vtype):
|
@@ -359,11 +341,6 @@ def test_constructor_simple_new(self, vals, dtype):
|
359 | 341 | result = index._simple_new(index.values, dtype)
|
360 | 342 | tm.assert_index_equal(result, index)
|
361 | 343 |
|
362 |
| - def test_constructor_wrong_kwargs(self): |
363 |
| - # GH #19348 |
364 |
| - with pytest.raises(TypeError, match="Unexpected keyword arguments {'foo'}"): |
365 |
| - Index([], foo="bar") |
366 |
| - |
367 | 344 | @pytest.mark.parametrize(
|
368 | 345 | "vals",
|
369 | 346 | [
|
@@ -554,12 +531,6 @@ def test_constructor_overflow_int64(self):
|
554 | 531 | with pytest.raises(OverflowError, match=msg):
|
555 | 532 | Index([np.iinfo(np.uint64).max - 1], dtype="int64")
|
556 | 533 |
|
557 |
| - @pytest.mark.xfail(reason="see GH#21311: Index doesn't enforce dtype argument") |
558 |
| - def test_constructor_cast(self): |
559 |
| - msg = "could not convert string to float" |
560 |
| - with pytest.raises(ValueError, match=msg): |
561 |
| - Index(["a", "b", "c"], dtype=float) |
562 |
| - |
563 | 534 | @pytest.mark.parametrize(
|
564 | 535 | "index",
|
565 | 536 | [
|
@@ -2528,78 +2499,12 @@ def test_copy_name2(self):
|
2528 | 2499 | assert index3.name == "NewName"
|
2529 | 2500 | assert index3.names == ["NewName"]
|
2530 | 2501 |
|
2531 |
| - def test_union_base(self): |
2532 |
| - index = self.create_index() |
2533 |
| - first = index[3:] |
2534 |
| - second = index[:5] |
2535 |
| - |
2536 |
| - result = first.union(second) |
2537 |
| - |
2538 |
| - expected = Index([0, 1, 2, "a", "b", "c"]) |
2539 |
| - tm.assert_index_equal(result, expected) |
2540 |
| - |
2541 |
| - @pytest.mark.parametrize("klass", [np.array, Series, list]) |
2542 |
| - def test_union_different_type_base(self, klass): |
2543 |
| - # GH 10149 |
2544 |
| - index = self.create_index() |
2545 |
| - first = index[3:] |
2546 |
| - second = index[:5] |
2547 |
| - |
2548 |
| - result = first.union(klass(second.values)) |
2549 |
| - |
2550 |
| - assert tm.equalContents(result, index) |
2551 |
| - |
2552 | 2502 | def test_unique_na(self):
|
2553 | 2503 | idx = pd.Index([2, np.nan, 2, 1], name="my_index")
|
2554 | 2504 | expected = pd.Index([2, np.nan, 1], name="my_index")
|
2555 | 2505 | result = idx.unique()
|
2556 | 2506 | tm.assert_index_equal(result, expected)
|
2557 | 2507 |
|
2558 |
| - @pytest.mark.parametrize("sort", [None, False]) |
2559 |
| - def test_intersection_base(self, sort): |
2560 |
| - # (same results for py2 and py3 but sortedness not tested elsewhere) |
2561 |
| - index = self.create_index() |
2562 |
| - first = index[:5] |
2563 |
| - second = index[:3] |
2564 |
| - |
2565 |
| - expected = Index([0, 1, "a"]) if sort is None else Index([0, "a", 1]) |
2566 |
| - result = first.intersection(second, sort=sort) |
2567 |
| - tm.assert_index_equal(result, expected) |
2568 |
| - |
2569 |
| - @pytest.mark.parametrize("klass", [np.array, Series, list]) |
2570 |
| - @pytest.mark.parametrize("sort", [None, False]) |
2571 |
| - def test_intersection_different_type_base(self, klass, sort): |
2572 |
| - # GH 10149 |
2573 |
| - index = self.create_index() |
2574 |
| - first = index[:5] |
2575 |
| - second = index[:3] |
2576 |
| - |
2577 |
| - result = first.intersection(klass(second.values), sort=sort) |
2578 |
| - assert tm.equalContents(result, second) |
2579 |
| - |
2580 |
| - @pytest.mark.parametrize("sort", [None, False]) |
2581 |
| - def test_difference_base(self, sort): |
2582 |
| - # (same results for py2 and py3 but sortedness not tested elsewhere) |
2583 |
| - index = self.create_index() |
2584 |
| - first = index[:4] |
2585 |
| - second = index[3:] |
2586 |
| - |
2587 |
| - result = first.difference(second, sort) |
2588 |
| - expected = Index([0, "a", 1]) |
2589 |
| - if sort is None: |
2590 |
| - expected = Index(safe_sort(expected)) |
2591 |
| - tm.assert_index_equal(result, expected) |
2592 |
| - |
2593 |
| - def test_symmetric_difference(self): |
2594 |
| - # (same results for py2 and py3 but sortedness not tested elsewhere) |
2595 |
| - index = self.create_index() |
2596 |
| - first = index[:4] |
2597 |
| - second = index[3:] |
2598 |
| - |
2599 |
| - result = first.symmetric_difference(second) |
2600 |
| - expected = Index([0, 1, 2, "a", "c"]) |
2601 |
| - tm.assert_index_equal(result, expected) |
2602 |
| - |
2603 | 2508 | def test_logical_compat(self):
|
2604 | 2509 | index = self.create_index()
|
2605 | 2510 | assert index.all() == index.values.all()
|
|
0 commit comments