Skip to content

Commit 71f85b6

Browse files
authored
Make showing cached bases more robust (#161)
1 parent de79731 commit 71f85b6

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ManifoldsBase"
22
uuid = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb"
33
authors = ["Seth Axen <[email protected]>", "Mateusz Baran <[email protected]>", "Ronny Bergmann <[email protected]>", "Antoine Levitt <[email protected]>"]
4-
version = "0.14.7"
4+
version = "0.14.8"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/bases.jl

+17-12
Original file line numberDiff line numberDiff line change
@@ -1010,18 +1010,23 @@ function show(
10101010
::MIME"text/plain",
10111011
B::CachedBasis{𝔽,T,D},
10121012
) where {𝔽,T<:AbstractBasis,D}
1013-
vectors = _get_vectors(B)
1014-
print(
1015-
io,
1016-
"Cached basis of type $T with $(length(vectors)) basis vector$(length(vectors) == 1 ? "" : "s"):",
1017-
)
1018-
return _show_basis_vector_range_noheader(
1019-
io,
1020-
vectors;
1021-
max_vectors = 4,
1022-
pre = " ",
1023-
sym = " E",
1024-
)
1013+
try
1014+
vectors = _get_vectors(B)
1015+
print(
1016+
io,
1017+
"Cached basis of type $T with $(length(vectors)) basis vector$(length(vectors) == 1 ? "" : "s"):",
1018+
)
1019+
return _show_basis_vector_range_noheader(
1020+
io,
1021+
vectors;
1022+
max_vectors = 4,
1023+
pre = " ",
1024+
sym = " E",
1025+
)
1026+
catch e
1027+
# in case _get_vectors(B) is not defined
1028+
print(io, "Cached basis of type $T")
1029+
end
10251030
end
10261031
function show(
10271032
io::IO,

test/bases.jl

+6
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ DiagonalizingBasisProxy() = DiagonalizingOrthonormalBasis([1.0, 0.0, 0.0])
255255

256256
M = DefaultManifold(3)
257257

258+
@test sprint(
259+
show,
260+
"text/plain",
261+
CachedBasis(NonBasis(), NonBroadcastBasisThing([])),
262+
) == "Cached basis of type NonBasis"
263+
258264
@testset "Constructors" begin
259265
@test DefaultBasis{ℂ,TangentSpaceType}() === DefaultBasis(ℂ)
260266
@test DefaultOrthogonalBasis{ℂ,TangentSpaceType}() === DefaultOrthogonalBasis(ℂ)

0 commit comments

Comments
 (0)