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

Add additional lattice models #6237

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Add additional lattice models #6237

wants to merge 13 commits into from

Conversation

ddhawan11
Copy link
Contributor

@ddhawan11 ddhawan11 commented Sep 6, 2024

Context:
Adds additional lattice templates for the lattice class.

Description of the Change:
Adds lattice models: Lieb, Cubic, Body centered cubic and Face centered cubic.

Benefits:

Possible Drawbacks:

Related GitHub Issues:

[sc-70987]

Copy link
Contributor

@austingmhuang austingmhuang left a comment

Choose a reason for hiding this comment

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

Functionally speaking it looks good! Make sure to remove print statements and add docstrings.

vectors = math.eye(3)
positions = [[0, 0, 0], [0.5, 0.5, 0.5]]

n_cells = n_cells[0:3]
Copy link
Contributor

@austingmhuang austingmhuang Sep 10, 2024

Choose a reason for hiding this comment

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

Not sure I agree with lines like these. If a user passes in n_cells=[1, 1, 2, 2, 3, 3...] they don't get an error. It would just truncate it down to the first 3 values, right? To me it should raise a friendly error rather than silently truncate it.

Copy link
Contributor

Choose a reason for hiding this comment

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

But I'm aware this has already been merged for the other internal functions so 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about we raise an error, if anything other than 1 is passed in the rest of the dimensions?

Copy link
Contributor

Choose a reason for hiding this comment

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

What purpose does having n_cells longer than the intended shape serve? If nothing, we should err on the side of raising an error/warning about skipping the rest of the values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was to provide flexibility to the user. I think we can raise a warning, or raise an error if anything in the higher dimension is other than 0 or 1. Please let me know if you have a preference for one over the other.

@ddhawan11 ddhawan11 changed the title [WIP] Add additional lattice models Add additional lattice models Sep 10, 2024
@ddhawan11 ddhawan11 marked this pull request as ready for review September 10, 2024 16:46
Copy link

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.58%. Comparing base (b78565c) to head (5d56113).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6237      +/-   ##
==========================================
- Coverage   99.58%   99.58%   -0.01%     
==========================================
  Files         443      443              
  Lines       42273    42227      -46     
==========================================
- Hits        42096    42050      -46     
  Misses        177      177              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@soranjh soranjh left a comment

Choose a reason for hiding this comment

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

Thanks @ddhawan11, looks good overall. We just need stronger tests for the correctness of the lattices.

doc/releases/changelog-dev.md Outdated Show resolved Hide resolved
pennylane/spin/lattice.py Outdated Show resolved Hide resolved
pennylane/spin/lattice.py Show resolved Hide resolved
tests/spin/test_lattice.py Show resolved Hide resolved
Copy link
Contributor

@soranjh soranjh left a comment

Choose a reason for hiding this comment

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

Thanks @ddhawan11, left some minor comments and questions.

pennylane/spin/lattice.py Outdated Show resolved Hide resolved
tests/spin/test_lattice.py Outdated Show resolved Hide resolved

@pytest.mark.parametrize(
# expected_points here were calculated manually.
("shape", "n_cells", "expected_points"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have such tests for all lattices or just for 3D ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, we test the rest of the cases when we test the lattice class.

Copy link
Contributor

@obliviateandsurrender obliviateandsurrender left a comment

Choose a reason for hiding this comment

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

Looks, good. Just a few minor suggestions.

doc/releases/changelog-dev.md Outdated Show resolved Hide resolved
vectors = math.eye(3)
positions = [[0, 0, 0], [0.5, 0.5, 0.5]]

n_cells = n_cells[0:3]
Copy link
Contributor

Choose a reason for hiding this comment

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

What purpose does having n_cells longer than the intended shape serve? If nothing, we should err on the side of raising an error/warning about skipping the rest of the values.

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.

4 participants