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

Conversation

neutrinoceros
Copy link
Member

PR Summary

In some occasion, it is useful (sometimes, mandatory) to load an exact dataset class explicitly. This happens with Boxlib-based datasets which are not easy to distinguish automatically with yt.load. It is also useful when developing a frontend.
Now, yt.load supports automatic expansion of ~/ via os.path.expanduser, however currently, this is not done in the Dataset classes themselves, resulting in an inconsistency where the first test pass, but not the second:

import yt
from yt.frontends.enzo.api import EnzoDataset

fn = "~/dev/yt-project/test-data-dir/IsolatedGalaxy/galaxy0030/galaxy0030"

def test_load():
    ds = yt.load(fn)

def test_api():
    ds = EnzoDataset(fn)

this fixes that by moving the os.path.expanduser call to Dataset.__init__

PR Checklist

  • New features are documented, with docstrings and narrative docs
  • Adds a test for any bugs fixed. Adds tests for new features.

@neutrinoceros neutrinoceros added the enhancement Making something better label Sep 24, 2021
@neutrinoceros neutrinoceros marked this pull request as draft September 26, 2021 20:26
@neutrinoceros neutrinoceros marked this pull request as ready for review September 26, 2021 21:19
@neutrinoceros neutrinoceros added the UX user-experience label Sep 26, 2021
Copy link
Member

@matthewturk matthewturk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modulo the one question LGTM

yt/data_objects/static_output.py Show resolved Hide resolved
@matthewturk matthewturk merged commit 3c378f4 into yt-project:main Oct 9, 2021
@neutrinoceros neutrinoceros deleted the expanduser_from_dataset branch October 9, 2021 15:53
@neutrinoceros neutrinoceros added the api-consistency naming conventions, code deduplication, informative error messages, code smells... label Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-consistency naming conventions, code deduplication, informative error messages, code smells... enhancement Making something better UX user-experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants