-
Notifications
You must be signed in to change notification settings - Fork 2
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
Remove own system in favor of metatensor.torch.atomistic.System
#12
Conversation
fc6b712
to
b0e74b8
Compare
My impression was that we were keeping |
Just as a suggestions, you could also do SystemDict = {
"types": torch.Tensor,
"positions": torch.Tensor,
"cell": torch.Tensor,
}
def compute(
self,
systems: Union[List[SystemDict], SystemDict],
) -> Union[torch.Tensor, List[torch.Tensor]]:
########################################################################
# alternatively
@torch.jit.script
class System:
def __init__(self, types, positions, cell):
self.types = types
self.positions = positions
self.cell = cell
# add some shape checks & friends
def compute(
self,
systems: Union[List[System], System],
) -> Union[torch.Tensor, List[torch.Tensor]]: |
It still is. |
I am not a huge fan of dictionary. They are usually very hard to document and people abuse them a lot A custom class was what we had before but I don't want to maintain this 😆 |
Thanks @PicoCentauri , that's good then! I'll have a look at the changes. I agree with @PicoCentauri -- not a fan of |
b0e74b8
to
eae787d
Compare
f115137
to
10c4b62
Compare
) -> Union[torch.Tensor, List[torch.Tensor]]: | ||
"""Compute the potential at the position of each atom for all provided systems. | ||
"""compute potential for all provided "systems" stacked inside list. |
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.
Shouldn't this start with an upper-case C?
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.
Yes!
cell = torch.eye(3) | ||
|
||
match = ( | ||
"each `type` must be a 1 dimensional tensor, got at least one tensor with " |
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 where using type
really becomes silly, in my opinion: you couldn't even write this as python code since type
is reserved!
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.
Yes, it is hard but basically the user will never see type
since we also work with a list which we name types
. However internally this will be interesting...
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 also changed the error message from type
-> types
Looks fine by me. I'm pretty opposed to the naming of |
10c4b62
to
31a3c38
Compare
Our
System
class was always a temporary solution and is now removed and replaced by the much bettermetatensor.torch.atomistic.System
.To have an independent torch API the synopsis of the the pure torch
MeshPotential
class now iswhich I think this synopsis also clear for people who only live in the torch world.
I also tried to work on the comment from @kvhuguenin and replaced
species
by the new lab conventionstypes
.📚 Documentation preview 📚: https://meshlode--12.org.readthedocs.build/en/12/