Skip to content

Commit 2bb85f1

Browse files
authored
Merge pull request #22 from TuringLang/tor/prettier-colon
Prettier show for `Colon`
2 parents 34fc3e1 + a01fa61 commit 2bb85f1

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uuid = "7a57a42e-76ec-4ea3-a279-07e840d6d9cf"
33
keywords = ["probablistic programming"]
44
license = "MIT"
55
desc = "Common interfaces for probabilistic programming"
6-
version = "0.1.4"
6+
version = "0.2.0"
77

88
[deps]
99
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"

src/varname.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ indexing expression through the [`@varname`](@ref) convenience macro.
1717
1818
```jldoctest
1919
julia> vn = VarName{:x}(((Colon(), 1), (2,)))
20-
x[Colon(),1][2]
20+
x[:,1][2]
2121
2222
julia> vn.indexing
2323
((Colon(), 1), (2,))
2424
2525
julia> @varname x[:, 1][1+1]
26-
x[Colon(),1][2]
26+
x[:,1][2]
2727
```
2828
"""
2929
struct VarName{sym, T<:Tuple}
@@ -93,11 +93,13 @@ function Base.show(io::IO, vn::VarName)
9393
print(io, getsym(vn))
9494
for indices in getindexing(vn)
9595
print(io, "[")
96-
join(io, indices, ",")
96+
join(io, map(replace_colon_string, indices), ",")
9797
print(io, "]")
9898
end
9999
end
100100

101+
prettify_index(x) = string(x)
102+
prettify_index(::Colon) = ":"
101103

102104
"""
103105
Symbol(vn::VarName)

0 commit comments

Comments
 (0)