spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From viirya <...@git.apache.org>
Subject [GitHub] spark pull request #20168: [SPARK-22730][ML] Add ImageSchema support for non...
Date Tue, 16 Jan 2018 06:10:45 GMT
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20168#discussion_r161664597
  
    --- Diff: python/pyspark/ml/image.py ---
    @@ -55,25 +72,66 @@ def imageSchema(self):
             """
     
             if self._imageSchema is None:
    -            ctx = SparkContext._active_spark_context
    +            ctx = SparkContext.getOrCreate()
                 jschema = ctx._jvm.org.apache.spark.ml.image.ImageSchema.imageSchema()
                 self._imageSchema = _parse_datatype_json_string(jschema.json())
             return self._imageSchema
     
         @property
         def ocvTypes(self):
             """
    -        Returns the OpenCV type mapping supported.
    +        Return the supported OpenCV types.
     
    -        :return: a dictionary containing the OpenCV type mapping supported.
    +        :return: a list containing the supported OpenCV types.
     
             .. versionadded:: 2.3.0
             """
     
             if self._ocvTypes is None:
    -            ctx = SparkContext._active_spark_context
    -            self._ocvTypes = dict(ctx._jvm.org.apache.spark.ml.image.ImageSchema.javaOcvTypes())
    -        return self._ocvTypes
    +            ctx = SparkContext.getOrCreate()
    +            ocvTypeList = ctx._jvm.org.apache.spark.ml.image.ImageSchema.javaOcvTypes()
    +            self._ocvTypes = [self._OcvType(name=x.name(),
    +                                            mode=x.mode(),
    +                                            nChannels=x.nChannels(),
    +                                            dataType=x.dataType(),
    +                                            nptype=self._ocvToNumpyMap[x.dataType()])
    +                              for x in ocvTypeList]
    +        return self._ocvTypes[:]
    +
    +
    +    def ocvTypeByName(self, name):
    +        """
    +        Return the supported OpenCvType with matching name or raise error if there is
no matching type.
    +
    +        :param: str name: OpenCv type name; must be equal to name of one of the supported
types.
    +        :return: OpenCvType with matching name.
    --- End diff --
    
    `OpenCvType` -> `OcvType`?



---

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


Mime
View raw message