azure-quantum 3.1.1.dev0__py3-none-any.whl → 3.1.1.dev2__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.
@@ -6,4 +6,4 @@
6
6
  # Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  # --------------------------------------------------------------------------
8
8
 
9
- VERSION = "3.1.1.dev0"
9
+ VERSION = "3.1.1.dev2"
@@ -2,6 +2,7 @@
2
2
  # Copyright (c) Microsoft Corporation.
3
3
  # Licensed under the MIT License.
4
4
  ##
5
+ import json
5
6
  import numpy as np
6
7
 
7
8
  from typing import TYPE_CHECKING, Any, Dict, Sequence
@@ -97,7 +98,7 @@ class QuantinuumTarget(Quantinuum, CirqTarget):
97
98
  metadata = {
98
99
  "qubits": len(program.all_qubits()),
99
100
  "repetitions": repetitions,
100
- "measurement_dict": self._measurement_dict(program)
101
+ "measurement_dict": json.dumps(self._measurement_dict(program))
101
102
  }
102
103
  # Override metadata with value from kwargs
103
104
  metadata.update(kwargs.get("metadata", {}))
@@ -59,7 +59,14 @@ class BaseJob(WorkspaceItem):
59
59
  @property
60
60
  def container_name(self):
61
61
  """Job input/output data container name"""
62
- return f"job-{self.id}"
62
+
63
+ if self._details.container_uri is None:
64
+ return f"job-{self.id}"
65
+ else:
66
+ container_uri = self._details.container_uri
67
+ path = urlparse(container_uri).path
68
+ container_name = path.split("/")[1]
69
+ return container_name
63
70
 
64
71
  @classmethod
65
72
  def from_input_data(
@@ -323,7 +330,10 @@ class BaseJob(WorkspaceItem):
323
330
 
324
331
  # Use Job's default container if not specified
325
332
  if container_uri is None:
326
- container_uri = self.workspace.get_container_uri(job_id=self.id)
333
+ if self._details.container_uri is None:
334
+ container_uri = self.workspace.get_container_uri(job_id=self.id)
335
+ else:
336
+ container_uri = self._details.container_uri
327
337
 
328
338
  uploaded_blob_uri = self.upload_input_data(
329
339
  container_uri = container_uri,
@@ -353,7 +363,10 @@ class BaseJob(WorkspaceItem):
353
363
 
354
364
  # Use Job's default container if not specified
355
365
  if container_uri is None:
356
- container_uri = self.workspace.get_container_uri(job_id=self.id)
366
+ if self._details.container_uri is None:
367
+ container_uri = self.workspace.get_container_uri(job_id=self.id)
368
+ else:
369
+ container_uri = self._details.container_uri
357
370
 
358
371
  container_client = ContainerClient.from_container_url(container_uri)
359
372
  blob_client = container_client.get_blob_client(name)
@@ -27,6 +27,8 @@ from qiskit_ionq.helpers import (
27
27
  if TYPE_CHECKING:
28
28
  from azure.quantum.qiskit import AzureQuantumProvider
29
29
 
30
+ import json
31
+
30
32
  import logging
31
33
 
32
34
  logger = logging.getLogger(__name__)
@@ -244,7 +246,7 @@ class IonQBackend(AzureBackend):
244
246
  _, _, meas_map = qiskit_circ_to_ionq_circ(circuit, gateset=self.gateset())
245
247
 
246
248
  metadata = super()._prepare_job_metadata(circuit, **kwargs)
247
- metadata["meas_map"] = meas_map
249
+ metadata["meas_map"] = json.dumps(meas_map)
248
250
 
249
251
  return metadata
250
252
 
@@ -240,10 +240,6 @@ class MicrosoftElementsDft(Target):
240
240
  # Check Model params
241
241
  self._check_dict_for_required_keys(input_params['model'], 'input_params["model"]', ['method', 'basis'])
242
242
 
243
- supported_drivers = ['energy', 'gradient', 'hessian', 'go', 'bomd']
244
- if input_params['driver'] not in supported_drivers:
245
- raise ValueError(f"Driver ({input_params['driver']}) is not supported. Please use one of {supported_drivers}.")
246
-
247
243
 
248
244
  @classmethod
249
245
  def _check_dict_for_required_keys(self, input_params: dict, dict_name: str, required_keys: list[str]):
@@ -317,4 +313,4 @@ class MicrosoftElementsDft(Target):
317
313
  return {
318
314
  "description": "This files contains the mapping between the xyz file name that were submitted and the qcschema blobs that are used for the calculation.",
319
315
  "tableOfContents": toc,
320
- }
316
+ }
@@ -250,4 +250,4 @@ class InputParams(InputParamsItem):
250
250
  if len(self.file_uris) > 0:
251
251
  result["fileUris"] = self.file_uris
252
252
 
253
- return result
253
+ return result
@@ -84,7 +84,7 @@ class Target(abc.ABC, SessionHost):
84
84
  :type output_data_format: str
85
85
  :param capability: QIR capability. Deprecated, use `target_profile`
86
86
  :type capability: str
87
- :param provider_id: Id of provider (ex. "microsoft-qc")
87
+ :param provider_id: Id of provider
88
88
  :type provider_id: str
89
89
  :param content_type: "Content-Type" attribute value to set on input blob (ex. "application/json")
90
90
  :type content_type: azure.quantum.job.ContentType
azure/quantum/version.py CHANGED
@@ -5,4 +5,4 @@
5
5
  # Copyright (c) Microsoft Corporation. All rights reserved.
6
6
  # Licensed under the MIT License.
7
7
  ##
8
- __version__ = "3.1.1.dev0"
8
+ __version__ = "3.1.1.dev2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: azure-quantum
3
- Version: 3.1.1.dev0
3
+ Version: 3.1.1.dev2
4
4
  Summary: Python client for Azure Quantum
5
5
  Home-page: https://github.com/microsoft/azure-quantum-python
6
6
  Author: Microsoft
@@ -14,7 +14,7 @@ Requires-Dist: azure-core<2.0,>=1.30
14
14
  Requires-Dist: azure-identity<2.0,>=1.17
15
15
  Requires-Dist: azure-storage-blob==12.20
16
16
  Requires-Dist: msrest<1.0,>=0.7.1
17
- Requires-Dist: numpy<2.0,>=1.21.0
17
+ Requires-Dist: numpy>=1.21.0
18
18
  Requires-Dist: deprecated<2.0,>=1.2.12
19
19
  Requires-Dist: Markdown>=3.4.1
20
20
  Requires-Dist: python-markdown-math>=0.8
@@ -31,7 +31,7 @@ Requires-Dist: pyqir<0.11,>=0.10.6; extra == "all"
31
31
  Requires-Dist: Markdown<4.0,>=3.4.1; extra == "all"
32
32
  Requires-Dist: python-markdown-math<1.0,>=0.8.0; extra == "all"
33
33
  Requires-Dist: qsharp<2.0,>=1.0.33; extra == "all"
34
- Requires-Dist: pyquil>=3.3.2; extra == "all"
34
+ Requires-Dist: pyquil==4.13.1; extra == "all"
35
35
  Provides-Extra: cirq
36
36
  Requires-Dist: cirq-core<=1.4.1,>=1.3.0; extra == "cirq"
37
37
  Requires-Dist: cirq-ionq<=1.4.1,>=1.3.0; extra == "cirq"
@@ -50,7 +50,7 @@ Requires-Dist: python-markdown-math<1.0,>=0.8.0; extra == "qiskit"
50
50
  Provides-Extra: qsharp
51
51
  Requires-Dist: qsharp<2.0,>=1.0.33; extra == "qsharp"
52
52
  Provides-Extra: quil
53
- Requires-Dist: pyquil>=3.3.2; extra == "quil"
53
+ Requires-Dist: pyquil==4.13.1; extra == "quil"
54
54
 
55
55
  ![Azure Quantum logo](https://raw.githubusercontent.com/microsoft/qdk-python/main/azure-quantum/Azure-Quantum-logo.png)
56
56
 
@@ -2,7 +2,7 @@ azure/quantum/__init__.py,sha256=Za8xZY4lzFkW8m4ero-bqrfN437D2NRukM77ukb4GPM,508
2
2
  azure/quantum/_constants.py,sha256=nDL_QrGdI_Zz_cvTB9nVgfE7J6A_Boo1ollMYqsiEBs,3499
3
3
  azure/quantum/_workspace_connection_params.py,sha256=KoT90U89Dj6pVwAKp_ENJL1hyTF0oQe7w0QioOGvjXg,21685
4
4
  azure/quantum/storage.py,sha256=_4bMniDk9LrB_K5CQwuCivJFZXdmhRvU2b6Z3xxXw9I,12556
5
- azure/quantum/version.py,sha256=mwhh54k6qbOq8jxdZyPBRH5_NU0LKAxQNCj9CPkOMRw,240
5
+ azure/quantum/version.py,sha256=kT6iAQuQmH3npEp-1ZuHMptXDTtsxidS3dtm45LNU2U,240
6
6
  azure/quantum/workspace.py,sha256=9oO4vjwIn1pdHFLZCQcEPQ_xjQjTNO4UIWSBQpj6Cgo,35574
7
7
  azure/quantum/_authentication/__init__.py,sha256=bniNZlS0hMIjO_y7DevGBAS6MixyA5pbPHcdGipUWM4,236
8
8
  azure/quantum/_authentication/_chained.py,sha256=0rdohB_fVGFHUhlly9sGxqQTBTZGpGxtlBqNHDFbAqE,4848
@@ -14,7 +14,7 @@ azure/quantum/_client/_configuration.py,sha256=FFUHJPp6X0015GpD-YLmYCoq8GI86nHCn
14
14
  azure/quantum/_client/_model_base.py,sha256=hu7OdRS2Ra1igfBo-R3zS3dzO3YhFC4FGHJ_WiyZgNg,43736
15
15
  azure/quantum/_client/_patch.py,sha256=YTV6yZ9bRfBBaw2z7v4MdzR-zeHkdtKkGb4SU8C25mE,694
16
16
  azure/quantum/_client/_serialization.py,sha256=bBl0y0mh-0sDd-Z8_dj921jQQhqhYWTOl59qSLuk01M,86686
17
- azure/quantum/_client/_version.py,sha256=E0hsuD8uvtrSiORFREhtmABWARMyqJN-bnfPGdlfMQg,500
17
+ azure/quantum/_client/_version.py,sha256=IweYXjVZv-WgI1yIRbwCoSP6EMpm2MDBFQBQCF6m3OU,500
18
18
  azure/quantum/_client/py.typed,sha256=dcrsqJrcYfTX-ckLFJMTaj6mD8aDe2u0tkQG-ZYxnEg,26
19
19
  azure/quantum/_client/models/__init__.py,sha256=MR2av7s_tCP66hicN9JXCmTngJ4_-ozM4cmblGjPwn8,1971
20
20
  azure/quantum/_client/models/_enums.py,sha256=RNCPXxeae4d7wtPqcSxu5JZBLFLZZYVZbALjui_f1fM,4288
@@ -25,16 +25,15 @@ azure/quantum/_client/operations/_operations.py,sha256=EL4c4l1t6VwdIay8_V2PomXYd
25
25
  azure/quantum/_client/operations/_patch.py,sha256=YTV6yZ9bRfBBaw2z7v4MdzR-zeHkdtKkGb4SU8C25mE,694
26
26
  azure/quantum/argument_types/__init__.py,sha256=AEDyuUMipR2za248GrRzqxfzr0Ysd8tj2F0OQBSFKWg,255
27
27
  azure/quantum/argument_types/types.py,sha256=2mM8s37DKgNfSsjzwmg4dnmj9roSeHY1ZT5vKnpjAYM,1041
28
- azure/quantum/chemistry/__init__.py,sha256=IWy-J-agQviD6GN5Px9c3X6MgMO_QhUKon5ZvQWEHJM,351
29
28
  azure/quantum/cirq/__init__.py,sha256=AJT_qCdxfqgeiPmqmbxQgCzETCOIJyHYoy6pCs-OskQ,227
30
29
  azure/quantum/cirq/job.py,sha256=Wm52HFYel9Di6xGdzDdYfBLM3ZklaE1qOQ9YNg87eeY,3031
31
30
  azure/quantum/cirq/service.py,sha256=5TcBvdULJJD_KsZna35dWYfkn7EY8Rge0ucnkwgJS3w,7833
32
31
  azure/quantum/cirq/targets/__init__.py,sha256=cpb677Kg1V5cdI0kdgkLafI8xfwYZZYx0tc6qc024gE,574
33
32
  azure/quantum/cirq/targets/ionq.py,sha256=PIX6jGgzhfRdXOXuwGxATuiMr_Le0XNEJJ6-Itit_Ws,5998
34
- azure/quantum/cirq/targets/quantinuum.py,sha256=I0uxYV90jCSq-rttSTHbv7yuruqyxI5FCMJYdhkXhOI,3939
33
+ azure/quantum/cirq/targets/quantinuum.py,sha256=IQYMQes9PZkgxhUb2nZ1hIzStWWhnSUJMXkMGNBdztQ,3964
35
34
  azure/quantum/cirq/targets/target.py,sha256=1EEog72dFZoiOTQP7obOrCuO3VH0yjXGAIMeO6bm22o,2184
36
35
  azure/quantum/job/__init__.py,sha256=nFuOsG25a8WzYFLwA2fhA0JMNWtblfDjV5WRgB6UQbw,829
37
- azure/quantum/job/base_job.py,sha256=NwtI-dcpOfKp-ANnLAPKQVgT3t9BEv_MQSp1N47oKM0,13876
36
+ azure/quantum/job/base_job.py,sha256=GDwoJDxoaCwGz9TBuzlkuqXdU84L6FliO_2YWxnLnrE,14399
38
37
  azure/quantum/job/filtered_job.py,sha256=qZfxTuDp0hzK4wermn4GRzLxnDy4yM-j6oZQ3D0O4vI,1877
39
38
  azure/quantum/job/job.py,sha256=D6MMOUEvx_qLdyr7vU1t62MUNMapOnFgcMBYCt7-TXM,17721
40
39
  azure/quantum/job/job_failed_with_results_error.py,sha256=bSqOZ0c6FNbS9opvwkCXG9mfTkAiyZRvp_YA3V-ktEs,1597
@@ -46,28 +45,27 @@ azure/quantum/qiskit/job.py,sha256=El1wyQ98WZaR96IICkDV8kToRtcA7yG24L2eE9Wdx2c,1
46
45
  azure/quantum/qiskit/provider.py,sha256=kbZJgDX-hI-AD5rQfik4JHNnNd74oyfrKYauosqBRxw,10966
47
46
  azure/quantum/qiskit/backends/__init__.py,sha256=Ygx3GwVHbIJ9Bi-_KqVQsL7B3QfeL-qUKIMIEfuStGw,994
48
47
  azure/quantum/qiskit/backends/backend.py,sha256=pE5FSsLRy6JpfCGDWd7SFcnH8k8qz6-eJRwZ31fh58o,23361
49
- azure/quantum/qiskit/backends/ionq.py,sha256=YivsJSuLBWmOxpK1qk4aEr1eJvQkWHTG4y8Ak6t-QN8,13781
48
+ azure/quantum/qiskit/backends/ionq.py,sha256=exXdWL63CxlIIiK4bfSFpJCKXzJgjLKz5OL7CvOB0iE,13808
50
49
  azure/quantum/qiskit/backends/qci.py,sha256=c0YK-znG8TSAnFmeszo7mpKhM624QHszTQoapOqOvHg,4794
51
50
  azure/quantum/qiskit/backends/quantinuum.py,sha256=1ThH4mmk4CUG-2RTvwsFEXQ3TEvHPJnW7Lo6QYpC3QE,12705
52
51
  azure/quantum/qiskit/backends/rigetti.py,sha256=lTsa0UjPdsAZUvvfnBge7H22TvA7c-_3fU09ZTA4ARs,4146
53
52
  azure/quantum/target/__init__.py,sha256=F0nIEJdlbczmxAdtvPDWf8J1Y33_XjPzloliHeWpJos,689
54
53
  azure/quantum/target/ionq.py,sha256=2iS4H-fBJYRTCM7VJse3Hqya_y2iEuU5QBG3Oj4c-SU,3931
55
- azure/quantum/target/params.py,sha256=oI-35HUEMCskNjpxCJU3tjL664K-TxqAg5LA5xU0nso,9130
54
+ azure/quantum/target/params.py,sha256=Txpq_AKdVV8OeZjK1z48CIym--_a6wncorj4LmmlQ_E,9128
56
55
  azure/quantum/target/quantinuum.py,sha256=5xvYb0Q2KSQr6FJ_A1bc2904Gz6NF_Xmn8UJ79NMOZU,3306
57
- azure/quantum/target/target.py,sha256=Iz8GAM-4AjVnKHaI12By1G3wzT5ZUWQau8BVCFU7Vvo,16679
56
+ azure/quantum/target/target.py,sha256=jmB4mU32rQIViJ_Zq5qYh-ktLr9vv_vz-sKpvR8GY-M,16658
58
57
  azure/quantum/target/target_factory.py,sha256=jjZ9zxWaNDkcvslKV02GSP8rtXwStJ7EmVXQSOFh_j8,5266
59
- azure/quantum/target/microsoft/target.py,sha256=MlEBPhXYcHPBuORSeoslFgpw31C_cwJBf-xl0F18Jc8,6226
60
58
  azure/quantum/target/microsoft/elements/__init__.py,sha256=gVVpaN5086iuBnajtvTjSd7MLExtnsR6RDCmcgz6xpE,70
61
59
  azure/quantum/target/microsoft/elements/dft/__init__.py,sha256=kCXOA9HT-gb23An-A0eyktlB66VoH6EwNO4gPM97l3U,224
62
60
  azure/quantum/target/microsoft/elements/dft/job.py,sha256=6v7lZwXyUGrOI8J17akanMrFXrPVDhsZR3c6AFpa5So,6942
63
- azure/quantum/target/microsoft/elements/dft/target.py,sha256=MoQ-jlWU25ct7YTG_vSm5nJDrP-S5YRbxdspf1-OIWY,13089
61
+ azure/quantum/target/microsoft/elements/dft/target.py,sha256=10el-q7QO3k19sytnoBfRaMzd5H2RvGHqm4N5IZfcjQ,12826
64
62
  azure/quantum/target/pasqal/__init__.py,sha256=qbe6oWTQTsnTYwY3xZr32z4AWaYIchx71bYlqC2rQqw,348
65
63
  azure/quantum/target/pasqal/result.py,sha256=SUvpnrtgvCGiepmNpyifW8b4p14-SZZ1ToCC0NAdIwg,1463
66
64
  azure/quantum/target/pasqal/target.py,sha256=K_vqavov6gvS84voRKeBx9pO8g4LrtWrlZ5-RMLWozw,5139
67
65
  azure/quantum/target/rigetti/__init__.py,sha256=I1vyzZBYGI540pauTqJd0RSSyTShGqkEL7Yjo25_RNY,378
68
66
  azure/quantum/target/rigetti/result.py,sha256=65mtAZxfdNrTWNjWPqgfwt2BZN6Nllo4g_bls7-Nm68,2334
69
67
  azure/quantum/target/rigetti/target.py,sha256=5C8p7CVKKXsaBM0BLFA4MrBwvLtY5INp4GQsE9t4P1U,7407
70
- azure_quantum-3.1.1.dev0.dist-info/METADATA,sha256=I9nmdcKDNZsgiyU2FYnS33dH93y4Q-dJuG_83MozFfM,7362
71
- azure_quantum-3.1.1.dev0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
72
- azure_quantum-3.1.1.dev0.dist-info/top_level.txt,sha256=S7DhWV9m80TBzAhOFjxDUiNbKszzoThbnrSz5MpbHSQ,6
73
- azure_quantum-3.1.1.dev0.dist-info/RECORD,,
68
+ azure_quantum-3.1.1.dev2.dist-info/METADATA,sha256=MkoZOkF6W1Ctm5W0mQ_f5z0i-7m6wUSvyOe-s7xCCoU,7359
69
+ azure_quantum-3.1.1.dev2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
70
+ azure_quantum-3.1.1.dev2.dist-info/top_level.txt,sha256=S7DhWV9m80TBzAhOFjxDUiNbKszzoThbnrSz5MpbHSQ,6
71
+ azure_quantum-3.1.1.dev2.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- ##
2
- # Copyright (c) Microsoft Corporation. All rights reserved.
3
- # Licensed under the MIT License.
4
- ##
5
-
6
- from urllib.request import urlopen
7
-
8
- def df_chemistry() -> bytes:
9
- """
10
- Returns bitcode of a QIR program for the double-factorized chemistry
11
- quantum algorithm.
12
- """
13
- return urlopen("https://aka.ms/RE/df_chemistry").read()
@@ -1,142 +0,0 @@
1
- ##
2
- # Copyright (c) Microsoft Corporation. All rights reserved.
3
- # Licensed under the MIT License.
4
- ##
5
- import re
6
- import warnings
7
- from dataclasses import dataclass, field
8
- from typing import Any, Dict, Optional, Type, Union, List
9
-
10
- from ...job import Job
11
- from ...job.base_job import ContentType
12
- from ...workspace import Workspace
13
- from ..params import InputParams, InputParamsItem, AutoValidatingParams, \
14
- validating_field
15
- from ..target import Target
16
-
17
- def _check_error_rate(name, value):
18
- if value <= 0.0 or value >= 1.0:
19
- raise ValueError(f"{name} must be between 0 and 1")
20
-
21
- def _check_error_rate_or_process_and_readout(name, value):
22
- if value is None:
23
- return
24
-
25
- if isinstance(value, float):
26
- _check_error_rate(name, value)
27
- return
28
-
29
- if not isinstance(value, MeasurementErrorRate):
30
- raise ValueError(f"{name} must be either a float or "
31
- "MeasurementErrorRate with two fields: 'process' and 'readout'")
32
-
33
- def check_time(name, value):
34
- pat = r"^(\+?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*(s|ms|μs|µs|us|ns)$"
35
- if re.match(pat, value) is None:
36
- raise ValueError(f"{name} is not a valid time string; use a "
37
- "suffix s, ms, us, or ns")
38
-
39
- @dataclass
40
- class MeasurementErrorRate(AutoValidatingParams):
41
- process: float = field(metadata={"validate": _check_error_rate})
42
- readout: float = field(metadata={"validate": _check_error_rate})
43
-
44
- @dataclass
45
- class ProtocolSpecificDistillationUnitSpecification(AutoValidatingParams):
46
- num_unit_qubits: Optional[int] = None
47
- duration_in_qubit_cycle_time: Optional[int] = None
48
-
49
- def post_validation(self, result):
50
- if self.num_unit_qubits is None:
51
- raise LookupError("num_unit_qubits must be set")
52
-
53
- if self.duration_in_qubit_cycle_time is None:
54
- raise LookupError("duration_in_qubit_cycle_time must be set")
55
-
56
-
57
- @dataclass
58
- class DistillationUnitSpecification(AutoValidatingParams):
59
- name: Optional[str] = None
60
- display_name: Optional[str] = None
61
- num_input_ts: Optional[int] = None
62
- num_output_ts: Optional[int] = None
63
- failure_probability_formula: Optional[str] = None
64
- output_error_rate_formula: Optional[str] = None
65
- physical_qubit_specification: Optional[ProtocolSpecificDistillationUnitSpecification] = None
66
- logical_qubit_specification: Optional[ProtocolSpecificDistillationUnitSpecification] = None
67
- logical_qubit_specification_first_round_override: \
68
- Optional[ProtocolSpecificDistillationUnitSpecification] = None
69
-
70
- def has_custom_specification(self):
71
- return \
72
- self.display_name is not None \
73
- or self.num_input_ts is not None \
74
- or self.num_output_ts is not None \
75
- or self.failure_probability_formula is not None \
76
- or self.output_error_rate_formula is not None \
77
- or self.physical_qubit_specification is not None \
78
- or self.logical_qubit_specification is not None \
79
- or self.logical_qubit_specification_first_round_override is not None
80
-
81
- def has_predefined_name(self):
82
- return self.name is not None
83
-
84
- def post_validation(self, result):
85
- if not self.has_custom_specification() and not self.has_predefined_name():
86
- raise LookupError("name must be set or custom specification must be provided")
87
-
88
- if self.has_custom_specification() and self.has_predefined_name():
89
- raise LookupError("If predefined name is provided, "
90
- "custom specification is not allowed. "
91
- "Either remove name or remove all other "
92
- "specification of the distillation unit")
93
-
94
- if self.has_predefined_name():
95
- return # all other validation is on the server side
96
-
97
- if self.num_input_ts is None:
98
- raise LookupError("num_input_ts must be set")
99
-
100
- if self.num_output_ts is None:
101
- raise LookupError("num_output_ts must be set")
102
-
103
- if self.failure_probability_formula is None:
104
- raise LookupError("failure_probability_formula must be set")
105
-
106
- if self.output_error_rate_formula is None:
107
- raise LookupError("output_error_rate_formula must be set")
108
-
109
- if self.physical_qubit_specification is not None:
110
- self.physical_qubit_specification.post_validation(result)
111
-
112
- if self.logical_qubit_specification is not None:
113
- self.logical_qubit_specification.post_validation(result)
114
-
115
- if self.logical_qubit_specification_first_round_override is not None:
116
- self.logical_qubit_specification_first_round_override.post_validation(result)
117
-
118
- def as_dict(self, validate=True) -> Dict[str, Any]:
119
- specification_dict = super().as_dict(validate)
120
- if len(specification_dict) != 0:
121
- if self.physical_qubit_specification is not None:
122
- physical_qubit_specification_dict = \
123
- self.physical_qubit_specification.as_dict(validate)
124
- if len(physical_qubit_specification_dict) != 0:
125
- specification_dict["physicalQubitSpecification"] = \
126
- physical_qubit_specification_dict
127
-
128
- if self.logical_qubit_specification is not None:
129
- logical_qubit_specification_dict = \
130
- self.logical_qubit_specification.as_dict(validate)
131
- if len(logical_qubit_specification_dict) != 0:
132
- specification_dict["logicalQubitSpecification"] = \
133
- logical_qubit_specification_dict
134
-
135
- if self.logical_qubit_specification_first_round_override is not None:
136
- logical_qubit_specification_first_round_override_dict = \
137
- self.logical_qubit_specification_first_round_override.as_dict(validate)
138
- if len(logical_qubit_specification_first_round_override_dict) != 0:
139
- specification_dict["logicalQubitSpecificationFirstRoundOverride"] = \
140
- logical_qubit_specification_first_round_override_dict
141
-
142
- return specification_dict