-
Notifications
You must be signed in to change notification settings - Fork 7
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
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5bf4556
add test for dataclusters
stevenhua0320 e3fe16f
define eq method in dataclusters.py
stevenhua0320 fdab59c
change parametrization form
stevenhua0320 82888bb
add one more case and change reference name to actual
stevenhua0320 f63abd5
delete comment
stevenhua0320 b959a09
add two more tests for DataClusters class function.
stevenhua0320 de2e964
change in docstring for clearer explanation for clear method, remove …
stevenhua0320 b25e9a4
change clear method docstring into numpydoc format. Delete dtype for …
stevenhua0320 17582f0
remove block
stevenhua0320 3638253
Make edition to condition on res, refactor for setdata to make behavi…
stevenhua0320 ca8a169
change condition on res
stevenhua0320 2105474
add condition on x and res are incompatible, update test.
stevenhua0320 cdaa3f2
revert change in setdata method.
stevenhua0320 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
add test for dataclusters
- Loading branch information
commit 5bf45562bc73f7058b5400d23d633e7bddf01f7a
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( | ||
"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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.