qml-essentials 0.3.2__tar.gz → 0.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/CITATION.cff +2 -2
  2. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/PKG-INFO +2 -2
  3. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/coefficients.md +38 -2
  4. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/pyproject.toml +2 -2
  5. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/qml_essentials/coefficients.py +142 -67
  6. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/qml_essentials/model.py +4 -2
  7. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/conftest.py +4 -1
  8. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/test_ansaetze.py +0 -2
  9. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/test_coefficients.py +402 -4
  10. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/test_entanglement.py +0 -2
  11. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/test_expressiblity.py +0 -2
  12. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/test_math_model.py +0 -3
  13. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/test_model.py +24 -1
  14. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/test_random_sampling.py +0 -2
  15. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/test_states.py +0 -3
  16. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/uv.lock +38 -38
  17. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/CODEOWNERS +0 -0
  18. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  19. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/ISSUE_TEMPLATE/code-health.md +0 -0
  20. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  21. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/dependabot.yml +0 -0
  22. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/workflows/dependabot-approve.yml +0 -0
  23. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/workflows/docs-publish.yml +0 -0
  24. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/workflows/docs.yml +0 -0
  25. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/workflows/publish.yml +0 -0
  26. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/workflows/quality-publish.yml +0 -0
  27. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/workflows/quality.yml +0 -0
  28. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/workflows/test-on-pr.yml +0 -0
  29. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.github/workflows/test-on-publish.yml +0 -0
  30. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.gitignore +0 -0
  31. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/.pre-commit-config.yaml +0 -0
  32. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/CONTRIBUTING.md +0 -0
  33. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/LICENSE +0 -0
  34. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/README.md +0 -0
  35. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/algebra.md +0 -0
  36. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/ansaetze.ipynb +0 -0
  37. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/ansaetze.md +0 -0
  38. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/coefficients.ipynb +0 -0
  39. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/diagrams.drawio +0 -0
  40. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/entanglement.md +0 -0
  41. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/expressibility.md +0 -0
  42. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/bloch-sphere.svg +0 -0
  43. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuit_tikz_dark.png +0 -0
  44. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuit_tikz_light.png +0 -0
  45. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_10_dark.png +0 -0
  46. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_10_light.png +0 -0
  47. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_13_dark.png +0 -0
  48. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_13_light.png +0 -0
  49. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_14_dark.png +0 -0
  50. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_14_light.png +0 -0
  51. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_15_dark.png +0 -0
  52. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_15_light.png +0 -0
  53. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_16_dark.png +0 -0
  54. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_16_light.png +0 -0
  55. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_17_dark.png +0 -0
  56. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_17_light.png +0 -0
  57. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_18_dark.png +0 -0
  58. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_18_light.png +0 -0
  59. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_19_dark.png +0 -0
  60. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_19_light.png +0 -0
  61. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_1_dark.png +0 -0
  62. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_1_light.png +0 -0
  63. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_20_dark.png +0 -0
  64. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_20_light.png +0 -0
  65. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_2_dark.png +0 -0
  66. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_2_light.png +0 -0
  67. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_3_dark.png +0 -0
  68. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_3_light.png +0 -0
  69. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_4_dark.png +0 -0
  70. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_4_light.png +0 -0
  71. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_5_dark.png +0 -0
  72. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_5_light.png +0 -0
  73. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_6_dark.png +0 -0
  74. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_6_light.png +0 -0
  75. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_7_dark.png +0 -0
  76. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_7_light.png +0 -0
  77. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_8_dark.png +0 -0
  78. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_8_light.png +0 -0
  79. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_9_dark.png +0 -0
  80. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Circuit_9_light.png +0 -0
  81. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/GHZ_dark.png +0 -0
  82. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/GHZ_light.png +0 -0
  83. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Hardware_Efficient_dark.png +0 -0
  84. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Hardware_Efficient_light.png +0 -0
  85. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/No_Ansatz_dark.png +0 -0
  86. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/No_Ansatz_light.png +0 -0
  87. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/No_Entangling_dark.png +0 -0
  88. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/No_Entangling_light.png +0 -0
  89. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Strongly_Entangling_dark.png +0 -0
  90. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_4q/Strongly_Entangling_light.png +0 -0
  91. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_10_dark.png +0 -0
  92. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_10_light.png +0 -0
  93. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_13_dark.png +0 -0
  94. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_13_light.png +0 -0
  95. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_14_dark.png +0 -0
  96. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_14_light.png +0 -0
  97. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_15_dark.png +0 -0
  98. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_15_light.png +0 -0
  99. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_16_dark.png +0 -0
  100. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_16_light.png +0 -0
  101. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_17_dark.png +0 -0
  102. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_17_light.png +0 -0
  103. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_18_dark.png +0 -0
  104. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_18_light.png +0 -0
  105. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_19_dark.png +0 -0
  106. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_19_light.png +0 -0
  107. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_1_dark.png +0 -0
  108. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_1_light.png +0 -0
  109. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_20_dark.png +0 -0
  110. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_20_light.png +0 -0
  111. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_2_dark.png +0 -0
  112. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_2_light.png +0 -0
  113. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_3_dark.png +0 -0
  114. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_3_light.png +0 -0
  115. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_4_dark.png +0 -0
  116. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_4_light.png +0 -0
  117. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_5_dark.png +0 -0
  118. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_5_light.png +0 -0
  119. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_6_dark.png +0 -0
  120. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_6_light.png +0 -0
  121. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_7_dark.png +0 -0
  122. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_7_light.png +0 -0
  123. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_8_dark.png +0 -0
  124. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_8_light.png +0 -0
  125. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_9_dark.png +0 -0
  126. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Circuit_9_light.png +0 -0
  127. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/GHZ_dark.png +0 -0
  128. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/GHZ_light.png +0 -0
  129. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Hardware_Efficient_dark.png +0 -0
  130. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Hardware_Efficient_light.png +0 -0
  131. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/No_Ansatz_dark.png +0 -0
  132. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/No_Ansatz_light.png +0 -0
  133. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/No_Entangling_dark.png +0 -0
  134. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/No_Entangling_light.png +0 -0
  135. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Strongly_Entangling_dark.png +0 -0
  136. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_5q/Strongly_Entangling_light.png +0 -0
  137. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_10_dark.png +0 -0
  138. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_10_light.png +0 -0
  139. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_13_dark.png +0 -0
  140. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_13_light.png +0 -0
  141. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_14_dark.png +0 -0
  142. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_14_light.png +0 -0
  143. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_15_dark.png +0 -0
  144. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_15_light.png +0 -0
  145. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_16_dark.png +0 -0
  146. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_16_light.png +0 -0
  147. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_17_dark.png +0 -0
  148. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_17_light.png +0 -0
  149. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_18_dark.png +0 -0
  150. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_18_light.png +0 -0
  151. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_19_dark.png +0 -0
  152. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_19_light.png +0 -0
  153. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_1_dark.png +0 -0
  154. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_1_light.png +0 -0
  155. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_20_dark.png +0 -0
  156. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_20_light.png +0 -0
  157. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_2_dark.png +0 -0
  158. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_2_light.png +0 -0
  159. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_3_dark.png +0 -0
  160. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_3_light.png +0 -0
  161. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_4_dark.png +0 -0
  162. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_4_light.png +0 -0
  163. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_5_dark.png +0 -0
  164. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_5_light.png +0 -0
  165. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_6_dark.png +0 -0
  166. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_6_light.png +0 -0
  167. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_7_dark.png +0 -0
  168. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_7_light.png +0 -0
  169. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_8_dark.png +0 -0
  170. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_8_light.png +0 -0
  171. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_9_dark.png +0 -0
  172. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Circuit_9_light.png +0 -0
  173. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/GHZ_dark.png +0 -0
  174. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/GHZ_light.png +0 -0
  175. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Hardware_Efficient_dark.png +0 -0
  176. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Hardware_Efficient_light.png +0 -0
  177. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/No_Ansatz_dark.png +0 -0
  178. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/No_Ansatz_light.png +0 -0
  179. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/No_Entangling_dark.png +0 -0
  180. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/No_Entangling_light.png +0 -0
  181. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Strongly_Entangling_dark.png +0 -0
  182. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/circuits_6q/Strongly_Entangling_light.png +0 -0
  183. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/code.svg +0 -0
  184. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/fourier_fingerprint_dark.png +0 -0
  185. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/fourier_fingerprint_light.png +0 -0
  186. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/fourier_series_dark.png +0 -0
  187. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/fourier_series_light.png +0 -0
  188. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/fourier_series_tf_dark.png +0 -0
  189. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/fourier_series_tf_light.png +0 -0
  190. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/histogram.svg +0 -0
  191. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/invert_images.sh +0 -0
  192. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_2d_psd_dark.png +0 -0
  193. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_2d_psd_light.png +0 -0
  194. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_fct_dark.png +0 -0
  195. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_fct_light.png +0 -0
  196. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_fct_spectr_dark.png +0 -0
  197. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_fct_spectr_light.png +0 -0
  198. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_fct_spectr_os_dark.png +0 -0
  199. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_fct_spectr_os_light.png +0 -0
  200. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_fct_spectr_ours_dark.png +0 -0
  201. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_fct_spectr_ours_light.png +0 -0
  202. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_psd_an_dark.png +0 -0
  203. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_psd_an_light.png +0 -0
  204. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_psd_dark.png +0 -0
  205. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/model_psd_light.png +0 -0
  206. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/rel-entropy.svg +0 -0
  207. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/trained_series_dark.png +0 -0
  208. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/trained_series_dataset_dark.png +0 -0
  209. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/trained_series_dataset_light.png +0 -0
  210. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/trained_series_light.png +0 -0
  211. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/trained_series_tf_dark.png +0 -0
  212. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/figures/trained_series_tf_light.png +0 -0
  213. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/generate_circuits.py +0 -0
  214. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/index.md +0 -0
  215. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/javascripts/mathjax.js +0 -0
  216. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/logo.svg +0 -0
  217. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/metrics.ipynb +0 -0
  218. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/noise.md +0 -0
  219. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/pulses.md +0 -0
  220. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/random_sampling.md +0 -0
  221. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/references.md +0 -0
  222. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/style.css +0 -0
  223. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/training.ipynb +0 -0
  224. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/training.md +0 -0
  225. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/usage.ipynb +0 -0
  226. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/docs/usage.md +0 -0
  227. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/mkdocs.yml +0 -0
  228. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/qml_essentials/__init__.py +0 -0
  229. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/qml_essentials/algebra.py +0 -0
  230. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/qml_essentials/ansaetze.py +0 -0
  231. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/qml_essentials/entanglement.py +0 -0
  232. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/qml_essentials/expressibility.py +0 -0
  233. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/qml_essentials/pauli.py +0 -0
  234. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/qml_essentials/random_sampling.py +0 -0
  235. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/qml_essentials/states.py +0 -0
  236. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/qml_essentials/topologies.py +0 -0
  237. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/qml_essentials/trainability.py +0 -0
  238. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/__init__.py +0 -0
  239. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/test_algebra.py +0 -0
  240. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/test_matchgate_migration.py +0 -0
  241. {qml_essentials-0.3.2 → qml_essentials-0.3.3}/tests/test_pauli_circuit.py +0 -0
@@ -21,8 +21,8 @@ authors:
21
21
  - family-names: "Wahl"
22
22
  given-names: "Johannes"
23
23
  title: "QML Essentials"
24
- version: 0.3.2
25
- date-released: 2026-11-09
24
+ version: 0.3.3
25
+ date-released: 2026-11-26
26
26
  repository-code: "https://github.com/cirKITers/qml-essentials"
27
27
  url: "https://cirkiters.github.io/qml-essentials"
28
28
  license: MIT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: qml-essentials
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: A toolbox to make working with QML models easier.
5
5
  Project-URL: Homepage, https://cirkiters.github.io/qml-essentials/
6
6
  Project-URL: Repository, https://github.com/cirKITers/qml-essentials
@@ -21,7 +21,7 @@ Classifier: Programming Language :: Python :: 3.13
21
21
  Classifier: Programming Language :: Python :: 3.14
22
22
  Classifier: Topic :: Scientific/Engineering :: Physics
23
23
  Requires-Python: <3.15,>=3.12
24
- Requires-Dist: jaqsi>=0.1.1
24
+ Requires-Dist: jaqsi>=0.1.2
25
25
  Requires-Dist: jax>=0.9.0.1
26
26
  Requires-Dist: jaxlib>=0.9.0.1
27
27
  Requires-Dist: numpy>=2.0.0
@@ -87,7 +87,7 @@ You might have noticed that we choose our sampling frequency `fs` in such a way,
87
87
  Also the number of samples `x` are just enough to sufficiently represent our function.
88
88
  In such a simplified scenario, this is fine, but there are cases, where we want to have more information both in the time and frequency domain.
89
89
  Therefore, two additional arguments exist in the `get_spectrum` method:
90
- - `mfs`: The multiplier for the highest frequency. Increasing this will increase the width of the spectrum
90
+ - `mfs`: The multiplier for the highest frequency. Increasing this will increase the width of the spectrum, either globally or per input feature (see below)
91
91
  - `mts`: The multiplier for the number of time samples. Increasing this will increase the resolution of the time domain and therefore "add" frequencies in between our original frequencies.
92
92
  - `trim`: Whether to remove the Nyquist frequency if spectrum is even. This will result in a symmetric spectrum
93
93
 
@@ -285,9 +285,45 @@ Using a logarithmic color bar, one obtains the following 2D-spectrum:
285
285
 
286
286
  Note that "X1" refers to the "RX" encoding and "X2" to the "RY" encoding.
287
287
 
288
- In the multidimensional case, the `freqs` variable now contains the frequency indices for each dimension.
288
+ In the multidimensional case, `freqs` is a list with one frequency vector per input feature, independent of `shift`.
289
289
  This is an important detail, as due to the `data_reupload` argument, it is possible to have a different number of frequencies for each input dimension.
290
290
 
291
+ ### Ragged frequency grids
292
+
293
+ In the multidimensional case, the per-axis degrees, and therefore the per-axis frequency grids, do not have to match: due to the `data_reupload` argument, each input feature can be encoded on a different number of wires, which is the generic case rather than an edge case.
294
+
295
+ The full pipeline, i.e. `Coefficients.get_spectrum` as well as `FCC.get_fcc` and `FCC.get_fourier_fingerprint`, supports these *ragged* frequency grids:
296
+
297
+ ```python
298
+ model = Model(
299
+ n_qubits=2,
300
+ n_layers=2,
301
+ circuit_type="Circuit_19",
302
+ encoding=["RX", "RY"],
303
+ data_reupload=[
304
+ [[True, True], [False, True]],
305
+ [[False, True], [True, True]],
306
+ ],
307
+ )
308
+ # model.degree == (5, 9)
309
+
310
+ coeffs, freqs = Coefficients.get_spectrum(model)
311
+ # coeffs reshapes to one axis per input feature; freqs holds one
312
+ # frequency vector per axis with different lengths
313
+ ```
314
+
315
+ The coefficients follow the ij/C-order convention: one axis per input feature with the first feature being the slowest, and the per-coefficient frequency tuples use the same order.
316
+
317
+ Oversampling can also be applied per axis, by passing `mfs` either as a single factor (applied to every feature) or as one factor per feature:
318
+
319
+ ```python
320
+ coeffs, freqs = Coefficients.get_spectrum(model, mfs=[1, 2])
321
+ # grid of shape (5, 18)
322
+ ```
323
+
324
+ A list with the wrong length raises a `ValueError`.
325
+ Similarly, `trim` removes the Nyquist entry of each even-length axis at that axis's own position.
326
+
291
327
  ## Fourier Coefficient Correlation (FCC)
292
328
 
293
329
  The FCC, as introduced in [Fourier Fingerprints of Ansatzes in Quantum Machine Learning](https://doi.org/10.48550/arXiv.2508.20868), is a metric that aims to predict the expected performance of an arbitrary Ansatz based on the the correlation between its Fourier modes.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "qml-essentials"
3
- version = "0.3.2"
3
+ version = "0.3.3"
4
4
  description = "A toolbox to make working with QML models easier."
5
5
  authors = [
6
6
  { name = "Melvin Strobl", email = "melvin.strobl@kit.edu" },
@@ -16,7 +16,7 @@ keywords = [
16
16
  "qml",
17
17
  ]
18
18
  dependencies = [
19
- "jaqsi>=0.1.1",
19
+ "jaqsi>=0.1.2",
20
20
  "jax>=0.9.0.1",
21
21
  "jaxlib>=0.9.0.1",
22
22
  "numpy>=2.0.0",
@@ -25,13 +25,13 @@ class Coefficients:
25
25
  def get_spectrum(
26
26
  cls,
27
27
  model: Model,
28
- mfs: int = 1,
28
+ mfs: Union[int, List[int]] = 1,
29
29
  mts: int = 1,
30
30
  shift=False,
31
31
  trim=False,
32
32
  numerical_cap: Optional[float] = -1,
33
33
  **kwargs,
34
- ) -> Tuple[jnp.ndarray, jnp.ndarray]:
34
+ ) -> Tuple[jnp.ndarray, Union[jnp.ndarray, List[jnp.ndarray]]]:
35
35
  """
36
36
  Extracts the coefficients of a given model using a FFT (jnp-fft).
37
37
 
@@ -44,7 +44,9 @@ class Coefficients:
44
44
 
45
45
  Args:
46
46
  model (Model): The model to sample.
47
- mfs (int): Multiplicator for the highest frequency. Default is 1.
47
+ mfs (Union[int, List[int]]): Multiplicator for the highest
48
+ frequency. Either a single factor applied to every input
49
+ feature, or one factor per input feature. Default is 1.
48
50
  mts (int): Multiplicator for the number of time samples. Default is 1.
49
51
  shift (bool): Whether to apply jnp-fftshift. Default is False.
50
52
  trim (bool): Whether to remove the Nyquist frequency if spectrum is even.
@@ -56,8 +58,11 @@ class Coefficients:
56
58
  kwargs (Any): Additional keyword arguments for the model function.
57
59
 
58
60
  Returns:
59
- Tuple[jnp.ndarray, jnp.ndarray]: Tuple containing the coefficients
60
- and frequencies.
61
+ Tuple[jnp.ndarray, Union[jnp.ndarray, List[jnp.ndarray]]]: The
62
+ coefficients, with one leading axis per input feature, and the
63
+ frequencies. For multiple input features, the frequencies are a
64
+ list with one vector per input feature, independent of `shift`;
65
+ for a single input feature, they are a single vector.
61
66
 
62
67
  Note:
63
68
  The FFT grid is built from the nominal `model.degree`, which does
@@ -66,6 +71,14 @@ class Coefficients:
66
71
  the nominal degree by a factor $s > 1$, choose `mfs` at least
67
72
  $\\lceil s \\rceil$ (e.g. `mfs=2` covers scalings up to 2),
68
73
  otherwise the scaled components alias.
74
+
75
+ Multi-feature input (d >= 2) is supported for per-axis frequency
76
+ vectors of different lengths (the generic case, since per-axis
77
+ degrees need not coincide). The grid and the returned frequency
78
+ labels follow the ij/C-order convention (meshgrid
79
+ ``indexing="ij"``, flattened row-major, first input feature
80
+ slowest). `trim` removes the Nyquist entry of each even-length axis
81
+ at that axis's own position.
69
82
  """
70
83
  kwargs.setdefault("force_mean", True)
71
84
  kwargs.setdefault("execution_type", "expval")
@@ -79,14 +92,19 @@ class Coefficients:
79
92
  )
80
93
 
81
94
  if trim:
95
+ # Per-axis Nyquist removal: each frequency axis is trimmed at
96
+ # its own length.
82
97
  for ax in range(model.n_input_feat):
83
98
  if coeffs.shape[ax] % 2 == 0:
84
- coeffs = np.delete(coeffs, len(coeffs) // 2, axis=ax)
85
- freqs = [np.delete(freq, len(freq) // 2, axis=ax) for freq in freqs]
99
+ nyquist = coeffs.shape[ax] // 2
100
+ coeffs = np.delete(coeffs, nyquist, axis=ax)
101
+ freqs[ax] = np.delete(freqs[ax], nyquist)
86
102
 
87
103
  if shift:
88
104
  coeffs = jnp.fft.fftshift(coeffs, axes=list(range(model.n_input_feat)))
89
- freqs = np.fft.fftshift(freqs)
105
+ # per-axis shift: a global fftshift on the ragged list of
106
+ # per-axis frequency vectors fails for multi-dim input
107
+ freqs = [np.fft.fftshift(f) for f in freqs]
90
108
 
91
109
  if numerical_cap > 0:
92
110
  # set coeffs below threshold to zero
@@ -115,12 +133,25 @@ class Coefficients:
115
133
 
116
134
  @classmethod
117
135
  def _fourier_transform(
118
- cls, model: Model, mfs: int, mts: int, **kwargs: Any
119
- ) -> jnp.ndarray:
136
+ cls, model: Model, mfs: Union[int, List[int]], mts: int, **kwargs: Any
137
+ ) -> Tuple[jnp.ndarray, List]:
138
+ # Per-axis oversampling: mfs may be a single integer factor (applied to
139
+ # every axis) or one per input feature.
140
+ mfs_axis = np.asarray(mfs)
141
+ if not np.issubdtype(mfs_axis.dtype, np.integer):
142
+ raise TypeError(f"mfs factors must be integers, got {mfs}")
143
+ if mfs_axis.ndim == 0:
144
+ mfs_axis = np.full(model.n_input_feat, mfs_axis)
145
+ elif mfs_axis.shape != (model.n_input_feat,):
146
+ raise ValueError(
147
+ f"mfs must be an int or one factor per input feature "
148
+ f"({model.n_input_feat}), got {mfs}"
149
+ )
150
+
120
151
  # Create a frequency vector with as many frequencies as model degrees,
121
152
  # oversampled by mfs
122
153
  n_freqs: jnp.ndarray = jnp.array(
123
- [mfs * model.degree[i] for i in range(model.n_input_feat)]
154
+ [mfs_axis[i] * model.degree[i] for i in range(model.n_input_feat)]
124
155
  )
125
156
 
126
157
  start, stop, step = 0, 2 * mts * jnp.pi, 2 * jnp.pi / n_freqs
@@ -129,16 +160,27 @@ class Coefficients:
129
160
  jnp.arange(start, stop, step[i]) for i in range(model.n_input_feat)
130
161
  ]
131
162
 
132
- # permute with input dimensionality
133
- nd_inputs = jnp.array(
134
- jnp.meshgrid(*[inputs[i] for i in range(model.n_input_feat)])
135
- ).T.reshape(-1, model.n_input_feat)
163
+ # Grid in ij/C order: meshgrid(indexing="ij") stacked on the last axis
164
+ # and flattened row-major, so the first input feature is the slowest
165
+ # and the last the fastest. This keeps the flat ordering aligned with
166
+ # the coefficient reshape, the frequency labels and the FFT axes, and
167
+ # supports per-axis vectors of different lengths (the generic
168
+ # multi-feature case).
169
+ nd_inputs = jnp.stack(jnp.meshgrid(*inputs, indexing="ij"), axis=-1).reshape(
170
+ -1, model.n_input_feat
171
+ )
136
172
 
137
- # Output vector is not necessarily the same length as input
173
+ # Output vector is not necessarily the same length as input.
174
+ # The leading axes are the flattened frequency grid: reshape to the
175
+ # per-axis sizes and drop the trailing axis if it has size 1 (e.g. a
176
+ # single observable). A bare .squeeze() would also collapse size-1
177
+ # frequency axes and misalign the FFT axes for degree-1 features.
138
178
  outputs = model(inputs=nd_inputs, **kwargs)
139
179
  outputs = outputs.reshape(
140
180
  *[inputs[i].shape[0] for i in range(model.n_input_feat)], -1
141
- ).squeeze()
181
+ )
182
+ if outputs.shape[-1] == 1:
183
+ outputs = outputs.squeeze(axis=-1)
142
184
 
143
185
  coeffs = jnp.fft.fftn(outputs, axes=list(range(model.n_input_feat)))
144
186
 
@@ -146,12 +188,9 @@ class Coefficients:
146
188
  jnp.fft.fftfreq(int(mts * n_freqs[i]), 1 / n_freqs[i])
147
189
  for i in range(model.n_input_feat)
148
190
  ]
149
- # freqs = jnp.fft.fftfreq(mts * n_freqs, 1 / n_freqs)
150
191
 
151
- # TODO: this could cause issues with multidim input
152
- # FIXME: account for different frequencies in multidim input scenarios
153
- # Run the fft and rearrange +
154
- # normalize the output (using product if multidim)
192
+ # Normalize by the frequency-grid size (the batch axis, if any, is
193
+ # not part of the grid).
155
194
  return (
156
195
  coeffs / math.prod(outputs.shape[0 : model.n_input_feat]),
157
196
  freqs,
@@ -1158,8 +1197,10 @@ class FCC:
1158
1197
  frequencies are returned as a `(row_freqs, col_freqs)` tuple that
1159
1198
  labels the two (redundancy-trimmed) matrix axes and the
1160
1199
  coefficients as a matching `(row_coeffs, col_coeffs)` tuple whose
1161
- rows align with those frequencies; otherwise the full frequency
1162
- vector and full coefficient array are returned.
1200
+ rows align with those frequencies; otherwise the frequencies as
1201
+ given by `Coefficients.get_spectrum` (a 1-D vector for one input
1202
+ feature, a list of per-axis vectors otherwise) and the full
1203
+ coefficient array are returned.
1163
1204
  """
1164
1205
  _, coeffs, freqs = cls._calculate_coefficients(
1165
1206
  model, n_samples, random_key, scale, **kwargs
@@ -1199,7 +1240,11 @@ class FCC:
1199
1240
  (coeffs_sub[row_mask], coeffs_sub[col_mask]),
1200
1241
  )
1201
1242
 
1202
- fourier_fingerprint = cls._correlate(coeffs.transpose(), method=method)
1243
+ # Flatten in C order, like the fast path, so `_calculate_mask` indices
1244
+ # address the matching rows/cols.
1245
+ fourier_fingerprint = cls._correlate(
1246
+ coeffs.reshape(-1, coeffs.shape[-1]).transpose(), method=method
1247
+ )
1203
1248
 
1204
1249
  if nan_to_one:
1205
1250
  # set nan to 1
@@ -1260,8 +1305,40 @@ class FCC:
1260
1305
  # apply the mask on the fingerprint
1261
1306
  return jnp.nanmean(jnp.abs(fourier_fingerprint))
1262
1307
 
1308
+ @staticmethod
1309
+ def _per_axis_frequencies(
1310
+ freqs: Union[jnp.ndarray, List[jnp.ndarray]],
1311
+ ) -> List[jnp.ndarray]:
1312
+ """
1313
+ Normalize a frequency container into a list of per-axis frequency
1314
+ vectors.
1315
+
1316
+ Accepts a ragged list/tuple of per-axis vectors (the generic
1317
+ multi-feature case, where axis lengths differ), a 1-D vector
1318
+ (single input feature, also as a plain list of scalars), or a
1319
+ ``(n_input_feat, K)`` stack of equal length vectors.
1320
+
1321
+ Args:
1322
+ freqs (Union[jnp.ndarray, List[jnp.ndarray]]): Frequency
1323
+ container as described above.
1324
+
1325
+ Returns:
1326
+ List[jnp.ndarray]: One frequency vector per input feature.
1327
+ """
1328
+ if isinstance(freqs, (list, tuple)) and np.ndim(freqs[0]) > 0:
1329
+ # Ragged per-axis frequency vectors: a global jnp.asarray fails
1330
+ # on unequal axis lengths, so consume the per-axis list directly.
1331
+ # A plain list of scalars is a single axis and falls through.
1332
+ return [jnp.asarray(f) for f in freqs]
1333
+ fa = jnp.asarray(freqs)
1334
+ if fa.ndim == 1:
1335
+ return [fa]
1336
+ return [fa[i] for i in range(fa.shape[0])]
1337
+
1263
1338
  @classmethod
1264
- def _calculate_mask(cls, freqs: jnp.ndarray) -> jnp.ndarray:
1339
+ def _calculate_mask(
1340
+ cls, freqs: Union[jnp.ndarray, List[jnp.ndarray]]
1341
+ ) -> jnp.ndarray:
1265
1342
  """
1266
1343
  Determine the flat indices of the Fourier correlation matrix
1267
1344
  that lie on a non-negative-frequency row/column. Together with
@@ -1279,60 +1356,57 @@ class FCC:
1279
1356
  self-correlations).
1280
1357
 
1281
1358
  Args:
1282
- freqs (jnp.ndarray): Array of frequencies. Either a 1-D
1283
- vector (single input feature) or a 2-D array of shape
1284
- ``(n_input_feat, K)`` whose rows are the per-axis
1285
- frequency vectors.
1359
+ freqs (Union[jnp.ndarray, List[jnp.ndarray]]): Frequencies.
1360
+ Either a 1-D vector (single input feature), a
1361
+ ``(n_input_feat, K)`` stack or a ragged list whose rows are
1362
+ the per-axis frequency vectors (multi-dim input).
1286
1363
 
1287
1364
  Returns:
1288
1365
  jnp.ndarray: 1-D int array of flat indices selecting the
1289
1366
  non-negative-frequency rows/cols of the fingerprint.
1290
1367
  """
1291
- freqs_arr = jnp.asarray(freqs)
1368
+ axes = cls._per_axis_frequencies(freqs)
1292
1369
 
1293
- if freqs_arr.ndim == 1:
1294
- pos_flat = freqs_arr >= 0
1370
+ if len(axes) == 1:
1371
+ pos_flat = axes[0] >= 0
1295
1372
  else:
1296
- # N-D case: build the per-axis non-negativity masks and
1297
- # combine them via broadcasting (no float `jnp.outer`!),
1298
- # then flatten to match the row-major flattening used by
1299
- # the upstream coefficient/correlation pipeline.
1300
- axes_pos = [freqs_arr[i] >= 0 for i in range(freqs_arr.shape[0])]
1301
- expanded = []
1302
- n_axes = len(axes_pos)
1303
- for i, p in enumerate(axes_pos):
1304
- shape = [1] * n_axes
1305
- shape[i] = p.shape[0]
1306
- expanded.append(p.reshape(shape))
1307
- nd_pos = reduce(jnp.logical_and, expanded)
1373
+ # Multi-axis case: build the per-axis non-negativity masks and
1374
+ # combine them via meshgrid (no float `jnp.outer`!), then
1375
+ # flatten row-major to match the C-order flattening used by
1376
+ # the coefficient/correlation pipeline.
1377
+ grids = jnp.meshgrid(*[axis >= 0 for axis in axes], indexing="ij")
1378
+ nd_pos = reduce(jnp.logical_and, grids)
1308
1379
  pos_flat = nd_pos.flatten()
1309
1380
 
1310
1381
  return jnp.where(pos_flat)[0]
1311
1382
 
1312
1383
  @classmethod
1313
- def _flat_frequencies(cls, freqs: jnp.ndarray) -> jnp.ndarray:
1384
+ def _flat_frequencies(
1385
+ cls, freqs: Union[jnp.ndarray, List[jnp.ndarray]]
1386
+ ) -> jnp.ndarray:
1314
1387
  """
1315
1388
  Build the per-coefficient flat frequency labels in the same
1316
1389
  C-order used to flatten the coefficient/correlation pipeline, so
1317
1390
  they can be indexed by the flat indices from `_calculate_mask`.
1318
1391
 
1319
1392
  Args:
1320
- freqs (jnp.ndarray): Either a 1-D vector (single input feature)
1321
- or a ``(n_input_feat, K)`` stack / list of per-axis frequency
1322
- vectors (multi-dim input).
1393
+ freqs (Union[jnp.ndarray, List[jnp.ndarray]]): Either a 1-D
1394
+ vector (single input feature) or a ``(n_input_feat, K)``
1395
+ stack / ragged list of per-axis frequency vectors
1396
+ (multi-dim input).
1323
1397
 
1324
1398
  Returns:
1325
1399
  jnp.ndarray: 1-D frequency vector (single input feature) or a
1326
1400
  ``(N, n_input_feat)`` array of per-coefficient frequency
1327
1401
  tuples (multi-dim input).
1328
1402
  """
1329
- fa = jnp.asarray(freqs)
1330
- if fa.ndim == 1:
1331
- return fa
1403
+ axes = cls._per_axis_frequencies(freqs)
1404
+ if len(axes) == 1:
1405
+ return axes[0]
1332
1406
  # Multi-dim: per-axis vectors -> flat grid of frequency tuples in the
1333
1407
  # same C-order used by `_calculate_mask` and the coefficient reshape.
1334
- grids = jnp.meshgrid(*[fa[i] for i in range(fa.shape[0])], indexing="ij")
1335
- return jnp.stack(grids, axis=-1).reshape(-1, fa.shape[0])
1408
+ grids = jnp.meshgrid(*axes, indexing="ij")
1409
+ return jnp.stack(grids, axis=-1).reshape(-1, len(axes))
1336
1410
 
1337
1411
  @classmethod
1338
1412
  def _calculate_coefficients(
@@ -1397,14 +1471,10 @@ class FCC:
1397
1471
  """
1398
1472
  assert len(mat.shape) >= 2, "Input matrix must have at least 2 dimensions"
1399
1473
 
1400
- # Note that for the general n-D case, we have to flatten along
1401
- # the first axis (last one is batch).
1402
- # Note that the order here is important so we can easily filter out
1403
- # negative coefficients later.
1404
- # Consider the following example: [[1,2,3],[4,5,6],[7,8,9]]
1405
- # we want to get [1, 4, 7, 2, 5, 8, 3, 6, 9]
1406
- # such that after correlation, all positive indexed coefficients
1407
- # will be in the bottom right quadrant
1474
+ # The first axis is the sample axis; any remaining axes are flattened
1475
+ # in C order. Callers pass coefficients already flattened in C order
1476
+ # (first input feature slowest), the order that `_calculate_mask`
1477
+ # and `_flat_frequencies` index into.
1408
1478
  if method == "pearson":
1409
1479
  result = cls._pearson(mat.reshape(mat.shape[0], -1))
1410
1480
  # result = cls._pearson(mat.reshape(mat.shape[-1], -1, order="F"))
@@ -1713,7 +1783,8 @@ class FCC:
1713
1783
  )
1714
1784
 
1715
1785
  coefficient_means = jnp.abs(jnp.mean(coeffs, axis=-1))
1716
- coefficient_means = coefficient_means.T.reshape(-1)
1786
+ # C order, matching the flattening of the correlated coefficients
1787
+ coefficient_means = coefficient_means.reshape(-1)
1717
1788
 
1718
1789
  assert fourier_fingerprint.shape[0] == coefficient_means.shape[0], (
1719
1790
  "Correlation matrix size must match the number of Fourier coefficients."
@@ -1826,9 +1897,11 @@ class Datasets:
1826
1897
  *[
1827
1898
  jnp.arange(0, 2 * mts * jnp.pi, 2 * jnp.pi / (mfs * d))
1828
1899
  for d in model.degree
1829
- ]
1830
- )
1831
- ).T.reshape(-1, model.n_input_feat)
1900
+ ],
1901
+ indexing="ij",
1902
+ ),
1903
+ axis=-1,
1904
+ ).reshape(-1, model.n_input_feat)
1832
1905
 
1833
1906
  @classmethod
1834
1907
  def construct_frequencies(
@@ -1904,7 +1977,9 @@ class Datasets:
1904
1977
  displace(model, i, sub_key, offgrid_prob, offgrid_resolution)
1905
1978
  )
1906
1979
 
1907
- return jnp.stack(jnp.meshgrid(*frequencies)).T.reshape(-1, model.n_input_feat)
1980
+ return jnp.stack(jnp.meshgrid(*frequencies, indexing="ij"), axis=-1).reshape(
1981
+ -1, model.n_input_feat
1982
+ )
1908
1983
 
1909
1984
  @classmethod
1910
1985
  def _offsets(
@@ -1987,7 +1987,8 @@ class Model:
1987
1987
 
1988
1988
  Uses the Pauli label where available and otherwise a hash of the
1989
1989
  matrix, memoized on the instance because reading the bytes copies the
1990
- full $2^n \\times 2^n$ array. Mutating a matrix in place is not
1990
+ full $2^n \\times 2^n$ array. The matrix is read at compile time, as
1991
+ this runs while a call is traced. Mutating a matrix in place is not
1991
1992
  detected.
1992
1993
 
1993
1994
  Args:
@@ -2000,7 +2001,8 @@ class Model:
2000
2001
  if label is not None:
2001
2002
  return label
2002
2003
  if getattr(obs, "_fingerprint_hash", None) is None:
2003
- obs._fingerprint_hash = hash(np.asarray(obs.matrix).tobytes())
2004
+ with jax.ensure_compile_time_eval():
2005
+ obs._fingerprint_hash = hash(np.asarray(obs.matrix).tobytes())
2004
2006
  return obs._fingerprint_hash
2005
2007
 
2006
2008
  def _structural_fingerprint(self) -> Tuple:
@@ -1,6 +1,9 @@
1
+ import jax
1
2
  import pytest
2
3
 
3
- from jaqsi.pulses import PulseInformation
4
+ jax.config.update("jax_enable_x64", True)
5
+
6
+ from jaqsi.pulses import PulseInformation # noqa: E402
4
7
 
5
8
 
6
9
  @pytest.fixture(autouse=True)
@@ -20,8 +20,6 @@ from jaqsi.gates import Gates, UnitaryGates
20
20
  from jaqsi.gates import PulseInformation as pinfo
21
21
  from jaqsi import gateset
22
22
 
23
- jax.config.update("jax_enable_x64", True)
24
-
25
23
 
26
24
  logger = logging.getLogger(__name__)
27
25