Skip to content

Commit a6572b2

Browse files
committed
Add copy keyword to uses of _set_dtype
1 parent db30fe9 commit a6572b2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pandas/tests/arrays/categorical/test_dtypes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def test_categories_match_up_to_permutation(self):
4949

5050
def test_set_dtype_same(self):
5151
c = Categorical(["a", "b", "c"])
52-
result = c._set_dtype(CategoricalDtype(["a", "b", "c"]))
52+
result = c._set_dtype(CategoricalDtype(["a", "b", "c"]), copy=True)
5353
tm.assert_categorical_equal(result, c)
5454

5555
def test_set_dtype_new_categories(self):
5656
c = Categorical(["a", "b", "c"])
57-
result = c._set_dtype(CategoricalDtype(list("abcd")))
57+
result = c._set_dtype(CategoricalDtype(list("abcd")), copy=True)
5858
tm.assert_numpy_array_equal(result.codes, c.codes)
5959
tm.assert_index_equal(result.dtype.categories, Index(list("abcd")))
6060

@@ -86,12 +86,12 @@ def test_set_dtype_new_categories(self):
8686
def test_set_dtype_many(self, values, categories, new_categories, ordered):
8787
c = Categorical(values, categories)
8888
expected = Categorical(values, new_categories, ordered)
89-
result = c._set_dtype(expected.dtype)
89+
result = c._set_dtype(expected.dtype, copy=True)
9090
tm.assert_categorical_equal(result, expected)
9191

9292
def test_set_dtype_no_overlap(self):
9393
c = Categorical(["a", "b", "c"], ["d", "e"])
94-
result = c._set_dtype(CategoricalDtype(["a", "b"]))
94+
result = c._set_dtype(CategoricalDtype(["a", "b"]), copy=True)
9595
expected = Categorical([None, None, None], categories=["a", "b"])
9696
tm.assert_categorical_equal(result, expected)
9797

pandas/tests/arrays/categorical/test_missing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_nan_handling(self):
5252

5353
def test_set_dtype_nans(self):
5454
c = Categorical(["a", "b", np.nan])
55-
result = c._set_dtype(CategoricalDtype(["a", "c"]))
55+
result = c._set_dtype(CategoricalDtype(["a", "c"]), copy=True)
5656
tm.assert_numpy_array_equal(result.codes, np.array([0, -1, -1], dtype="int8"))
5757

5858
def test_set_item_nan(self):

0 commit comments

Comments
 (0)