Show More
@@ -287,6 +287,21 b' class TestView(ClusterTestCase):' | |||
|
287 | 287 | assert_array_equal(B,C) |
|
288 | 288 | |
|
289 | 289 | @skip_without('numpy') |
|
290 | def test_apply_numpy_object_dtype(self): | |
|
291 | """view.apply(f, ndarray) with dtype=object""" | |
|
292 | import numpy | |
|
293 | from numpy.testing.utils import assert_array_equal | |
|
294 | view = self.client[-1] | |
|
295 | ||
|
296 | A = numpy.array([dict(a=5)]) | |
|
297 | B = view.apply_sync(lambda x:x, A) | |
|
298 | assert_array_equal(A,B) | |
|
299 | ||
|
300 | A = numpy.array([(0, dict(b=10))], dtype=[('i', int), ('o', object)]) | |
|
301 | B = view.apply_sync(lambda x:x, A) | |
|
302 | assert_array_equal(A,B) | |
|
303 | ||
|
304 | @skip_without('numpy') | |
|
290 | 305 | def test_push_pull_recarray(self): |
|
291 | 306 | """push/pull recarrays""" |
|
292 | 307 | import numpy |
@@ -192,7 +192,15 b' class CannedArray(CannedObject):' | |||
|
192 | 192 | from numpy import ascontiguousarray |
|
193 | 193 | self.shape = obj.shape |
|
194 | 194 | self.dtype = obj.dtype.descr if obj.dtype.fields else obj.dtype.str |
|
195 | self.pickled = False | |
|
195 | 196 | if sum(obj.shape) == 0: |
|
197 | self.pickled = True | |
|
198 | elif obj.dtype == 'O': | |
|
199 | # can't handle object dtype with buffer approach | |
|
200 | self.pickled = True | |
|
201 | elif obj.dtype.fields and any(dt == 'O' for dt,sz in obj.dtype.fields.values()): | |
|
202 | self.pickled = True | |
|
203 | if self.pickled: | |
|
196 | 204 | # just pickle it |
|
197 | 205 | self.buffers = [pickle.dumps(obj, -1)] |
|
198 | 206 | else: |
@@ -203,7 +211,7 b' class CannedArray(CannedObject):' | |||
|
203 | 211 | def get_object(self, g=None): |
|
204 | 212 | from numpy import frombuffer |
|
205 | 213 | data = self.buffers[0] |
|
206 |
if |
|
|
214 | if self.pickled: | |
|
207 | 215 | # no shape, we just pickled it |
|
208 | 216 | return pickle.loads(data) |
|
209 | 217 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now