本文整理汇总了Python中qctoolkit.pulses.table_pulse_template.TablePulseTemplate.deserialize方法的典型用法代码示例。如果您正苦于以下问题:Python TablePulseTemplate.deserialize方法的具体用法?Python TablePulseTemplate.deserialize怎么用?Python TablePulseTemplate.deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qctoolkit.pulses.table_pulse_template.TablePulseTemplate
的用法示例。
在下文中一共展示了TablePulseTemplate.deserialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_deserialize
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import deserialize [as 别名]
def test_deserialize(self) -> None:
data = dict(is_measurement_pulse=True,
time_parameter_declarations=[dict(name='hugo'), dict(name='foo')],
voltage_parameter_declarations=[dict(name='ilse')],
entries=[(0, 0, 'hold'), ('foo', 2, 'hold'), ('hugo', 'ilse', 'linear')],
identifier='foo')
# prepare dependencies for deserialization
self.serializer.subelements['foo'] = ParameterDeclaration('foo')
self.serializer.subelements['hugo'] = ParameterDeclaration('hugo')
self.serializer.subelements['ilse'] = ParameterDeclaration('ilse')
# deserialize
template = TablePulseTemplate.deserialize(self.serializer, **data)
# prepare expected parameter declarations
self.serializer.subelements['foo'].min_value = 0
self.serializer.subelements['foo'].max_value = self.serializer.subelements['hugo']
all_declarations = set(self.serializer.subelements.values())
# prepare expected entries
entries = [(0, 0, HoldInterpolationStrategy()),
(self.serializer.subelements['foo'], 2, HoldInterpolationStrategy()),
(self.serializer.subelements['hugo'], self.serializer.subelements['ilse'], LinearInterpolationStrategy())]
# compare!
self.assertEqual(all_declarations, template.parameter_declarations)
self.assertEqual({'foo', 'hugo', 'ilse'}, template.parameter_names)
self.assertEqual(entries, template.entries)
self.assertEqual('foo', template.identifier)