-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathtest_exp.py
32 lines (22 loc) · 898 Bytes
/
test_exp.py
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
"""Testing exponentiantion methods for PWC propagation"""
import tensorflow as tf
import pytest
from numpy.testing import assert_array_almost_equal as almost_equal
from c3.libraries.propagation import tf_expm, tf_expm_dynamic
@pytest.mark.unit
def test_tf_expm(get_exp_problem) -> None:
"""Testing tf_expm with fixed number of terms"""
rot, res = get_exp_problem
terms = 100
almost_equal(tf_expm(1j * rot, terms), res)
@pytest.mark.unit
@pytest.mark.skip(reason="experimental: to be tested")
def test_expm_dynamic(get_exp_problem) -> None:
"""Testing dynamically adjusted exp method"""
rot, res = get_exp_problem
almost_equal(tf_expm_dynamic(1j * rot), res)
@pytest.mark.unit
def test_tf_exponentiation(get_exp_problem) -> None:
"""Testing with the TF exponentiation method"""
rot, res = get_exp_problem
almost_equal(tf.linalg.expm(1j * rot), res)