XanaduAI / thewalrus

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

Refactor `thewalrus.quantum` #197

Closed thisac closed 4 years ago

thisac commented 4 years ago

Look in the quantum/__init__.py file to get an overview for how the functions have been moved around.

Context: The Walrus quantum module (thewalrus.quantum) is currently a bit unwieldy due to the large number of functions in the same file. It needs to be refactored to a package with better organization.

Description of the Change: thewalrus.quantum.py is split up into several files collected in a folder/submodule named quantum. This folder contains the following files:

Furthermore, the following functions have been renamed, although the old names are still functional:

Means -> real_to_complex_displacements Beta -> complex_to_real_displacements prefactor -> _prefactor gen_multi_mode_dist -> _convolve_squeezed_state_distribution gen_single_mode_dist -> _squeezed_state_distribution total_photon_num_dist_pure_state -> pure_state_distribution

Benefits: The quantum submodule is much cleaner and clearer. Everything works the same way as it did before, only the names are updated.

Possible Drawbacks: The function renaming shouldn't cause any issues since the old names still function, although removing the old names shouldn't either since neither TW nor SF seem to use any of the renamed functions.

There are currently no circular imports, although this could be an issue if adding more functions to these files. One has to be careful when doing so! :octocat:

Related GitHub Issues: N/A

codecov[bot] commented 4 years ago

Codecov Report

Merging #197 into master will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #197   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        20    +6     
  Lines         1087      1131   +44     
=========================================
+ Hits          1087      1131   +44     
Impacted Files Coverage Δ
thewalrus/__init__.py 100.00% <100.00%> (ø)
thewalrus/quantum/__init__.py 100.00% <100.00%> (ø)
thewalrus/quantum/adjacency_matrices.py 100.00% <100.00%> (ø)
thewalrus/quantum/conversions.py 100.00% <100.00%> (ø)
thewalrus/quantum/fock_tensors.py 100.00% <100.00%> (ø)
thewalrus/quantum/gaussian_checks.py 100.00% <100.00%> (ø)
thewalrus/quantum/means_and_variances.py 100.00% <100.00%> (ø)
thewalrus/quantum/photon_number_distributions.py 100.00% <100.00%> (ø)
... and 5 more

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 49f675b...82cd63f. Read the comment docs.