LabeledArrays

Vectors for fast Int index retrieval, NamedMatrix with names as keys of arbitrary type and sparse index vectors.

TODO:

  • generalized NamedArray implementation.
  • examples

Public Documentation

Documentation for LabeledArrays.jl's public interface.

LabeledArrays.NBijectionType
NBijection(x::Vector{T})

KEY <-> Int, bijection map. Synonym to possibly better name EnumerationDict, or VectorDict.

Store inverse indices in a Dict{T,I} as well as original Vector{T}.

  • copy: set to false to store x without copying. (make sure that Vector will be mutated only through NBijection API.
source
Base.get!Method
Base.get!(f::Function,b::NBijection, key)

Calls f(length(b),key) hook function if key !in b, push key to b.enumeration and store key=>index. Similar to get!(f,b::Dict, key).

TODO: remove f(n,key)

julia> x = NBijection(['a','b','c'])
julia> get!(x,'b')
2

julia> get!((i,k)->println("neu"), x, 'd')
neu
4

julia> get!((i,k)->println("neu"), x, 'd')
4
source
Base.get!Method
Base.get!(b::NBijection, key)

When key !in b.index, push nothing to b.enumeration and store key=>index.

julia> x = NBijection(['a','b','c'])
julia> get!(x,'b')
2

julia> get!(x,'d')
4

julia> get!(x,'d')
4
source
Base.keysMethod
keys(b::NBijection)

terms are keys in sequence that share position index with some other data structure, like a count matrix in Count.

source
Base.push!Method
Base.push!(b::NBijection, key)

Push key to b.enumeration and store key=>index. Return last index.

@asserts that key is not in index, fails otherwise. Consider get!.

source
SparseArrays.nnzMethod
nnz(x::LinearAlgebra.Adjoint)

Call SparseArrays.nnz of transpose for performance.

source