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
creating fermionic creation and annihilation operators #2166
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.
Thank you very much for the PR! The implementation and code style look good.
Here are a few comments:
- The two functions share very similar code. Maybe it is better to define one
private
function and then use it infcreate
andfdestroy
. - You could also add your source to the doc. Please make sure that URL follows the rst syntax used by Sphinx.
@BoxiLi thank you so much for the comments! I addressed all your comments in my new commit, but when I try to run the tests with This seems to be an issue with a circular import in Also, to avoid the circular import problem with Thank you so much, and please let me know if you have any insight on the |
This is likely because qutip is not correctly installed. Could you try uninstalling qutip and reinstalling again?
A new file for this seems too much for me... I think |
@BoxiLi I did this and it worked, thank you! The issue was that I had originally installed it with the Also, the code now passes both my new tests and existing tests in Lastly, regarding the circular import problem, I did as you suggested and moved the import inside the |
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 in general. Two minor suggestions on the naming and docstring.
Let's wait a bit for others to give a double-check, if this should be in operators.py
or moved to other places.
hi @BoxiLi, thank you for the minor suggestions! I implemented them and pushed the changes.
sounds good :) |
@khnikhil I just realized that this function has not been added to the API doc. Could you add Also, could you formulate the equations in math syntax so that Sphinx can render it correctly? For instance, like this: Lines 900 to 907 in fb7ec12
Does anyone want to give a double-check? @Ericgig, @hodgestar? Is it okay to put these functions in |
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 think it's fine to include them in operators.py, unless we create a few more fermionic operators it's not worth it's own file.
Please include the functions in the documentation as Boxi mentioned.
@khnikhil Something went wrong with the dimension. For the doctrines, the empty line before and after |
@khnikhil Congrats! |
Description
Adding spin-1/2 fermionic creation and annihilation operators to close #2165 (for UnitaryHack 2023).
Specifically, in
qutip.core.operators
, I added thefcreate
andfdestroy
functions, following the Jordan-Wigner transformation described in this guide.Specifically, I implemented the following using
qutip.tensor
objects, and documented this in the code.Additionally, I wrote a new test in
qutip.tests.core.test_operators
that verified the commutation relations. I also ran the new code throughpycodestyle
to verify it was written nicely.Please let me know if there are any issues or anything I should be doing on the documentation side! I hope I understood the problem correctly :)
Related issues or PRs
close #2165
I closely followed the protocol in #863