示例#1
0
    def __init__(self):
        super().__init__('Dataset - additional parameters', '')
        g_layout = QGridLayout()
        self.layout.addLayout(g_layout)
        self.params = {'target_idx': 0,
                       'data_type': float,
                       'delimiter': ','}

        target_label = CustomLabel('Target index')
        target_edit = CustomTextBox()
        target_edit.setValidator(ArithmeticValidator.INT)
        target_edit.textChanged. \
            connect(lambda: self.update_dict('target_idx', target_edit.text()))
        g_layout.addWidget(target_label, 0, 0)
        g_layout.addWidget(target_edit, 0, 1)

        data_type_label = CustomLabel('Data type')
        data_type_edit = CustomComboBox()
        data_type_edit.addItems(['float', 'int'])
        data_type_edit.activated. \
            connect(lambda: self.update_dict('data_type', data_type_edit.currentText()))
        g_layout.addWidget(data_type_label, 1, 0)
        g_layout.addWidget(data_type_edit, 1, 1)

        delimiter_label = CustomLabel('Delimiter character')
        delimiter_edit = CustomTextBox(',')
        delimiter_edit.textChanged. \
            connect(lambda: self.update_dict('delimiter', delimiter_edit.text()))
        g_layout.addWidget(delimiter_label, 2, 0)
        g_layout.addWidget(delimiter_edit, 2, 1)

        self.cancel_btn.clicked.connect(self.reset)
        self.render_layout()
示例#2
0
class EditNodeInputDialog(NeVerDialog):
    def __init__(self, node_block: NodeBlock):
        super().__init__(node_block.node.name, "")
        self.layout = QGridLayout()

        # Connect node
        self.node = node_block
        self.new_in_dim = ','.join(map(str, node_block.in_dim))
        self.in_dim_box = CustomTextBox()
        self.has_edits = False

        # Build main_layout
        title_label = CustomLabel("Edit network input")
        title_label.setStyleSheet(style.NODE_LABEL_STYLE)
        title_label.setAlignment(Qt.AlignCenter)
        self.layout.addWidget(title_label, 0, 0, 1, 2)

        # Input box
        in_dim_label = CustomLabel("Input shape")
        in_dim_label.setStyleSheet(style.IN_DIM_LABEL_STYLE)
        in_dim_label.setAlignment(Qt.AlignRight)
        self.layout.addWidget(in_dim_label, 1, 0)

        self.in_dim_box.setText(self.new_in_dim)
        self.in_dim_box.setValidator(ArithmeticValidator.TENSOR)

        self.layout.addWidget(self.in_dim_box, 1, 1)

        if not node_block.is_head:
            self.in_dim_box.setReadOnly(True)

        # "Apply" button which saves changes
        apply_button = CustomButton("Apply")
        apply_button.clicked.connect(self.save_data)
        self.layout.addWidget(apply_button, 2, 0)

        # "Cancel" button which closes the dialog without saving
        cancel_button = CustomButton("Cancel")
        cancel_button.clicked.connect(self.close)
        self.layout.addWidget(cancel_button, 2, 1)

        self.layout.setColumnStretch(0, 1)
        self.layout.setColumnStretch(1, 1)

        self.render_layout()

    def save_data(self) -> None:
        """
        This method saves the new in_dim, returning
        it to the caller.

        """

        self.has_edits = True

        if len(self.in_dim_box.text()) != 0:
            self.new_in_dim = tuple(map(int, self.in_dim_box.text().split(',')))

        self.close()
示例#3
0
    def __init__(self):
        super().__init__('Mixed Verification', '')
        g_layout = QGridLayout()
        self.layout.addLayout(g_layout)
        self.n_neurons = 0

        target_label = CustomLabel('Neurons number')
        target_edit = CustomTextBox()
        target_edit.textChanged.connect(lambda: self.update_neurons(target_edit.text()))
        target_edit.setValidator(ArithmeticValidator.INT)
        g_layout.addWidget(target_label, 0, 0)
        g_layout.addWidget(target_edit, 0, 1)

        # Buttons
        self.cancel_btn.clicked.connect(self.reset)

        self.render_layout()
示例#4
0
class EditPolyhedralPropertyDialog(NeVerDialog):
    """
    This dialog allows to define a polyhedral property
    within a controlled environment.

    Attributes
    ----------
    property_block : PropertyBlock
        Current property to edit.
    property_list : list
        List of given properties.
    has_edits : bool
        Flag signaling if the property was edited.

    Methods
    ----------
    add_entry(str, str, str)
        Procedure to append the current constraint to the property list.
    save_property()
        Procedure to return the defined property.

    """

    def __init__(self, property_block: PropertyBlock):
        super().__init__("Edit property", "")
        self.property_block = property_block
        self.has_edits = False
        self.property_list = []
        self.viewer = CustomTextArea()
        self.viewer.setReadOnly(True)
        self.viewer.setFixedHeight(100)
        grid = QGridLayout()

        # Build main_layout
        title_label = CustomLabel("Polyhedral property")
        title_label.setStyleSheet(style.NODE_LABEL_STYLE)
        title_label.setAlignment(Qt.AlignCenter)
        grid.addWidget(title_label, 0, 0, 1, 3)

        # Labels
        var_label = CustomLabel("Variable")
        var_label.setStyleSheet(style.IN_DIM_LABEL_STYLE)
        var_label.setAlignment(Qt.AlignRight)
        grid.addWidget(var_label, 1, 0)

        relop_label = CustomLabel("Operator")
        relop_label.setStyleSheet(style.IN_DIM_LABEL_STYLE)
        relop_label.setAlignment(Qt.AlignCenter)
        grid.addWidget(relop_label, 1, 1)

        value_label = CustomLabel("Value")
        value_label.setStyleSheet(style.IN_DIM_LABEL_STYLE)
        value_label.setAlignment(Qt.AlignLeft)
        grid.addWidget(value_label, 1, 2)

        self.var_cb = CustomComboBox()
        for v in property_block.variables:
            self.var_cb.addItem(v)
        grid.addWidget(self.var_cb, 2, 0)

        self.op_cb = CustomComboBox()
        operators = ["<=", "<", ">", ">="]
        for o in operators:
            self.op_cb.addItem(o)
        grid.addWidget(self.op_cb, 2, 1)

        self.val = CustomTextBox()
        self.val.setValidator(ArithmeticValidator.FLOAT)
        grid.addWidget(self.val, 2, 2)

        # "Add" button which adds the constraint
        add_button = CustomButton("Add")
        add_button.clicked.connect(
            lambda: self.add_entry(str(self.var_cb.currentText()), str(self.op_cb.currentText()), self.val.text()))
        grid.addWidget(add_button, 3, 0)

        # "Save" button which saves the state
        save_button = CustomButton("Save")
        save_button.clicked.connect(self.save_property)
        grid.addWidget(save_button, 3, 1)

        # "Cancel" button which closes the dialog without saving
        cancel_button = CustomButton("Cancel")
        cancel_button.clicked.connect(self.close)
        grid.addWidget(cancel_button, 3, 2)

        grid.setColumnStretch(0, 1)
        grid.setColumnStretch(1, 1)
        grid.setColumnStretch(2, 1)

        self.layout.addLayout(grid)
        self.layout.addWidget(self.viewer, 3)
        self.render_layout()

    def add_entry(self, var: str, op: str, val: str) -> None:
        self.property_list.append((var, op, val))
        self.viewer.appendPlainText(f"{var} {op} {val}")
        self.var_cb.setCurrentIndex(0)
        self.op_cb.setCurrentIndex(0)
        self.val.setText("")

    def save_property(self) -> None:
        self.has_edits = True
        if self.val.text() != '':
            self.add_entry(str(self.var_cb.currentText()),
                           str(self.op_cb.currentText()),
                           self.val.text())
        self.close()