def update_table(self, fusers, relations):
     self.clear()
     self.setRowCount(0)
     self.setColumnCount(len(fusers))
     self.setHorizontalHeaderLabels([fuser[0].name for fuser in fusers.values()])
     for id, relation in relations.items():
         row = self.rowCount()
         self.insertRow(row)
         if not np.ma.is_masked(relation.data):
             widget.warning(id, 'Relation "{}" has no missing values '
                                '(mask)'.format(relation_str(relation)))
         rmses = []
         for fuser in fusers.values():
             rep_rmse = []
             for fuserfit in fuser:
                 if not fuserfit.can_complete(relation):
                     break
                 completion = fuserfit.complete(relation)
                 rep_rmse.append(RMSE(relation.data, completion))
             rmses.append(np.mean(rep_rmse) if rep_rmse else None)
         try: min_rmse = min(e for e in rmses if e is not None)
         except ValueError: continue # No fuser could complete this relation
         for col, rmse in enumerate(rmses):
             if rmse is None: continue
             item = QTableWidgetItem('{:.05f}'.format(rmse))
             item.setFlags(Qt.ItemIsEnabled)
             if rmse == min_rmse and len(rmses) > 1:
                 item.setFont(BOLD_FONT)
             self.setItem(row, col, item)
     self.setVerticalHeaderLabels([relation_str(i) for i in relations.values()])
     self.resizeColumnsToContents()
     self.resizeRowsToContents()
Example #2
0
    def __init__(self, lights, parent):
        super(LightConfigUI, self).__init__()
        self.title = 'Lighting Configuration'
        self.setLayout(QVBoxLayout(self))
        self.layout().setAlignment(Qt.AlignCenter)
        self.parent = parent
        self.lights = lights

        # Init logger
        self.logger = Logger('lightConfig', "UI : LightConfig", level='debug')

        # Create layout
        self._plus = QPushButton('+', self)
        self._plus.clicked.connect(self.__createLight)
        self._minus = QPushButton('-', self)
        self._minus.clicked.connect(self.__destroyLight)
        _panel = QWidget(self)
        _panel.setLayout(QHBoxLayout(_panel))
        _panel.layout().setAlignment(Qt.AlignRight)
        _panel.layout().addWidget(self._plus)
        _panel.layout().addWidget(self._minus)
        self.layout().addWidget(_panel)
        self._lightsList = QTableWidget(0, 5, self)
        self._lightsList.setSelectionBehavior(QAbstractItemView.SelectRows)
        self._lightsList.setHorizontalHeaderLabels(
            ['Name', 'Output Pin', 'Enabled', 'Icon', 'Strobe'])
        self._lightsList.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)
        self.keyPressed.connect(self.__onKey)
        self.layout().addWidget(self._lightsList)
        self._editBtn = QPushButton('Edit', self)
        self._editBtn.clicked.connect(self.__editLight)
        self.layout().addWidget(self._editBtn)
        self._closeBtn = QPushButton('Close', self)
        self._closeBtn.clicked.connect(self.__closeBtnAction)
        self.layout().addWidget(self._closeBtn)

        # Populate table
        for _light in self.lights:
            _i = self._lightsList.rowCount()
            self._lightsList.setRowCount(_i + 1)
            for _c, _item in enumerate([
                    _light.name,
                    str(_light.outputPin),
                    str(_light.enabled), _light.icon,
                    str(_light.strobe)
            ]):
                _tblItem = QTableWidgetItem(_item)
                _tblItem.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
                self._lightsList.setItem(_i, _c, _tblItem)
Example #3
0
    def __init__(self, obas, parent):
        super(OBAConfigUI, self).__init__()
        self.title = 'OnBoard Air Configuration'
        self.setLayout(QVBoxLayout(self))
        self.layout().setAlignment(Qt.AlignCenter)
        self.parent = parent
        self.obas = obas

        # Init logger
        self.logger = Logger('obaConfig', "UI : OBAConfig")

        # Create layout
        self._plus = QPushButton('+', self)
        self._plus.clicked.connect(self.__createOBA)
        self._minus = QPushButton('-', self)
        self._minus.clicked.connect(self.__destroyOBA)
        _panel = QWidget(self)
        _panel.layout = QHBoxLayout(_panel)
        _panel.layout.setAlignment(Qt.AlignRight)
        _panel.layout.addWidget(self._plus)
        _panel.layout.addWidget(self._minus)
        self.layout().addWidget(_panel)
        self._obaList = QTableWidget(0, 5, self)
        self._obaList.setSelectionBehavior(QAbstractItemView.SelectRows)
        self._obaList.setHorizontalHeaderLabels(
            ['Name', 'Output Pin', 'Momentary', 'Enabled', 'Icon'])
        self._obaList.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)
        self.keyPressed.connect(self.__onKey)
        self.layout().addWidget(self._obaList)
        self._editBtn = QPushButton('Edit', self)
        self._editBtn.clicked.connect(self.__editOBA)
        self.layout().addWidget(self._editBtn)
        self._closeBtn = QPushButton('Close', self)
        self._closeBtn.clicked.connect(self.__closeBtnAction)
        self.layout().addWidget(self._closeBtn)

        # Populate table
        for _oba in self.obas:
            _i = self._obaList.rowCount()
            self._obaList.setRowCount(_i + 1)
            for _c, _item in enumerate([
                    _oba.name,
                    str(_oba.outputPin),
                    str(_oba.momentary),
                    str(_oba.enabled), _oba.icon
            ]):
                _tblItem = QTableWidgetItem(_item)
                _tblItem.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
                self._obaList.setItem(_i, _c, _tblItem)
Example #4
0
 def update_table(self, fusers, relations):
     self.clear()
     self.setRowCount(0)
     self.setColumnCount(len(fusers))
     self.setHorizontalHeaderLabels(
         [fuser[0].name for fuser in fusers.values()])
     for id, relation in relations.items():
         row = self.rowCount()
         self.insertRow(row)
         if not np.ma.is_masked(relation.data):
             widget.warning(
                 id, 'Relation "{}" has no missing values '
                 '(mask)'.format(relation_str(relation)))
         rmses = []
         for fuser in fusers.values():
             rep_rmse = []
             for fuserfit in fuser:
                 if not fuserfit.can_complete(relation):
                     break
                 completion = fuserfit.complete(relation)
                 rep_rmse.append(RMSE(relation.data, completion))
             rmses.append(np.mean(rep_rmse) if rep_rmse else None)
         try:
             min_rmse = min(e for e in rmses if e is not None)
         except ValueError:
             continue  # No fuser could complete this relation
         for col, rmse in enumerate(rmses):
             if rmse is None: continue
             item = QTableWidgetItem('{:.05f}'.format(rmse))
             item.setFlags(Qt.ItemIsEnabled)
             if rmse == min_rmse and len(rmses) > 1:
                 item.setFont(BOLD_FONT)
             self.setItem(row, col, item)
     self.setVerticalHeaderLabels(
         [relation_str(i) for i in relations.values()])
     self.resizeColumnsToContents()
     self.resizeRowsToContents()