Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c8744f6

Browse filesBrowse files
Merge pull request #87 from SylvainCorlay/simplify-wrap-modules
Simplify wrapmodules
2 parents 72c6f6b + 9846c52 commit c8744f6
Copy full SHA for c8744f6

File tree

Expand file treeCollapse file tree

2 files changed

+58
-61
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+58
-61
lines changed

‎test/runtests.jl

Copy file name to clipboardExpand all lines: test/runtests.jl
+58-1Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,61 @@
66
# The full license is in the file LICENSE, distributed with this software. #
77
############################################################################
88

9-
include("tensors.jl")
9+
using Test
10+
11+
module TensorFunctions
12+
using CxxWrap
13+
using Xtensor
14+
@wrapmodule Xtensor._l_tensors
15+
end
16+
17+
# Test example functions from the TensorFunctions module
18+
19+
# example1
20+
arr = [[1.0 2.0]
21+
[3.0 4.0]]
22+
@test TensorFunctions.test_access(arr) == 4.0
23+
@test TensorFunctions.example1([4., 5., 6.]) == 4.0
24+
25+
# example2
26+
x = [[0. 1.]
27+
[2. 3.]]
28+
res = [[2. 3.]
29+
[4. 5.]]
30+
y = TensorFunctions.example2(x)
31+
@test y res atol=1e-12
32+
33+
# vectorize_example1
34+
x1 = [[0 1]
35+
[2 3]]
36+
x2 = [0, 1]
37+
res = [[0 2]
38+
[2 4]]
39+
y = TensorFunctions.vectorize_example1(x1, x2)
40+
@test y == res
41+
42+
# readme_example1
43+
v = [[0.0 3.0 6.0 9.0 12.0]
44+
[1.0 4.0 7.0 10.0 13.0]
45+
[2.0 5.0 8.0 11.0 14.0]]
46+
47+
y = TensorFunctions.readme_example1(v)
48+
@test y 1.2853996391883833 atol=1e-12
49+
50+
# readme_example2
51+
x = [[ 0.0 1.0 2.0 3.0 4.0]
52+
[ 5.0 6.0 7.0 8.0 9.0]
53+
[10.0 11.0 12.0 13.0 14.0]]
54+
y = [1.0, 2.0, 3.0, 4.0, 5.0]
55+
z = TensorFunctions.readme_example2(x, y)
56+
expected = [[-0.540302 1.257618 1.89929 0.794764 -1.040465]
57+
[-1.499227 0.136731 1.646979 1.643002 0.128456]
58+
[-1.084323 -0.583843 0.45342 1.073811 0.706945]]
59+
@test z expected atol=1e-5
60+
61+
# compare_shapes
62+
x = ones(4, 4)
63+
y = ones(5, 5)
64+
z = zeros(4, 4)
65+
@assert !TensorFunctions.compare_shapes(x, y)
66+
@assert TensorFunctions.compare_shapes(x, z)

‎test/tensors.jl

Copy file name to clipboardExpand all lines: test/tensors.jl
-60Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.