Skip to content

Commit

Permalink
Merge pull request #135 from goggle/typos01
Browse files Browse the repository at this point in the history
Correct some typos
  • Loading branch information
andyferris authored Jan 30, 2024
2 parents 74e716c + 382b084 commit fa49137
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 29 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ julia> filter(isodd, dict)
"c"3
```

The `filterview` function is provided to lazily filter a dictionary, which may occassionally
The `filterview` function is provided to lazily filter a dictionary, which may occasionally
be more performant when working with larger containers.

The `pairs` function allows access to both the index (key) and value when iterating.
Expand Down Expand Up @@ -396,7 +396,7 @@ julia> zeros(UInt8, dict)
"c"0x00
```

Note that the *indices* of the output are not guaranteed to be mutable/insertable - in fact, in the current implementation inserting or deleting indices to the output of the above can corrupt the input container (Julia suffers similar restrictions with `AbstractArray`s with mutable indices, for example changing the size of the indices of a `SubArray` can lead to corruption and segfaults). This also holds true for the output of `map`, `broadcast`, `getindices`, `similar`, `zeros`, `ones`, `falses` and `trues`. If you want a new container with indices you can insert, by sure to `copy` the indices furst, or use `empty` instead.
Note that the *indices* of the output are not guaranteed to be mutable/insertable - in fact, in the current implementation inserting or deleting indices to the output of the above can corrupt the input container (Julia suffers similar restrictions with `AbstractArray`s with mutable indices, for example changing the size of the indices of a `SubArray` can lead to corruption and segfaults). This also holds true for the output of `map`, `broadcast`, `getindices`, `similar`, `zeros`, `ones`, `falses` and `trues`. If you want a new container with indices you can insert, by sure to `copy` the indices first, or use `empty` instead.

#### Empty, insertable dictionaries indices

Expand Down Expand Up @@ -478,7 +478,7 @@ To make operations on dictionaries fast, we need to avoid unnecessary lookups in

#### Implementing the token interface for `AbstractIndices`

A token is a more efficient way of refering to an element of `indices`. Using tokens may
A token is a more efficient way of referring to an element of `indices`. Using tokens may
help avoid multiple index lookups for a single operation.

A tokenizable indices must implement:
Expand Down Expand Up @@ -536,15 +536,15 @@ julia> @btime map(+, d1, d2);
```

The `copy` below makes `keys(d1) !== keys(d2)`, disabling token co-iteration. It still uses
an iterative approach rather than using mulitple hash-table lookups per element, so it's
an iterative approach rather than using multiple hash-table lookups per element, so it's
relatively snappy.

```julia
julia> @btime map(+, d1, $(Dictionary(copy(keys(d2)), d2)));
61.615 ms (20 allocations: 76.29 MiB)
```

For a comparitive baseline benchmark, we can try the same with dense vectors.
For a comparative baseline benchmark, we can try the same with dense vectors.

```julia
julia> v1 = collect(10_000_000:-1:1);
Expand All @@ -557,7 +557,7 @@ julia> @btime map(+, v1, v2);

Here, the vector results are in line with the dictionary co-iteration!

Using insertion, instead of preserving the existing indices, is comparitively slow.
Using insertion, instead of preserving the existing indices, is comparatively slow.

```julia
julia> function f(d1, d2)
Expand Down
6 changes: 3 additions & 3 deletions contrib/DenseHashDictionaries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function rehash!(indices::DenseHashIndices{I}, newsize::Integer) where {I}
else
trial_slot = trial_slot & bit_mask
end
# This is potentially an infinte loop and care must be taken by the callee not
# This is potentially an infinite loop and care must be taken by the callee not
# to overfill the container
end
end
Expand Down Expand Up @@ -84,7 +84,7 @@ function Dictionaries.gettoken(indices::DenseHashIndices{I}, i::I) where {I}
end

trial_slot = trial_slot & bit_mask
# This is potentially an infinte loop and care must be taken upon insertion not
# This is potentially an infinite loop and care must be taken upon insertion not
# to completely fill the container
end
end
Expand Down Expand Up @@ -119,7 +119,7 @@ function Dictionaries.gettoken!(indices::DenseHashIndices{I}, i::I) where {I}
end

trial_slot = trial_slot & bit_mask
# This is potentially an infinte loop and care must be taken upon insertion not
# This is potentially an infinite loop and care must be taken upon insertion not
# to completely fill the container
end

Expand Down
6 changes: 3 additions & 3 deletions src/AbstractDictionary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function isdictequal(d1::AbstractDictionary, d2::AbstractDictionary)
return out
end

# Lexical ordering based on iteration (of pairs - lesser key takes priority over lesser value, as implmeneted in `cmp(::Pair)`)
# Lexical ordering based on iteration (of pairs - lesser key takes priority over lesser value, as implemented in `cmp(::Pair)`)
function Base.isless(dict1::AbstractDictionary, dict2::AbstractDictionary)
if sharetokens(dict1, dict2)
@inbounds for t in tokens(dict1)
Expand Down Expand Up @@ -310,7 +310,7 @@ indices). The mutable interface requires the dictionary to implement:
* `setindex!(dict::AbstractDictionary{I, T}, value::I, index::T)`
New settable dictionaries are primarily created through the `similar` function (for
unitialized values), as well as `fill`, `zeros`, `ones`, `trues` and `falses` (for
uninitialized values), as well as `fill`, `zeros`, `ones`, `trues` and `falses` (for
initialized values).
See also `isinsertable`.
Expand Down Expand Up @@ -350,7 +350,7 @@ end
similar(d::AbstractDictionary, [T=eltype(d)])
Construct a new `issettable` dictionary with identical `keys` as `d` and an element type of
`T`. The initial values are3unitialized/undefined.
`T`. The initial values are uninitialized/undefined.
"""
Base.similar(d::AbstractDictionary) = similar(keys(d), eltype(d))
Base.similar(d::AbstractDictionary, ::Type{T}) where {T} = similar(keys(d), T)
Expand Down
2 changes: 1 addition & 1 deletion src/ArrayDictionary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct ArrayDictionary{I, T, Inds <: ArrayIndices{I}, Vals <: AbstractArray{T}}

@inline function ArrayDictionary{I, T, Indices, Values}(indices::Indices, values::Values) where {I, T, Indices <: ArrayIndices{I}, Values <: AbstractArray{T}}
@boundscheck if LinearIndices(parent(indices)) != LinearIndices(values)
error("Dictinary indices and values inputs do not match")
error("Dictionary indices and values inputs do not match")
end
return new(indices, values)
end
Expand Down
10 changes: 5 additions & 5 deletions src/Indices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function Indices{I}(values::Vector{I}) where {I}
end
end
trial_slot = trial_slot & bit_mask
# This is potentially an infinte loop and care must be taken not to overfill the container
# This is potentially an infinite loop and care must be taken not to overfill the container
end
end
return Indices{I}(slots, hashes, values, 0)
Expand Down Expand Up @@ -150,7 +150,7 @@ function Base.convert(::Type{Indices{I}}, inds::AbstractIndices) where {I}
end
end
trial_slot = trial_slot & bit_mask
# This is potentially an infinte loop and care must be taken not to overfill the container
# This is potentially an infinite loop and care must be taken not to overfill the container
end
end
return Indices{I}(slots, hashes, values, 0)
Expand Down Expand Up @@ -224,7 +224,7 @@ function rehash!(indices::Indices{I}, newsize::Int, values = (), include_last_va
else
trial_slot = trial_slot & bit_mask
end
# This is potentially an infinte loop and care must be taken not to overfill the container
# This is potentially an infinite loop and care must be taken not to overfill the container
end
end
else
Expand Down Expand Up @@ -358,7 +358,7 @@ function gettoken(indices::Indices{I}, i) where {I}
end

trial_slot = trial_slot & bit_mask
# This is potentially an infinte loop and care must be taken upon insertion not
# This is potentially an infinite loop and care must be taken upon insertion not
# to completely fill the container
end
end
Expand Down Expand Up @@ -403,7 +403,7 @@ function gettoken!(indices::Indices{I}, i::I, values = ()) where {I}
end

trial_slot = trial_slot & bit_mask
# This is potentially an infinte loop and care must be taken upon insertion not
# This is potentially an infinite loop and care must be taken upon insertion not
# to completely fill the container
end

Expand Down
6 changes: 3 additions & 3 deletions src/UnorderedDictionary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ UnorderedDictionary() = UnorderedDictionary{Any}()
UnorderedDictionary{I, T}(indices, undef::UndefInitializer)
Construct a `UnorderedDictionary` with index type `I` and element type `T`. The container is
initialized with `keys` that match the values of `indices`, but the values are unintialized.
initialized with `keys` that match the values of `indices`, but the values are uninitialized.
"""
function UnorderedDictionary{I, T}(indices, ::UndefInitializer) where {I, T}
return UnorderedDictionary{I, T}(UnorderedIndices{I}(indices), undef)
Expand Down Expand Up @@ -70,7 +70,7 @@ function UnorderedDictionary{I, T}(indices, values) where {I, T}
end
function UnorderedDictionary{I}(indices, values) where {I}
if Base.IteratorEltype(values) === Base.EltypeUnknown()
# TODO: implement automatic widening from iterators of Base.EltypeUnkown
# TODO: implement automatic widening from iterators of Base.EltypeUnknown
values = collect(values)
end

Expand All @@ -79,7 +79,7 @@ end

function UnorderedDictionary(indices, values)
if Base.IteratorEltype(indices) === Base.EltypeUnknown()
# TODO: implement automatic widening from iterators of Base.EltypeUnkown
# TODO: implement automatic widening from iterators of Base.EltypeUnknown
indices = collect(indices)
end

Expand Down
2 changes: 1 addition & 1 deletion src/UnorderedIndices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Construct a `UnorderedIndices` with indices from iterable container `iter`.
"""
function UnorderedIndices(iter)
if Base.IteratorEltype(iter) === Base.EltypeUnknown()
# TODO: implement automatic widening from iterators of Base.EltypeUnkown
# TODO: implement automatic widening from iterators of Base.EltypeUnknown
iter = collect(iter)
end

Expand Down
2 changes: 1 addition & 1 deletion src/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ end
end

# TODO accelerate view(::Union{Dictionary, Indices}, ::Indices) to fetch not compute the intermediate `hash`
# (similary a sort-based index could take advantage of sort-merge algorithms on iteration?)
# (similarly a sort-based index could take advantage of sort-merge algorithms on iteration?)
4 changes: 2 additions & 2 deletions src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function Base.show(io::IO, ::MIME"text/plain", d::AbstractIndices)
for i in Iterators.reverse(keys(d))
if bottom_full
if isequal(i, top_last_index[])
bottom_full = false # overide this, we don't need the ⋮
bottom_full = false # override this, we don't need the ⋮
else
bottom_ind_strs[end] = ""
end
Expand Down Expand Up @@ -170,7 +170,7 @@ function Base.show(io::IO, ::MIME"text/plain", d::AbstractDictionary)
for i in Iterators.reverse(keys(d))
if bottom_full
if isequal(i, top_last_index[])
bottom_full = false # overide this, we don't need the ⋮
bottom_full = false # override this, we don't need the ⋮
else
bottom_ind_strs[end] = ""
bottom_val_strs[end] = ""
Expand Down
4 changes: 2 additions & 2 deletions src/tokens.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Return `true` if the indices `indices` obeys the token interface, or `false` otherwise.
A token is a more efficient way of refering to an element of `indices`. Using tokens may
A token is a more efficient way of referring to an element of `indices`. Using tokens may
help avoid multiple index lookups for a single operation.
A tokenizable indices must implement:
Expand All @@ -24,7 +24,7 @@ An `isinsertable` tokenizable indices must implement
Return `true` if the dictionary `dict` obeys the token interface, or `false` otherwise.
A token is a more efficient way of refering to an element of `dict`. Using tokens may
A token is a more efficient way of referring to an element of `dict`. Using tokens may
help avoid multiple index lookups for a single operation.
An tokenizable dictionary must implement:
Expand Down
2 changes: 1 addition & 1 deletion test/Indices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
@test (i5 == Indices([1,2,missing])) === missing
end

@testset "Adapated from Dict tests from Base" begin
@testset "Adapted from Dict tests from Base" begin
h = Indices{Int}()
N = 10000

Expand Down
2 changes: 1 addition & 1 deletion test/UnorderedIndices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
@test issetequal(i2, i2)
end

@testset "Adapated from Dict tests from Base" begin
@testset "Adapted from Dict tests from Base" begin
h = UnorderedIndices{Int}()
N = 10000

Expand Down

0 comments on commit fa49137

Please sign in to comment.