Skip to content

Commit 133e3dd

Browse files
committed
fix warning from scipy backend guess_can_open on directory
When passing a directory to open_dataset(), the scipy backend fails and a "RuntimeWarning: 'scipy' fails while guessing" is produced. This affects me since I'm implementing a backend to read data written by the adios2 package, whose data "files" are actually a directory. This tiny patch treats this case just like file not found, that is, the scipy backend will now return that it cannot open such a "file", but without raising an exception.
1 parent 6875c64 commit 133e3dd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

xarray/core/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ def try_read_magic_number_from_path(pathlike, count=8) -> bytes | None:
645645
try:
646646
with open(path, "rb") as f:
647647
return read_magic_number_from_file(f, count)
648-
except (FileNotFoundError, TypeError):
648+
except (FileNotFoundError, IsADirectoryError, TypeError):
649649
pass
650650
return None
651651

0 commit comments

Comments
 (0)