Skip to content

FockBasics ​

Truncated number-basis construction, validation and truncation

8/8 passed in 78ms

TestWhat it doesResult
test_axis_uniformA non-uniform axis is refused on p as on x, and |1> scores 0.4262 on an even grid.✅ pass
test_fock_ladder|n> carries all its population on level n, with mean photon number n, purity 1, parity (-1)^n and nothing discarded.✅ pass
test_kernel_rangeA coherent state at x = 28 in 512 levels peaks at 1/pi with no NaN, and the Wigner kernel stays finite out to radius 150.✅ pass
test_matrix_validatedfrom_matrix refuses non-Hermitian, non-unit-trace, negative-eigenvalue and non-square matrices, and the cutoff, level index, GKP squeezing and axis slots go the same way.✅ pass
test_spectrum_settlesThe 512-level thermal entropy is g(nbar) to 1e-6 in under 5 s, with the spectrum still non-negative.✅ pass
test_states_physicalEvery constructor returns a physical state, the pure ones at purity 1 and a lossy thermal state below it.✅ pass
test_truncation_firesAn 18-photon coherent state reads truncated at cutoffs 8 and 20 and clean at 60, and tail() fires on a state displaced against its ceiling that discarded() calls clean.✅ pass
test_vacuum_peaksThe vacuum Wigner peaks at 1/pi and its Husimi at 1/(2 pi) under dx dp, both integrating to 1.✅ pass