Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Request: List which Monoids support merge #279

Closed
schlichtanders opened this issue Mar 8, 2024 · 1 comment
Closed

Documentation Request: List which Monoids support merge #279

schlichtanders opened this issue Mar 8, 2024 · 1 comment

Comments

@schlichtanders
Copy link

schlichtanders commented Mar 8, 2024

I am trying to use OnlineStats.jl with DTable.jl and while it is a great combination, I often run into the error that merge is not defined for my Monoid of choice.

It would be great if there could be an easy list which Monoids also support merge.

EDIT: As a workaround for now, is there some programmatic way to find this list? I found the following:

foreach(println, unique(Base.unwrap_unionall(m.sig).parameters[2] for m in methods(OnlineStats._merge!)))
@joshday
Copy link
Owner

joshday commented May 21, 2024

Finally clearing out some old GH notifications...sorry for the delay.

There are a set of ideas swirling around in my head for "OnlineStats 2.0", one of which solves this. My temporary solution is below:


In OnlineStatsBase master, I've removed the fallback _merge! method (which just threw an error), so that this works:

julia> is_mergeable(o::T) where {T <: OnlineStat} = hasmethod(OnlineStats._merge!, Tuple{T,T})

julia> is_mergeable(Mean())
# true

Julia> is_mergeable(CircBuff(Int,5)) 
# false

I've added is_mergeable to OnlineStatsBase (unexported).

@joshday joshday closed this as completed May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants