当前位置: 首页>>代码示例>>Python>>正文


Python table_pulse_template.TablePulseTemplate类代码示例

本文整理汇总了Python中qctoolkit.pulses.table_pulse_template.TablePulseTemplate的典型用法代码示例。如果您正苦于以下问题:Python TablePulseTemplate类的具体用法?Python TablePulseTemplate怎么用?Python TablePulseTemplate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TablePulseTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_add_entry_for_interpolation

    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")
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:7,代码来源:table_pulse_template_tests.py

示例2: test_add_entry_empty_time_is_str

 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)
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:7,代码来源:table_pulse_template_tests.py

示例3: test_add_entry_empty_time_is_0_voltage_is_parameter

 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)
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:7,代码来源:table_pulse_template_tests.py

示例4: generate_TablePulseTemplates

 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
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:35,代码来源:sample_pulse_generator.py

示例5: test_add_entry_time_float_after_declaration_smaller_bound

 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)
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:8,代码来源:table_pulse_template_tests.py

示例6: test_add_entry_empty_time_is_declaration

 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)
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:8,代码来源:table_pulse_template_tests.py

示例7: test_add_entry_known_interpolation_strategies

    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)
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:8,代码来源:table_pulse_template_tests.py

示例8: test_add_entry_time_declaration_lower_min_after_float

 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)
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:8,代码来源:table_pulse_template_tests.py

示例9: test_add_entry_voltage_declaration_in_use_as_time

 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)
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:8,代码来源:table_pulse_template_tests.py

示例10: test_get_entries_instantiated_two_entries_invalid_parameters

 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})
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:8,代码来源:table_pulse_template_tests.py

示例11: test_add_entry_time_declaration_higher_min_after_float

 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)
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:8,代码来源:table_pulse_template_tests.py

示例12: test_add_entry_time_float_after_declaration_greater_bound

 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)
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:9,代码来源:table_pulse_template_tests.py

示例13: test_add_entry_time_declaration_lower_bound_upper_bound_too_small_after_declaration

 def test_add_entry_time_declaration_lower_bound_upper_bound_too_small_after_declaration(self) -> None:
     table = TablePulseTemplate()
     bar_decl = ParameterDeclaration('bar', min=1, max=2)
     foo_decl = ParameterDeclaration('foo', min=1, max=1.5)
     table.add_entry(bar_decl, -3)
     self.assertRaises(ValueError, table.add_entry, foo_decl, 0.1)
     self.assertEqual([(0, 0, HoldInterpolationStrategy()), (bar_decl, -3, HoldInterpolationStrategy())], table.entries)
     self.assertEqual({'bar'}, table.parameter_names)
     self.assertEqual({bar_decl}, table.parameter_declarations)
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:9,代码来源:table_pulse_template_tests.py

示例14: test_add_entry_time_declaration_lower_bound_after_declaration_upper_bound

 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)
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:9,代码来源:table_pulse_template_tests.py

示例15: test_add_entry_time_parmeter_name_in_use_as_time

 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)
开发者ID:carriercomm,项目名称:qc-toolkit,代码行数:9,代码来源:table_pulse_template_tests.py


注:本文中的qctoolkit.pulses.table_pulse_template.TablePulseTemplate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。