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

Manual charges #14

Merged
merged 11 commits into from
Apr 11, 2024
Merged

Manual charges #14

merged 11 commits into from
Apr 11, 2024

Conversation

E-Rum
Copy link
Contributor

@E-Rum E-Rum commented Apr 8, 2024


📚 Documentation preview 📚: https://meshlode--14.org.readthedocs.build/en/14/

Copy link
Contributor

@PicoCentauri PicoCentauri left a comment

Choose a reason for hiding this comment

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

Very nice. I made some minor comments. If you could be able to fix them this would be nice. Besides the linter is not happy:

/home/runner/work/MeshLODE/MeshLODE/src/meshlode/calculators/meshpotential.py:245:13: B007 Loop control variable 'types_single' not used within the loop body. If this is intended, start the name with an underscore.
/home/runner/work/MeshLODE/MeshLODE/tests/calculators/test_meshpotential.py:110:5: B018 Found useless Tuple expression. Consider either assigning it to a variable or removing it.

You can test your changes also locally with tox -e lint (tox -e format does not fix all issues, especially not renaming of code.)

I will do the metatensor version afterwards. As we discussed the idea there is that the key of the block will be [“center_type”, “charge_channel”] if explicit charges are given instead of ["center_type", "neighbor_type"] for one hot charges.

src/meshlode/calculators/meshpotential.py Outdated Show resolved Hide resolved
tests/calculators/test_meshpotential.py Outdated Show resolved Hide resolved
@@ -95,6 +104,19 @@ def test_single_frame():
)


def test_single_frame_with_charges():
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a comment here that this test uses an explicit one hot encoding for the charges.

src/meshlode/calculators/meshpotential.py Show resolved Hide resolved
src/meshlode/calculators/meshpotential.py Outdated Show resolved Hide resolved
@E-Rum E-Rum requested a review from PicoCentauri April 10, 2024 12:59
Copy link
Contributor

@PicoCentauri PicoCentauri left a comment

Choose a reason for hiding this comment

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

Wonderful.

I have two minor comments and then we are good to go!

charges_single = self._one_hot_charges(
types_single,
requested_types,
n_types,
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 just len(requested_types) as you write in L199 I think you don't need this as a parameter.

Comment on lines 361 to 362
dtype: torch.dtype,
device: torch.device,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for convenience and consistence with torch, I would make them optional.

Suggested change
dtype: torch.dtype,
device: torch.device,
dtype: Optional[torch.dtype]=None,
device: Optional[torch.device]=None,

for spec_neighbor in range(len(requested_types)):
a_pair = spec_center * n_types + spec_neighbor
for spec_channel in range(len(spec_channels)):
a_pair = spec_center * n_charges_channels + spec_channel
Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh yes good catch!

@PicoCentauri PicoCentauri merged commit e0fbf02 into main Apr 11, 2024
5 checks passed
@PicoCentauri PicoCentauri deleted the manual_charges branch April 11, 2024 06:45
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.

2 participants