org-arl / SignalAnalysis.jl

Signal analysis toolbox for Julia
MIT License
41 stars 10 forks source link

Add support for intervals #10

Closed mchitre closed 3 years ago

mchitre commented 4 years ago

Suggested syntax: x[1..2] or x[1s..2s] as signal from 1 seconds to 2 seconds.

Interval data type from https://github.com/invenia/Intervals.jl

baggepinnen commented 4 years ago

Wouldn't the typed range 1s:2s have the same amount of information and dispatch possibilities?

mchitre commented 4 years ago

I played around with that, and had an implementation in the initial days. It would work with unitful quantities (which are supported but optional in the package). If someone wanted to use just numbers for time, dispatching on integer vs float is possible, but error-prone in usage. Hence my thought on using intervals rather than ranges.

But thoughts welcome, as I am ambivalent about it.

mchitre commented 3 years ago

Done. Will be part of 0.4.0 release.

Final implementation is as @baggepinnen suggested, but with 𝓈 instead of s to avoid conflict with single letter variables in code. If using SignalAnalysis.Units in included, then s will work too.