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

Bug: Counter T does not work with abstract types like Any #242

Closed
schlichtanders opened this issue Dec 6, 2021 · 3 comments
Closed

Bug: Counter T does not work with abstract types like Any #242

schlichtanders opened this issue Dec 6, 2021 · 3 comments

Comments

@schlichtanders
Copy link

Using Counter I was very surprised that Counter(Any) does not work.

Given the documentation Count the number of items in a data stream with elements of type T. this sounds like a but, as every element is of type Any.

@joshday
Copy link
Owner

joshday commented Dec 6, 2021

Could you clarify what doesn't work? I don't think I follow you.

julia> o = Counter(Any)
Counter: n=0 | value=0

julia> fit!(o, 1)
Counter: n=1 | value=1

julia> fit!(o, "hi")
Counter: n=2 | value=2

@joshday joshday closed this as completed Dec 12, 2021
@schlichtanders
Copy link
Author

Hi JoshDay, thank you for managing these tickets.

I actually found the misunderstanding

julia> o = Counter(Any)
Counter: n=0 | value=0

julia> fit!(o, [1,2,3,4])
Counter: n=1 | value=1

Any is also matching iterators, which makes totally sense.
The workaround is iterating yourself.

@joshday
Copy link
Owner

joshday commented Dec 13, 2021

Ah, right! Glad you worked it out.

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