spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sethah <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-13047][PYSPARK][ML] Pyspark Params.hasP...
Date Thu, 28 Jan 2016 03:52:11 GMT
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message