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

Odd interaction of Group with broadcast #275

Closed
adienes opened this issue Feb 8, 2024 · 2 comments
Closed

Odd interaction of Group with broadcast #275

adienes opened this issue Feb 8, 2024 · 2 comments

Comments

@adienes
Copy link

adienes commented Feb 8, 2024

this was a little unexpected to me, as ordinarily foo.(x) is equivalent to map(foo, x)

julia> g = Group(Mean(), Variance())
Group
├─ Mean: n=0 | value=0.0
└─ Variance: n=0 | value=1.0


julia> value.(g)
(Mean: n=0 | value=0.0, Variance: n=0 | value=1.0)

julia> map(value, g)
2-element Vector{Float64}:
 0.0
 1.0
@joshday
Copy link
Owner

joshday commented Feb 8, 2024

I'm more surprised that map(value, g) works here, actually. The following method is in OnlineStatsBase, so OnlineStats opt out of the broadcast stuff:

Broadcast.broadcastable(o::OnlineStat) = Ref(o)

According to git blame, I apparently accepted a PR from someone 4 years ago (!) that added it. I don't know the reason, but there must have been one for adding it. At this point I think it's too breaking to remove it.

@joshday joshday closed this as completed Feb 8, 2024
@adienes
Copy link
Author

adienes commented Feb 8, 2024

ok, thanks for the explanation (also I just realized I can use values anyway)

I suspect map works because iterate works. And I suppose it wouldn't be the first object that iterates differently from broadcasting, e.g. String

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