Allow users to serialize custom classes. (#393)

* Allow serialization of custom classes.

* Add documentation and test cases, also fix pickle case.

* Don't allow old-style classes.
This commit is contained in:
Robert Nishihara
2016-09-06 13:28:24 -07:00
committed by Philipp Moritz
parent d5cb3ac090
commit 11a8914684
22 changed files with 497 additions and 403 deletions
-8
View File
@@ -16,14 +16,6 @@ class DistArray(object):
if self.num_blocks != list(self.objectids.shape):
raise Exception("The fields `num_blocks` and `objectids` are inconsistent, `num_blocks` is {} and `objectids` has shape {}".format(self.num_blocks, list(self.objectids.shape)))
@staticmethod
def deserialize(primitives):
(shape, objectids) = primitives
return DistArray(shape, objectids)
def serialize(self):
return (self.shape, self.objectids)
@staticmethod
def compute_block_lower(index, shape):
if len(index) != len(shape):