示例#1
0
    def test_update_sub_cube_2d(self):
        cube = setup_2d_cube()
        status = self.setup_update()
        dim_indices = {'dim 1 index': 1,
                       'dim 2 index': 0,
                       'sliced dim index': -1}
        status['cube'] = cube
        status['dim indices'] = dim_indices
        status['slice index'] = -1
        status['collapsed indices'] = []

        sub_cube, _ = cl.update(status)
        self.assertEqual(sub_cube, cube)
示例#2
0
    def test_update_sub_cube_7d(self):
        cube = setup_7d_anonymous_cube()
        status = self.setup_update()
        dim_indices = {'dim 1 index': 4,
                       'dim 2 index': 2,
                       'sliced dim index': 6}
        status['cube'] = cube
        status['dim indices'] = dim_indices
        status['slice index'] = 2
        status['collapsed indices'] = [2, 1, 2, 4]

        sub_cube, _ = cl.update(status)
        expected_cube = cube[2, 1, :, 2, :, 4, 2]
        self.assertEqual(sub_cube, expected_cube)
示例#3
0
    def test_update_sub_cube_4d(self):
        cube = setup_4d_cube()
        status = self.setup_update()
        dim_indices = {'dim 1 index': 1,
                       'dim 2 index': 0,
                       'sliced dim index': 2}
        status['cube'] = cube
        status['dim indices'] = dim_indices
        status['slice index'] = 2
        status['collapsed indices'] = [3]

        sub_cube, _ = cl.update(status)
        expected_cube = cube[:, :, 2, 3]
        self.assertEqual(sub_cube, expected_cube)
示例#4
0
文件: main_window.py 项目: esc24/thea
    def update(self):
        """
        This method is called whenever a new cube is loaded, or when the
        update button is pressed. It is responsible for gathering the
        information needed to plot the cube from the interface, and passing
        it to the update function in cubeLogic. It also calls for the
        information about the sub cube to be displayed.

        """
        QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)

        self.update_button.setEnabled(False)

        interface_status = self.get_status()

        self.clear_fig()
        self.statusBar().showMessage('Drawing Cube')

        try:
            # passes information to the plotting function.
            self.plotted_cube, self.set_global = cl.update(interface_status)

        # Should anything fail during the plotting that was not explicitly
        # caught, the program produces dialog box containg the error message.
        except Exception as e:
            flags = QtGui.QMessageBox.StandardButton.Ok
            QtGui.QMessageBox.critical(
                self, 'Unable to plot cube!', str(e), flags)
            self.statusBar().showMessage('Failed to Plot Cube')
            QApplication.restoreOverrideCursor()

        # update the display and use the data from the plotted cube to print a
        # summary of the cube and show its data.
        self.display()
        self.print_cube_slice_browser.setText(str(self.plotted_cube))
        self.show_data()
        self.statusBar().showMessage('Ready')
        QApplication.restoreOverrideCursor()
示例#5
0
    def update(self):
        """
        This method is called whenever a new cube is loaded, or when the
        update button is pressed. It is responsible for gathering the
        information needed to plot the cube from the interface, and passing
        it to the update function in cubeLogic. It also calls for the
        information about the sub cube to be displayed.

        """
        QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)

        self.update_button.setEnabled(False)

        interface_status = self.get_status()

        self.clear_fig()
        self.statusBar().showMessage('Drawing Cube')

        try:
            # passes information to the plotting function.
            self.plotted_cube, self.set_global = cl.update(interface_status)

        # Should anything fail during the plotting that was not explicitly
        # caught, the program produces dialog box containg the error message.
        except Exception as e:
            flags = QtGui.QMessageBox.StandardButton.Ok
            QtGui.QMessageBox.critical(
                self, 'Unable to plot cube!', str(e), flags)
            self.statusBar().showMessage('Failed to Plot Cube')
            QApplication.restoreOverrideCursor()

        # update the display and use the data from the plotted cube to print a
        # summary of the cube and show its data.
        self.display()
        self.print_cube_slice_browser.setText(str(self.plotted_cube))
        self.show_data()
        self.statusBar().showMessage('Ready')
        QApplication.restoreOverrideCursor()