Github user yanboliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/10962#discussion_r51075753
--- Diff: python/pyspark/ml/param/__init__.py ---
@@ -152,13 +152,17 @@ def isDefined(self, param):
return self.isSet(param) or self.hasDefault(param)
@since("1.4.0")
- def hasParam(self, paramName):
+ def hasParam(self, param):
"""
- Tests whether this instance contains a param with a given
- (string) name.
+ Tests whether this instance contains a param.
"""
- param = self._resolveParam(paramName)
- return param in self.params
+ if isinstance(param, Param):
+ return hasattr(self, param.name)
--- End diff --
If we support ```param``` of type ```Param```, we should not only check the
```hasattr(self, param.name)``` but also check ```self.uid == param.parent```.
You can directly call ```_shouldOwn``` to do this work. It means if you provide
a ```Param``` to check whether it belongs to the instance, you should both
check ```uid``` and ```name```.
I vote to only support ```paramName``` that make consistent semantics with
Scala.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]