This is an automated email from the ASF dual-hosted git repository.
gaogaotiantian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 77dd98babc7e [SPARK-60160][PS][TEST] Improve test coverage of
complex_ops in pandas API
77dd98babc7e is described below
commit 77dd98babc7e105f61fb6972a70b397ddaa0747d
Author: Zhen-Lun (Kevin) Hong <[email protected]>
AuthorDate: Mon Nov 9 14:56:39 2026 -0800
[SPARK-60160][PS][TEST] Improve test coverage of complex_ops in pandas API
### What changes were proposed in this pull request?
This PR improves the test coverage for complex_ops.
### Why are the changes needed?
The existing tests incorrectly compared pandas DataFrames against
themselves, resulting in low test coverage for complex_ops.
This PR fixes these comparisons and adds some minor updates to the
TypeError and class pretty_name tests.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
The changes are limited to existing tests, which have been updated and
verified with the following command
```
python/run-tests --python-executables=python --testnames
"pyspark.pandas.tests.data_type_ops.test_complex_ops,pyspark.pandas.tests.connect.data_type_ops.test_parity_complex_ops"
```
| | Stmts | Miss | Cover |
|---|---|---|---|
| Before | 71 | 30 | 58% |
| After | 71 | 5 | 93% |
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code Opus 5.5
Closes #59373 from kevinhongzl/SPARK-60160-test-complex-ops-coverage.
Authored-by: Zhen-Lun (Kevin) Hong <[email protected]>
Signed-off-by: Tian Gao <[email protected]>
skip-checks: true
---
.../pandas/tests/data_type_ops/test_complex_ops.py | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/python/pyspark/pandas/tests/data_type_ops/test_complex_ops.py
b/python/pyspark/pandas/tests/data_type_ops/test_complex_ops.py
index 84369afe6f17..d4130bef07b6 100644
--- a/python/pyspark/pandas/tests/data_type_ops/test_complex_ops.py
+++ b/python/pyspark/pandas/tests/data_type_ops/test_complex_ops.py
@@ -100,7 +100,7 @@ class ComplexOpsTestsMixin:
"this_struct": ps.Index([("x",
1)]).to_series().reset_index(drop=True),
"that_struct": ps.Index([("a",
2)]).to_series().reset_index(drop=True),
}
- return ps.concat(pssers, axis=1)
+ return ps.concat([psser.rename(name) for name, psser in
pssers.items()], axis=1)
def test_add(self):
pdf, psdf = self.array_pdf, self.array_psdf
@@ -141,6 +141,11 @@ class ComplexOpsTestsMixin:
for non_numeric_col in self.non_numeric_array_df_cols:
self.assertRaises(TypeError, lambda: psdf[numeric_col] +
psdf[non_numeric_col])
+ # Array + non-array
+ self.assertRaises(TypeError, lambda: self.psser + 1)
+ psdf = ps.DataFrame({"array": [[1, 2]], "int": [1]})
+ self.assertRaises(TypeError, lambda: psdf["array"] + psdf["int"])
+
def test_sub(self):
self.assertRaises(TypeError, lambda: self.psser - "x")
self.assertRaises(TypeError, lambda: self.psser - 1)
@@ -266,7 +271,7 @@ class ComplexOpsTestsMixin:
self.assertRaises(TypeError, lambda: ~self.psser)
def test_eq(self):
- pdf, psdf = self.complex_pdf, self.complex_pdf
+ pdf, psdf = self.complex_pdf, self.complex_psdf
self.assert_eq(
pdf["this_array"] == pdf["that_array"], psdf["this_array"] ==
psdf["that_array"]
)
@@ -281,7 +286,7 @@ class ComplexOpsTestsMixin:
)
def test_ne(self):
- pdf, psdf = self.complex_pdf, self.complex_pdf
+ pdf, psdf = self.complex_pdf, self.complex_psdf
self.assert_eq(
pdf["this_array"] != pdf["that_array"], psdf["this_array"] !=
psdf["that_array"]
)
@@ -296,7 +301,7 @@ class ComplexOpsTestsMixin:
)
def test_lt(self):
- pdf, psdf = self.complex_pdf, self.complex_pdf
+ pdf, psdf = self.complex_pdf, self.complex_psdf
self.assert_eq(
pdf["this_array"] < pdf["that_array"], psdf["this_array"] <
psdf["that_array"]
)
@@ -311,7 +316,7 @@ class ComplexOpsTestsMixin:
)
def test_le(self):
- pdf, psdf = self.complex_pdf, self.complex_pdf
+ pdf, psdf = self.complex_pdf, self.complex_psdf
self.assert_eq(
pdf["this_array"] <= pdf["that_array"], psdf["this_array"] <=
psdf["that_array"]
)
@@ -326,7 +331,7 @@ class ComplexOpsTestsMixin:
)
def test_gt(self):
- pdf, psdf = self.complex_pdf, self.complex_pdf
+ pdf, psdf = self.complex_pdf, self.complex_psdf
self.assert_eq(
pdf["this_array"] > pdf["that_array"], psdf["this_array"] >
psdf["that_array"]
)
@@ -341,7 +346,7 @@ class ComplexOpsTestsMixin:
)
def test_ge(self):
- pdf, psdf = self.complex_pdf, self.complex_pdf
+ pdf, psdf = self.complex_pdf, self.complex_psdf
self.assert_eq(
pdf["this_array"] >= pdf["that_array"], psdf["this_array"] >=
psdf["that_array"]
)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]