iqm-exa-common 25.33__py3-none-any.whl → 26.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.
Files changed (41) hide show
  1. exa/common/api/proto_serialization/_parameter.py +4 -3
  2. exa/common/api/proto_serialization/nd_sweep.py +3 -8
  3. exa/common/api/proto_serialization/sequence.py +5 -5
  4. exa/common/control/sweep/exponential_sweep.py +15 -47
  5. exa/common/control/sweep/fixed_sweep.py +10 -14
  6. exa/common/control/sweep/linear_sweep.py +15 -40
  7. exa/common/control/sweep/option/__init__.py +1 -1
  8. exa/common/control/sweep/option/center_span_base_options.py +14 -7
  9. exa/common/control/sweep/option/center_span_options.py +13 -6
  10. exa/common/control/sweep/option/constants.py +2 -2
  11. exa/common/control/sweep/option/fixed_options.py +8 -2
  12. exa/common/control/sweep/option/option_converter.py +4 -8
  13. exa/common/control/sweep/option/start_stop_base_options.py +20 -6
  14. exa/common/control/sweep/option/start_stop_options.py +20 -5
  15. exa/common/control/sweep/option/sweep_options.py +9 -0
  16. exa/common/control/sweep/sweep.py +52 -16
  17. exa/common/control/sweep/sweep_values.py +58 -0
  18. exa/common/data/base_model.py +40 -0
  19. exa/common/data/parameter.py +123 -68
  20. exa/common/data/setting_node.py +481 -135
  21. exa/common/data/settingnode_v2.html.jinja2 +6 -6
  22. exa/common/data/value.py +49 -0
  23. exa/common/logger/logger.py +1 -1
  24. exa/common/qcm_data/file_adapter.py +2 -6
  25. exa/common/qcm_data/qcm_data_client.py +1 -37
  26. exa/common/sweep/database_serialization.py +30 -98
  27. exa/common/sweep/util.py +4 -5
  28. {iqm_exa_common-25.33.dist-info → iqm_exa_common-26.0.dist-info}/METADATA +2 -2
  29. iqm_exa_common-26.0.dist-info/RECORD +54 -0
  30. exa/common/api/model/__init__.py +0 -15
  31. exa/common/api/model/parameter_model.py +0 -111
  32. exa/common/api/model/setting_model.py +0 -63
  33. exa/common/api/model/setting_node_model.py +0 -72
  34. exa/common/api/model/sweep_model.py +0 -63
  35. exa/common/control/sweep/function_sweep.py +0 -35
  36. exa/common/control/sweep/option/function_options.py +0 -26
  37. exa/common/control/sweep/utils.py +0 -43
  38. iqm_exa_common-25.33.dist-info/RECORD +0 -59
  39. {iqm_exa_common-25.33.dist-info → iqm_exa_common-26.0.dist-info}/LICENSE.txt +0 -0
  40. {iqm_exa_common-25.33.dist-info → iqm_exa_common-26.0.dist-info}/WHEEL +0 -0
  41. {iqm_exa_common-25.33.dist-info → iqm_exa_common-26.0.dist-info}/top_level.txt +0 -0
@@ -1,72 +0,0 @@
1
- # Copyright 2024 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
- """Pydantic model for SettingNode."""
16
-
17
- from __future__ import annotations
18
-
19
- from typing import Any, Dict
20
-
21
- from pydantic import BaseModel, ConfigDict
22
-
23
- from exa.common.api.model.setting_model import SettingModel
24
- from exa.common.data.setting_node import SettingNode
25
-
26
-
27
- class SettingNodeModel(BaseModel):
28
- """Pydantic setting node model""" # noqa: D200
29
-
30
- name: str
31
- settings: Dict[str, SettingModel]
32
- subtrees: Dict[str, SettingNodeModel]
33
-
34
- def __hash__(self):
35
- return hash((self.name, self.settings, self.subtrees))
36
-
37
- def __eq__(self, other: SettingNodeModel):
38
- return isinstance(other, SettingNodeModel) and (
39
- (self.name, self.settings, self.subtrees) == (other.name, other.settings, other.subtrees)
40
- )
41
-
42
- model_config = ConfigDict(extra="allow")
43
-
44
- def decode(self) -> SettingNode:
45
- """Creates instance of :class:`exa.common.data.setting_node.SettingNode` out of pydantic `SettingNodeModel`"""
46
- return SettingNode(self.name, **SettingNodeModel._get_children(self))
47
-
48
- @staticmethod
49
- def _get_children(root: SettingNodeModel) -> Dict[str, Any]:
50
- children = {}
51
- for k_s, v_s in root.settings.items():
52
- children[k_s] = v_s.decode()
53
- for k, v in root.subtrees.items():
54
- children[k] = SettingNode(v.name, **SettingNodeModel._get_children(v))
55
- return children
56
-
57
- @classmethod
58
- def encode(cls, node: SettingNode) -> SettingNodeModel:
59
- """Creates pydantic `SettingNodeModel` out of :class:`exa.common.data.setting_node.SettingNode` instance"""
60
- return SettingNodeModel(**cls._get_dict(node))
61
-
62
- @classmethod
63
- def _get_dict(cls, root: SettingNode) -> Dict[str, Any]:
64
- return {
65
- "name": root.name,
66
- "settings": {key: SettingModel.encode(setting) for key, setting in root._settings.items()},
67
- "subtrees": {key: cls._get_dict(node) for key, node in root._subtrees.items()},
68
- }
69
-
70
-
71
- # Since model references itself as a field type need to resolve ForwardRef during model creation
72
- SettingNodeModel.model_rebuild()
@@ -1,63 +0,0 @@
1
- # Copyright 2024 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
- """Pydantic model for Sweep."""
16
-
17
- from __future__ import annotations
18
-
19
- from typing import Any
20
-
21
- from pydantic import BaseModel, ConfigDict, field_serializer
22
-
23
- from exa.common.api.model.parameter_model import ParameterModel
24
- from exa.common.control.sweep.fixed_sweep import FixedSweep
25
- from exa.common.control.sweep.option.fixed_options import FixedOptions
26
- from exa.common.control.sweep.sweep import Sweep
27
- from exa.common.helpers import json_helper
28
-
29
-
30
- class SweepModel(BaseModel):
31
- """Pydantic sweep model."""
32
-
33
- parameter: ParameterModel
34
- data: list[Any]
35
-
36
- def __hash__(self):
37
- return hash((self.parameter, self.data))
38
-
39
- def __eq__(self, other: SweepModel):
40
- return isinstance(other, SweepModel) and ((self.parameter, self.data) == (other.parameter, other.data))
41
-
42
- model_config = ConfigDict(extra="allow")
43
-
44
- @field_serializer("data")
45
- def serialize_data(self, data: Any, _info):
46
- for index, value in enumerate(data):
47
- encoder = json_helper.get_json_encoder().get(type(value))
48
- if encoder:
49
- data[index] = encoder(value)
50
- return data
51
-
52
- def decode(self) -> FixedSweep:
53
- """Creates instance of :class:`exa.common.control.sweep.fixed_sweep.FixedSweep` out of pydantic `SweepModel`."""
54
- parameter = ParameterModel.decode(self.parameter)
55
- data = [json_helper.decode_json(d) for d in self.data]
56
- options = FixedOptions(fixed=data)
57
- # TODO: FixedSweep is used as a temporary solution, since it is possible to send list of values with FixedSweep.
58
- return FixedSweep(parameter=parameter, options=options)
59
-
60
- @classmethod
61
- def encode(cls, sweep: Sweep) -> SweepModel:
62
- """Creates pydantic `SweepModel` out of :class:`exa.common.control.sweep.sweep.Sweep` instance."""
63
- return SweepModel(parameter=ParameterModel.encode(sweep.parameter), data=sweep.data)
@@ -1,35 +0,0 @@
1
- # Copyright 2024 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
- """Sweep specification with generated parameter values based on callable object."""
16
-
17
- from dataclasses import dataclass
18
-
19
- from exa.common.control.sweep.option import FunctionOptions
20
- from exa.common.control.sweep.sweep import Sweep
21
- from exa.common.errors.exa_error import InvalidSweepOptionsTypeError
22
-
23
-
24
- @dataclass(frozen=True)
25
- class FunctionSweep(Sweep):
26
- """Generates parameter values based on callable object from `options`."""
27
-
28
- def __post_init__(self):
29
- if not isinstance(self.options, FunctionOptions):
30
- raise InvalidSweepOptionsTypeError(str(type(self.options)))
31
-
32
- data = self.options.function()
33
- if not all(self.parameter.validate(value) for value in data):
34
- raise ValueError(f"Invalid generated range data {data} for parameter type {self.parameter.data_type}.")
35
- object.__setattr__(self, "_data", data)
@@ -1,26 +0,0 @@
1
- # Copyright 2024 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
- from dataclasses import dataclass
16
- from typing import Callable, List, Union
17
-
18
- from exa.common.control.sweep.option.sweep_options import SweepOptions
19
-
20
-
21
- @dataclass(frozen=True)
22
- class FunctionOptions(SweepOptions):
23
- """Range generation options."""
24
-
25
- #: Object that returns generated range of values.
26
- function: Callable[[], List[Union[int, float, complex]]]
@@ -1,43 +0,0 @@
1
- # Copyright 2024 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
- from typing import Type
16
-
17
- from exa.common.control.sweep.exponential_sweep import ExponentialSweep
18
- from exa.common.control.sweep.fixed_sweep import FixedSweep
19
- from exa.common.control.sweep.function_sweep import FunctionSweep
20
- from exa.common.control.sweep.linear_sweep import LinearSweep
21
- from exa.common.control.sweep.option import (
22
- CenterSpanBaseOptions,
23
- CenterSpanOptions,
24
- FixedOptions,
25
- FunctionOptions,
26
- StartStopBaseOptions,
27
- StartStopOptions,
28
- )
29
- from exa.common.control.sweep.option.sweep_options import SweepOptions
30
- from exa.common.control.sweep.sweep import Sweep
31
-
32
- SWEEP_CLASS_OPTIONS_MAPPING = {
33
- FixedOptions.__name__: FixedSweep,
34
- FunctionOptions.__name__: FunctionSweep,
35
- StartStopOptions.__name__: LinearSweep,
36
- CenterSpanOptions.__name__: LinearSweep,
37
- StartStopBaseOptions.__name__: ExponentialSweep,
38
- CenterSpanBaseOptions.__name__: ExponentialSweep,
39
- }
40
-
41
-
42
- def get_sweep_class_from_options(options: SweepOptions) -> Type[Sweep]:
43
- return SWEEP_CLASS_OPTIONS_MAPPING[type(options).__name__]
@@ -1,59 +0,0 @@
1
- exa/common/__init__.py,sha256=AqxwNht57urLqMxFblY7SgxjzkQYW7pRRUUPS1j1Gck,962
2
- exa/common/api/__init__.py,sha256=PAYujWNG8CtSQX_8U9gnubDh5cwGRhtOfLr0r0xGx3M,587
3
- exa/common/api/model/__init__.py,sha256=l3JxadYmX2p0ZcdwpdFZGumn9QFufWrGF36ePIqHA2I,635
4
- exa/common/api/model/parameter_model.py,sha256=9Axf88nDFl2IH1vztBHrOAnliDy0TBwD-vPHegk6Kak,3850
5
- exa/common/api/model/setting_model.py,sha256=byTM2eKDuqQM7blmjXZaLzdGpXS_dwLq0wmv-SfVDzU,2330
6
- exa/common/api/model/setting_node_model.py,sha256=O57sttuxNBWrgHWx0zLNMlFD7GRm670cRxiG9RkECzc,2658
7
- exa/common/api/model/sweep_model.py,sha256=9rVmo2rNN4k3yhVIdnlEuNqVBs79fN6Z1IOEEOZmfVo,2455
8
- exa/common/api/proto_serialization/__init__.py,sha256=Vn2C79OqovFu5wJus9EHsMtK3Of1JLJDcpg2QZKmXsY,1565
9
- exa/common/api/proto_serialization/_parameter.py,sha256=ED_wE1JN6EwdGJJxMUSqfYWTAfelsoKDm1XfAAPUw6Y,2837
10
- exa/common/api/proto_serialization/array.py,sha256=iht5WlfGEkzXM3PcOFDXxd2TgXWFyYNyPt44CMqXnl8,3110
11
- exa/common/api/proto_serialization/datum.py,sha256=gFIAncWpOhy4V56DKYdKoasEIpGu1yUerSuRQf65unY,4828
12
- exa/common/api/proto_serialization/nd_sweep.py,sha256=JfEOcISWZyfrVRaTvWkIwGRRlkSGKFwmOHVqbNlNKUw,2866
13
- exa/common/api/proto_serialization/sequence.py,sha256=yIAxO6zdhsSkrUkJ5XonuLsf3nZQ-hHq8uzCwHkZaDU,2447
14
- exa/common/api/proto_serialization/setting_node.py,sha256=Ac-WuYKUTiVywRmRJHhdpfoswQWRQEIEgIWsn7IsA_g,3700
15
- exa/common/control/__init__.py,sha256=00T_xV0lL20QZcEt__vWq81N1oGF0KpJMhTitfAI4VI,629
16
- exa/common/control/sweep/__init__.py,sha256=GzKoQdQsLutcHhmrLPyPrW1n7Cpg766p3OWDHlRpuTs,607
17
- exa/common/control/sweep/exponential_sweep.py,sha256=hKAj9_4w9frWzZouvNDGnhsjAjLt4k28fjtR0PXfA9I,3510
18
- exa/common/control/sweep/fixed_sweep.py,sha256=099H7rTsE9s_tUEopP_5UwGeUo1LDhuDPtBav2Pk4pU,1473
19
- exa/common/control/sweep/function_sweep.py,sha256=hfi1WafPX6t7U9EcQIOspSPFZgfAlVILTFIDNM-LdiI,1432
20
- exa/common/control/sweep/linear_sweep.py,sha256=5d5OsCR9P7ujOLdzbjLt2v_5BPuhTuwLxnV_nOPrDLE,3107
21
- exa/common/control/sweep/sweep.py,sha256=g9RZhMO254ACK51B4zX1i5Y5n-EVyqlRpt6E_6qHufc,1532
22
- exa/common/control/sweep/utils.py,sha256=9moO0qnuF_xuvWkWuwYjLV2ejXnDXTogARVQz_jESo4,1610
23
- exa/common/control/sweep/option/__init__.py,sha256=R_KvrmH-FCC1K0ixtFr1QmOTiyS3lhIgFVDmCQBKSuU,951
24
- exa/common/control/sweep/option/center_span_base_options.py,sha256=ckmzlG430P3JxbPJBPCw-4rwuVxtNOgJsCtfpZIeuoM,2137
25
- exa/common/control/sweep/option/center_span_options.py,sha256=Y6eKSwQ-hFWyvgMW43OnkwUD1qBkMcSdFwgKwWCzaj4,2111
26
- exa/common/control/sweep/option/constants.py,sha256=aNzcuLP4YYeCSpF114CDQx8-ZzOIbTTl6ZJydgYtqjg,1423
27
- exa/common/control/sweep/option/fixed_options.py,sha256=jBB0w0DpN_7skM6JhdT4op6FvBwFfh6iSqJgSEHVsgc,931
28
- exa/common/control/sweep/option/function_options.py,sha256=9X21CndZK_pubfkKtDvFBIJCOgrBr_t8Jx3suutAb-o,930
29
- exa/common/control/sweep/option/option_converter.py,sha256=RG9jmRbm-G4isnjBpbWFVT1M56hRVBkKYE2gOM6tJ98,3811
30
- exa/common/control/sweep/option/start_stop_base_options.py,sha256=a7iIJKNZC1osMsX5kC2Mo6xZ1EzoyFnkgH8C0HQbXRE,1836
31
- exa/common/control/sweep/option/start_stop_options.py,sha256=aR_ksYJsMlHwXhLqmLweTQq5Ix3sqKrnPVGQMLFnQe0,2498
32
- exa/common/control/sweep/option/sweep_options.py,sha256=ToyNX9FifKxa-_TTVCuFuTRZIdep8yBtPR86EgbtJrQ,698
33
- exa/common/data/__init__.py,sha256=F5SRe5QHBTjef4XJVQ63kO5Oxc_AiZnPbV560i7La0Y,644
34
- exa/common/data/parameter.py,sha256=A4a7hSUhW2eKn_d8ZNPpED2eJK-YyMktb-Z6_he9ImY,20759
35
- exa/common/data/setting_node.py,sha256=q9lkP60Y8NA0PW_jBbp39vCzwmzuBU6CejbK6xmOMJE,26980
36
- exa/common/data/settingnode_v2.html.jinja2,sha256=1cADQhBi0c7xewh1ZxWXBQqvTI-jxZNJdEUgS44SPWU,3125
37
- exa/common/errors/__init__.py,sha256=ArMBdpmx1EUenBpzrSNG63kmUf7PM0gCqSYnaCnL9Qk,597
38
- exa/common/errors/exa_error.py,sha256=eB_c-Qp1OchcBMr3LSyYitity4SochQh-nAghZmGLJU,975
39
- exa/common/helpers/__init__.py,sha256=IgtVD3tojIFA4MTV2mT5uYM6jb2qny9kBIIhEZT2PuI,610
40
- exa/common/helpers/data_helper.py,sha256=vhzJ63g1S2JqnCj0WJJuqWcuiIwKATnQeHdWw_3gkZg,1934
41
- exa/common/helpers/json_helper.py,sha256=VTcYU8FRgv3tXPifuogUWmVAzt_4JoQ_laTHolyodtA,2672
42
- exa/common/helpers/numpy_helper.py,sha256=KKKyZ_fD0O1gn7_InEQROYnX3WGMA6C1qHh8KzzjtUI,1062
43
- exa/common/helpers/software_version_helper.py,sha256=kpuQer4p1p4cj9_CzwziBSCX7wuH-FvfNw8G8U-EI3Y,5162
44
- exa/common/logger/__init__.py,sha256=1bIsGxHzfujXlkgtcAnWToKMkw3dpU5PEd_7LE_NpgQ,686
45
- exa/common/logger/logger.py,sha256=McZSKAl3JdfBnqd4RPJrO_mjN5mQ4XMJWSlEiq4fsCs,5716
46
- exa/common/qcm_data/__init__.py,sha256=VtsYkGoaniSjCkY0oQlqkcYJCtmC2sTDxfrIe_kpqZg,567
47
- exa/common/qcm_data/chad_model.py,sha256=MQ1xuRODOA6uzb3GJ4fgYx9cXS8z1DeRGw6HYKA9Sio,11223
48
- exa/common/qcm_data/chip_topology.py,sha256=OJU8-CXV7wfdxrn0HqryNZmxGRoffrg0vi0aMaiYbbY,19328
49
- exa/common/qcm_data/file_adapter.py,sha256=cqjnRUK-arKWEP4N7wwmH8nUjVZsNhM7aXaLjAQvSoE,2530
50
- exa/common/qcm_data/immutable_base_model.py,sha256=QXmKIWQbsbWQvovXwKT1d9jtyf2LNJtjQquIwO52zOU,901
51
- exa/common/qcm_data/qcm_data_client.py,sha256=dSjy_Rz8VDmtaOO698JfVIpNd_bPJ3Td0DG_I8vdXZ8,7676
52
- exa/common/sweep/__init__.py,sha256=uEKk5AtzSgSnf8Y0geRPwUpqXIBIXpeCxsN64sX7F1o,591
53
- exa/common/sweep/database_serialization.py,sha256=Qw0SFuT1zRxvDtwpq1aIruGxs4rVNB5AhqYmEVhUquU,9962
54
- exa/common/sweep/util.py,sha256=P8U93M1kBchpSvfBfDCq5tu0dhZsQYcKlCzUgCwSCJE,3786
55
- iqm_exa_common-25.33.dist-info/LICENSE.txt,sha256=R6Q7eUrLyoCQgWYorQ8WJmVmWKYU3dxA3jYUp0wwQAw,11332
56
- iqm_exa_common-25.33.dist-info/METADATA,sha256=P_uXhnzxJfkGYrQtVQTnqsPbRVseE176rT4MEZoHP3o,14548
57
- iqm_exa_common-25.33.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
58
- iqm_exa_common-25.33.dist-info/top_level.txt,sha256=Clphg2toaZ3_jSFRPhjMNEmLurkMNMc4lkK2EFYsSlM,4
59
- iqm_exa_common-25.33.dist-info/RECORD,,