Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: follow-up to Test nested pandas array #24993 #25155

Merged
merged 9 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pandas/compat/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
_np_version_under1p13 = _nlv < LooseVersion('1.13')
_np_version_under1p14 = _nlv < LooseVersion('1.14')
_np_version_under1p15 = _nlv < LooseVersion('1.15')

_np_version_under1p16 = _nlv < LooseVersion('1.16')

if _nlv < '1.12':
raise ImportError('this version of pandas is incompatible with '
Expand Down Expand Up @@ -64,5 +64,6 @@ def np_array_datetime64_compat(arr, *args, **kwargs):
__all__ = ['np',
'_np_version_under1p13',
'_np_version_under1p14',
'_np_version_under1p15'
'_np_version_under1p15',
'_np_version_under1p16'
]
17 changes: 6 additions & 11 deletions pandas/tests/extension/base/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,14 @@ def test_groupby_extension_transform(self, data_for_grouping):

self.assert_series_equal(result, expected)

@pytest.mark.parametrize('op', [
lambda x: 1,
lambda x: [1] * len(x),
lambda x: pd.Series([1] * len(x)),
lambda x: x,
], ids=['scalar', 'list', 'series', 'object'])
def test_groupby_extension_apply(self, data_for_grouping, op):
def test_groupby_extension_apply(
self, data_for_grouping, groupby_apply_op):
df = pd.DataFrame({"A": [1, 1, 2, 2, 3, 3, 1, 4],
"B": data_for_grouping})
df.groupby("B").apply(op)
df.groupby("B").A.apply(op)
df.groupby("A").apply(op)
df.groupby("A").B.apply(op)
df.groupby("B").apply(groupby_apply_op)
df.groupby("B").A.apply(groupby_apply_op)
df.groupby("A").apply(groupby_apply_op)
df.groupby("A").B.apply(groupby_apply_op)

def test_in_numeric_groupby(self, data_for_grouping):
df = pd.DataFrame({"A": [1, 1, 2, 2, 3, 3, 1, 4],
Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/extension/base/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ def test_shift_fill_value(self, data):
expected = data.take([2, 3, 0, 0])
self.assert_extension_array_equal(result, expected)

@pytest.mark.parametrize("as_frame", [True, False])
def test_hash_pandas_object_works(self, data, as_frame):
# https://github.com/pandas-dev/pandas/issues/23066
data = pd.Series(data)
Expand All @@ -250,7 +249,6 @@ def test_hash_pandas_object_works(self, data, as_frame):
b = pd.util.hash_pandas_object(data)
self.assert_equal(a, b)

@pytest.mark.parametrize("as_series", [True, False])
def test_searchsorted(self, data_for_sorting, as_series):
b, c, a = data_for_sorting
arr = type(data_for_sorting)._from_sequence([a, b, c])
Expand All @@ -275,7 +273,6 @@ def test_searchsorted(self, data_for_sorting, as_series):
sorter = np.array([1, 2, 0])
assert data_for_sorting.searchsorted(a, sorter=sorter) == 0

@pytest.mark.parametrize("as_frame", [True, False])
def test_where_series(self, data, na_value, as_frame):
assert data[0] != data[1]
cls = type(data)
Expand Down Expand Up @@ -309,8 +306,6 @@ def test_where_series(self, data, na_value, as_frame):
expected = expected.to_frame(name='a')
self.assert_equal(result, expected)

@pytest.mark.parametrize("use_numpy", [True, False])
@pytest.mark.parametrize("as_series", [True, False])
@pytest.mark.parametrize("repeats", [0, 1, 2, [1, 2, 3]])
def test_repeat(self, data, repeats, as_series, use_numpy):
arr = type(data)._from_sequence(data[:3], dtype=data.dtype)
Expand All @@ -327,7 +322,6 @@ def test_repeat(self, data, repeats, as_series, use_numpy):

self.assert_equal(result, expected)

@pytest.mark.parametrize("use_numpy", [True, False])
@pytest.mark.parametrize('repeats, kwargs, error, msg', [
(2, dict(axis=1), ValueError, "'axis"),
(-1, dict(), ValueError, "negative"),
Expand Down
8 changes: 3 additions & 5 deletions pandas/tests/extension/base/missing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import pytest

import pandas as pd
import pandas.util.testing as tm
Expand Down Expand Up @@ -89,14 +88,13 @@ def test_fillna_series(self, data_missing):
result = ser.fillna(ser)
self.assert_series_equal(result, ser)

@pytest.mark.parametrize('method', ['ffill', 'bfill'])
def test_fillna_series_method(self, data_missing, method):
def test_fillna_series_method(self, data_missing, fillna_method):
fill_value = data_missing[1]

if method == 'ffill':
if fillna_method == 'ffill':
data_missing = data_missing[::-1]

result = pd.Series(data_missing).fillna(method=method)
result = pd.Series(data_missing).fillna(method=fillna_method)
expected = pd.Series(data_missing._from_sequence(
[fill_value, fill_value], dtype=data_missing.dtype))

Expand Down
1 change: 0 additions & 1 deletion pandas/tests/extension/base/setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def test_setitem_sequence(self, data, box_in_series):
assert data[0] == original[1]
assert data[1] == original[0]

@pytest.mark.parametrize('as_array', [True, False])
def test_setitem_sequence_mismatched_length_raises(self, data, as_array):
ser = pd.Series(data)
original = ser.copy()
Expand Down
38 changes: 38 additions & 0 deletions pandas/tests/extension/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import pytest

from pandas import Series


@pytest.fixture
def dtype():
Expand Down Expand Up @@ -108,3 +110,39 @@ def data_for_grouping():
def box_in_series(request):
"""Whether to box the data in a Series"""
return request.param


@pytest.fixture(params=[
lambda x: 1,
lambda x: [1] * len(x),
lambda x: Series([1] * len(x)),
lambda x: x,
], ids=['scalar', 'list', 'series', 'object'])
def groupby_apply_op(request):
"""functions to test groupby.apply()"""
return request.param


@pytest.fixture(params=[True, False])
def as_frame(request):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you give these a comment

return request.param


@pytest.fixture(params=[True, False])
def as_series(request):
return request.param


@pytest.fixture(params=[True, False])
def use_numpy(request):
return request.param


@pytest.fixture(params=['ffill', 'bfill'])
def fillna_method(request):
return request.param


@pytest.fixture(params=[True, False])
def as_array(request):
return request.param
Empty file.
38 changes: 0 additions & 38 deletions pandas/tests/extension/numpy_/conftest.py

This file was deleted.

182 changes: 0 additions & 182 deletions pandas/tests/extension/numpy_/test_numpy.py

This file was deleted.

Loading