Skip to content

Commit 8a66b03

Browse files
committed
More consistently use math-formatted arguments in doc strings.
Also fixes a couple of copy-paste errors in describing the return values of some private functions. This change is enabled by updating to MathJax ≥v3.2.0 which correctly handles rendering inline Unicode math characters as math. (Previously they instead appeared as upright text-mode characters.)
1 parent 62e2396 commit 8a66b03

File tree

3 files changed

+38
-31
lines changed

3 files changed

+38
-31
lines changed

Diff for: docs/make.jl

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ doctest = "--fix" in ARGS ? :fix :
88
DocMeta.setdocmeta!(CMB, :DocTestSetup, :(using CMB); recursive=true)
99

1010
makedocs(
11-
format = Documenter.HTML(mathengine = Documenter.MathJax3()),
11+
format = Documenter.HTML(
12+
mathengine = Documenter.MathJax3(
13+
# If and/or when Documenter is updated to do use MathJax ≥v3.2.0,
14+
# this line can be deleted. (See Documenter.jl#174)
15+
url = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-svg.js"
16+
)
17+
),
1218
sitename = "CMB Analysis",
1319
authors = "Justin Willmert",
1420
modules = [CMB],

Diff for: src/healpix.jl

+16-15
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ pix2ringidx(nside, p) = pix2ringidx(promote(nside, p)...)
291291
"""
292292
z = pix2z(nside, p)
293293
294-
Computes the cosine of the colatitude `z` for the given pixel `p`, where `nside` is the
295-
Nside resolution factor.
294+
Computes the cosine of the colatitude ``z = \\cos(θ)`` for the given pixel `p`, where
295+
`nside` is the Nside resolution factor.
296296
"""
297297
function pix2z(nside::I, p::I) where I<:Integer
298298
checkhealpix(nside, p)
@@ -301,7 +301,7 @@ end
301301
pix2z(nside, p) = pix2z(promote(nside, p)...)
302302

303303
"""
304-
(θ,ϕ) = unsafe_pix2z(nside, p)
304+
z = unsafe_pix2z(nside, p)
305305
306306
Like [`pix2z`](@ref) but does not call [`checkhealpix`](@ref) to check `nside` and pixel
307307
index validity.
@@ -345,13 +345,13 @@ end
345345
"""
346346
θ = pix2theta(nside, p)
347347
348-
Computes the colatitude `θ` for the given pixel `p`, where `nside` is the Nside resolution
348+
Computes the colatitude ``θ`` for the given pixel `p`, where `nside` is the Nside resolution
349349
factor.
350350
"""
351351
pix2theta(nside, p) = acos(pix2z(promote(nside, p)...))
352352

353353
"""
354-
(θ,ϕ) = unsafe_pix2theta(nside, p)
354+
θ = unsafe_pix2theta(nside, p)
355355
356356
Like [`pix2theta`](@ref) but does not call [`checkhealpix`](@ref) to check `nside` and pixel
357357
index validity.
@@ -361,7 +361,7 @@ unsafe_pix2theta(nside, p) = acos(unsafe_pix2z(promote(nside, p)...))
361361
"""
362362
ϕ = pix2phi(nside, p)
363363
364-
Computes the azimuth `ϕ` for the given pixel `p`, where `nside` is the Nside resolution
364+
Computes the azimuth ``ϕ`` for the given pixel `p`, where `nside` is the Nside resolution
365365
factor.
366366
"""
367367
function pix2phi(nside::I, p::I) where I<:Integer
@@ -371,7 +371,7 @@ end
371371
pix2phi(nside, p) = pix2phi(promote(nside, p)...)
372372

373373
"""
374-
(θ,ϕ) = unsafe_pix2phi(nside, p)
374+
ϕ = unsafe_pix2phi(nside, p)
375375
376376
Like [`pix2phi`](@ref) but does not call [`checkhealpix`](@ref) to check `nside` and pixel
377377
index validity.
@@ -409,7 +409,7 @@ end
409409
"""
410410
(θ,ϕ) = pix2ang(nside, p)
411411
412-
Computes the colatitude and azimuth pair `(θ,ϕ)` for the given pixel `p`, where
412+
Computes the colatitude and azimuth pair ``(θ,ϕ)`` for the given pixel `p`, where
413413
`nside` is the Nside resolution factor.
414414
"""
415415
function pix2ang(nside::I, p::I) where {I<:Integer}
@@ -433,7 +433,7 @@ end
433433
"""
434434
r = pix2vec(nside, p)
435435
436-
Computes the unit vector `r` pointing to the pixel center of the given pixel `p`, where
436+
Computes the unit vector ``r`` pointing to the pixel center of the given pixel `p`, where
437437
`nside` is the Nside resolution factor.
438438
"""
439439
function pix2vec(nside::I, p::I) where I<:Integer
@@ -443,7 +443,7 @@ end
443443
pix2vec(nside, p) = pix2vec(promote(nside, p)...)
444444

445445
"""
446-
(θ,ϕ) = unsafe_pix2vec(nside, p)
446+
r = unsafe_pix2vec(nside, p)
447447
448448
Like [`pix2vec`](@ref) but does not call [`checkhealpix`](@ref) to check `nside` and pixel
449449
index validity.
@@ -465,7 +465,7 @@ end
465465
p = ang2pix(nside, θ, ϕ)
466466
467467
Computes the HEALPix pixel index `p` which contains the point ``(θ,ϕ)`` given by the
468-
colatitude `θ` and azimuth `ϕ`, where `nside` is the Nside resolution factor.
468+
colatitude ``θ`` and azimuth ``ϕ``, where `nside` is the Nside resolution factor.
469469
"""
470470
function ang2pix(nside::Integer, θ::F, ϕ::F) where {F}
471471
checkhealpix(nside)
@@ -479,7 +479,7 @@ ang2pix(nside::Integer, θ, ϕ) = ang2pix(nside, promote(θ, ϕ)...)
479479
p = vec2pix(nside, r)
480480
481481
Computes the HEALPix pixel index `p` which contains the point at the end of the unit
482-
vector `r`, where `nside` is the Nside resolution factor.
482+
vector ``r``, where `nside` is the Nside resolution factor.
483483
"""
484484
function vec2pix(nside::Integer, r)
485485
checkhealpix(nside)
@@ -491,7 +491,7 @@ end
491491
p = unsafe_ang2pix(nside, θ, ϕ)
492492
493493
Like [`ang2pix`](@ref) but neither calls [`checkhealpix`](@ref) to check the validity of
494-
`nside` nor checks the domain of the spherical coordinates `θ` and `ϕ`.
494+
`nside` nor checks the domain of the spherical coordinates ``θ`` and ``ϕ``.
495495
"""
496496
function unsafe_ang2pix(nside::Integer, θ, ϕ)
497497
z = cos(θ)
@@ -501,7 +501,7 @@ end
501501
"""
502502
p = unsafe_vec2pix(nside, r)
503503
504-
Like [`vec2pix`](@ref) but does not check the validity of the `nside` or length of `r`.
504+
Like [`vec2pix`](@ref) but does not check the validity of the `nside` or length of ``r``.
505505
"""
506506
@propagate_inbounds function unsafe_vec2pix(nside::Integer, r)
507507
z = r[3]
@@ -513,7 +513,8 @@ end
513513
"""
514514
p = unsafe_zphi2pix(nside, z, ϕ)
515515
516-
Like [`unsafe_ang2pix`](@ref) but uses the value ``z = \\cos(θ)`` instead.
516+
Like [`unsafe_ang2pix`](@ref) but takes the value ``z = \\cos(θ)`` instead of the colatitude
517+
``θ``.
517518
"""
518519
function unsafe_zphi2pix(nside::I, z::F, ϕ::F) where {I<:Integer, F}
519520
z′ = abs(z)

Diff for: src/sphere.jl

+15-15
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const ẑ = SVector(0, 0, 1)
4444
r = cartvec(θ, ϕ)
4545
r = cartvec((θ, ϕ))
4646
47-
Converts the colatitude-azimuth pair `(θ, ϕ)` to a Cartesian unit vector `r`.
47+
Converts the colatitude-azimuth pair ``(θ, ϕ)`` to a Cartesian unit vector ``r``.
4848
"""
4949
function cartvec(θ, ϕ)
5050
sθ, cθ = sincos(float(θ))
@@ -56,7 +56,7 @@ end
5656
"""
5757
θ, ϕ = colataz(r)
5858
59-
Converts the Cartesian unit vector `r` to a colatitude-azimuth pair `(θ, ϕ)` in radians.
59+
Converts the Cartesian unit vector ``r`` to a colatitude-azimuth pair ``(θ, ϕ)`` in radians.
6060
"""
6161
function colataz(r::SVector{3})
6262
θ = acos(r[3])
@@ -68,8 +68,8 @@ end
6868
θ, ϕ = colataz(δ, λ)
6969
θ, ϕ = colataz((δ, λ))
7070
71-
Converts the latitude-longitude pair `(δ, λ)` in degrees to colatitude-azimuth `(θ, ϕ)` in
72-
radians.
71+
Converts the latitude-longitude pair ``(δ, λ)`` in degrees to colatitude-azimuth ``(θ, ϕ)``
72+
in radians.
7373
"""
7474
function colataz(δ, λ)
7575
θ, ϕ = unsafe_colataz(δ, λ)
@@ -88,7 +88,7 @@ end
8888
"""
8989
δ, λ = latlon(r)
9090
91-
Converts the Cartesian unit vector `r` to a latitude-longitude pair `(δ, λ)` in degrees.
91+
Converts the Cartesian unit vector ``r`` to a latitude-longitude pair ``(δ, λ)`` in degrees.
9292
"""
9393
function latlon(r::SVector{3})
9494
δ = asind(r[3])
@@ -100,8 +100,8 @@ end
100100
δ, λ = latlon(θ, ϕ)
101101
δ, λ = latlon((θ, ϕ))
102102
103-
Converts the colatitude-azimuth pair `(θ, ϕ)` in radians to latitude-longitude `(δ, λ)` in
104-
radians.
103+
Converts the colatitude-azimuth pair ``(θ, ϕ)`` in radians to latitude-longitude ``(δ, λ)``
104+
in radians.
105105
"""
106106
function latlon(θ, ϕ)
107107
θ′, ϕ′ = promote(float(θ), float(ϕ))
@@ -303,8 +303,8 @@ function cosdistance(r₁::AbstractVector, r₂::AbstractVector)
303303
end
304304

305305
"""
306-
Calculates a position on the sphere a given [`distance`](@ref) (`σ`, in radians) and
307-
relative [`bearing`](@ref) angle (`α`, in radians) away from a given point (measuring the
306+
Calculates a position on the sphere a given [`distance`](@ref) (``σ``, in radians) and
307+
relative [`bearing`](@ref) angle (``α``, in radians) away from a given point (measuring the
308308
eastward-of-north orientation of the great circle connecting the source and destination
309309
points with respect to the merdian passing through the source).
310310
"""
@@ -313,11 +313,11 @@ function reckon end
313313
"""
314314
r′ = reckon(r::AbstractVector, σ, α)
315315
316-
The point on the sphere is given as a unit vector `r`.
316+
The point on the sphere is given as a unit vector ``r``.
317317
318318
!!! note
319-
When `r` points to either the north or south pole, the meridian is defined to be
320-
**prime meridian** and the bearing angle `α` is oriented with respect to it.
319+
When ``r`` points to either the north or south pole, the meridian is defined to be
320+
**prime meridian** and the bearing angle ``α`` is oriented with respect to it.
321321
322322
For example, moving a distance ``π/2`` with no bearing goes to the negative ``x``
323323
axis (i.e. 0° N, 180° W):
@@ -349,12 +349,12 @@ end
349349
"""
350350
(θ′, ϕ′) = reckon(θ, ϕ, σ, α)
351351
352-
The point on the sphere is given by the colatitude-azimuth pair (`θ`, `ϕ`), both given
352+
The point on the sphere is given by the colatitude-azimuth pair ``(θ, ϕ)``, both given
353353
in radians.
354354
355355
!!! note
356-
When `r` points to either the north or south pole, the meridian is defined to be
357-
**`θ` meridian**, and the bearing angle `α` is oriented with respect to it.
356+
When ``r`` points to either the north or south pole, the meridian is defined to be
357+
**``θ`` meridian**, and the bearing angle ``α`` is oriented with respect to it.
358358
359359
For example, moving a distance ``π/2`` with no bearing goes to the equator, with the
360360
longitude dependent on the input longitude:

0 commit comments

Comments
 (0)