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
Merge remote-tracking branch 'upstream/main' into test_numpy_complex2
  • Loading branch information
MichaelTiemannOSC committed Jan 5, 2024
commit c31b21307d5b6730c868ccd74669c6c1702ff1b7
7 changes: 3 additions & 4 deletions pandas/tests/arithmetic/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,11 +1116,10 @@ def test_ufunc_compat(self, holder, dtype):
tm.assert_equal(result, expected)

# TODO: add more dtypes
@pytest.mark.parametrize("holder", [Index, Series])
@pytest.mark.parametrize("dtype", [np.int64, np.uint64, np.float64, np.complex128])
def test_ufunc_coercions(self, holder, dtype):
idx = holder([1, 2, 3, 4, 5], dtype=dtype, name="x")
box = Series if holder is Series else Index
def test_ufunc_coercions(self, index_or_series, dtype):
idx = index_or_series([1, 2, 3, 4, 5], dtype=dtype, name="x")
box = index_or_series

result = np.sqrt(idx)
if result.dtype.kind == "c":
Copy link
Member

Choose a reason for hiding this comment

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

@jbrockmendel is there something in our type conversion / introspection functions that lets us cast to the nearest inexact data type? If not that might be something we want to do here or in a follow up PR to better handle this

Copy link
Member

Choose a reason for hiding this comment

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

that lets us cast to the nearest inexact data type

I don't think so, no. i expected maybe_promote to do that, but looks like it always gives float64

Expand Down
20 changes: 20 additions & 0 deletions pandas/tests/extension/base/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ def test_EA_types(self, engine, data, request):
reason=f"engine '{engine}' cannot parse the dtype {data.dtype.name}"
)
)
if isinstance(data.dtype, pd.CategoricalDtype):
# in parsers.pyx _convert_with_dtype there is special-casing for
# Categorical that pre-empts _from_sequence_of_strings
pass
elif isinstance(data.dtype, pd.core.dtypes.dtypes.NumpyEADtype):
# These get unwrapped internally so are treated as numpy dtypes
# in the parsers.pyx code
pass
elif (
type(data)._from_sequence_of_strings.__func__
is ExtensionArray._from_sequence_of_strings.__func__
):
# i.e. the EA hasn't overridden _from_sequence_of_strings
mark = pytest.mark.xfail(
reason="_from_sequence_of_strings not implemented",
raises=NotImplementedError,
)
request.node.add_marker(mark)

>>>>>>> upstream/main
df = pd.DataFrame({"with_dtype": pd.Series(data, dtype=str(data.dtype))})
csv_output = df.to_csv(index=False, na_rep=np.nan)
result = pd.read_csv(
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/extension/decimal/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ def test_fillna_copy_series(self, data_missing, using_copy_on_write):
with tm.assert_produces_warning(warn, match=msg, check_stacklevel=False):
super().test_fillna_copy_series(data_missing)

@pytest.mark.parametrize("dropna", [True, False])
def test_value_counts(self, all_data, dropna):
all_data = all_data[:10]
if dropna:
Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/extension/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ def test_map(self, data, na_action):
result = data.map(lambda x: x, na_action=na_action)
tm.assert_extension_array_equal(result, data)

@pytest.mark.parametrize("engine", ["c", "python"])
def test_EA_types(self, engine, data, request):
expected_msg = r".*must implement _from_sequence_of_strings.*"
with pytest.raises(NotImplementedError, match=expected_msg):
super().test_EA_types(engine, data, request)

def check_reduce(self, ser: pd.Series, op_name: str, skipna: bool):
if op_name in ["median", "mean", "std"]:
alt = ser.astype("int64")
Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/extension/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool:
def test_fillna_length_mismatch(self, data_missing):
super().test_fillna_length_mismatch(data_missing)

@pytest.mark.parametrize("engine", ["c", "python"])
def test_EA_types(self, engine, data, request):
expected_msg = r".*must implement _from_sequence_of_strings.*"
with pytest.raises(NotImplementedError, match=expected_msg):
super().test_EA_types(engine, data, request)


# TODO: either belongs in tests.arrays.interval or move into base tests.
def test_fillna_non_scalar_raises(data_missing):
Expand Down
68 changes: 40 additions & 28 deletions pandas/tests/extension/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,36 +286,54 @@ def _get_expected_exception(
return TypeError
return super()._get_expected_exception(op_name, obj, other)

@skip_nested
def test_divmod(self, data):
divmod_exc = None
if data.dtype.kind == "O":
divmod_exc = TypeError
self.divmod_exc = divmod_exc
super().test_divmod(data)

def test_divmod_series_array(self, data):
ser = pd.Series(data)
exc = None
if data.dtype.kind == "O":
exc = TypeError
self.divmod_exc = exc
self._check_divmod_op(ser, divmod, data)

def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
super().test_arith_series_with_scalar(
data, all_arithmetic_operators, request=request
)
opname = all_arithmetic_operators
series_scalar_exc = None
if data.dtype.numpy_dtype == object:
if opname in ["__mul__", "__rmul__"]:
mark = pytest.mark.xfail(
reason="the Series.combine step raises but not the Series method."
)
request.node.add_marker(mark)
series_scalar_exc = TypeError
self.series_scalar_exc = series_scalar_exc
super().test_arith_series_with_scalar(data, all_arithmetic_operators)

def test_arith_series_with_array(self, data, all_arithmetic_operators):
opname = all_arithmetic_operators
series_array_exc = None
if data.dtype.numpy_dtype == object and opname not in ["__add__", "__radd__"]:
mark = pytest.mark.xfail(reason="Fails for object dtype")
# TODO: check that we shouldn't use applymarker here instead
request.node.add_marker(mark)
# TODO: check that the request=request parameter is needed
super().test_arith_series_with_array(
data, all_arithmetic_operators, request=request
)
series_array_exc = TypeError
self.series_array_exc = series_array_exc
super().test_arith_series_with_array(data, all_arithmetic_operators)

@skip_nested
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
super().test_arith_frame_with_scalar(
data, all_arithmetic_operators, request=request
)

@skip_nested
def test_divmod(self, data, request):
super().test_divmod(data, request=request)

def test_divmod_series_array(self, data, data_for_twos, request):
super().test_divmod_series_array(data, data_for_twos, request=request)
opname = all_arithmetic_operators
frame_scalar_exc = None
if data.dtype.numpy_dtype == object:
if opname in ["__mul__", "__rmul__"]:
mark = pytest.mark.xfail(
reason="the Series.combine step raises but not the Series method."
)
request.node.add_marker(mark)
frame_scalar_exc = TypeError
self.frame_scalar_exc = frame_scalar_exc
super().test_arith_frame_with_scalar(data, all_arithmetic_operators)

def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool:
if ser.dtype.kind == "O":
Expand Down Expand Up @@ -363,12 +381,6 @@ def test_fillna_no_op_returns_copy(self, data, request):
)
super().test_fillna_no_op_returns_copy(data)


class TestReshaping(BaseNumPyTests, base.BaseReshapingTests):
pass


class TestSetitem(BaseNumPyTests, base.BaseSetitemTests):
@skip_nested
def test_setitem_invalid(self, data, invalid_scalar):
# object dtype can hold anything, so doesn't raise
Expand Down
10 changes: 3 additions & 7 deletions pandas/tests/extension/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,9 @@ def test_sparse_array(self, data_for_compare: SparseArray, comparison_op, reques
def test_array_repr(self, data, size):
super().test_array_repr(data, size)


class TestParsing(BaseSparseTests, base.BaseParsingTests):
@pytest.mark.parametrize("engine", ["c", "python"])
def test_EA_types(self, engine, data, request):
expected_msg = r".*must implement _from_sequence_of_strings.*"
with pytest.raises(NotImplementedError, match=expected_msg):
super().test_EA_types(engine, data, request)
@pytest.mark.xfail(reason="result does not match expected")
def test_groupby_extension_agg(self, as_index, data_for_grouping):
super().test_groupby_extension_agg(as_index, data_for_grouping)


def test_array_type_with_arg(dtype):
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.