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

pauli refactor #539

Merged
merged 5 commits into from
Apr 9, 2024
Merged

pauli refactor #539

merged 5 commits into from
Apr 9, 2024

Conversation

Bchass
Copy link
Contributor

@Bchass Bchass commented Apr 5, 2024

Description

Closes: #529

I left is_sparse in for the moment even though it's not technically being used in pauli.py due to the test cases relying on True or False. Would it make sense to completely remove is_sparse and drop True from the test cases? @purva-thakre I believe so, but drafting this for PR for now.

Changes

  • Remove csr_matrix

Checklist

  • Use ruff and pylint for errors related to code style and formatting.
  • Verify all previous and newly added unit tests pass in pytest.
  • Check the documentation build does not lead to any failures. Sphinx build can be checked locally for any failures related to your PR
  • Use linkcheck to check for broken links in the documentation
  • Use doctest to verify the examples in the function docstrings work as expected.

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.1%. Comparing base (0dc6d54) to head (1ad3cb7).
Report is 1 commits behind head on master.

Additional details and impacted files
@@          Coverage Diff           @@
##           master    #539   +/-   ##
======================================
  Coverage    98.1%   98.1%           
======================================
  Files         160     162    +2     
  Lines        3084    3112   +28     
  Branches      750     760   +10     
======================================
+ Hits         3026    3054   +28     
  Misses         37      37           
  Partials       21      21           

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

@Bchass Bchass marked this pull request as ready for review April 6, 2024 13:30
def pauli(ind: int | str | list[int] | list[str], is_sparse: bool = False) -> np.ndarray | sparse.csr_matrix:
def pauli(ind: int | str | list[int] | list[str], is_sparse: bool = False) -> csr_array:
Copy link
Collaborator

@purva-thakre purva-thakre Apr 6, 2024

Choose a reason for hiding this comment

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

Why remove np.ndarray? You get a csr_array for the output only when we provide is_sparse is not False.

I think you could use np.ndarray as the output type for all allowed input types if we use the .toarray() option at line 99. WDYT @vprusso ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking back to: #521 (comment) and that's why initially I removed is_sparse and made some changes to the test cases. But I'll wait for a further response.

Copy link
Collaborator

@purva-thakre purva-thakre Apr 6, 2024

Choose a reason for hiding this comment

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

Yes, but issparse is a method for both sparse array and sparse matrix types. So, the structure of the function shouldn't change that much in this PR. Before, the return type was an array or a sparse matrix. Now, it can be an np.ndarray for all options of allowed inputs.

https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.issparse.html#scipy.sparse.issparse

@purva-thakre purva-thakre added this to the v1.0.8 milestone Apr 6, 2024
Copy link
Collaborator

@purva-thakre purva-thakre left a comment

Choose a reason for hiding this comment

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

LGTM! I'll wait for @vprusso to Ok this before merging.

@vprusso
Copy link
Owner

vprusso commented Apr 9, 2024

Yep, all good here as well. Merge when ready! Thank you again for the contribution, @Bchass ! 🚀

@purva-thakre purva-thakre merged commit d1049fe into vprusso:master Apr 9, 2024
18 checks passed
@Bchass Bchass deleted the pauli_refactor branch April 9, 2024 01:14
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.

Remove csr_matrix in toqito/matrices/pauli.py
3 participants