ANN: Measurements.jl v0.4.0

I’m happy to announce the release of the version 0.4.0 if Measurements.jl, an error propagation package for physical measurements, carefully taking functional correlation between them into account. This library supports real and complex numbers with uncertainty, arbitrary precision calculations, operations with arrays, and much more. As usual, the complete documentation is available at Measurements.jl — Measurements.jl 0.4.1-dev documentation.

These are the new in the latest version:

Breaking Changes

  • Support for Julia 0.4 and 0.5 was dropped.
  • value and uncertainty functions are no more exported.
  • Measurements.gradient function has been removed. Use the vectorized function Measurements.derivative.(x, array) instead.

Improvements

  • There were several performance improvements, both in speed and memory usage. These improvements are more evident for simple operations like addition and subtraction (now these operations are 2-3 times faster than in v0.3.0). In addition, the overhead of operations with arrays of Measurements and complex Measurements was greatly reduced by avoiding useless conversions (now summing an array is 100 times faster than in v0.3.0).

New Features

  • quadgk function from QuadGK.jl package is extended to support Measurement objects as endpoints of integration (#8). Note that only the case of two real endpoints is supported.
  • Real Measurement objects can be printed with "text/x-tex" and "text/x-latex" MIME types. \pm TeX macro is used to render the ± sign.
  • A new parse method is provided, to parse a string to Measurement{Float64}. This is the same as calling measurement with a string argument.

In particular, I’ve worked towards making calculations as fast as possible, removing some useless steps. A few microbenchmarks are presented at Performance — Measurements.jl 0.4.0 documentation.

I also managed to enable computation of numerical integrals with Measurement objects as integration bounds using QuadGK (which already supports integration of custom Julia types as integrands). I couldn’t find other similar packages in other languages with this feature. For instance, this new feature allows for cosmological calculations involving numbers with uncertainties (like cosmological parameters measured by the experiments): Using Measurements, including errors in cosmology constants and redshift · Issue #7 · JuliaAstro/Cosmology.jl · GitHub. Other examples of out-of-the-box integration with third-party packages (like numerical and automatic differentiation, and packages for numbers with physical units) are shown at Examples — Measurements.jl 0.4.0 documentation. The great Julia type system is instrumental in making all this work so easily!

5 Likes

A couple of days ago, I tagged a new minor version of Measurements.jl, v0.5.0. This is the list of changes:

Breaking Changes

  • isinteger and iszero now check also that the uncertainty is zero.
  • Comparison between Measurement and Real with == now compares also the
    uncertainty, so that the Measurement must have uncertainty equal to zero to
    be equal to a real number.
  • Comparison between Measurement and Irrational with == now gives always
    false, consistently with the rest of Real types.

New Features

  • New mathematical operations supported: sinpi, cospi, sinc, cosc,
    asec, acsc, acot, asech, acsch, acoth, sincos (the last one only
    on Julia 0.7).
  • It is now possible to parse a string as a Measurement{T} with any
    T<:AbstractFloat (not only Measurement{Float64}), as long as the parsing
    method is able to digest the string. Tested with T equal to Float16,
    Float32, Float64, and BigFloat.

There is also a change under the hood, not mentioned above, inspired by this thread: it is possible to define a macro to numerically propagate the uncertainty of a complex-valued function of one complex argument, not supported out-of-the-box by the package (like complex special functions).