joshday / OnlineStats.jl

⚡ Single-pass algorithms for statistics
https://joshday.github.io/OnlineStats.jl/latest/
MIT License
838 stars 64 forks source link

Regression in #206? Unitful support question #240

Closed NAThompson closed 3 years ago

NAThompson commented 3 years ago

In #206, we have a very nice diff which allows us to use Unitful datatypes in series. However, using:

pkg> status
Status `~/foo.jl/Project.toml`
  [a15396b6] OnlineStats v1.5.13
  [1986cc42] Unitful v1.9.1

I attempt to compute the mean of a series of values:

julia> t0 = 1.0u"s"
julia> m = Mean(typeof(t0))
Mean: n=0 | value=0.0 s
julia> t1 = 2.0u"s"
2.0 s
julia> fit!(m, t1)
ERROR: DimensionError: 0.0 s and 2.0 s² are not dimensionally compatible.

Note that the variance appears to work as expected:

julia> v = Variance(typeof(t0))
Variance: n=0 | value=1.0 s²
julia> fit!(v, t1)
Variance: n=1 | value=1.0 s²

As does Extrema:

julia> e = Extrema(typeof(t0))
Extrema: n=0 | value=(min = Inf s, max = -Inf s, nmin = 0, nmax = 0)

julia> fit!(e, t1)
Extrema: n=1 | value=(min = 2.0 s, max = 2.0 s, nmin = 1, nmax = 1)
joshday commented 3 years ago

Thanks for reporting! Fixed on OnlineStatsBase master...new release in progress.