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

Integration with Zygote

GrigorySarnitsky opened this issue · comments

I was trying out Zygote and was testing how it plays with Measurements, see also a cross post in Zygote's github (FluxML/Zygote.jl#1320). I have encountered a problem when I try to take a second derivative:

using Zygote
using Measurements

(√)''(2 ± 0.1)

This throws an exception:

MethodError: no method matching Float64(::Measurement{Float64})

At the same time (√)''(2) works just fine. I can fix this by defining

Float64(x::Measurement{Float64}) = Measurements.value(x)

I know little about Zygote and Measurments and I cannot tell what is going on and if this needs fixing and on which side.