Skip to content

Commit

Permalink
Merge pull request #55 from jishnub/showFreq
Browse files Browse the repository at this point in the history
Compact show for Frequencies
  • Loading branch information
jishnub authored Feb 5, 2024
2 parents d9f15f4 + 41f58b5 commit d743eb6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ 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 show(io::IO, f::Frequencies)
print(io, Frequencies, "(", f.n_nonnegative, ", ", f.n, ", ", f.multiplier, ")")
end

"""
fftfreq(n, fs=1)
Return the discrete Fourier transform (DFT) sample frequencies for a DFT of length `n`. The returned
Expand Down
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ end
check_extrema(freqs)
end
end

@testset "show" begin
@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

@testset "normalization" begin
Expand Down

0 comments on commit d743eb6

Please sign in to comment.