-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathstack_test.v
More file actions
102 lines (89 loc) · 2.5 KB
/
stack_test.v
File metadata and controls
102 lines (89 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
module vtl
fn test_concatenate_flat() {
a := ones[f64]([3])
b := zeros[f64]([2])
result := concatenate[f64]([a, b], axis: 0)!
expected := from_1d[f64]([1.0, 1, 1, 0, 0])!
assert result.array_equal(expected)
}
fn test_concatenate() {
a := ones[f64]([2, 2])
b := zeros[f64]([2, 2])
result := concatenate[f64]([a, b], axis: 0)!
expected := from_array([1.0, 1, 1, 1, 0, 0, 0, 0], [4, 2])!
assert result.array_equal(expected)
}
fn test_vstack() {
a := ones[f64]([3])
b := zeros[f64]([2])
result := vstack[f64]([a, b])!
expected := from_1d[f64]([1.0, 1, 1, 0, 0])!
assert result.array_equal(expected)
}
fn test_hstack_flat() {
a := ones[f64]([3])
b := zeros[f64]([2])
result := hstack[f64]([a, b])!
expected := from_1d[f64]([1.0, 1, 1, 0, 0])!
assert result.array_equal(expected)
}
fn test_hstack() {
a := ones[f64]([2, 2])
b := zeros[f64]([2, 2])
result := hstack[f64]([a, b])!
expected := from_array([1.0, 1, 0, 0, 1, 1, 0, 0], [2, 4])!
assert result.array_equal(expected)
}
fn test_dstack_flat() {
a := ones[f64]([3])
b := zeros[f64]([3])
result := dstack[f64]([a, b])!
expected := from_array([1.0, 0, 1, 0, 1, 0], [1, 3, 2])!
assert result.array_equal(expected)
}
fn test_dstack() {
a := ones[f64]([2, 2])
b := zeros[f64]([2, 2])
result := dstack[f64]([a, b])!
expected := from_array([1.0, 0, 1, 0, 1, 0, 1, 0], [2, 2, 2])!
assert result.array_equal(expected)
}
fn test_column_stack_flat() {
a := ones[f64]([2])
b := zeros[f64]([2])
result := column_stack[f64]([a, b])!
expected := from_array([1.0, 0, 1, 0], [2, 2])!
assert result.array_equal(expected)
}
fn test_column_stack_2d() {
a := ones[f64]([2, 2])
b := zeros[f64]([2, 2])
result := column_stack[f64]([a, b])!
expected := from_array([1.0, 1, 0, 0, 1, 1, 0, 0], [2, 4])!
assert result.array_equal(expected)
}
fn test_stack() {
a := ones[f64]([2, 2])
b := zeros[f64]([2, 2])
result := stack[f64]([a, b], axis: 1)!
expected := from_array([1.0, 1, 0, 0, 1, 1, 0, 0], [2, 2, 2])!
assert result.array_equal(expected)
}
fn test_unsqueeze_1() {
a := ones[f64]([2, 2])
result := a.unsqueeze[f64](axis: 1)!
expected := from_array([1.0, 1, 1, 1], [2, 1, 2])!
assert result.array_equal(expected)
}
fn test_unsqueeze_2() {
a := ones[f64]([2, 2])
result := a.unsqueeze[f64](axis: 0)!
expected := from_array([1.0, 1, 1, 1], [1, 2, 2])!
assert result.array_equal(expected)
}
fn test_expand_dims() {
a := ones[f64]([2, 2])
result := a.expand_dims[f64](axis: 1)!
expected := from_array([1.0, 1, 1, 1], [2, 1, 2])!
assert result.array_equal(expected)
}