Github user sethah commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10962#discussion_r51076979
  
    --- 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 --
    
    I tend to agree that we should only accept string types for this function. 
The reason I have included `Param` type is because in the current ml param 
tests, there is a check where `hasParam` is called by passing a `Param` 
instance instead of a string, so this test would fail ([see 
here](https://github.com/apache/spark/blob/master/python/pyspark/ml/tests.py#L216)).
 It is odd that the test passes a `Param` instance and not a string, since the 
function describes itself as accepting strings, but, in an odd twist, the check 
works anyway.
    
    If we do accept `Param` type, we can't call `_shouldOwn` because it throws 
an error instead of returning `False` (by design?). At any rate, I vote to 
accept only strings and change the test to pass in the param name instead of 
the param. 


---
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]

Reply via email to