Пример #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)
    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)
Пример #3
0
    def __qupulse_serialize(sequence):
        """ Converts a qupulse sequence into a JSON string.

        Args:
            sequence (dict): A sequence created using the sequencer.

        Returns:
            Str: A JSON string with the sequence data.
        """
        backend = DictBackend()
        serializer = Serializer(backend)
        return serializer.serialize(sequence, overwrite=True)