@@ -10,14 +10,24 @@ using NamedDimsArrays:
1010 randname,
1111 setname
1212
13- tagsstring (tags:: Dict{String,String} ) = string (tags)
13+ tagpairstring (pair:: Pair ) = repr (first (pair)) * " =>" * repr (last (pair))
14+ function tagsstring (tags:: Dict{String,String} )
15+ tagpairs = sort (collect (tags); by= first)
16+ tagpair1, tagpair_rest = Iterators. peel (tagpairs)
17+ return mapreduce (* , tagpair_rest; init= tagpairstring (tagpair1)) do tagpair
18+ return " ," * tagpairstring (tagpair)
19+ end
20+ end
1421
15- @kwdef struct IndexName <: AbstractName
16- id:: UInt64 = rand (UInt64)
17- tags:: Dict{String,String} = Dict {String,String} ()
18- plev:: Int = 0
22+ struct IndexName <: AbstractName
23+ id:: UInt64
24+ tags:: Dict{String,String}
25+ plev:: Int
26+ end
27+ function IndexName (; id:: UInt64 = rand (UInt64), tags= Dict {String,String} (), plev:: Int = 0 )
28+ return IndexName (id, Dict {String,String} (tags), plev)
1929end
20- NamedDimsArrays. randname (n:: IndexName ) = IndexName (; tags = tags (n), plev = plev (n) )
30+ NamedDimsArrays. randname (n:: IndexName ) = IndexName ()
2131
2232id (n:: IndexName ) = n. id
2333tags (n:: IndexName ) = n. tags
@@ -47,7 +57,7 @@ sim(n::IndexName) = randname(n)
4757
4858function Base. show (io:: IO , i:: IndexName )
4959 idstr = " id=$(id (i) % 1000 ) "
50- tagsstr = ! isempty (tags (i)) ? " |\" $(tagsstring (tags (i))) \" " : " "
60+ tagsstr = ! isempty (tags (i)) ? " |$(tagsstring (tags (i))) " : " "
5161 primestr = primestring (plev (i))
5262 str = " IndexName($(idstr)$(tagsstr) )$(primestr) "
5363 print (io, str)
125135function Base. show (io:: IO , i:: Index )
126136 lenstr = " length=$(dename (length (i))) "
127137 idstr = " |id=$(id (i) % 1000 ) "
128- tagsstr = ! isempty (tags (i)) ? " |\" $(tagsstring (tags (i))) \" " : " "
138+ tagsstr = ! isempty (tags (i)) ? " |$(tagsstring (tags (i))) " : " "
129139 primestr = primestring (plev (i))
130140 str = " Index($(lenstr)$(idstr)$(tagsstr) )$(primestr) "
131141 print (io, str)
0 commit comments