Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions docs/src/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
8 changes: 3 additions & 5 deletions src/Bijections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}()

Expand Down Expand Up @@ -269,6 +269,4 @@ function Serialization.deserialize(
return B(f)
end

include("composition.jl")

end # end of module Bijections
13 changes: 0 additions & 13 deletions src/composition.jl

This file was deleted.

14 changes: 0 additions & 14 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}()
Expand Down
Loading