Skip to content

Commit 3452711

Browse files
committed
move Algorithm to file and add show
1 parent 113c1d7 commit 3452711

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/MPSKit.jl

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,7 @@ export exact_diagonalization
6363
export TransferMatrix
6464
export transfer_left, transfer_right
6565

66-
# Abstract type defs
67-
"""
68-
$(TYPEDEF)
69-
70-
Abstract supertype for all algorithm structs.
71-
These can be thought of as `NamedTuple`s that hold the settings for a given algorithm,
72-
which can be used for dispatch.
73-
Additionally, the constructors can be used to provide default values and input sanitation.
74-
"""
75-
abstract type Algorithm end
66+
include("algorithms/algorithm.jl")
7667

7768
# submodules
7869
include("utility/dynamictols.jl")

src/algorithms/algorithm.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
$(TYPEDEF)
3+
4+
Abstract supertype for all algorithm structs.
5+
These can be thought of as `NamedTuple`s that hold the settings for a given algorithm,
6+
which can be used for dispatch.
7+
Additionally, the constructors can be used to provide default values and input sanitation.
8+
"""
9+
abstract type Algorithm end
10+
11+
function Base.show(io::IO, ::MIME"text/plain", alg::Algorithm)
12+
if get(io, :compact, false)
13+
println(io, "$typeof(alg)(...)")
14+
return nothing
15+
end
16+
println(io, typeof(alg), ":")
17+
iocompact = IOContext(io, :compact => true)
18+
for f in propertynames(alg)
19+
println(io, " * ", f, ": ", getproperty(alg, f))
20+
end
21+
return nothing
22+
end

0 commit comments

Comments
 (0)