File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 3535from pyspark .files import SparkFiles
3636from 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
3947SPARK_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+
362382if __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"
You can’t perform that action at this time.
0 commit comments