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

ENH: allow direct dataset instanciation using the user path '~' glyph, consistently with yt.load #3525

Merged
merged 1 commit into from
Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
matthewturk marked this conversation as resolved.
Show resolved Hide resolved
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