Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions python/pyspark/ml/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It becomes 5 since we don't dropImageFailures.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!


.. versionadded:: 2.3.0
"""
Expand All @@ -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()