Skip to content
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

add test for dataclusters #54

Merged
merged 13 commits into from
Aug 10, 2024
Merged
Next Next commit
add test for dataclusters
  • Loading branch information
stevenhua0320 committed Aug 7, 2024
commit 5bf45562bc73f7058b5400d23d633e7bddf01f7a
51 changes: 51 additions & 0 deletions src/diffpy/srmise/tests/test_dataclusters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import numpy as np
import pytest

from diffpy.srmise.dataclusters import DataClusters


@pytest.mark.parametrize(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we are only doing one test here, we don't need the mark.parameterize, you can just load the values directly into the test below.

"input_x, input_y, input_res, expected_x, expected_y, expected_data_order, expected_clusters, expected_res, "
"expected_current_index, expected_last_cluster_idx, expected_last_pt_idx, expected_status",
[
(
np.array([1, 2, 3]),
np.array([3, 2, 1]),
4,
np.array([]),
np.array([]),
np.array([], dtype=np.int32),
np.array([[]], dtype=np.int32),
0,
0,
None,
None,
0,
)
],
)
def test_clear(
input_x,
input_y,
input_res,
expected_x,
expected_y,
expected_data_order,
expected_clusters,
expected_res,
expected_current_index,
expected_last_cluster_idx,
expected_last_pt_idx,
expected_status,
):
c1 = DataClusters(x=input_x, y=input_y, res=input_res)
c1.clear()
assert np.array_equal(c1.x, expected_x)
assert np.array_equal(c1.y, expected_y)
assert np.array_equal(c1.data_order, expected_data_order)
assert np.array_equal(c1.clusters, expected_clusters)
assert c1.res == expected_res
assert c1.current_idx == expected_current_index
assert c1.lastcluster_idx == expected_last_cluster_idx
assert c1.lastpoint_idx == expected_last_pt_idx
assert c1.status == expected_status
Loading