Skip to content

Commit cf28a95

Browse files
authored
Merge pull request #57 from icweaver/remove-codegen
Slay the dragon
2 parents d46b630 + 6ef359a commit cf28a95

File tree

9 files changed

+15
-25
lines changed

9 files changed

+15
-25
lines changed

src/DustExtinction.jl

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,9 @@ include("dust_maps.jl")
161161
include("fittable_laws.jl")
162162
include("mixture_laws.jl")
163163

164-
# --------------------------------------------------------------------------------
165-
# Here be codegen!
166-
167-
# generate unitful support for the following laws
168-
# this can be removed when julia support is pinned to 1.3 or higher,
169-
# at which point adding `(l::ExtinctionLaw)(wave::Quantity)` is possible, until then
170-
# using this code-gen does the trick but requires manually editing
171-
# instead of providing support for all <: ExtinctionLaw
172-
for law in [CCM89, OD94, CAL00, GCC09, VCG04, FM90, G16, G03_SMCBar, G03_LMCAve, F99, F04, F19, M14]
173-
(l::law)(wavelength::U.Quantity) = l(U.ustrip(U.u"Å", wavelength)) * U.u"mag"
174-
end
164+
# generate unitful support
165+
(l::ExtinctionLaw)(wavelength::U.Quantity) = l(U.ustrip(U.u"Å", wavelength)) * U.u"mag"
175166

176-
# --------------------------------------------------------------------------------
177167

178168
function __init__()
179169
# register our data dependencies

src/color_laws.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Base.@kwdef struct OD94 <: ExtinctionLaw
2222
Rv::Float64 = 3.1
2323
end
2424

25-
function (law::OD94)(wave::T) where T
25+
function (law::OD94)(wave::T) where T <: Real
2626
checkbounds(law, wave) || return zero(float(T))
2727
x = aa_to_invum(wave)
2828
return ccm89_invum(x, law.Rv, od94_ca, od94_cb)
@@ -50,7 +50,7 @@ fit value for such galaxies was 4.05±0.80.
5050
Base.@kwdef struct CAL00 <: ExtinctionLaw
5151
Rv::Float64 = 4.05
5252
end
53-
function (law::CAL00)(wave::T) where T
53+
function (law::CAL00)(wave::T) where T <: Real
5454
checkbounds(law, wave) || return zero(float(T))
5555
x = aa_to_invum(wave)
5656
if wave < 6300

src/color_laws/ccm89.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Base.@kwdef struct CCM89 <: ExtinctionLaw
2222
Rv::Float64 = 3.1
2323
end
2424

25-
function (law::CCM89)(wave::T) where T
25+
function (law::CCM89)(wave::T) where T <: Real
2626
checkbounds(law, wave) || return zero(float(T))
2727
x = aa_to_invum(wave)
2828
return ccm89_invum(x, law.Rv, ccm89_ca, ccm89_cb)

src/color_laws/fitzpatrick.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Base.@kwdef struct F99 <: ExtinctionLaw
7676
Rv::Float64 = 3.1
7777
end
7878

79-
function (law::F99)(wave::T) where T
79+
function (law::F99)(wave::T) where T <: Real
8080
checkbounds(law, wave) || return zero(float(T))
8181
x = aa_to_invum(wave)
8282
return f99_invum(x, law.Rv)
@@ -169,7 +169,7 @@ Base.@kwdef struct F04 <: ExtinctionLaw
169169
Rv::Float64 = 3.1
170170
end
171171

172-
function (law::F04)(wave::T) where T
172+
function (law::F04)(wave::T) where T <: Real
173173
checkbounds(law, wave) || return zero(float(T))
174174
x = aa_to_invum(wave)
175175
return f04_invum(x, law.Rv)
@@ -246,7 +246,7 @@ Base.@kwdef struct F19 <: ExtinctionLaw
246246
Rv::Float64 = 3.1
247247
end
248248

249-
function (law::F19)(wave::T) where T
249+
function (law::F19)(wave::T) where T <: Real
250250
checkbounds(law, wave) || return zero(float(T))
251251
x = aa_to_invum(wave)
252252
return f19_invum(x, law.Rv)

src/color_laws/gcc09.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Base.@kwdef struct GCC09 <: ExtinctionLaw
1313
Rv::Float64 = 3.1
1414
end
1515

16-
function (law::GCC09)(wave::T) where T
16+
function (law::GCC09)(wave::T) where T <: Real
1717
checkbounds(law, wave) || return zero(float(T))
1818
x = aa_to_invum(wave)
1919
return gcc09_invum(x, law.Rv)

src/color_laws/m14.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Base.@kwdef struct M14 <: ExtinctionLaw
6969
Rv::Float64 = 3.1
7070
end
7171

72-
function (law::M14)(wave::T) where T
72+
function (law::M14)(wave::T) where T <: Real
7373
checkbounds(law, wave) || return zero(float(T))
7474
x = aa_to_invum(wave)
7575
return m14_invum(x, law.Rv)

src/color_laws/vcg04.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Base.@kwdef struct VCG04 <: ExtinctionLaw
1313
Rv::Float64 = 3.1
1414
end
1515

16-
function (law::VCG04)(wave::T) where T
16+
function (law::VCG04)(wave::T) where T <: Real
1717
checkbounds(law, wave) || return zero(float(T))
1818
x = aa_to_invum(wave)
1919
return vcg04_invum(x, law.Rv)

src/fittable_laws.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ FM90(coeffs, x0=4.60, gamma=0.99) = FM90(coeffs..., x0, gamma)
6464

6565
bounds(::Type{<:FM90}) = (912, 3200)
6666

67-
function (law::FM90)(wave::T) where T
67+
function (law::FM90)(wave::T) where T <: Real
6868
checkbounds(law, wave) || return zero(float(T))
6969

7070
x = aa_to_invum(wave)

src/mixture_laws.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ bounds(::Type{<:G03_SMCBar}) = (1000.0, 33333.3)
9999
bounds(::Type{<:G03_LMCAve}) = (1000.0, 33333.3)
100100

101101

102-
function (law::G03_SMCBar)(wave::T) where T
102+
function (law::G03_SMCBar)(wave::T) where T <: Real
103103
checkbounds(law, wave) || return zero(float(T))
104104
x = aa_to_invum(wave)
105105
return g03_invum(x, law.Rv)
106106
end
107107

108-
function (law::G03_LMCAve)(wave::T) where T
108+
function (law::G03_LMCAve)(wave::T) where T <: Real
109109
checkbounds(law, wave) || return zero(float(T))
110110
x = aa_to_invum(wave)
111111
return g03lmc_invum(x, law.Rv)
@@ -180,7 +180,7 @@ end
180180

181181
bounds(::Type{<:G16}) = (1000.0, 33333.3)
182182

183-
function (law::G16)(wave::T) where T
183+
function (law::G16)(wave::T) where T <: Real
184184
checkbounds(law, wave) || return zero(float(T))
185185
x = aa_to_invum(wave)
186186
return g16_invum(x, law.Rv, law.f_A)

0 commit comments

Comments
 (0)