Skip to content

Commit

Permalink
Merge pull request #4693 from chrishavlin/fix_load_sample_noargs
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros authored Oct 9, 2023
2 parents 0f36ad5 + 7fe4c2d commit e318e88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 9 additions & 8 deletions yt/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -1487,14 +1487,6 @@ def _get_sample_data(
# broadcast to other processes during parallel execution).
import tarfile

if fn is None:
print(
"One can see which sample datasets are available at: https://yt-project.org/data\n"
"or alternatively by running: yt.sample_data.api.get_data_registry_table()",
file=sys.stderr,
)
return None

from yt.sample_data.api import (
_download_sample_data_file,
_get_test_data_dir_path,
Expand Down Expand Up @@ -1663,6 +1655,15 @@ def load_sample(
- Corresponding sample data live at https://yt-project.org/data
"""

if fn is None:
print(
"One can see which sample datasets are available at: https://yt-project.org/data\n"
"or alternatively by running: yt.sample_data.api.get_data_registry_table()",
file=sys.stderr,
)
return None

loadable_path, load_kwargs = _get_sample_data(
fn, progressbar=progressbar, timeout=timeout, **kwargs
)
Expand Down
6 changes: 6 additions & 0 deletions yt/tests/test_load_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,9 @@ def test_data_dir_broken():
)
with pytest.warns(UserWarning, match=msg):
load_sample("ToroShockTube")


def test_filename_none(capsys):
assert load_sample() is None
captured = capsys.readouterr()
assert "yt.sample_data.api.get_data_registry_table" in captured.err

0 comments on commit e318e88

Please sign in to comment.