andyferris / Dictionaries.jl

An alternative interface for dictionaries in Julia, for improved productivity and performance
Other
278 stars 28 forks source link

Add convert method to `Dictionary` #67

Closed serenity4 closed 2 years ago

serenity4 commented 2 years ago

This implements a very basic method to automatically convert between Dictionary types. I am not sure whether there is anything more to do.

Solves #66.

codecov[bot] commented 2 years ago

Codecov Report

Merging #67 (eadc8af) into master (03d79e4) will increase coverage by 0.90%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #67      +/-   ##
==========================================
+ Coverage   74.02%   74.93%   +0.90%     
==========================================
  Files          19       19              
  Lines        1721     1871     +150     
==========================================
+ Hits         1274     1402     +128     
- Misses        447      469      +22     
Impacted Files Coverage Δ
src/Dictionary.jl 67.71% <100.00%> (+3.36%) :arrow_up:
src/Indices.jl 87.97% <0.00%> (-0.49%) :arrow_down:
src/find.jl 100.00% <0.00%> (ø)
src/insertion.jl 71.00% <0.00%> (+0.19%) :arrow_up:
src/AbstractIndices.jl 78.53% <0.00%> (+0.21%) :arrow_up:
src/filter.jl 63.20% <0.00%> (+0.26%) :arrow_up:
src/show.jl 93.75% <0.00%> (+0.41%) :arrow_up:
src/ArrayIndices.jl 96.47% <0.00%> (+0.58%) :arrow_up:
src/broadcast.jl 51.38% <0.00%> (+0.61%) :arrow_up:
src/map.jl 44.32% <0.00%> (+0.80%) :arrow_up:
... and 8 more

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 03d79e4...eadc8af. Read the comment docs.

serenity4 commented 2 years ago

Yes, it would be nice to make it work for all types of dictionaries. I'm not sure if there is a generic way to do it on AbstractDictionary that could work regardless of the implementation, though it might be reasonable to have a default conversion behavior that can be customized for dictionary implementations.

andyferris commented 2 years ago

I know in Base there are methods like convert(::Type{AbstractVector{T}}, v::Vector) where {T} = Vector{T}(v). I think we could do that kind of thing here? I'm happy to merge this now and address it in the future though.

andyferris commented 2 years ago

FYI https://github.com/JuliaRegistries/General/pull/45174

serenity4 commented 2 years ago

Thanks! Indeed there might be a way to do it cleanly. I personally needed this for Dictionary at the moment, but I'd be happy to revisit that in the future if needed.