diff options
author | Matthew Farrellee <matt@redhat.com> | 2014-09-19 14:35:22 -0700 |
---|---|---|
committer | Josh Rosen <joshrosen@apache.org> | 2014-09-19 14:35:22 -0700 |
commit | a03e5b81e91d9d792b6a2e01d1505394ea303dd8 (patch) | |
tree | 074018184808d230a4c64805db0523ed73a34531 /examples/src/main/python/pi.py | |
parent | be0c7563ea001a59469dbba219d2a8ef5785afa3 (diff) | |
download | spark-a03e5b81e91d9d792b6a2e01d1505394ea303dd8.tar.gz spark-a03e5b81e91d9d792b6a2e01d1505394ea303dd8.tar.bz2 spark-a03e5b81e91d9d792b6a2e01d1505394ea303dd8.zip |
[SPARK-1701] [PySpark] remove slice terminology from python examples
Author: Matthew Farrellee <matt@redhat.com>
Closes #2304 from mattf/SPARK-1701-partition-over-slice-for-python-examples and squashes the following commits:
928a581 [Matthew Farrellee] [SPARK-1701] [PySpark] remove slice terminology from python examples
Diffstat (limited to 'examples/src/main/python/pi.py')
-rwxr-xr-x | examples/src/main/python/pi.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/src/main/python/pi.py b/examples/src/main/python/pi.py index ee9036adfa..a7c74e969c 100755 --- a/examples/src/main/python/pi.py +++ b/examples/src/main/python/pi.py @@ -24,18 +24,18 @@ from pyspark import SparkContext if __name__ == "__main__": """ - Usage: pi [slices] + Usage: pi [partitions] """ sc = SparkContext(appName="PythonPi") - slices = int(sys.argv[1]) if len(sys.argv) > 1 else 2 - n = 100000 * slices + partitions = int(sys.argv[1]) if len(sys.argv) > 1 else 2 + n = 100000 * partitions def f(_): x = random() * 2 - 1 y = random() * 2 - 1 return 1 if x ** 2 + y ** 2 < 1 else 0 - count = sc.parallelize(xrange(1, n + 1), slices).map(f).reduce(add) + count = sc.parallelize(xrange(1, n + 1), partitions).map(f).reduce(add) print "Pi is roughly %f" % (4.0 * count / n) sc.stop() |