Skip to content

Commit

Permalink
Import yr unit from Unitful using appropriate macro (#30)
Browse files Browse the repository at this point in the history
* Import `yr` unit from `Unitful` using appropriate macro

* Add test
  • Loading branch information
giordano authored Dec 1, 2021
1 parent ae685f4 commit 36af82d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "UnitfulAstro"
uuid = "6112ee07-acf9-5e0f-b108-d242c714bf9f"
license = "MIT"
version = "1.1.0"
version = "1.1.1"

[deps]
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
Expand Down
4 changes: 2 additions & 2 deletions src/UnitfulAstro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ __precompile__()
module UnitfulAstro

import Unitful
using Unitful: @unit, @logscale, @logunit, yr
using Unitful: @unit, @logscale, @logunit

macro import_from_unitful(args...)
expr = Expr(:block)
Expand Down Expand Up @@ -34,7 +34,7 @@ function should_we_use_SI_prefixes(arg::Expr)
end
should_we_use_SI_prefixes(arg::Symbol) = false, arg

@import_from_unitful ~m ~s ~A ~K ~cd
@import_from_unitful ~m ~s ~A ~K ~cd ~yr
@import_from_unitful ~L ~Hz ~N ~Pa ~J ~W ~C ~V ~Ω ~S ~F ~H ~T ~Wb ~lm ~lx ~Bq ~Gy ~Sv ~kat ~eV
@import_from_unitful sr rad ° °C °F Ra minute hr d wk ~bar atm Torr
@import_from_unitful q c0 c μ0 µ0 ε0 ϵ0 Z0 G gn ge h ħ Φ0 me mn mp μB µB Na R k σ
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const u = UnitfulAstro
@test 1.0*Unitful.angstrom 1e-10*u.m
@test 1*u.SFU 10000*u.Jy
@test 1*u.TECU == 1e12*u.cm^-2
# Make sure we can access Gyr directly from UnitfulAstro
@test 1*u.Gyr 1e9*u.yr
end

@testset "simple calculations" begin
Expand Down

2 comments on commit 36af82d

@giordano
Copy link
Member Author

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/49684

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.1.1 -m "<description of version>" 36af82de103cab1879a0964e3974a58e247013a2
git push origin v1.1.1

Please sign in to comment.