Skip to content

Commit a96837f

Browse files
committed
add ascii interface
1 parent 3af1ecc commit a96837f

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/diskmargin.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ function Diskmargin(α, σ=0; ω0=mising, f0=missing, δ0=missing, L=nothing)
3535
Diskmargin(α, ω0, f0, δ0, γmin, γmax, σ, ϕm, L)
3636
end
3737

38+
39+
function Base.getproperty(dm::Diskmargin, s::Symbol)
40+
s fieldnames(typeof(dm)) && return getfield(dm, s)
41+
if s (:margin, :alpha, :diskmargin)
42+
return dm.α
43+
elseif s (:gm, :gainmargin)
44+
return [dm.γmin, dm.γmax]
45+
elseif s === :phasemargin
46+
return dm.ϕm
47+
else
48+
throw(ArgumentError("$(typeof(dm)) has no property named $s"))
49+
end
50+
end
51+
52+
Base.propertynames(dm::Diskmargin) = (fieldnames(typeof(dm))..., :margin, :gainmargin, :phasemargin)
53+
54+
3855
function Base.show(io::IO, dm::Diskmargin)
3956
println(io, "Disk margin with:")
4057
println(io, "Margin: ", dm.α)

test/test_diskmargin.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ nyquistplot(L)
1515
plot!(dm, nyquist=true)
1616
plot!(Disk(dm), nyquist=true)
1717

18+
@test dm.alpha == dm.α
19+
@test length(dm.gainmargin) == 2
20+
@test dm.phasemargin == dm.ϕm
21+
@test :gainmargin propertynames(dm)
1822

1923

2024

@@ -163,9 +167,9 @@ end
163167

164168

165169
unsafe_comparisons(true)
166-
dm = diskmargin(L3, 0, 4.05)
167-
168-
170+
dm = loop_diskmargin(L3, 0, 4.05)
171+
@test dm[1].α isa Particles
172+
@test pmean(dm[1].α) 0.794418036911981 rtol=0.01
169173

170174

171175
L3 = let

0 commit comments

Comments
 (0)