Skip to content

Commit

Permalink
better caching
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetanfacchinetti committed Mar 18, 2024
1 parent e53d7f2 commit 22f76ab
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/HostHalos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export circular_velocity, circular_period, number_circular_orbits, velocity_disp
export circular_velocity_kms, velocity_dispersion_spherical_kms
export milky_way_MM17_g1, milky_way_MM17_g0
export maximum_impact_parameter, number_stellar_encounters, stellar_mass_function, stellar_mass_model_C03, moments_stellar_mass
export preload!
export load!

abstract type BulgeModel{T<:Real} end
abstract type GasModel{T<:Real} end
Expand Down Expand Up @@ -66,6 +66,11 @@ function Base.getproperty(obj::HostModel, s::Symbol)
return getfield(obj, s)
end


# overrinding print function
Base.show(io::IO, host::HostModel) = print(io, "host name : " * host.name)


ρ_HI(r::Real, z::Real, host::HostModel) = ρ_gas(r, z, host.gas_HI)
ρ_H2(r::Real, z::Real, host::HostModel) = ρ_gas(r, z, host.gas_H2)
ρ_ISM(r::Real, z, host::HostModel) = ρ_HI(r, z, host) + ρ_H2(r, z, host)
Expand Down Expand Up @@ -303,7 +308,7 @@ function _load(host::HostModel, s::Symbol)
end

# preload a number of functions
function preload!(host::HostModel)
function load!(host::HostModel)
for field in fieldnames(HostModel)
(getfield(host, field) === nothing) && setfield!(host, field, _load(host, field))
end
Expand Down

0 comments on commit 22f76ab

Please sign in to comment.