-
Notifications
You must be signed in to change notification settings - Fork 586
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
base: master
Are you sure you want to change the base?
Conversation
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.
Functionally speaking it looks good! Make sure to remove print statements and add docstrings.
pennylane/spin/lattice.py
Outdated
vectors = math.eye(3) | ||
positions = [[0, 0, 0], [0.5, 0.5, 0.5]] | ||
|
||
n_cells = n_cells[0:3] |
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.
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.
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.
But I'm aware this has already been merged for the other internal functions so 🤷
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.
How about we raise an error, if anything other than 1 is passed in the rest of the dimensions?
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.
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.
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.
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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
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.
Thanks @ddhawan11, looks good overall. We just need stronger tests for the correctness of the lattices.
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.
Thanks @ddhawan11, left some minor comments and questions.
|
||
@pytest.mark.parametrize( | ||
# expected_points here were calculated manually. | ||
("shape", "n_cells", "expected_points"), |
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.
Do we have such tests for all lattices or just for 3D ones?
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, we test the rest of the cases when we test the lattice class.
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.
Looks, good. Just a few minor suggestions.
pennylane/spin/lattice.py
Outdated
vectors = math.eye(3) | ||
positions = [[0, 0, 0], [0.5, 0.5, 0.5]] | ||
|
||
n_cells = n_cells[0:3] |
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.
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.
Co-authored-by: Utkarsh <utkarshazad98@gmail.com>
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]