Github user HyukjinKwon commented on a diff in the pull request: https://github.com/apache/spark/pull/20168#discussion_r161366253 --- Diff: python/pyspark/ml/image.py --- @@ -71,9 +88,33 @@ def ocvTypes(self): """ 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): --- End diff -- Let's write a doc and doctest too.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org