Skip to content

Commit

Permalink
add test comment and corresponding tests to test files.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenhua0320 committed Aug 12, 2024
1 parent 5be09d5 commit 2deb679
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/diffpy/srmise/tests/test_dataclusters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from copy import copy

import pytest
import numpy as np

from diffpy.srmise.dataclusters import DataClusters
Expand Down Expand Up @@ -32,3 +32,34 @@ def test___eq__():
print(f"not-equal test failed on {attr_key}")
assert not expected == actual
attributes.update({attr_key: reset})

# For reset clusters test, we have two test cases:
# Precondition: DataClusters object should be a valid object.
# Case (1): x and y are non-empty with positive res, reset_clusters would reset clusters to largest y arg
# Case (2): x and y are empty with zero res, reset_clusters would reset clusters to an empty numpy arr
@pytest.mark.parametrize(
"inputs, expected",
[
(
# case (1)
{
"input_x": np.array([1, 2, 3]),
"input_y": np.array([3, 2, 1]),
"input_res": 4,
},
DataClusters(np.array([1, 2, 3]), np.array([3, 2, 1]), 4),
),
(
# case (2)
{
"input_x": np.array([]),
"input_y": np.array([]),
"input_res": 0,
},
DataClusters(np.array([]), np.array([]), 0),
),
],
)
def test_reset_clusters(inputs, expected):
actual = DataClusters(x=inputs["input_x"], y=inputs["input_y"], res=inputs["input_res"])
assert actual == expected

0 comments on commit 2deb679

Please sign in to comment.