Skip to content

Commit 2d40986

Browse files
committed
Fixed some show methods.
1 parent 4d147c4 commit 2d40986

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

docs/make.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using Documenter, ComponentArrays
33
makedocs(;
44
modules=[ComponentArrays],
55
format=Documenter.HTML(
6-
canonical = "https://jonniedie.github.io/ComponentArrays.jl/stable",
6+
canonical="https://jonniedie.github.io/ComponentArrays.jl/stable",
77
),
88
pages=[
99
"Home" => "index.md",
@@ -19,6 +19,7 @@ makedocs(;
1919
sitename="ComponentArrays.jl",
2020
authors="Jonnie Diegelman",
2121
assets=String[],
22+
doctest=:fix,
2223
)
2324

2425
deploydocs(;

src/axis.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ viewindex(i) = i
8888
Gives named component access for `ComponentArray`s.
8989
# Examples
9090
91-
```jldoctest
91+
```
9292
julia> using ComponentArrays
9393
9494
julia> ax = Axis((a = 1, b = ViewAxis(2:7, PartitionedAxis(2, (a = 1, b = 2))), c = ViewAxis(8:10, (a = 1, b = 2:3))));
@@ -102,7 +102,7 @@ julia> ca.a
102102
100.0
103103
104104
julia> ca.b
105-
3-element LazyArray{ComponentVector{Float64,SubArray...},1}:
105+
3-element LazyArray{ComponentVector{Float64,SubArray...}}:
106106
ComponentVector{Float64,SubArray...}(a = 4.0, b = 1.3)
107107
ComponentVector{Float64,SubArray...}(a = 1.0, b = 1.0)
108108
ComponentVector{Float64,SubArray...}(a = 4.4, b = 0.4)
@@ -111,7 +111,7 @@ julia> ca.c
111111
ComponentVector{Float64,SubArray...}(a = 2.0, b = [1.0, 45.0])
112112
113113
julia> ca.c.b
114-
2-element view(::Array{Float64,1}, 9:10) with eltype Float64:
114+
2-element view(::Vector{Float64}, 9:10) with eltype Float64:
115115
1.0
116116
45.0
117117
```

src/componentarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ julia> x[5]
2121
400
2222
2323
julia> collect(x)
24-
7-element Array{Int64,1}:
24+
7-element Vector{Int64}:
2525
1
2626
2
2727
1
@@ -252,7 +252,7 @@ Access ```.axes``` field of a ```ComponentArray```. This is different than ```ax
252252
julia> using ComponentArrays
253253
254254
julia> ax = Axis(a=1:3, b=(4:6, (a=1, b=2:3)))
255-
Axis{(a = 1:3, b = (4:6, (a = 1, b = 2:3)))}()
255+
Axis(a = 1:3, b = (4:6, (a = 1, b = 2:3)))
256256
257257
julia> A = zeros(6,6);
258258

src/lazyarray.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Base.eltype(::LazyArray{T,N,G}) where {T,N,G} = T
3232

3333
Base.show(io::IO, a::LazyArray) = show(io, collect(a))
3434
function Base.show(io::IO, mime::MIME"text/plain", a::LazyArray)
35-
rep = repr(mime, collect(a))
36-
return print(replace(rep, "Array" => "LazyArray"; count=1))
35+
arr = collect(a)
36+
rep = repr(mime, arr)
37+
return print(replace(rep, r"(\d+-element )?((Vector|Array){(.+)?})" => s"\1LazyArray{\4}"; count=1))
3738
end

src/plot_utils.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Get string labels for for each index of a `ComponentVector`. Useful for automati
99
julia> x = ComponentArray(a=5, b=[(a=(a=20,b=1), b=0), (a=(a=33,b=1), b=0)], c=(a=(a=2, b=[1,2]), b=[1. 2.; 5 6]))
1010
ComponentVector{Float64}(a = 5.0, b = [(a = (a = 20.0, b = 1.0), b = 0.0), (a = (a = 33.0, b = 1.0), b = 0.0)], c = (a = (a = 2.0, b = [1.0, 2.0]), b = [1.0 2.0; 5.0 6.0]))
1111
12-
julia> labels(x)
13-
14-element Array{String,1}:
12+
julia> ComponentArrays.labels(x)
13+
14-element Vector{String}:
1414
"a"
1515
"b[1].a.a"
1616
"b[1].a.b"
@@ -51,7 +51,7 @@ julia> x = ComponentArray(a=5, b=[(a=(a=20,b=1), b=0), (a=(a=33,b=1), b=0)], c=(
5151
ComponentVector{Float64}(a = 5.0, b = [(a = (a = 20.0, b = 1.0), b = 0.0), (a = (a = 33.0, b = 1.0), b = 0.0)], c = (a = (a = 2.0, b = [1.0, 2.0]), b = [1.0 2.0; 5.0 6.0]))
5252
5353
julia> labels(x)
54-
14-element Array{String,1}:
54+
14-element Vector{String}:
5555
"a"
5656
"b[1].a.a"
5757
"b[1].a.b"
@@ -68,13 +68,13 @@ julia> labels(x)
6868
"c.b[2,2]"
6969
7070
julia> label2index(x, "c.a")
71-
3-element Array{Int64,1}:
71+
3-element Vector{Int64}:
7272
8
7373
9
7474
10
7575
7676
julia> label2index(x, "b[1]")
77-
3-element Array{Int64,1}:
77+
3-element Vector{Int64}:
7878
2
7979
3
8080
4

src/show.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ Base.show(io::IO, ::MIME"text/plain", ::Type{ComponentArray{T,N,A,Ax}}) where {T
2929
Base.show(io::IO, ::Type{<:ComponentArray{T,N,<:Array}}) where {T,N} = print(io, "ComponentArray{$T,$N}") # do not pollute the stacktrace with verbose type printing
3030
Base.show(io::IO, ::Type{<:ComponentArray{T,1,<:Array}}) where T = print(io, "ComponentVector{$T}")
3131
Base.show(io::IO, ::Type{<:ComponentArray{T,2,<:Array}}) where T = print(io, "ComponentMatrix{$T}")
32-
Base.show(io::IO, ::Type{<:ComponentArray{T,N,A}}) where {T,N,A} = print(io, "ComponentArray{$T,$N,$(A.name)...}")
33-
Base.show(io::IO, ::Type{<:ComponentArray{T,1,A}}) where {T,A} = print(io, "ComponentVector{$T,$(A.name)...}")
34-
Base.show(io::IO, ::Type{<:ComponentArray{T,2,A}}) where {T,A} = print(io, "ComponentMatrix{$T,$(A.name)...}")
32+
Base.show(io::IO, ::Type{<:ComponentArray{T,N,A}}) where {T,N,A} = print(io, "ComponentArray{$T,$N,$(nameof(A))...}")
33+
Base.show(io::IO, ::Type{<:ComponentArray{T,1,A}}) where {T,A} = print(io, "ComponentVector{$T,$(nameof(A))...}")
34+
Base.show(io::IO, ::Type{<:ComponentArray{T,2,A}}) where {T,A} = print(io, "ComponentMatrix{$T,$(nameof(A))...}")
3535

3636
function Base.show(io::IO, x::ComponentVector)
3737
print(io, "(")

0 commit comments

Comments
 (0)