@@ -80,7 +80,7 @@ function Chains(
80
80
end
81
81
82
82
"""
83
- Chains(c::Chains, section::Union{Symbol,String })
83
+ Chains(c::Chains, section::Union{Symbol,AbstractString })
84
84
Chains(c::Chains, sections)
85
85
86
86
Return a new chain with only a specific `section` or multiple `sections` pulled out.
@@ -101,7 +101,7 @@ julia> names(chn2)
101
101
:a
102
102
```
103
103
"""
104
- Chains (c:: Chains , section:: Union{Symbol,String } ) = Chains (c, (section,))
104
+ Chains (c:: Chains , section:: Union{Symbol,AbstractString } ) = Chains (c, (section,))
105
105
function Chains (chn:: Chains , sections)
106
106
# Make sure the sections exist first.
107
107
all (haskey (chn. name_map, Symbol (x)) for x in sections) ||
@@ -121,7 +121,7 @@ Chains(chain::Chains, ::Nothing) = chain
121
121
# Groups of parameters
122
122
123
123
"""
124
- namesingroup(chains::Chains, sym::Symbol; index_type::Symbol=:bracket)
124
+ namesingroup(chains::Chains, sym::Union{AbstractString, Symbol} ; index_type::Symbol=:bracket)
125
125
126
126
Return the parameters with the same name `sym`, but have a different index. Bracket indexing format
127
127
in the form of `:sym[index]` is assumed by default. Use `index_type=:dot` for parameters with dot
@@ -147,7 +147,7 @@ julia> namesingroup(chn, :A; index_type=:dot)
147
147
Symbol("A.2")
148
148
```
149
149
"""
150
- namesingroup (chains:: Chains , sym:: String ; kwargs... ) = namesingroup (chains, Symbol (sym); kwargs... )
150
+ namesingroup (chains:: Chains , sym:: AbstractString ; kwargs... ) = namesingroup (chains, Symbol (sym); kwargs... )
151
151
function namesingroup (chains:: Chains , sym:: Symbol ; index_type:: Symbol = :bracket )
152
152
if index_type != = :bracket && index_type != = :dot
153
153
error (" index_type must be :bracket or :dot" )
@@ -161,14 +161,14 @@ function namesingroup(chains::Chains, sym::Symbol; index_type::Symbol=:bracket)
161
161
end
162
162
163
163
"""
164
- group(chains::Chains, name::Union{String ,Symbol}; index_type::Symbol=:bracket)
164
+ group(chains::Chains, name::Union{AbstractString ,Symbol}; index_type::Symbol=:bracket)
165
165
166
166
Return a subset of the chain containing parameters with the same `name`, but a different index.
167
167
168
168
Bracket indexing format in the form of `:name[index]` is assumed by default. Use `index_type=:dot` for parameters with dot
169
169
indexing, i.e. `:sym.index`.
170
170
"""
171
- function group (chains:: Chains , name:: Union{String ,Symbol} ; kwargs... )
171
+ function group (chains:: Chains , name:: Union{AbstractString ,Symbol} ; kwargs... )
172
172
return chains[:, namesingroup (chains, name; kwargs... ), :]
173
173
end
174
174
177
177
Base. getindex (c:: Chains , i:: Integer ) = c[i, :, :]
178
178
Base. getindex (c:: Chains , i:: AbstractVector{<:Integer} ) = c[i, :, :]
179
179
180
- Base. getindex (c:: Chains , v:: String ) = c[:, Symbol (v), :]
181
- Base. getindex (c:: Chains , v:: AbstractVector{String } ) = c[:, Symbol .(v), :]
180
+ Base. getindex (c:: Chains , v:: AbstractString ) = c[:, Symbol (v), :]
181
+ Base. getindex (c:: Chains , v:: AbstractVector{<:AbstractString } ) = c[:, Symbol .(v), :]
182
182
183
183
Base. getindex (c:: Chains , v:: Symbol ) = c[:, v, :]
184
184
Base. getindex (c:: Chains , v:: AbstractVector{Symbol} ) = c[:, v, :]
@@ -199,7 +199,7 @@ _toindex(i, j, k::Integer) = (i, string2symbol(j), k:k)
199
199
_toindex (i:: Integer , j, k:: Integer ) = (i: i, string2symbol (j), k: k)
200
200
201
201
# return an array or a number if a single parameter is specified
202
- const SingleIndex = Union{Symbol,String ,Integer}
202
+ const SingleIndex = Union{Symbol,AbstractString ,Integer}
203
203
_toindex (i, j:: SingleIndex , k) = (i, string2symbol (j), k)
204
204
_toindex (i:: Integer , j:: SingleIndex , k) = (i, string2symbol (j), k)
205
205
_toindex (i, j:: SingleIndex , k:: Integer ) = (i, string2symbol (j), k)
@@ -542,7 +542,7 @@ Return multiple `Chains` objects, each containing only a single section.
542
542
function get_sections (chains:: Chains , sections = keys (chains. name_map))
543
543
return [Chains (chains, section) for section in sections]
544
544
end
545
- get_sections (chains:: Chains , section:: Union{Symbol, String } ) = Chains (chains, section)
545
+ get_sections (chains:: Chains , section:: Union{Symbol, AbstractString } ) = Chains (chains, section)
546
546
547
547
"""
548
548
sections(c::Chains)
@@ -727,7 +727,7 @@ function _clean_sections(chains::Chains, sections)
727
727
haskey (chains. name_map, Symbol (section))
728
728
end
729
729
end
730
- function _clean_sections (chains:: Chains , section:: Union{String ,Symbol} )
730
+ function _clean_sections (chains:: Chains , section:: Union{AbstractString ,Symbol} )
731
731
return haskey (chains. name_map, Symbol (section)) ? section : ()
732
732
end
733
733
_clean_sections (:: Chains , :: Nothing ) = nothing
0 commit comments