Skip to content

Commit 70ac170

Browse files
vickydekaeliascarv
andauthored
fixed AssertionError (#160)
* fixed AssertionError * fixed * few changes * fixed * added test * added test * Update test/transforms/zscore.jl Co-authored-by: Elias Carvalho <[email protected]> Co-authored-by: Elias Carvalho <[email protected]>
1 parent 976ce71 commit 70ac170

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/transforms.jl

+7-6
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,17 @@ reapply(transform::StatelessFeatureTransform, table, cache) =
170170
# ------------------
171171

172172
function applyfeat(transform::ColwiseFeatureTransform, feat, prep)
173-
# basic checks
174-
for assertion in assertions(transform)
175-
assertion(feat)
176-
end
177-
178173
# retrieve column names and values
179174
cols = Tables.columns(feat)
180175
names = Tables.columnnames(cols)
181176
snames = choose(transform.colspec, names)
177+
sfeat = feat |> Select(snames)
182178

179+
# basic checks
180+
for assertion in assertions(transform)
181+
assertion(sfeat)
182+
end
183+
183184
# function to transform a single column
184185
function colfunc(n)
185186
x = Tables.getcolumn(cols, n)
@@ -288,4 +289,4 @@ include("transforms/eigenanalysis.jl")
288289
include("transforms/projectionpursuit.jl")
289290
include("transforms/rowtable.jl")
290291
include("transforms/coltable.jl")
291-
include("transforms/parallel.jl")
292+
include("transforms/parallel.jl")

test/transforms/zscore.jl

+10
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,14 @@
8686
@test isapprox(σ[2], 1; atol=1e-6)
8787
tₒ = revert(T, n, c)
8888
@test Tables.matrix(t) Tables.matrix(tₒ)
89+
90+
a = rand(Int, 10)
91+
b = rand(10)
92+
t = Table(; a, b)
93+
T = ZScore(:b)
94+
n, c = apply(T, t)
95+
@test isapprox(mean(n.b), 0; atol=1e-6)
96+
@test isapprox(std(n.b), 1; atol=1e-6)
97+
tₒ = revert(T, n, c)
98+
@test Tables.matrix(t) Tables.matrix(tₒ)
8999
end

0 commit comments

Comments
 (0)