From 41f58b5f5931d8e587f87b74c59ed05407962d06 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Sat, 3 Feb 2024 17:02:52 +0530 Subject: [PATCH] Display Frequencies constructor --- src/definitions.jl | 9 ++------- test/runtests.jl | 17 ++++------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/definitions.jl b/src/definitions.jl index f10beed..948c582 100644 --- a/src/definitions.jl +++ b/src/definitions.jl @@ -462,13 +462,8 @@ Base.maximum(f::Frequencies{T}) where T = (f.n_nonnegative - ifelse(f.multiplier Base.minimum(f::Frequencies{T}) where T = (f.n_nonnegative - ifelse(f.multiplier >= zero(T), f.n, 1)) * f.multiplier Base.extrema(f::Frequencies) = (minimum(f), maximum(f)) -function Base.show(io::IO, f::Frequencies) - r1 = 0:f.n_nonnegative-1 - r2 = -f.n + f.n_nonnegative:-1 - print(io, "[", r1, ";") - !isempty(r2) && print(io, " ", r2) - print(io, "]*", step(f)) - return nothing +function show(io::IO, f::Frequencies) + print(io, Frequencies, "(", f.n_nonnegative, ", ", f.n, ", ", f.multiplier, ")") end """ diff --git a/test/runtests.jl b/test/runtests.jl index 16f8408..2c86b08 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -110,19 +110,10 @@ end end @testset "show" begin - for f in Any[fftfreq(6), fftfreq(7, 2), rfftfreq(5, 0.3), rfftfreq(4, 3)] - fnn = f.n_nonnegative - r1 = 0:fnn - 1 - r2 = -length(f) + fnn:-1 - v = [r1; r2] * step(f) - @test v ≈ f - s = repr(f) - if !isempty(r2) # fftfreq - @test s == "[$r1; $r2]*$(step(f))" - else # rfftfreq - @test s == "[$r1;]*$(step(f))" - end - end + @test repr(fftfreq(6)) == "Frequencies(3, 6, $(1/6))" + @test repr(fftfreq(7, 2)) == "Frequencies(4, 7, $(2/7))" + @test repr(rfftfreq(5, 0.3)) == "Frequencies(3, 3, $(0.3/5))" + @test repr(rfftfreq(4, 3)) == "Frequencies(3, 3, $(3/4))" end end