コード例 #1
0
def _launch_qt_app(main_window_factory, block):
    """Wrapper to display plot in a separate process."""
    def _doit(factory):
        # for windows these needs to be repeated due to multiprocessing (?)
        from Qt.QtWidgets import QApplication
        from Qt.QtCore import QCoreApplication
        try:
            app = QApplication([])
        except RuntimeError:
            app = QCoreApplication.instance()
        main_window = factory()
        if getattr(sys, '_called_from_test',
                   False) and (is_windows_platform() or is_macos_platform()):
            QTimer.singleShot(1000, app.quit)
        main_window.show()
        app.exec_()

    import sys
    # we treat win and osx differently here since no (reliable) forking is possible with multiprocessing startup
    if (block and not getattr(sys, '_called_from_test', False)) or (
            is_windows_platform() or is_macos_platform()):
        _doit(main_window_factory)
    else:
        p = multiprocessing.Process(target=_doit, args=(main_window_factory, ))
        p.start()
        _launch_qt_processes.add(p.pid)
コード例 #2
0
ファイル: qt.py プロジェクト: renemilk/pyMor
 def _doit(factory):
     try:
         app = QApplication([])
     except RuntimeError:
         app = QCoreApplication.instance()
     main_window = factory()
     if getattr(sys, '_called_from_test', False) and is_windows_platform():
         QTimer.singleShot(500, app, Slot('quit()'))
     main_window.show()
     app.exec_()
コード例 #3
0
 def _doit(factory):
     try:
         app = QApplication([])
     except RuntimeError:
         app = QCoreApplication.instance()
     main_window = factory()
     if getattr(sys, '_called_from_test', False) and is_windows_platform():
         QTimer.singleShot(500, app, Slot('quit()'))
     main_window.show()
     app.exec_()
コード例 #4
0
 def _doit(factory):
     # for windows these needs to be repeated due to multiprocessing (?)
     from Qt.QtWidgets import QApplication
     from Qt.QtCore import QCoreApplication
     try:
         app = QApplication([])
     except RuntimeError:
         app = QCoreApplication.instance()
     main_window = factory()
     if getattr(sys, '_called_from_test',
                False) and (is_windows_platform() or is_macos_platform()):
         QTimer.singleShot(1000, app.quit)
     main_window.show()
     app.exec_()
コード例 #5
0
ファイル: cache.py プロジェクト: meretp/pymor
def test_region_api():
    with tempfile.TemporaryDirectory() as tmpdir:
        backends = [cache.MemoryRegion(100)] 
        # this specific backend test is currently broken on windows
        if not is_windows_platform():
            backends.append(cache.DiskRegion(path=os.path.join(tmpdir, str(uuid4())),
                                                max_size=1024 ** 2, persistent=False))
        for backend in backends:
            assert backend.get('mykey') == (False, None)
            backend.set('mykey', 1)
            assert backend.get('mykey') == (True, 1)
            # second set is ignored
            backend.set('mykey', 2)
            assert backend.get('mykey') == (True, 1)
コード例 #6
0
ファイル: thermalblock_gui.py プロジェクト: pymor/pymor
 def __init__(self, parent, sim):
     super().__init__(parent)
     self.sim = sim
     box = QtWidgets.QHBoxLayout()
     if is_windows_platform():
         self.solution = MatplotlibPatchWidget(self, self.sim.grid, vmin=0., vmax=0.8)
         box.addWidget(self.solution, 2)
     else:
         self.solution = GLPatchWidget(self, self.sim.grid, vmin=0., vmax=0.8)
         self.bar = ColorBarWidget(self, vmin=0., vmax=0.8)
         box.addWidget(self.solution, 2)
         box.addWidget(self.bar, 2)
     self.param_panel = ParamRuler(self, sim)
     box.addWidget(self.param_panel)
     self.setLayout(box)
コード例 #7
0
 def __init__(self, parent, sim):
     super().__init__(parent)
     self.sim = sim
     box = QtWidgets.QHBoxLayout()
     if is_windows_platform():
         self.solution = MatplotlibPatchWidget(self, self.sim.grid, vmin=0., vmax=0.8)
         box.addWidget(self.solution, 2)
     else:
         self.solution = GLPatchWidget(self, self.sim.grid, vmin=0., vmax=0.8)
         self.bar = ColorBarWidget(self, vmin=0., vmax=0.8)
         box.addWidget(self.solution, 2)
         box.addWidget(self.bar, 2)
     self.param_panel = ParamRuler(self, sim)
     box.addWidget(self.param_panel)
     self.setLayout(box)
コード例 #8
0
ファイル: qt.py プロジェクト: pymor/pymor
def _launch_qt_app(main_window_factory, block):
    """Wrapper to display plot in a separate process."""

    def _doit(factory):
        try:
            app = QApplication([])
        except RuntimeError:
            app = QCoreApplication.instance()
        main_window = factory()
        if getattr(sys, '_called_from_test', False) and is_windows_platform():
            QTimer.singleShot(500, app, Slot('quit()'))
        main_window.show()
        app.exec_()

    import sys
    if (block and not getattr(sys, '_called_from_test', False)) or is_windows_platform():
        _doit(main_window_factory)
    else:
        p = multiprocessing.Process(target=_doit, args=(main_window_factory,))
        p.start()
        _launch_qt_processes.add(p.pid)
コード例 #9
0
def _launch_qt_app(main_window_factory, block):
    """Wrapper to display plot in a separate process."""
    def _doit(factory):
        try:
            app = QApplication([])
        except RuntimeError:
            app = QCoreApplication.instance()
        main_window = factory()
        if getattr(sys, '_called_from_test', False) and is_windows_platform():
            QTimer.singleShot(500, app, Slot('quit()'))
        main_window.show()
        app.exec_()

    import sys
    if (block and not getattr(sys, '_called_from_test', False)
        ) or is_windows_platform():
        _doit(main_window_factory)
    else:
        p = multiprocessing.Process(target=_doit, args=(main_window_factory, ))
        p.start()
        _launch_qt_processes.add(p.pid)
コード例 #10
0
ファイル: demos.py プロジェクト: OVGULIU/pymor
    finally:
        shutil.rmtree(d)


def test_analyze_pickle4():
    d = mkdtemp()
    try:
        test_demos(('pymordemos.thermalblock', ['--pickle=' + os.path.join(d, 'data'), 2, 2, 2, 10]))
        test_demos(('pymordemos.analyze_pickle',
                   ['convergence', '--detailed=' + os.path.join(d, 'data_detailed'),
                    os.path.join(d, 'data_reduced'), 10]))
    finally:
        shutil.rmtree(d)


@pytest.mark.skipif(is_windows_platform(), reason='hangs indefinitely')
@pytest.mark.skipif(is_macos_platform(), reason='spurious JSON Decode errors in Ipython launch')
def test_thermalblock_ipython(demo_args):
    if demo_args[0] != 'pymordemos.thermalblock':
        return
    from pymor.tools import mpi
    if mpi.parallel:  # simply running 'ipcluster start' (without any profile) does not seem to work
        return        # when running under mpirun, so we do not test this combination for now
    try:
        test_demos((demo_args[0], ['--ipython-engines=2'] + demo_args[1]))
    finally:
        import time     # there seems to be no way to shutdown the IPyhton cluster s.t. a new
        time.sleep(10)  # cluster can be started directly afterwards, so we have to wait ...


def test_thermalblock_results(thermalblock_args):
コード例 #11
0
ファイル: demos.py プロジェクト: renemilk/pyMor
                    '--error-norm=h1_0_semi', os.path.join(d, 'data_reduced'), 10]))
    finally:
        shutil.rmtree(d)


def test_analyze_pickle4():
    d = mkdtemp()
    try:
        test_demos(('pymordemos.thermalblock', ['--pickle=' + os.path.join(d, 'data'), 2, 2, 2, 10]))
        test_demos(('pymordemos.analyze_pickle',
                   ['convergence', '--detailed=' + os.path.join(d, 'data_detailed'),
                    os.path.join(d, 'data_reduced'), 10]))
    finally:
        shutil.rmtree(d)

@pytest.mark.skipif(is_windows_platform(), reason='hangs indefinitely')
def test_thermalblock_ipython(demo_args):
    if demo_args[0] != 'pymordemos.thermalblock':
        return
    from pymor.tools import mpi
    if mpi.parallel:  # simply running 'ipcluster start' (without any profile) does not seem to work
        return        # when running under mpirun, so we do not test this combination for now
    try:
        test_demos((demo_args[0], ['--ipython-engines=2'] + demo_args[1]))
    finally:
        import time     # there seems to be no way to shutdown the IPyhton cluster s.t. a new
        time.sleep(10)  # cluster can be started directly afterwards, so we have to wait ...


def test_thermalblock_results(thermalblock_args):
    from pymordemos import thermalblock
コード例 #12
0
ファイル: demos.py プロジェクト: meretp/pymor
    ('elliptic_oned', ['--fv', 1, 20]),
    ('burgers', ['--num-flux=lax_friedrichs', '0.1']),
    ('burgers', ['--num-flux=engquist_osher', '0.1']),
    ('burgers', ['--num-flux=simplified_engquist_osher', '0.1']),
    ('linear_optimization', [40, 20]),
    ('parabolic', ['heat', 1]),
    ('parabolic', ['heat', '--rect', 1]),
    ('parabolic', ['heat', '--fv', 1]),
    ('parabolic', ['heat', '--rect', '--fv', 1]),
    ('parabolic', ['dar', 1]),
    ('parabolic', ['dar', '--rect', 1]),
)

if not parallel:
    DISCRETIZATION_ARGS += (('elliptic_unstructured', [6., 16, 1e-1]), )
if not is_windows_platform():
    DISCRETIZATION_ARGS += (('neural_networks', [25, 50, 10]),
                            ('neural_networks_fenics', [15, 3]),
                            ('neural_networks_instationary', [25, 25, 30, 5]))

THERMALBLOCK_ARGS = (
    ('thermalblock',
     ['--plot-solutions', '--plot-err', '--plot-error-sequence', 2, 2, 3, 5]),
    ('thermalblock', ['--fenics', 2, 2, 3, 5]),
    ('thermalblock', ['--no-greedy-with-error-estimator', 3, 1, 2, 5]),
    ('thermalblock', ['--alg=pod', 2, 2, 3, 5]),
    ('thermalblock', ['--alg=adaptive_greedy', 2, 2, 10, 30]),
    ('thermalblock', ['--alg=naive', '--reductor=traditional', 2, 2, 10, 5]),
    ('thermalblock', ['--list-vector-array', 2, 2, 2, 2]),
)