Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4188e9f
ENH: Implement EA unary ops
sinhrks Oct 24, 2018
6e5cf3d
Fixed test for older NumPy ver
sinhrks Jan 15, 2019
3b3003f
Fixed tests for latest numpy
sinhrks Jan 15, 2019
e0b37ae
updated doc
sinhrks Jan 15, 2019
6476d0d
Additional fixes
sinhrks Jan 17, 2019
528e4d1
Remove unary method from DatetimeArray
sinhrks Jan 22, 2019
dbdce23
move __pos__ logic to ExtensionArray
sinhrks Jan 23, 2019
af84599
Merge remote-tracking branch 'upstream/master' into unary
WillAyd Jun 8, 2019
b0975f4
Reverted bad merge of 24 whatsnew
WillAyd Jun 8, 2019
8e3638c
Removed Panel-specific code
WillAyd Jun 8, 2019
63430e7
Added stdlib operator import
WillAyd Jun 10, 2019
9fe6085
Merge remote-tracking branch 'upstream/master' into unary
WillAyd Jun 10, 2019
b6430f1
Removed old np13 check
WillAyd Jun 10, 2019
736fc27
Fixed wrong error msg expectation
WillAyd Jun 10, 2019
87b8cab
lint fixup
WillAyd Jun 10, 2019
c6437ba
Merge remote-tracking branch 'upstream/master' into unary
WillAyd Jun 11, 2019
91a7fec
Added warnings catch for operator pos
WillAyd Jun 11, 2019
b221fd0
lint fixup
WillAyd Jun 11, 2019
0afef3c
Reverted warnings catch
WillAyd Jun 11, 2019
4c322b6
Reimplemented warnings catch for np dev
WillAyd Jun 11, 2019
2b480be
test fixup
WillAyd Jun 11, 2019
ad62830
Used OrderedDict for py35 compat
WillAyd Jun 11, 2019
0d6e0c5
Changed to tm.assert_produces_warning
WillAyd Jun 11, 2019
4f6d656
Merge remote-tracking branch 'upstream/master' into unary
WillAyd Jun 30, 2019
536d002
Fixed bad imports
WillAyd Jun 30, 2019
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed tests for latest numpy
  • Loading branch information
sinhrks committed Jan 21, 2019
commit 3b3003fd849a34fed91bddda4a776ab9511666b7
1 change: 1 addition & 0 deletions pandas/compat/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +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':
Expand Down
9 changes: 5 additions & 4 deletions pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
construct_1d_object_array_from_listlike, find_common_type,
maybe_upcast_putmask)
from pandas.core.dtypes.common import (
ensure_object, is_bool_dtype, is_categorical_dtype, is_datetime64_dtype,
is_datetime64_any_dtype, is_datetime64tz_dtype, is_datetimelike_v_numeric,
is_extension_array_dtype, is_integer_dtype, is_list_like, is_object_dtype,
is_period_dtype, is_scalar, is_timedelta64_dtype, needs_i8_conversion)
ensure_object, is_bool_dtype, is_categorical_dtype,
is_datetime64_any_dtype, is_datetime64_dtype, is_datetime64tz_dtype,
is_datetimelike_v_numeric, is_extension_array_dtype, is_integer_dtype,
is_list_like, is_object_dtype, is_period_dtype, is_scalar,
is_timedelta64_dtype, needs_i8_conversion)
from pandas.core.dtypes.generic import (
ABCDataFrame, ABCIndex, ABCIndexClass, ABCPanel, ABCSeries, ABCSparseArray,
ABCSparseSeries)
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/frame/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,9 @@ def test_timedelta_mixed_inv_raise(self, typ, op):
df = df.astype({'a': typ, 'b': typ})
pytest.raises(TypeError, op, df)

@pytest.mark.skipif(not pd.compat.numpy._np_version_under1p16,
reason='NumPy 1.6 or later shows warning when op '
'performed against non-numeric dtype')
@pytest.mark.parametrize('typ', ['Int64', 'Int32', 'Int16', 'Int8'])
@pytest.mark.parametrize('op', [operator.pos])
def test_object_mixed(self, typ, op):
Expand Down
13 changes: 12 additions & 1 deletion pandas/tests/frame/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,21 @@ def test_invert(self):

@pytest.mark.parametrize('df', [
pd.DataFrame({'a': [-1, 1]}),
pd.DataFrame({'a': [0.0, 1.1]}),
])
def test_pos_numeric(self, df):
# GH#16073
assert_frame_equal(+df, df)
assert_series_equal(+df['a'], df['a'])

@pytest.mark.skipif(not pd.compat.numpy._np_version_under1p16,
reason='NumPy 1.6 or later shows warning when op '
'performed against non-numeric dtype')
@pytest.mark.parametrize('df', [
pd.DataFrame({'a': [False, True]}),
pd.DataFrame({'a': pd.Series(pd.to_timedelta([-1, 1]))}),
])
def test_pos_numeric(self, df):
def test_pos_non_numeric(self, df):
# GH#16073
assert_frame_equal(+df, df)
assert_series_equal(+df['a'], df['a'])
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/series/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ def test_float_inv_raise(self, float_dtype, op):
# consistent with numpy
pytest.raises(TypeError, op, ser.values)

@pytest.mark.skipif(not pd.compat.numpy._np_version_under1p16,
reason='NumPy 1.6 or later shows warning when op '
'performed against non-numeric dtype')
@pytest.mark.parametrize('typ', ['bool'])
@pytest.mark.parametrize('op', [operator.pos, operator.neg,
operator.inv, operator.abs])
Expand All @@ -245,6 +248,9 @@ def test_bool(self, typ, op):
exp = Series(op(ser.values), index=ser.index)
tm.assert_series_equal(result, exp)

@pytest.mark.skipif(not pd.compat.numpy._np_version_under1p16,
reason='NumPy 1.6 or later shows warning when op '
'performed against non-numeric dtype')
@pytest.mark.parametrize('typ', ['datetime64[ns]', 'datetime64[ns, GMT]',
'datetime64[ns, US/Eastern]'])
@pytest.mark.parametrize('op', [operator.pos])
Expand Down Expand Up @@ -290,6 +296,9 @@ def test_timedelta_inv_raise(self, typ, op):
# consistent with numpy
pytest.raises(TypeError, op, ser.values)

@pytest.mark.skipif(not pd.compat.numpy._np_version_under1p16,
reason='NumPy 1.6 or later shows warning when op '
'performed against non-numeric dtype')
@pytest.mark.parametrize('typ', ['str', 'object'])
@pytest.mark.parametrize('op', [operator.pos])
def test_object(self, typ, op):
Expand Down