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

Suggestions for OnlineStats v2 #285

Closed
adknudson opened this issue Apr 6, 2024 · 1 comment
Closed

Suggestions for OnlineStats v2 #285

adknudson opened this issue Apr 6, 2024 · 1 comment

Comments

@adknudson
Copy link

In the event that a version 2 is ever released, I think it would be good to have place to discuss potential design changes. Please close this issue if it's inappropriate or not worth discussing :)

To start, I think Sum(Integer) should only accept integer types. The fact that it can accept a real value and round to an integer can cause unexpected behavior, and requires extra code in OnlineStatsBase to handle that condition:

_fit!(o::Sum{T}, x::Real) where {T<:AbstractFloat} = (o.sum += convert(T, x); o.n += 1)
_fit!(o::Sum{T}, x::Real) where {T<:Integer} = (o.sum += round(T, x); o.n += 1) # <- this should be an error
@joshday
Copy link
Owner

joshday commented May 21, 2024

Agreed! This is one of the earliest pieces of code ever added to OnlineStats(Base). I vet contributions with a little more rigor nowadays...

I'm removing the methods that use round.

@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