From edbd6feb8a8dc79dcd8b5185e5ea48f332bbfae2 Mon Sep 17 00:00:00 2001 From: Xiangrui Meng Date: Wed, 28 Jan 2015 12:41:41 -0800 Subject: [PATCH] move Identifiable to ml.util --- python/pyspark/ml/param/__init__.py | 16 ++-------------- python/pyspark/ml/util.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/python/pyspark/ml/param/__init__.py b/python/pyspark/ml/param/__init__.py index 9d657acdd94f4..5566792cead48 100644 --- a/python/pyspark/ml/param/__init__.py +++ b/python/pyspark/ml/param/__init__.py @@ -15,24 +15,12 @@ # limitations under the License. # -import uuid from abc import ABCMeta -__all__ = ['Param', 'Params'] - - -class Identifiable(object): - """ - Object with a unique ID. - """ +from pyspark.ml.util import Identifiable - def __init__(self): - #: A unique id for the object. The default implementation - #: concatenates the class name, "-", and 8 random hex chars. - self.uid = type(self).__name__ + "-" + uuid.uuid4().hex[:8] - def __repr__(self): - return self.uid +__all__ = ['Param', 'Params'] class Param(object): diff --git a/python/pyspark/ml/util.py b/python/pyspark/ml/util.py index 991330f78e983..b1caa84b6306a 100644 --- a/python/pyspark/ml/util.py +++ b/python/pyspark/ml/util.py @@ -15,6 +15,8 @@ # limitations under the License. # +import uuid + def inherit_doc(cls): for name, func in vars(cls).items(): @@ -28,3 +30,17 @@ def inherit_doc(cls): func.__doc__ = parent_func.__doc__ break return cls + + +class Identifiable(object): + """ + Object with a unique ID. + """ + + def __init__(self): + #: A unique id for the object. The default implementation + #: concatenates the class name, "-", and 8 random hex chars. + self.uid = type(self).__name__ + "-" + uuid.uuid4().hex[:8] + + def __repr__(self): + return self.uid