File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -933,7 +933,7 @@ def _change_cell_value(cell, newval):
933
933
Note: These can never be renamed due to client compatibility issues"""
934
934
935
935
def _getobject (modname , attribute ):
936
- mod = __import__ (modname )
936
+ mod = __import__ (modname , fromlist = [ attribute ] )
937
937
return mod .__dict__ [attribute ]
938
938
939
939
def _generateImage (size , mode , str_rep ):
Original file line number Diff line number Diff line change 33
33
from pyspark .java_gateway import SPARK_HOME
34
34
from pyspark .serializers import read_int
35
35
36
+ _have_scipy = False
37
+ try :
38
+ import scipy .sparse
39
+ _have_scipy = True
40
+ except :
41
+ # No SciPy, but that's okay, we'll skip those tests
42
+ pass
43
+
36
44
37
45
class PySparkTestCase (unittest .TestCase ):
38
46
@@ -234,5 +242,22 @@ def test_termination_sigterm(self):
234
242
from signal import SIGTERM
235
243
self .do_termination_test (lambda daemon : os .kill (daemon .pid , SIGTERM ))
236
244
245
+
246
+ @unittest .skipIf (not _have_scipy , "SciPy not installed" )
247
+ class SciPyTests (PySparkTestCase ):
248
+ """General PySpark tests that depend on scipy """
249
+
250
+ def test_serialize (self ):
251
+ from scipy .special import gammaln
252
+ x = range (1 , 5 )
253
+ expected = map (gammaln , x )
254
+ observed = self .sc .parallelize (x ).map (gammaln ).collect ()
255
+ self .assertEqual (expected , observed )
256
+
257
+
237
258
if __name__ == "__main__" :
259
+ if not _have_scipy :
260
+ print "NOTE: Skipping SciPy tests as it does not seem to be installed"
238
261
unittest .main ()
262
+ if not _have_scipy :
263
+ 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