Skip to content

Commit 9c66242

Browse files
authored
Update compat for MultivariateStats (#487)
* Remove dead code * Use new predict instead of deprecated transform * Bump compat * Increment version number * Add MDS test
1 parent 7c5f41f commit 9c66242

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "StatsPlots"
22
uuid = "f3b207a7-027a-5e70-b257-86293d7955fd"
3-
version = "0.14.32"
3+
version = "0.14.33"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
@@ -30,7 +30,7 @@ DataValues = "0.4"
3030
Distributions = "0.21, 0.22, 0.23, 0.24, 0.25"
3131
Interpolations = "0.12, 0.13"
3232
KernelDensity = "0.5, 0.6"
33-
MultivariateStats = "0.7, 0.8"
33+
MultivariateStats = "0.9"
3434
Observables = "0.2.2, 0.3, 0.4"
3535
Plots = "0.28, 0.29, 1.0"
3636
RecipesBase = "0.6, 0.7, 0.8, 1"

src/StatsPlots.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import Widgets: @nodeps
1818
import DataStructures: OrderedDict
1919
import Clustering: Hclust, nnodes
2020
using Interpolations
21-
import MultivariateStats: MDS, eigvals, projection, principalvars,
22-
principalratio, transform
21+
using MultivariateStats: MultivariateStats
2322
using AbstractFFTs: fft, ifft
2423
import KernelDensity
2524
@recipe f(k::KernelDensity.UnivariateKDE) = k.x, k.density

src/ordinations.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
@recipe function f(mds::MDS{<:Real}; mds_axes=(1,2))
1+
@recipe function f(mds::MultivariateStats.MDS{<:Real}; mds_axes=(1,2))
22
length(mds_axes) in [2,3] || throw(ArgumentError("Can only accept 2 or 3 mds axes"))
33
xax = mds_axes[1]
44
yax = mds_axes[2]
5-
ev = eigvals(mds)
6-
var_explained = [v / sum(ev) for v in ev]
7-
tfm = collect(transform(mds)')
5+
tfm = collect(MultivariateStats.predict(mds)')
86

97
xlabel --> "MDS$xax"
108
ylabel --> "MDS$yax"

test/runtests.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ using StableRNGs
44
using NaNMath
55
using Clustering
66
using Distributions
7+
using MultivariateStats
78

89
@testset "Grouped histogram" begin
910
rng = StableRNG(1337)
@@ -103,3 +104,25 @@ end
103104
end
104105
end
105106
end
107+
108+
@testset "ordinations" begin
109+
@testset "MDS" begin
110+
X = randn(4, 100)
111+
M = fit(MultivariateStats.MDS, X; maxoutdim=3, distances=false)
112+
Y = MultivariateStats.predict(M)'
113+
114+
mds_plt = plot(M)
115+
@test mds_plt[1][1][:x] == Y[:,1]
116+
@test mds_plt[1][1][:y] == Y[:,2]
117+
@test mds_plt[1][:xaxis][:guide] == "MDS1"
118+
@test mds_plt[1][:yaxis][:guide] == "MDS2"
119+
120+
mds_plt2 = plot(M; mds_axes=(3,1,2))
121+
@test mds_plt2[1][1][:x] == Y[:,3]
122+
@test mds_plt2[1][1][:y] == Y[:,1]
123+
@test mds_plt2[1][1][:z] == Y[:,2]
124+
@test mds_plt2[1][:xaxis][:guide] == "MDS3"
125+
@test mds_plt2[1][:yaxis][:guide] == "MDS1"
126+
@test mds_plt2[1][:zaxis][:guide] == "MDS2"
127+
end
128+
end

0 commit comments

Comments
 (0)