[ANN] UnitTypes v3.0.0

Version 3.0 brings the major addition of a Catchall type for operations that result in undefined units; explicit types are still preferred and will be chosen when available.

  • Exponentiation works on UnitTypes
  • UnitType ranges can be defined over any coherent unit
  • Convenience (1:5)u"m" added
  • Broadcasting implemented: 3.*(1:5)u"m"
  • @relateMeasures now accepts compound left hand expressions, intermediate types therein are defined
  • Fixed non-const globals having Any type
  • Test coverage on all new code
  • Extended benchmark comparison suite
  • Documentation updated

Breaking changes:

  • @makeMeasure argument order changed to be more natural: @makeMeasure 1e-3 Meter = 1 MilliMeter "mm"

Closed issues:

  • exponent handling (#20)
  • Density * Length = undefined? (#21)
  • add getUnitAbbreviation(1u"mm") (#25)
  • Catchall UnitType (#26)
  • More complex unit handling (#27)

Prior to 3.0.0, the biggest limitation of UnitTypes was that every operation had to result in a defined UnitType. If the type did not exist, then the operation would error. This has been fixed by introducing a Catch-all type:

julia> Yard(2) * Lumen(3)  # no named type with yd*lm
8.2296m*lm   # ::Catchall with dimensions AbstractLength=1, AbstractLuminousFlux=1

The price of operations producing undefined UnitTypes is that Catchalls are allocated; these can be eliminated by defining the needed types.

Compound unit strings are also parsed 1u"mm*s/kg", returning an explicit type or a Catchall for that combination.

See the v1.0.0 annoucement

1 Like