Skip to content

Commit a224317

Browse files
committed
Rename cache_geom_slices to cache_geometry_slices
1 parent dc68bfe commit a224317

6 files changed

Lines changed: 9 additions & 10 deletions

File tree

docs/source/howtos/configuration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ the `platformdirs <https://github.com/platformdirs/platformdirs#example-output>`
101101
Cache Geometry Slices
102102
^^^^^^^^^^^^^^^^^^^^^
103103
104-
* **Environment variable**: ``PYRESAMPLE_CACHE_GEOM_SLICES``
105-
* **YAML/Config Key**: ``cache_geom_slices``
104+
* **Environment variable**: ``PYRESAMPLE_CACHE_GEOMETRY_SLICES``
105+
* **YAML/Config Key**: ``cache_geometry_slices``
106106
* **Default**: ``False``
107107
108108
Whether or not generated slices for geometry objects are cached to disk.

pyresample/_caching.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _run_and_cache(self, arg_hash: str, args: tuple[Any]) -> Any:
6464
res = self._callable(*args)
6565
json_path.parent.mkdir(exist_ok=True)
6666
with open(json_path, "w") as json_cache:
67-
json.dump(res, json_cache, cls=_ExtraJSONEncoder)
67+
json.dump(res, json_cache, cls=_JSONEncoderWithSlice)
6868

6969
# for consistency, always load the cached result
7070
with open(json_path, "r") as json_cache:
@@ -97,7 +97,7 @@ def _hash_args(args: tuple[Any]) -> str:
9797
return arg_hash.hexdigest()
9898

9999

100-
class _ExtraJSONEncoder(json.JSONEncoder):
100+
class _JSONEncoderWithSlice(json.JSONEncoder):
101101
def default(self, obj: Any) -> Any:
102102
if isinstance(obj, slice):
103103
return {"__slice__": True, "start": obj.start, "stop": obj.stop, "step": obj.step}

pyresample/_config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from donfig import Config
2222

2323
BASE_PATH = os.path.dirname(os.path.realpath(__file__))
24-
# FIXME: Use package_resources?
2524
PACKAGE_CONFIG_PATH = os.path.join(BASE_PATH, 'etc')
2625

2726
_user_config_dir = platformdirs.user_config_dir("pyresample", "pytroll")
@@ -37,7 +36,7 @@
3736
"pyresample",
3837
defaults=[{
3938
"cache_dir": platformdirs.user_cache_dir("pyresample", "pytroll"),
40-
"cache_geom_slices": False,
39+
"cache_geometry_slices": False,
4140
"features": {
4241
"future_geometries": False,
4342
},

pyresample/future/geometry/_subset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from pyresample import AreaDefinition
1919

2020

21-
@cache_to_json_if("cache_geom_slices")
21+
@cache_to_json_if("cache_geometry_slices")
2222
def get_area_slices(
2323
src_area: AreaDefinition,
2424
area_to_cover: AreaDefinition,

pyresample/test/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
def reset_pyresample_config(tmpdir):
4343
"""Set pyresample config to logical defaults for tests."""
4444
test_config = {
45-
"cache_geom_slices": False,
45+
"cache_geometry_slices": False,
4646
"features": {
4747
"future_geometries": False,
4848
},

pyresample/test/test_geometry/test_area.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ def test_area_slices_caching(self, create_test_area, tmp_path, cache_slices):
18331833
100, 100,
18341834
(15.9689, 58.5284, 16.4346, 58.6995))
18351835
cache_glob = str(tmp_path / "geometry_slices_v1" / "*.json")
1836-
with pyresample.config.set(cache_dir=tmp_path, cache_geom_slices=cache_slices):
1836+
with pyresample.config.set(cache_dir=tmp_path, cache_geometry_slices=cache_slices):
18371837
assert len(glob(cache_glob)) == 0
18381838
slice_x, slice_y = src_area.get_area_slices(crop_area)
18391839
assert len(glob(cache_glob)) == int(cache_slices)
@@ -1857,7 +1857,7 @@ def test_area_slices_caching_no_swaths(self, tmp_path, create_test_area, create_
18571857
lats = create_test_latitude(25.0, 35.0, shape=(1000, 500))
18581858
swath = create_test_swath(lons, lats)
18591859

1860-
with pyresample.config.set(cache_dir=tmp_path, cache_geom_slices=True), pytest.raises(NotImplementedError):
1860+
with pyresample.config.set(cache_dir=tmp_path, cache_geometry_slices=True), pytest.raises(NotImplementedError):
18611861
with pytest.warns(UserWarning, match="unhashable"):
18621862
get_area_slices(swath, area, None)
18631863

0 commit comments

Comments
 (0)