forked from diffpy/diffpy.fourigui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_functions.py
More file actions
40 lines (33 loc) · 1.03 KB
/
test_functions.py
File metadata and controls
40 lines (33 loc) · 1.03 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
import numpy as np
import pytest
from diffpy.fourigui import functions # noqa
def test_dot_product_2D_list():
a = [1, 2]
b = [3, 4]
expected = 11.0
actual = functions.dot_product(a, b)
assert actual == expected
def test_dot_product_3D_list():
a = [1, 2, 3]
b = [4, 5, 6]
expected = 32.0
actual = functions.dot_product(a, b)
assert actual == expected
@pytest.mark.parametrize(
"a, b, expected",
[
# Test whether the dot product function works with 2D and 3D vectors
# C1: lists, expect correct float output
([1, 2], [3, 4], 11.0),
([1, 2, 3], [4, 5, 6], 32.0),
# C2: tuples, expect correct float output
((1, 2), (3, 4), 11.0),
((1, 2, 3), (4, 5, 6), 32.0),
# C3: numpy arrays, expect correct float output
(np.array([1, 2]), np.array([3, 4]), 11.0),
(np.array([1, 2, 3]), np.array([4, 5, 6]), 32.0),
],
)
def test_dot_product(a, b, expected):
actual = functions.dot_product(a, b)
assert actual == expected