diff --git a/Project.toml b/Project.toml index 9fe750cda..eef2514e5 100644 --- a/Project.toml +++ b/Project.toml @@ -23,6 +23,7 @@ IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c" LogDensityProblemsAD = "996a588d-648d-4e1f-a8f0-a84b347e47b1" +MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" NamedTupleTools = "d9ec5142-1e00-5aa0-9d6a-321866360f50" PaddedViews = "5432bcbf-9aad-5242-b902-cca2824c8663" ParameterHandling = "2412ca09-6db7-441c-8e3a-88d5709968c5" @@ -62,8 +63,8 @@ ComradePigeonsExt = "Pigeons" ComradePyehtimExt = "Pyehtim" [compat] -Accessors = "0.1" AbstractMCMC = "3, 4, 5" +Accessors = "0.1" AdvancedHMC = "0.6" ArgCheck = "2" AstroTime = "0.6,0.7" @@ -80,8 +81,8 @@ FillArrays = "0.12, 0.13, 1" ForwardDiff = "0.9, 0.10" HypercubeTransform = "0.4" IntervalSets = "0.6, 0.7" -LogDensityProblemsAD = "1" LogDensityProblems = "2" +LogDensityProblemsAD = "1" Makie = "0.21" NamedTupleTools = "0.13,0.14" NestedSamplers = "0.8" diff --git a/src/skymodels/macro.jl b/src/skymodels/macro.jl new file mode 100644 index 000000000..232db2bef --- /dev/null +++ b/src/skymodels/macro.jl @@ -0,0 +1,38 @@ +using MacroTools +using NamedTupleTools + + +# Idea +# 1. capture all tilde statements and convert them to a NamedTupleDist +# 2. capture all equals signs and convert make a function with a gensym name +# 3. capture all arguments and make a named tuple with them as metadata + + +macro sky(expr) + # println(expr) + def = splitdef(expr) + name = def[:name] + args = def[:args] + kwargs = def[:kwargs] + body = def[:body] + + g = args[1] + gexpr = Expr(:kw, g, esc(g)) + metadata = build_metadata([kwargs...,gexpr]) + prior = build_prior(metadata, body) + # skym = build_sky(args, kwargs, body) + return quote + $metadata + # $(esc(name)) = SkyModel($skym, $prior, $g; metadata=$metadata) + # $name = SkyModel($skym, $prior, $g; metadata=$metadata) + end +end + +function build_metadata(kwargs) + isempty(kwargs) && return nothing + return Expr(:tuple, Expr(:parameters, kwargs..., (:))) +end + +function build_prior(metadata, body) + +end