Skip to content

Commit d947e8c

Browse files
committed
Added test for scipy.special importing
1 parent 1798bbd commit d947e8c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

python/pyspark/tests.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
from pyspark.files import SparkFiles
3636
from pyspark.serializers import read_int
3737

38+
_have_scipy = False
39+
try:
40+
import scipy.sparse
41+
_have_scipy = True
42+
except:
43+
# No SciPy, but that's okay, we'll skip those tests
44+
pass
45+
3846

3947
SPARK_HOME = os.environ["SPARK_HOME"]
4048

@@ -359,5 +367,21 @@ def test_single_script_on_cluster(self):
359367
self.assertIn("[2, 4, 6]", out)
360368

361369

370+
@unittest.skipIf(not _have_scipy, "SciPy not installed")
371+
class SciPyTests(PySparkTestCase):
372+
"""General PySpark tests that depend on scipy """
373+
374+
def test_serialize(self):
375+
from scipy.special import gammaln
376+
x = range(1, 5)
377+
expected = map(gammaln, x)
378+
observed = self.sc.parallelize(x).map(gammaln).collect()
379+
self.assertEqual(expected, observed)
380+
381+
362382
if __name__ == "__main__":
383+
if not _have_scipy:
384+
print "NOTE: Skipping SciPy tests as it does not seem to be installed"
363385
unittest.main()
386+
if not _have_scipy:
387+
print "NOTE: SciPy tests were skipped as it does not seem to be installed"

0 commit comments

Comments
 (0)