This is an automated email from the ASF dual-hosted git repository.

dongjoon 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 49f215a  [SPARK-38082][PYTHON] Update minimum numpy version to 1.15
49f215a is described below

commit 49f215a5ae64a50e889ae5cf94421cdeb0eacf09
Author: zero323 <mszymkiew...@gmail.com>
AuthorDate: Fri Feb 4 20:05:35 2022 -0800

    [SPARK-38082][PYTHON] Update minimum numpy version to 1.15
    
    ### What changes were proposed in this pull request?
    
    This PR changes minimum required numpy version to 1.15.
    
    Additionally, it replaces calls to deprecated `tostring` method.
    
    ### Why are the changes needed?
    
    Current lower bound is ancient and no longer supported by the rest our 
dependencies.
    
    Additionally, supporting it, requires usage of long deprecated methods 
creating unnecessary gaps in our type checker coverage.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing tests.
    
    Closes #35398 from zero323/SPARK-38082.
    
    Authored-by: zero323 <mszymkiew...@gmail.com>
    Signed-off-by: Dongjoon Hyun <dongj...@apache.org>
---
 python/pyspark/ml/linalg/__init__.py    | 12 ++++++------
 python/pyspark/mllib/linalg/__init__.py | 14 +++++++-------
 python/setup.py                         |  6 +++---
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/python/pyspark/ml/linalg/__init__.py 
b/python/pyspark/ml/linalg/__init__.py
index b361925..03e63e9 100644
--- a/python/pyspark/ml/linalg/__init__.py
+++ b/python/pyspark/ml/linalg/__init__.py
@@ -303,7 +303,7 @@ class DenseVector(Vector):
         self.array = ar
 
     def __reduce__(self):
-        return DenseVector, (self.array.tostring(),)
+        return DenseVector, (self.array.tobytes(),)
 
     def numNonzeros(self):
         """
@@ -591,7 +591,7 @@ class SparseVector(Vector):
         return np.linalg.norm(self.values, p)
 
     def __reduce__(self):
-        return (SparseVector, (self.size, self.indices.tostring(), 
self.values.tostring()))
+        return (SparseVector, (self.size, self.indices.tobytes(), 
self.values.tobytes()))
 
     def dot(self, other):
         """
@@ -949,7 +949,7 @@ class DenseMatrix(Matrix):
         return DenseMatrix, (
             self.numRows,
             self.numCols,
-            self.values.tostring(),
+            self.values.tobytes(),
             int(self.isTransposed),
         )
 
@@ -1160,9 +1160,9 @@ class SparseMatrix(Matrix):
         return SparseMatrix, (
             self.numRows,
             self.numCols,
-            self.colPtrs.tostring(),
-            self.rowIndices.tostring(),
-            self.values.tostring(),
+            self.colPtrs.tobytes(),
+            self.rowIndices.tobytes(),
+            self.values.tobytes(),
             int(self.isTransposed),
         )
 
diff --git a/python/pyspark/mllib/linalg/__init__.py 
b/python/pyspark/mllib/linalg/__init__.py
index 30fa84c..b9c391e 100644
--- a/python/pyspark/mllib/linalg/__init__.py
+++ b/python/pyspark/mllib/linalg/__init__.py
@@ -390,7 +390,7 @@ class DenseVector(Vector):
         return DenseVector(values)
 
     def __reduce__(self) -> Tuple[Type["DenseVector"], Tuple[bytes]]:
-        return DenseVector, (self.array.tostring(),)  # type: 
ignore[attr-defined]
+        return DenseVector, (self.array.tobytes(),)
 
     def numNonzeros(self) -> int:
         """
@@ -712,8 +712,8 @@ class SparseVector(Vector):
             SparseVector,
             (
                 self.size,
-                self.indices.tostring(),  # type: ignore[attr-defined]
-                self.values.tostring(),  # type: ignore[attr-defined]
+                self.indices.tobytes(),
+                self.values.tobytes(),
             ),
         )
 
@@ -1256,7 +1256,7 @@ class DenseMatrix(Matrix):
         return DenseMatrix, (
             self.numRows,
             self.numCols,
-            self.values.tostring(),  # type: ignore[attr-defined]
+            self.values.tobytes(),
             int(self.isTransposed),
         )
 
@@ -1489,9 +1489,9 @@ class SparseMatrix(Matrix):
         return SparseMatrix, (
             self.numRows,
             self.numCols,
-            self.colPtrs.tostring(),  # type: ignore[attr-defined]
-            self.rowIndices.tostring(),  # type: ignore[attr-defined]
-            self.values.tostring(),  # type: ignore[attr-defined]
+            self.colPtrs.tobytes(),
+            self.rowIndices.tobytes(),
+            self.values.tobytes(),
             int(self.isTransposed),
         )
 
diff --git a/python/setup.py b/python/setup.py
index 4ff495c..673b146 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -260,8 +260,8 @@ try:
         # if you're updating the versions or dependencies.
         install_requires=['py4j==0.10.9.3'],
         extras_require={
-            'ml': ['numpy>=1.7'],
-            'mllib': ['numpy>=1.7'],
+            'ml': ['numpy>=1.15'],
+            'mllib': ['numpy>=1.15'],
             'sql': [
                 'pandas>=%s' % _minimum_pandas_version,
                 'pyarrow>=%s' % _minimum_pyarrow_version,
@@ -269,7 +269,7 @@ try:
             'pandas_on_spark': [
                 'pandas>=%s' % _minimum_pandas_version,
                 'pyarrow>=%s' % _minimum_pyarrow_version,
-                'numpy>=1.14',
+                'numpy>=1.15',
             ],
         },
         python_requires='>=3.7',

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to