aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/mllib/feature.py
diff options
context:
space:
mode:
authorDavies Liu <davies@databricks.com>2014-11-13 10:24:54 -0800
committerXiangrui Meng <meng@databricks.com>2014-11-13 10:24:54 -0800
commitce0333f9a008348692bb9a200449d2d992e7825e (patch)
tree03a42efe832281f0cb668d460a53153cd4bbc99b /python/pyspark/mllib/feature.py
parent484fecbf1402c25f310be0b0a5ec15c11cbd65c3 (diff)
downloadspark-ce0333f9a008348692bb9a200449d2d992e7825e.tar.gz
spark-ce0333f9a008348692bb9a200449d2d992e7825e.tar.bz2
spark-ce0333f9a008348692bb9a200449d2d992e7825e.zip
[SPARK-4348] [PySpark] [MLlib] rename random.py to rand.py
This PR rename random.py to rand.py to avoid the side affects of conflict with random module, but still keep the same interface as before. ``` >>> from pyspark.mllib.random import RandomRDDs ``` ``` $ pydoc pyspark.mllib.random Help on module random in pyspark.mllib: NAME random - Python package for random data generation. FILE /Users/davies/work/spark/python/pyspark/mllib/rand.py CLASSES __builtin__.object pyspark.mllib.random.RandomRDDs class RandomRDDs(__builtin__.object) | Generator methods for creating RDDs comprised of i.i.d samples from | some distribution. | | Static methods defined here: | | normalRDD(sc, size, numPartitions=None, seed=None) ``` cc mengxr reference link: http://xion.org.pl/2012/05/06/hacking-python-imports/ Author: Davies Liu <davies@databricks.com> Closes #3216 from davies/random and squashes the following commits: 7ac4e8b [Davies Liu] rename random.py to rand.py
Diffstat (limited to 'python/pyspark/mllib/feature.py')
-rw-r--r--python/pyspark/mllib/feature.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/python/pyspark/mllib/feature.py b/python/pyspark/mllib/feature.py
index 9ec28079ae..8cb992df2d 100644
--- a/python/pyspark/mllib/feature.py
+++ b/python/pyspark/mllib/feature.py
@@ -18,8 +18,11 @@
"""
Python package for feature in MLlib.
"""
+from __future__ import absolute_import
+
import sys
import warnings
+import random
from py4j.protocol import Py4JJavaError
@@ -341,8 +344,6 @@ class Word2Vec(object):
"""
Construct Word2Vec instance
"""
- import random # this can't be on the top because of mllib.random
-
self.vectorSize = 100
self.learningRate = 0.025
self.numPartitions = 1
@@ -411,8 +412,5 @@ def _test():
exit(-1)
if __name__ == "__main__":
- # remove current path from list of search paths to avoid importing mllib.random
- # for C{import random}, which is done in an external dependency of pyspark during doctests.
- import sys
sys.path.pop(0)
_test()