NaNMath.powandNaNMath.sqrtfrom NaNMath.jl are supported via a package extension (#824).
The aliases
degCanddegFfor°Cand°Fare added (#826).Correct LaTeX printing of affine units (#825).
Fix a world-age warning on Julia 1.12 (#819).
Fix a parsing error on Julia 1.13 (#817).
Quantities and units can now be converted to a LaTeX representation using
Latexify.jl. This is provided via a package extension and replaces the UnitfulLatexify.jl package (#795).- This package now requires Julia ≥ 1.6.
The alias
degfor°is added (#764).
Fix a world-age issue with the new mechanism to preserve the floating-point precision on unit conversion (#790).
On Julia ≥ 1.9, dimensionless quantities can now be converted to
ForwardDiff.Dual. This is important for compatibility with the SciML ecosystem and is provided via a package extension (#765).On Julia ≥ 1.9,
@printfand@sprintfcan now be used with Unitful quantities. The specified format is applied to the numeric part of the quantity and the unit is appended to that. This is provided via a package extension (#772).Certain unit conversions involving units that are defined using non-integer exponents no longer error (#783).
uconvertnow preserves the floating-point precision of quantities in a non-breaking way (#782).
The behaviour to preserve the floating-point precision of quantities (#754, added in v1.22.0) is reverted because it is not compatible with IntervalArithmetic.jl (see #758). The feature will be added in a non-breaking way in a future release.
Base.bigcan now be used with quantities (#755).Using
Base.convertto convert to a unitless quantity no longer errors (#724).Using
Base.convertto convert to a mixed logarithmic quantity no longer returns wrong results. In cases that returned a result even though it was unknown whether the quantity was a power or root-power quantity, an error is thrown instead (#724).uconvertnow preserves the floating-point precision of quantities (#754).When printing arrays, quantities are now aligned at the decimal point just like unitless numbers (#752).
Base.cisnow returns more accurate results for arguments in degrees. This unfortunately is slower. If you prioritize speed over precision you can convert toNoUnitsbefore callingcisor use@fastmath(#745).Trigonometric functions now return more accurate results for arguments in degrees when using
BigFloatprecision and@fastmath(#750).Performance of trigonometric functions with
@fastmathis improved for some argument types (#750).- The documentation now contains a list of all units and constants defined in this package (#729).
Arithmetic between
Dates.TimeTypeandUnitful.Timeis added, e.g.,Dates.now() + 1u"hr"now works (#731).
isapproxwith arrays of quantities now supports thenanskeyword argument (#719).isapproxwith arrays of quantities now calculates the defaultrtolcorrectly, i.e.,rtoldefaults to zero if a positiveatolis specified, like in the scalar or unitless case (#719).isapproxwith arrays of quantities now checks whethernorm(x-y) ≤ max(atol, rtol*max(norm(x), norm(y))), like in the scalar or unitless case, instead ofnorm(x-y) ≤ atol + rtol*max(norm(x), norm(y))(#719).
Broadcasting
upreferred,ustrip, or a unit (when used as a conversion function) over ranges now works correctly again (#711, #715).Broadcasting
upreferred,ustrip, or a unit (when used as a conversion function) over aStepRangenow returns aStepRangeLenwhen the conversion results in floating-point numbers (#715).
The dimensionless units parts per cent mille (
pcm, 10^-5), parts per million (ppm, 10^-6), parts per billion (ppb, 10^-9), parts per trillion (ppt, 10^-12), and parts per quadrillion (ppq, 10^-15) are added (#699).
The two-argument versions of
nextfloatandprefloatnow allow quantities as their first argument (#692).
The standard atmosphere (
atm) now accepts SI prefixes, e.g.,μatmis defined (#664).
Calling
minandmaxwith quantities of different units can no longer return wrong results due to floating-point overflow in the unit conversion (#675).minandmaxnow handle quantities withNaNvalues correctly (#675).Base.hastypemaxis now correctly implemented for quantity types (#674).
The conversion factors between units can no longer be wrongly calculated as
NaN,Inf, or0(which could happen, e.g., in the case of large exponents). The conversion factor is now calculated correctly in more cases, and an error is thrown if it cannot be calculated due to floating-point over- or underflow (#648).
Replaced occurrences of single-argument
@docfor duplicating docstrings, which could lead to errors when creating a Docker image with Julia 1.9 and Unitful (#671).
The derived dimension
MolarMass(𝐌/𝐍) is added (#663).Dimensionless quantities now support the
tanpifunction added in Julia 1.10 (#620).
Support for InverseFunctions.jl is extended to all supported Julia versions. On Julia < 1.9, InverseFunctions.jl is added as a regular dependency (#652).
On Julia ≥ 1.9, ConstructionBase.jl is now a weak dependency. On older versions, it is still a regular dependency. (#658).
On Julia ≥ 1.9, InverseFunctions.jl can be used to get the inverse function of
Base.Fix1(ustrip, u::Units)(#622).<=now works correctly forAbstractQuantity{T}whenTis a type for which<=(x::T,y::T)is different thanx < y || x == y(#646).
Adapt test suite for Julia 1.9 (#643).
Base.sleepnow accepts quantities of time as argument (#628).Base.copysignandBase.flipsigncan now be called with a plain number as first argument and a quantity as second argument (#612).All known method ambiguities of the package are resolved (#606, #626).
- The package now has a logo. It was created by Leandro Martínez and shows the International Prototype of the Kilogram (#567, #634).
@fastmathwith quantities now uses functions fromBase.FastMathinstead of intrinsic functions, because the latter may be removed at any time (#617).
Multiplication is no longer assumed to be commutative, which is wrong for, e.g., quaternions (#608).
Adapt the documentation on extending Unitful for Julia ≥ 1.9 (#600).
Broadcasting
upreferredover floating-point ranges now works again (#577).
Fixed
istriu/istrilfor affine quantities (#572).
Dimensionless quantities now support
cispi,sincospi, andmodf(#533, #539).Ranges of affine quantities are now printed correctly (#551).
The non-existent functions
convertrandconvertrpare no longer exported (#530).
Base.zeronow works on heterogeneous arrays of quantities, e.g.,zero([1m, 1s]) == [0m, 0s](#533, #516).StepRangeLens of complex-valued quantities are now printed correctly (#513).Method ambiguities of
Base._rangeare resolved (#514).Updated
rangeimplementation for Julia ≥ 1.8 (#514).
Fixed
isapproxfor arrays of complex-valued quantities (#468).
Dimensions and units can now be documented by adding a docstring before the
@dimension,@refunit,@unit, and@affineunitmacro calls. The@dimension,@derived_dimension,@refunit, and@unitmacros have an optional boolean argumentautodocsto add autogenerated docstrings to some objects generated by these macros. All dimensions, units and constants defined in this package now have docstrings (#476).Calling
preferunitswith non-pure units (e.g.,preferunits(C/ms)) no longer results in wrong behavior (#478).Fixed some invalidations to improve compile times (#509).
Broadcasting
ustrip,upreferred, and*over a range now returns another range instead of aVector(#501, #503).LinearAlgebra.normnow returns a floating-point quantity, which matches the behavior forBasenumbers (#500).
The functions
Unitful.cos_fast,Unitful.sin_fast, andUnitful.tan_fastare removed. Due to an implementation error, they always threw aMethodError, so removing them is not breaking. This fixes a warning during precompilation (#497).
Multiplying a
StepRangeLenbyUnitsnow preserves the floating-point precision (#485).Make
^(::AbstractQuantity, ::Rational)inferrable on Julia ≥ 1.8 (#487).Updated multiplication of range and quantity for Julia ≥ 1.8 compatibility (#489, #495).
deg2radandrad2degcan now be used to convert between°andrad(#459).
The
IOContextproperty:fancy_exponentcan be used to control the printing of exponents in units (i.e.,m²orm^2). Previously, this could only be done by setting the environment variableUNITFUL_FANCY_EXPONENTS. The:fancy_exponentproperty overrides the environment variable (#446).
The functions
dimension,unit,absoluteunit,upreferred, andnumtypenow supportAbstractQuantity(instead of justQuantity) arguments (#431).Support for conversion between
Unitful.TimeandDates.FixedPeriodtypes is added (#331).
Support for the
Base.unorderedfunction is added (#406).The CGS units Gauss (
Gauss), Oersted (Oe), and Maxwell (Mx) are added (#397).Removed a wrong use of
@evalthat broke precompilation (#417).The traits
Base.ArithmeticStyleandBase.OrderStyleare now implemented correctly to support number types that are not defined inBase(#407).==andisequalnow work correctly forGains andLevels with bignums (#404).range(start; step, length)now always creates a functioning range whenstartandstephave different units (#411).It is no longer possible to create a
Levelwith non-real value or reference quantity (#400, #421).Macro hygiene is improved (#390).
Dimensionless quantities now support inverse and hyperbolic trig functions (#387).
Adapt test suite to Julia ≥ 1.6 type parameter printing (#380).
It is now possible to divide an array by units (#369).
Complex and mixed quantities are now printed with brackets (#366).
islessis now defined for logarithmic quantities (#315).Calling
div,rem, etc. with affine quantities now errors (#354).Custom printing of types was removed (#322).
Fix an error when converting units with fractional power (#335).
The unit
Yearnow allows SI prefixes (#320).Unit conversions can now return integer-valued quantities if the conversion factor is whole (#323).
div,fld,cldnow allow arguments of different dimensions as long as one of them is a plain number (i.e., not anAbstractQuantity), e.g.,div(10m, 3) == 3mandcld(10, 3m) == 4/m(#317).Unicode superscript can now be used to to display powers in units and dimensions (e.g.,
m²instead ofm^2). TheUNITFUL_FANCY_EXPONENTSenvironment variable can be used to control whether unicode powers are used or not (#297).The unit
Year(yr) is defined, equal to 365.25 days (#288).roundwith thedigits/sigdigitskeyword now works correctly for quantities that are not based on floating-point numbers. It returns a float-based quantity in those cases (#308).
The
uparsefunction can be used to parse units and quantities from a string (#298).The constructors
Float16,Float32,Float64, andBigFloatcan be used to convert a quantity to one based on the specified floating-point type, e.g.,Float64(1m) === 1.0m. Thefloatfunction can be used to convert a quantity to an appropriate floating-point type (#296).The unit
Pertenthousand(‱) is added (#294).Calling the two-argument
atanwith quantities that have the same numeric type and dimension but different units no longer errors (#293).
Quantitytypes now support theconstructoroffunction from the ConstructionBase.jl package (#280).Using units as conversion functions now supports
missing(#278).The unit
Angstrom(Åorangstrom) is added (#271).
The unit
rps(revolutions per second) is now equal to2π*rad/sinstead of1/sand the unitrpm(revolutions per minute) is now equal to2π*rad/minuteinstead of1/minute(#268).The derived dimensions
MassFlow(𝐌/𝐓),MolarFlow(𝐍/𝐓), andVolumeFlow(𝐋^3/𝐓) are added (#269).The dimensions power density (
𝐌 𝐋^-1 𝐓^-3) and work (𝐋^2 𝐌 𝐓^-2) are marked as power-like for use with logarithmic quantities (#267).zero(::Type{<:AbstractQuantity{T,D}}) where {T,D}can be used to get an additive identity with numeric typeTand dimensionD(#266).The unit
Molar(M) is added (#258).Unitful.registernow extendsUnitful.basefactors, so packages that define units don’t have to do it themselves (#251).Ranges of quantities are now printed in a more concise way (#256).
Angular degrees are now printed without a space between the number and unit, in compliance with the SI standard (#255).
zeronow errors if the dimension of its argument is unspecified (#266).Unitful.promote_to_derivedworks again (#252).
The physical constants are updated to the CODATA 2018 recommended values (#235).
On Julia v1, the rounding functions
round,ceil,floor, andtruncnow accept all keyword arguments that are supported for plain numbers. In addition, the first argument to these functions can be a unit instead of a type (#246, #249, #250).The functions
Base.complex,Base.reim, andBase.widencan now be called with unitful quantities (#227).The function
upreferrednow supportsmissing(#224).Two-argument and three-argument
ustripnow support dimensionless quantities andmissing(#212).Better support for number types that customize their
MIME"text/plain"printing (#213).Ranges which use
Base.TwicePrecisioninternally now work correctly (#245).Fixed some issues around use of
@generatedfunctions that could lead to world-age errors or wrong behavior (#233, #243).
The functions
uconvert,ustrip,unit, anddimensionas well as arithmetic with units now supportmissing(#208).Two-argument
ustrip(unit, x)and three-argumentustrip(T, unit, x)methods are added (#205).The
AbstractQuantity{T,D,U}type is defined to support defining quantity types other thanQuantity{T,D,U}(#204).The derived dimensions
Molarity(𝐍/𝐋^3) andMolality(𝐍/𝐌) are added (#198).Multiplying a range by units now works correctly (#206).
- v0.14.0
- Support for
digitskwarg (#196). - Try to support precompilation with
u_strmacro (#201).
- Support for
- v0.13.0
- Implement affine quantities for better temperature handling (#177, #182).
- Rename
°RatoRato emphasize that it is an absolute scale. - Fix some precompilation issues (#161).
- Add
Velocity,Acceleration,Densityderived dimensions (#187). - Days display as
dnow (#184). - Type signature of
Quantitys has been simplified. Helps with reading error messages (#183). - Support
isequalwithNaNquantities (#172).
- v0.12.0
- Bug fixes.
- Support carrier-to-noise-density ratio (C/N0) in dB-Hz.
- Added dimensions:
DField,EField,ElectricDipoleMoment,ElectricQuadrupoleMoment,MagneticDipoleMoment. - Added unit:
barn. - Some documentation improvements.
- v0.11.0--v0.9.0
- Fixes for Julia 0.7 update, primarily.
- Some new TwicePrecision functionality for quantities.
- v0.8.0
- Add Rydberg constant, unified atomic mass unit, mils, rpm, rps, percent, permille.
- Introduce/rename derived dimensions: ElectricalConductivity, ElectricalResistivity, ElectricalConductance, ElectricalResistance.
- Fix some Julia 0.7 deprecations.
- This will probably be the last release that supports Julia 0.6.
- v0.7.1
- Bug fixes, mainly.
- v0.7.0
- Implement
mod2pifor degrees, cleanup display of degree units. - Tweak implementation of
Gaintypes for usability. - Implement
zeroandoneforLevelandGain. - Add a few more cgs units.
- Tests pass on 32-bit systems, for the first time in a long time (ever?).
- Implement
- v0.6.1
- Permit symbols that are bound to
Numbers to be used inu_strmacro, such that π and other non-literal numbers can be used. - Add some cgs units and a few dimensions #115.
- Fix a comparison / promotion bug introduced in v0.6.0.
- Permit symbols that are bound to
- v0.6.0
- Restore compatibility with 0.7.0-DEV.
- v0.5.1
- Dimensionless quantities no longer lose their units when dividing by a real number.
- Ranges constructed via
rangeorcolonshould work more reliably (e.g., 0:10°:350° works now).
- v0.5.0
- Add
dBΩanddBSto permit working with impedances and admittances in dB. These are used in the Touchstone format and in microwave measurements. - Implement
angleforQuantity{<:Complex}. - Implement
floatforGain,Level. - Replace
fieldratioandrootpowerratiowithuconvertrp.- Permits unit conversion between
NoUnitsanddB, etc. by presuming unitless ratios are of root-power quantities (hence therpafteruconvert). uconvertrphas generic fallbacks and can be used as a drop-in replacement foruconvertotherwise.
- Permits unit conversion between
- Likewise, replace
powerratiowithuconvertpfor ratios of power quantities. - Introduce
convertrpandconvertp. These are likeconvertbut they make similar assumptions about unitless ratios being of power or root-power quantities, respectively. - Implement more division operations for
Gains (accidental omissions)
- Add
- v0.4.0
- Introduce logarithmic quantities (experimental!)
- Update syntax for Julia 0.6 and reorganize code for clarity.
- Redefine
ustrip(x::Quantity) = ustrip(x.val). In most cases, this is unlikely to affect user code. The generic fallbackustrip(x::Number)remains unchanged. isapprox(1.0u"m",5)returnsfalseinstead of throwing aDimensionError, in keeping with the behavior of an equality check (==).- Display of some units has changed to match their symbols #104.
- Don't export
cdfrom Unitful.DefaultSymbols in order to avoid conflicts #102. - Deprecated
dimension(x::AbstractArray{T}) where T<:Number, use broadcasting instead. - Deprecated
dimension(x::AbstractArray{T}) where T<:Units, use broadcasting instead. - Deprecated
ustrip(A::AbstractArray{T}) where T<:Number, use broadcasting instead. - Deprecated
ustrip(A::AbstractArray{T}) where T<:Quantity, use broadcasting instead.
- v0.3.0
- v0.2.6
- v0.2.5
- v0.2.4
- Bug fix: avoid four-argument
promote_type - Bug fix: define method for
*(::Base.TwicePrecision, ::Quantity) - Bug fix: definition of Bohr magneton had
einstead ofq
- Bug fix: avoid four-argument
- v0.2.3
- Dimensionful quantities are no longer accepted for
floor,ceil,trunc,round,isinteger. The choice of units can yield physically different results. The functions are defined for dimensionless quantities, and return unitless numbers. Closes #78. - Added
gn, a constant quantity for the gravitational acceleration on earth #75. - Added
ge, the gravitational acceleration on earth as a unit #75. - Added
lbf, pounds-force unit #75.
- Dimensionful quantities are no longer accepted for
- v0.2.2
- Fixed a bug in promotion involving
ContextUnitswhere the promotion context might not be properly retained.
- Fixed a bug in promotion involving
- v0.2.1
- v0.2.0
Units{N,D}is now an abstract type. Different concrete types for units give different behavior under conversion and promotion. The currently implemented concrete types are:FreeUnits{N,D}: these give the typical behavior from prior versions of Unitful. Units defined in Unitful.jl and reachable by theu_strmacro are allFreeUnits.ContextUnits{N,D,P}, where P is some typeFreeUnits{M,D}: these enable context-specific promotion rules, e.g. if units are defined in different packages.FixedUnits{N,D}: these inhibit automatic conversion of quantities with different units.
LengthUnit,EnergyUnit, etc. are renamed toLengthUnits,EnergyUnits, etc. for consistency (they are related more toUnitsobjects thanUnitobjects). You can still use the old names for now, but please switch over to using...Unitsinstead of...Unitin this release as the old names will be removed in a future release.cis now a unit, to permit converting mass intoMeV/c^2, for example.c0is still a quantity equal to the speed of light in vacuum, in units ofm/s#67.
- v0.1.5
- v0.1.4
- Critical bug fix owing to
mod_fastchanges.
- Critical bug fix owing to
- v0.1.3
- Fix symmetry of
==#56. - Using
@refunitwill implicitly specify the ref. unit as the default for promotion. This will not change behavior for most people; it just ensures promotion won't fail for quantities with user-defined dimensions. - Remove
mod_fastin anticipation of Julia PR #20859. - Allow tolerance args for
isapprox#57
- Fix symmetry of
- v0.1.2
- On Julia 0.6, exponentiation by a literal is now type stable for integers.
- v0.1.1
- Fixed a macro hygiene issue that prevented
@dimensionand@derived_dimensionfrom working properly if Compat was not imported in the calling namespace.
- Fixed a macro hygiene issue that prevented
- v0.1.0
- Julia 0.6 compatibility.
- On Julia 0.6, exponentiation by a literal is now type stable for common integer powers: -3, -2, -1, 0, 1, 2, 3.
- Added missing methods for dot operators
.<and.<=(Julia 0.5, fix #55). - Fix #45. Ranges should work as expected on Julia 0.6. On Julia 0.5, Ranges.jl is used to make ranges work as well as possible given limitations in Base.
- Fix #33,
#42,
and #50.
deps/Defaults.jlis dead. Long livedeps/Defaults.jl. To define your own units, dimensions, and so on, you should now put them in a module, or ideally a package so that others can use the definitions too. You can override default promotion rules immediately after loading Unitful and dependent packages; this will generate method overwrite warnings on Julia 0.5 but not on 0.6. @u_strmacro has been improved. It can now traverse separate unit packages, as well as return tuples ofUnitsobjects.@preferunithas been replaced with a functionpreferunits.- Added some methods for
ustrip. - Implement
typemin,typemax,cbrtforQuantitys. - Added matrix inversion for
StridedMatrix{T<:Quantity}. - Added
istriu,istrilforAbstractMatrix{T<:Quantity}. - The
Unitful.SIUnitsmodule has been renamed toUnitful.DefaultSymbols. - Add
lb,oz,dr,grto Unitful (international Avoirdupois mass units).
- v0.0.4
- Be aware, breaking changes to
deps/Defaults.jlcaused by some of the following! - Fix #40.
- Fix #30.
- Support relevant
@fastmathoperations forQuantitys. - Implement
fma,atan2forQuantitys. - Implement
cisfor dimensionlessQuantitys. - Removed
DimensionedUnitsandDimensionedQuantityabstract types. They were of dubious utility, and this change shortened the promotion code considerably. More importantly, this change has made it possible to write methods like the following, without method ambiguities:uconvert(e::EnergyUnit, f::Frequency) = uconvert(e, u"h"*f). - Promotion wraps usual
Numbertypes in dimensionless, unitlessQuantitytypes when promoted together with dimensionfulQuantitys. WithQuantitys it is not always possible to promote to a common concrete type, but this way we can at least ensure that the numeric backing types are all promoted: (promote(1.0u"m", 1u"N"//2, 0x08) == (1.0 m,0.5 N,8.0), where8.0is actually a dimensionless, unitlessQuantity). The usual outer constructor forQuantitys (Quantity(val::T, unit)) continues to return a number of typeTif the unit isNoUnits, since most of the time the user would prefer aNumbertype from base rather than a dimensionless, unitless quantity. - Add more units to defaults:
bar(bar),Torr(torr),atm(atmosphere),lorL(liter; both symbols accepted). You will need to deletedeps/Defaults.jlin the Unitful package directory to get the new units. - Two character encodings for
μin SI prefixes are now generated automatically (some logic moved out of defaults). - Moved definition of
sin,cos,tan,sec,csc,cotout ofdeps/build.jland intosrc/Unitful.jl.
- Be aware, breaking changes to
- v0.0.3
- Bug fix:
uconvert(°C, 0x01°C)no longer disturbs the numeric type - Allow μ-prefixed units to be typed with option-m on a Mac, in addition to
using Unicode. Previously only
μmcould be typed this way. - Include a
baremodulecalledSIUnitsin the factory defaults. You can now dousing Unitful.SIUnitsto bring all of the SI units into the calling namespace. - Added remaining SI units to the factory defaults:
sr(steradian),lm(luminous flux),lx(illuminance),Bq(becquerel),Gy(gray),Sv(sievert),kat(katal). - Simplify array creation, as in
[1, 2]u"km"#29 - Support multiplying ranges by units, as in
(1:3)*mm#28 - Bug fix #26
- Promoting
Quantitys with different dimensions now returns quantities with the same numeric backing type, e.g.Quantity{Float64}. Ideally, this would also be true if you mixed unitless and unitful numbers during promotion, but that is not yet the case. See #24 for motivation.
- Bug fix:
- v0.0.2
- Bug fixes (
[1.0m, 2.0m] ./ 3would throw aUnitful.DimensionError()). Promotion still isn't perfect, but it is hard for me to see what@inferrederrors are real until JuliaLang/julia#18465 is resolved. - Made units callable for unit conversion:
u"cm"(1u"m") == 100u"cm"//1. Note thatUnitsobjects have no fields, so this is totally unambiguous. Moreover, we have convenient syntax for unit conversion by function chaining:1u"m" |> u"cm" == 100u"cm"//1. Note thatuconvertwill remain supported.
- Bug fixes (
- v0.0.1 - Initial release