Skip to content
Permalink
Browse files

[SPARK-23132][PYTHON][ML] Run doctests in ml.image when testing

## What changes were proposed in this pull request?

This PR proposes to actually run the doctests in `ml/image.py`.

## How was this patch tested?

doctests in `python/pyspark/ml/image.py`.

Author: hyukjinkwon <gurwls223@gmail.com>

Closes #20294 from HyukjinKwon/trigger-image.

(cherry picked from commit 45ad97d)
Signed-off-by: hyukjinkwon <gurwls223@gmail.com>
  • Loading branch information...
HyukjinKwon committed Jan 17, 2018
1 parent 6e509fd commit b84c2a30665ebbd65feb7418826501f6c959eb96
Showing with 24 additions and 2 deletions.
  1. +24 −2 python/pyspark/ml/image.py
@@ -194,9 +194,9 @@ def readImages(self, path, recursive=False, numPartitions=-1,
:return: a :class:`DataFrame` with a single column of "images",
see ImageSchema for details.
>>> df = ImageSchema.readImages('python/test_support/image/kittens', recursive=True)
>>> df = ImageSchema.readImages('data/mllib/images/kittens', recursive=True)
>>> df.count()
4
5
.. versionadded:: 2.3.0
"""
@@ -216,3 +216,25 @@ def readImages(self, path, recursive=False, numPartitions=-1,
def _disallow_instance(_):
raise RuntimeError("Creating instance of _ImageSchema class is disallowed.")
_ImageSchema.__init__ = _disallow_instance


def _test():
import doctest
import pyspark.ml.image
globs = pyspark.ml.image.__dict__.copy()
spark = SparkSession.builder\
.master("local[2]")\
.appName("ml.image tests")\
.getOrCreate()
globs['spark'] = spark

(failure_count, test_count) = doctest.testmod(
pyspark.ml.image, globs=globs,
optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)
spark.stop()
if failure_count:
exit(-1)


if __name__ == "__main__":
_test()

0 comments on commit b84c2a3

Please sign in to comment.
You can’t perform that action at this time.