Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
5f43e618
Commit
5f43e618
authored
Jul 04, 2017
by
Martin Reinecke
Browse files
re-introduce caching
parent
6cad3319
Pipeline
#14356
passed with stage
in 5 minutes and 22 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty/spaces/power_space/power_space.py
View file @
5f43e618
...
...
@@ -22,6 +22,8 @@ from d2o import distributed_data_object
from
nifty.spaces.space
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
,
binbounds
)
if
_PSCache
.
get
(
key
)
is
not
None
:
(
self
.
_binbounds
,
self
.
_pindex
,
self
.
_kindex
,
self
.
_rho
)
\
=
_PSCache
[
key
]
return
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
(
weights
=
dists
).
get_full_data
()
/
self
.
_rho
_PSCache
[
key
]
=
\
(
self
.
_binbounds
,
self
.
_pindex
,
self
.
_kindex
,
self
.
_rho
)
def
pre_cast
(
self
,
x
,
axes
):
""" Casts power spectrum functions to discretized power spectra.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment