Skip to content

skpkg: setup CI after migrating tests, src, requirements, and .github folder #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
skpkg: migrate tests folder
  • Loading branch information
tinatn29 committed Jun 17, 2025
commit 20f3744b43dc7745afa5267868c7500c03c48d83
40 changes: 40 additions & 0 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
2 changes: 1 addition & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Unit tests for __version__.py."""

import diffpy.fourigui
import diffpy.fourigui # noqa


def test_package_version():
Expand Down