Skip to content

Commit 199d68c

Browse files
committed
review comments
1 parent 111ad77 commit 199d68c

File tree

6 files changed

+22
-20
lines changed

6 files changed

+22
-20
lines changed

pandas/core/frame.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import sys
1717
import warnings
1818
from textwrap import dedent
19-
from typing import FrozenSet, List, Optional, Set, Type, Union
19+
from typing import FrozenSet, List, Optional, Tuple, Set, Type, Union
2020

2121
import numpy as np
2222
import numpy.ma as ma
@@ -2644,14 +2644,15 @@ def transpose(self, *args, **kwargs):
26442644
def __array__(self, dtype=None):
26452645
return com.values_from_object(self)
26462646

2647-
def __array_wrap__(self, result: np.ndarray, context=None) -> 'DataFrame':
2647+
def __array_wrap__(self, result: np.ndarray,
2648+
context: Optional[Tuple] = None) -> 'DataFrame':
26482649
"""
26492650
We are called post ufunc; reconstruct the original object and dtypes.
26502651
26512652
Parameters
26522653
----------
26532654
result : np.ndarray
2654-
context
2655+
context : tuple, optional
26552656
26562657
Returns
26572658
-------

pandas/core/series.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from shutil import get_terminal_size
77
from textwrap import dedent
88
import warnings
9+
from typing import Optional, Tuple
910

1011
import numpy as np
1112

@@ -745,20 +746,20 @@ def __array__(self, dtype=None):
745746
dtype = 'M8[ns]'
746747
return np.asarray(self.array, dtype)
747748

748-
def __array_wrap__(self, result: np.ndarray, context=None) -> 'Series':
749+
def __array_wrap__(self, result: np.ndarray,
750+
context: Optional[Tuple] = None) -> 'Series':
749751
"""
750752
We are called post ufunc; reconstruct the original object and dtypes.
751753
752754
Parameters
753755
----------
754756
result : np.ndarray
755-
context
757+
context : tuple, optional
756758
757759
Returns
758760
-------
759761
Series
760762
"""
761-
762763
result = self._constructor(result, index=self.index,
763764
copy=False)
764765

pandas/tests/groupby/test_function.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pandas import (
1313
DataFrame, Index, MultiIndex, Series, Timestamp, date_range, isna)
1414
import pandas.core.nanops as nanops
15-
from pandas.util import testing as tm
15+
from pandas.util import _test_decorators as td, testing as tm
1616

1717

1818
@pytest.mark.parametrize("agg_func", ['any', 'all'])
@@ -461,11 +461,8 @@ def test_groupby_cumprod():
461461

462462

463463
def scipy_sem(*args, **kwargs):
464-
try:
465-
from scipy.stats import sem
466-
return sem(*args, ddof=1, **kwargs)
467-
except ImportError:
468-
pytest.skip("No Scipy installed")
464+
from scipy.stats import sem
465+
return sem(*args, ddof=1, **kwargs)
469466

470467

471468
@pytest.mark.parametrize(
@@ -481,7 +478,7 @@ def scipy_sem(*args, **kwargs):
481478
('first', lambda x: x.iloc[0]),
482479
('last', lambda x: x.iloc[-1]),
483480
('count', np.size),
484-
('sem', scipy_sem)])
481+
pytest.param('sem', scipy_sem, mark=td._skip_if_no_scipy)])
485482
def test_ops_general(op, targop):
486483
df = DataFrame(np.random.randn(1000))
487484
labels = np.random.randint(0, 50, size=1000).astype(float)

pandas/tests/sparse/frame/test_analytics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_quantile_multi():
4242
tm.assert_sp_frame_equal(result, sparse_expected)
4343

4444

45-
@pytest.mark.parametrize('func', [np.exp, np.sqrt], ids=lambda x: x.__name__)
45+
@pytest.mark.parametrize('func', [np.exp, np.sqrt], ids=str)
4646
def test_ufunc(func):
4747
# GH 23743
4848
# assert we preserve the incoming dtype on ufunc operation

pandas/tests/sparse/series/test_analytics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pandas.util import testing as tm
66

77

8-
@pytest.mark.parametrize('func', [np.exp, np.sqrt], ids=lambda x: x.__name__)
8+
@pytest.mark.parametrize('func', [np.exp, np.sqrt], ids=str)
99
def test_ufunc(func):
1010
# GH 23743
1111
# assert we preserve the incoming dtype on ufunc operation

pandas/tests/sparse/test_pivot.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ def test_pivot_table(self):
5454
'median',
5555
'first',
5656
'last'])
57-
def test_pivot_table_multi(self, func):
57+
@pytest.mark.parametrize('dropna', [True, False])
58+
def test_pivot_table_multi(self, func, dropna):
5859

59-
res_sparse = pd.pivot_table(self.sparse, index='A', columns='B',
60-
values=['D', 'E'], aggfunc=func)
61-
res_dense = pd.pivot_table(self.dense, index='A', columns='B',
62-
values=['D', 'E'], aggfunc=func)
60+
res_sparse = pd.pivot_table(
61+
self.sparse, index='A', columns='B',
62+
values=['D', 'E'], aggfunc=func, dropna=dropna)
63+
res_dense = pd.pivot_table(
64+
self.dense, index='A', columns='B',
65+
values=['D', 'E'], aggfunc=func, dropna=dropna)
6366
res_dense = res_dense.apply(lambda x: x.astype("Sparse[float64]"))
6467
tm.assert_frame_equal(res_sparse, res_dense)

0 commit comments

Comments
 (0)