Skip to content

Commit f66ba0c

Browse files
committed
make params a property
1 parent d5efd34 commit f66ba0c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

python/pyspark/ml/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def _transfer_params_to_java(self, params, java_obj):
221221
:param java_obj: Java object to receive the params
222222
"""
223223
paramMap = self._merge_params(params)
224-
for param in self.params():
224+
for param in self.params:
225225
if param in paramMap:
226226
java_obj.set(param.name, paramMap[param])
227227

python/pyspark/ml/param/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ def __init__(self):
5555
#: embedded param map
5656
self.paramMap = {}
5757

58+
@property
5859
def params(self):
5960
"""
6061
Returns all params. The default implementation uses
6162
:py:func:`dir` to get all attributes of type
6263
:py:class:`Param`.
6364
"""
64-
return filter(lambda x: isinstance(x, Param), map(lambda x: getattr(self, x), dir(self)))
65+
return filter(lambda attr: isinstance(attr, Param),
66+
[getattr(self, x) for x in dir(self) if x != "params"])
6567

6668
def _merge_params(self, params):
6769
paramMap = self.paramMap.copy()

0 commit comments

Comments
 (0)