Skip to content

Commit 03e3eef

Browse files
authored
Merge pull request #240 from JuliaStats/an/show
Fix show method for PCA
2 parents e80818c + de41405 commit 03e3eef

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,17 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
version:
17-
- '1.1'
18-
- '1.6' # current LTS release
19-
- '1' # automatically expands to the latest stable 1.x release of Julia
20-
# - 'nightly'
17+
- 'min'
18+
- 'lts'
19+
- '1'
20+
- 'pre'
2121
os:
2222
- ubuntu-latest
2323
# - macOS-latest
2424
# - windows-latest
2525
arch:
2626
- x64
2727
allow-to-fail: [false]
28-
include:
29-
- version: 'nightly'
30-
os: ubuntu-latest
31-
arch: x64
32-
allow-to-fail: true
3328
steps:
3429
- uses: actions/checkout@v6
3530
- uses: julia-actions/setup-julia@v2

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ keywords = ["multivariate statistics", "dimensionality reduction"]
44
license = "MIT"
55
desc = "A Julia package for multivariate statistics and data analysis"
66
repository = "https://github.com/JuliaStats/MultivariateStats.jl.git"
7-
version = "0.10.3"
7+
version = "0.11.0"
88

99
[deps]
1010
Arpack = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
@@ -22,7 +22,7 @@ StableRNGs = "1"
2222
Statistics = "1"
2323
StatsAPI = "^1.3"
2424
StatsBase = "^0.33, 0.34"
25-
julia = "1.1"
25+
julia = "1.6"
2626

2727
[extras]
2828
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"

src/pca.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function show(io::IO, ::MIME"text/plain", M::PCA)
153153
ldgs = ldgs * diagm(0 => ldgs_signs[:])
154154
print(io, "\n\nPattern matrix (unstandardized loadings):\n")
155155
cft = CoefTable(ldgs, string.("PC", 1:odim), string.("", 1:idim))
156-
print(io, cft)
156+
show(io, MIME"text/plain"(), cft)
157157
print(io, "\n\n")
158158
print(io, "Importance of components:\n")
159159
λ = eigvals(M)
@@ -164,7 +164,7 @@ function show(io::IO, ::MIME"text/plain", M::PCA)
164164
"Proportion explained", "Cumulative proportion"]
165165
cft = CoefTable(vcat', prp', cumsum(prp)', prpv', cumsum(prpv)'),
166166
string.("PC", 1:odim), names)
167-
print(io, cft)
167+
show(io, MIME"text/plain"(), cft)
168168
end
169169

170170
#### PCA Training

test/pca.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,30 @@ import SparseArrays
4343
@test reconstruct(M, Y[:,1]) P * Y[:,1]
4444
@test reconstruct(M, Y) P * Y
4545

46+
@test repr("text/plain", M) == """
47+
PCA(indim = 5, outdim = 3, principalratio = 0.8)
48+
49+
Pattern matrix (unstandardized loadings):
50+
─────────────────────────────────
51+
PC1 PC2 PC3
52+
─────────────────────────────────
53+
1 -0.236399 0.706558 1.21106
54+
2 1.27426 0.047799 0.212282
55+
3 0.990598 -1.22718 0.882179
56+
4 -1.51861 -0.725771 0.631665
57+
5 0.181386 1.21069 0.557706
58+
─────────────────────────────────
59+
60+
Importance of components:
61+
───────────────────────────────────────────────────
62+
PC1 PC2 PC3
63+
───────────────────────────────────────────────────
64+
SS Loadings (Eigenvalues) 5.0 4.0 3.0
65+
Variance explained 0.333333 0.266667 0.2
66+
Cumulative variance 0.333333 0.6 0.8
67+
Proportion explained 0.416667 0.333333 0.25
68+
Cumulative proportion 0.416667 0.75 1.0
69+
───────────────────────────────────────────────────"""
4670

4771
## PCA with non-zero mean
4872

0 commit comments

Comments
 (0)