aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/ml/util.py
diff options
context:
space:
mode:
authorwm624@hotmail.com <wm624@hotmail.com>2016-03-28 22:33:25 -0700
committerJoseph K. Bradley <joseph@databricks.com>2016-03-28 22:33:25 -0700
commit63b200e8d4a05d5b744d437fd10781c6b5429da9 (patch)
tree64698cc8e0b7a8eeff8fdbe6ca65d1d0e9842836 /python/pyspark/ml/util.py
parentf6066b0c3c35ceea1706378145e15776c9b4415a (diff)
downloadspark-63b200e8d4a05d5b744d437fd10781c6b5429da9.tar.gz
spark-63b200e8d4a05d5b744d437fd10781c6b5429da9.tar.bz2
spark-63b200e8d4a05d5b744d437fd10781c6b5429da9.zip
[SPARK-14071][PYSPARK][ML] Change MLWritable.write to be a property
Add property to MLWritable.write method, so we can use .write instead of .write() Add a new test to ml/test.py to check whether the write is a property. ./python/run-tests --python-executables=python2.7 --modules=pyspark-ml Will test against the following Python executables: ['python2.7'] Will test the following Python modules: ['pyspark-ml'] Finished test(python2.7): pyspark.ml.evaluation (11s) Finished test(python2.7): pyspark.ml.clustering (16s) Finished test(python2.7): pyspark.ml.classification (24s) Finished test(python2.7): pyspark.ml.recommendation (24s) Finished test(python2.7): pyspark.ml.feature (39s) Finished test(python2.7): pyspark.ml.regression (26s) Finished test(python2.7): pyspark.ml.tuning (15s) Finished test(python2.7): pyspark.ml.tests (30s) Tests passed in 55 seconds Author: wm624@hotmail.com <wm624@hotmail.com> Closes #11945 from wangmiao1981/fix_property.
Diffstat (limited to 'python/pyspark/ml/util.py')
-rw-r--r--python/pyspark/ml/util.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/python/pyspark/ml/util.py b/python/pyspark/ml/util.py
index 6703851262..d4411fdfb9 100644
--- a/python/pyspark/ml/util.py
+++ b/python/pyspark/ml/util.py
@@ -134,13 +134,14 @@ class MLWritable(object):
.. versionadded:: 2.0.0
"""
+ @property
def write(self):
"""Returns an JavaMLWriter instance for this ML instance."""
raise NotImplementedError("MLWritable is not yet implemented for type: %r" % type(self))
def save(self, path):
"""Save this ML instance to the given path, a shortcut of `write().save(path)`."""
- self.write().save(path)
+ self.write.save(path)
@inherit_doc
@@ -149,6 +150,7 @@ class JavaMLWritable(MLWritable):
(Private) Mixin for ML instances that provide :py:class:`JavaMLWriter`.
"""
+ @property
def write(self):
"""Returns an JavaMLWriter instance for this ML instance."""
return JavaMLWriter(self)