def _do_find_similarities_gui_action(self):
     """Calculate the similarities between all currently loaded songs and display them"""
     progress_bar = ProgressBar()
     self.setCentralWidget(progress_bar)
     self._similarity_finder = SimilarityFinder(
         self._loaded_song_list, progress_bar,
         self._calculating_similarities_done)
Exemplo n.º 2
0
    def __init__(self, loaded_songs_list):
        """Show and modify the list of all loaded songs
        :type loaded_songs_list: LoadedSongs
        :param loaded_songs_list: All currently loaded songs"""
        super().__init__()

        # Main layout
        self.resize(900, 600)
        self.setWindowTitle("Loaded Songs")
        self._list_widget = OrderableListWidget()
        self.setCentralWidget(self._list_widget)

        # Setup parameters
        self._song_list: LoadedSongs = loaded_songs_list
        self._song_list.subscribe(LoadedSongs.ADDED, self._song_added)
        self._song_list.subscribe(LoadedSongs.DELETED, self._song_deleted)
        self._song_gui_list: dict[Song:QWidget] = {}
        self._progress_bar = ProgressBar()
        self._load_songs_dialog = LoadSongsDialog(self, self._progress_bar)

        self._signal_song_added.connect(self._song_added_function)

        # Setup gui
        self._create_menu_bar()
        self._status_bar.addPermanentWidget(self._progress_bar)
Exemplo n.º 3
0
    def run(self):
        if odeconfig.c_num == 0:
            if odeconfig.ntraj != 1:  #check if ntraj!=1 which is pointless for no collapse operators
                odeconfig.ntraj = 1
                print(
                    'No collapse operators specified.\nRunning a single trajectory only.\n'
                )
            if odeconfig.e_num == 0:  # return psi Qobj at each requested time
                self.psi_out = no_collapse_psi_out(self.num_times,
                                                   self.psi_out)
            else:  # return expectation values of requested operators
                self.expect_out = no_collapse_expect_out(
                    self.num_times, self.expect_out)
        elif odeconfig.c_num != 0:
            self.seed = array([
                int(ceil(random.rand() * 1e4)) for ll in range(odeconfig.ntraj)
            ])
            if odeconfig.e_num == 0:
                mc_alg_out = zeros((self.num_times), dtype=ndarray)
                mc_alg_out[0] = odeconfig.psi0
            else:
                #PRE-GENERATE LIST OF EXPECTATION VALUES
                mc_alg_out = []
                for i in range(odeconfig.e_num):
                    if odeconfig.e_ops_isherm[
                            i]:  #preallocate real array of zeros
                        mc_alg_out.append(zeros(self.num_times))
                    else:  #preallocate complex array of zeros
                        mc_alg_out.append(zeros(self.num_times, dtype=complex))
                    mc_alg_out[i][0] = mc_expect(odeconfig.e_ops_data[i],
                                                 odeconfig.e_ops_ind[i],
                                                 odeconfig.e_ops_ptr[i],
                                                 odeconfig.e_ops_isherm[i],
                                                 odeconfig.psi0)

            #set arguments for input to monte-carlo
            args = (mc_alg_out, odeconfig.options, odeconfig.tlist,
                    self.num_times, self.seed)
            if not odeconfig.options.gui:
                self.parallel(args, self)
            else:
                if qutip.settings.qutip_gui == "PYSIDE":
                    from PySide import QtGui, QtCore
                elif qutip.settings.qutip_gui == "PYQT4":
                    from PyQt4 import QtGui, QtCore
                from gui.ProgressBar import ProgressBar, Pthread
                app = QtGui.QApplication.instance(
                )  #checks if QApplication already exists (needed for iPython)
                if not app:  #create QApplication if it doesnt exist
                    app = QtGui.QApplication(sys.argv)
                thread = Pthread(target=self.parallel, args=args, top=self)
                self.bar = ProgressBar(self, thread, odeconfig.ntraj,
                                       self.cpus)
                QtCore.QTimer.singleShot(0, self.bar.run)
                self.bar.show()
                self.bar.activateWindow()
                self.bar.raise_()
                app.exec_()
                return