diff --git a/docs/src/operations.md b/docs/src/operations.md index 1df5ed5..a9583ab 100644 --- a/docs/src/operations.md +++ b/docs/src/operations.md @@ -80,23 +80,3 @@ julia> for (x,y) in b; println("$x --> $y"); end 1 --> alpha ``` - - - - -## Composition - -Given two `Bijection`s `a` and `b`, their composition `c = a*b` is a new -`Bijection` with the property that `c[x] = a[b[x]]` for all `x` in the -domain of `b`. - -``` -julia> a = Bijection{Int,Int}(); a[1] = 10; a[2] = 20; - -julia> b = Bijection{String,Int}(); b["hi"] = 1; b["bye"] = 2; - -julia> c = a * b; - -julia> c["hi"] -10 -``` diff --git a/src/Bijections.jl b/src/Bijections.jl index 78b9e1d..020bae5 100644 --- a/src/Bijections.jl +++ b/src/Bijections.jl @@ -25,12 +25,12 @@ end """ Bijection() -Construct a new `Bijection`. +Construct a new `Bijection`. * `Bijection{S,T}()` creates an empty `Bijection` from objects of type `S` to objects of type `T`. If `S` and `T` are omitted, then we have `Bijection{Any,Any}`. * `Bijection(x::S, y::T)` creates a new `Bijection` initialized with `x` mapping to `y`. -* `Bijection(dict::Dict{S,T})` creates a new `Bijection` based on the mapping in `dict`. -* `Bijection(pair_list::Vector{Pair{S,T}})` creates a new `Bijection` using the key/value pairs in `pair_list`. +* `Bijection(dict::Dict{S,T})` creates a new `Bijection` based on the mapping in `dict`. +* `Bijection(pair_list::Vector{Pair{S,T}})` creates a new `Bijection` using the key/value pairs in `pair_list`. """ Bijection() = Bijection{Any,Any}() @@ -269,6 +269,4 @@ function Serialization.deserialize( return B(f) end -include("composition.jl") - end # end of module Bijections diff --git a/src/composition.jl b/src/composition.jl deleted file mode 100644 index d0268d8..0000000 --- a/src/composition.jl +++ /dev/null @@ -1,13 +0,0 @@ -""" - (*)(a::Bijection{A,B}, b::Bijection{B,C})::Bijection{A,C} where {A,B,C} - -The result of `a * b` is a new `Bijection` `c` such that `c[x]` is `a[b[x]]` for `x` -in the domain of `b`. -""" -function Base.:(*)(a::Bijection{B,A}, b::Bijection{C,B}) where {A,B,C} - c = Bijection{C,A}() - for x in keys(b) - c[x] = a[b[x]] - end - return c -end diff --git a/test/runtests.jl b/test/runtests.jl index 79cd499..495a02a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -38,20 +38,6 @@ using Serialization @test Bijection(collect(b)) == b end -# check composition -@testset "Composition" begin - a = Bijection{Int,Int}() - a[1] = 10 - a[2] = 20 - - b = Bijection{String,Int}() - b["hi"] = 1 - b["bye"] = 2 - - c = a * b - @test c["hi"] == 10 -end - # Test empty constructor @testset "empty_constructor" begin b = Bijection{Int,String}()