This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch branch-3.2
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.2 by this push:
new a0d2be5 [SPARK-38297][PYTHON] Explicitly cast the return value at
DataFrame.to_numpy in POS
a0d2be5 is described below
commit a0d2be565486367abd6b637c98634c35420994ce
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Wed Feb 23 14:12:39 2022 +0900
[SPARK-38297][PYTHON] Explicitly cast the return value at
DataFrame.to_numpy in POS
MyPy build currently fails as below:
```
starting mypy annotations test...
annotations failed mypy checks:
python/pyspark/pandas/generic.py:585: error: Incompatible return value type
(got "Union[ndarray[Any, Any], ExtensionArray]", expected "ndarray[Any, Any]")
[return-value]
Found 1 error in 1 file (checked 324 source files)
1
```
https://github.com/apache/spark/runs/5298261168?check_suite_focus=true
I tried to reproduce in my local by matching NumPy and MyPy versions but
failed. So I decided to work around the problem first by explicitly casting to
make MyPy happy.
To make the build pass.
No, dev-only.
CI in this PR should verify if it's fixed.
Closes #35617 from HyukjinKwon/SPARK-38297.
Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
(cherry picked from commit b46b74ce0521d1d5e7c09cadad0e9639e31214cb)
Signed-off-by: Hyukjin Kwon <[email protected]>
---
python/pyspark/pandas/generic.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/python/pyspark/pandas/generic.py b/python/pyspark/pandas/generic.py
index cdd8f67..c26b516 100644
--- a/python/pyspark/pandas/generic.py
+++ b/python/pyspark/pandas/generic.py
@@ -573,7 +573,7 @@ class Frame(object, metaclass=ABCMeta):
>>> ps.Series(['a', 'b', 'a']).to_numpy()
array(['a', 'b', 'a'], dtype=object)
"""
- return self.to_pandas().values
+ return cast(np.ndarray, self._to_pandas().values)
@property
def values(self) -> np.ndarray:
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]