-
Notifications
You must be signed in to change notification settings - Fork 33
chore: deprecated addNewAtom #157
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
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9ed7fc6
build: deprecate addNewItem
stevenhua0320 6e99082
build: change body of deprecated function
stevenhua0320 95138f7
build: add test cases for addNewAtom to test it & show deprecation me…
stevenhua0320 3f285b6
fix: refine test code to avoid if logic
stevenhua0320 1fc8a34
test: add docstring and comments to the test.
stevenhua0320 cb7aec0
fix: add more test cases and refine behavior of add_new_atom
stevenhua0320 114f3d6
fix: add docstring for hyperparamter for add_new_atom
stevenhua0320 40e8773
fix: fix comment with syntax error
stevenhua0320 8f8253c
fix: change behavior to warning and use pytest parametrize to test it.
stevenhua0320 15ccba1
[pre-commit.ci] auto fixes from pre-commit hooks
pre-commit-ci[bot] 52c99e6
fix: fix comment for UserWarning.
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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,23 @@ | ||
| **Added:** | ||
|
|
||
| * No News Added: deprecate CamelCase function for addNewItem | ||
|
|
||
| **Changed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Deprecated:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Removed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Fixed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Security:** | ||
|
|
||
| * <news item> |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| numpy | ||
| pycifrw | ||
| diffpy.utils |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| numpy | ||
| pycifrw | ||
| diffpy.utils |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -120,6 +120,41 @@ def test___copy__(self): | |
| # """check Structure.getLastAtom()""" | ||
| # return | ||
|
|
||
| def test_add_new_atom(self): | ||
| """Check Structure.add_new_item()""" | ||
| # Case: We initialize a Structure object, after calling | ||
| # add_new_item method, we check whether length of Structure | ||
| # object is added by 1. Moreover, we check added Atom's attributes | ||
| # are properly loaded into Structure object. | ||
| s_lat = Lattice() | ||
| structure = Structure(lattice=s_lat) | ||
|
|
||
| length = len(structure) | ||
| structure.add_new_atom(atype="C", xyz=[0.1, 0.2, 0.3]) | ||
| expected = len(structure) # length of structure should add by 1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove comment. this is handled in the comment at the top. Is this LLM code? OK, to get help from an LLM if it is, but I want you in charge, so you are responsible for what is happening and not the chatbot. |
||
| actual = length + 1 | ||
| assert expected == actual | ||
| atom_object = structure[-1] | ||
| assert atom_object.element == "C" | ||
| assert numpy.allclose(atom_object.xyz, [0.1, 0.2, 0.3]) | ||
|
|
||
| def test_addNewAtom(self): | ||
| """Duplicate test for the deprecated addNewAtom method. | ||
|
|
||
| Remove this test in version 4.0.0 | ||
| """ | ||
| s_lat = Lattice() | ||
| structure = Structure(lattice=s_lat) | ||
|
|
||
| length = len(structure) | ||
| structure.addNewAtom(atype="C", xyz=[0.1, 0.2, 0.3]) | ||
| expected = len(structure) | ||
| actual = length + 1 | ||
| assert expected == actual | ||
| atom_object = structure[-1] | ||
| assert atom_object.element == "C" | ||
| assert numpy.allclose(atom_object.xyz, [0.1, 0.2, 0.3]) | ||
|
|
||
| def test_assignUniqueLabels(self): | ||
| """Check Structure.assignUniqueLabels()""" | ||
| self.assertEqual("", "".join([a.label for a in self.stru])) | ||
|
|
||
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.
This is describing the test, but remember the test tests behavior so we want to describe the behavior we want. This would be better as something like
Then we will likely need
and
and some behaviors for invalid atoms maybe, if we can think of tests that don't take too long to write.
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.
I'm not quite sure about the physical perspective here. Do we allow duplicated atom into the atom list (for Case 3)? If not then we might expect an error and give the user some message about it.
Uh oh!
There was an error while loading. Please reload this page.
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.
@sbillinge ready for review. Note that from my bad physical perspective what I can think of is we should not allow a same atom at the same position in the space. So, I add the case 3 in the test, refining the original function here.