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

    https://github.com/apache/spark/pull/9581#discussion_r48774100
  
    --- Diff: python/pyspark/ml/param/__init__.py ---
    @@ -247,7 +248,27 @@ def _set(self, **kwargs):
             Sets user-supplied params.
             """
             for param, value in kwargs.items():
    -            self._paramMap[getattr(self, param)] = value
    +            p = getattr(self, param)
    +            if (p.expectedType is not None):
    +                if p.expectedType is None or type(value) == p.expectedType 
or value is None:
    --- End diff --
    
    I believe the `p.expectedType is None` check in the second if statement is 
frivolous. Couldn't this be condensed into a single if else like:
    
    ```python
    if p.expectedType is not None and type(value) != p.expectedType and value 
is not None:
        try:
            ...
    else:
        self._paramMap[getattr(self, param)] = value
    ```


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to