Skip to content

Commit

Permalink
move Identifiable to ml.util
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxr committed Jan 28, 2015
1 parent 44c2405 commit edbd6fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
16 changes: 2 additions & 14 deletions python/pyspark/ml/param/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 16 additions & 0 deletions python/pyspark/ml/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# limitations under the License.
#

import uuid


def inherit_doc(cls):
for name, func in vars(cls).items():
Expand All @@ -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

0 comments on commit edbd6fe

Please sign in to comment.