Skip to content

Commit

Permalink
Merge pull request #3525 from neutrinoceros/expanduser_from_dataset
Browse files Browse the repository at this point in the history
ENH: allow direct dataset instanciation using the user path '~' glyph, consistently with yt.load
  • Loading branch information
matthewturk authored Oct 9, 2021
2 parents 8015b41 + 6a17cc6 commit 3c378f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions yt/data_objects/static_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def __new__(cls, filename=None, *args, **kwargs):
if not is_stream:
obj.__init__(filename, *args, **kwargs)
return obj
apath = os.path.abspath(filename)
apath = os.path.abspath(os.path.expanduser(filename))
cache_key = (apath, pickle.dumps(args), pickle.dumps(kwargs))
if ytcfg.get("yt", "skip_dataset_cache"):
obj = object.__new__(cls)
Expand Down Expand Up @@ -212,9 +212,10 @@ def __init__(
self.default_species_fields = default_species_fields

# path stuff
self.parameter_filename = str(filename)
filename = os.path.expanduser(filename)
self.parameter_filename = filename
self.basename = os.path.basename(filename)
self.directory = os.path.expanduser(os.path.dirname(filename))
self.directory = os.path.dirname(filename)
self.fullpath = os.path.abspath(self.directory)
self.backup_filename = self.parameter_filename + "_backup.gdf"
self.read_from_backup = False
Expand Down
2 changes: 1 addition & 1 deletion yt/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def load(fn, *args, **kwargs):
yt.utilities.exceptions.YTAmbiguousDataType
If the data format matches more than one class of similar specilization levels.
"""
fn = os.path.expanduser(fn)
fn = os.fspath(fn)

if any(wildcard in fn for wildcard in "[]?!*"):
from yt.data_objects.time_series import DatasetSeries
Expand Down

0 comments on commit 3c378f4

Please sign in to comment.