Exemple #1
0
    def test_serializer_integration_old(self):
        # test for deprecated version during transition period, remove after final switch
        with self.assertWarnsRegex(
                DeprecationWarning,
                "deprecated",
                msg=
                "FunctionPT does not issue warning for old serialization routines."
        ):
            before = FunctionPulseTemplate(
                expression=self.s,
                duration_expression=self.s2,
                channel='A',
                measurements=self.meas_list,
                parameter_constraints=self.constraints,
                identifier='my_tpt',
                registry=dict())
            serializer = Serializer(DummyStorageBackend())
            serializer.serialize(before)
            after = serializer.deserialize('my_tpt')

            self.assertIsInstance(after, FunctionPulseTemplate)
            self.assertEqual(before.expression, after.expression)
            self.assertEqual(before.duration, after.duration)
            self.assertEqual(before.defined_channels, after.defined_channels)

            self.assertEqual(before.measurement_declarations,
                             after.measurement_declarations)
            self.assertEqual(before.parameter_constraints,
                             after.parameter_constraints)
Exemple #2
0
    def deserialize(json_string):
        """ Convert a JSON string into a sequencer object.

        Args:
            json_string: The JSON data containing the sequencer obect.

        Returns:
            Dict: *NAME*, *TYPE*, *WAVE* keys containing values; sequence name,
                  sequence data type and the actual qupulse sequencePT respectively.
        """
        backend = DictBackend()
        serializer = Serializer(backend)
        return serializer.deserialize(json_string)
    def test_serializer_integration_old(self):
        registry = dict()

        # test for deprecated version during transition period, remove after final switch
        with self.assertWarnsRegex(DeprecationWarning, "deprecated",
                                   msg="PointPT does not issue warning for old serialization routines."):
            serializer = Serializer(DummyStorageBackend())
            serializer.serialize(self.template)
            template = serializer.deserialize('foo')

            self.assertIsInstance(template, PointPulseTemplate)
            self.assertEqual(template.point_pulse_entries, self.template.point_pulse_entries)
            self.assertEqual(template.measurement_declarations, self.template.measurement_declarations)
            self.assertEqual(template.parameter_constraints, self.template.parameter_constraints)
 def deserialize_pulse(self):
     serializer = Serializer(
         FilesystemBackend(os.path.join(self.data_folder, 'pulse_storage')))
     self.pulse = typing.cast(PulseTemplate,
                              serializer.deserialize(self.pulse_name))