Commit 5f43e618 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

re-introduce caching

parent 6cad3319
Pipeline #14356 passed with stage
in 5 minutes and 22 seconds
......@@ -22,6 +22,8 @@ from d2o import distributed_data_object
from import Space
_PSCache = {}
class PowerSpace(Space):
""" NIFTY class for spaces of power spectra.
......@@ -100,6 +102,16 @@ class PowerSpace(Space):
raise ValueError(
"if binbounds is defined, nbin and logarithmic must be None")
if binbounds is not None:
binbounds = tuple(binbounds)
key = (harmonic_partner, distribution_strategy, logarithmic, nbin,
if _PSCache.get(key) is not None:
(self._binbounds, self._pindex, self._kindex, self._rho) \
= _PSCache[key]
self._binbounds = None
if logarithmic is None and nbin is None and binbounds is None:
bb = self._harmonic_partner.get_natural_binbounds()
......@@ -147,6 +159,9 @@ class PowerSpace(Space):
self._kindex = self._pindex.bincount(
_PSCache[key] = \
(self._binbounds, self._pindex, self._kindex, self._rho)
def pre_cast(self, x, axes):
""" Casts power spectrum functions to discretized power spectra.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment