def testDeserializeWithHook(self):
   obj1 = range(10)
   obj2 = TestObject(5)
   json_str = sd.serialize([obj1, obj2])
   [new_obj1, new_obj2] = sd.deserialize(json_str)
   self.assertEqual(obj2.a_list, new_obj2.a_list)
   json_str = sd.serialize(obj2)
   new_obj2 = sd.deserialize(json_str)
   self.assertEqual(obj2.a_list, new_obj2.a_list)
Пример #2
0
 def testDeserializeWithHook(self):
     obj1 = range(10)
     obj2 = TestObject(5)
     json_str = sd.serialize([obj1, obj2])
     [new_obj1, new_obj2] = sd.deserialize(json_str)
     self.assertEqual(obj2.a_list, new_obj2.a_list)
     json_str = sd.serialize(obj2)
     new_obj2 = sd.deserialize(json_str)
     self.assertEqual(obj2.a_list, new_obj2.a_list)
Пример #3
0
 def testForColumn(self):
     self.column = createColumn(COLUMN_NAME,
                                data=LIST,
                                table=None,
                                formula=VALID_FORMULA)
     json_str = sd.serialize(self.column)
     new_column = sd.deserialize(json_str)
     self.assertTrue(self.column.isEquivalent(new_column))
Пример #4
0
 def testDeserializeWithHookForLists(self):
     obj = [np.array(range(x)) for x in range(5)]
     json_str = sd.serialize(obj)
     new_obj = sd.deserialize(json_str)
     self.assertEqual(len(obj), len(new_obj))
     pairs = zip(obj, new_obj)
     for o1, o2 in pairs:
         self.assertEqual(o1.tolist(), o2)
 def testSerializeWithHook(self):
   return
   obj1 = range(10)
   obj2 = TestObject(5)
   json_str = sd.serialize([obj1, obj2])
   [new_obj1, obj2_dict] = json.loads(json_str)
   new_obj2 = TestObject(obj2_dict['range_length'])
   self.assertEqual(obj2.a_list, new_obj2.a_list)
Пример #6
0
 def testSerializeWithHook(self):
     return
     obj1 = range(10)
     obj2 = TestObject(5)
     json_str = sd.serialize([obj1, obj2])
     [new_obj1, obj2_dict] = json.loads(json_str)
     new_obj2 = TestObject(obj2_dict['range_length'])
     self.assertEqual(obj2.a_list, new_obj2.a_list)
 def testDeserializeWithHookForLists(self):
   obj = [np.array(range(x)) for x in range(5)]
   json_str = sd.serialize(obj)
   new_obj = sd.deserialize(json_str)
   self.assertEqual(len(obj), len(new_obj))
   pairs = zip(obj, new_obj)
   for o1, o2 in pairs:
     self.assertEqual(o1.tolist(), o2)
Пример #8
0
def writeObjectToFile(an_object, filepath=None):
  """
  Serializes and writes the object to the file
  :param object an_object:
  :param str filepath:
  :raises ValueError: if cannot find a filepath
  """
  if 'getFilepath' in dir(an_object):
    filepath = an_object.getFilepath()
  if filepath is None:
    raise ValueError("No way to find filepath")
  with open(filepath, "w") as fh:
    fh.write(serialize(an_object))
Пример #9
0
def writeObjectToFile(an_object, filepath=None):
  """
  Serializes and writes the object to the file
  :param object an_object:
  :param str filepath:
  :raises ValueError: if cannot find a filepath
  """
  if 'getFilepath' in dir(an_object):
    filepath = an_object.getFilepath()
  if filepath is None:
    raise ValueError("No way to find filepath")
  with open(filepath, "w") as fh:
    fh.write(serialize(an_object))
Пример #10
0
def _serializeTable(table):
  with open(table.getFilepath(), "w") as fh:
    fh.write(serialize(table))
Пример #11
0
 def testForTable(self):
     setupTableInitialization(self)
     json_str = sd.serialize(self.table)
     new_table = sd.deserialize(json_str)
     self.assertTrue(self.table.isEquivalent(new_table))
Пример #12
0
 def testSerializeBasic(self):
     return
     obj = {"a": range(10)}
     json_str = sd.serialize(obj)
     self.assertEqual(json.loads(json_str), obj)
 def testForTable(self):
   setupTableInitialization(self)
   json_str = sd.serialize(self.table)
   new_table = sd.deserialize(json_str)
   self.assertTrue(self.table.isEquivalent(new_table))
 def testForColumn(self):
   self.column = createColumn(COLUMN_NAME, data=LIST, table=None,
       formula=VALID_FORMULA)
   json_str = sd.serialize(self.column)
   new_column = sd.deserialize(json_str)
   self.assertTrue(self.column.isEquivalent(new_column))
 def testDeserializeBasic(self):
   return
   obj = range(10)
   json_str = sd.serialize(obj)
   new_obj = sd.deserialize(json_str)
   self.assertEqual(obj, new_obj)
Пример #16
0
 def testDeserializeBasic(self):
     return
     obj = range(10)
     json_str = sd.serialize(obj)
     new_obj = sd.deserialize(json_str)
     self.assertEqual(obj, new_obj)
Пример #17
0
def _serializeTable(table):
  with open(table.getFilepath(), "w") as fh:
    fh.write(serialize(table))
 def testSerializeBasic(self):
   return
   obj = {"a": range(10)}
   json_str = sd.serialize(obj)
   self.assertEqual(json.loads(json_str), obj)