diff --git a/src/LegendDataManagement.jl b/src/LegendDataManagement.jl index 313e7f89..0836857f 100644 --- a/src/LegendDataManagement.jl +++ b/src/LegendDataManagement.jl @@ -17,6 +17,7 @@ using PropertyDicts using StructArrays using Unitful using Measurements +using Measurements: ± using Printf: @printf diff --git a/src/ljl_expressions.jl b/src/ljl_expressions.jl index 308c1eee..5374c8e4 100644 --- a/src/ljl_expressions.jl +++ b/src/ljl_expressions.jl @@ -41,7 +41,8 @@ const ljl_expr_allowed_funcs = Set([ :abs, :abs2, :normalize, :norm, :exp, exp2, :exp10, :log, :log2, :log10, :sin, :cos, :tan, :asin, :acos, :atan, - :isnan, :isinf + :isnan, :isinf, + :± ]) const _ljlexpr_units = IdDict([ diff --git a/test/test_ljl_expressions.jl b/test/test_ljl_expressions.jl index 712e6ffb..6a99508b 100644 --- a/test/test_ljl_expressions.jl +++ b/test/test_ljl_expressions.jl @@ -4,6 +4,7 @@ using LegendDataManagement using Test using PropertyFunctions, StructArrays +import Measurements include("testing_utils.jl") @@ -32,6 +33,15 @@ include("testing_utils.jl") @test num_pf === ljl_propfunc(num_expr_string) @test @inferred(broadcast(num_pf, data)) == ref_numfunc.(data) + meas_expr_string = "(offs + slope * abs(E_trap) / 1000) - (5.2 ± 0.1)" + meas_expr = parse_ljlexpr(meas_expr_string) + @test meas_expr == :((offs + (slope * abs(E_trap)) / 1000) - (5.2 ± 0.1)) + ref_measfunc(x) = (x.offs + (x.slope * abs(x.E_trap)) / 1000) - Measurements.:(±)(5.2, 0.1) + meas_pf = ljl_propfunc(meas_expr) + @test meas_pf isa PropertyFunctions.PropertyFunction + @test meas_pf === ljl_propfunc(meas_expr_string) + @test @inferred(broadcast(meas_pf, data)) == ref_measfunc.(data) + expr_map = props = PropDict(:e_flag => bool_expr_string, :e_cal => num_expr_string) multi_pf = ljl_propfunc(expr_map) @test multi_pf isa PropertyFunctions.PropertyFunction