-
Notifications
You must be signed in to change notification settings - Fork 8
add test for dataclusters #54
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
Changes from 9 commits
5bf4556
e3fe16f
fdab59c
82888bb
f63abd5
b959a09
de2e964
b25e9a4
17582f0
3638253
ca8a169
2105474
cdaa3f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from diffpy.srmise.dataclusters import DataClusters | ||
|
||
|
||
@pytest.mark.parametrize( | ||
|
||
"inputs, expected", | ||
[ | ||
( | ||
{ | ||
"input_x": np.array([1, 2, 3]), | ||
"input_y": np.array([3, 2, 1]), | ||
"input_res": 4, | ||
}, | ||
{ | ||
"x": np.array([]), | ||
"y": np.array([]), | ||
"data_order": np.array([]), | ||
"clusters": np.array([[]]), | ||
"res": 0, | ||
"current_idx": 0, | ||
"lastcluster_idx": None, | ||
"lastpoint_idx": None, | ||
"status": 0, | ||
}, | ||
), | ||
], | ||
) | ||
def test_clear(inputs, expected): | ||
# Initialize DataClusters with input parameters | ||
actual = DataClusters(x=inputs["input_x"], y=inputs["input_y"], res=inputs["input_res"]) | ||
|
||
# Perform the clear operation | ||
actual.clear() | ||
|
||
# Assert each expected attribute against its actual value after clearing | ||
for attr, expected_value in expected.items(): | ||
|
||
assert ( | ||
np.array_equal(getattr(actual, attr), expected_value) | ||
if isinstance(expected_value, np.ndarray) | ||
else getattr(actual, attr) == expected_value | ||
) |
Uh oh!
There was an error while loading. Please reload this page.