def test_numpress_slof(self): data = mzml_spectra[0]['intensity array'] encoded = base64.b64encode( pynumpress.encode_slof(data, pynumpress.optimal_slof_fixed_point( data)).tobytes()).decode('ascii') record = aux.BinaryDataArrayTransformer()._make_record( encoded, 'MS-Numpress short logged float compression', data.dtype) self.assertTrue(np.allclose(data, record.decode(), rtol=0.001))
def test_encode_decode_slof(self): """ """ # pynumpress.decoded_data = self.i_slof_data print(self.i_slof_data) fp = pynumpress.optimal_slof_fixed_point(self.i_slof_data) encoded_array = pynumpress.encode_slof( np.asarray(self.i_slof_data, dtype=np.float64), fp) decoded_array = pynumpress.decode_slof(encoded_array) for i, dec in enumerate(decoded_array): self.assertAlmostEqual(dec, self.i_slof_data[i], places=2)
def test_encode_decode_slof(self): """ """ # pynumpress.decoded_data = self.i_slof_data print(self.i_slof_data) fp = pynumpress.optimal_slof_fixed_point(self.i_slof_data) encoded_array = pynumpress.encode_slof( np.asarray(self.i_slof_data, dtype=np.float64), fp ) decoded_array = pynumpress.decode_slof(encoded_array) for i, dec in enumerate(decoded_array): self.assertAlmostEqual(dec, self.i_slof_data[i], places=2)
def test_encode_slof(self): fp = pynumpress.optimal_slof_fixed_point(self.i_slof_data) encoded_array = pynumpress.encode_slof(np.asarray(self.i_slof_data, dtype=np.float64), fp) self.assertEqual(len(encoded_array), 14) self.assertEqual(encoded_array[0], 0x40) self.assertEqual(encoded_array[1], 0xe3) self.assertEqual(encoded_array[2], 0xe1) self.assertEqual(encoded_array[3], 0xe0) self.assertEqual(encoded_array[4], 0x0) self.assertEqual(encoded_array[5], 0x0) self.assertEqual(encoded_array[6], 0x0) self.assertEqual(encoded_array[7], 0x0) self.assertEqual(encoded_array[8], 0x40) self.assertEqual(encoded_array[9], 0x6e) self.assertEqual(encoded_array[10], 0xbe) self.assertEqual(encoded_array[11], 0xae) self.assertEqual(encoded_array[12], 0xff) self.assertEqual(encoded_array[13], 0xff)