JuliaPhysics / Measurements.jl

Error propagation calculator and library for physical measurements. It supports real and complex numbers with uncertainty, arbitrary precision calculations, operations with arrays, and numerical integration.

Home Page:https://juliaphysics.github.io/Measurements.jl/stable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support for `parse`

CNOT opened this issue · comments

It would be nice if parse knew how to handle Measurement type numbers.
Something on the following lines, might work:

import Base.parse
function parse(::Type{Measurement}, s::AbstractString)
   n = parse.(Float64,split(s,"±"))
   return n[1]±n[2]
end

This is handy when you have Measurement type data produced and stored as a string, for example in a CSV file.

It already does: https://juliaphysics.github.io/Measurements.jl/stable/examples/#Measurements-from-Strings-1

julia> using Measurements

julia> parse(Measurement{Float64}, "4 ± 1.3")
4.0 ± 1.3