How to use the xenonpy.utils.config 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 / utils / test_gadget.py View on Github external
def test_config_1():
    tmp = config('name')
    assert tmp == 'xenonpy'

    with pytest.raises(RuntimeError):
        config('no_exist')

    tmp = config(new_key='test')
    assert tmp is None

    tmp = config('new_key')
    assert tmp == 'test'

    tmp = config('github_username', other_key='other')
    assert tmp == 'yoshida-lab'

    tmp = config('other_key')
    assert tmp == 'other'
github yoshida-lab / XenonPy / tests / utils / test_gadget.py View on Github external
def test_config_1():
    tmp = config('name')
    assert tmp == 'xenonpy'

    with pytest.raises(RuntimeError):
        config('no_exist')

    tmp = config(new_key='test')
    assert tmp is None

    tmp = config('new_key')
    assert tmp == 'test'

    tmp = config('github_username', other_key='other')
    assert tmp == 'yoshida-lab'

    tmp = config('other_key')
    assert tmp == 'other'
github yoshida-lab / XenonPy / tests / utils / test_gadget.py View on Github external
def test_config_1():
    tmp = config('name')
    assert tmp == 'xenonpy'

    with pytest.raises(RuntimeError):
        config('no_exist')

    tmp = config(new_key='test')
    assert tmp is None

    tmp = config('new_key')
    assert tmp == 'test'

    tmp = config('github_username', other_key='other')
    assert tmp == 'yoshida-lab'

    tmp = config('other_key')
    assert tmp == 'other'
github yoshida-lab / XenonPy / xenonpy / datatools / preset.py View on Github external
# check sha256 value
        sha256_file.touch()  # make sure sha256_file file exist.
        sha256 = self._yaml.load(sha256_file)
        if sha256 is None:
            sha256 = {}
        if data not in sha256:
            sha256_ = get_sha256(str(dataset))
            sha256[data] = sha256_
            self._yaml.dump(sha256, sha256_file)
        else:
            sha256_ = sha256[data]

        if sha256_ != config(data):
            warn(
                "local version {0} is different from the latest version {1}."
                "you can use  to fix it.".format(data, config('db_version')),
                RuntimeWarning)
github yoshida-lab / XenonPy / xenonpy / __main__.py View on Github external
def migrate(args_):
    data_path = Path('~/.xenonpy/dataset').expanduser().absolute()
    user_path = Path(config('userdata')).expanduser().absolute()

    def migrate_(f):
        path = data_path / f
        if not path.exists():
            return
        if args_.keep:
            path_ = user_path / f
            rename(str(path), str(path_))
        else:
            remove(str(path))

    for file in tqdm(['mp_inorganic.pkl.pd_', 'mp_structure.pkl.pd_', 'oqmd_inorganic.pkl.pd_',
                      'oqmd_structure.pkl.pd_'], desc='Migrating'):
        migrate_(file)
github yoshida-lab / XenonPy / xenonpy / datatools / preset.py View on Github external
def __init__(self):
        self._dataset = Path(__cfg_root__) / 'dataset'
        self._ext_data = config('ext_data')
        super().__init__(
            str(self._dataset),
            config('userdata'),
            *self._ext_data,
            backend='pandas',
            prefix=('dataset',))

        yaml = YAML(typ='safe')
        yaml.indent(mapping=2, sequence=4, offset=2)

        self._yaml = yaml
github yoshida-lab / XenonPy / xenonpy / datatools / preset.py View on Github external
'See also: https://xenonpy.readthedocs.io/en/latest/tutorials/1-dataset.html'
            )

        # check sha256 value
        sha256_file.touch()  # make sure sha256_file file exist.
        sha256 = self._yaml.load(sha256_file)
        if sha256 is None:
            sha256 = {}
        if data not in sha256:
            sha256_ = get_sha256(str(dataset))
            sha256[data] = sha256_
            self._yaml.dump(sha256, sha256_file)
        else:
            sha256_ = sha256[data]

        if sha256_ != config(data):
            warn(
                "local version {0} is different from the latest version {1}."
                "you can use  to fix it.".format(data, config('db_version')),
                RuntimeWarning)
github yoshida-lab / XenonPy / xenonpy / datatools / preset.py View on Github external
def __init__(self):
        self._dataset = Path(__cfg_root__) / 'dataset'
        self._ext_data = config('ext_data')
        super().__init__(
            str(self._dataset),
            config('userdata'),
            *self._ext_data,
            backend='pandas',
            prefix=('dataset',))

        yaml = YAML(typ='safe')
        yaml.indent(mapping=2, sequence=4, offset=2)

        self._yaml = yaml