Skip to content

Commit 1fee0b2

Browse files
authored
Add alias deg for ° (JuliaPhysics#764)
1 parent 26a1558 commit 1fee0b2

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

docs/src/defaultunits.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ The steradian, a unit of spherical angle. There are 4π sr in a sphere.
748748

749749
```
750750
Unitful.°
751+
Unitful.deg
751752
```
752753

753754
The degree, a unit of angle. There are 360° in a circle.

src/pkgdefaults.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ const AbsoluteScaleTemperature = Quantity{T, 𝚯, <:ScalarUnits} where T
105105
\nDimension: [`Unitful.NoDims`](@ref)."
106106
@unit rad "rad" Radian 1 true true
107107
" Unitful.°
108+
Unitful.deg
108109
\nThe degree, a unit of angle. There are 360° in a circle.
109110
\nDimension: [`Unitful.NoDims`](@ref)."
110-
@unit ° "°" Degree pi/180 false
111+
((@unit ° "°" Degree pi/180 false), const deg = °)
111112
# For numerical accuracy, specific to the degree
112113
import Base: sind, cosd, tand, secd, cscd, cotd
113114
for (_x,_y) in ((:sin,:sind), (:cos,:cosd), (:tan,:tand),

test/runtests.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Unitful:
1010
ac,
1111
mg, g, kg,
1212
Ra, °F, °C, K,
13-
rad, mrad, °,
13+
rad, mrad, °, deg,
1414
ms, s, minute, hr, d, yr, Hz,
1515
J, A, N, mol, V, mJ, eV, dyn, mN,
1616
mW, W,
@@ -734,6 +734,7 @@ Base.:(<=)(x::Issue399, y::Issue399) = x.num <= y.num
734734
@test zero(Quantity{Int, 𝐋}) isa Quantity{Int}
735735
@test @inferred/2*u"rad" + 90u"°") π # Dimless quantities
736736
@test @inferred/2*u"rad" - 90u"°") 0 # Dimless quantities
737+
@test @inferred(90u"deg" - 90u"°") == 0
737738
@test_throws DimensionError 1+1m # Dim mismatched
738739
@test_throws DimensionError 1-1m
739740
end
@@ -2328,6 +2329,10 @@ end
23282329
@test (1//2)Unitful.ϵ0 === (1//2)Unitful.ε0
23292330
@test Unitful.Å === Unitful.angstrom
23302331
@test 1.0Unitful.Å === 1.0Unitful.angstrom
2332+
@test Unitful.deg === Unitful.°
2333+
@test 2Unitful.° === 2Unitful.deg
2334+
@test u"deg" === u"°"
2335+
@test uparse("deg") === uparse("°")
23312336
end
23322337

23332338
module DocUnits

0 commit comments

Comments
 (0)