Skip to content

Commit 561e960

Browse files
committed
review comments
1 parent d1490a2 commit 561e960

File tree

6 files changed

+22
-20
lines changed

6 files changed

+22
-20
lines changed

pandas/core/frame.py

Lines changed: 4 additions & 3 deletions
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
@@ -2651,14 +2651,15 @@ def transpose(self, *args, **kwargs):
26512651
def __array__(self, dtype=None):
26522652
return com.values_from_object(self)
26532653

2654-
def __array_wrap__(self, result: np.ndarray, context=None) -> 'DataFrame':
2654+
def __array_wrap__(self, result: np.ndarray,
2655+
context: Optional[Tuple] = None) -> 'DataFrame':
26552656
"""
26562657
We are called post ufunc; reconstruct the original object and dtypes.
26572658
26582659
Parameters
26592660
----------
26602661
result : np.ndarray
2661-
context
2662+
context : tuple, optional
26622663
26632664
Returns
26642665
-------

pandas/core/series.py

Lines changed: 4 additions & 3 deletions
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

@@ -762,20 +763,20 @@ def __array__(self, dtype=None):
762763
dtype = 'M8[ns]'
763764
return np.asarray(self.array, dtype)
764765

765-
def __array_wrap__(self, result: np.ndarray, context=None) -> 'Series':
766+
def __array_wrap__(self, result: np.ndarray,
767+
context: Optional[Tuple] = None) -> 'Series':
766768
"""
767769
We are called post ufunc; reconstruct the original object and dtypes.
768770
769771
Parameters
770772
----------
771773
result : np.ndarray
772-
context
774+
context : tuple, optional
773775
774776
Returns
775777
-------
776778
Series
777779
"""
778-
779780
result = self._constructor(result, index=self.index,
780781
copy=False)
781782

pandas/tests/groupby/test_function.py

Lines changed: 4 additions & 7 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ def test_pivot_table(self):
5656
'median',
5757
'first',
5858
'last'])
59-
def test_pivot_table_multi(self, func):
59+
@pytest.mark.parametrize('dropna', [True, False])
60+
def test_pivot_table_multi(self, func, dropna):
6061

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

0 commit comments

Comments
 (0)