-
Notifications
You must be signed in to change notification settings - Fork 247
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
Define counter(::Generator) #302
Define counter(::Generator) #302
Conversation
src/accumulator.jl
Outdated
@@ -24,6 +24,14 @@ function counter{T}(seq::AbstractArray{T}) | |||
return ct | |||
end | |||
|
|||
function counter{T<:Base.Generator}(gen::T) | |||
ct = counter(Base._default_eltype(T)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there is a better way to do this? My only concern is that this is meant to be an internal function and could (in theory) go away...
Anyway, this is useful functionality. Sorry to let it languish!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered that too, but it's how Base.Set
does it, and similarly for Dict
. It's defined as _default_eltype(itrt::ANY) = Core.Inference.return_type(first, Tuple{itrt})
, so I don't think we can do it correctly using exported functionality.
Codecov Report
@@ Coverage Diff @@
## master #302 +/- ##
==========================================
- Coverage 96.36% 95.88% -0.48%
==========================================
Files 31 31
Lines 2284 2261 -23
==========================================
- Hits 2201 2168 -33
- Misses 83 93 +10
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #302 +/- ##
==========================================
- Coverage 67.35% 67.34% -0.01%
==========================================
Files 31 31
Lines 3265 3271 +6
==========================================
+ Hits 2199 2203 +4
- Misses 1066 1068 +2
Continue to review full report at Codecov.
|
Fixed merge conflicts against master. Will merge once CI passes. I need to open up an issue against Base regarding |
As before, (incorrect) coverage changes are JuliaCI/Coverage.jl#132. |
The call to
_default_eltype
comes from theSet
constructor. Also, it might be worth defining apushmany!
function; thefor x in blah; push!(c, x) end
loop happens four times already in that file.