Skip to content

Commit

Permalink
Remove lru_cache on LOS methods
Browse files Browse the repository at this point in the history
The 'self' argument is included in the caching calculation, and the cache is kept globally with the class (not with each instance, as you might expect). One of these even has an unbound size! Finally, these don't actually provide an appreciable speedup.
  • Loading branch information
JelleAalbers committed Nov 20, 2022
1 parent 2edd7f4 commit 6f1c419
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions paltas/Substructure/los_dg19.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import numpy as np
from colossus.lss import peaks, bias
from ..Utils import power_law, cosmology_utils
import functools
from . import nfw_functions
import lenstronomy.Util.util as util
from lenstronomy.LensModel.Profiles.nfw import NFW
Expand Down Expand Up @@ -121,7 +120,6 @@ def dn_dm(self,m,z):

return -1/3*nfn_eval*rho_m/m**2*d_ln_sigma_d_ln_r

@functools.lru_cache(maxsize=None)
def power_law_dn_dm(self,z,m_min,m_max,n_dm=100):
"""Returns the best fit power law parameters for the physical number
density at a given redshift and mass range.
Expand Down Expand Up @@ -192,7 +190,6 @@ def two_halo_boost(self,z,z_lens,dz,lens_m200,r_max,r_min,n_quads=100):
model='tinker10')
return 1+np.mean(xi_halo)

@functools.lru_cache(maxsize=1024)
def cone_angle_to_radius(self,z,z_lens,z_source,cone_angle,
angle_buffer=0.8):
"""Returns the radius in kpc at the given redshift for the given cone
Expand Down Expand Up @@ -228,7 +225,6 @@ def cone_angle_to_radius(self,z,z_lens,z_source,cone_angle,
r_los *= 1 - scal_factor
return r_los

@functools.lru_cache(maxsize=1024)
def volume_element(self,z,z_lens,z_source,dz,cone_angle,angle_buffer=0.8):
"""Returns the physical volume element at the given redshift
Expand Down

0 comments on commit 6f1c419

Please sign in to comment.