diff options
author | Josh Rosen <joshrosen@eecs.berkeley.edu> | 2013-01-20 11:22:38 -0800 |
---|---|---|
committer | Josh Rosen <joshrosen@eecs.berkeley.edu> | 2013-01-20 11:58:57 -0800 |
commit | 17035db159e191a11cd86882c97078581073deb2 (patch) | |
tree | 7081945e85be0cec9bc51b96aeac4bfa6af43695 /python/pyspark | |
parent | 9f54d7e1f5a5e6f80b3d710de67f800bef943d33 (diff) | |
download | spark-17035db159e191a11cd86882c97078581073deb2.tar.gz spark-17035db159e191a11cd86882c97078581073deb2.tar.bz2 spark-17035db159e191a11cd86882c97078581073deb2.zip |
Add __repr__ to Accumulator; fix bug in sc.accumulator
Diffstat (limited to 'python/pyspark')
-rw-r--r-- | python/pyspark/accumulators.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/python/pyspark/accumulators.py b/python/pyspark/accumulators.py index c00c3a37af..8011779ddc 100644 --- a/python/pyspark/accumulators.py +++ b/python/pyspark/accumulators.py @@ -11,6 +11,12 @@ >>> a.value 7 +>>> sc.accumulator(1.0).value +1.0 + +>>> sc.accumulator(1j).value +1j + >>> rdd = sc.parallelize([1,2,3]) >>> def f(x): ... global a @@ -124,6 +130,9 @@ class Accumulator(object): def __str__(self): return str(self._value) + def __repr__(self): + return "Accumulator<id=%i, value=%s>" % (self.aid, self._value) + class AddingAccumulatorParam(object): """ @@ -145,7 +154,7 @@ class AddingAccumulatorParam(object): # Singleton accumulator params for some standard types INT_ACCUMULATOR_PARAM = AddingAccumulatorParam(0) -DOUBLE_ACCUMULATOR_PARAM = AddingAccumulatorParam(0.0) +FLOAT_ACCUMULATOR_PARAM = AddingAccumulatorParam(0.0) COMPLEX_ACCUMULATOR_PARAM = AddingAccumulatorParam(0.0j) |