unittest
python
test_tensor.py
Go to the documentation of this file.
1
import
numpy
as
np
2
import
tensor
3
4
dim = np.array([10, 20, 30], dtype=np.int64)
5
t = tensor.TensorContainer3(dim)
6
r = t.get_ref()
7
r[:] = 0.0
8
c = t.get_copy()
9
r2 = tensor.ref(r)
10
cr = tensor.const_ref(r)
11
c2 = tensor.copy(cr)
12
13
assert
np.all(c == r)
14
assert
np.all(r2 == r)
15
assert
np.all(cr == r)
16
assert
np.all(c2 == r)
17
18
tensor.print_base(cr)
19
tensor.print_ref(cr)
20
tensor.print(cr)
21
22
r2[:] = 100.0
23
assert
not
np.all(c == r)
24
assert
not
np.all(c2 == r)
25
assert
np.all(r2 == r)
26
assert
np.all(cr == r)
27
28
tensor.print_base(cr)
29
tensor.print_ref(cr)
30
tensor.print(cr)
eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Sat Nov 2 2024 02:14:45