How to use the xenonpy.model.training.base.BaseRunner.check_device function in xenonpy

To help you get started, we’ve selected a few xenonpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yoshida-lab / XenonPy / tests / models / test_base_runner.py View on Github external
def test_base_runner_1(data):
    assert BaseRunner.check_device(False).type == 'cpu'
    assert BaseRunner.check_device('cpu').type == 'cpu'

    with pytest.raises(RuntimeError, match='could not use CUDA on this machine'):
        BaseRunner.check_device(True)

    with pytest.raises(RuntimeError, match='could not use CUDA on this machine'):
        BaseRunner.check_device('cuda')

    with pytest.raises(RuntimeError, match='wrong device identifier'):
        BaseRunner.check_device('other illegal')
github yoshida-lab / XenonPy / tests / models / test_base_runner.py View on Github external
def test_base_runner_1(data):
    assert BaseRunner.check_device(False).type == 'cpu'
    assert BaseRunner.check_device('cpu').type == 'cpu'

    with pytest.raises(RuntimeError, match='could not use CUDA on this machine'):
        BaseRunner.check_device(True)

    with pytest.raises(RuntimeError, match='could not use CUDA on this machine'):
        BaseRunner.check_device('cuda')

    with pytest.raises(RuntimeError, match='wrong device identifier'):
        BaseRunner.check_device('other illegal')
github yoshida-lab / XenonPy / tests / models / test_base_runner.py View on Github external
def test_base_runner_1(data):
    assert BaseRunner.check_device(False).type == 'cpu'
    assert BaseRunner.check_device('cpu').type == 'cpu'

    with pytest.raises(RuntimeError, match='could not use CUDA on this machine'):
        BaseRunner.check_device(True)

    with pytest.raises(RuntimeError, match='could not use CUDA on this machine'):
        BaseRunner.check_device('cuda')

    with pytest.raises(RuntimeError, match='wrong device identifier'):
        BaseRunner.check_device('other illegal')
github yoshida-lab / XenonPy / tests / models / test_base_runner.py View on Github external
def test_base_runner_1(data):
    assert BaseRunner.check_device(False).type == 'cpu'
    assert BaseRunner.check_device('cpu').type == 'cpu'

    with pytest.raises(RuntimeError, match='could not use CUDA on this machine'):
        BaseRunner.check_device(True)

    with pytest.raises(RuntimeError, match='could not use CUDA on this machine'):
        BaseRunner.check_device('cuda')

    with pytest.raises(RuntimeError, match='wrong device identifier'):
        BaseRunner.check_device('other illegal')
github yoshida-lab / XenonPy / tests / models / test_base_runner.py View on Github external
def test_base_runner_1(data):
    assert BaseRunner.check_device(False).type == 'cpu'
    assert BaseRunner.check_device('cpu').type == 'cpu'

    with pytest.raises(RuntimeError, match='could not use CUDA on this machine'):
        BaseRunner.check_device(True)

    with pytest.raises(RuntimeError, match='could not use CUDA on this machine'):
        BaseRunner.check_device('cuda')

    with pytest.raises(RuntimeError, match='wrong device identifier'):
        BaseRunner.check_device('other illegal')
github yoshida-lab / XenonPy / xenonpy / model / training / checker.py View on Github external
Set to ``True`` to prevent the potential risk of overwriting.
            Default ``False``.
        """
        if path is None:
            path = Path().resolve()
            self._path = path / path.name
        else:
            self._path = Path(path).resolve()
        if increment:
            i = 1
            while Path(f'{path}@{i}').exists():
                i += 1
            self._path = Path(f'{path}@{i}').resolve()
        self._path.mkdir(parents=True, exist_ok=True)
        # self._path = self._path.resolve()
        self._device = BaseRunner.check_device(device)
        self._handle = default_handle

        self._files: Dict[str, str] = defaultdict(str)
        self._make_file_index()