Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path.replace bug #2535

Merged
merged 10 commits into from
Mar 19, 2024
Merged
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,5 @@ Sarthak Srivastava <[email protected]> Sarthak Srivastava <sarthaksri592@g

Kim Lingemann <[email protected]> kimsina <[email protected]>
Kim Lingemann <[email protected]> kim <[email protected]>

Sumit Gupta <[email protected]>
2 changes: 1 addition & 1 deletion tardis/io/atom_data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def from_hdf(cls, fname=None):

Parameters
----------
fname : str, optional
fname : Path, optional
Path to the HDFStore file or name of known atom data file
(default: None)
"""
Expand Down
11 changes: 7 additions & 4 deletions tardis/io/atom_data/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import logging
from pathlib import Path

from tardis.io.configuration.config_internal import get_data_dir
from tardis.io.atom_data.atom_web_download import (
Expand All @@ -16,26 +17,28 @@

Parameters
----------
fname : str
fname : Path
name or path of atom data HDF file

Returns
-------
: str
: Path
resolved fpath
"""

fname = Path(fname)
if os.path.exists(fname):
return fname

fpath = os.path.join(os.path.join(get_data_dir(), fname))
fname = Path(fname.stem).with_suffix(".h5")
fpath = Path(os.path.join(get_data_dir(), fname))

Check warning on line 34 in tardis/io/atom_data/util.py

View check run for this annotation

Codecov / codecov/patch

tardis/io/atom_data/util.py#L33-L34

Added lines #L33 - L34 were not covered by tests
if os.path.exists(fpath):
logger.info(
f"\n\tAtom Data {fname} not found in local path.\n\tExists in TARDIS Data repo {fpath}"
)
return fpath

atom_data_name = fname.replace(".h5", "")
atom_data_name = fname.stem

Check warning on line 41 in tardis/io/atom_data/util.py

View check run for this annotation

Codecov / codecov/patch

tardis/io/atom_data/util.py#L41

Added line #L41 was not covered by tests
atom_repo_config = get_atomic_repo_config()
if atom_data_name in atom_repo_config:
raise IOError(
Expand Down
2 changes: 1 addition & 1 deletion tardis/simulation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def from_config(
if atom_data is None:
if "atom_data" in config:
if Path(config.atom_data).is_absolute():
atom_data_fname = config.atom_data
atom_data_fname = Path(config.atom_data)
else:
atom_data_fname = (
Path(config.config_dirname) / config.atom_data
Expand Down
Loading