iqm-exa-common 27.0.0__py3-none-any.whl → 27.2.0__py3-none-any.whl

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.
@@ -0,0 +1,123 @@
1
+ # Copyright 2025 IQM
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Chip layout class."""
16
+
17
+ from __future__ import annotations
18
+
19
+ from functools import cached_property
20
+
21
+ import numpy as np
22
+
23
+ from exa.common.errors.exa_error import ExaError
24
+
25
+
26
+ class ChipLayout:
27
+ """The chip layout contains the components and their 2D cartesian coordinates."""
28
+
29
+ def __init__(
30
+ self,
31
+ qubits: dict[str, tuple[float, float]],
32
+ couplers: dict[str, tuple[float, float]],
33
+ computational_resonators: dict[str, tuple[float, float]],
34
+ ) -> None:
35
+ self._qubits = list(qubits)
36
+ self._couplers = list(couplers)
37
+ self._computational_resonators = list(computational_resonators)
38
+ self._coordinates = {
39
+ comp: (x, y) for comp, (x, y) in [*qubits.items(), *couplers.items(), *computational_resonators.items()]
40
+ }
41
+
42
+ @classmethod
43
+ def from_chip_design_record(cls, record: dict) -> ChipLayout:
44
+ """Construct the chip layout from a raw chip design record.
45
+
46
+ Args:
47
+ record: The chip design record as returned by station control.
48
+
49
+ Returns:
50
+ The corresponding chip layout.
51
+
52
+ """
53
+ qubits = record["content"]["components"].get("qubit", [])
54
+ couplers = record["content"]["components"].get("tunable_coupler", [])
55
+ comprs = record["content"]["components"].get("computational_resonator", [])
56
+ if all("locations" in component for component in [*qubits, *couplers, *comprs]):
57
+ return cls(
58
+ qubits={
59
+ qubit["name"]: (qubit["locations"]["metro"]["x"], qubit["locations"]["metro"]["y"])
60
+ for qubit in qubits
61
+ },
62
+ couplers={
63
+ coupler["name"]: (coupler["locations"]["metro"]["x"], coupler["locations"]["metro"]["y"])
64
+ for coupler in couplers
65
+ },
66
+ computational_resonators={
67
+ compr["name"]: (compr["locations"]["metro"]["x"], compr["locations"]["metro"]["y"])
68
+ for compr in comprs
69
+ },
70
+ )
71
+ raise ExaError("Chip design record is missing locations.")
72
+
73
+ def normalize_coordinates(self, scale: float) -> None:
74
+ self._coordinates = {comp: (xx * scale, yy * scale) for comp, (xx, yy) in self._coordinates.items()}
75
+
76
+ def mirror_yaxis(self) -> None:
77
+ self._coordinates = {comp: (xx, -yy) for comp, (xx, yy) in self._coordinates.items()}
78
+
79
+ def rotate_layout(self) -> None:
80
+ self._coordinates = {
81
+ comp: ((xx + yy) / np.sqrt(2), (-xx + yy) / np.sqrt(2)) for comp, (xx, yy) in self._coordinates.items()
82
+ }
83
+
84
+ def move_origin(self) -> None:
85
+ x_min, y_min = (
86
+ min([xx for comp, (xx, yy) in self._coordinates.items()]),
87
+ min([yy for comp, (xx, yy) in self._coordinates.items()]),
88
+ )
89
+ self._coordinates = {comp: (xx - x_min, yy - y_min) for comp, (xx, yy) in self._coordinates.items()}
90
+
91
+ @property
92
+ def qubits(self) -> list[str]:
93
+ return self._qubits
94
+
95
+ @property
96
+ def couplers(self) -> list[str]:
97
+ return self._couplers
98
+
99
+ @property
100
+ def computational_resonators(self) -> list[str]:
101
+ return self._computational_resonators
102
+
103
+ @cached_property
104
+ def components(self) -> list[str]:
105
+ return [*self._qubits, *self._couplers, *self._computational_resonators]
106
+
107
+ def get_coordinates(self, component: str) -> tuple[float, float]:
108
+ """Get the coordinates for the given component.
109
+
110
+ Args:
111
+ component: The name of the component.
112
+
113
+ Returns:
114
+ The 2D cartesian coordinates.
115
+
116
+ """
117
+ if component not in self.components:
118
+ raise ValueError(f"Component {component} not in chip layout.")
119
+ return self._coordinates[component]
120
+
121
+ def get_all_qubit_coordinates(self) -> dict[str, tuple[float, float]]:
122
+ """Get the coordinates for all qubits."""
123
+ return {qubit: self._coordinates[qubit] for qubit in self._qubits}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: iqm-exa-common
3
- Version: 27.0.0
3
+ Version: 27.2.0
4
4
  Summary: Framework for control and measurement of superconducting qubits: common library
5
5
  Author-email: IQM Finland Oy <info@meetiqm.com>
6
6
  License: Apache License
@@ -41,6 +41,7 @@ exa/common/logger/__init__.py,sha256=1bIsGxHzfujXlkgtcAnWToKMkw3dpU5PEd_7LE_NpgQ
41
41
  exa/common/logger/logger.py,sha256=TA9HxFZDyFB7ai8C6mCZOm1cx3JMRAhB8DcMCwDAKt0,5713
42
42
  exa/common/qcm_data/__init__.py,sha256=VtsYkGoaniSjCkY0oQlqkcYJCtmC2sTDxfrIe_kpqZg,567
43
43
  exa/common/qcm_data/chad_model.py,sha256=1vWpB8gsrnIEDqEOqqQAXrofN2jM6c8AypZvOSH5I18,11279
44
+ exa/common/qcm_data/chip_layout.py,sha256=jDEMsujltH_KqLjj2Ja-XEEJubfsMg_HPlqnC4-L9YE,4555
44
45
  exa/common/qcm_data/chip_topology.py,sha256=-IsWh0hev_vnAWs0z3iWBvProe6LypgKs1Erp8HCb0M,20027
45
46
  exa/common/qcm_data/file_adapter.py,sha256=VAvyV4FrCE93bvy7YP2DDlS_cgHQe-uwPdMQwMlZveQ,2319
46
47
  exa/common/qcm_data/immutable_base_model.py,sha256=QXmKIWQbsbWQvovXwKT1d9jtyf2LNJtjQquIwO52zOU,901
@@ -48,8 +49,8 @@ exa/common/qcm_data/qcm_data_client.py,sha256=Rze6yQd0xUeH6eUMv3wduYbiDCTP3C4WEC
48
49
  exa/common/sweep/__init__.py,sha256=uEKk5AtzSgSnf8Y0geRPwUpqXIBIXpeCxsN64sX7F1o,591
49
50
  exa/common/sweep/database_serialization.py,sha256=9n96OqmEnjy1x2F1HwaNOQgwX_39HjLtE9EUoetSw0E,7493
50
51
  exa/common/sweep/util.py,sha256=-QE2AaH-WDkYAVH5-Z-30leLgY0x4efmby4kc1JTCgY,3732
51
- iqm_exa_common-27.0.0.dist-info/LICENSE.txt,sha256=R6Q7eUrLyoCQgWYorQ8WJmVmWKYU3dxA3jYUp0wwQAw,11332
52
- iqm_exa_common-27.0.0.dist-info/METADATA,sha256=HSADQ--8rxKTImWGTmuX7t6lDJ1Tajdke8LLVC98trw,14741
53
- iqm_exa_common-27.0.0.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
54
- iqm_exa_common-27.0.0.dist-info/top_level.txt,sha256=Clphg2toaZ3_jSFRPhjMNEmLurkMNMc4lkK2EFYsSlM,4
55
- iqm_exa_common-27.0.0.dist-info/RECORD,,
52
+ iqm_exa_common-27.2.0.dist-info/LICENSE.txt,sha256=R6Q7eUrLyoCQgWYorQ8WJmVmWKYU3dxA3jYUp0wwQAw,11332
53
+ iqm_exa_common-27.2.0.dist-info/METADATA,sha256=pUaveDJ3RTxPsMtAOwoM8u7ujPd0vEiwlpw1i0pGLes,14741
54
+ iqm_exa_common-27.2.0.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
55
+ iqm_exa_common-27.2.0.dist-info/top_level.txt,sha256=Clphg2toaZ3_jSFRPhjMNEmLurkMNMc4lkK2EFYsSlM,4
56
+ iqm_exa_common-27.2.0.dist-info/RECORD,,