Skip to content

Commit

Permalink
Display Frequencies constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Feb 3, 2024
1 parent f1562d5 commit 41f58b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
9 changes: 2 additions & 7 deletions src/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down
17 changes: 4 additions & 13 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 41f58b5

Please sign in to comment.