Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation fix, unit test temporary fix #57

Merged
merged 5 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ on:
- test/**
- Project.toml
pull_request:
branches:
- master
paths:
- src/**
- test/**
Expand Down
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ Extension). It contains additional functionalities that complement Wavelets.jl,
## Authors
This package is written and maintained by Zeng Fung Liew and Shozen Dan under the supervision of Professor Naoki Saito at the University of California, Davis.

## What's New (v0.1.13)
- **Changes in supported types in `denoise` and `denoiseall` functions.** For the `inputtype` positional argument, the initially supported arguments `:acwt` and `:acwpt` are now changed to `:acdwt` and `:acwpd` to match the function name change in `WaveletsExt.ACWT`.
- **2D Local Discriminant Basis now supported.** 2D version of LDB is now up and running without any changes in the syntax compared to the 1D version.

## What's New (v0.1.12)
- **Bug fixes on best basis algorithms** to allow compatibility when partial wavelet decomposition is run.
- **New function `plot_tfbdry2()` implemented.** Visual representation of leaf nodes for 2D best basis trees now available.

## Installation
The package is part of the official Julia Registry. It can be install via the Julia REPL.
```julia
Expand Down Expand Up @@ -85,5 +77,4 @@ Using the Multiscale Basis Dictionaries*. DOI: [10.1109/TSIPN.2016.2632039](http


## TODO(long term):
* Inverse Transforms for Shift-Invariant WPT
* nD wavelet transforms for redundant and non-redundant versions
2 changes: 2 additions & 0 deletions docs/src/api/siwt.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Modules = [SIWT]
## Data Structures
```@docs
SIWT.ShiftInvariantWaveletTransformNode
SIWT.ShiftInvariantWaveletTransformNode(::Array{T},::S,::S,::S,::T) where {T<:AbstractFloat, S<:Integer}
SIWT.ShiftInvariantWaveletTransformObject
SIWT.ShiftInvariantWaveletTransformObject(::Array{T}, ::OrthoFilter,::S,::S) where {T<:AbstractFloat, S<:Integer}
```

## Signal Transform and Reconstruction
Expand Down
5 changes: 3 additions & 2 deletions docs/src/manual/bestbasis.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@ plot(p1, p2, p3, p4, p5, p6, layout=(3,2))
## [Best Basis of Shift-Invariant Wavelet Packet Decomposition](@id si_bestbasis)
One can think of searching for the best basis of the shift-invariant wavelet packet decomposition as a problem of finding ``\min_{b \in B} \sum_{x \in X} M_x(b)``, where ``X`` is all the possible shifted versions of an original signal ``y``. One can compute the best basis tree as follows:
```@repl
using Wavelets, WaveletsExt;
x = [2,3,-4,5.0];
wt = wavelet(WT.haar);
xwObj = siwpd(x, wt, 1, 1);
xwObj.BestTree # Original tree (all decomposed nodes)

bestbasistree!(xwObj)
bestbasistree!(xwObj);
xwObj.BestTree # Best basis tree

x̂ = isiwpd(xwObj) # Reconstruction of signal
x̂ = isiwpd(xwObj); # Reconstruction of signal
x̂ == x
```
1 change: 1 addition & 0 deletions docs/src/manual/transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ The [Shift-Invariant Wavelet Decomposition (SIWPD)](https://israelcohen.com/wp-c

One can compute the SIWPD of a single signal as follows.
```@repl
using Wavelets, WaveletsExt
x = [2,3,-4,5.0];
wt = wavelet(WT.haar);
xwObj = siwpd(x, wt, 1, 1);
Expand Down
6 changes: 2 additions & 4 deletions src/mod/Visualizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,9 @@ function wiggle!(plt::Plots.Plot,
# generate the desired plots as of O3/19/2018. Somehow, the relative value of 0,
# i.e., fillrange=0, works well, which is used temporarily.
if Orient == :down
plot!(plt, inputy, inputx, fillrange=0, fillalpha=0.75,
fillcolor=FaceColor, linecolor=EdgeColor, orientation=:v)
plot!(plt, inputy, inputx, fillrange=0, fillalpha=0.75, fillcolor=FaceColor, linecolor=EdgeColor, orientation=:v)
else
plot!(plt, inputx, inputy, fillrange=0, fillalpha=0.75,
fillcolor=FaceColor, linecolor=EdgeColor)
plot!(plt, inputx, inputy, fillrange=0, fillalpha=0.75, fillcolor=FaceColor, linecolor=EdgeColor)
end
end
return plt
Expand Down
90 changes: 48 additions & 42 deletions test/visualizations.jl
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
tree = BitVector([1,1,1])
@test Visualizations.treenodes_matrix(tree) == BitArray([1 1; 1 1])
# plot_tfbdry() test
p = plot()
@test isa(plot_tfbdry(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry(p, tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry!(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry!(p, tree), Plots.Plot{Plots.GRBackend})
@test_nowarn plot_tfbdry(tree, start=1)
@test_throws AssertionError plot_tfbdry(tree, start=2)
@test_nowarn plot_tfbdry(tree, node_color=:red, background_color=:white, line_color=:black)
# plot_tfbdry2() test
tree = maketree(4,4,2,:dwt)
p = plot()
@test isa(plot_tfbdry2(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry2(p, tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry2!(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry2!(p, tree), Plots.Plot{Plots.GRBackend})
@test_nowarn plot_tfbdry2(tree)
@test_nowarn plot_tfbdry2(tree, 4)
@test_nowarn plot_tfbdry2(tree, 4, 8)
@test_throws AssertionError plot_tfbdry2(tree, 3, 8)
@test_throws AssertionError plot_tfbdry2(tree, 4, 3)
@test_throws AssertionError plot_tfbdry2(tree, 6, 6)
x = randn(16,5)
# wiggle() test
@test typeof(wiggle(x)) == Plots.Plot{Plots.GRBackend}
p = plot()
@test typeof(wiggle(p, x)) == Plots.Plot{Plots.GRBackend}
# wiggle!() test
@test typeof(wiggle!(x)) == Plots.Plot{Plots.GRBackend}
@test typeof(wiggle!(p, x)) == Plots.Plot{Plots.GRBackend}
@test_throws ErrorException("Inconsistent taxis dimension!") wiggle!(p, x, taxis=1:5)
@test_throws ErrorException("Inconsistent zaxis dimension!") wiggle!(p, x, zaxis=1:4)
@test_nowarn wiggle!(p, x, sc=0.3)
@test_nowarn wiggle!(p, x, EdgeColor=:red)
@test_nowarn wiggle!(p, x, FaceColor=:red)
@test_nowarn wiggle!(p, x, Overlap=false)
@test_nowarn wiggle!(p, x, Orient=:down)
@test_throws AssertionError wiggle!(p, x, Orient=:fail)
@test_nowarn wiggle!(p, x, ZDir=:reverse)
@test_throws AssertionError wiggle!(p, x, ZDir=:fail)
@testset "plot_tfbdry" begin
tree = BitVector([1,1,1])
@test Visualizations.treenodes_matrix(tree) == BitArray([1 1; 1 1])
p = plot()
@test isa(plot_tfbdry(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry(p, tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry!(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry!(p, tree), Plots.Plot{Plots.GRBackend})
@test_nowarn plot_tfbdry(tree, start=1)
@test_throws AssertionError plot_tfbdry(tree, start=2)
@test_nowarn plot_tfbdry(tree, node_color=:red, background_color=:white, line_color=:black)
end

@testset "plot_tfbdry2" begin
tree = maketree(4,4,2,:dwt)
p = plot()
@test isa(plot_tfbdry2(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry2(p, tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry2!(tree), Plots.Plot{Plots.GRBackend})
@test isa(plot_tfbdry2!(p, tree), Plots.Plot{Plots.GRBackend})
@test_nowarn plot_tfbdry2(tree)
@test_nowarn plot_tfbdry2(tree, 4)
@test_nowarn plot_tfbdry2(tree, 4, 8)
@test_throws AssertionError plot_tfbdry2(tree, 3, 8)
@test_throws AssertionError plot_tfbdry2(tree, 4, 3)
@test_throws AssertionError plot_tfbdry2(tree, 6, 6)
end

@testset "wiggle" begin
x = randn(16,5)
# wiggle() test
@test typeof(wiggle(x)) == Plots.Plot{Plots.GRBackend}
p = plot()
@test typeof(wiggle(p, x)) == Plots.Plot{Plots.GRBackend}
# wiggle!() test
@test typeof(wiggle!(x)) == Plots.Plot{Plots.GRBackend}
@test typeof(wiggle!(p, x)) == Plots.Plot{Plots.GRBackend}
@test_throws ErrorException("Inconsistent taxis dimension!") wiggle!(p, x, taxis=1:5)
@test_throws ErrorException("Inconsistent zaxis dimension!") wiggle!(p, x, zaxis=1:4)
@test_nowarn wiggle!(p, x, sc=0.3)
@test_nowarn wiggle!(p, x, EdgeColor=:red)
@test_nowarn wiggle!(p, x, FaceColor=:red)
@test_nowarn wiggle!(p, x, Overlap=false)
@test isa(wiggle!(p, x, Orient=:down), Plots.Plot{Plots.GRBackend}) # TODO: Keyword plot(orientation) deprecated. Figure out long term solution to this.
@test_throws AssertionError wiggle!(p, x, Orient=:fail)
@test_nowarn wiggle!(p, x, ZDir=:reverse)
@test_throws AssertionError wiggle!(p, x, ZDir=:fail)
end