def __init__(self):
        QtGui.QMainWindow.__init__(self)

        pathcandidates = [
            os.path.curdir,
            os.path.join(os.path.pardir, "qt"),
            os.path.join(imp.find_module("mtb")[1], "qt")
        ]

        self.gui = None
        for path in pathcandidates:
            try:
                uifile = os.path.join(path, "task_frontend.ui")
                self.gui = uic.loadUi(uifile)
                print "loaded " + uifile
                break
            except IOError:
                pass
        if self.gui is None:
            raise IOError("could not find task_frontend.ui")
        self.__lastrow = -1
        self.__lastvar = None
        self.__enable_cell_checks = False
        self.__enable_sink_checks = False

        for s in TYPE_STRINGS:
            self.gui.param_type.addItem(s)
        self.connect(self.gui.open_json, SIGNAL("activated()"),
                     lambda: self.load_json_file())
        self.connect(self.gui.save_json, SIGNAL("activated()"),
                     lambda: self.save_json_file())
        self.connect(self.gui.import_tb, SIGNAL("activated()"),
                     lambda: self.import_tb())
        self.connect(self.gui.import_grc, SIGNAL("activated()"),
                     lambda: self.import_grc())
        self.connect(self.gui.variable_table, SIGNAL("cellClicked(int,int)"),
                     lambda row, col: self._cell_clicked(row, col))
        self.connect(self.gui.variable_table, SIGNAL("cellActivated(int,int)"),
                     lambda row, col: self._cell_clicked(row, col))
        self.connect(self.gui.variable_table, SIGNAL("cellChanged(int,int)"),
                     lambda row, col: self._cell_changed(row, col))
        self.connect(self.gui.sink_table, SIGNAL("cellChanged(int,int)"),
                     lambda row, col: self._sink_changed(row, col))
        self.connect(self.gui.add_button, SIGNAL("clicked()"),
                     lambda: self._add_var())
        self.connect(self.gui.add_sink_button, SIGNAL("clicked()"),
                     lambda: self._add_sink())
        self.connect(self.gui.del_sink_button, SIGNAL("clicked()"),
                     lambda: self._del_sink())
        self.connect(self.gui.run_task, SIGNAL("activated()"),
                     lambda: self.run_task())
        self.connect(self.gui.param_type, SIGNAL("currentIndexChanged(int)"),
                     lambda idx: self._type_changed(idx))
        self.connect(self.gui.task_type, SIGNAL("currentIndexChanged(int)"),
                     lambda idx: self._task_type_changed(idx))
        self.gui.show()
        self.task = task()
        self.__enable_cell_checks = True
Пример #2
0
    def test_009_grid(self):
        task = benchmarking_task.task()
        ns = [5, 7, 13]
        for n in ns:
            task.set_parametrization("var_range_"+str(n), benchmarking_task.parametrization(benchmarking_task.LIN_RANGE, (0,1,n)))
        ns.append(2)
        task.set_parametrization("var_list", benchmarking_task.parametrization(benchmarking_task.LIST, [0,1]))
        ns.append(1)
        task.set_parametrization("var_static", benchmarking_task.parametrization(benchmarking_task.STATIC, numpy.pi))

        total_should = reduce(lambda x,y: x*y, ns, 1)
        grid, constants, names = task.get_parameter_set()
        self.assertEqual(len(grid) , total_should)
        self.assertSequenceEqual(constants, [task.variables["var_static"].get_values()])
Пример #3
0
 def test_005_task_json_save(self):
     task = benchmarking_task.task("class", "module")
     task.set_parametrization("static_test_variable", 
         benchmarking_task.parametrization(benchmarking_task.STATIC,numpy.pi, numpy.dtype("float32").type))
     task.set_parametrization("range_test_variable", 
         benchmarking_task.parametrization(benchmarking_task.LIN_RANGE, self.range_spec) )
     task.set_parametrization("list_test_variable", 
         benchmarking_task.parametrization(benchmarking_task.LIST, [10,20,30], int) )
     task.sinks = self.ref_task_dic["sinks"]
     outfile = tempfile.NamedTemporaryFile(delete=False,suffix=".json")
     task.save(outfile)
     outfile.close()
     infile = open(outfile.name)
     resdic = json.load(infile)
     self.assert_(helpers.comp_dict(resdic, self.ref_task_dic))
     infile.close()
Пример #4
0
    def test_008_total_points(self):
        task = benchmarking_task.task()
        l_noise     = 100
        l_signal    = 13
        task.set_parametrization("noise_power",  benchmarking_task.parametrization(benchmarking_task.LIST, range(l_noise), int))
        task.set_parametrization("signal_power", benchmarking_task.parametrization(benchmarking_task.LIN_RANGE, (0,10,l_signal)))
        task.set_parametrization("sample_rate", benchmarking_task.parametrization())
        task.set_parametrization("threshold", benchmarking_task.parametrization(benchmarking_task.STATIC, 1.0/numpy.pi))

        points = task.get_total_points()
        self.assertEqual(points, l_noise*l_signal * 1 * 1)

        n = 20

        tasks = task.split(n)
        self.assertEqual(len(tasks), 20)
        self.assertEqual(sum([t.get_total_points() for t in tasks]), points)
 def test_005_task_json_save(self):
     task = benchmarking_task.task("class", "module")
     task.set_parametrization(
         "static_test_variable",
         benchmarking_task.parametrization(benchmarking_task.STATIC,
                                           numpy.pi,
                                           numpy.dtype("float32").type))
     task.set_parametrization(
         "range_test_variable",
         benchmarking_task.parametrization(benchmarking_task.LIN_RANGE,
                                           self.range_spec))
     task.set_parametrization(
         "list_test_variable",
         benchmarking_task.parametrization(benchmarking_task.LIST,
                                           [10, 20, 30], int))
     outfile = StringIO.StringIO()
     task.save(outfile)
     outfile.seek(0)
     resdic = json.load(outfile)
     self.assert_(helpers.comp_dict(resdic, self.ref_task_dic))
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        pathcandidates = [os.path.curdir, os.path.join(os.path.pardir, "qt"), os.path.join(imp.find_module("mtb")[1], "qt")]

        self.gui = None
        for path in pathcandidates:
            try:
                uifile = os.path.join(path, "task_frontend.ui")
                self.gui = uic.loadUi(uifile)
                print "loaded "+uifile
                break
            except IOError:
                pass
        if self.gui is None:
            raise IOError("could not find task_frontend.ui")        
        self.__lastrow = -1
        self.__lastvar = None
        self.__enable_cell_checks = False
        self.__enable_sink_checks = False
        
        for s in TYPE_STRINGS:
            self.gui.param_type.addItem(s)
        self.connect(self.gui.open_json, SIGNAL("activated()"), lambda: self.load_json_file())
        self.connect(self.gui.save_json, SIGNAL("activated()"), lambda: self.save_json_file())
        self.connect(self.gui.import_tb, SIGNAL("activated()"), lambda: self.import_tb())
        self.connect(self.gui.import_grc, SIGNAL("activated()"), lambda: self.import_grc())
        self.connect(self.gui.variable_table, SIGNAL("cellClicked(int,int)"), lambda row, col: self._cell_clicked(row,col))
        self.connect(self.gui.variable_table, SIGNAL("cellActivated(int,int)"), lambda row, col: self._cell_clicked(row,col))
        self.connect(self.gui.variable_table, SIGNAL("cellChanged(int,int)"), lambda row, col: self._cell_changed(row,col))
        self.connect(self.gui.sink_table, SIGNAL("cellChanged(int,int)"), lambda row, col: self._sink_changed(row,col))
        self.connect(self.gui.add_button, SIGNAL("clicked()"), lambda: self._add_var())
        self.connect(self.gui.add_sink_button, SIGNAL("clicked()"), lambda: self._add_sink())
        self.connect(self.gui.del_sink_button, SIGNAL("clicked()"), lambda: self._del_sink())
        self.connect(self.gui.run_task, SIGNAL("activated()"), lambda: self.run_task())
        self.connect(self.gui.param_type, SIGNAL("currentIndexChanged(int)"), lambda idx: self._type_changed(idx))
        self.connect(self.gui.task_type, SIGNAL("currentIndexChanged(int)"), lambda idx: self._task_type_changed(idx))
        self.gui.show()
        self.task = task()
        self.__enable_cell_checks = True