Skip to content

Commit a2f2d56

Browse files
committed
add tests for _replace
1 parent 4a6cb16 commit a2f2d56

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

test/runtests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import MultivariateStats
21
import Dates
2+
import MLJMultivariateStatsInterface: _replace!
3+
import MultivariateStats
34
import Random
45

56
using LinearAlgebra

test/utils.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
@testset "replace!" begin
2+
y = [1, 2, 2, 2, 3]
3+
z1 = 1:5
4+
z2 = 0:3
5+
r1 = -2:2
6+
r2 = 2:5
7+
@test_throws DimensionMismatch _replace!(y, z1, r2)
8+
@test_throws DimensionMismatch _replace!(y, z2, r1)
9+
@test _replace!(deepcopy(y), z1, r1) == Base.replace!(deepcopy(y), (z1 .=> r1)...)
10+
@test _replace!(deepcopy(y), z2, r2) == Base.replace!(deepcopy(y), (z2 .=> r2)...)
11+
end
12+
113
@testset "softmax" begin
214
X = rand(100,5)
315
max_ = maximum(X, dims=2)

0 commit comments

Comments
 (0)