@@ -48,14 +48,14 @@ There are also a numer of special selectors, which work like this:
4848| -----------------| ------------------| -------------------------| ---------|
4949| one nearest | ` B[time = 3] ` | ` B(time = Near(17.0)) ` | vector |
5050| all in a range | ` B[2:5, :] ` | ` B(Interval(14,25), :) ` | matrix |
51- | all matching | ` B[3:end, 3:3 ] ` | ` B(>(17), = =(33)) ` | matrix |
51+ | all matching | ` B[3:end, Not(3) ] ` | ` B(>(17), ! =(33)) ` | matrix |
5252| mixture | ` A[1, 2, end] ` | ` A(:left, Index[2], Index[end]) ` | scalar |
5353| non-scalar | ` B[iter=[1, 3]] ` | ` B(iter=[31, 33]) ` | matrix |
5454
5555Here ` Interval(13,18) ` can also be written ` 13..18 ` , it's from [ IntervalSets.jl] ( https://github.com/JuliaMath/IntervalSets.jl ) .
5656Any functions can be used to select keys, including lambdas: ` B(time = t -> 0<t<17) ` .
5757You may give just one ` ::Base.Fix2 ` function
58- (such as ` <=(18) ` or ` ! =(20)` ) provided its argument type matches the keys of one dimension.
58+ (such as ` <=(18) ` or ` = =(20)` ) provided its argument type matches the keys of one dimension.
5959An interval or a function always selects via ` findall ` ,
6060i.e. it does not drop a dimension, even if there is exactly one match.
6161
@@ -76,17 +76,18 @@ see [PR#5](https://github.com/mcabbott/AxisKeys.jl/pull/5) for an attempt.)
7676KeyedArray (rand (Int8, 2 ,10 ), ([:a , :b ], 10 : 10 : 100 )) # AbstractArray, Tuple{AbstractVector, ...}
7777```
7878
79- A nested pair with names can be constructed with keywords,
80- and (apart from a few bugs) this should work the same in either order:
79+ A nested pair with names can be constructed with keywords for names,
80+ and (apart from a few bugs) everything should work the same way in either order:
8181
8282``` julia
8383KeyedArray (rand (Int8, 2 ,10 ), row= [:a , :b ], col= 10 : 10 : 100 ) # KeyedArray(NamedDimsArray(...))
8484NamedDimsArray (rand (Int8, 2 ,10 ), row= [:a , :b ], col= 10 : 10 : 100 ) # NamedDimsArray(KeyedArray(...))
8585```
8686
8787The function ` wrapdims ` does a bit more checking and fixing, but is not type-stable.
88- It will adjust the length of key vectors if it can, and their indexing if needed to match the array.
89- The order of wrappers produced is controlled by ` AxisKeys.nameouter()=false ` .
88+ It will adjust the length of ranges of keys if it can,
89+ and will fix indexing offsets if needed to match the array.
90+ The resulting order of wrappers is controlled by ` AxisKeys.nameouter()=false ` .
9091
9192``` julia
9293wrapdims (rand (Int8, 10 ), alpha= ' a' :' z' )
@@ -100,14 +101,11 @@ axiskeys(ans,1) # 10:10:100 with indices 0:9
100101
101102As usual ` axes(A) ` returns (a tuple of vectors of) indices,
102103and ` axiskeys(A) ` returns (a tuple of vectors of) keys.
103- If the array has names, then ` dimnames(A) ` returns them,
104- and functions like ` axes (A, name)` give just one.
104+ If the array has names, then ` dimnames(A) ` returns them.
105+ These functions work like ` size (A, d) = size(A, name)` to get just one.
105106
106107Many functions should work, for example:
107108
108- * Reductions like ` sum(A; dims=:channel) ` can use dimension names.
109- Likewise ` prod ` , ` mean ` etc., and ` dropdims ` .
110-
111109* Broadcasting ` log.(A) ` and ` map(log, A) ` , as well as comprehensions
112110 ` [log(x) for x in A] ` should all work.
113111
@@ -116,21 +114,28 @@ Many functions should work, for example:
116114* Concatenation ` hcat(B, B .+ 100) ` works.
117115 Note that the keys along the glued direction may not be unique afterwards.
118116
117+ * Reductions like ` sum(A; dims=:channel) ` can use dimension names.
118+ Likewise ` prod ` , ` mean ` etc., and ` dropdims ` .
119+
119120* Some linear algebra functions like ` * ` and ` \ ` will work.
120121
121122* Getproperty returns the key vector, to allow things like
122- ` for (i,t) in enumerate(A.time); fun(A[i], t); ... ` .
123+ ` for (i,t) in enumerate(A.time); fun(val = A[i,:], time = t); ... ` .
123124
124125* Vectors support ` push!(V, val) ` , which will try to extend the key vector.
125126 There is also a method ` push!(V, key => val) ` which pushes in a new key.
126127
127128To allow for this limited mutability, ` V.keys isa Ref ` for vectors,
128129while ` A.keys isa Tuple ` for matrices & higher. But ` axiskeys(A) ` always returns a tuple.
129130
130- * [ LazyStack] ( https://github.com/mcabbott/LazyStack.jl ) ` .stack ` is now hooked up.
131- Stacks of named tuples like ` stack((a=i, b=i^2) for i=1:5) ` create axis keys.
131+ * Named tuples can be converted to and from keyed vectors,
132+ with ` collect(keys(nt)) == Symbol.(axiskeys(V),1) `
133+
134+ * [ LazyStack] ( https://github.com/mcabbott/LazyStack.jl ) ` .stack ` understands names and keys.
135+ Stacks of named tuples like ` stack((a=i, b=i^2) for i=1:5) ` create a matrix with ` [:a, :b] ` .
132136
133- * [ NamedPlus] ( https://github.com/mcabbott/NamedPlus.jl ) has a macro: ` @named [n^pow for n=1:10, pow=0:2:4] ` has names & keys.
137+ * [ NamedPlus] ( https://github.com/mcabbott/NamedPlus.jl ) has a macro which works on comprehensions:
138+ ` @named [n^pow for n=1:10, pow=0:2:4] ` has names and keys.
134139
135140### Absent
136141
0 commit comments