diff --git a/src/diffpy/srmise/tests/test_dataclusters.py b/src/diffpy/srmise/tests/test_dataclusters.py index 0ea6b42..025d1a6 100644 --- a/src/diffpy/srmise/tests/test_dataclusters.py +++ b/src/diffpy/srmise/tests/test_dataclusters.py @@ -1,5 +1,5 @@ from copy import copy - +import pytest import numpy as np from diffpy.srmise.dataclusters import DataClusters @@ -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