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

Implements the Montrealer #374

Merged
merged 16 commits into from
Nov 29, 2023
Merged

Implements the Montrealer #374

merged 16 commits into from
Nov 29, 2023

Conversation

nquesada
Copy link
Collaborator

Implements new function to calculation photon-number cumulants reducing the complexity of the problem from combinatorial to exponential

@nquesada nquesada added the WIP label Sep 21, 2023
@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

Merging #374 (e764235) into master (0e163bf) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #374   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        28    +1     
  Lines         1907      1972   +65     
=========================================
+ Hits          1907      1972   +65     
Files Coverage Δ
thewalrus/__init__.py 100.00% <100.00%> (ø)
thewalrus/_montrealer.py 100.00% <100.00%> (ø)
thewalrus/_torontonian.py 100.00% <100.00%> (ø)
thewalrus/reference.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e163bf...e764235. Read the comment docs.

yaniccd and others added 2 commits October 22, 2023 17:48
* Yanic the pirate

* mtl test

* mtl first tests

* mtl test

* test mtl

* test montrealer

* test montrealer

* test Montrealer

* test montrealer

* test montrealer

* test montrealer

* test montrealer

* test montrealer

* tests montrealer

* montrealer test

* montrealer test

* montrealer test

* montrealer test

* montrealer test

* test montrealer

* test montrealer

* montrealer test

* montrealer test

* montrealer test

* montrealer tests

* montrealer tests

* montrealer tests

* montrealer tests

* functions header update

* test montrealer

* test montrealer

* test montrealer

* test montrealer

* test montrealer

* test montrealer

* test montrealer

* test montrealer ready for review

* test montrealer

* test montrealer

* test montrealer

* test montrealer

* test montrealer

* test montrealer - failed tests

* test montrealer

* test montrealer

* test montrealer

* test montrealer

* test montrealer

* the rspms are now ordered

* Passes black

* garbage test file to be deleted later

* minor changes

* Done

---------

Co-authored-by: Nicolas Quesada <[email protected]>
Copy link
Contributor

@sduquemesa sduquemesa left a comment

Choose a reason for hiding this comment

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

Hey! I'm leaving some comments on docstring aesthetics. I still need to get to review the code properly. In the time being, it'd be nice to ensure that the docstring format is consistent as well as avoiding the use of acronyms.

thewalrus/_montrealer.py Outdated Show resolved Hide resolved
thewalrus/_torontonian.py Outdated Show resolved Hide resolved
Comment on lines +287 to +288
def mapper(x, objects):
"""Helper function to turn a permutation and bistring into an element of rpmp.
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be nice to add a little example here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Like so:

mapper(((1,2,3), '0000'), (0,1,2,3,4,5,6,7))
Out[38]: ((0, 5), (1, 6), (2, 7), (4, 3))

?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes!

Copy link
Contributor

Choose a reason for hiding this comment

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

I find this function particularly hard to follow. It would be nice to have a test that specifically checks the output of this function against hard-coded values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added an extra test test_mapper_hard_coded.

thewalrus/tests/test_montrealer.py Outdated Show resolved Hide resolved
thewalrus/_montrealer.py Outdated Show resolved Hide resolved
thewalrus/reference.py Outdated Show resolved Hide resolved
thewalrus/reference.py Outdated Show resolved Hide resolved
Returns:
generator: the set of restricted perfect matching permutations of the tuple s
"""
m = len(s) // 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Make sure s is an instance of a Sequence

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we just followed what is done in the function partitions in line 138 of this file. Do you think it is worth changing it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not really as long as you're sure is a sequence. In any case, if it is not then it will throw an error.



def splitter(elem):
"""Takes an element from rpmp and returns all the associated elements in rspm
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using acronyms: someone without context (like me) will struggle hard to understand their meaning when reading the docstrings.

thewalrus/reference.py Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@nquesada nquesada left a comment

Choose a reason for hiding this comment

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

Thanks for the comments @sduquemesa

nquesada and others added 2 commits November 8, 2023 21:42
Co-authored-by: Sebastián Duque Mesa <[email protected]>
Co-authored-by: Sebastián Duque Mesa <[email protected]>
thewalrus/reference.py Outdated Show resolved Hide resolved
Copy link
Contributor

@sduquemesa sduquemesa left a comment

Choose a reason for hiding this comment

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

I left some more comments about docstrings and a couple about the code itself. However, the comments do not prevent this PR from being merged. Henceforth, I yield my approval.

digits = np.zeros((n), dtype=type(num))
nn = num
counter = -1
while nn >= 1: # Should be >= 1, not > 1.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is not informative. Consider

  • removing it and leaving the code as is
  • removing it and changing the code for nn>0
  • extending it to make it more descriptive

If there is a particular reason why in the context it makes sense to have nn>=1 then I'd choose the last option.

thewalrus/_montrealer.py Outdated Show resolved Hide resolved
thewalrus/_montrealer.py Show resolved Hide resolved
thewalrus/_montrealer.py Outdated Show resolved Hide resolved
Returns:
generator: the set of restricted perfect matching permutations of the tuple s
"""
m = len(s) // 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really as long as you're sure is a sequence. In any case, if it is not then it will throw an error.

Comment on lines +287 to +288
def mapper(x, objects):
"""Helper function to turn a permutation and bistring into an element of rpmp.
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this function particularly hard to follow. It would be nice to have a test that specifically checks the output of this function against hard-coded values.

thewalrus/reference.py Show resolved Hide resolved
thewalrus/reference.py Show resolved Hide resolved
thewalrus/_montrealer.py Outdated Show resolved Hide resolved
@nquesada nquesada merged commit 8ec2172 into master Nov 29, 2023
5 checks passed
@nquesada nquesada deleted the montrealer branch November 29, 2023 20:53
rachelchadwick added a commit that referenced this pull request Apr 29, 2024
commit 7c63905
Merge: 127a1a7 f935053
Author: Eli Bourassa <[email protected]>
Date:   Mon Apr 29 14:16:22 2024 -0400

    Merge branch 'master' into internal_modes

commit f935053
Author: Alberto Fumagalli <[email protected]>
Date:   Mon Apr 29 14:14:51 2024 -0400

    Add codecov token to test workflow (#390)

commit fe9e112
Author: Nicolas Quesada <[email protected]>
Date:   Wed Apr 10 15:31:34 2024 -0400

    Updates references (#384)

    * updates references

    * Updates biblio

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>

commit 25b5f08
Author: Nicolas Quesada <[email protected]>
Date:   Wed Feb 28 20:35:28 2024 -0500

    Implements the pre-Iwasawa and Iwasawa decompositions. (#382)

    * First working version

    * First working version

    * First working version

    * better tests

    * better tests

    * Finally correct

    * Finally correct

    * putting the traingles in the right places

    * Removes unnecesary T

    * More tests

    * More tests and spell correction

    * More tests and spell correction

    * Removes unnecesary complex number usage

    * Apply suggestions from code review

    Co-authored-by: Sebastián Duque Mesa <[email protected]>

    * Apply suggestions from code review

    Co-authored-by: Sebastián Duque Mesa <[email protected]>

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>
    Co-authored-by: Sebastián Duque Mesa <[email protected]>

commit 127a1a7
Merge: e6de063 8759363
Author: Nicolas Quesada <[email protected]>
Date:   Tue Feb 13 16:43:20 2024 -0500

    Merge branch 'master' into internal_modes

commit 8759363
Author: Nicolas Quesada <[email protected]>
Date:   Thu Feb 1 16:57:23 2024 -0500

    Better blochmessiah (#381)

    * Nicer BM

    * Updates changelog

    * Unnecesary import

    * More simplifications

    * More simplifications

    * one more

    * Updates docstring

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>

commit 6247fc8
Author: Nicolas Quesada <[email protected]>
Date:   Wed Jan 24 10:43:57 2024 -0500

    Updates docstring and simplifies Williamson (#380)

    Co-authored-by: Nicolas Quesada <[email protected]>

commit 0b1af63
Author: Sebastián Duque Mesa <[email protected]>
Date:   Thu Jan 11 17:09:32 2024 -0500

    Increment version number to `0.22.0-dev` (#379)

commit 544c457
Author: Sebastián Duque Mesa <[email protected]>
Date:   Wed Jan 10 16:52:38 2024 -0500

    bump version to `0.21.0` (#378)

commit 2268bf0
Author: Nicolas Quesada <[email protected]>
Date:   Thu Jan 4 11:12:27 2024 -0500

    Adds extra degenerate tests with nonvac nullspace (#377)

    * Adds extra degenerate tests with nonvac nullspace

    * updates changelog

    * updates changelog

    * updates changelog

    * Removes unnecesary comment

    * Still breaking something

    * Simplifications still work

    * Simplifications still work

    * Fixes bug

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>

commit 8ec2172
Author: Nicolas Quesada <[email protected]>
Date:   Wed Nov 29 15:53:11 2023 -0500

    Implements the Montrealer (#374)

    * Saving changes

    * Passes black

    * Passes black

    * Black

    * updates acknowledgements and changelog

    * updates acknowledgements and changelog

    * Adds montrealer

    * Adds Montrealer tests (#375)

    * Yanic the pirate

    * mtl test

    * mtl first tests

    * mtl test

    * test mtl

    * test montrealer

    * test montrealer

    * test Montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * tests montrealer

    * montrealer test

    * montrealer test

    * montrealer test

    * montrealer test

    * montrealer test

    * test montrealer

    * test montrealer

    * montrealer test

    * montrealer test

    * montrealer test

    * montrealer tests

    * montrealer tests

    * montrealer tests

    * montrealer tests

    * functions header update

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer ready for review

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer - failed tests

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * the rspms are now ordered

    * Passes black

    * garbage test file to be deleted later

    * minor changes

    * Done

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>

    * making bots happy

    * Apply suggestions from code review

    Co-authored-by: Sebastián Duque Mesa <[email protected]>

    * Apply suggestions from code review

    Co-authored-by: Sebastián Duque Mesa <[email protected]>

    * Apply suggestions from code review

    * Apply suggestions from code review

    Co-authored-by: Sebastián Duque Mesa <[email protected]>

    * Apply suggestions from code review

    Co-authored-by: Sebastián Duque Mesa <[email protected]>

    * Adds extra tests

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>
    Co-authored-by: Yanic Cardin <[email protected]>
    Co-authored-by: Sebastián Duque Mesa <[email protected]>

commit 0e163bf
Author: Nicolas Quesada <[email protected]>
Date:   Tue Aug 22 10:19:08 2023 -0400

    Update symplectic.py (#372)

    * Update decompositions.py

    * New takagi

    * New takagi

    * Passes black

    * Simplifies blochmessiah

    * Simplifies blochmessiah

    * Found a case that breaks Takagi

    * Fixes all the tests

    * Fixes issues found by the linter

    * Adds extra test

    * Adds extra test

    * dummy

    * dummy

    * Update symplectic.py

    Removes `autonne`

    * relocates test

    * trying to make pylint happy

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>

commit e999e49
Author: Nicolas Quesada <[email protected]>
Date:   Thu Aug 17 12:55:45 2023 -0400

    Better way to determine if a matrix is a phase times a real matrix (#373)

    * Add a better way to determine if a matrix is a phase times a real matrix and tests

    * CHANGELOG updates

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>
rachelchadwick added a commit that referenced this pull request May 1, 2024
* First commit

* Fixes bug

* removes unused import

* Working version

* Passes black

* removes unused function

* removes unused function

* Rachels code review (#385)

* Minor fixes

* passes black

* Fix test

* removes unused function

* test error is raised

* test error is raised

* Passes black

* Passes black

---------

Co-authored-by: Nicolas Quesada <[email protected]>
Co-authored-by: rachelchadwick <[email protected]>

* Now the non-recursive function do not produce warning (#386)

* Now the non-recursive function do not produce warning

* Now the non-recursive function do not produce warning

* Passes black

* Simplifies the diagonal method

* More tests, always

* More tests, always

* minor pylint improvements

* Adds extra test

* black

* minor simplification

* some tests pass

* some tests pass

* Moves the tests that take forever to the end of the test file

* Passes black

* Adds else

---------

Co-authored-by: Nicolas Quesada <[email protected]>

* Adds the warning (#388)

* Adds the warning

* passes black

* Apply suggestions from code review

Co-authored-by: rachelchadwick <[email protected]>

* Update thewalrus/internal_modes/fock_density_matrices.py

---------

Co-authored-by: Nicolas Quesada <[email protected]>
Co-authored-by: rachelchadwick <[email protected]>

* Windows fix for numba types (#389)

* Fix numba types

* Passes black

* Apply suggestions from code review

* Apply suggestions from code review

* passes black

* Make lists tuples

* Check non-recursive

* Tests with high tolerances

* Run black

* Update test_density_matrix

* Minor changes

---------

Co-authored-by: Nicolas Quesada <[email protected]>
Co-authored-by: Nicolas Quesada <[email protected]>

* Apply suggestions from code review

Co-authored-by: rachelchadwick <[email protected]>

* removes unnecesary import

* Squashed commit of the following:

commit 7c63905
Merge: 127a1a7 f935053
Author: Eli Bourassa <[email protected]>
Date:   Mon Apr 29 14:16:22 2024 -0400

    Merge branch 'master' into internal_modes

commit f935053
Author: Alberto Fumagalli <[email protected]>
Date:   Mon Apr 29 14:14:51 2024 -0400

    Add codecov token to test workflow (#390)

commit fe9e112
Author: Nicolas Quesada <[email protected]>
Date:   Wed Apr 10 15:31:34 2024 -0400

    Updates references (#384)

    * updates references

    * Updates biblio

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>

commit 25b5f08
Author: Nicolas Quesada <[email protected]>
Date:   Wed Feb 28 20:35:28 2024 -0500

    Implements the pre-Iwasawa and Iwasawa decompositions. (#382)

    * First working version

    * First working version

    * First working version

    * better tests

    * better tests

    * Finally correct

    * Finally correct

    * putting the traingles in the right places

    * Removes unnecesary T

    * More tests

    * More tests and spell correction

    * More tests and spell correction

    * Removes unnecesary complex number usage

    * Apply suggestions from code review

    Co-authored-by: Sebastián Duque Mesa <[email protected]>

    * Apply suggestions from code review

    Co-authored-by: Sebastián Duque Mesa <[email protected]>

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>
    Co-authored-by: Sebastián Duque Mesa <[email protected]>

commit 127a1a7
Merge: e6de063 8759363
Author: Nicolas Quesada <[email protected]>
Date:   Tue Feb 13 16:43:20 2024 -0500

    Merge branch 'master' into internal_modes

commit 8759363
Author: Nicolas Quesada <[email protected]>
Date:   Thu Feb 1 16:57:23 2024 -0500

    Better blochmessiah (#381)

    * Nicer BM

    * Updates changelog

    * Unnecesary import

    * More simplifications

    * More simplifications

    * one more

    * Updates docstring

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>

commit 6247fc8
Author: Nicolas Quesada <[email protected]>
Date:   Wed Jan 24 10:43:57 2024 -0500

    Updates docstring and simplifies Williamson (#380)

    Co-authored-by: Nicolas Quesada <[email protected]>

commit 0b1af63
Author: Sebastián Duque Mesa <[email protected]>
Date:   Thu Jan 11 17:09:32 2024 -0500

    Increment version number to `0.22.0-dev` (#379)

commit 544c457
Author: Sebastián Duque Mesa <[email protected]>
Date:   Wed Jan 10 16:52:38 2024 -0500

    bump version to `0.21.0` (#378)

commit 2268bf0
Author: Nicolas Quesada <[email protected]>
Date:   Thu Jan 4 11:12:27 2024 -0500

    Adds extra degenerate tests with nonvac nullspace (#377)

    * Adds extra degenerate tests with nonvac nullspace

    * updates changelog

    * updates changelog

    * updates changelog

    * Removes unnecesary comment

    * Still breaking something

    * Simplifications still work

    * Simplifications still work

    * Fixes bug

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>

commit 8ec2172
Author: Nicolas Quesada <[email protected]>
Date:   Wed Nov 29 15:53:11 2023 -0500

    Implements the Montrealer (#374)

    * Saving changes

    * Passes black

    * Passes black

    * Black

    * updates acknowledgements and changelog

    * updates acknowledgements and changelog

    * Adds montrealer

    * Adds Montrealer tests (#375)

    * Yanic the pirate

    * mtl test

    * mtl first tests

    * mtl test

    * test mtl

    * test montrealer

    * test montrealer

    * test Montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * tests montrealer

    * montrealer test

    * montrealer test

    * montrealer test

    * montrealer test

    * montrealer test

    * test montrealer

    * test montrealer

    * montrealer test

    * montrealer test

    * montrealer test

    * montrealer tests

    * montrealer tests

    * montrealer tests

    * montrealer tests

    * functions header update

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer ready for review

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer - failed tests

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * test montrealer

    * the rspms are now ordered

    * Passes black

    * garbage test file to be deleted later

    * minor changes

    * Done

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>

    * making bots happy

    * Apply suggestions from code review

    Co-authored-by: Sebastián Duque Mesa <[email protected]>

    * Apply suggestions from code review

    Co-authored-by: Sebastián Duque Mesa <[email protected]>

    * Apply suggestions from code review

    * Apply suggestions from code review

    Co-authored-by: Sebastián Duque Mesa <[email protected]>

    * Apply suggestions from code review

    Co-authored-by: Sebastián Duque Mesa <[email protected]>

    * Adds extra tests

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>
    Co-authored-by: Yanic Cardin <[email protected]>
    Co-authored-by: Sebastián Duque Mesa <[email protected]>

commit 0e163bf
Author: Nicolas Quesada <[email protected]>
Date:   Tue Aug 22 10:19:08 2023 -0400

    Update symplectic.py (#372)

    * Update decompositions.py

    * New takagi

    * New takagi

    * Passes black

    * Simplifies blochmessiah

    * Simplifies blochmessiah

    * Found a case that breaks Takagi

    * Fixes all the tests

    * Fixes issues found by the linter

    * Adds extra test

    * Adds extra test

    * dummy

    * dummy

    * Update symplectic.py

    Removes `autonne`

    * relocates test

    * trying to make pylint happy

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>

commit e999e49
Author: Nicolas Quesada <[email protected]>
Date:   Thu Aug 17 12:55:45 2023 -0400

    Better way to determine if a matrix is a phase times a real matrix (#373)

    * Add a better way to determine if a matrix is a phase times a real matrix and tests

    * CHANGELOG updates

    ---------

    Co-authored-by: Nicolas Quesada <[email protected]>

* Revert "Squashed commit of the following:"

This reverts commit 0f99b20.

---------

Co-authored-by: Nicolas Quesada <[email protected]>
Co-authored-by: rachelchadwick <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants