Merge BijectiveDicts into Bijections#15
Conversation
|
Thank you @mofeing . This was a lot that you did! I'll look it over. I see you've added a lot of tests! Do you think it's nearly ready for release? |
|
Thank you for accepting the changes so quick! I already have been working with BijectiveDicts.jl for a while so I already knew which were the edge cases and how to test them.
I think so. We should update the README with a "breaking notice" to tell users that the |
OK. I can work on that. I'm unclear about
Do I have that right? But when I try to construct a |
I just started using |
|
In reality, this is more verbose:
you need to specify the full type of julia> b = Bijection{Int, Int, IdDict{Int,Int}, IdDict{Int,Int}}()
Bijection{Int64, Int64, IdDict{Int64, Int64}, IdDict{Int64, Int64}}()This is just in the case that you want to customize julia> b = Bijection{Int, Int}()
Bijection{Int64, Int64, Dict{Int64, Int64}, Dict{Int64, Int64}}() |
Yes! I want to update the documentation (at least the |
Got it! Gracias. |
Yes, this is a breaking release but behavior should be the same. The only breaking change is that The only thing you should update is when you have a field that is a from anchor_keys::Bijections.Bijection{String,String}to anchor_keys::Bijections.Bijection{String,String,Dict{String,String},Dict{String,String}}Note that you shouldn't need to change anything else. For example, in https://github.com/JuliaDocs/DocumenterCitations.jl/blob/52aa72bf4e2a045a2426cf0791fa2bb14ec9f0c6/src/DocumenterCitations.jl#L129, where you instantiate a anchor_keys = Bijections.Bijection{String,String}()There's no problem because this constructor will default If it feels too verbose, we can add a macro like |
|
@scheinerman right |
Following discussion in JuliaRegistries/General#131059, I'm merging the modifications made in bsc-quantic/BijectiveDicts.jl in here.
I've tried to be as less disruptive as posible, but I've also have taken some freedom to update some parts of the code to minimize overhead and be more idiomatic.
Some of these changes include:
Bijection's underneath dictionary typesshowmethod It's already handled byAbstractDict. I guess this was from a time whereshowwas not implemented forAbstractDict, but since LTS version is Julia 1.10 and this will be a breaking release, I guess it's okay to assume that all users wil be using a Julia version that supports it.haskey,keysandvaluesThis gives the opportunity to be faster as if not implemented, it will probably need toiterateto reconstruct each function.hasvaluefunction This behaves just likehaskeybut for the keys of the inverse mapping. It actually callshaskeyonfinv, which should be much faster than iterating in some cases.setindex!when there is an existing key (but the value is not present) This is a common pattern I find myself in and that it's useful. I previously implemented into some coherence bugs, so this implementation avoids errors by checking that the value is not present.invandactive_invThe wayinvwas implemented was no longer valid.delete!sizehint!