Skip to content

Commit b84c2a3

Browse files
committed
[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 <[email protected]> Closes #20294 from HyukjinKwon/trigger-image. (cherry picked from commit 45ad97d) Signed-off-by: hyukjinkwon <[email protected]>
1 parent 6e509fd commit b84c2a3

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

python/pyspark/ml/image.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ def readImages(self, path, recursive=False, numPartitions=-1,
194194
:return: a :class:`DataFrame` with a single column of "images",
195195
see ImageSchema for details.
196196
197-
>>> df = ImageSchema.readImages('python/test_support/image/kittens', recursive=True)
197+
>>> df = ImageSchema.readImages('data/mllib/images/kittens', recursive=True)
198198
>>> df.count()
199-
4
199+
5
200200
201201
.. versionadded:: 2.3.0
202202
"""
@@ -216,3 +216,25 @@ def readImages(self, path, recursive=False, numPartitions=-1,
216216
def _disallow_instance(_):
217217
raise RuntimeError("Creating instance of _ImageSchema class is disallowed.")
218218
_ImageSchema.__init__ = _disallow_instance
219+
220+
221+
def _test():
222+
import doctest
223+
import pyspark.ml.image
224+
globs = pyspark.ml.image.__dict__.copy()
225+
spark = SparkSession.builder\
226+
.master("local[2]")\
227+
.appName("ml.image tests")\
228+
.getOrCreate()
229+
globs['spark'] = spark
230+
231+
(failure_count, test_count) = doctest.testmod(
232+
pyspark.ml.image, globs=globs,
233+
optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)
234+
spark.stop()
235+
if failure_count:
236+
exit(-1)
237+
238+
239+
if __name__ == "__main__":
240+
_test()

0 commit comments

Comments
 (0)