qudas 0.1.0__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 (124) hide show
  1. qudas-0.1.0/LICENSE +233 -0
  2. qudas-0.1.0/MANIFEST.in +8 -0
  3. qudas-0.1.0/PKG-INFO +272 -0
  4. qudas-0.1.0/README.md +258 -0
  5. qudas-0.1.0/VERSION +1 -0
  6. qudas-0.1.0/docs/Makefile +20 -0
  7. qudas-0.1.0/docs/build/doctrees/environment.pickle +0 -0
  8. qudas-0.1.0/docs/build/doctrees/index.doctree +0 -0
  9. qudas-0.1.0/docs/build/doctrees/pipeline/index.doctree +0 -0
  10. qudas-0.1.0/docs/build/doctrees/pipeline/steps/base.doctree +0 -0
  11. qudas-0.1.0/docs/build/doctrees/pipeline/steps/iterator_mixin.doctree +0 -0
  12. qudas-0.1.0/docs/build/doctrees/pipeline/steps/optimizer_mixin.doctree +0 -0
  13. qudas-0.1.0/docs/build/doctrees/qudata/base.doctree +0 -0
  14. qudas-0.1.0/docs/build/doctrees/qudata/index.doctree +0 -0
  15. qudas-0.1.0/docs/build/doctrees/qudata/input.doctree +0 -0
  16. qudas-0.1.0/docs/build/doctrees/qudata/main.doctree +0 -0
  17. qudas-0.1.0/docs/build/doctrees/qudata/output.doctree +0 -0
  18. qudas-0.1.0/docs/build/doctrees/quickstart.doctree +0 -0
  19. qudas-0.1.0/docs/build/doctrees/references.doctree +0 -0
  20. qudas-0.1.0/docs/build/html/.buildinfo +4 -0
  21. qudas-0.1.0/docs/build/html/_images/data_abstract.png +0 -0
  22. qudas-0.1.0/docs/build/html/_images/fmqa_pipeline.png +0 -0
  23. qudas-0.1.0/docs/build/html/_modules/index.html +257 -0
  24. qudas-0.1.0/docs/build/html/_modules/qudas/pipeline/pipeline.html +672 -0
  25. qudas-0.1.0/docs/build/html/_modules/qudas/pipeline/steps/base.html +276 -0
  26. qudas-0.1.0/docs/build/html/_modules/qudas/pipeline/steps/iterator_mixin.html +280 -0
  27. qudas-0.1.0/docs/build/html/_modules/qudas/pipeline/steps/optimizer_mixin.html +291 -0
  28. qudas-0.1.0/docs/build/html/_modules/qudas/qudata/qudata.html +284 -0
  29. qudas-0.1.0/docs/build/html/_modules/qudas/qudata/qudata_base.html +279 -0
  30. qudas-0.1.0/docs/build/html/_modules/qudas/qudata/qudata_input.html +820 -0
  31. qudas-0.1.0/docs/build/html/_modules/qudas/qudata/qudata_output.html +361 -0
  32. qudas-0.1.0/docs/build/html/_sources/index.rst.txt +48 -0
  33. qudas-0.1.0/docs/build/html/_sources/pipeline/index.rst.txt +16 -0
  34. qudas-0.1.0/docs/build/html/_sources/pipeline/steps/base.rst.txt +5 -0
  35. qudas-0.1.0/docs/build/html/_sources/pipeline/steps/iterator_mixin.rst.txt +5 -0
  36. qudas-0.1.0/docs/build/html/_sources/pipeline/steps/optimizer_mixin.rst.txt +5 -0
  37. qudas-0.1.0/docs/build/html/_sources/qudata/base.rst.txt +9 -0
  38. qudas-0.1.0/docs/build/html/_sources/qudata/index.rst.txt +12 -0
  39. qudas-0.1.0/docs/build/html/_sources/qudata/input.rst.txt +9 -0
  40. qudas-0.1.0/docs/build/html/_sources/qudata/main.rst.txt +9 -0
  41. qudas-0.1.0/docs/build/html/_sources/qudata/output.rst.txt +9 -0
  42. qudas-0.1.0/docs/build/html/_sources/quickstart.rst.txt +162 -0
  43. qudas-0.1.0/docs/build/html/_sources/references.rst.txt +6 -0
  44. qudas-0.1.0/docs/build/html/_static/basic.css +921 -0
  45. qudas-0.1.0/docs/build/html/_static/debug.css +69 -0
  46. qudas-0.1.0/docs/build/html/_static/doctools.js +156 -0
  47. qudas-0.1.0/docs/build/html/_static/documentation_options.js +14 -0
  48. qudas-0.1.0/docs/build/html/_static/file.png +0 -0
  49. qudas-0.1.0/docs/build/html/_static/language_data.js +199 -0
  50. qudas-0.1.0/docs/build/html/_static/minus.png +0 -0
  51. qudas-0.1.0/docs/build/html/_static/plus.png +0 -0
  52. qudas-0.1.0/docs/build/html/_static/pygments.css +258 -0
  53. qudas-0.1.0/docs/build/html/_static/scripts/furo-extensions.js +0 -0
  54. qudas-0.1.0/docs/build/html/_static/scripts/furo.js +3 -0
  55. qudas-0.1.0/docs/build/html/_static/scripts/furo.js.LICENSE.txt +7 -0
  56. qudas-0.1.0/docs/build/html/_static/scripts/furo.js.map +1 -0
  57. qudas-0.1.0/docs/build/html/_static/searchtools.js +566 -0
  58. qudas-0.1.0/docs/build/html/_static/skeleton.css +296 -0
  59. qudas-0.1.0/docs/build/html/_static/sphinx_highlight.js +144 -0
  60. qudas-0.1.0/docs/build/html/_static/styles/furo-extensions.css +2 -0
  61. qudas-0.1.0/docs/build/html/_static/styles/furo-extensions.css.map +1 -0
  62. qudas-0.1.0/docs/build/html/_static/styles/furo.css +2 -0
  63. qudas-0.1.0/docs/build/html/_static/styles/furo.css.map +1 -0
  64. qudas-0.1.0/docs/build/html/genindex.html +508 -0
  65. qudas-0.1.0/docs/build/html/index.html +328 -0
  66. qudas-0.1.0/docs/build/html/objects.inv +0 -0
  67. qudas-0.1.0/docs/build/html/pipeline/index.html +443 -0
  68. qudas-0.1.0/docs/build/html/pipeline/steps/base.html +326 -0
  69. qudas-0.1.0/docs/build/html/pipeline/steps/iterator_mixin.html +321 -0
  70. qudas-0.1.0/docs/build/html/pipeline/steps/optimizer_mixin.html +339 -0
  71. qudas-0.1.0/docs/build/html/qudata/base.html +336 -0
  72. qudas-0.1.0/docs/build/html/qudata/index.html +281 -0
  73. qudas-0.1.0/docs/build/html/qudata/input.html +717 -0
  74. qudas-0.1.0/docs/build/html/qudata/main.html +351 -0
  75. qudas-0.1.0/docs/build/html/qudata/output.html +362 -0
  76. qudas-0.1.0/docs/build/html/quickstart.html +497 -0
  77. qudas-0.1.0/docs/build/html/references.html +268 -0
  78. qudas-0.1.0/docs/build/html/search.html +260 -0
  79. qudas-0.1.0/docs/build/html/searchindex.js +1 -0
  80. qudas-0.1.0/docs/make.bat +35 -0
  81. qudas-0.1.0/docs/source/_templates/sidebar/brand.html +32 -0
  82. qudas-0.1.0/docs/source/_templates/sidebar/ethical-ads.html +10 -0
  83. qudas-0.1.0/docs/source/_templates/sidebar/navigation.html +1 -0
  84. qudas-0.1.0/docs/source/_templates/sidebar/search.html +12 -0
  85. qudas-0.1.0/docs/source/_templates/sidebar/variant-selector.html +45 -0
  86. qudas-0.1.0/docs/source/conf.py +56 -0
  87. qudas-0.1.0/docs/source/img/data_abstract.png +0 -0
  88. qudas-0.1.0/docs/source/img/fmqa_pipeline.png +0 -0
  89. qudas-0.1.0/docs/source/index.rst +48 -0
  90. qudas-0.1.0/docs/source/pipeline/index.rst +16 -0
  91. qudas-0.1.0/docs/source/pipeline/steps/base.rst +5 -0
  92. qudas-0.1.0/docs/source/pipeline/steps/iterator_mixin.rst +5 -0
  93. qudas-0.1.0/docs/source/pipeline/steps/optimizer_mixin.rst +5 -0
  94. qudas-0.1.0/docs/source/qudata/base.rst +9 -0
  95. qudas-0.1.0/docs/source/qudata/index.rst +12 -0
  96. qudas-0.1.0/docs/source/qudata/input.rst +9 -0
  97. qudas-0.1.0/docs/source/qudata/main.rst +9 -0
  98. qudas-0.1.0/docs/source/qudata/output.rst +9 -0
  99. qudas-0.1.0/docs/source/quickstart.rst +162 -0
  100. qudas-0.1.0/docs/source/references.rst +6 -0
  101. qudas-0.1.0/pyproject.toml +32 -0
  102. qudas-0.1.0/qudas/__init__.py +21 -0
  103. qudas-0.1.0/qudas/pipeline/__init__.py +3 -0
  104. qudas-0.1.0/qudas/pipeline/pipeline.py +457 -0
  105. qudas-0.1.0/qudas/pipeline/steps/__init__.py +5 -0
  106. qudas-0.1.0/qudas/pipeline/steps/base.py +27 -0
  107. qudas-0.1.0/qudas/pipeline/steps/iterator_mixin.py +31 -0
  108. qudas-0.1.0/qudas/pipeline/steps/optimizer_mixin.py +42 -0
  109. qudas-0.1.0/qudas/qudata/__init__.py +9 -0
  110. qudas-0.1.0/qudas/qudata/qudata.py +35 -0
  111. qudas-0.1.0/qudas/qudata/qudata_base.py +30 -0
  112. qudas-0.1.0/qudas/qudata/qudata_input.py +571 -0
  113. qudas-0.1.0/qudas/qudata/qudata_output.py +112 -0
  114. qudas-0.1.0/qudas.egg-info/PKG-INFO +272 -0
  115. qudas-0.1.0/qudas.egg-info/SOURCES.txt +122 -0
  116. qudas-0.1.0/qudas.egg-info/dependency_links.txt +1 -0
  117. qudas-0.1.0/qudas.egg-info/top_level.txt +1 -0
  118. qudas-0.1.0/requirements.txt +95 -0
  119. qudas-0.1.0/setup.cfg +4 -0
  120. qudas-0.1.0/setup.py +128 -0
  121. qudas-0.1.0/test/test_pipeline.py +144 -0
  122. qudas-0.1.0/test/test_qudata.py +603 -0
  123. qudas-0.1.0/test/test_qudata_input.py +291 -0
  124. qudas-0.1.0/test/test_qudata_output.py +158 -0
qudas-0.1.0/LICENSE ADDED
@@ -0,0 +1,233 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2024 DEVEL Co., Ltd.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
203
+ ---
204
+
205
+ ## Additional Terms and Conditions for Qudas
206
+
207
+ The following terms are supplementary to the Apache License Version 2.0 and apply specifically to the use of the Qudas software package:
208
+
209
+ 1. **Prohibited Uses**
210
+ - The software may not be used for illegal activities, intellectual property infringement, or any purpose that violates public policy.
211
+ - Reverse engineering, decompiling, or modifying the software is prohibited unless explicitly permitted by this license or applicable law.
212
+
213
+ 2. **Export Control Compliance**
214
+ - Users agree to comply with all applicable export control laws and regulations when using this software.
215
+
216
+ 3. **Disclaimer of High-Risk Use**
217
+ - This software is not designed for high-risk applications such as life support systems, nuclear facilities, or other critical infrastructure requiring fail-safe performance.
218
+
219
+ 4. **Third-Party Components**
220
+ - This package may include third-party components with their own licensing terms. Users must adhere to these terms when using those components.
221
+
222
+ 5. **Support and Maintenance**
223
+ - The Qudas package is provided "AS IS" without warranty of any kind. Support and maintenance are not guaranteed but may be available under separate terms.
224
+
225
+ 6. **Fixstars Amplify SDK Compliance**
226
+ - If the software integrates or interfaces with the Fixstars Amplify SDK, users must comply with the SDK's licensing terms as specified by Fixstars Corporation.
227
+
228
+ 7. **Liability Limitations**
229
+ - Under no circumstances shall the authors or copyright holders be liable for any damages arising from the use of this software, except as required by applicable law.
230
+
231
+ ---
232
+
233
+ For inquiries or more information, contact: higa.devel@gmail.com
@@ -0,0 +1,8 @@
1
+ include README.md
2
+ include LICENSE
3
+ include VERSION
4
+ include requirements.txt
5
+ recursive-include docs * # docs フォルダ内のすべてのファイルを含める
6
+ recursive-include tests * # テストフォルダ内のすべてのファイルを含める
7
+ graft qudas # qudas フォルダ全体を含める
8
+ global-exclude *.pyc # コンパイル済みのPythonファイルを除外
qudas-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,272 @@
1
+ Metadata-Version: 2.1
2
+ Name: qudas
3
+ Version: 0.1.0
4
+ Summary: Quantum data transform package
5
+ Home-page: https://github.com/devel-system/qudas
6
+ Author: Keiichiro Higa
7
+ Author-email: Keiichiro Higa <higa.devel@gmail.com>
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+
15
+
16
+ # Qudas (Quantum Data Transformation Library)
17
+
18
+ Qudasは、量子計算における最適化問題の入出力データを変換するためのPythonライブラリです。異なるデータ形式間の変換をサポートし、さまざまな量子計算環境での統一的なデータ処理を可能にします。
19
+
20
+ ## 主な機能
21
+ - 量子計算における入力データのフォーマット変換
22
+ - 計算結果の出力データのフォーマット変換
23
+ - AnnealingやGateデバイスのデータに対応
24
+
25
+ ## インストール
26
+ 以下のコマンドを使用してインストールします。
27
+
28
+ ```
29
+ pip install qudas
30
+ ```
31
+
32
+ ## 使用方法
33
+
34
+ ### 初期化
35
+
36
+ ```python
37
+ from qudata import QuData
38
+
39
+ # 最適化問題の初期化
40
+ prob = {('q0', 'q1'): 1.0, ('q2', 'q2'): -1.0}
41
+ qudata = QuData.input(prob)
42
+ print(qudata.prob) # 出力: {('q0', 'q1'): 1.0, ('q2', 'q2'): -1.0}
43
+
44
+ # Noneで初期化した場合
45
+ qudata = QuData.input()
46
+ print(qudata.prob) # 出力: {}
47
+ ```
48
+
49
+ ### 加算・減算・乗算・べき乗
50
+
51
+ ```python
52
+ # 辞書形式の問題を加算
53
+ qudata1 = QuData.input({('q0', 'q1'): 1.0})
54
+ qudata2 = QuData.input({('q0', 'q0'): 2.0})
55
+ result = qudata1 + qudata2
56
+ print(result.prob) # 出力: {('q0', 'q1'): 1.0, ('q0', 'q0'): 2.0}
57
+
58
+ # 辞書形式の問題をべき乗
59
+ qudata = QuData.input({('q0', 'q1'): 1.0})
60
+ result = qudata ** 2
61
+ print(result.prob) # 出力: {('q0', 'q1'): 1.0, ('q0', 'q2', 'q1'): -2.0}
62
+ ```
63
+
64
+ ### データ形式の変換(QuDataInput)
65
+ デバイスへの様々な入力形式のデータを `QuData` オブジェクトを介して変換することができます。
66
+
67
+ #### pyqubo から Amplify への変換
68
+ ```python
69
+ from pyqubo import Binary
70
+ from qudas import QuData
71
+
72
+ # Pyqubo で問題を定義
73
+ q0, q1 = Binary("q0"), Binary("q1")
74
+ prob = (q0 + q1) ** 2
75
+
76
+ # QuData に Pyqubo の問題を渡す
77
+ qudata = QuData.input().from_pyqubo(prob)
78
+ print(qudata.prob) # 出力: {('q0', 'q0'): 1.0, ('q0', 'q1'): 2.0, ('q1', 'q1'): 1.0}
79
+
80
+ # Amplify 形式に変換
81
+ amplify_prob = qudata.to_amplify()
82
+ print(amplify_prob)
83
+ ```
84
+
85
+ #### 配列から BQM への変換
86
+ ```python
87
+ import numpy as np
88
+ from qudas import QuData
89
+
90
+ # Numpy 配列を定義
91
+ prob = np.array([
92
+ [1, 1, 0],
93
+ [0, 2, 0],
94
+ [0, 0, -1],
95
+ ])
96
+
97
+ # QuData に配列を渡す
98
+ qudata = QuData.input().from_array(prob)
99
+ print(qudata.prob) # 出力: {('q_0', 'q_0'): 1, ('q_0', 'q_1'): 1, ('q_1', 'q_1'): 2, ('q_2', 'q_2'): -1}
100
+
101
+ # BQM 形式に変換
102
+ bqm_prob = qudata.to_dimod_bqm()
103
+ print(bqm_prob)
104
+ ```
105
+
106
+ #### CSV から PuLP への変換
107
+ ```python
108
+ import pulp
109
+ from qudas import QuData
110
+
111
+ # CSVファイルのパス
112
+ csv_file_path = './data/qudata.csv'
113
+
114
+ # QuData に CSV を渡す
115
+ qudata = QuData.input().from_csv(csv_file_path)
116
+ print(qudata.prob) # 出力: {('q_0', 'q_0'): 1.0, ('q_0', 'q_2'): 2.0, ...}
117
+
118
+ # PuLP 形式に変換
119
+ pulp_prob = qudata.to_pulp()
120
+ print(pulp_prob)
121
+ ```
122
+
123
+ ### データ形式の変換(QuDataOutput)
124
+ デバイスからの様々な出力形式のデータを `QuData` オブジェクトを介して変換することができます。
125
+
126
+ #### PuLP から Amplify への変換
127
+ ```python
128
+ import pulp
129
+ from qudas import QuData
130
+
131
+ # PuLP問題を定義して解く
132
+ prob = pulp.LpProblem("Test Problem", pulp.LpMinimize)
133
+ x = pulp.LpVariable('x', lowBound=0, upBound=1, cat='Binary')
134
+ y = pulp.LpVariable('y', lowBound=0, upBound=1, cat='Binary')
135
+ prob += 2*x - y
136
+ prob.solve()
137
+
138
+ # QuDataOutputのインスタンスを生成し、from_pulpメソッドで問題を変換
139
+ qudata = QuData.output().from_pulp(prob)
140
+ print(qudata.prob) # 出力: {'x': 2.0, 'y': -1.0}
141
+
142
+ # Amplify形式に変換
143
+ amplify_prob = qudata.to_amplify()
144
+ print(amplify_prob) # 出力: Amplifyの目標関数形式
145
+ ```
146
+
147
+ #### SciPy から Dimod への変換
148
+ ```python
149
+ import numpy as np
150
+ from sympy import symbols, lambdify
151
+ from scipy.optimize import minimize, Bounds
152
+ from qudas import QuData
153
+
154
+ # シンボリック変数の定義
155
+ q0, q1, q2 = symbols('q0 q1 q2')
156
+
157
+ # 目的関数を定義
158
+ objective_function = 2 * q0 - q1 - q2
159
+
160
+ # シンボリック関数を数値化して評価できる形式に変換
161
+ f = lambdify([q0, q1, q2], objective_function, 'numpy')
162
+
163
+ # 初期解 (すべて0.5に設定)
164
+ q = [0.5, 0.5, 0.5]
165
+
166
+ # バイナリ変数の範囲を定義 (0 <= x <= 1)
167
+ bounds = Bounds([0, 0, 0], [1, 1, 1])
168
+
169
+ # SciPyで制約付き最適化を実行
170
+ res = minimize(lambda q: f(q[0], q[1], q[2]), q, method='SLSQP', bounds=bounds)
171
+
172
+ # QuDataOutputのインスタンスを生成し、from_scipyメソッドをテスト
173
+ qudata = QuData.output().from_scipy(res)
174
+ print(qudata.prob) # 出力: {'q0': 2, 'q1': -1, 'q2': -1}
175
+
176
+ # Dimod形式に変換
177
+ dimod_prob = qudata.to_dimod_bqm()
178
+ print(dimod_prob) # 出力: DimodのBQM形式
179
+ ```
180
+
181
+ ## テストコード
182
+ 本ライブラリには、以下のようなテストを含めて動作確認を行っています。
183
+
184
+ ```python
185
+ class TestQudata(unittest.TestCase):
186
+
187
+ def test_init_with_dict(self):
188
+ # 辞書データで初期化する場合のテスト
189
+ prob = {('q0', 'q1'): 1.0, ('q2', 'q2'): -1.0}
190
+ qudata = QuData.input(prob)
191
+ self.assertTrue(dicts_are_equal(qudata.prob, prob))
192
+
193
+ def test_add(self):
194
+ # __add__メソッドのテスト
195
+ prob1 = {('q0', 'q1'): 1.0}
196
+ prob2 = {('q0', 'q0'): 2.0}
197
+ qudata1 = QuData.input(prob1)
198
+ qudata2 = QuData.input(prob2)
199
+ result = qudata1 + qudata2
200
+ expected = {('q0', 'q1'): 1.0, ('q0', 'q0'): 2.0}
201
+ self.assertTrue(dicts_are_equal(result.prob, expected))
202
+ ```
203
+
204
+ ## 開発者向け情報
205
+
206
+ ### ドキュメントの生成方法
207
+
208
+ Sphinxを使用してHTMLドキュメントを生成します。
209
+
210
+ 1. 初回の設定
211
+ ```
212
+ mkdir docs
213
+ cd docs
214
+ sphinx-quickstart
215
+ sphinx-apidoc -f -o source ../qudas
216
+ ```
217
+
218
+ 2. `docs/source/conf.py` を適宜修正
219
+
220
+ 3. ドキュメントをビルド
221
+ ```
222
+ cd docs
223
+ make clean
224
+ make html
225
+ ```
226
+
227
+ 生成されたHTMLドキュメントは `docs/build/html/index.html` で確認できます。
228
+ Markdownは [GitHub-flavored Markdown](https://guides.github.com/features/mastering-markdown/) を参考にしてください。
229
+
230
+ ### テスト
231
+ Qudasのテストは、`tests/` ディレクトリに配置された `test_xxx.py` ファイルで行います。テストの実行は以下のコマンドで可能です。
232
+
233
+ ```
234
+ pytest tests/
235
+ ```
236
+
237
+ ### コードフォーマット
238
+
239
+ このプロジェクトでは、Python コードのフォーマットに [Black](https://black.readthedocs.io/en/stable/) を使用しています。`Black` は自動でコードを整形し、一貫したスタイルを保つことができます。
240
+
241
+ #### `Black` を使ったコードフォーマット
242
+
243
+ 1. `Black` のインストール:
244
+ - 開発環境用の依存パッケージとともに `Black` をインストールします:
245
+ ```bash
246
+ pip install .[dev]
247
+ ```
248
+
249
+ 2. コードを自動フォーマットするには、プロジェクトのルートディレクトリで次のコマンドを実行します:
250
+ ```bash
251
+ black .
252
+ ```
253
+
254
+ これにより、すべての Python ファイルが自動的にフォーマットされます。
255
+
256
+ #### コードフォーマットの確認
257
+
258
+ `black --check .` コマンドを使用すると、コードがフォーマットされているかどうかを確認することができます。このコマンドは実際にはファイルを変更せず、フォーマットが必要かどうかを表示するだけです。
259
+
260
+ ```bash
261
+ black --check .
262
+ ```
263
+
264
+ ### パッケージの更新方法
265
+ 以下のコマンドでパッケージを更新します。
266
+
267
+ ```
268
+ pip install . -U
269
+ ```
270
+
271
+ ## ライセンス
272
+ このプロジェクトはApache-2.0ライセンスの下で提供されています。詳細は`LICENSE`ファイルを参照してください。