Skip to content

Commit

Permalink
Make caching using wrong types a warning instead of an error
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Oct 10, 2023
1 parent 9ad6b16 commit 6a59c85
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion satpy/modifiers/angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ def _hash_args(*args, unhashable_types=DEFAULT_UNCACHE_TYPES):
hashable_args = []
for arg in args:
if isinstance(arg, unhashable_types):
raise TypeError(f"Unhashable type in function signature ({type(arg)}), cannot be cached.")
warnings.warn(f"Unhashable type in function signature ({type(arg)}), cannot be cached.", stacklevel=2)
continue
if isinstance(arg, HASHABLE_GEOMETRIES):
arg = hash(arg)
elif isinstance(arg, datetime):
Expand Down
2 changes: 1 addition & 1 deletion satpy/tests/modifier_tests/test_angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def test_caching_with_array_in_args_fails(self, tmp_path):
def _fake_func(array):
return array + 1

with pytest.raises(TypeError), \
with pytest.warns(UserWarning), \
satpy.config.set(cache_lonlats=True, cache_dir=str(tmp_path)):
_fake_func(da.zeros(100))

Expand Down

0 comments on commit 6a59c85

Please sign in to comment.