Skip to content

Commit 88d6b23

Browse files
committed
skpkg: migrate tests folder
1 parent fb15602 commit 88d6b23

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

tests/test_functions.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import numpy as np
2+
import pytest
3+
4+
from diffpy.morph import functions # noqa
5+
6+
7+
def test_dot_product_2D_list():
8+
a = [1, 2]
9+
b = [3, 4]
10+
expected = 11.0
11+
actual = functions.dot_product(a, b)
12+
assert actual == expected
13+
14+
15+
def test_dot_product_3D_list():
16+
a = [1, 2, 3]
17+
b = [4, 5, 6]
18+
expected = 32.0
19+
actual = functions.dot_product(a, b)
20+
assert actual == expected
21+
22+
23+
@pytest.mark.parametrize(
24+
"a, b, expected",
25+
[
26+
# Test whether the dot product function works with 2D and 3D vectors
27+
# C1: lists, expect correct float output
28+
([1, 2], [3, 4], 11.0),
29+
([1, 2, 3], [4, 5, 6], 32.0),
30+
# C2: tuples, expect correct float output
31+
((1, 2), (3, 4), 11.0),
32+
((1, 2, 3), (4, 5, 6), 32.0),
33+
# C3: numpy arrays, expect correct float output
34+
(np.array([1, 2]), np.array([3, 4]), 11.0),
35+
(np.array([1, 2, 3]), np.array([4, 5, 6]), 32.0),
36+
],
37+
)
38+
def test_dot_product(a, b, expected):
39+
actual = functions.dot_product(a, b)
40+
assert actual == expected

tests/test_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Unit tests for __version__.py."""
22

3-
import diffpy.morph
3+
import diffpy.morph # noqa
44

55

66
def test_package_version():

0 commit comments

Comments
 (0)