Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6125494
Enable many complex number tests
MichaelTiemannOSC Aug 25, 2023
e7a285a
Update v2.1.0.rst
MichaelTiemannOSC Aug 25, 2023
02719d9
Merge branch 'main' into test_numpy_complex2
MichaelTiemannOSC Aug 29, 2023
f9bfeb9
Fix merge error in test_decimal.py
MichaelTiemannOSC Aug 29, 2023
077213f
Simplify test_fillna_no_op_returns_copy
MichaelTiemannOSC Aug 29, 2023
9fda0ef
Merge remote-tracking branch 'upstream/main' into test_numpy_complex2
MichaelTiemannOSC Sep 8, 2023
d25baa2
changes from review
MichaelTiemannOSC Sep 8, 2023
ad841bf
Merge remote-tracking branch 'upstream/main' into test_numpy_complex2
MichaelTiemannOSC Sep 8, 2023
7535374
Merge branch 'main' into test_numpy_complex2
MichaelTiemannOSC Sep 22, 2023
7ef6052
Use LSP parameter style for request
MichaelTiemannOSC Sep 22, 2023
f1139f5
Merge branch 'main' into test_numpy_complex2
MichaelTiemannOSC Oct 10, 2023
19d3127
Handle complex128 EA in _ensure_data
MichaelTiemannOSC Oct 11, 2023
67e2dbc
Fix mypy pre-commit problems
MichaelTiemannOSC Oct 12, 2023
909ced4
Remove some LSP sigs for _get_expected_exception
MichaelTiemannOSC Oct 13, 2023
48cb330
Merge branch 'main' into test_numpy_complex2
MichaelTiemannOSC Oct 13, 2023
bc96021
Additional `requests` removed; indentation fix
MichaelTiemannOSC Oct 13, 2023
d98e6f0
Merge branch 'main' into test_numpy_complex2
MichaelTiemannOSC Oct 14, 2023
dabaf6f
Keep rval refs alive in StringHashTable._unique
MichaelTiemannOSC Oct 15, 2023
61c9b32
Merge branch 'main' into test_numpy_complex2
MichaelTiemannOSC Nov 4, 2023
6ed24ad
Code review changes
MichaelTiemannOSC Nov 4, 2023
e923878
Fix incomplete removal of `keep_rval_refs`
MichaelTiemannOSC Nov 4, 2023
5efad33
Merge remote-tracking branch 'upstream/main' into test_numpy_complex2
MichaelTiemannOSC Dec 9, 2023
51450c8
Merge branch 'main' into test_numpy_complex2
MichaelTiemannOSC Dec 9, 2023
c31b213
Merge remote-tracking branch 'upstream/main' into test_numpy_complex2
MichaelTiemannOSC Jan 5, 2024
9473130
Update io.py
MichaelTiemannOSC Jan 5, 2024
a86c896
Update test_numpy.py
MichaelTiemannOSC Jan 5, 2024
de56177
Update test_numpy.py
MichaelTiemannOSC Jan 5, 2024
198a16d
Merge branch 'main' into test_numpy_complex2
MichaelTiemannOSC Jan 5, 2024
554a5c3
Update ops.py
MichaelTiemannOSC Jan 6, 2024
6ddb7f7
Update test_decimal.py
MichaelTiemannOSC Jan 6, 2024
c4a17a7
Further simplifications due to upstream
MichaelTiemannOSC Jan 6, 2024
040c98b
Update test_arrow.py
MichaelTiemannOSC Jan 6, 2024
3a58f5a
Update test_arrow.py
MichaelTiemannOSC Jan 6, 2024
29aa747
Update test_arrow.py
MichaelTiemannOSC Jan 6, 2024
5210c8b
setitem exceptions for complex raise ValueError
MichaelTiemannOSC Jan 9, 2024
9f4bea5
Merge branch 'main' into test_numpy_complex2
MichaelTiemannOSC Jan 16, 2024
be1f02b
Merge branch 'main' into test_numpy_complex2
MichaelTiemannOSC Jan 23, 2024
b3edefa
Update _mixins.py
MichaelTiemannOSC Jan 23, 2024
89ea60b
Incorporate feedback
MichaelTiemannOSC Jan 31, 2024
4dc3bea
Merge branch 'main' into test_numpy_complex2
MichaelTiemannOSC Mar 22, 2024
4e273fa
Update test_sparse.py
MichaelTiemannOSC Mar 22, 2024
abfdedb
Merge branch 'main' into test_numpy_complex2
MichaelTiemannOSC Mar 29, 2024
59b50c9
Update algorithms.py
MichaelTiemannOSC Mar 29, 2024
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
Prev Previous commit
Next Next commit
Remove some LSP sigs for _get_expected_exception
Test functions defined in `BaseArithmeticOpsTests` such as `test_arith_series_with_scalar` call `check_opname` which calls `_get_expected_exception`.  Because `TestArithmetic` in `test_numpy.py` overrides `_get_expected_exception` and needs to access the `request` parameter, we need a mechanism to pass `request` down and back up the type hiearchy, which we can do using LSP style parameters `*args` and `**kwargs`.

We could opt to do this consistently across all EA types, but since only `decimal/test_decimal.py` overrides, and because it doesn't actually use the `result` parameter, we instead simply omit `*args, **kwargs` when not needed.

Signed-off-by: Michael Tiemann <[email protected]>
  • Loading branch information
MichaelTiemannOSC committed Oct 13, 2023
commit 909ced4ebc4b1f280fc8d49803daa5d0923c28ea
2 changes: 1 addition & 1 deletion pandas/tests/extension/base/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BaseOpsUtil:
divmod_exc: type[Exception] | None = TypeError

def _get_expected_exception(
self, op_name: str, obj, other, *args, **kwargs
self, op_name: str, obj, other
) -> type[Exception] | None:
# Find the Exception, if any we expect to raise calling
# obj.__op_name__(other)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/extension/decimal/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def data_for_grouping():

class TestDecimalArray(base.ExtensionTests):
def _get_expected_exception(
self, op_name: str, obj, other, *args, **kwargs
self, op_name: str, obj, other
) -> type[Exception] | None:
return None

Expand Down Expand Up @@ -330,7 +330,7 @@ class TestArithmeticOps(base.BaseArithmeticOpsTests):
series_array_exc = None

def _get_expected_exception(
self, op_name: str, obj, other, *args, **kwargs
self, op_name: str, obj, other
) -> type[Exception] | None:
return None

Expand Down
14 changes: 5 additions & 9 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ def _is_temporal_supported(self, opname, pa_dtype):
)

def _get_expected_exception(
self, op_name: str, obj, other, *args, **kwargs
self, op_name: str, obj, other
) -> type[Exception] | None:
if op_name in ("__divmod__", "__rdivmod__"):
return self.divmod_exc
Expand Down Expand Up @@ -1048,9 +1048,7 @@ def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request)
if mark is not None:
request.node.add_marker(mark)

super().test_arith_series_with_scalar(
data, all_arithmetic_operators, request=request
)
super().test_arith_series_with_scalar(data, all_arithmetic_operators)

def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
pa_dtype = data.dtype.pyarrow_dtype
Expand All @@ -1064,9 +1062,7 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
if mark is not None:
request.node.add_marker(mark)

super().test_arith_frame_with_scalar(
data, all_arithmetic_operators, request=request
)
super().test_arith_frame_with_scalar(data, all_arithmetic_operators)

def test_arith_series_with_array(self, data, all_arithmetic_operators, request):
pa_dtype = data.dtype.pyarrow_dtype
Expand Down Expand Up @@ -1100,7 +1096,7 @@ def test_arith_series_with_array(self, data, all_arithmetic_operators, request):
# since ser.iloc[0] is a python scalar
other = pd.Series(pd.array([ser.iloc[0]] * len(ser), dtype=data.dtype))

self.check_opname(ser, op_name, other, request=request)
self.check_opname(ser, op_name, other)

def test_add_series_with_extension_array(self, data, request):
pa_dtype = data.dtype.pyarrow_dtype
Expand All @@ -1112,7 +1108,7 @@ def test_add_series_with_extension_array(self, data, request):
reason=f"raises on overflow for {pa_dtype}",
)
)
super().test_add_series_with_extension_array(data, request=request)
super().test_add_series_with_extension_array(data)

def test_invalid_other_comp(self, data, comparison_op):
# GH 48833
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/extension/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ def cmp(a, b):

# ----------------------------------------------------------------------------
class TestDatetimeArray(base.ExtensionTests):
def _get_expected_exception(self, op_name, obj, other, *args, **kwargs):
def _get_expected_exception(self, op_name, obj, other):
if op_name in ["__sub__", "__rsub__"]:
return None
return super()._get_expected_exception(op_name, obj, other, *args, **kwargs)
return super()._get_expected_exception(op_name, obj, other)

def _supports_accumulation(self, ser, op_name: str) -> bool:
return op_name in ["cummin", "cummax"]
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/extension/test_masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def data_for_grouping(dtype):


class TestMaskedArrays(base.ExtensionTests):
def _get_expected_exception(self, op_name, obj, other, *args, **kwargs):
def _get_expected_exception(self, op_name, obj, other):
try:
dtype = tm.get_dtype(obj)
except AttributeError:
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/extension/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def data_for_grouping(dtype):


class TestPeriodArray(base.ExtensionTests):
def _get_expected_exception(self, op_name, obj, other, *args, **kwargs):
def _get_expected_exception(self, op_name, obj, other):
if op_name in ("__sub__", "__rsub__"):
return None
return super()._get_expected_exception(op_name, obj, other, *args, **kwargs)
return super()._get_expected_exception(op_name, obj, other)

def _supports_accumulation(self, ser, op_name: str) -> bool:
return op_name in ["cummin", "cummax"]
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/extension/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,11 @@ def _skip_if_different_combine(self, data):

def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
self._skip_if_different_combine(data)
super().test_arith_series_with_scalar(data, all_arithmetic_operators, request)
super().test_arith_series_with_scalar(data, all_arithmetic_operators)

def test_arith_series_with_array(self, data, all_arithmetic_operators, request):
self._skip_if_different_combine(data)
super().test_arith_series_with_array(data, all_arithmetic_operators, request)
super().test_arith_series_with_array(data, all_arithmetic_operators)

def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
if data.dtype.fill_value != 0:
Expand All @@ -403,7 +403,7 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
]:
mark = pytest.mark.xfail(reason="result dtype.fill_value mismatch")
request.node.add_marker(mark)
super().test_arith_frame_with_scalar(data, all_arithmetic_operators, request)
super().test_arith_frame_with_scalar(data, all_arithmetic_operators)


class TestComparisonOps(BaseSparseTests):
Expand Down