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

    https://github.com/apache/spark/pull/11663#discussion_r57084301
  
    --- Diff: python/pyspark/ml/param/__init__.py ---
    @@ -65,6 +80,144 @@ def __eq__(self, other):
                 return False
     
     
    +class TypeConverters(object):
    +    """
    +    .. note:: DeveloperApi
    +
    +    Factory methods for common type conversion functions for 
`Param.typeConverter`.
    +
    +    .. versionadded:: 2.0.0
    +    """
    +
    +    @staticmethod
    +    def _is_numeric(value):
    +        vtype = type(value)
    +        return vtype in [int, float, np.float64, np.int64] or 
vtype.__name__ == 'long'
    +
    +    @staticmethod
    +    def _is_integer(value):
    +        return TypeConverters._is_numeric(value) and 
float(value).is_integer()
    +
    +    @staticmethod
    +    def _can_convert_to_list(value):
    +        vtype = type(value)
    +        return vtype in [list, np.ndarray, tuple, xrange, array.array] or 
isinstance(value, Vector)
    +
    +    @staticmethod
    +    def _can_convert_to_string(value):
    --- End diff --
    
    I hadn't thought about this before, but we actually should support unicode. 
 The main use case is StringIndexer, which might be used to index unicode.  For 
that, we'd want to pass an array of unicode and probably avoid converting it to 
str types.
    
    Java/Scala should already handle this since java.lang.String handles 
unicode.


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