Skip to content

Add set data test cases #61

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

Merged
merged 15 commits into from
Aug 13, 2024
Merged
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
update test for setdata function
  • Loading branch information
stevenhua0320 committed Aug 13, 2024
commit 321f47dd48e9a5006877250ec017e45ba83a6b29
27 changes: 5 additions & 22 deletions src/diffpy/srmise/tests/test_dataclusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,15 @@ def test___eq__():
"y": np.array([3, 2, 1]),
"res": 4,
},
{
"x": np.array([1, 2, 3]),
"y": np.array([3, 2, 1]),
"res": 4,
"data_order": [2, 1, 0],
"clusters": np.array([[0, 0]]),
"current_idx": 2,
"lastpoint_idx": 0,
"INIT": 0,
"READY": 1,
"CLUSTERING": 2,
"DONE": 3,
"lastcluster_idx": None,
"status": 1,
}
DataClusters(x=np.array([1, 2, 3]), y=np.array([3, 2, 1]), res=4),
),
],
)
def test_set_data(inputs, expected):
actual = DataClusters(x=inputs["x"], y=inputs["y"], res=inputs["res"])
attributes = vars(actual)
for attr_key, attr_val in attributes.items():
if isinstance(attr_val, np.ndarray):
assert np.array_equal(attr_val, expected[attr_key])
else:
assert attr_val == expected[attr_key]
actual = DataClusters(x=np.array([]), y=np.array([]), res=0)
actual.setdata(x=inputs["x"], y=inputs["y"], res=inputs["res"])
assert expected == actual



@pytest.mark.parametrize(
Expand Down