Esempio n. 1
0
 def test_save_load_unsigned(self):
     c1 = Calibration()
     c1.current_offset = CAL1_IK[:7]
     c1.current_gain = CAL1_1G[:7]
     c1.voltage_offset = CAL1_VK
     c1.voltage_gain = CAL1_VG
     data = c1.save()
     c2 = Calibration().load(data, keys=[])
     self.assertFalse(c2.signed)
     np.testing.assert_allclose(CAL1_VK, c2.voltage_offset)
     np.testing.assert_allclose(CAL1_VG, c2.voltage_gain)
     np.testing.assert_allclose(CAL1_IK, c2.current_offset)
     np.testing.assert_allclose(CAL1_1G, c2.current_gain)
Esempio n. 2
0
 def test_save_load_signed(self):
     c1 = Calibration()
     c1.current_offset = CAL1_IK[:7]
     c1.current_gain = CAL1_1G[:7]
     c1.voltage_offset = CAL1_VK
     c1.voltage_gain = CAL1_VG
     data = c1.save(PRIVATE_KEY)
     # with open(os.path.join(MYPATH, 'calibration_01.dat'), 'wb') as f:
     #     f.write(data)
     c2 = Calibration().load(data, keys=[PUBLIC_KEY])
     self.assertTrue(c2.signed)
     np.testing.assert_allclose(CAL1_VK, c2.voltage_offset)
     np.testing.assert_allclose(CAL1_VG, c2.voltage_gain)
     np.testing.assert_allclose(CAL1_IK, c2.current_offset)
     np.testing.assert_allclose(CAL1_1G, c2.current_gain)