Conversation
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
|
@sbillinge I've edited the DocString (moved it to under init and each parameter starts with "the") |
sbillinge
left a comment
There was a problem hiding this comment.
nice. Please see suggestions
| Parameters | ||
| Methods | ||
| ------- | ||
| from_structure(structure, site_index=None) |
There was a problem hiding this comment.
A cleaner API may be to have load_structure() and make it something that simply tests what the input is (pymatgen object or file-path/string) and behaves accordingly
There was a problem hiding this comment.
sounds good! Would you add load_structure() as a function in diffpy.clusterrender.io or as a method in this class?
There was a problem hiding this comment.
and in that case, should we make __init__() take something like structure_input as argument, and we specify in the DocString that structure_input can be a pymatgen Structure, pathlib.Path, or str?
There was a problem hiding this comment.
right.
Regarding function or method, I think it is really a parser, so perhaps we should call it parse_data and have it as method in the class. If the only way to do it is on instantiation, then we would presumably make it a private method.
| site_index : int, optional | ||
| The index of atom in the structure to be treated as the | ||
| central atom. | ||
| filename : str, optional |
There was a problem hiding this comment.
let's accept a pathlib.Path or a string. That is our kind of new standard. Also, we only need to have structure entry if we resolve this in the method but allow it to be a file path or a pytmatgen structure object. In general, we may want to pass it a diffpy or objcryst structure object too, later, and this will be more easily extended if we do it this way.
There was a problem hiding this comment.
ok we can have load_structure() take care of that
|
@sbillinge I addressed your comments in this commit (will make a |
news/tn-structuredf.rst
Outdated
| @@ -0,0 +1,23 @@ | |||
| **Added:** | |||
|
|
|||
| * create StructureDF class (DataFrame) to store a cluster of atoms | |||
sbillinge
left a comment
There was a problem hiding this comment.
Nice. Nearly there. After reading what it does, I wonder whether w should call it "ClusterDataFrame" since it denotes center atom and references everything to that? It is like a container for a cluster around a center atom?
But otherwise it looks good
|
@sbillinge I changed the name to |
sbillinge
left a comment
There was a problem hiding this comment.
This is good. Are we missing tests?
We just have a constructor but this is still a function that could be tested. Since all it does is create a DataFrame, have it create one and test that this is equal to what you expect.
|
@sbillinge can we add the constructor test later? Currently, instantiating this class requires the method Alternatively, we could change |
I think this comment was before we talked, but basically, we want the test to fail until it passes. Failing tests are good. |
|
@sbillinge I started setting up the test for the |
sbillinge
left a comment
There was a problem hiding this comment.
Thanks for this. Please see inline comments though.
| input_structure, site_index, expected_output = input_test_data | ||
| cdf = ClusterDataFrame(input_structure, site_index=site_index) | ||
|
|
||
| # check if the output matches the expected DataFrame |
There was a problem hiding this comment.
we don't need comments like this as they are a bit trivial.
|
|
||
| from diffpy.clusterrender.clusterdataframe import ClusterDataFrame | ||
|
|
||
| """ |
There was a problem hiding this comment.
This probably is working but it is a slightly different structure than our most recent standard. I think that Yuchen is writing good standard tests, and so is Caden. The standards make the tests easier to read for the reviewers because the intent becomes very clear, and the test to test the intent is right below it and so things become easier to review. Could I maybe ask you to check with those guys, or check their code and try and use that style? Thanks so much.
There was a problem hiding this comment.
Caden sent me an example from cmi. Will try to get to it today!
create a class
StructureDF(inherited from pandas DataFrame) to represent a local structure or cluster of atoms. will later add_from_structureand_from_filemethods