Skip to content

Commit 01cba79

Browse files
committed
Name functions more consistently
1 parent 15ee516 commit 01cba79

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

docs/src/api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ vsym
1919
```@docs
2020
index_to_dict
2121
dict_to_index
22-
vn_to_string
23-
vn_from_string
22+
varname_to_string
23+
string_to_varname
2424
```
2525

2626
## Abstract model functions

src/AbstractPPL.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export VarName,
1313
@vsym,
1414
index_to_dict,
1515
dict_to_index,
16-
vn_to_string,
17-
vn_from_string
16+
varname_to_string,
17+
string_to_varname
1818

1919

2020
# Abstract model functions

src/varname.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -857,12 +857,12 @@ function dict_to_optic(dict)
857857
end
858858
end
859859

860-
vn_to_dict(vn::VarName) = Dict("sym" => getsym(vn), "optic" => optic_to_dict(getoptic(vn)))
860+
varname_to_dict(vn::VarName) = Dict("sym" => getsym(vn), "optic" => optic_to_dict(getoptic(vn)))
861861

862-
dict_to_vn(dict::Dict{<:AbstractString, Any}) = VarName{Symbol(dict["sym"])}(dict_to_optic(dict["optic"]))
862+
dict_to_varname(dict::Dict{<:AbstractString, Any}) = VarName{Symbol(dict["sym"])}(dict_to_optic(dict["optic"]))
863863

864864
"""
865-
vn_to_string(vn::VarName)
865+
varname_to_string(vn::VarName)
866866
867867
Convert a `VarName` as a string, via an intermediate dictionary. This differs
868868
from `string(vn)` in that concretised slices are faithfully represented (rather
@@ -875,25 +875,25 @@ if you are using custom index types, you will need to implement the
875875
documentation of [`dict_to_index`](@ref) for instructions on how to do this.
876876
877877
```jldoctest
878-
julia> vn_to_string(@varname(x))
878+
julia> varname_to_string(@varname(x))
879879
"{\\"optic\\":{\\"type\\":\\"identity\\"},\\"sym\\":\\"x\\"}"
880880
881-
julia> vn_to_string(@varname(x.a))
881+
julia> varname_to_string(@varname(x.a))
882882
"{\\"optic\\":{\\"field\\":\\"a\\",\\"type\\":\\"property\\"},\\"sym\\":\\"x\\"}"
883883
884-
julia> y = ones(2); vn_to_string(@varname(y[:]))
884+
julia> y = ones(2); varname_to_string(@varname(y[:]))
885885
"{\\"optic\\":{\\"indices\\":{\\"values\\":[{\\"type\\":\\"Base.Colon\\"}],\\"type\\":\\"Base.Tuple\\"},\\"type\\":\\"index\\"},\\"sym\\":\\"y\\"}"
886886
887-
julia> y = ones(2); vn_to_string(@varname(y[:], true))
887+
julia> y = ones(2); varname_to_string(@varname(y[:], true))
888888
"{\\"optic\\":{\\"indices\\":{\\"values\\":[{\\"range\\":{\\"stop\\":2,\\"type\\":\\"Base.OneTo\\"},\\"type\\":\\"AbstractPPL.ConcretizedSlice\\"}],\\"type\\":\\"Base.Tuple\\"},\\"type\\":\\"index\\"},\\"sym\\":\\"y\\"}"
889889
```
890890
"""
891-
vn_to_string(vn::VarName) = JSON.json(vn_to_dict(vn))
891+
varname_to_string(vn::VarName) = JSON.json(varname_to_dict(vn))
892892

893893
"""
894-
vn_from_string(str::AbstractString)
894+
string_to_varname(str::AbstractString)
895895
896896
Convert a string representation of a `VarName` back to a `VarName`. The string
897-
should have been generated by `vn_to_string`.
897+
should have been generated by `varname_to_string`.
898898
"""
899-
vn_from_string(str::AbstractString) = dict_to_vn(JSON.parse(str))
899+
string_to_varname(str::AbstractString) = dict_to_varname(JSON.parse(str))

0 commit comments

Comments
 (0)