diff --git a/Project.toml b/Project.toml index 0913331..d86420e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Cosmology" uuid = "76746363-e552-5dba-9a5a-cef6fa9cc5ab" -version = "1.0.2" +version = "1.0.3" [deps] QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" @@ -15,6 +15,7 @@ julia = "1" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" [targets] -test = ["Test"] +test = ["Test", "Documenter"] diff --git a/docs/Project.toml b/docs/Project.toml index 7d1c29c..c6778be 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -4,4 +4,4 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" UnitfulAstro = "6112ee07-acf9-5e0f-b108-d242c714bf9f" [compat] -Documenter = "0.24, 0.25, 0.26, 0.27" +Documenter = "0.24, 0.25, 0.26, 0.27, 1" diff --git a/docs/make.jl b/docs/make.jl index 33bbdc0..7e97b6a 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,5 +1,6 @@ using Documenter using Cosmology +using Documenter.Remotes: GitHub DocMeta.setdocmeta!(Cosmology, :DocTestSetup, :(using Cosmology); recursive = true) @@ -9,13 +10,16 @@ include("pages.jl") makedocs(; modules = [Cosmology], authors = "Julia Astro", - repo = "https://github.com/JuliaAstro/Cosmology.jl/blob/{commit}{path}#L{line}", + repo = GitHub("JuliaAstro/Cosmology.jl"), sitename = "Cosmology.jl", format = Documenter.HTML(; prettyurls = get(ENV, "CI", "false") == "true", canonical = "https://juliaastro.github.io/Cosmology.jl", - assets = String[],), - pages=pages,) + assets = String[], + ), + pages=pages, +) deploydocs(; - repo = "github.com/JuliaAstro/Cosmology.jl",) + repo = "github.com/JuliaAstro/Cosmology.jl", +) diff --git a/docs/src/api.md b/docs/src/api.md index 8ddc9d0..a19a63b 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -1,5 +1,8 @@ ```@meta -DocTestSetup = :(using Cosmology, Unitful, UnitfulAstro) +DocTestSetup = quote + using Cosmology, Unitful, UnitfulAstro + ENV["UNITFUL_FANCY_EXPONENTS"] = false +end ``` # API/Reference @@ -62,7 +65,7 @@ julia> c = cosmology(OmegaM=0.26) Cosmology.FlatLCDM{Float64}(0.69, 0.7399122024007928, 0.26, 8.77975992071536e-5) julia> comoving_volume_element(c, 2.1) -46.74459228888612 Gpc^3 +46.74459228888613 Gpc^3 julia> comoving_volume(c, 0.6) 49.3633436631307 Gpc^3 @@ -84,8 +87,8 @@ julia> c = cosmology(OmegaM=0.26) Cosmology.FlatLCDM{Float64}(0.69, 0.7399122024007928, 0.26, 8.77975992071536e-5) julia> age(c, 1.2) -5.445600787626434 Gyr +5.4454795007229455 Gyr julia> lookback_time(u"yr", c, 1.2) -8.761660748088268e9 yr +8.761465604385489e9 yr ``` diff --git a/docs/src/index.md b/docs/src/index.md index edb7d82..0cd6cb0 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -3,7 +3,7 @@ [![Build Status](https://img.shields.io/travis/JuliaAstro/Cosmology.jl.svg?style=flat-square&label=build)](https://travis-ci.org/JuliaAstro/Cosmology.jl) [![Coverage Status](http://img.shields.io/coveralls/JuliaAstro/Cosmology.jl.svg?style=flat-square)](https://coveralls.io/r/JuliaAstro/Cosmology.jl?branch=master) -[`Cosmology.jl`](https://github.com/JuliaAstro/Cosmology.jl) provides functions for quick cosmological calculations, written in pure Julia. +[`Cosmology.jl`](https://github.com/JuliaAstro/Cosmology.jl) provides functions for quick cosmological calculations, written in pure Julia. ## Installation diff --git a/src/Cosmology.jl b/src/Cosmology.jl index a32cc7e..3829816 100644 --- a/src/Cosmology.jl +++ b/src/Cosmology.jl @@ -1,6 +1,7 @@ module Cosmology -using QuadGK, Unitful +using QuadGK +using Unitful import Unitful: km, s, Gyr using UnitfulAstro: Mpc, Gpc @@ -187,7 +188,9 @@ comoving_radial_dist(c::AbstractCosmology, z₁, z₂ = nothing; kws...) = hubbl """ comoving_radial_dist([u::Unitlike,] c::AbstractCosmology, [z₁,] z₂) -Comoving radial distance in Mpc at redshift `z₂` as seen by an observer at `z₁`. Redshift `z₁` defaults to 0 if omitted. Will convert to compatible unit `u` if provided. +Comoving radial distance in Mpc at redshift `z₂` as seen by an observer at `z₁`. +Redshift `z₁` defaults to 0 if omitted. Will convert to compatible unit `u` if +provided. """ comoving_radial_dist @@ -211,7 +214,9 @@ angular_diameter_dist(c::AbstractCosmology, z₁, z₂; kws...) = """ angular_diameter_dist([u::Unitlike,] c::AbstractCosmology, [z₁,] z₂) -Ratio of the proper transverse size in Mpc of an object at redshift `z₂` to its angular size in radians, as seen by an observer at `z₁`. Redshift `z₁` defaults to 0 if omitted. Will convert to compatible unit `u` if provided. +Ratio of the proper transverse size in Mpc of an object at redshift `z₂` to its +angular size in radians, as seen by an observer at `z₁`. Redshift `z₁` defaults +to 0 if omitted. Will convert to compatible unit `u` if provided. """ angular_diameter_dist @@ -221,7 +226,8 @@ luminosity_dist(c::AbstractCosmology, z; kws...) = """ luminosity_dist([u::Unitlike,] c::AbstractCosmology, z) -Bolometric luminosity distance in Mpc at redshift `z`. Will convert to compatible unit `u` if provided. +Bolometric luminosity distance in Mpc at redshift `z`. Will convert to +compatible unit `u` if provided. """ luminosity_dist @@ -266,6 +272,7 @@ comoving_volume_element(c::AbstractCosmology, z; kws...) = # times T(c::AbstractCosmology, a0, a1; kws...) = QuadGK.quadgk(x->x / a2E(c, x), a0, a1; kws...)[1] + """ age([u::Unitlike,] c::AbstractCosmology, z) @@ -276,14 +283,17 @@ age(c::AbstractCosmology, z; kws...) = hubble_time0(c) * T(c, 0, scale_factor(z) """ lookback_time([u::Unitlike,] c::AbstractCosmology, z) -Difference between age at redshift 0 and age at redshift `z` in Gyr. Will convert to compatible unit `u` if provided. +Difference between age at redshift 0 and age at redshift `z` in Gyr. +Will convert to compatible unit `u` if provided. """ lookback_time(c::AbstractCosmology, z; kws...) = hubble_time0(c) * T(c, scale_factor(z), 1; kws...) # Easily select a different unit -for f in (:hubble_dist0, :hubble_dist, :hubble_time0, :hubble_time, :comoving_radial_dist, - :comoving_transverse_dist, :angular_diameter_dist, :luminosity_dist, - :comoving_volume, :comoving_volume_element, :age, :lookback_time) +for f in (:hubble_dist0, :hubble_dist, :hubble_time0, :hubble_time, + :comoving_radial_dist, :comoving_transverse_dist, + :angular_diameter_dist, :luminosity_dist, + :comoving_volume, :comoving_volume_element, + :age, :lookback_time) @eval $f(u::Unitful.Unitlike, args...; kws...) = uconvert(u, $f(args...; kws...)) end diff --git a/test/runtests.jl b/test/runtests.jl index fce4b29..88766fc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,9 @@ using Cosmology using Test, Unitful, UnitfulAstro, QuadGK +using Documenter + +DocMeta.setdocmeta!(Cosmology, :DocTestSetup, :(using Cosmology); recursive = true) +doctest(Cosmology) # values from http://icosmos.co.uk/