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

Fix quantity types #106

Merged
merged 21 commits into from
May 16, 2024
Merged

Fix quantity types #106

merged 21 commits into from
May 16, 2024

Conversation

ladinesa
Copy link
Collaborator

@ladinesa ladinesa commented Apr 25, 2024

Fix shape and type inconsistencies due to metainfo refactoring. @TLCFEM

@coveralls
Copy link

coveralls commented Apr 25, 2024

Pull Request Test Coverage Report for Build 9111179626

Details

  • 198 of 205 (96.59%) changed or added relevant lines in 20 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 88.168%

Changes Missing Coverage Covered Lines Changed/Added Lines %
atomisticparsers/lammps/parser.py 0 1 0.0%
atomisticparsers/gromacs/parser.py 6 8 75.0%
atomisticparsers/utils/mdanalysis.py 4 6 66.67%
atomisticparsers/utils/parsers.py 26 28 92.86%
Totals Coverage Status
Change from base Build 8751893048: -0.03%
Covered Lines: 6237
Relevant Lines: 7074

💛 - Coveralls

Copy link
Contributor

@JFRudzinski JFRudzinski left a comment

Choose a reason for hiding this comment

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

Most changes look perfectly fine. I would like to fix the issues in the interaction section before your merge this.

if not interactions:
return

def write_interaction_values(values):
Copy link
Contributor

Choose a reason for hiding this comment

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

In general this function is now a bit confusing to me, I think I do not yet fully understand all your motivations here. Please clarfiy.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made this part simpler to get rid of the mapping of the data to the interaction types, now I simply sort the interactions by type and collect the values until a new interaction type is encountered then write the interaction values. I had a temporary fix for the atom_indices and atom_labels because before, the shape (arbitrary) and type (np.object) is not consistent with the definition hence the error. The more formal fix, I think is to restructure the defintion so we get we are not compelled to have a fixed array.

for key, val in interaction_dict.items():
sec_interaction.type = current_type
sec_interaction.n_atoms = max(
[len(v) for v in values.get("atom_indices", [[0]])]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we really give a default of [[0]] if there are no atom_indices instead of just not populating any interactions sections? Can this even occur?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes sure I can put a return here.

)
for key, val in values.items():
# TODO tempory fix: atom_labels, atom_indices not homogeneous
# fill in missing atom label with 'X', atom index with -1
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it is actually what the function below is doing, and I don't understand what you mean by fill in missing values? I guess you are thinking a case where atom_indices and atom_labels are of a different length than the actual list of atoms? This would be a very strange occurrence from my perspective and should result in an error, unless we have a concrete use case for this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From the denition atom_labels and atom_indices have shape ['n_interactions', 'n_atoms'] but n_atoms is not the same for all interactions. Is this right? Hence the fix that I have here that fulfills the definition is to set n_atoms to the max value l189 and for interactions with n-atoms less than max value, I fill in 'X' or -1 respectively. As I have mentioned above, this is not an ideal fix and it is better to redefine Interaction section so we do not group all interactions.

if key in ["atom_indices", "atom_labels"]:
val = [
(
v
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the reason for the errors in the tests dealing with interactions and the bond list that you have commented out. In the case of "atom_indices" you are subtracting 1 from the atom_index in all cases, which results in a -1-indexed list of indices, and all the test assertions to be off by 1.

val = [
(
v
+ [-1 if key == "atom_indices" else "X"]
Copy link
Contributor

Choose a reason for hiding this comment

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

In line 133/4 of utils/mdanalysis.py I have made a check for atom_names and replaced the labels by X if they do not correspond to actual elements. We should employ a similar logic in general here, but not based on individual missing labels, as mentioned above. If there are no atom label info, then we can replace all by X, otherwise we should check the names/labels individually to see if they correspond to elements. Again, not sure if there exists a case where the atom_label/name list does not match the length of system.atoms. Please clarify if I am wrong.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i really do not like this fix from me and it is simply wrong. We need to fix the rewrite the definition instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

To go back to a flat list, I need to check and adjust my implementation, because this is used for things like the bond list. How do you want to proceed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can perhaps just go for the temporary fix for now, because you are also working on a new schema which probably will not have this complication anyway.

@JFRudzinski
Copy link
Contributor

JFRudzinski commented May 15, 2024

@ladinesa I think there are some major misunderstandings happening here. I would like to come to a consensus and fix the issues (i.e., I don't want to wait for the new schema), but would like to chat first. Can you let me know when you are available?

@ladinesa
Copy link
Collaborator Author

@JFRudzinski can we merge thus now?

@JFRudzinski
Copy link
Contributor

@JFRudzinski can we merge thus now?

Yes, sorry, I thought that was assumed, please go ahead.

@ladinesa ladinesa merged commit 7e2734d into develop May 16, 2024
3 checks passed
@ladinesa ladinesa deleted the fix-quantity-types branch May 16, 2024 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants