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

Remove special case in guess_engines #4777

Merged
merged 2 commits into from
Jan 8, 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
5 changes: 0 additions & 5 deletions xarray/backends/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ def list_engines():
def guess_engine(store_spec):
engines = list_engines()

# use the pre-defined selection order for netCDF files
for engine in ["netcdf4", "h5netcdf", "scipy"]:
if engine in engines and engines[engine].guess_can_open(store_spec):
return engine

for engine, backend in engines.items():
try:
if backend.guess_can_open and backend.guess_can_open(store_spec):
Expand Down
1 change: 1 addition & 0 deletions xarray/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ def read_magic_number(filename_or_obj, count=8):
elif isinstance(filename_or_obj, io.IOBase):
if filename_or_obj.tell() != 0:
raise ValueError(
"cannot guess the engine, "
"file-like object read/write pointer not at the start of the file, "
"please close and reopen, or use a context manager"
)
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2661,7 +2661,7 @@ def test_open_fileobj(self):
open_dataset(f, engine="scipy")

f.seek(8)
with raises_regex(ValueError, "read/write pointer not at the start"):
with raises_regex(ValueError, "cannot guess the engine"):
open_dataset(f)


Expand Down