Show More
@@ -90,14 +90,14 b' class CanningTestCase(TestCase):' | |||||
90 | self.assertEquals(td, 'ndarray') |
|
90 | self.assertEquals(td, 'ndarray') | |
91 | md = ser1.getMetadata() |
|
91 | md = ser1.getMetadata() | |
92 | self.assertEquals(md['shape'], a.shape) |
|
92 | self.assertEquals(md['shape'], a.shape) | |
93 |
self.assertEquals(md['dtype'], a.dtype |
|
93 | self.assertEquals(md['dtype'], a.dtype) | |
94 | buff = ser1.getData() |
|
94 | buff = ser1.getData() | |
95 | self.assertEquals(buff, buffer(a)) |
|
95 | self.assertEquals(buff, buffer(a)) | |
96 | s = ns.Serialized(buff, td, md) |
|
96 | s = ns.Serialized(buff, td, md) | |
97 | final = ns.unserialize(s) |
|
97 | final = ns.unserialize(s) | |
98 | self.assertEquals(buffer(a), buffer(final)) |
|
98 | self.assertEquals(buffer(a), buffer(final)) | |
99 | self.assertTrue((a==final).all()) |
|
99 | self.assertTrue((a==final).all()) | |
100 |
self.assertEquals(a.dtype |
|
100 | self.assertEquals(a.dtype, final.dtype) | |
101 | self.assertEquals(a.shape, final.shape) |
|
101 | self.assertEquals(a.shape, final.shape) | |
102 | # test non-copying: |
|
102 | # test non-copying: | |
103 | a[2] = 1e9 |
|
103 | a[2] = 1e9 |
@@ -283,6 +283,30 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||||
283 | C = view.apply_sync(lambda x:x, B) |
|
283 | C = view.apply_sync(lambda x:x, B) | |
284 | assert_array_equal(B,C) |
|
284 | assert_array_equal(B,C) | |
285 |
|
285 | |||
|
286 | @skip_without('numpy') | |||
|
287 | def test_push_pull_recarray(self): | |||
|
288 | """push/pull recarrays""" | |||
|
289 | import numpy | |||
|
290 | from numpy.testing.utils import assert_array_equal | |||
|
291 | ||||
|
292 | view = self.client[-1] | |||
|
293 | ||||
|
294 | R = numpy.array([ | |||
|
295 | (1, 'hi', 0.), | |||
|
296 | (2**30, 'there', 2.5), | |||
|
297 | (-99999, 'world', -12345.6789), | |||
|
298 | ], [('n', int), ('s', '|S10'), ('f', float)]) | |||
|
299 | ||||
|
300 | view['RR'] = R | |||
|
301 | R2 = view['RR'] | |||
|
302 | ||||
|
303 | r_dtype, r_shape = view.apply_sync(interactive(lambda : (RR.dtype, RR.shape))) | |||
|
304 | self.assertEquals(r_dtype, R.dtype) | |||
|
305 | self.assertEquals(r_shape, R.shape) | |||
|
306 | self.assertEquals(R2.dtype, R.dtype) | |||
|
307 | self.assertEquals(R2.shape, R.shape) | |||
|
308 | assert_array_equal(R2, R) | |||
|
309 | ||||
286 | def test_map(self): |
|
310 | def test_map(self): | |
287 | view = self.client[:] |
|
311 | view = self.client[:] | |
288 | def f(x): |
|
312 | def f(x): |
@@ -110,7 +110,7 b' class SerializeIt(object):' | |||||
110 | self.obj = numpy.ascontiguousarray(self.obj, dtype=None) |
|
110 | self.obj = numpy.ascontiguousarray(self.obj, dtype=None) | |
111 | self.typeDescriptor = 'ndarray' |
|
111 | self.typeDescriptor = 'ndarray' | |
112 | self.metadata = {'shape':self.obj.shape, |
|
112 | self.metadata = {'shape':self.obj.shape, | |
113 |
'dtype':self.obj.dtype |
|
113 | 'dtype':self.obj.dtype} | |
114 | elif isinstance(self.obj, bytes): |
|
114 | elif isinstance(self.obj, bytes): | |
115 | self.typeDescriptor = 'bytes' |
|
115 | self.typeDescriptor = 'bytes' | |
116 | self.metadata = {} |
|
116 | self.metadata = {} |
General Comments 0
You need to be logged in to leave comments.
Login now