本文整理汇总了Python中qctoolkit.pulses.table_pulse_template.TablePulseTemplate.add_entry方法的典型用法代码示例。如果您正苦于以下问题:Python TablePulseTemplate.add_entry方法的具体用法?Python TablePulseTemplate.add_entry怎么用?Python TablePulseTemplate.add_entry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qctoolkit.pulses.table_pulse_template.TablePulseTemplate
的用法示例。
在下文中一共展示了TablePulseTemplate.add_entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_entry_for_interpolation
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_add_entry_for_interpolation(self) -> None:
table = TablePulseTemplate()
strategies = ["linear","hold","jump","hold"]
for i,strategy in enumerate(strategies):
table.add_entry(2*(i+1), i+1, strategy)
self.assertRaises(ValueError, table.add_entry, 1,2, "bar")
示例2: generate_TablePulseTemplates
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def generate_TablePulseTemplates(self,number_of_entries,max_dist=RANGE):
while 1:
x = TablePulseTemplate()
name = "TablePulseTemplate_{}".format(self.__TablePulseTemplateOffset)
self.__TablePulseTemplateOffset +=1
if bool(random.getrandbits(1)):
x.identifier = name
previous_min = 0
previous_max = 0
parameter_names = []
for i in range(number_of_entries):
dict_ = {}
for j in ["time","voltage"]:
a = random.choice(["float","str","ParameterDeclaration"])
if a == "float":
if j == "time":
dict_[j] = random.uniform(previous_max,previous_max+max_dist)
previous_min = dict_[j]
previous_max = dict_[j]
else:
dict_[j] = random.uniform(-RANGE,RANGE)
elif a == "str":
dict_[j] = "_".join([name,"str",str(i),str(j)])
parameter_names.append(dict_[j])
elif a == "ParameterDeclaration":
if j == "time":
dict_[j] = self.generate_ParameterDeclaration(previous_min, previous_min+max_dist, name, previous_max).__next__()
previous_min = dict_[j].min_value
previous_max = dict_[j].max_value
else:
dict_[j] = self.generate_ParameterDeclaration().__next__()
parameter_names.append(dict_[j].name)
x.add_entry(time=dict_["time"],voltage=dict_["voltage"],interpolation=random.choice(INTERPOLATION_STRATEGIES))
yield x
示例3: test_add_entry_empty_time_is_0_voltage_is_parameter
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_add_entry_empty_time_is_0_voltage_is_parameter(self) -> None:
table = TablePulseTemplate()
table.add_entry(0, 'foo')
decl = ParameterDeclaration('foo')
self.assertEqual([(0, decl, HoldInterpolationStrategy())], table.entries)
self.assertEqual({'foo'}, table.parameter_names)
self.assertEqual({decl}, table.parameter_declarations)
示例4: test_add_entry_empty_time_is_str
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_add_entry_empty_time_is_str(self) -> None:
table = TablePulseTemplate()
table.add_entry('t', 0)
decl = ParameterDeclaration('t', min=0)
self.assertEqual([(0, 0, HoldInterpolationStrategy()), (decl, 0, HoldInterpolationStrategy())], table.entries)
self.assertEqual({'t'}, table.parameter_names)
self.assertEqual({decl}, table.parameter_declarations)
示例5: test_no_measurement_windows
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_no_measurement_windows(self) -> None:
pulse = TablePulseTemplate(measurement=False)
pulse.add_entry(1, 1)
pulse.add_entry(3, 0)
pulse.add_entry(5, 0)
windows = pulse.get_measurement_windows()
self.assertEqual([], windows)
示例6: test_add_entry_empty_time_is_declaration
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_add_entry_empty_time_is_declaration(self) -> None:
table = TablePulseTemplate()
decl = ParameterDeclaration('foo')
table.add_entry(decl, 0)
decl.min_value = 0
self.assertEqual([(0, 0, HoldInterpolationStrategy()), (decl, 0, HoldInterpolationStrategy())], table.entries)
self.assertEqual({'foo'}, table.parameter_names)
self.assertEqual({decl}, table.parameter_declarations)
示例7: test_add_entry_time_declaration_lower_min_after_float
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_add_entry_time_declaration_lower_min_after_float(self) -> None:
table = TablePulseTemplate()
table.add_entry(3.2, 92.1)
decl = ParameterDeclaration('t', min=0.1)
self.assertRaises(ValueError, table.add_entry, decl, 1.2)
self.assertEqual([(0, 0, HoldInterpolationStrategy()), (3.2, 92.1, HoldInterpolationStrategy())], table.entries)
self.assertFalse(table.parameter_names)
self.assertFalse(table.parameter_declarations)
示例8: test_add_entry_time_declaration_higher_min_after_float
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_add_entry_time_declaration_higher_min_after_float(self) -> None:
table = TablePulseTemplate()
table.add_entry(3.2, 92.1)
decl = ParameterDeclaration('t', min=4.5)
table.add_entry(decl, 1.2)
self.assertEqual([(0, 0, HoldInterpolationStrategy()), (3.2, 92.1, HoldInterpolationStrategy()), (decl, 1.2, HoldInterpolationStrategy())], table.entries)
self.assertEqual({'t'}, table.parameter_names)
self.assertEqual({decl}, table.parameter_declarations)
示例9: test_add_entry_known_interpolation_strategies
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_add_entry_known_interpolation_strategies(self) -> None:
table = TablePulseTemplate()
strategies = ["linear", "hold", "jump"]
for i,strategy in enumerate(strategies):
table.add_entry(i, i, strategy)
manual = [(0,0,LinearInterpolationStrategy()), (1,1,HoldInterpolationStrategy()), (2,2,JumpInterpolationStrategy())]
self.assertEqual(manual, table.entries)
示例10: test_add_entry_time_float_after_declaration_smaller_bound
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_add_entry_time_float_after_declaration_smaller_bound(self) -> None:
table = TablePulseTemplate()
decl = ParameterDeclaration('t', min=1.0, max=1.3)
table.add_entry(decl, 7.1)
table.add_entry(2.1, 5.5)
self.assertEqual([(0, 0, HoldInterpolationStrategy()), (decl, 7.1, HoldInterpolationStrategy()), (2.1, 5.5, HoldInterpolationStrategy())], table.entries)
self.assertEqual({'t'}, table.parameter_names)
self.assertEqual({decl}, table.parameter_declarations)
示例11: test_get_entries_instantiated_two_entries_invalid_parameters
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_get_entries_instantiated_two_entries_invalid_parameters(self) -> None:
table = TablePulseTemplate()
table.add_entry(0, 'v1')
t_decl = ParameterDeclaration('t', min=1, max=2)
v2_decl = ParameterDeclaration('v2', min=10, max=30)
table.add_entry(t_decl, v2_decl)
self.assertRaises(ParameterValueIllegalException, table.get_entries_instantiated, {'v1': -5, 't': 0, 'v2': 20})
self.assertRaises(ParameterValueIllegalException, table.get_entries_instantiated, {'v1': -5, 't': 1, 'v2': -20})
示例12: test_add_entry_voltage_declaration_in_use_as_time
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_add_entry_voltage_declaration_in_use_as_time(self) -> None:
table = TablePulseTemplate()
foo_decl = ParameterDeclaration('foo', min=0, max=2)
table.add_entry(foo_decl, 0)
self.assertRaises(ValueError, table.add_entry, 4, foo_decl)
self.assertEqual([(0, 0, HoldInterpolationStrategy()), (foo_decl, 0, HoldInterpolationStrategy())], table.entries)
self.assertEqual({'foo'}, table.parameter_names)
self.assertEqual({foo_decl}, table.parameter_declarations)
示例13: test_add_entry_time_declaration_lower_bound_after_declaration_upper_bound
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_add_entry_time_declaration_lower_bound_after_declaration_upper_bound(self) -> None:
table = TablePulseTemplate()
bar_decl = ParameterDeclaration('bar', min=1, max=2)
foo_decl = ParameterDeclaration('foo', min=1)
table.add_entry(bar_decl, -3)
table.add_entry(foo_decl, 0.1)
self.assertEqual([(0, 0, HoldInterpolationStrategy()), (bar_decl, -3, HoldInterpolationStrategy()), (foo_decl, 0.1, HoldInterpolationStrategy())], table.entries)
self.assertEqual({'foo', 'bar'}, table.parameter_names)
self.assertEqual({foo_decl, bar_decl}, table.parameter_declarations)
示例14: test_add_entry_time_parmeter_name_in_use_as_time
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_add_entry_time_parmeter_name_in_use_as_time(self) -> None:
table = TablePulseTemplate()
table.add_entry('foo', 'bar')
foo_decl = ParameterDeclaration('foo', min=0)
bar_decl = ParameterDeclaration('bar')
self.assertRaises(ValueError, table.add_entry, ParameterDeclaration('foo'), 3.4)
self.assertEqual([(0, 0, HoldInterpolationStrategy()), (foo_decl, bar_decl, HoldInterpolationStrategy())], table.entries)
self.assertEqual({'foo', 'bar'}, table.parameter_names)
self.assertEqual({foo_decl, bar_decl}, table.parameter_declarations)
示例15: test_add_entry_time_float_after_declaration_greater_bound
# 需要导入模块: from qctoolkit.pulses.table_pulse_template import TablePulseTemplate [as 别名]
# 或者: from qctoolkit.pulses.table_pulse_template.TablePulseTemplate import add_entry [as 别名]
def test_add_entry_time_float_after_declaration_greater_bound(self) -> None:
table = TablePulseTemplate()
decl = ParameterDeclaration('t', max=3.4)
table.add_entry(decl, 7.1)
decl.min_value = 0
self.assertRaises(ValueError, table.add_entry, 2.1, 5.5)
self.assertEqual([(0, 0, HoldInterpolationStrategy()), (decl, 7.1, HoldInterpolationStrategy())], table.entries)
self.assertEqual({'t'}, table.parameter_names)
self.assertEqual({decl}, table.parameter_declarations)