XanaduAI / thewalrus

A library for the calculation of hafnians, Hermite polynomials and Gaussian boson sampling.
https://the-walrus.readthedocs.io
Apache License 2.0
99 stars 54 forks source link

[hotfix] create sparse or dense identity matrix accordingly #350

Closed sduquemesa closed 1 year ago

sduquemesa commented 1 year ago

Context: PR #347 introduced support for scipy's sparse matrices on the expand function. When dealing with such, first a dense identity matrix is created before checking if sparse matrices are used, the creation of this dense matrix leads to memory errors for large matrices.

Description of the Change: Create the identity matrix accordingly (sparse or dense).

Benefits: Avoids memory issues.

Possible Drawbacks: None

Related GitHub Issues: None

codecov[bot] commented 1 year ago

Codecov Report

Merging #350 (19eee98) into master (84d04dc) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #350   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines         1737      1735    -2     
=========================================
- Hits          1737      1735    -2     
Impacted Files Coverage Δ
thewalrus/symplectic.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

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