Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make showing cached bases more robust #161

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ManifoldsBase"
uuid = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb"
authors = ["Seth Axen <seth.axen@gmail.com>", "Mateusz Baran <mateuszbaran89@gmail.com>", "Ronny Bergmann <manopt@ronnybergmann.net>", "Antoine Levitt <antoine.levitt@gmail.com>"]
version = "0.14.7"
version = "0.14.8"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
29 changes: 17 additions & 12 deletions src/bases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1010,18 +1010,23 @@ function show(
::MIME"text/plain",
B::CachedBasis{𝔽,T,D},
) where {𝔽,T<:AbstractBasis,D}
vectors = _get_vectors(B)
print(
io,
"Cached basis of type $T with $(length(vectors)) basis vector$(length(vectors) == 1 ? "" : "s"):",
)
return _show_basis_vector_range_noheader(
io,
vectors;
max_vectors = 4,
pre = " ",
sym = " E",
)
try
vectors = _get_vectors(B)
print(
io,
"Cached basis of type $T with $(length(vectors)) basis vector$(length(vectors) == 1 ? "" : "s"):",
)
return _show_basis_vector_range_noheader(
io,
vectors;
max_vectors = 4,
pre = " ",
sym = " E",
)
catch e
# in case _get_vectors(B) is not defined
print(io, "Cached basis of type $T")
end
end
function show(
io::IO,
Expand Down
6 changes: 6 additions & 0 deletions test/bases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ DiagonalizingBasisProxy() = DiagonalizingOrthonormalBasis([1.0, 0.0, 0.0])

M = DefaultManifold(3)

@test sprint(
show,
"text/plain",
CachedBasis(NonBasis(), NonBroadcastBasisThing([])),
) == "Cached basis of type NonBasis"

@testset "Constructors" begin
@test DefaultBasis{ℂ,TangentSpaceType}() === DefaultBasis(ℂ)
@test DefaultOrthogonalBasis{ℂ,TangentSpaceType}() === DefaultOrthogonalBasis(ℂ)
Expand Down