Exemplo n.º 1
0
 def testSaveRestore(self):
     self.field.creator=u"Klaus"
     self.field.seal()
     self.eln.createGroup(self.eln.root,'testSaveRestoreField')
     saveField(self.eln,self.eln.root.testSaveRestoreField,self.field)
     restoredField = loadField(self.eln,self.eln.root.testSaveRestoreField)
     self.assertEqual(restoredField,self.field)
Exemplo n.º 2
0
 def testDateTime(self):
     """Test the correct saving and  restoring of object arrays composed from datetime objects."""
     objectArray = numpy.array([datetime.datetime.now() for i in range(10)])
     objectField = FieldContainer(objectArray,longname=u"timestamp",
                                 shortname='t')
     objectField.seal()
     self.eln.createGroup(self.eln.root,'testObjectFields')
     saveField(self.eln,self.eln.root.testObjectFields,objectField)
     restoredField = loadField(self.eln,self.eln.root.testObjectFields)
     for i,j in zip(restoredField.data.tolist(),objectField.data.tolist()):
         self.assertEqual(i,j,'Expected %s but got %s!' % (j,i))
Exemplo n.º 3
0
 def testUnicodeFields(self):
     self.field.seal()
     unicodeArray = numpy.array([u'Hallo World!',u'Hallo Wörld!'])
     unicodeField = FieldContainer(unicodeArray,longname=u"blabla",
                                 shortname=self.shortname,
                                 unit = 1,
                                 attributes = self.attributes
                                 )
     unicodeField.seal()
     self.eln.createGroup(self.eln.root,'testUnicodeFields')
     saveField(self.eln,self.eln.root.testUnicodeFields,unicodeField)
     restoredField = loadField(self.eln,self.eln.root.testUnicodeFields)
     self.assertEqual(restoredField,unicodeField,
                      "Restored unicode string is %s (%s) but is expected to be %s (%s)." % (restoredField.data,restoredField.data.dtype,unicodeField.data,unicodeField.data.dtype))