Skip to content

Commit

Permalink
Merge pull request #47 from JuliaAstro/documenter-update
Browse files Browse the repository at this point in the history
Documenter update and doctests in test suite
  • Loading branch information
abhro authored Jun 13, 2024
2 parents 87e62fd + ccca60b commit e145c44
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 20 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"]
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
12 changes: 8 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Documenter
using Cosmology
using Documenter.Remotes: GitHub


DocMeta.setdocmeta!(Cosmology, :DocTestSetup, :(using Cosmology); recursive = true)
Expand All @@ -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",
)
11 changes: 7 additions & 4 deletions docs/src/api.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
```@meta
DocTestSetup = :(using Cosmology, Unitful, UnitfulAstro)
DocTestSetup = quote
using Cosmology, Unitful, UnitfulAstro
ENV["UNITFUL_FANCY_EXPONENTS"] = false
end
```

# API/Reference
Expand Down Expand Up @@ -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
Expand All @@ -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
```
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 18 additions & 8 deletions src/Cosmology.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Cosmology

using QuadGK, Unitful
using QuadGK
using Unitful
import Unitful: km, s, Gyr
using UnitfulAstro: Mpc, Gpc

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -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/

Expand Down

2 comments on commit e145c44

@abhro
Copy link
Member Author

@abhro abhro commented on e145c44 Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/108922

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.3 -m "<description of version>" e145c44a257239b6bcb27b14db55b3f7b553de37
git push origin v1.0.3

Please sign in to comment.