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

Define counter(::Generator) #302

Merged
merged 3 commits into from
Sep 3, 2017

Conversation

cstjean
Copy link
Contributor

@cstjean cstjean commented Jul 8, 2017

The call to _default_eltype comes from the Set constructor. Also, it might be worth defining a pushmany! function; the for x in blah; push!(c, x) end loop happens four times already in that file.

@@ -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))
Copy link
Member

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!

Copy link
Contributor Author

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
Copy link

codecov bot commented Aug 26, 2017

Codecov Report

Merging #302 into master will decrease coverage by 0.47%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/accumulator.jl 100% <100%> (ø) ⬆️
src/priorityqueue.jl 90% <0%> (-9.14%) ⬇️
src/DataStructures.jl 80% <0%> (-8.89%) ⬇️
src/disjoint_set.jl 97.87% <0%> (-2.13%) ⬇️
src/heaps/mutable_binary_heap.jl 92.66% <0%> (-0.14%) ⬇️
src/trie.jl 93.22% <0%> (ø) ⬆️
src/multi_dict.jl 96.66% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7178c60...9c5c952. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 26, 2017

Codecov Report

Merging #302 into master will decrease coverage by <.01%.
The diff coverage is 57.14%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/accumulator.jl 60.31% <57.14%> (+0.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b8de28...d58af8b. Read the comment docs.

@kmsquire
Copy link
Member

kmsquire commented Sep 2, 2017

Fixed merge conflicts against master. Will merge once CI passes.

I need to open up an issue against Base regarding _default_eltype.

@kmsquire
Copy link
Member

kmsquire commented Sep 3, 2017

As before, (incorrect) coverage changes are JuliaCI/Coverage.jl#132.

@kmsquire kmsquire merged commit 5138101 into JuliaCollections:master Sep 3, 2017
@cstjean cstjean deleted the pull-request/d61810d5 branch September 27, 2017 13:39
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

Successfully merging this pull request may close these issues.

2 participants