You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2021/11/09 01:33:00 UTC

[spark] branch master updated: [SPARK-37235][PYTHON] Inline type hints for python/pyspark/mllib/stat/distribution.py and __init__.py

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

gurwls223 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 bde1bd4  [SPARK-37235][PYTHON] Inline type hints for python/pyspark/mllib/stat/distribution.py and __init__.py
bde1bd4 is described below

commit bde1bd4fdc4c75a81bcbffeccaf0c7c5f6e2822b
Author: dch nguyen <dg...@viettel.com.vn>
AuthorDate: Tue Nov 9 10:32:04 2021 +0900

    [SPARK-37235][PYTHON] Inline type hints for python/pyspark/mllib/stat/distribution.py and __init__.py
    
    ### What changes were proposed in this pull request?
    Inline type hints for python/pyspark/mllib/stat/distribution.py and __init__.py
    
    ### Why are the changes needed?
    We can take advantage of static type checking within the functions by inlining the type hints.
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    Existing Tests
    
    Closes #34515 from dchvn/SPARK-37235.
    
    Authored-by: dch nguyen <dg...@viettel.com.vn>
    Signed-off-by: Hyukjin Kwon <gu...@apache.org>
---
 python/pyspark/mllib/stat/__init__.pyi     | 29 -----------------------------
 python/pyspark/mllib/stat/distribution.py  | 10 +++++++---
 python/pyspark/mllib/stat/distribution.pyi | 25 -------------------------
 3 files changed, 7 insertions(+), 57 deletions(-)

diff --git a/python/pyspark/mllib/stat/__init__.pyi b/python/pyspark/mllib/stat/__init__.pyi
deleted file mode 100644
index bdd080a..0000000
--- a/python/pyspark/mllib/stat/__init__.pyi
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-from pyspark.mllib.stat.KernelDensity import (  # noqa: F401
-    KernelDensity as KernelDensity,
-)
-from pyspark.mllib.stat._statistics import (  # noqa: F401
-    MultivariateStatisticalSummary as MultivariateStatisticalSummary,
-    Statistics as Statistics,
-)
-from pyspark.mllib.stat.distribution import (  # noqa: F401
-    MultivariateGaussian as MultivariateGaussian,
-)
-from pyspark.mllib.stat.test import ChiSqTestResult as ChiSqTestResult  # noqa: F401
diff --git a/python/pyspark/mllib/stat/distribution.py b/python/pyspark/mllib/stat/distribution.py
index aa35ac6..91798fc 100644
--- a/python/pyspark/mllib/stat/distribution.py
+++ b/python/pyspark/mllib/stat/distribution.py
@@ -15,12 +15,14 @@
 # limitations under the License.
 #
 
-from collections import namedtuple
-
 __all__ = ['MultivariateGaussian']
 
+from typing import NamedTuple
+
+from pyspark.mllib.linalg import Matrix, Vector
+
 
-class MultivariateGaussian(namedtuple('MultivariateGaussian', ['mu', 'sigma'])):
+class MultivariateGaussian(NamedTuple):
 
     """Represents a (mu, sigma) tuple
 
@@ -32,3 +34,5 @@ class MultivariateGaussian(namedtuple('MultivariateGaussian', ['mu', 'sigma'])):
     >>> (m[0], m[1])
     (DenseVector([11.0, 12.0]), array([[ 1., 5.],[ 3., 2.]]))
     """
+    mu: Vector
+    sigma: Matrix
diff --git a/python/pyspark/mllib/stat/distribution.pyi b/python/pyspark/mllib/stat/distribution.pyi
deleted file mode 100644
index 8bb93f9..0000000
--- a/python/pyspark/mllib/stat/distribution.pyi
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-from typing import NamedTuple
-
-from pyspark.mllib.linalg import Vector, Matrix
-
-class MultivariateGaussian(NamedTuple):
-    mu: Vector
-    sigma: Matrix

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