Skip to content

Commit eb681ac

Browse files
authored
Merge pull request #48 from JuliaAstro/isolate-doctests
Isolate doctests
2 parents e145c44 + a917cbf commit eb681ac

File tree

1 file changed

+135
-126
lines changed

1 file changed

+135
-126
lines changed

test/runtests.jl

Lines changed: 135 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -2,143 +2,152 @@ using Cosmology
22
using Test, Unitful, UnitfulAstro, QuadGK
33
using Documenter
44

5-
DocMeta.setdocmeta!(Cosmology, :DocTestSetup, :(using Cosmology); recursive = true)
6-
doctest(Cosmology)
5+
@testset "Cosmology" begin
76

8-
# values from http://icosmos.co.uk/
7+
# Doctest is good for CI, but has variation in system to system. For now,
8+
# only run on supported systems as a measure that the docs are reasonably
9+
# accurate.
10+
doctest_conds = Bool[Sys.islinux(), Sys.ARCH == :x86_64]
11+
if all(doctest_conds)
12+
DocMeta.setdocmeta!(Cosmology, :DocTestSetup, :(using Cosmology); recursive = true)
13+
doctest(Cosmology)
14+
end
915

10-
dist_rtol = 1e-6
11-
age_rtol = 2e-4
12-
# Integrating a unitful function would require UnitfulIntegration.jl. Without using it, we
13-
# strip the units away from the integrand function
14-
integrand(c, z) = 4pi*ustrip(comoving_volume_element(c, z))
16+
# values from http://icosmos.co.uk/
1517

16-
@testset "FlatLCDM" begin
17-
c = cosmology(h=0.7, OmegaM=0.3, OmegaR=0)
18-
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1651.9145u"Mpc" rtol = dist_rtol
19-
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 625.3444u"Mpc" rtol = dist_rtol
20-
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
21-
@test comoving_radial_dist(c,1,rtol=dist_rtol) 3303.829u"Mpc" rtol = dist_rtol
22-
@test comoving_volume(c,1,rtol=dist_rtol) 151.0571u"Gpc^3" rtol = dist_rtol
23-
@test quadgk(z -> integrand(c, z), 0, 2.5)[1] ustrip(comoving_volume(c, 2.5))
24-
@test luminosity_dist(c,1,rtol=dist_rtol) 6607.6579u"Mpc" rtol = dist_rtol
25-
@test distmod(c,1,rtol=dist_rtol) 44.1002 rtol = dist_rtol
26-
@test age(c,0,rtol=age_rtol) 13.4694u"Gyr" rtol = age_rtol
27-
@test age(c,1,rtol=age_rtol) 5.7527u"Gyr" rtol = age_rtol
28-
@test lookback_time(c,1,rtol=age_rtol) (13.4694-5.7527)u"Gyr" rtol = age_rtol
29-
@test age(c, 1) + lookback_time(c, 1) age(c, 0)
30-
end
18+
dist_rtol = 1e-6
19+
age_rtol = 2e-4
20+
# Integrating a unitful function would require UnitfulIntegration.jl. Without using it, we
21+
# strip the units away from the integrand function
22+
integrand(c, z) = 4pi*ustrip(comoving_volume_element(c, z))
3123

32-
@testset "OpenLCDM" begin
33-
c = cosmology(h=0.7, OmegaK=0.1, OmegaM=0.3, OmegaR=0)
34-
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1619.9588u"Mpc" rtol = dist_rtol
35-
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 598.9118u"Mpc" rtol = dist_rtol
36-
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
37-
@test comoving_radial_dist(c,1,rtol=dist_rtol) 3209.784u"Mpc" rtol = dist_rtol
38-
@test comoving_volume(c,1,rtol=dist_rtol) 140.0856u"Gpc^3" rtol = dist_rtol
39-
@test quadgk(z -> integrand(c, z), 0, 2.5)[1] ustrip(comoving_volume(c, 2.5))
40-
@test luminosity_dist(c,1,rtol=dist_rtol) 6479.8352u"Mpc" rtol = dist_rtol
41-
@test distmod(c,1,rtol=dist_rtol) 44.0578 rtol = dist_rtol
42-
@test age(c,0,rtol=age_rtol) 13.064u"Gyr" rtol = age_rtol
43-
@test age(c,1,rtol=age_rtol) 5.5466u"Gyr" rtol = age_rtol
44-
@test lookback_time(c,1,rtol=age_rtol) (13.064-5.5466)u"Gyr" rtol = age_rtol
45-
@test age(c, 1) + lookback_time(c, 1) age(c, 0)
46-
end
24+
@testset "FlatLCDM" begin
25+
c = cosmology(h=0.7, OmegaM=0.3, OmegaR=0)
26+
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1651.9145u"Mpc" rtol = dist_rtol
27+
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 625.3444u"Mpc" rtol = dist_rtol
28+
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
29+
@test comoving_radial_dist(c,1,rtol=dist_rtol) 3303.829u"Mpc" rtol = dist_rtol
30+
@test comoving_volume(c,1,rtol=dist_rtol) 151.0571u"Gpc^3" rtol = dist_rtol
31+
@test quadgk(z -> integrand(c, z), 0, 2.5)[1] ustrip(comoving_volume(c, 2.5))
32+
@test luminosity_dist(c,1,rtol=dist_rtol) 6607.6579u"Mpc" rtol = dist_rtol
33+
@test distmod(c,1,rtol=dist_rtol) 44.1002 rtol = dist_rtol
34+
@test age(c,0,rtol=age_rtol) 13.4694u"Gyr" rtol = age_rtol
35+
@test age(c,1,rtol=age_rtol) 5.7527u"Gyr" rtol = age_rtol
36+
@test lookback_time(c,1,rtol=age_rtol) (13.4694-5.7527)u"Gyr" rtol = age_rtol
37+
@test age(c, 1) + lookback_time(c, 1) age(c, 0)
38+
end
4739

48-
@testset "ClosedLCDM" begin
49-
c = cosmology(h=0.7, OmegaK=-0.1, OmegaM=0.3, OmegaR=0)
50-
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1686.5272u"Mpc" rtol = dist_rtol
51-
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 655.6019u"Mpc" rtol = dist_rtol
52-
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
53-
@test comoving_radial_dist(c,1,rtol=dist_rtol) 3408.937u"Mpc" rtol = dist_rtol
54-
@test comoving_volume(c,1,rtol=dist_rtol) 163.8479u"Gpc^3" rtol = dist_rtol
55-
@test quadgk(z -> integrand(c, z), 0, 2.5)[1] ustrip(comoving_volume(c, 2.5))
56-
@test luminosity_dist(c,1,rtol=dist_rtol) 6746.1088u"Mpc" rtol = dist_rtol
57-
@test distmod(c,1,rtol=dist_rtol) 44.1453 rtol = dist_rtol
58-
@test age(c,0,rtol=age_rtol) 13.925u"Gyr" rtol = age_rtol
59-
@test age(c,1,rtol=age_rtol) 5.9868u"Gyr" rtol = age_rtol
60-
@test lookback_time(c,1,rtol=age_rtol) (13.925-5.9868)u"Gyr" rtol = age_rtol
61-
@test age(c, 1) + lookback_time(c, 1) age(c, 0)
62-
end
40+
@testset "OpenLCDM" begin
41+
c = cosmology(h=0.7, OmegaK=0.1, OmegaM=0.3, OmegaR=0)
42+
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1619.9588u"Mpc" rtol = dist_rtol
43+
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 598.9118u"Mpc" rtol = dist_rtol
44+
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
45+
@test comoving_radial_dist(c,1,rtol=dist_rtol) 3209.784u"Mpc" rtol = dist_rtol
46+
@test comoving_volume(c,1,rtol=dist_rtol) 140.0856u"Gpc^3" rtol = dist_rtol
47+
@test quadgk(z -> integrand(c, z), 0, 2.5)[1] ustrip(comoving_volume(c, 2.5))
48+
@test luminosity_dist(c,1,rtol=dist_rtol) 6479.8352u"Mpc" rtol = dist_rtol
49+
@test distmod(c,1,rtol=dist_rtol) 44.0578 rtol = dist_rtol
50+
@test age(c,0,rtol=age_rtol) 13.064u"Gyr" rtol = age_rtol
51+
@test age(c,1,rtol=age_rtol) 5.5466u"Gyr" rtol = age_rtol
52+
@test lookback_time(c,1,rtol=age_rtol) (13.064-5.5466)u"Gyr" rtol = age_rtol
53+
@test age(c, 1) + lookback_time(c, 1) age(c, 0)
54+
end
6355

64-
@testset "FlatWCDM" begin
65-
c = cosmology(h=0.7, OmegaM=0.3, OmegaR=0, w0=-0.9, wa=0.1)
66-
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1612.0585u"Mpc" rtol = dist_rtol
67-
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 607.6802u"Mpc" rtol = dist_rtol
68-
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
69-
@test comoving_radial_dist(c,1,rtol=dist_rtol) 3224.1169u"Mpc" rtol = dist_rtol
70-
@test comoving_volume(c,1,rtol=dist_rtol) 140.3851u"Gpc^3" rtol = dist_rtol
71-
@test quadgk(z -> integrand(c, z), 0, 2.5)[1] ustrip(comoving_volume(c, 2.5))
72-
@test luminosity_dist(c,1,rtol=dist_rtol) 6448.2338u"Mpc" rtol = dist_rtol
73-
@test distmod(c,1,rtol=dist_rtol) 44.0472 rtol = dist_rtol
74-
@test age(c,0,rtol=age_rtol) 13.1915u"Gyr" rtol = age_rtol
75-
@test age(c,1,rtol=age_rtol) 5.6464u"Gyr" rtol = age_rtol
76-
@test lookback_time(c,1,rtol=age_rtol) (13.1915-5.6464)u"Gyr" rtol = age_rtol
77-
@test age(c, 1) + lookback_time(c, 1) age(c, 0)
78-
end
56+
@testset "ClosedLCDM" begin
57+
c = cosmology(h=0.7, OmegaK=-0.1, OmegaM=0.3, OmegaR=0)
58+
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1686.5272u"Mpc" rtol = dist_rtol
59+
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 655.6019u"Mpc" rtol = dist_rtol
60+
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
61+
@test comoving_radial_dist(c,1,rtol=dist_rtol) 3408.937u"Mpc" rtol = dist_rtol
62+
@test comoving_volume(c,1,rtol=dist_rtol) 163.8479u"Gpc^3" rtol = dist_rtol
63+
@test quadgk(z -> integrand(c, z), 0, 2.5)[1] ustrip(comoving_volume(c, 2.5))
64+
@test luminosity_dist(c,1,rtol=dist_rtol) 6746.1088u"Mpc" rtol = dist_rtol
65+
@test distmod(c,1,rtol=dist_rtol) 44.1453 rtol = dist_rtol
66+
@test age(c,0,rtol=age_rtol) 13.925u"Gyr" rtol = age_rtol
67+
@test age(c,1,rtol=age_rtol) 5.9868u"Gyr" rtol = age_rtol
68+
@test lookback_time(c,1,rtol=age_rtol) (13.925-5.9868)u"Gyr" rtol = age_rtol
69+
@test age(c, 1) + lookback_time(c, 1) age(c, 0)
70+
end
7971

80-
@testset "OpenWCDM" begin
81-
c = cosmology(h=0.7, OmegaK=0.1, OmegaM=0.3, OmegaR=0, w0=-0.9, wa=0.1)
82-
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1588.0181u"Mpc" rtol = dist_rtol
83-
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 585.4929u"Mpc" rtol = dist_rtol
84-
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
85-
@test comoving_radial_dist(c,rtol=dist_rtol,1) 3147.6227u"Mpc" rtol = dist_rtol
86-
@test comoving_volume(c,1,rtol=dist_rtol) 132.0466u"Gpc^3" rtol = dist_rtol
87-
@test quadgk(z -> integrand(c, z), 0, 2.5)[1] ustrip(comoving_volume(c, 2.5))
88-
@test luminosity_dist(c,1,rtol=dist_rtol) 6352.0723u"Mpc" rtol = dist_rtol
89-
@test distmod(c,1,rtol=dist_rtol) 44.0146 rtol = dist_rtol
90-
@test age(c,0,rtol=age_rtol) 12.8488u"Gyr" rtol = age_rtol
91-
@test age(c,1,rtol=age_rtol) 5.4659u"Gyr" rtol = age_rtol
92-
@test lookback_time(c,1,rtol=age_rtol) (12.8488-5.4659)u"Gyr" rtol = age_rtol
93-
@test age(c, 1) + lookback_time(c, 1) age(c, 0)
94-
end
72+
@testset "FlatWCDM" begin
73+
c = cosmology(h=0.7, OmegaM=0.3, OmegaR=0, w0=-0.9, wa=0.1)
74+
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1612.0585u"Mpc" rtol = dist_rtol
75+
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 607.6802u"Mpc" rtol = dist_rtol
76+
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
77+
@test comoving_radial_dist(c,1,rtol=dist_rtol) 3224.1169u"Mpc" rtol = dist_rtol
78+
@test comoving_volume(c,1,rtol=dist_rtol) 140.3851u"Gpc^3" rtol = dist_rtol
79+
@test quadgk(z -> integrand(c, z), 0, 2.5)[1] ustrip(comoving_volume(c, 2.5))
80+
@test luminosity_dist(c,1,rtol=dist_rtol) 6448.2338u"Mpc" rtol = dist_rtol
81+
@test distmod(c,1,rtol=dist_rtol) 44.0472 rtol = dist_rtol
82+
@test age(c,0,rtol=age_rtol) 13.1915u"Gyr" rtol = age_rtol
83+
@test age(c,1,rtol=age_rtol) 5.6464u"Gyr" rtol = age_rtol
84+
@test lookback_time(c,1,rtol=age_rtol) (13.1915-5.6464)u"Gyr" rtol = age_rtol
85+
@test age(c, 1) + lookback_time(c, 1) age(c, 0)
86+
end
9587

96-
@testset "ClosedWCDM" begin
97-
c = cosmology(h=0.7, OmegaK=-0.1, OmegaM=0.3, OmegaR=0, w0=-0.9, wa=0.1)
98-
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1637.5993u"Mpc" rtol = dist_rtol
99-
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 632.5829u"Mpc" rtol = dist_rtol
100-
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
101-
@test comoving_radial_dist(c,1,rtol=dist_rtol) 3307.9932u"Mpc" rtol = dist_rtol
102-
@test comoving_volume(c,1,rtol=dist_rtol) 149.8301u"Gpc^3" rtol = dist_rtol
103-
@test quadgk(z -> integrand(c, z), 0, 2.5)[1] ustrip(comoving_volume(c, 2.5))
104-
@test luminosity_dist(c,1,rtol=dist_rtol) 6550.3973u"Mpc" rtol = dist_rtol
105-
@test distmod(c,1,rtol=dist_rtol) 44.0813 rtol = dist_rtol
106-
@test age(c,0,rtol=age_rtol) 13.5702u"Gyr" rtol = age_rtol
107-
@test age(c,1,rtol=age_rtol) 5.8482u"Gyr" rtol = age_rtol
108-
@test lookback_time(c,1,rtol=age_rtol) (13.5702-5.8482)u"Gyr" rtol = age_rtol
109-
@test age(c, 1) + lookback_time(c, 1) age(c, 0)
110-
end
88+
@testset "OpenWCDM" begin
89+
c = cosmology(h=0.7, OmegaK=0.1, OmegaM=0.3, OmegaR=0, w0=-0.9, wa=0.1)
90+
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1588.0181u"Mpc" rtol = dist_rtol
91+
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 585.4929u"Mpc" rtol = dist_rtol
92+
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
93+
@test comoving_radial_dist(c,rtol=dist_rtol,1) 3147.6227u"Mpc" rtol = dist_rtol
94+
@test comoving_volume(c,1,rtol=dist_rtol) 132.0466u"Gpc^3" rtol = dist_rtol
95+
@test quadgk(z -> integrand(c, z), 0, 2.5)[1] ustrip(comoving_volume(c, 2.5))
96+
@test luminosity_dist(c,1,rtol=dist_rtol) 6352.0723u"Mpc" rtol = dist_rtol
97+
@test distmod(c,1,rtol=dist_rtol) 44.0146 rtol = dist_rtol
98+
@test age(c,0,rtol=age_rtol) 12.8488u"Gyr" rtol = age_rtol
99+
@test age(c,1,rtol=age_rtol) 5.4659u"Gyr" rtol = age_rtol
100+
@test lookback_time(c,1,rtol=age_rtol) (12.8488-5.4659)u"Gyr" rtol = age_rtol
101+
@test age(c, 1) + lookback_time(c, 1) age(c, 0)
102+
end
111103

112-
@testset "Non-Float64" begin
113-
# Test that FlatLCDM works with non-Float64 (BigFloat in this example)
114-
c = cosmology(h=0.7, OmegaM=big(0.3), OmegaR=0)
115-
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1651.9145u"Mpc" rtol = dist_rtol
116-
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 625.3444u"Mpc" rtol = dist_rtol
117-
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
118-
@test comoving_volume_element(c, big(1.41)) 3.4030879e10u"Mpc^3" rtol = dist_rtol
119-
# Test that FlatWCDM works with non-Float64 (BigFloat in this example)
120-
c = cosmology(h=big(0.7), OmegaM=0.3, OmegaR=0, w0=-0.9, wa=0.1)
121-
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1612.0585u"Mpc" rtol = dist_rtol
122-
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 607.6802u"Mpc" rtol = dist_rtol
123-
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
124-
@test comoving_volume_element(c, big(1.41)) 3.1378625e10u"Mpc^3" rtol = dist_rtol
125-
end
104+
@testset "ClosedWCDM" begin
105+
c = cosmology(h=0.7, OmegaK=-0.1, OmegaM=0.3, OmegaR=0, w0=-0.9, wa=0.1)
106+
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1637.5993u"Mpc" rtol = dist_rtol
107+
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 632.5829u"Mpc" rtol = dist_rtol
108+
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
109+
@test comoving_radial_dist(c,1,rtol=dist_rtol) 3307.9932u"Mpc" rtol = dist_rtol
110+
@test comoving_volume(c,1,rtol=dist_rtol) 149.8301u"Gpc^3" rtol = dist_rtol
111+
@test quadgk(z -> integrand(c, z), 0, 2.5)[1] ustrip(comoving_volume(c, 2.5))
112+
@test luminosity_dist(c,1,rtol=dist_rtol) 6550.3973u"Mpc" rtol = dist_rtol
113+
@test distmod(c,1,rtol=dist_rtol) 44.0813 rtol = dist_rtol
114+
@test age(c,0,rtol=age_rtol) 13.5702u"Gyr" rtol = age_rtol
115+
@test age(c,1,rtol=age_rtol) 5.8482u"Gyr" rtol = age_rtol
116+
@test lookback_time(c,1,rtol=age_rtol) (13.5702-5.8482)u"Gyr" rtol = age_rtol
117+
@test age(c, 1) + lookback_time(c, 1) age(c, 0)
118+
end
126119

127-
@testset "Unit conversion" begin
128-
c = cosmology(h=0.9, OmegaM=0.5, OmegaR=0)
129-
for u in (u"m", u"pc", u"ly")
130-
@test unit(luminosity_dist(u, c, 1)) == u
131-
@test unit(angular_diameter_dist(u, c, 2)) == u
120+
@testset "Non-Float64" begin
121+
# Test that FlatLCDM works with non-Float64 (BigFloat in this example)
122+
c = cosmology(h=0.7, OmegaM=big(0.3), OmegaR=0)
123+
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1651.9145u"Mpc" rtol = dist_rtol
124+
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 625.3444u"Mpc" rtol = dist_rtol
125+
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
126+
@test comoving_volume_element(c, big(1.41)) 3.4030879e10u"Mpc^3" rtol = dist_rtol
127+
# Test that FlatWCDM works with non-Float64 (BigFloat in this example)
128+
c = cosmology(h=big(0.7), OmegaM=0.3, OmegaR=0, w0=-0.9, wa=0.1)
129+
@test angular_diameter_dist(c,1,rtol=dist_rtol) 1612.0585u"Mpc" rtol = dist_rtol
130+
@test angular_diameter_dist(c,1,2,rtol=dist_rtol) 607.6802u"Mpc" rtol = dist_rtol
131+
@test angular_diameter_dist(c,pi,rtol=dist_rtol) angular_diameter_dist(c,0,pi,rtol=dist_rtol) rtol = dist_rtol
132+
@test comoving_volume_element(c, big(1.41)) 3.1378625e10u"Mpc^3" rtol = dist_rtol
132133
end
133-
for u in (u"s", u"yr")
134-
@test unit(age(u, c, 3)) == u
135-
@test unit(lookback_time(u, c, 4)) == u
134+
135+
@testset "Unit conversion" begin
136+
c = cosmology(h=0.9, OmegaM=0.5, OmegaR=0)
137+
for u in (u"m", u"pc", u"ly")
138+
@test unit(luminosity_dist(u, c, 1)) == u
139+
@test unit(angular_diameter_dist(u, c, 2)) == u
140+
end
141+
for u in (u"s", u"yr")
142+
@test unit(age(u, c, 3)) == u
143+
@test unit(lookback_time(u, c, 4)) == u
144+
end
136145
end
137-
end
138146

139-
@testset "Utilities" begin
140-
c = cosmology(h = 0.7)
141-
@test hubble_time(c, 0) Cosmology.hubble_time0(c)
142-
@test hubble_dist(c, 0) Cosmology.hubble_dist0(c)
143-
@test H(c, 0) 70u"km/s/Mpc"
147+
@testset "Utilities" begin
148+
c = cosmology(h = 0.7)
149+
@test hubble_time(c, 0) Cosmology.hubble_time0(c)
150+
@test hubble_dist(c, 0) Cosmology.hubble_dist0(c)
151+
@test H(c, 0) 70u"km/s/Mpc"
152+
end
144153
end

0 commit comments

Comments
 (0)