Skip to content

Commit

Permalink
fix class naming conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Gilman committed Oct 29, 2024
1 parent 0680968 commit 66cbe6d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from lenstronomy.LensModel.Profiles.gaussian import Gaussian
import numpy as np

class Gaussian(Halo):
class GaussianHalo(Halo):
"""
The base class for a Gaussian fluctuation
Expand All @@ -19,8 +19,8 @@ def __init__(self, mass, x, y, r3d, z,
self._concentration_class = concentration_class
self._truncation_class = truncation_class
mdef = 'GAUSSIAN_KAPPA'
super(Gaussian, self).__init__(mass, x, y, r3d, mdef, z, sub_flag,
lens_cosmo_instance, args, unique_tag, fixed_position=True)
super(GaussianHalo, self).__init__(mass, x, y, r3d, mdef, z, sub_flag,
lens_cosmo_instance, args, unique_tag, fixed_position=True)

@property
def profile_args(self):
Expand Down
10 changes: 5 additions & 5 deletions pyHalo/realization_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pyHalo.Halos.HaloModels.powerlaw import PowerLawSubhalo, PowerLawFieldHalo, GlobularCluster
from pyHalo.Halos.HaloModels.generalized_nfw import GeneralNFWSubhalo, GeneralNFWFieldHalo
from pyHalo.single_realization import Realization
from pyHalo.Halos.HaloModels.gaussian import Gaussian
from pyHalo.Halos.HaloModels.gaussianhalo import GaussianHalo
from pyHalo.Rendering.correlated_structure import CorrelatedStructure
from pyHalo.Rendering.MassFunctions.delta_function import DeltaFunction
from pyHalo.Rendering.MassFunctions.gaussian import Gaussian
Expand Down Expand Up @@ -557,10 +557,10 @@ def _get_fluctuation_halos(realization, fluctuation_amplitude, fluctuation_size,

args_fluc=[{'amp': amps[i], 'sigma': sigs[i], 'center_x': xs[i], 'center_y': ys[i]} for i in range(len(amps))]
masses = np.absolute(amps)
fluctuations = [Gaussian(masses[i], xs[i], ys[i], None, realization.lens_cosmo.z_lens,
True, realization.lens_cosmo, args_fluc[i],
truncation_class=None, concentration_class=None,
unique_tag=np.random.rand()) for i in range(len(amps))]
fluctuations = [GaussianHalo(masses[i], xs[i], ys[i], None, realization.lens_cosmo.z_lens,
True, realization.lens_cosmo, args_fluc[i],
truncation_class=None, concentration_class=None,
unique_tag=np.random.rand()) for i in range(len(amps))]

return fluctuations

Expand Down
4 changes: 2 additions & 2 deletions pyHalo/single_realization.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pyHalo.Halos.HaloModels.PTMass import PTMass
from pyHalo.Halos.HaloModels.ULDM import ULDMFieldHalo, ULDMSubhalo
from pyHalo.Halos.HaloModels.NFW_core_trunc import TNFWCFieldHaloSIDM, TNFWCSubhaloSIDM
from pyHalo.Halos.HaloModels.gaussian import Gaussian
from pyHalo.Halos.HaloModels.gaussianhalo import GaussianHalo
import numpy as np
from copy import deepcopy

Expand Down Expand Up @@ -677,7 +677,7 @@ def _load_halo_model(mass, x, y, r3d, mdef, z, is_subhalo,
else:
model = ULDMFieldHalo
elif mdef == 'GAUSSIAN_KAPPA':
model = Gaussian
model = GaussianHalo
elif mdef == 'GNFW':
if is_subhalo:
model = GeneralNFWSubhalo
Expand Down
8 changes: 4 additions & 4 deletions tests/test_halos/test_gaussian.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy.testing as npt
import numpy as np
from pyHalo.Halos.HaloModels.gaussian import Gaussian
from pyHalo.Halos.HaloModels.gaussianhalo import GaussianHalo
from pyHalo.Halos.lens_cosmo import LensCosmo
from pyHalo.Cosmology.cosmology import Cosmology
from astropy.cosmology import FlatLambdaCDM
Expand All @@ -22,9 +22,9 @@ def setup_method(self):
lens_cosmo = LensCosmo(z, 2., cosmo)
profile_args = {'amp':1,'sigma':1,'center_x':1.0,'center_y':1.0}
sub_flag = False
self.halo = Gaussian(mass, x, y, r3d, z,
sub_flag, lens_cosmo,
profile_args, None, None, unique_tag=np.random.rand())
self.halo = GaussianHalo(mass, x, y, r3d, z,
sub_flag, lens_cosmo,
profile_args, None, None, unique_tag=np.random.rand())

def test_lenstronomy_params(self):

Expand Down
7 changes: 4 additions & 3 deletions tests/test_halos/test_globular_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ def test_lenstronomy_ID(self):
profile = GlobularCluster(mass, 0.0, 0.0, self.zhalo, self.lens_cosmo,
args, 1)
lenstronomy_ID = profile.lenstronomy_ID
npt.assert_string_equal(lenstronomy_ID[0], 'SPLCORE')
npt.assert_string_equal(lenstronomy_ID[0], 'SPL_CORE')

def test_lenstronomy_args(self):

mass = 10 ** 5
logM = 5.0
mass = 10 ** logM
args = {'gamma': 2.5,
'r_core_fraction': 0.05,
'gc_size_lightyear': 100}
Expand All @@ -45,7 +46,7 @@ def test_lenstronomy_args(self):
sigma_crit_mpc = self.lens_cosmo.get_sigma_crit_lensing(profile.z, self.lens_cosmo.z_source)
kpc_per_arcsec = self.lens_cosmo.cosmo.kpc_proper_per_asec(profile.z)
sigma_crit_arcsec = sigma_crit_mpc * (0.001 * kpc_per_arcsec) ** 2
npt.assert_almost_equal(np.log10(mass), np.log10(mass * sigma_crit_arcsec))
npt.assert_almost_equal(logM, np.log10(mass * sigma_crit_arcsec))

if __name__ == '__main__':
pytest.main()

0 comments on commit 66cbe6d

Please sign in to comment.