From 9407c10860e6fb0f3bc4dfb1b0ab5e89d54aa0a7 2012-03-14 00:17:46 From: MinRK Date: 2012-03-14 00:17:46 Subject: [PATCH] test that pushing numpy arrays is zero-copy --- diff --git a/IPython/parallel/tests/test_view.py b/IPython/parallel/tests/test_view.py index 3f1d335..06479b4 100644 --- a/IPython/parallel/tests/test_view.py +++ b/IPython/parallel/tests/test_view.py @@ -233,6 +233,23 @@ class TestView(ClusterTestCase): view.scatter('a', a) b = view.gather('a', block=True) assert_array_equal(b, a) + + @skip_without('numpy') + def test_push_numpy_nocopy(self): + import numpy + view = self.client[:] + a = numpy.arange(64) + view['A'] = a + @interactive + def check_writeable(x): + return x.flags.writeable + + for flag in view.apply_sync(check_writeable, pmod.Reference('A')): + self.assertFalse(flag, "array is writeable, push shouldn't have pickled it") + + view.push(dict(B=a)) + for flag in view.apply_sync(check_writeable, pmod.Reference('B')): + self.assertFalse(flag, "array is writeable, push shouldn't have pickled it") def test_map(self): view = self.client[:]