Skip to content

Commit 6702f90

Browse files
committed
remove copy from tests
1 parent 821d79d commit 6702f90

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

pandas/tests/categorical/test_dtypes.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -100,55 +100,53 @@ def test_codes_dtypes(self):
100100
assert result.codes.dtype == 'int8'
101101

102102
@pytest.mark.parametrize('ordered', [True, False])
103-
@pytest.mark.parametrize('copy', [True, False])
104-
def test_astype(self, copy, ordered):
103+
def test_astype(self, ordered):
105104
# string
106105
cat = Categorical(list('abbaaccc'), ordered=ordered)
107-
result = cat.astype(object, copy=copy)
106+
result = cat.astype(object)
108107
expected = np.array(cat)
109108
tm.assert_numpy_array_equal(result, expected)
110109

111110
msg = 'could not convert string to float'
112111
with tm.assert_raises_regex(ValueError, msg):
113-
cat.astype(float, copy=copy)
112+
cat.astype(float)
114113

115114
# numeric
116115
cat = Categorical([0, 1, 2, 2, 1, 0, 1, 0, 2], ordered=ordered)
117-
result = cat.astype(object, copy=copy)
116+
result = cat.astype(object)
118117
expected = np.array(cat, dtype=object)
119118
tm.assert_numpy_array_equal(result, expected)
120119

121-
result = cat.astype(int, copy=copy)
120+
result = cat.astype(int)
122121
expected = np.array(cat, dtype=np.int)
123122
tm.assert_numpy_array_equal(result, expected)
124123

125-
result = cat.astype(float, copy=copy)
124+
result = cat.astype(float)
126125
expected = np.array(cat, dtype=np.float)
127126
tm.assert_numpy_array_equal(result, expected)
128127

129-
@pytest.mark.parametrize('copy', [True, False])
130128
@pytest.mark.parametrize('dtype_ordered', [True, False])
131129
@pytest.mark.parametrize('cat_ordered', [True, False])
132-
def test_astype_category(self, copy, dtype_ordered, cat_ordered):
130+
def test_astype_category(self, dtype_ordered, cat_ordered):
133131
# GH 10696/18593
134132
data = list('abcaacbab')
135133
cat = Categorical(data, categories=list('bac'), ordered=cat_ordered)
136134

137135
# standard categories
138136
dtype = CategoricalDtype(ordered=dtype_ordered)
139-
result = cat.astype(dtype, copy=copy)
137+
result = cat.astype(dtype)
140138
expected = Categorical(
141139
data, categories=cat.categories, ordered=dtype_ordered)
142140
tm.assert_categorical_equal(result, expected)
143141

144142
# non-standard categories
145143
dtype = CategoricalDtype(list('adc'), dtype_ordered)
146-
result = cat.astype(dtype, copy=copy)
144+
result = cat.astype(dtype)
147145
expected = Categorical(data, dtype=dtype)
148146
tm.assert_categorical_equal(result, expected)
149147

150148
if dtype_ordered is False:
151149
# dtype='category' can't specify ordered, so only test once
152-
result = cat.astype('category', copy=copy)
150+
result = cat.astype('category')
153151
expected = cat
154152
tm.assert_categorical_equal(result, expected)

pandas/tests/indexes/test_category.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -411,19 +411,18 @@ def test_astype(self):
411411
result = IntervalIndex.from_intervals(result.values)
412412
tm.assert_index_equal(result, expected)
413413

414-
@pytest.mark.parametrize('copy', [True, False])
415414
@pytest.mark.parametrize('name', [None, 'foo'])
416415
@pytest.mark.parametrize('dtype_ordered', [True, False])
417416
@pytest.mark.parametrize('index_ordered', [True, False])
418-
def test_astype_category(self, copy, name, dtype_ordered, index_ordered):
417+
def test_astype_category(self, name, dtype_ordered, index_ordered):
419418
# GH 18630
420419
index = self.create_index(ordered=index_ordered)
421420
if name:
422421
index = index.rename(name)
423422

424423
# standard categories
425424
dtype = CategoricalDtype(ordered=dtype_ordered)
426-
result = index.astype(dtype, copy=copy)
425+
result = index.astype(dtype)
427426
expected = CategoricalIndex(index.tolist(),
428427
name=name,
429428
categories=index.categories,
@@ -432,13 +431,13 @@ def test_astype_category(self, copy, name, dtype_ordered, index_ordered):
432431

433432
# non-standard categories
434433
dtype = CategoricalDtype(index.unique().tolist()[:-1], dtype_ordered)
435-
result = index.astype(dtype, copy=copy)
434+
result = index.astype(dtype)
436435
expected = CategoricalIndex(index.tolist(), name=name, dtype=dtype)
437436
tm.assert_index_equal(result, expected)
438437

439438
if dtype_ordered is False:
440439
# dtype='category' can't specify ordered, so only test once
441-
result = index.astype('category', copy=copy)
440+
result = index.astype('category')
442441
expected = index
443442
tm.assert_index_equal(result, expected)
444443

pandas/tests/series/test_dtypes.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,10 @@ def cmp(a, b):
322322
lambda x: x.astype('object').astype(Categorical)]:
323323
pytest.raises(TypeError, lambda: invalid(s))
324324

325-
@pytest.mark.parametrize('copy', [True, False])
326325
@pytest.mark.parametrize('name', [None, 'foo'])
327326
@pytest.mark.parametrize('dtype_ordered', [True, False])
328327
@pytest.mark.parametrize('series_ordered', [True, False])
329-
def test_astype_categorical_to_categorical(self, copy, name, dtype_ordered,
328+
def test_astype_categorical_to_categorical(self, name, dtype_ordered,
330329
series_ordered):
331330
# GH 10696/18593
332331
s_data = list('abcaacbab')
@@ -335,7 +334,7 @@ def test_astype_categorical_to_categorical(self, copy, name, dtype_ordered,
335334

336335
# unspecified categories
337336
dtype = CategoricalDtype(ordered=dtype_ordered)
338-
result = s.astype(dtype, copy=copy)
337+
result = s.astype(dtype)
339338
exp_dtype = CategoricalDtype(s_dtype.categories, dtype_ordered)
340339
expected = Series(s_data, name=name, dtype=exp_dtype)
341340
tm.assert_series_equal(result, expected)
@@ -346,7 +345,7 @@ def test_astype_categorical_to_categorical(self, copy, name, dtype_ordered,
346345

347346
# different categories
348347
dtype = CategoricalDtype(list('adc'), dtype_ordered)
349-
result = s.astype(dtype, copy=copy)
348+
result = s.astype(dtype)
350349
expected = Series(s_data, name=name, dtype=dtype)
351350
tm.assert_series_equal(result, expected)
352351

@@ -358,7 +357,7 @@ def test_astype_categorical_to_categorical(self, copy, name, dtype_ordered,
358357
if dtype_ordered is False:
359358
# not specifying ordered, so only test once
360359
expected = s
361-
result = s.astype('category', copy=copy)
360+
result = s.astype('category')
362361
tm.assert_series_equal(result, expected)
363362

364363
def test_astype_categoricaldtype(self):

0 commit comments

Comments
 (0)