utahplt / TrackedFloats.jl

Julia library providing tracking of floating point errors through a program resources
https://juliahub.com/ui/Packages/General/TrackedFloats
MIT License
34 stars 3 forks source link

Improve TrackedFloat-wrapping functions #20

Open ashton314 opened 1 year ago

ashton314 commented 1 year ago

Per discussion on RXInfer.jl#116 it would be nice to have some functions to make it easier to wrap inputs in the TrackedFloat type.

bennn commented 1 year ago

Concretely:

  1. track(x) to traverse the array x and replace all floats with TFs. Use TrackedFloat64 as the default but allow changes.
  2. @track foo(...) to replace all Float-like types in the function signature with TF

Is 2 needed? I'm thinking no, because TF is a subtype of the matching floats and the type alone doesn't do any converting. (foo(4.2) would be an error).

ashton314 commented 1 year ago

I think it'd be neat for 2 if we could hijack the original function so if it gets called with non-TrackedFloats, we wrap it and then call again.

bennn commented 1 year ago

Yes, that'd be great! Just like a Python decorator.