fix(cache): distinguish callables in the shared EMS cache

Include the function object in cache keys so methods of one interpolator cannot reuse a probability as a power value. Cover both call orders, keyword arguments, cache hits and separate closures with identical qualified names.
This commit is contained in:
Andreas
2026-09-16 18:27:34 +02:00
parent 2b76a33b57
commit a4ebc72f4e
2 changed files with 52 additions and 0 deletions
+3
View File
@@ -228,6 +228,9 @@ def cache_energy_management(
cached_wrapper = cachebox.cached(
cache=CacheEnergyManagementStore().cache,
# This store is shared by all decorated callables, including methods
# on the same instance. Arguments alone cannot identify their results.
key_maker=lambda *args, **kwargs: cachebox.make_key(func, *args, **kwargs),
callback=cache_energy_management_store_callback,
)(wrapper)