diff --git a/docs/src/conversion.md b/docs/src/conversion.md index d1363e76..22b6d984 100644 --- a/docs/src/conversion.md +++ b/docs/src/conversion.md @@ -140,12 +140,12 @@ the following three cases: ```jldoctest julia> [1.0u"m", 2.0u"m"] -2-element Vector{Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}: +2-element Vector{Quantity{Float64, 𝐋, Unitful.LengthFreeUnits{(m,), nothing}}}: 1.0 m 2.0 m julia> [1.0u"m", 2.0u"cm"] -2-element Vector{Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}: +2-element Vector{Quantity{Float64, 𝐋, Unitful.LengthFreeUnits{(m,), nothing}}}: 1.0 m 0.02 m diff --git a/src/Unitful.jl b/src/Unitful.jl index 4e65ebce..dbab6b2d 100644 --- a/src/Unitful.jl +++ b/src/Unitful.jl @@ -69,6 +69,8 @@ include("complex.jl") include("pkgdefaults.jl") include("dates.jl") +@public AbstractQuantity + if !isdefined(Base, :get_extension) include("../ext/ConstructionBaseUnitfulExt.jl") include("../ext/InverseFunctionsUnitfulExt.jl") diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 352fed1f..e52a21a9 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -4,66 +4,66 @@ # dimensions from units, and also helps prevent common namespace collisions. " Unitful.𝐋 \nA dimension representing length." -@dimension 𝐋 "𝐋" Length true +@dimension 𝐋 "𝐋" Length true true " Unitful.𝐌 \nA dimension representing mass." -@dimension 𝐌 "𝐌" Mass true +@dimension 𝐌 "𝐌" Mass true true " Unitful.𝐓 \nA dimension representing time." -@dimension 𝐓 "𝐓" Time true +@dimension 𝐓 "𝐓" Time true true " Unitful.𝐈 \nA dimension representing electric current." -@dimension 𝐈 "𝐈" Current true +@dimension 𝐈 "𝐈" Current true true " Unitful.𝚯 \nA dimension representing thermodynamic temperature." -@dimension 𝚯 "𝚯" Temperature true # This one is \bfTheta +@dimension 𝚯 "𝚯" Temperature true true # This one is \bfTheta " Unitful.𝐉 \nA dimension representing luminous intensity." -@dimension 𝐉 "𝐉" Luminosity true +@dimension 𝐉 "𝐉" Luminosity true true " Unitful.𝐍 \nA dimension representing amount of substance." -@dimension 𝐍 "𝐍" Amount true +@dimension 𝐍 "𝐍" Amount true true const RelativeScaleTemperature = Quantity{T, 𝚯, <:AffineUnits} where T const AbsoluteScaleTemperature = Quantity{T, 𝚯, <:ScalarUnits} where T # Define derived dimensions. -@derived_dimension Area 𝐋^2 true -@derived_dimension Volume 𝐋^3 true -@derived_dimension Density 𝐌/𝐋^3 true -@derived_dimension Frequency inv(𝐓) true -@derived_dimension Velocity 𝐋/𝐓 true -@derived_dimension Acceleration 𝐋/𝐓^2 true -@derived_dimension Force 𝐌*𝐋/𝐓^2 true -@derived_dimension Pressure 𝐌*𝐋^-1*𝐓^-2 true -@derived_dimension Energy 𝐌*𝐋^2/𝐓^2 true -@derived_dimension Momentum 𝐌*𝐋/𝐓 true -@derived_dimension Power 𝐋^2*𝐌*𝐓^-3 true -@derived_dimension Charge 𝐈*𝐓 true -@derived_dimension Voltage 𝐈^-1*𝐋^2*𝐌*𝐓^-3 true -@derived_dimension ElectricalResistance 𝐈^-2*𝐋^2*𝐌*𝐓^-3 true -@derived_dimension ElectricalResistivity 𝐈^-2*𝐋^3*𝐌*𝐓^-3 true -@derived_dimension ElectricalConductance 𝐈^2*𝐋^-2*𝐌^-1*𝐓^3 true -@derived_dimension ElectricalConductivity 𝐈^2*𝐋^-3*𝐌^-1*𝐓^3 true -@derived_dimension Capacitance 𝐈^2*𝐋^-2*𝐌^-1*𝐓^4 true -@derived_dimension Inductance 𝐈^-2*𝐋^2*𝐌*𝐓^-2 true -@derived_dimension MagneticFlux 𝐈^-1*𝐋^2*𝐌*𝐓^-2 true -@derived_dimension DField 𝐈*𝐓/𝐋^2 true -@derived_dimension EField 𝐋*𝐌*𝐓^-3*𝐈^-1 true -@derived_dimension HField 𝐈/𝐋 true -@derived_dimension BField 𝐈^-1*𝐌*𝐓^-2 true -@derived_dimension Action 𝐋^2*𝐌*𝐓^-1 true -@derived_dimension DynamicViscosity 𝐌*𝐋^-1*𝐓^-1 true -@derived_dimension KinematicViscosity 𝐋^2*𝐓^-1 true -@derived_dimension Wavenumber inv(𝐋) true -@derived_dimension ElectricDipoleMoment 𝐋*𝐓*𝐈 true -@derived_dimension ElectricQuadrupoleMoment 𝐋^2*𝐓*𝐈 true -@derived_dimension MagneticDipoleMoment 𝐋^2*𝐈 true -@derived_dimension Molarity 𝐍/𝐋^3 true -@derived_dimension Molality 𝐍/𝐌 true -@derived_dimension MolarMass 𝐌/𝐍 true -@derived_dimension MassFlow 𝐌/𝐓 true -@derived_dimension MolarFlow 𝐍/𝐓 true -@derived_dimension VolumeFlow 𝐋^3/𝐓 true +@derived_dimension Area 𝐋^2 true true +@derived_dimension Volume 𝐋^3 true true +@derived_dimension Density 𝐌/𝐋^3 true true +@derived_dimension Frequency inv(𝐓) true true +@derived_dimension Velocity 𝐋/𝐓 true true +@derived_dimension Acceleration 𝐋/𝐓^2 true true +@derived_dimension Force 𝐌*𝐋/𝐓^2 true true +@derived_dimension Pressure 𝐌*𝐋^-1*𝐓^-2 true true +@derived_dimension Energy 𝐌*𝐋^2/𝐓^2 true true +@derived_dimension Momentum 𝐌*𝐋/𝐓 true true +@derived_dimension Power 𝐋^2*𝐌*𝐓^-3 true true +@derived_dimension Charge 𝐈*𝐓 true true +@derived_dimension Voltage 𝐈^-1*𝐋^2*𝐌*𝐓^-3 true true +@derived_dimension ElectricalResistance 𝐈^-2*𝐋^2*𝐌*𝐓^-3 true true +@derived_dimension ElectricalResistivity 𝐈^-2*𝐋^3*𝐌*𝐓^-3 true true +@derived_dimension ElectricalConductance 𝐈^2*𝐋^-2*𝐌^-1*𝐓^3 true true +@derived_dimension ElectricalConductivity 𝐈^2*𝐋^-3*𝐌^-1*𝐓^3 true true +@derived_dimension Capacitance 𝐈^2*𝐋^-2*𝐌^-1*𝐓^4 true true +@derived_dimension Inductance 𝐈^-2*𝐋^2*𝐌*𝐓^-2 true true +@derived_dimension MagneticFlux 𝐈^-1*𝐋^2*𝐌*𝐓^-2 true true +@derived_dimension DField 𝐈*𝐓/𝐋^2 true true +@derived_dimension EField 𝐋*𝐌*𝐓^-3*𝐈^-1 true true +@derived_dimension HField 𝐈/𝐋 true true +@derived_dimension BField 𝐈^-1*𝐌*𝐓^-2 true true +@derived_dimension Action 𝐋^2*𝐌*𝐓^-1 true true +@derived_dimension DynamicViscosity 𝐌*𝐋^-1*𝐓^-1 true true +@derived_dimension KinematicViscosity 𝐋^2*𝐓^-1 true true +@derived_dimension Wavenumber inv(𝐋) true true +@derived_dimension ElectricDipoleMoment 𝐋*𝐓*𝐈 true true +@derived_dimension ElectricQuadrupoleMoment 𝐋^2*𝐓*𝐈 true true +@derived_dimension MagneticDipoleMoment 𝐋^2*𝐈 true true +@derived_dimension Molarity 𝐍/𝐋^3 true true +@derived_dimension Molality 𝐍/𝐌 true true +@derived_dimension MolarMass 𝐌/𝐍 true true +@derived_dimension MassFlow 𝐌/𝐓 true true +@derived_dimension MolarFlow 𝐍/𝐓 true true +@derived_dimension VolumeFlow 𝐋^3/𝐓 true true # Define base units. This is not to imply g is the base SI unit instead of kg. # See the documentation for further details. @@ -71,44 +71,45 @@ const AbsoluteScaleTemperature = Quantity{T, 𝚯, <:ScalarUnits} where T " Unitful.m \nThe meter, the SI base unit of length. \nDimension: [`Unitful.𝐋`](@ref)." -@refunit m "m" Meter 𝐋 true true +@refunit m "m" Meter 𝐋 true true true " Unitful.s \nThe second, the SI base unit of time. \nDimension: [`Unitful.𝐓`](@ref)." -@refunit s "s" Second 𝐓 true true +@refunit s "s" Second 𝐓 true true true " Unitful.A \nThe ampere, the SI base unit of electric current. \nDimension: [`Unitful.𝐈`](@ref)." -@refunit A "A" Ampere 𝐈 true true +@refunit A "A" Ampere 𝐈 true true true " Unitful.K \nThe kelvin, the SI base unit of thermodynamic temperature. \nDimension: [`Unitful.𝚯`](@ref)." -@refunit K "K" Kelvin 𝚯 true true +@refunit K "K" Kelvin 𝚯 true true true " Unitful.cd \nThe candela, the SI base unit of luminous intensity. \nDimension: [`Unitful.𝐉`](@ref)." -@refunit cd "cd" Candela 𝐉 true true +@refunit cd "cd" Candela 𝐉 true true true # the docs for all gram-based units are defined later, to ensure kg is the base unit. -@refunit g "g" Gram 𝐌 true +@refunit g "g" Gram 𝐌 true false true " Unitful.mol \nThe mole, the SI base unit for amount of substance. \nDimension: [`Unitful.𝐍`](@ref)." -@refunit mol "mol" Mole 𝐍 true true +@refunit mol "mol" Mole 𝐍 true true true # Angles and solid angles " Unitful.sr \nThe steradian, a unit of spherical angle. There are 4Ο€ sr in a sphere. \nDimension: [`Unitful.NoDims`](@ref)." -@unit sr "sr" Steradian 1 true true +@unit sr "sr" Steradian 1 true true true " Unitful.rad \nThe radian, a unit of angle. There are 2Ο€ rad in a circle. \nDimension: [`Unitful.NoDims`](@ref)." -@unit rad "rad" Radian 1 true true +@unit rad "rad" Radian 1 true true true " Unitful.Β° Unitful.deg \nThe degree, a unit of angle. There are 360Β° in a circle. \nDimension: [`Unitful.NoDims`](@ref)." -((@unit Β° "Β°" Degree pi/180 false), const deg = Β°) +((@unit Β° "Β°" Degree pi/180 false false true), const deg = Β°) +@public deg # For numerical accuracy, specific to the degree import Base: sind, cosd, sincosd, tand, secd, cscd, cotd for (_x,_y) in ((:sin,:sind), (:cos,:cosd), (:sincos,:sincosd), (:tan,:tand), @@ -132,138 +133,138 @@ rad2deg(r::Quantity{T, NoDims, typeof(rad)}) where {T} = rad2deg(ustrip(rad, r)) \nThe hertz, an SI unit of frequency, defined as 1 s^-1. \nDimension: 𝐓^-1. \nSee also: [`Unitful.s`](@ref)." -@unit Hz "Hz" Hertz 1/s true true +@unit Hz "Hz" Hertz 1/s true true true " Unitful.N \nThe newton, an SI unit of force, defined as 1 kg Γ— m / s^2. \nDimension: 𝐋 𝐌 𝐓^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.s`](@ref)." -@unit N "N" Newton 1kg*m/s^2 true true +@unit N "N" Newton 1kg*m/s^2 true true true " Unitful.Pa \nThe pascal, an SI unit of pressure, defined as 1 N / m^2. \nDimension: 𝐌 𝐋^-1 𝐓^-2. \nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." -@unit Pa "Pa" Pascal 1N/m^2 true true +@unit Pa "Pa" Pascal 1N/m^2 true true true " Unitful.J \nThe joule, an SI unit of energy, defined as 1 N Γ— m. \nDimension: 𝐋^2 𝐌 𝐓^-2. \nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." -@unit J "J" Joule 1N*m true true +@unit J "J" Joule 1N*m true true true " Unitful.W \nThe watt, an SI unit of power, defined as 1 J / s. \nDimension: 𝐋^2 𝐌 𝐓^-3. \nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." -@unit W "W" Watt 1J/s true true +@unit W "W" Watt 1J/s true true true " Unitful.C \nThe coulomb, an SI unit of electric charge, defined as 1 A Γ— s. \nDimension: 𝐈 𝐓. \nSee also: [`Unitful.A`](@ref), [`Unitful.s`](@ref)." -@unit C "C" Coulomb 1A*s true true +@unit C "C" Coulomb 1A*s true true true " Unitful.V \nThe volt, an SI unit of electric potential, defined as 1 W / A. \nDimension: 𝐋^2 𝐌 𝐈^-1 𝐓^-3. \nSee also: [`Unitful.W`](@ref), [`Unitful.A`](@ref)" -@unit V "V" Volt 1W/A true true +@unit V "V" Volt 1W/A true true true " Unitful.Ω \nThe ohm, an SI unit of electrical resistance, defined as 1 V / A. \nDimension: 𝐋^2 𝐌 𝐈^-2 𝐓^-3. \nSee also: [`Unitful.V`](@ref), [`Unitful.A`](@ref)." -@unit Ξ© "Ξ©" Ohm 1V/A true true +@unit Ξ© "Ξ©" Ohm 1V/A true true true " Unitful.S \nThe siemens, an SI unit of electrical conductance, defined as 1 Ξ©^-1. \nDimension: 𝐈^2 𝐓^3 𝐋^-2 𝐌^-1. \nSee also: [`Unitful.Ξ©`](@ref)" -@unit S "S" Siemens 1/Ξ© true true +@unit S "S" Siemens 1/Ξ© true true true " Unitful.F \nThe farad, an SI unit of electrical capacitance, defined as 1 s^4 Γ— A^2 / (kg Γ— m^2). \nDimension: 𝐈^2 𝐓^4 𝐋^-2 𝐌^-1. \nSee also: [`Unitful.s`](@ref), [`Unitful.A`](@ref), [`Unitful.kg`](@ref), [`Unitful.m`](@ref)." -@unit F "F" Farad 1s^4*A^2/(kg*m^2) true true +@unit F "F" Farad 1s^4*A^2/(kg*m^2) true true true " Unitful.H \nThe henry, an SI unit of electrical inductance, defined as 1 J / A^2. \nDimension: 𝐋^2 𝐌 𝐈^-2 𝐓^-2. \nSee also: [`Unitful.J`](@ref), [`Unitful.A`](@ref)." -@unit H "H" Henry 1J/(A^2) true true +@unit H "H" Henry 1J/(A^2) true true true " Unitful.T \nThe tesla, an SI unit of magnetic B-field strength, defined as 1 kg / (A Γ— s^2). \nDimension: 𝐌 𝐈^-1 𝐓^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." -@unit T "T" Tesla 1kg/(A*s^2) true true +@unit T "T" Tesla 1kg/(A*s^2) true true true " Unitful.Wb \nThe weber, an SI unit of magnetic flux, defined as 1 kg Γ— m^2 / (A Γ— s^2). \nDimension: 𝐋^2 𝐌 𝐈^-1 𝐓^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." -@unit Wb "Wb" Weber 1kg*m^2/(A*s^2) true true +@unit Wb "Wb" Weber 1kg*m^2/(A*s^2) true true true " Unitful.lm \nThe lumen, an SI unit of luminous flux, defined as 1 cd Γ— sr. \nDimension: [`Unitful.𝐉`](@ref). \nSee also: [`Unitful.cd`](@ref), [`Unitful.sr`](@ref)." -@unit lm "lm" Lumen 1cd*sr true true +@unit lm "lm" Lumen 1cd*sr true true true " Unitful.lx \nThe lux, an SI unit of illuminance, defined as 1 lm / m^2. \nDimension: 𝐉 𝐋^-2. \nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." -@unit lx "lx" Lux 1lm/m^2 true true +@unit lx "lx" Lux 1lm/m^2 true true true " Unitful.Bq \nThe becquerel, an SI unit of radioactivity, defined as 1 nuclear decay per s. \nDimension: 𝐓^-1. \nSee also: [`Unitful.s`](@ref)." -@unit Bq "Bq" Becquerel 1/s true true +@unit Bq "Bq" Becquerel 1/s true true true " Unitful.Gy \nThe gray, an SI unit of ionizing radiation dose, defined as the absorption of 1 J per kg of matter. \nDimension: 𝐋^2 𝐓^-2. \nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." -@unit Gy "Gy" Gray 1J/kg true true +@unit Gy "Gy" Gray 1J/kg true true true " Unitful.Sv \nThe sievert, an SI unit of the biological effect of an ionizing radiation dose. Defined as the health effect of 1 Gy of radiation, scaled by a quality factor. \nDimension: 𝐋^2 𝐓^-2. \nSee also: [`Unitful.Gy`](@ref)." -@unit Sv "Sv" Sievert 1J/kg true true +@unit Sv "Sv" Sievert 1J/kg true true true " Unitful.kat \nThe katal, an SI unit of catalytic activity, defined as 1 mol of catalyzed substrate per s. \nDimension: 𝐍 𝐓^-1. \nSee also: [`Unitful.mol`](@ref), [`Unitful.s`](@ref)." -@unit kat "kat" Katal 1mol/s true true +@unit kat "kat" Katal 1mol/s true true true " Unitful.percent \nPercent, a unit meaning parts per hundred. Printed as \"%\". \nDimension: [`Unitful.NoDims`](@ref)." -@unit percent "%" Percent 1//100 false +@unit percent "%" Percent 1//100 false false true " Unitful.permille \nPermille, a unit meaning parts per thousand. Printed as \"‰\". \nDimension: [`Unitful.NoDims`](@ref)." -@unit permille "‰" Permille 1//1000 false +@unit permille "‰" Permille 1//1000 false false true " Unitful.pertenthousand \nPermyriad, a unit meaning parts per ten thousand. Printed as \"β€±\". \nDimension: [`Unitful.NoDims`](@ref)." -@unit pertenthousand "β€±" Pertenthousand 1//10000 false +@unit pertenthousand "β€±" Pertenthousand 1//10000 false false true " Unitful.pcm \nPercentmille, a unit meaning parts per hundred thousand. \nDimension: [`Unitful.NoDims`](@ref)." -@unit pcm "pcm" Percentmille 1//100000 false +@unit pcm "pcm" Percentmille 1//100000 false false true " Unitful.ppm \nPermillion, a unit meaning parts per million. \nDimension: [`Unitful.NoDims`](@ref)." -@unit ppm "ppm" Permillion 1//1000000 false +@unit ppm "ppm" Permillion 1//1000000 false false true " Unitful.ppb \nPerbillion, a unit meaning parts per billion (in the short-scale sense), i.e., 10^-9. \nDimension: [`Unitful.NoDims`](@ref)." -@unit ppb "ppb" Perbillion 1//1000000000 false +@unit ppb "ppb" Perbillion 1//1000000000 false false true " Unitful.ppt \nPertrillion, a unit meaning parts per trillion (in the short-scale sense), i.e., 10^-12. \nDimension: [`Unitful.NoDims`](@ref)." -@unit ppt "ppt" Pertrillion 1//1000000000000 false +@unit ppt "ppt" Pertrillion 1//1000000000000 false false true " Unitful.ppq \nPerquadrillion, a unit meaning parts per quadrillion (in the short-scale sense), i.e., 10^-15. \nDimension: [`Unitful.NoDims`](@ref)." -@unit ppq "ppq" Perquadrillion 1//1000000000000000 false +@unit ppq "ppq" Perquadrillion 1//1000000000000000 false false true # Temperature " Unitful.Β°C \nThe degree Celsius, an SI unit of temperature, defined such that 0 Β°C = 273.15 K. \nDimension: [`Unitful.𝚯`](@ref). \nSee also: [`Unitful.K`](@ref)." -@affineunit Β°C "Β°C" (27315//100)K +@affineunit Β°C "Β°C" (27315//100)K true # Common units of time " Unitful.minute @@ -271,37 +272,37 @@ substrate per s. to avoid confusion with the Julia function `min`. \nDimension: [`Unitful.𝐓`](@ref). \nSee Also: [`Unitful.s`](@ref)." -@unit minute "minute" Minute 60s false +@unit minute "minute" Minute 60s false false true " Unitful.hr \nThe hour, a unit of time defined as 60 minutes. \nDimension: [`Unitful.𝐓`](@ref). \nSee Also: [`Unitful.minute`](@ref)." -@unit hr "hr" Hour 3600s false +@unit hr "hr" Hour 3600s false false true " Unitful.d \nThe day, a unit of time defined as 24 hr. \nDimension: [`Unitful.𝐓`](@ref). \nSee Also: [`Unitful.hr`](@ref)." -@unit d "d" Day 86400s false +@unit d "d" Day 86400s false false true " Unitful.wk \nThe week, a unit of time, defined as 7 d. \nDimension: [`Unitful.𝐓`](@ref). \nSee Also: [`Unitful.d`](@ref)." -@unit wk "wk" Week 604800s false +@unit wk "wk" Week 604800s false false true " Unitful.yr \nThe year, a unit of time, defined as 365.25 d. \nDimension: [`Unitful.𝐓`](@ref). \nSee Also: [`Unitful.hr`](@ref)." -@unit yr "yr" Year 31557600s true true +@unit yr "yr" Year 31557600s true true true " Unitful.rps \nRevolutions per second, a unit of rotational speed, defined as 2Ο€ rad / s. \nDimension: 𝐓^-1. \nSee Also: [`Unitful.rad`](@ref), [`Unitful.s`](@ref)." -@unit rps "rps" RevolutionsPerSecond 2Ο€*rad/s false +@unit rps "rps" RevolutionsPerSecond 2Ο€*rad/s false false true " Unitful.rpm \nRevolutions per minute, a unit of rotational speed, defined as 2Ο€ rad / minute. \nDimension: 𝐓^-1. \nSee Also: [`Unitful.minute`](@ref), [`Unitful.rad`](@ref)." -@unit rpm "rpm" RevolutionsPerMinute 2Ο€*rad/minute false +@unit rpm "rpm" RevolutionsPerMinute 2Ο€*rad/minute false false true # Area # The hectare is used more frequently than any other power-of-ten of an are. @@ -309,17 +310,18 @@ to avoid confusion with the Julia function `min`. \nThe are, a metric unit of area, defined as 100 m^2. \nDimension: 𝐋^2. \nSee Also: [`Unitful.m`](@ref)." -@unit a "a" Are 100m^2 false +@unit a "a" Are 100m^2 false false true " Unitful.ha \nThe hectare, a metric unit of area, defined as 100 a. \nDimension: 𝐋^2. \nSee Also: [`Unitful.a`](@ref)." const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, 𝐋^2}(2, 1//1),), 𝐋^2}() +@public ha " Unitful.b \nThe barn, a metric unit of area, defined as 100 fm^2. \nDimension: 𝐋^2. \nSee Also: [`Unitful.fm`](@ref)." -@unit b "b" Barn 100fm^2 true true +@unit b "b" Barn 100fm^2 true true true # Volume # `l` is also an acceptable symbol for liters @@ -328,7 +330,8 @@ const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, 𝐋^2}(2, 1//1),), 𝐋^2}() \nThe liter, a metric unit of volume, defined as 1000 cm^3. \nDimension: 𝐋^3. \nSee Also: [`Unitful.cm`](@ref)." -((@unit L "L" Liter m^3//1000 true), const l = L) +((@unit L "L" Liter m^3//1000 true false true), const l = L) +@public l for (k,v) in prefixdict if k != 0 sym_L = Symbol(v,:L) @@ -343,7 +346,13 @@ for (k,v) in prefixdict See also: [`Unitful.L`](@ref). """ - run = quote @doc $docstring ((const $sym_l = $sym_L), $sym_L) end + expr1 = quote @doc $docstring ((const $sym_l = $sym_L), $sym_L) end + if VERSION >= v"1.11.0-DEV.469" + expr2 = Expr(:public, sym_L, sym_l) + run = Expr(:block, expr1, expr2, nothing) + else + run = Expr(:block, expr1, nothing) + end eval(run) end end @@ -353,7 +362,7 @@ end \nA unit for measuring molar concentration, equal to 1 mol/L. \nDimension: 𝐍 𝐋^-3. \nSee Also: [`Unitful.L`](@ref), [`Unitful.mol`](@ref)." -@unit M "M" Molar 1mol/L true true +@unit M "M" Molar 1mol/L true true true # Energy " Unitful.q @@ -363,33 +372,34 @@ confusion with Euler's number. \nDimension: 𝐈 𝐓. \nSee Also: [`Unitful.C`](@ref)." const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... +@public q " Unitful.eV \nThe electron-volt, a unit of energy, defined as q*V. \nDimension: 𝐋^2 𝐌 𝐓^-2. \nSee also: [`Unitful.q`](@ref), [`Unitful.V`](@ref)." -@unit eV "eV" eV q*V true true +@unit eV "eV" eV q*V true true true # For convenience " Unitful.Hz2Ο€ \nA unit for convenience in angular frequency, equal to 2Ο€ Hz. \nDimension: 𝐓^-1. \nSee also: [`Unitful.Hz`](@ref)." -@unit Hz2Ο€ "Hz2Ο€" AngHertz 2Ο€/s true true +@unit Hz2Ο€ "Hz2Ο€" AngHertz 2Ο€/s true true true " Unitful.bar \nThe bar, a metric unit of pressure, defined as 100 kPa. \nDimension: 𝐌 𝐋^-1 𝐓^-2. \nSee also: [`Unitful.kPa`](@ref)." -@unit bar "bar" Bar 100000Pa true true +@unit bar "bar" Bar 100000Pa true true true " Unitful.atm \nThe standard atmosphere, a unit of pressure, defined as 101,325 Pa. \nDimension: 𝐌 𝐋^-1 𝐓^-2. \nSee also: [`Unitful.Pa`](@ref)." -@unit atm "atm" Atmosphere 101325Pa true true +@unit atm "atm" Atmosphere 101325Pa true true true " Unitful.Torr \nThe torr, a unit of pressure, defined as 1/760 atm. \nDimension: 𝐌 𝐋^-1 𝐓^-2. \nSee also: [`Unitful.atm`](@ref)." -@unit Torr "Torr" Torr 101325Pa//760 true true +@unit Torr "Torr" Torr 101325Pa//760 true true true # Constants (2018 CODATA values) (uncertainties in final digits) " Unitful.c0 @@ -399,35 +409,40 @@ const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... \nDimension: 𝐋 𝐓^-1. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const c0 = 299_792_458*m/s # exact +@public c0 " Unitful.c \nThe speed of light in a vacuum, a unit of speed, defined as exactly 2.997,924,58 Γ— 10^8 m/s. \n[`Unitful.c0`](@ref) is a quantity (with units `m/s`) whereas `Unitful.c` is a unit equal to `c0`. \nDimension: 𝐋 𝐓^-1. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." -@unit c "c" SpeedOfLight 1c0 false +@unit c "c" SpeedOfLight 1c0 false false true " Unitful.ΞΌ0 \nA quantity representing the vacuum permeability constant, defined as 4Ο€ Γ— 10^-7 H / m. \nDimension: 𝐋 𝐌 𝐈^-2 𝐓^-2. \nSee also: [`Unitful.H`](@ref), [`Unitful.m`](@ref)." const ΞΌ0 = 4Ο€*(1//10)^7*H/m # exact (but gets promoted to Float64...), magnetic constant +@public ΞΌ0 " Unitful.Ξ΅0 Unitful.Ο΅0 \nA quantity representing the vacuum permittivity constant, defined as 1 / (ΞΌ0 Γ— c^2). \nDimension: 𝐈^2 𝐓^4 𝐋^-3 𝐌^-1. \nSee also: [`Unitful.ΞΌ0`](@ref), [`Unitful.c`](@ref)." ((const Ξ΅0 = 1/(ΞΌ0*c^2)), const Ο΅0 = Ξ΅0) # exact, electric constant; changes here may affect test of issue 79. +@public Ξ΅0, Ο΅0 " Unitful.Z0 \nA quantity representing the impedance of free space, a constant defined as ΞΌ0 Γ— c. \nDimension: 𝐋^2 𝐌 𝐈^-2 𝐓^-3. \nSee also: [`Unitful.ΞΌ0`](@ref), [`Unitful.c`](@ref)." const Z0 = ΞΌ0*c # exact, impedance of free space +@public Z0 " Unitful.G \nA quantity representing the universal gravitational constant, equal to 6.674,30 Γ— 10^-11 m^3 / (kg Γ— s^2) (the CODATA 2018 recommended value). \nDimension: 𝐋^3 𝐌^-1 𝐓^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.kg`](@ref), [`Unitful.s`](@ref)." const G = 6.674_30e-11*m^3/kg/s^2 # (15) gravitational constant +@public G " Unitful.gn \nA quantity representing the nominal acceleration due to gravity in a vacuum near the surface of the earth, defined by standard to be exactly 9.806,65 m / s^2. @@ -435,83 +450,96 @@ near the surface of the earth, defined by standard to be exactly 9.806,65 m / s^ \nDimension: 𝐋 𝐓^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const gn = 9.80665*m/s^2 # exact, standard acceleration of gravity +@public gn " Unitful.h \nA quantity representing Planck's constant, defined as exactly 6.626,070,15 Γ— 10^-34 J Γ— s. \nDimension: 𝐋^2 𝐌 𝐓^-1. \nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." const h = 6.626_070_15e-34*J*s # exact, Planck constant +@public h " Unitful.Δ§ \nA quantity representing the reduced Planck constant, defined as h / 2Ο€. \nDimension: 𝐋^2 𝐌 𝐓^-1. \nSee also: [`Unitful.h`](@ref)." const Δ§ = h/2Ο€ # hbar +@public Δ§ " Unitful.Ξ¦0 \nA quantity representing the superconducting magnetic flux quantum, defined as h / (2 Γ— q). \nDimension: 𝐋^2 𝐌 𝐈^-1 𝐓^-2. \nSee also: [`Unitful.h`](@ref), [`Unitful.q`](@ref)." const Ξ¦0 = h/(2q) # Superconducting magnetic flux quantum +@public Ξ¦0 " Unitful.me \nA quantity representing the rest mass of an electron, equal to 9.109,383,7015 Γ— 10^-31 kg (the CODATA 2018 recommended value). \nDimension: [`Unitful.𝐌`](@ref). \nSee also: [`Unitful.kg`](@ref)." const me = 9.109_383_7015e-31*kg # (28) electron rest mass +@public me " Unitful.mn \nA quantity representing the rest mass of a neutron, equal to 1.674,927,498,04 Γ— 10^-27 kg (the CODATA 2018 recommended value). \nDimension: [`Unitful.𝐌`](@ref). \nSee also: [`Unitful.kg`](@ref)." const mn = 1.674_927_498_04e-27*kg # (95) neutron rest mass +@public mn " Unitful.mp \nA quantity representing the rest mass of a proton, equal to 1.672,621,923,69 Γ— 10^-27 kg (the CODATA 2018 recommended value). \nDimension: [`Unitful.𝐌`](@ref). \nSee also: [`Unitful.kg`](@ref)." const mp = 1.672_621_923_69e-27*kg # (51) proton rest mass +@public mp " Unitful.ΞΌB \nA quantity representing the Bohr magneton, equal to q Γ— Δ§ / (2 Γ— me). \nDimension: 𝐈 𝐋^2. \nSee also: [`Unitful.q`](@ref), [`Unitful.Δ§`](@ref), [`Unitful.me`](@ref)." const ΞΌB = q*Δ§/(2*me) # Bohr magneton +@public ΞΌB " Unitful.Na \nA quantity representing Avogadro's constant, defined as exactly 6.022,140,76 Γ— 10^23 / mol. \nDimension: 𝐍^-1. \nSee also: [`Unitful.mol`](@ref)." const Na = 6.022_140_76e23/mol # exact, Avogadro constant +@public Na " Unitful.k \nA quantity representing the Boltzmann constant, defined as exactly 1.380,649 Γ— 10^-23 J / K. \nDimension: 𝐋^2 𝐌 𝚯^-1 𝐓^-2. \nSee also: [`Unitful.J`](@ref), [`Unitful.K`](@ref)." const k = 1.380_649e-23*(J/K) # exact, Boltzmann constant +@public k " Unitful.R \nA quantity representing the molar gas constant, defined as Na Γ— k. \nDimension: 𝐋^2 𝐌 𝐍^-1 𝚯^-1 𝐓^-2. \nSee also: [`Unitful.Na`](@ref), [`Unitful.k`](@ref)." const R = Na*k # molar gas constant +@public R " Unitful.Οƒ \nA quantity representing the Stefan-Boltzmann constant, defined as Ο€^2 Γ— k^4 / (60 Γ— Δ§^3 Γ— c^2). \nDimension: 𝐌 𝚯^-4 𝐓^-3. \nSee also: [`Unitful.k`](@ref), [`Unitful.Δ§`](@ref), [`Unitful.c`](@ref)." const Οƒ = Ο€^2*k^4/(60*Δ§^3*c^2) # Stefan-Boltzmann constant +@public Οƒ " Unitful.R∞ \nA quantity representing the Rydberg constant, equal to 1.097,373,156,8160 Γ— 10^-7 / m (the CODATA 2018 recommended value). \nDimension: 𝐋^-1. \nSee also: [`Unitful.m`](@ref)." const R∞ = 10_973_731.568_160/m # (21) Rydberg constant +@public R∞ " Unitful.u \nThe unified atomic mass unit, or dalton, a unit of mass defined as 1/12 the mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 Γ— 10^-27 kg (the CODATA 2018 recommended value). \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.kg`](@ref)." -@unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false # (50) +@unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false false true# (50) # Acceleration " Unitful.ge @@ -520,7 +548,7 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \n[`Unitful.gn`](@ref) is a quantity (with units `m/s^2`) whereas `Unitful.ge` is a unit equal to `gn`. \nDimension: 𝐋 𝐓^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." -@unit ge "ge" EarthGravity gn false +@unit ge "ge" EarthGravity gn false false true # CGS units @@ -528,47 +556,47 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe gal, a CGS unit of acceleration, defined as 1 cm / s^2. \nDimension: 𝐋 𝐓^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)." -@unit Gal "Gal" Gal 1cm/s^2 true true +@unit Gal "Gal" Gal 1cm/s^2 true true true " Unitful.dyn \nThe dyne, a CGS unit of force, defined as 1 g Γ— cm / s^2. \nDimension: 𝐋 𝐌 𝐓^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref), [`Unitful.g`](@ref)." -@unit dyn "dyn" Dyne 1g*cm/s^2 true true +@unit dyn "dyn" Dyne 1g*cm/s^2 true true true " Unitful.erg \nThe erg, a CGS unit of energy, defined as 1 dyn Γ— cm. \nDimension: 𝐋^2 𝐌 𝐓^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" -@unit erg "erg" Erg 1g*cm^2/s^2 true true +@unit erg "erg" Erg 1g*cm^2/s^2 true true true " Unitful.Ba \nThe barye, a CGS unit of pressure, defined as 1 dyn / cm^2. \nDimension: 𝐌 𝐋^-1 𝐓^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" -@unit Ba "Ba" Barye 1g/cm/s^2 true true +@unit Ba "Ba" Barye 1g/cm/s^2 true true true " Unitful.P \nThe poise, a CGS unit of dynamic viscosity, defined as 1 dyn Γ— s / cm^2. \nDimension: 𝐌 𝐋^-1 𝐓^-1. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref), [`Unitful.s`](@ref)" -@unit P "P" Poise 1g/cm/s true true +@unit P "P" Poise 1g/cm/s true true true " Unitful.St \nThe stokes, a CGS unit of kinematic viscosity, defined as 1 cm^2 / s. \nDimension: 𝐌^2 𝐓^-1. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)" -@unit St "St" Stokes 1cm^2/s true true +@unit St "St" Stokes 1cm^2/s true true true " Unitful.Gauss \nThe gauss, a CGS unit of magnetic B-field strength, defined as 1 Mx / cm^2. \nDimension: 𝐌 𝐈^-1 𝐓^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.Mx`](@ref)" -@unit Gauss "Gauss" Gauss (1//10_000)*T true true +@unit Gauss "Gauss" Gauss (1//10_000)*T true true true " Unitful.Oe \nThe oersted, a CGS unit of magnetic H-field strength, defined as 1000 A / (4Ο€ Γ— m). \nDimension: 𝐈 𝐋^-1. \nSee also: [`Unitful.A`](@ref), [`Unitful.m`](@ref)" -@unit Oe "Oe" Oersted (1_000/4Ο€)*A/m true true +@unit Oe "Oe" Oersted (1_000/4Ο€)*A/m true true true " Unitful.Mx \nThe maxwell, a CGS unit of magnetic flux, defined as 1 Gauss Γ— cm^2. \nDimension: 𝐋^2 𝐌 𝐈^-1 𝐓^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.Gauss`](@ref)" -@unit Mx "Mx" Maxwell (1//100_000_000)*Wb true true +@unit Mx "Mx" Maxwell (1//100_000_000)*Wb true true true ######### @@ -580,86 +608,87 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe inch, a US customary unit of length defined as 2.54 cm. \nDimension: [`Unitful.𝐋`](@ref). \nSee Also: [`Unitful.cm`](@ref)." -@unit inch "inch" Inch (254//10000)*m false +@unit inch "inch" Inch (254//10000)*m false false true " Unitful.mil \nThe mil, a US customary unit of length defined as 1/1000 inch. \nDimension: [`Unitful.𝐋`](@ref). \nSee Also: [`Unitful.inch`](@ref)." -@unit mil "mil" Mil (1//1000)*inch false +@unit mil "mil" Mil (1//1000)*inch false false true " Unitful.ft \nThe foot, a US customary unit of length defined as 12 inch. \nDimension: [`Unitful.𝐋`](@ref). \nSee Also: [`Unitful.inch`](@ref)." -@unit ft "ft" Foot 12inch false +@unit ft "ft" Foot 12inch false false true " Unitful.yd \nThe yard, a US customary unit of length defined as 3 ft. \nDimension: [`Unitful.𝐋`](@ref). \nSee Also: [`Unitful.ft`](@ref)." -@unit yd "yd" Yard 3ft false +@unit yd "yd" Yard 3ft false false true " Unitful.mi \nThe mile, a US customary unit of length defined as 1760 yd. \nDimension: [`Unitful.𝐋`](@ref). \nSee Also: [`Unitful.yd`](@ref)." -@unit mi "mi" Mile 1760yd false +@unit mi "mi" Mile 1760yd false false true " Unitful.angstrom Unitful.Γ… \nThe angstrom, a metric unit of length defined as 1/10 nm. \nDimension: [`Unitful.𝐋`](@ref). \nSee Also: [`Unitful.nm`](@ref)." -((@unit angstrom "Γ…" Angstrom (1//10)*nm false), const Γ… = angstrom) +((@unit angstrom "Γ…" Angstrom (1//10)*nm false false true), const Γ… = angstrom) +@public Γ… # Area " Unitful.ac \nThe acre, a US customary unit of area defined as 4840 yd^2. \nDimension: 𝐋^2. \nSee Also: [`Unitful.yd`](@ref)." -@unit ac "ac" Acre (316160658//78125)*m^2 false +@unit ac "ac" Acre (316160658//78125)*m^2 false false true # Temperatures " Unitful.Ra \nThe rankine, a US customary unit of temperature defined as 5/9 K. \nDimension: [`Unitful.𝚯`](@ref). \nSee Also: [`Unitful.K`](@ref)." -@unit Ra "Ra" Rankine (5//9)*K false +@unit Ra "Ra" Rankine (5//9)*K false false true " Unitful.Β°F \nThe degree Fahrenheit, a US customary unit of temperature, defined such that 0 Β°F = 459.67 Ra. \nDimension: [`Unitful.𝚯`](@ref). \nSee also: [`Unitful.Ra`](@ref)." -@affineunit Β°F "Β°F" (45967//100)Ra +@affineunit Β°F "Β°F" (45967//100)Ra true # Masses " Unitful.lb \nThe pound-mass, a US customary unit of mass defined as exactly 0.453,592,37 kg. \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.kg`](@ref)." -@unit lb "lb" Pound 0.45359237kg false # is exact +@unit lb "lb" Pound 0.45359237kg false false true # is exact " Unitful.oz \nThe ounce, a US customary unit of mass defined as 1/16 lb. \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.lb`](@ref)." -@unit oz "oz" Ounce lb//16 false +@unit oz "oz" Ounce lb//16 false false true " Unitful.slug \nThe slug, a US customary unit of mass defined as 1 lbf Γ— s^2 / ft. \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.lbf`](@ref), [`Unitful.s`](@ref), [`Unitful.ft`](@ref)." -@unit slug "slug" Slug 1lb*ge*s^2/ft false +@unit slug "slug" Slug 1lb*ge*s^2/ft false false true " Unitful.dr \nThe dram, a US customary unit of mass defined as 1/16 oz. \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.oz`](@ref)." -@unit dr "dr" Dram oz//16 false +@unit dr "dr" Dram oz//16 false false true " Unitful.gr \nThe grain, a US customary unit of mass defined as 1/7000 lb. \nDimension: [`Unitful.𝐌`](@ref). \nSee Also: [`Unitful.lb`](@ref)." -@unit gr "gr" Grain (32//875)*dr false +@unit gr "gr" Grain (32//875)*dr false false true # Force " Unitful.lbf \nThe pound-force, a US customary unit of force defined as 1 lb Γ— ge. \nDimension: 𝐋 𝐌 𝐓^-2. \nSee Also: [`Unitful.lb`](@ref), [`Unitful.ge`](@ref)." -@unit lbf "lbf" PoundsForce 1lb*ge false +@unit lbf "lbf" PoundsForce 1lb*ge false false true # Energy # Use ISO 31-4 for BTU definition @@ -667,19 +696,19 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe calorie, a unit of energy defined as exactly 4.184 J. \nDimension: 𝐋^2 𝐌 𝐓^-2. \nSee Also: [`Unitful.J`](@ref)." -@unit cal "cal" Calorie 4.184J true true +@unit cal "cal" Calorie 4.184J true true true " Unitful.btu \nThe British thermal unit, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06 J. \nDimension: 𝐋^2 𝐌 𝐓^-2. \nSee Also: [`Unitful.J`](@ref)." -@unit btu "btu" BritishThermalUnit 1055.06J false +@unit btu "btu" BritishThermalUnit 1055.06J false false true # Pressure " Unitful.psi \nPounds per square inch, a US customary unit of pressure defined as 1 lbf / inch^2. \nDimension: 𝐌 𝐋^-1 𝐓^-2. \nSee Also: [`Unitful.lbf`](@ref), [`Unitful.inch`](@ref)." -@unit psi "psi" PoundsPerSquareInch 1lbf/inch^2 false +@unit psi "psi" PoundsPerSquareInch 1lbf/inch^2 false false true ######### # Logarithmic scales and units diff --git a/src/user.jl b/src/user.jl index 8df784c9..873e76d5 100644 --- a/src/user.jl +++ b/src/user.jl @@ -26,7 +26,7 @@ function register(unit_module::Module) end """ - @dimension(symb, abbr, name, autodocs=false) + @dimension(symb, abbr, name, autodocs=false, makepublic=false) Creates new dimensions. `name` will be used like an identifier in the type parameter for a [`Unitful.Dimension`](@ref) object. `symb` will be a symbol defined in the namespace from which this macro is called that is bound to a @@ -44,6 +44,7 @@ of the newly defined dimension. The type alias for quantities or levels is simpl Note that there is also `LengthFreeUnits`, for example, which is an alias for dispatching on `FreeUnits` with length dimensions. The aliases are not exported. If `autodocs == true`, docstrings will be automatically generated for these aliases. +If `makepublic=true`, makes the dimension name, abbreviation, and corresponding `Units` and `FreeUnits` type names public when running on Julia β‰₯ 1.11. !!! compat "Unitful 1.10" Documenting the resulting dimension symbol by adding a docstring before the `@dimension` @@ -59,7 +60,7 @@ Returns the `Dimensions` object to which `symb` is bound. Usage example from `src/pkgdefaults.jl`: `@dimension 𝐋 "𝐋" Length` """ -macro dimension(symb, abbr, name, autodocs=false) +macro dimension(symb, abbr, name, autodocs=false, makepublic=false) s = Symbol(symb) x = Expr(:quote, name) uname = Symbol(name,"Units") @@ -91,7 +92,7 @@ macro dimension(symb, abbr, name, autodocs=false) See also: [`$__module__.$s`](@ref). """ - esc(quote + expr1 = quote $Unitful.abbr(::$Dimension{$x}) = $abbr Base.@__doc__ const global $s = $Dimensions{($Dimension{$x}(1),)}() const global ($name){T,U} = Union{ @@ -105,15 +106,19 @@ macro dimension(symb, abbr, name, autodocs=false) @doc $funit_doc $funame end $s - end) + end + (VERSION >= v"1.11.0-DEV.469" && makepublic) || return esc(expr1) + expr2 = Expr(:public, Symbol(abbr), name, uname, funame) + esc(Expr(:block, expr1, expr2, s)) end """ - @derived_dimension(name, dims, autodocs=false) + @derived_dimension(name, dims, autodocs=false, makepublic=false) Creates type aliases to allow dispatch on [`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref), and [`Unitful.Units`](@ref) objects of a derived dimension, like area, which is just length squared. The type aliases are not exported. If `autodocs == true`, docstrings will be automatically generated for these aliases. +If `makepublic=true`, makes the dimension name public when running on Julia β‰₯ 1.11. !!! compat "Unitful 1.10" The `autodocs` argument requires Unitful 1.10 or later. @@ -127,7 +132,7 @@ Usage examples: - `@derived_dimension Area 𝐋^2` gives `Area` and `AreaUnit` type aliases - `@derived_dimension Speed 𝐋/𝐓` gives `Speed` and `SpeedUnit` type aliases """ -macro derived_dimension(name, dims, autodocs=false) +macro derived_dimension(name, dims, autodocs=false, makepublic=false) uname = Symbol(name,"Units") funame = Symbol(name,"FreeUnits") name_links = __module__ == Unitful ? "[`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)" : "`Unitful.Quantity`, `Unitful.Level`" @@ -154,7 +159,7 @@ macro derived_dimension(name, dims, autodocs=false) A supertype for $funit_links of dimension `$dims`. Equivalent to `Unitful.FreeUnits{U, $dims}`. """ - esc(quote + expr1 = quote const global ($name){T,U} = Union{ $Quantity{T,$dims,U}, $Level{L,S,$Quantity{T,$dims,U}} where {L,S}} @@ -166,12 +171,16 @@ macro derived_dimension(name, dims, autodocs=false) @doc $funit_doc $funame end nothing - end) + end + + (VERSION >= v"1.11.0-DEV.469" && makepublic) || return esc(expr1) + expr2 = Expr(:public, name, uname, funame) + esc(Expr(:block, expr1, expr2, nothing)) end """ - @refunit(symb, abbr, name, dimension, tf, autodocs=false) + @refunit(symb, abbr, name, dimension, tf, autodocs=false, makepublic=false) Define a reference unit, typically SI. Rather than define conversion factors between each and every unit of a given dimension, conversion factors are given between each unit and a reference unit, defined by this macro. @@ -182,6 +191,7 @@ for every power of ten of the unit, using the standard SI prefixes. A `dimension must be given ([`Unitful.Dimensions`](@ref) object) that specifies the dimension of the reference unit. If `autodocs == true`, autogenerated docstrings for SI-prefixed units will be added. This option has no effect when `tf == false`. +If `makepublic=true`, makes the units names public when running on Julia β‰₯ 1.11. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@refunit` call requires @@ -204,7 +214,7 @@ Usage example: `@refunit m "m" Meter 𝐋 true` This example, found in `src/pkgdefaults.jl`, generates `km`, `m`, `cm`, ... """ -macro refunit(symb, abbr, name, dimension, tf, autodocs=false) +macro refunit(symb, abbr, name, dimension, tf, autodocs=false, makepublic=false) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -214,14 +224,16 @@ macro refunit(symb, abbr, name, dimension, tf, autodocs=false) if tf push!(expr.args, quote - Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $dimension (1.0, 1) $autodocs + Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $dimension (1.0, 1) $autodocs $makepublic end) else push!(expr.args, quote - Base.@__doc__ $Unitful.@unit_symbols $symb $name $dimension (1.0, 1) + Base.@__doc__ $Unitful.@unit_symbols $symb $name $dimension (1.0, 1) $makepublic end) end + VERSION >= v"1.11.0-DEV.469" && makepublic && push!(expr.args, Expr(:public, symb)) + push!(expr.args, quote $preferunits($symb) $symb @@ -231,12 +243,13 @@ macro refunit(symb, abbr, name, dimension, tf, autodocs=false) end """ - @unit(symb,abbr,name,equals,tf,autodocs=false) + @unit(symb, abbr, name, equals, tf, autodocs=false, makepublic=false) Define a unit. Rather than specifying a dimension like in [`@refunit`](@ref), `equals` should be a [`Unitful.Quantity`](@ref) equal to one of the unit being defined. If `tf == true`, symbols will be made for each power-of-ten prefix. If `autodocs == true`, autogenerated docstrings for SI-prefixed units will be added. This option has no effect when `tf == false`. +If `makepublic=true`, makes the unit name public when running on Julia β‰₯ 1.11. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@unit` call requires @@ -248,7 +261,7 @@ Usage example: `@unit mi "mi" Mile (201168//125)*m false` This example will *not* generate `kmi` (kilomiles). """ -macro unit(symb,abbr,name,equals,tf,autodocs=false) +macro unit(symb, abbr, name, equals, tf, autodocs=false, makepublic=false) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -262,14 +275,16 @@ macro unit(symb,abbr,name,equals,tf,autodocs=false) if tf push!(expr.args, quote - Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $d $basef $autodocs + Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $d $basef $autodocs $makepublic end) else push!(expr.args, quote - Base.@__doc__ $Unitful.@unit_symbols $symb $name $d $basef + Base.@__doc__ $Unitful.@unit_symbols $symb $name $d $basef $makepublic end) end + VERSION >= v"1.11.0-DEV.469" && makepublic && push!(expr.args, Expr(:public, symb)) + push!(expr.args, quote $symb end) @@ -278,21 +293,25 @@ macro unit(symb,abbr,name,equals,tf,autodocs=false) end """ - @affineunit(symb, abbr, offset) + @affineunit(symb, abbr, offset, makepublic=false) Macro for easily defining affine units. `offset` gives the zero of the relative scale in terms of an absolute scale; the scaling is the same as the absolute scale. Example: `@affineunit Β°C "Β°C" (27315//100)K` is used internally to define degrees Celsius. +If `makepublic=true`, makes the unit name public when running on Julia β‰₯ 1.11. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@affineunit` call requires Unitful 1.10 or later. """ -macro affineunit(symb, abbr, offset) +macro affineunit(symb, abbr, offset, makepublic=false) s = Symbol(symb) - return esc(quote + expr1 = quote Base.@__doc__ const global $s = $affineunit($offset) $Base.show(io::$IO, ::$genericunit($s)) = $print(io, $abbr) - end) + end + (VERSION >= v"1.11.0-DEV.469" && makepublic) || return esc(expr1) + expr2 = Expr(:public, s) + esc(Expr(:block, expr1, expr2, s)) end function basefactors_expr(m::Module, n, basefactor) @@ -310,10 +329,11 @@ function basefactors_expr(m::Module, n, basefactor) end """ - @prefixed_unit_symbols(symb,name,dimension,basefactor,autodocs=false) + @prefixed_unit_symbols(symb, name, user_dimension, basefactor, autodocs=false, makepublic=false) Not called directly by the user. Given a unit symbol and a unit's name, will define units for each possible SI power-of-ten prefix on that unit. If `autodocs == true`, it will automatically generate docstrings for these units. +If `makepublic=true`, makes the units names public when running on Julia β‰₯ 1.11. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@prefixed_unit_symbols` @@ -323,7 +343,7 @@ will define units for each possible SI power-of-ten prefix on that unit. If Example: `@prefixed_unit_symbols m Meter 𝐋 (1.0,1) true` results in `nm`, `cm`, `m`, `km`, ... all getting defined in the calling namespace, with docstrings automatically defined for SI-prefixed units. """ -macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs=false) +macro prefixed_unit_symbols(symb, name, user_dimension, basefactor, autodocs=false, makepublic=false) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -351,16 +371,19 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs=false) end end end + VERSION >= v"1.11.0-DEV.469" && makepublic && push!(expr.args, Expr(:public, s)) push!(expr.args, ea) end esc(expr) end +# TODO update example in the docstring """ - @unit_symbols(symb,name) + @unit_symbols(symb, name, user_dimension, basefactor, makepublic=false) Not called directly by the user. Given a unit symbol and a unit's name, will define units without SI power-of-ten prefixes. +If `makepublic=true`, makes the unit name public when running on Julia β‰₯ 1.11. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@unit_symbols` call @@ -368,14 +391,17 @@ will define units without SI power-of-ten prefixes. Example: `@unit_symbols ft Foot 𝐋` results in `ft` getting defined but not `kft`. """ -macro unit_symbols(symb,name,user_dimension,basefactor) +macro unit_symbols(symb, name, user_dimension, basefactor, makepublic=false) s = Symbol(symb) n = Meta.quot(Symbol(name)) u = :($Unit{$n, $user_dimension}(0,1//1)) - esc(quote + expr1 = quote $(basefactors_expr(__module__, n, basefactor)) Base.@__doc__ const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() - end) + end + (VERSION >= v"1.11.0-DEV.469" && makepublic) || return esc(expr1) + expr2 = Expr(:public, s) + esc(Expr(:block, expr1, expr2, s)) end """ @@ -577,12 +603,12 @@ end @logunit(symb, abbr, logscale, reflevel) Defines a logarithmic unit. For examples see `src/pkgdefaults.jl`. """ -macro logunit(symb, abbr, logscale, reflevel) +macro logunit(symb, abbr, logscale, reflevel, makepublic=false) quote - $Unitful.abbr(::Level{$(esc(logscale)), $(esc(reflevel))}) = $abbr - const global $(esc(symb)) = - MixedUnits{Level{$(esc(logscale)), $(esc(reflevel))}}() - end + $Unitful.abbr(::Level{$(logscale), $(reflevel)}) = $abbr + const global $(symb) = + MixedUnits{Level{$(logscale), $(reflevel)}}() + end |> esc end """ @@ -620,7 +646,7 @@ julia> u"m,kg,s" (m, kg, s) julia> typeof(1.0u"m/s") -Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(m, s^-1), 𝐋 𝐓^-1, nothing}} +Quantity{Float64, 𝐋 𝐓^-1, Unitful.VelocityFreeUnits{(m, s^-1), nothing}} julia> u"Δ§" 1.0545718176461565e-34 J s diff --git a/src/utils.jl b/src/utils.jl index 23efcfdc..606a05ee 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -69,17 +69,17 @@ the result to PyPlot, for example. ```jldoctest julia> a = [1u"m", 2u"m"] -2-element Vector{Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}: +2-element Vector{Quantity{Int64, 𝐋, Unitful.LengthFreeUnits{(m,), nothing}}}: 1 m 2 m julia> b = ustrip(a) -2-element reinterpret(Int64, ::Vector{Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}): +2-element reinterpret(Int64, ::Vector{Quantity{Int64, 𝐋, Unitful.LengthFreeUnits{(m,), nothing}}}): 1 2 julia> a[1] = 3u"m"; b -2-element reinterpret(Int64, ::Vector{Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}): +2-element reinterpret(Int64, ::Vector{Quantity{Int64, 𝐋, Unitful.LengthFreeUnits{(m,), nothing}}}): 3 2 ``` @@ -265,3 +265,21 @@ Base.showerror(io::IO, e::AffineError) = print(io, "AffineError: $(e.x)") fp_overflow_underflow(input, result) = isfinite(input) && !isfinite(result) || !iszero(input) && iszero(result) + +""" + macro public(ex) +Declares variables as public on Julia v1.11 or later, and is noop otherwise. +See https://discourse.julialang.org/t/is-compat-jl-worth-it-for-the-public-keyword/119041 + +Examples: + +``` +julia> @public x +julia> @public x, y +``` +""" +macro public(ex) + @static Base.VERSION >= v"1.11.0-DEV.469" || return nothing + args = ex isa Symbol ? (ex,) : Base.isexpr(ex, :tuple) ? ex.args : error("Macro argument must be single symbol or tuple, see docstring") + return esc(Expr(:public, args...)) +end diff --git a/test/runtests.jl b/test/runtests.jl index 74dc8d63..6f3d06c7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1705,8 +1705,17 @@ end @testset "Display" begin withenv("UNITFUL_FANCY_EXPONENTS" => false) do - @test string(typeof(1.0m/s)) == "Quantity{Float64, 𝐋 𝐓^-1, FreeUnits{(m, s^-1), 𝐋 𝐓^-1, nothing}}" - @test string(typeof(m/s)) == "FreeUnits{(m, s^-1), 𝐋 𝐓^-1, nothing}" + # Declaring VelocityFreeUnits as public (or exported) results in change of displayed velocity type from FreeUnits to VelocityFreeUnits + # The same with other units, e.g. typeof(Unitful.L) would be displayed, if VolumeFreeUnits is declared as public, as + # VolumeFreeUnits{(L,), nothing} (alias for Unitful.FreeUnits{(L,), 𝐋³, nothing}) + # vs. Unitful.FreeUnits{(L,), 𝐋³, nothing} + if isdefined(Base, :ispublic) && Base.ispublic(Unitful, :VelocityFreeUnits) + @test string(typeof(1.0m/s)) == "Quantity{Float64, 𝐋 𝐓^-1, Unitful.VelocityFreeUnits{(m, s^-1), nothing}}" + @test string(typeof(m/s)) == "Unitful.VelocityFreeUnits{(m, s^-1), nothing}" + else + @test string(typeof(1.0m/s)) == "Quantity{Float64, 𝐋 𝐓^-1, FreeUnits{(m, s^-1), 𝐋 𝐓^-1, nothing}}" + @test string(typeof(m/s)) == "FreeUnits{(m, s^-1), 𝐋 𝐓^-1, nothing}" + end @test string(dimension(1u"m/s")) == "𝐋 𝐓^-1" @test string(NoDims) == "NoDims" end @@ -2547,6 +2556,109 @@ using REPL # This is necessary to make `@doc` work correctly """ end +VERSION >= v"1.11.0-DEV.469" && @testset "Declare Public" begin + all_public_vars = Symbol[ + :A, :AbstractQuantity, :Acceleration, :AccelerationFreeUnits, :AccelerationUnits, :Action, :ActionFreeUnits, + :ActionUnits, :Amount, :AmountFreeUnits, :AmountUnits, :Area, :AreaFreeUnits, :AreaUnits, :BField, + :BFieldFreeUnits, :BFieldUnits, :Ba, :Bq, :C, :Capacitance, :CapacitanceFreeUnits, :CapacitanceUnits, :Charge, + :ChargeFreeUnits, :ChargeUnits, :Current, :CurrentFreeUnits, :CurrentUnits, :DField, :DFieldFreeUnits, + :DFieldUnits, :Density, :DensityFreeUnits, :DensityUnits, :DynamicViscosity, :DynamicViscosityFreeUnits, + :DynamicViscosityUnits, :EA, :EBa, :EBq, :EC, :EF, :EField, :EFieldFreeUnits, :EFieldUnits, :EGal, :EGauss, :EGy, + :EH, :EHz, :EHz2Ο€, :EJ, :EK, :EL, :EM, :EMx, :EN, :EOe, :EP, :EPa, :ES, :ESt, :ESv, :ET, :ETorr, :EV, :EW, :EWb, + :Eatm, :Eb, :Ebar, :Ecal, :Ecd, :Edyn, :EeV, :Eerg, :Eg, :Ekat, :El, :ElectricDipoleMoment, + :ElectricDipoleMomentFreeUnits, :ElectricDipoleMomentUnits, :ElectricQuadrupoleMoment, + :ElectricQuadrupoleMomentFreeUnits, :ElectricQuadrupoleMomentUnits, :ElectricalConductance, + :ElectricalConductanceFreeUnits, :ElectricalConductanceUnits, :ElectricalConductivity, + :ElectricalConductivityFreeUnits, :ElectricalConductivityUnits, :ElectricalResistance, + :ElectricalResistanceFreeUnits, :ElectricalResistanceUnits, :ElectricalResistivity, + :ElectricalResistivityFreeUnits, :ElectricalResistivityUnits, :Elm, :Elx, :Em, :Emol, :Energy, :EnergyFreeUnits, + :EnergyUnits, :Erad, :Es, :Esr, :Eyr, :EΞ©, :F, :Force, :ForceFreeUnits, :ForceUnits, :Frequency, + :FrequencyFreeUnits, :FrequencyUnits, :G, :GA, :GBa, :GBq, :GF, :GGal, :GGauss, :GGy, :GH, :GHz, :GHz2Ο€, :GJ, + :GK, :GL, :GM, :GMx, :GN, :GOe, :GP, :GPa, :GS, :GSt, :GSv, :GT, :GTorr, :GV, :GW, :GWb, :Gal, :Gatm, :Gauss, + :Gb, :Gbar, :Gcal, :Gcd, :Gdyn, :GeV, :Gerg, :Gg, :Gkat, :Gl, :Glm, :Glx, :Gm, :Gmol, :Grad, :Gs, :Gsr, :Gy, + :Gyr, :GΞ©, :H, :HField, :HFieldFreeUnits, :HFieldUnits, :Hz, :Hz2Ο€, :Inductance, :InductanceFreeUnits, + :InductanceUnits, :J, :K, :KinematicViscosity, :KinematicViscosityFreeUnits, :KinematicViscosityUnits, :L, + :Length, :LengthFreeUnits, :LengthUnits, :Luminosity, :LuminosityFreeUnits, :LuminosityUnits, :M, :MA, :MBa, + :MBq, :MC, :MF, :MGal, :MGauss, :MGy, :MH, :MHz, :MHz2Ο€, :MJ, :MK, :ML, :MM, :MMx, :MN, :MOe, :MP, :MPa, :MS, + :MSt, :MSv, :MT, :MTorr, :MV, :MW, :MWb, :MagneticDipoleMoment, :MagneticDipoleMomentFreeUnits, + :MagneticDipoleMomentUnits, :MagneticFlux, :MagneticFluxFreeUnits, :MagneticFluxUnits, :Mass, :MassFlow, + :MassFlowFreeUnits, :MassFlowUnits, :MassFreeUnits, :MassUnits, :Matm, :Mb, :Mbar, :Mcal, :Mcd, :Mdyn, :MeV, + :Merg, :Mg, :Mkat, :Ml, :Mlm, :Mlx, :Mm, :Mmol, :Molality, :MolalityFreeUnits, :MolalityUnits, :MolarFlow, + :MolarFlowFreeUnits, :MolarFlowUnits, :MolarMass, :MolarMassFreeUnits, :MolarMassUnits, :Molarity, + :MolarityFreeUnits, :MolarityUnits, :Momentum, :MomentumFreeUnits, :MomentumUnits, :Mrad, :Ms, :Msr, :Mx, :Myr, + :MΞ©, :N, :Na, :Oe, :P, :PA, :PBa, :PBq, :PC, :PF, :PGal, :PGauss, :PGy, :PH, :PHz, :PHz2Ο€, :PJ, :PK, :PL, :PM, + :PMx, :PN, :POe, :PP, :PPa, :PS, :PSt, :PSv, :PT, :PTorr, :PV, :PW, :PWb, :Pa, :Patm, :Pb, :Pbar, :Pcal, :Pcd, + :Pdyn, :PeV, :Perg, :Pg, :Pkat, :Pl, :Plm, :Plx, :Pm, :Pmol, :Power, :PowerFreeUnits, :PowerUnits, :Prad, + :Pressure, :PressureFreeUnits, :PressureUnits, :Ps, :Psr, :Pyr, :PΞ©, :R, :Ra, :R∞, :S, :St, :Sv, :T, :TA, :TBa, + :TBq, :TC, :TF, :TGal, :TGauss, :TGy, :TH, :THz, :THz2Ο€, :TJ, :TK, :TL, :TM, :TMx, :TN, :TOe, :TPa, :TS, :TSt, + :TSv, :TT, :TTorr, :TV, :TW, :TWb, :Tatm, :Tb, :Tbar, :Tcal, :Tcd, :Tdyn, :TeV, :Temperature, + :TemperatureFreeUnits, :TemperatureUnits, :Terg, :Tg, :Time, :TimeFreeUnits, :TimeUnits, :Tkat, :Tl, :Tlm, :Tlx, + :Tm, :Tmol, :Torr, :Trad, :Ts, :Tsr, :Tyr, :TΞ©, :V, :Velocity, :VelocityFreeUnits, :VelocityUnits, :Voltage, + :VoltageFreeUnits, :VoltageUnits, :Volume, :VolumeFlow, :VolumeFlowFreeUnits, :VolumeFlowUnits, :VolumeFreeUnits, + :VolumeUnits, :W, :Wavenumber, :WavenumberFreeUnits, :WavenumberUnits, :Wb, :YA, :YBa, :YBq, :YC, :YF, :YGal, + :YGauss, :YGy, :YH, :YHz, :YHz2Ο€, :YJ, :YK, :YL, :YM, :YMx, :YN, :YOe, :YP, :YPa, :YS, :YSt, :YSv, :YT, :YTorr, + :YV, :YW, :YWb, :Yatm, :Yb, :Ybar, :Ycal, :Ycd, :Ydyn, :YeV, :Yerg, :Yg, :Ykat, :Yl, :Ylm, :Ylx, :Ym, :Ymol, + :Yrad, :Ys, :Ysr, :Yyr, :YΞ©, :Z0, :ZA, :ZBa, :ZBq, :ZC, :ZF, :ZGal, :ZGauss, :ZGy, :ZH, :ZHz, :ZHz2Ο€, :ZJ, :ZK, + :ZL, :ZM, :ZMx, :ZN, :ZOe, :ZP, :ZPa, :ZS, :ZSt, :ZSv, :ZT, :ZTorr, :ZV, :ZW, :ZWb, :Zatm, :Zb, :Zbar, :Zcal, + :Zcd, :Zdyn, :ZeV, :Zerg, :Zg, :Zkat, :Zl, :Zlm, :Zlx, :Zm, :Zmol, :Zrad, :Zs, :Zsr, :Zyr, :ZΞ©, :a, :aA, :aBa, + :aBq, :aC, :aF, :aGal, :aGauss, :aGy, :aH, :aHz, :aHz2Ο€, :aJ, :aK, :aL, :aM, :aMx, :aN, :aOe, :aP, :aPa, :aS, + :aSt, :aSv, :aT, :aTorr, :aV, :aW, :aWb, :aatm, :ab, :abar, :ac, :acal, :acd, :adyn, :aeV, :aerg, :ag, :akat, + :al, :alm, :alx, :am, :amol, :angstrom, :arad, :as, :asr, :atm, :ayr, :aΞ©, :b, :bar, :btu, :c, :c0, :cA, :cBa, + :cBq, :cC, :cF, :cGal, :cGauss, :cGy, :cH, :cHz, :cHz2Ο€, :cJ, :cK, :cL, :cM, :cMx, :cN, :cOe, :cP, :cPa, :cS, + :cSt, :cSv, :cT, :cTorr, :cV, :cW, :cWb, :cal, :catm, :cb, :cbar, :ccal, :ccd, :cdyn, :ceV, :cerg, :cg, :ckat, + :cl, :clm, :clx, :cm, :cmol, :crad, :cs, :csr, :cyr, :cΞ©, :d, :dA, :dBa, :dBq, :dC, :dF, :dGal, :dGauss, :dGy, + :dH, :dHz, :dHz2Ο€, :dJ, :dK, :dL, :dM, :dMx, :dN, :dOe, :dP, :dPa, :dS, :dSt, :dSv, :dT, :dTorr, :dV, :dW, :dWb, + :daA, :daBa, :daBq, :daC, :daF, :daGal, :daGauss, :daGy, :daH, :daHz, :daHz2Ο€, :daJ, :daK, :daL, :daM, :daMx, + :daN, :daOe, :daP, :daPa, :daS, :daSt, :daSv, :daT, :daTorr, :daV, :daW, :daWb, :daatm, :dab, :dabar, :dacal, + :dacd, :dadyn, :daeV, :daerg, :dag, :dakat, :dal, :dalm, :dalx, :dam, :damol, :darad, :das, :dasr, :datm, :dayr, + :daΞ©, :db, :dbar, :dcal, :dcd, :ddyn, :deV, :deg, :derg, :dg, :dkat, :dl, :dlm, :dlx, :dm, :dmol, :dr, :drad, + :ds, :dsr, :dyn, :dyr, :dΞ©, :eV, :erg, :fA, :fBa, :fBq, :fC, :fF, :fGal, :fGauss, :fGy, :fH, :fHz, :fHz2Ο€, :fJ, + :fK, :fL, :fM, :fMx, :fN, :fOe, :fP, :fPa, :fS, :fSt, :fSv, :fT, :fTorr, :fV, :fW, :fWb, :fatm, :fb, :fbar, + :fcal, :fcd, :fdyn, :feV, :ferg, :fg, :fkat, :fl, :flm, :flx, :fm, :fmol, :frad, :fs, :fsr, :ft, :fyr, :fΞ©, :g, + :ge, :gn, :gr, :h, :hA, :hBa, :hBq, :hC, :hF, :hGal, :hGauss, :hGy, :hH, :hHz, :hHz2Ο€, :hJ, :hK, :hL, :hM, :hMx, + :hN, :hOe, :hP, :hPa, :hS, :hSt, :hSv, :hT, :hTorr, :hV, :hW, :hWb, :ha, :hatm, :hb, :hbar, :hcal, :hcd, :hdyn, + :heV, :herg, :hg, :hkat, :hl, :hlm, :hlx, :hm, :hmol, :hr, :hrad, :hs, :hsr, :hyr, :hΞ©, :inch, :k, :kA, :kBa, + :kBq, :kC, :kF, :kGal, :kGauss, :kGy, :kH, :kHz, :kHz2Ο€, :kJ, :kK, :kL, :kM, :kMx, :kN, :kOe, :kP, :kPa, :kS, + :kSt, :kSv, :kT, :kTorr, :kV, :kW, :kWb, :kat, :katm, :kb, :kbar, :kcal, :kcd, :kdyn, :keV, :kerg, :kg, :kkat, + :kl, :klm, :klx, :km, :kmol, :krad, :ks, :ksr, :kyr, :kΞ©, :l, :lb, :lbf, :lm, :lx, :m, :mA, :mBa, :mBq, :mC, :mF, + :mGal, :mGauss, :mGy, :mH, :mHz, :mHz2Ο€, :mJ, :mK, :mL, :mM, :mMx, :mN, :mOe, :mP, :mPa, :mS, :mSt, :mSv, :mT, + :mTorr, :mV, :mW, :mWb, :matm, :mb, :mbar, :mcal, :mcd, :mdyn, :me, :meV, :merg, :mg, :mi, :mil, :minute, :mkat, + :ml, :mlm, :mlx, :mm, :mmol, :mn, :mol, :mp, :mrad, :ms, :msr, :myr, :mΞ©, :nA, :nBa, :nBq, :nC, :nF, :nGal, + :nGauss, :nGy, :nH, :nHz, :nHz2Ο€, :nJ, :nK, :nL, :nM, :nMx, :nN, :nOe, :nP, :nPa, :nS, :nSt, :nSv, :nT, :nTorr, + :nV, :nW, :nWb, :natm, :nb, :nbar, :ncal, :ncd, :ndyn, :neV, :nerg, :ng, :nkat, :nl, :nlm, :nlx, :nm, :nmol, + :nrad, :ns, :nsr, :nyr, :nΞ©, :oz, :pA, :pBa, :pBq, :pC, :pF, :pGal, :pGauss, :pGy, :pH, :pHz, :pHz2Ο€, :pJ, :pK, + :pL, :pM, :pMx, :pN, :pOe, :pP, :pPa, :pS, :pSt, :pSv, :pT, :pTorr, :pV, :pW, :pWb, :patm, :pb, :pbar, :pcal, + :pcd, :pcm, :pdyn, :peV, :percent, :perg, :permille, :pertenthousand, :pg, :pkat, :pl, :plm, :plx, :pm, :pmol, + :ppb, :ppm, :ppq, :ppt, :prad, :ps, :psi, :psr, :pyr, :pΞ©, :q, :rad, :rpm, :rps, :s, :sr, :u, :wk, :yA, :yBa, + :yBq, :yC, :yF, :yGal, :yGauss, :yGy, :yH, :yHz, :yHz2Ο€, :yJ, :yK, :yL, :yM, :yMx, :yN, :yOe, :yP, :yPa, :yS, + :ySt, :ySv, :yT, :yTorr, :yV, :yW, :yWb, :yatm, :yb, :ybar, :ycal, :ycd, :yd, :ydyn, :yeV, :yerg, :yg, :ykat, + :yl, :ylm, :ylx, :ym, :ymol, :yr, :yrad, :ys, :ysr, :yyr, :yΞ©, :zA, :zBa, :zBq, :zC, :zF, :zGal, :zGauss, :zGy, + :zH, :zHz, :zHz2Ο€, :zJ, :zK, :zL, :zM, :zMx, :zN, :zOe, :zP, :zPa, :zS, :zSt, :zSv, :zT, :zTorr, :zV, :zW, :zWb, + :zatm, :zb, :zbar, :zcal, :zcd, :zdyn, :zeV, :zerg, :zg, :zkat, :zl, :zlm, :zlx, :zm, :zmol, :zrad, :zs, :zsr, + :zyr, :zΞ©, :Β°, :Β°C, :Β°F, :Γ…, :Δ§, :Ξ¦0, :Ξ©, :Ξ΅0, :ΞΌ0, :ΞΌA, :ΞΌB, :ΞΌBa, :ΞΌBq, :ΞΌC, :ΞΌF, :ΞΌGal, :ΞΌGauss, :ΞΌGy, :ΞΌH, + :ΞΌHz, :ΞΌHz2Ο€, :ΞΌJ, :ΞΌK, :ΞΌL, :ΞΌM, :ΞΌMx, :ΞΌN, :ΞΌOe, :ΞΌP, :ΞΌPa, :ΞΌS, :ΞΌSt, :ΞΌSv, :ΞΌT, :ΞΌTorr, :ΞΌV, :ΞΌW, :ΞΌWb, + :ΞΌatm, :ΞΌb, :ΞΌbar, :ΞΌcal, :ΞΌcd, :ΞΌdyn, :ΞΌeV, :ΞΌerg, :ΞΌg, :ΞΌkat, :ΞΌl, :ΞΌlm, :ΞΌlx, :ΞΌm, :ΞΌmol, :ΞΌrad, :ΞΌs, :ΞΌsr, + :ΞΌyr, :ΞΌΞ©, :Οƒ, :Ο΅0, :𝐈, :𝐉, :𝐋, :𝐌, :𝐍, :𝐓, :𝚯] + + private_vars = Symbol[ + :AbsoluteScaleTemperature, :Affine, :AffineError, :AffineQuantity, :AffineUnits, :B, :B_p, :B_rp, :Bel, + :BracketStyle, :Centineper, :ContextUnits, :Decibel, :Dimension, :DimensionError, :DimensionlessUnits, :Dimensions, + :FixedUnits, :FreeOrContextUnits, :FreeUnits, :IsRootPowerRatio, :LogInfo, :LogScaled, :MixedUnits, :Neper, + :NoBrackets, :Np, :Np_p, :Np_rp, :PowerRatio, :RealOrRealQuantity, :ReferenceQuantity, :RelativeScaleTemperature, + :RootPowerRatio, :RoundBrackets, :ScalarQuantity, :ScalarUnits, :SquareBrackets, :Unit, :Unitlike, :Units, :abbr, + :abs2_fast, :abs_fast, :affinetranslation, :affineunit, :base, :basefactor, :basefactors_expr, :cNp, :cNp_p, + :cNp_rp, :colon, :colonstartstop, :conj_fast, :convfact, :convfact_floattype, :dB, :dBFS, :dBHz, :dBS, :dBSPL, :dBV, + :dB_p, :dB_rp, :dBm, :dBu, :dBΞ©, :dBΞΌV, :dimtype, :expfn, :fp_overflow_underflow, :fromlog, :gaintype, :genericunit, + :get_T, :has_unit_spacing, :inv_fast, :isrootpower, :isrootpower_dim, :isunitless, :leveltype, :logfn, + :lookup_units, :name, :numtype, :power, :prefactor, :preferunits, :prefix, :print_closing_bracket, + :print_opening_bracket, :printed_length, :promote_to_derived, :promote_unit, :quantitytype, :register, :showrep, + :showval, :sign_fast, :sortexp, :superscript, :tens, :tensfactor, :tolog, :try_uconvert, :uconvert_affine, :unwrap, + :ustrcheck_bool] + + @test Base.ispublic.(Ref(Unitful), all_public_vars) |> all + @test Base.ispublic.(Ref(Unitful), private_vars) |> any |> ! +end + # Test precompiled Unitful extension modules mktempdir() do load_path mktempdir() do load_cache_path