libqasm 0.6.8__cp311-cp311-macosx_11_0_arm64.whl → 1.0.0__cp311-cp311-macosx_11_0_arm64.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.
cqasm/v3x/ast.py CHANGED
@@ -8387,17 +8387,20 @@ class NonGateInstruction(Instruction):
8387
8387
  __slots__ = [
8388
8388
  '_attr_name',
8389
8389
  '_attr_operands',
8390
+ '_attr_parameter',
8390
8391
  ]
8391
8392
 
8392
8393
  def __init__(
8393
8394
  self,
8394
8395
  name=None,
8395
8396
  operands=None,
8397
+ parameter=None,
8396
8398
  annotations=None,
8397
8399
  ):
8398
8400
  super().__init__(annotations=annotations)
8399
8401
  self.name = name
8400
8402
  self.operands = operands
8403
+ self.parameter = parameter
8401
8404
 
8402
8405
  @property
8403
8406
  def name(self):
@@ -8439,6 +8442,26 @@ class NonGateInstruction(Instruction):
8439
8442
  def operands(self):
8440
8443
  self._attr_operands = None
8441
8444
 
8445
+ @property
8446
+ def parameter(self):
8447
+ return self._attr_parameter
8448
+
8449
+ @parameter.setter
8450
+ def parameter(self, val):
8451
+ if val is None:
8452
+ del self.parameter
8453
+ return
8454
+ if not isinstance(val, Expression):
8455
+ # Try to "typecast" if this isn't an obvious mistake.
8456
+ if isinstance(val, Node):
8457
+ raise TypeError('parameter must be of type Expression')
8458
+ val = Expression(val)
8459
+ self._attr_parameter = val
8460
+
8461
+ @parameter.deleter
8462
+ def parameter(self):
8463
+ self._attr_parameter = None
8464
+
8442
8465
  def __eq__(self, other):
8443
8466
  """Equality operator. Ignores annotations!"""
8444
8467
  if not isinstance(other, NonGateInstruction):
@@ -8447,6 +8470,8 @@ class NonGateInstruction(Instruction):
8447
8470
  return False
8448
8471
  if self.operands != other.operands:
8449
8472
  return False
8473
+ if self.parameter != other.parameter:
8474
+ return False
8450
8475
  if self.annotations != other.annotations:
8451
8476
  return False
8452
8477
  return True
@@ -8483,6 +8508,14 @@ class NonGateInstruction(Instruction):
8483
8508
  s.append(self.operands.dump(indent + 1, annotations, links) + '\n')
8484
8509
  s.append(' '*indent + '>\n')
8485
8510
  s.append(' '*indent)
8511
+ s.append('parameter: ')
8512
+ if self.parameter is None:
8513
+ s.append('-\n')
8514
+ else:
8515
+ s.append('<\n')
8516
+ s.append(self.parameter.dump(indent + 1, annotations, links) + '\n')
8517
+ s.append(' '*indent + '>\n')
8518
+ s.append(' '*indent)
8486
8519
  s.append('annotations: ')
8487
8520
  if not self.annotations:
8488
8521
  s.append('-\n')
@@ -8512,6 +8545,8 @@ class NonGateInstruction(Instruction):
8512
8545
  self._attr_name.find_reachable(id_map)
8513
8546
  if self._attr_operands is not None:
8514
8547
  self._attr_operands.find_reachable(id_map)
8548
+ if self._attr_parameter is not None:
8549
+ self._attr_parameter.find_reachable(id_map)
8515
8550
  for el in self._attr_annotations:
8516
8551
  el.find_reachable(id_map)
8517
8552
  return id_map
@@ -8531,6 +8566,8 @@ class NonGateInstruction(Instruction):
8531
8566
  raise NotWellFormed('operands is required but not set')
8532
8567
  if self._attr_operands is not None:
8533
8568
  self._attr_operands.check_complete(id_map)
8569
+ if self._attr_parameter is not None:
8570
+ self._attr_parameter.check_complete(id_map)
8534
8571
  for child in self._attr_annotations:
8535
8572
  child.check_complete(id_map)
8536
8573
 
@@ -8539,6 +8576,7 @@ class NonGateInstruction(Instruction):
8539
8576
  return NonGateInstruction(
8540
8577
  name=self._attr_name,
8541
8578
  operands=self._attr_operands,
8579
+ parameter=self._attr_parameter,
8542
8580
  annotations=self._attr_annotations.copy()
8543
8581
  )
8544
8582
 
@@ -8551,6 +8589,7 @@ class NonGateInstruction(Instruction):
8551
8589
  return NonGateInstruction(
8552
8590
  name=_cloned(self._attr_name),
8553
8591
  operands=_cloned(self._attr_operands),
8592
+ parameter=_cloned(self._attr_parameter),
8554
8593
  annotations=_cloned(self._attr_annotations)
8555
8594
  )
8556
8595
 
@@ -8592,6 +8631,17 @@ class NonGateInstruction(Instruction):
8592
8631
  else:
8593
8632
  f_operands = ExpressionList._deserialize(field, seq_to_ob, links)
8594
8633
 
8634
+ # Deserialize the parameter field.
8635
+ field = cbor.get('parameter', None)
8636
+ if not isinstance(field, dict):
8637
+ raise ValueError('missing or invalid serialization of field parameter')
8638
+ if field.get('@T') != '?':
8639
+ raise ValueError('unexpected edge type for field parameter')
8640
+ if field.get('@t', None) is None:
8641
+ f_parameter = None
8642
+ else:
8643
+ f_parameter = Expression._deserialize(field, seq_to_ob, links)
8644
+
8595
8645
  # Deserialize the annotations field.
8596
8646
  field = cbor.get('annotations', None)
8597
8647
  if not isinstance(field, dict):
@@ -8608,7 +8658,7 @@ class NonGateInstruction(Instruction):
8608
8658
  f_annotations.append(AnnotationData._deserialize(element, seq_to_ob, links))
8609
8659
 
8610
8660
  # Construct the NonGateInstruction node.
8611
- node = NonGateInstruction(f_name, f_operands, f_annotations)
8661
+ node = NonGateInstruction(f_name, f_operands, f_parameter, f_annotations)
8612
8662
 
8613
8663
  # Deserialize annotations.
8614
8664
  for key, val in cbor.items():
@@ -8650,6 +8700,14 @@ class NonGateInstruction(Instruction):
8650
8700
  field.update(self._attr_operands._serialize(id_map))
8651
8701
  cbor['operands'] = field
8652
8702
 
8703
+ # Serialize the parameter field.
8704
+ field = {'@T': '?'}
8705
+ if self._attr_parameter is None:
8706
+ field['@t'] = None
8707
+ else:
8708
+ field.update(self._attr_parameter._serialize(id_map))
8709
+ cbor['parameter'] = field
8710
+
8653
8711
  # Serialize the annotations field.
8654
8712
  field = {'@T': '*'}
8655
8713
  lst = []
cqasm/v3x/semantic.py CHANGED
@@ -1973,6 +1973,7 @@ class NonGateInstruction(Instruction):
1973
1973
  '_attr_instruction_ref',
1974
1974
  '_attr_name',
1975
1975
  '_attr_operands',
1976
+ '_attr_parameter',
1976
1977
  ]
1977
1978
 
1978
1979
  def __init__(
@@ -1980,12 +1981,14 @@ class NonGateInstruction(Instruction):
1980
1981
  instruction_ref=None,
1981
1982
  name=None,
1982
1983
  operands=None,
1984
+ parameter=None,
1983
1985
  annotations=None,
1984
1986
  ):
1985
1987
  super().__init__(annotations=annotations)
1986
1988
  self.instruction_ref = instruction_ref
1987
1989
  self.name = name
1988
1990
  self.operands = operands
1991
+ self.parameter = parameter
1989
1992
 
1990
1993
  @property
1991
1994
  def instruction_ref(self):
@@ -2047,6 +2050,26 @@ class NonGateInstruction(Instruction):
2047
2050
  def operands(self):
2048
2051
  self._attr_operands = cqasm.v3x.values.MultiValueBase()
2049
2052
 
2053
+ @property
2054
+ def parameter(self):
2055
+ return self._attr_parameter
2056
+
2057
+ @parameter.setter
2058
+ def parameter(self, val):
2059
+ if val is None:
2060
+ del self.parameter
2061
+ return
2062
+ if not isinstance(val, cqasm.v3x.values.ValueBase):
2063
+ # Try to "typecast" if this isn't an obvious mistake.
2064
+ if isinstance(val, Node):
2065
+ raise TypeError('parameter must be of type cqasm.v3x.values.ValueBase')
2066
+ val = cqasm.v3x.values.ValueBase(val)
2067
+ self._attr_parameter = val
2068
+
2069
+ @parameter.deleter
2070
+ def parameter(self):
2071
+ self._attr_parameter = None
2072
+
2050
2073
  def __eq__(self, other):
2051
2074
  """Equality operator. Ignores annotations!"""
2052
2075
  if not isinstance(other, NonGateInstruction):
@@ -2057,6 +2080,8 @@ class NonGateInstruction(Instruction):
2057
2080
  return False
2058
2081
  if self.operands != other.operands:
2059
2082
  return False
2083
+ if self.parameter != other.parameter:
2084
+ return False
2060
2085
  if self.annotations != other.annotations:
2061
2086
  return False
2062
2087
  return True
@@ -2092,6 +2117,14 @@ class NonGateInstruction(Instruction):
2092
2117
  s.append(child.dump(indent + 1, annotations, links) + '\n')
2093
2118
  s.append(' '*indent + ']\n')
2094
2119
  s.append(' '*indent)
2120
+ s.append('parameter: ')
2121
+ if self.parameter is None:
2122
+ s.append('-\n')
2123
+ else:
2124
+ s.append('<\n')
2125
+ s.append(self.parameter.dump(indent + 1, annotations, links) + '\n')
2126
+ s.append(' '*indent + '>\n')
2127
+ s.append(' '*indent)
2095
2128
  s.append('annotations: ')
2096
2129
  if not self.annotations:
2097
2130
  s.append('-\n')
@@ -2119,6 +2152,8 @@ class NonGateInstruction(Instruction):
2119
2152
  id_map[id(self)] = len(id_map)
2120
2153
  for el in self._attr_operands:
2121
2154
  el.find_reachable(id_map)
2155
+ if self._attr_parameter is not None:
2156
+ self._attr_parameter.find_reachable(id_map)
2122
2157
  for el in self._attr_annotations:
2123
2158
  el.find_reachable(id_map)
2124
2159
  return id_map
@@ -2132,6 +2167,8 @@ class NonGateInstruction(Instruction):
2132
2167
  id_map = self.find_reachable()
2133
2168
  for child in self._attr_operands:
2134
2169
  child.check_complete(id_map)
2170
+ if self._attr_parameter is not None:
2171
+ self._attr_parameter.check_complete(id_map)
2135
2172
  for child in self._attr_annotations:
2136
2173
  child.check_complete(id_map)
2137
2174
 
@@ -2141,6 +2178,7 @@ class NonGateInstruction(Instruction):
2141
2178
  instruction_ref=self._attr_instruction_ref,
2142
2179
  name=self._attr_name,
2143
2180
  operands=self._attr_operands.copy(),
2181
+ parameter=self._attr_parameter,
2144
2182
  annotations=self._attr_annotations.copy()
2145
2183
  )
2146
2184
 
@@ -2154,6 +2192,7 @@ class NonGateInstruction(Instruction):
2154
2192
  instruction_ref=_cloned(self._attr_instruction_ref),
2155
2193
  name=_cloned(self._attr_name),
2156
2194
  operands=_cloned(self._attr_operands),
2195
+ parameter=_cloned(self._attr_parameter),
2157
2196
  annotations=_cloned(self._attr_annotations)
2158
2197
  )
2159
2198
 
@@ -2206,6 +2245,17 @@ class NonGateInstruction(Instruction):
2206
2245
  raise ValueError('unexpected edge type for Any/Many element')
2207
2246
  f_operands.append(cqasm.v3x.values.ValueBase._deserialize(element, seq_to_ob, links))
2208
2247
 
2248
+ # Deserialize the parameter field.
2249
+ field = cbor.get('parameter', None)
2250
+ if not isinstance(field, dict):
2251
+ raise ValueError('missing or invalid serialization of field parameter')
2252
+ if field.get('@T') != '?':
2253
+ raise ValueError('unexpected edge type for field parameter')
2254
+ if field.get('@t', None) is None:
2255
+ f_parameter = None
2256
+ else:
2257
+ f_parameter = cqasm.v3x.values.ValueBase._deserialize(field, seq_to_ob, links)
2258
+
2209
2259
  # Deserialize the annotations field.
2210
2260
  field = cbor.get('annotations', None)
2211
2261
  if not isinstance(field, dict):
@@ -2222,7 +2272,7 @@ class NonGateInstruction(Instruction):
2222
2272
  f_annotations.append(AnnotationData._deserialize(element, seq_to_ob, links))
2223
2273
 
2224
2274
  # Construct the NonGateInstruction node.
2225
- node = NonGateInstruction(f_instruction_ref, f_name, f_operands, f_annotations)
2275
+ node = NonGateInstruction(f_instruction_ref, f_name, f_operands, f_parameter, f_annotations)
2226
2276
 
2227
2277
  # Deserialize annotations.
2228
2278
  for key, val in cbor.items():
@@ -2270,6 +2320,14 @@ class NonGateInstruction(Instruction):
2270
2320
  field['@d'] = lst
2271
2321
  cbor['operands'] = field
2272
2322
 
2323
+ # Serialize the parameter field.
2324
+ field = {'@T': '?'}
2325
+ if self._attr_parameter is None:
2326
+ field['@t'] = None
2327
+ else:
2328
+ field.update(self._attr_parameter._serialize(id_map))
2329
+ cbor['parameter'] = field
2330
+
2273
2331
  # Serialize the annotations field.
2274
2332
  field = {'@T': '*'}
2275
2333
  lst = []
Binary file
libqasm/libqasm.py CHANGED
@@ -1,5 +1,5 @@
1
1
  # This file was automatically generated by SWIG (https://www.swig.org).
2
- # Version 4.2.1
2
+ # Version 4.3.0
3
3
  #
4
4
  # Do not make changes to this file unless you know what you are doing - modify
5
5
  # the SWIG interface file instead.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: libqasm
3
- Version: 0.6.8
3
+ Version: 1.0.0
4
4
  Summary: libqasm Python Package
5
5
  Home-page: https://github.com/QuTech-Delft/libqasm
6
6
  Author: QuTech, TU Delft
@@ -17,11 +17,19 @@ Classifier: Topic :: Scientific/Engineering
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE.md
19
19
  Requires-Dist: numpy
20
+ Dynamic: author
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: home-page
25
+ Dynamic: requires-dist
26
+ Dynamic: summary
20
27
 
21
28
  # libQASM
22
29
 
23
30
  [![CI](https://github.com/QuTech-Delft/libqasm/workflows/Test/badge.svg)](https://github.com/qutech-delft/libqasm/actions)
24
31
  [![Conan Center](https://img.shields.io/conan/v/libqasm)](https://conan.io/center/recipes/libqasm)
32
+ [![cpp-linter](https://github.com/cpp-linter/cpp-linter-action/actions/workflows/cpp-linter.yml/badge.svg)](https://github.com/cpp-linter/cpp-linter-action/actions/workflows/cpp-linter.yml)
25
33
  [![PyPI](https://badgen.net/pypi/v/libqasm)](https://pypi.org/project/libqasm/)
26
34
  ![OS](https://img.shields.io/badge/os-emscripten%20%7C%20linux%20%7C%20macos%20%7C%20windows-blue?style=flat-square)
27
35
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
@@ -62,7 +70,7 @@ CNOT q[0], q[1]
62
70
  b = measure q
63
71
  ```
64
72
 
65
- We can parse or analyze this circuit, using libQASM through the following programming language:
73
+ We can parse or analyze this circuit using libQASM through the following programming language:
66
74
 
67
75
  ### C++
68
76
 
@@ -77,7 +85,6 @@ int main() {
77
85
  }
78
86
  ```
79
87
 
80
-
81
88
  ### Emscripten
82
89
 
83
90
  The emscripten API only allows to input a cQASM program as a string.
@@ -0,0 +1,16 @@
1
+ cqasm/__init__.py,sha256=MsSFjiLMLJZ7QhUPpVBWKiyDnCzryquRyr329NoCACI,2
2
+ cqasm/v3x/values.py,sha256=YY_41YQ7iU2te7FqtstGnQJd4W3CFH7LmkawSKh5e_A,61680
3
+ cqasm/v3x/semantic.py,sha256=mcV3SzqKU-IBBGb6PgryApCEG_qZwehbjqe4BqAdkp4,116741
4
+ cqasm/v3x/primitives.py,sha256=aB-srIVOWSAmEWfmDk9-kHgKqTcvHQzSXCfCivUj4ic,2038
5
+ cqasm/v3x/__init__.py,sha256=4MVCcT7wu69SVoJ6sQ_tXFeHdEUILyVDtvyZ_eqd3Tw,4774
6
+ cqasm/v3x/types.py,sha256=izXYdNmYvJUcRSZVLJ-blPnU2TmhOGR1Z3Rhtk8rTOQ,63328
7
+ cqasm/v3x/ast.py,sha256=V-_2fREv8Ql3xqtNY8tzeeqsFswSfk_axrO2filmx2w,422188
8
+ cqasm/v3x/instruction.py,sha256=AEOwKV2riafpyTiJvgq7azwOhyhhZfpKV12uWWJ5M2A,1177
9
+ libqasm/__init__.py,sha256=liVJFi24VHbmUU-9lBA6hm-xPpF1DgzXMsZ0f1dqO3E,727
10
+ libqasm/_libqasm.cpython-311-darwin.so,sha256=rn8cjkhT3Ax5DfmgWE4LRehJNkFGYoMaE42cPGiI0eI,4165800
11
+ libqasm/libqasm.py,sha256=AtVuO_pMe2Xnbzul1xMDCtcTzaJrn_KdDXYB1lSxLpM,30619
12
+ libqasm-1.0.0.dist-info/LICENSE.md,sha256=duRlJgy46W8Cw_IQjOmud5xJUvgJkX6pkBmBJkoKi4I,566
13
+ libqasm-1.0.0.dist-info/RECORD,,
14
+ libqasm-1.0.0.dist-info/WHEEL,sha256=uZm-0PiOS8tRdZxJBJgtzs5SssLMMKtm3LCPIWseOMM,109
15
+ libqasm-1.0.0.dist-info/top_level.txt,sha256=iZ8PSLyg3lJwvSUCvWE8VCJGU-nmQY2YIrbMe7M7kLw,14
16
+ libqasm-1.0.0.dist-info/METADATA,sha256=AVVav0WiFJBzuZyWxTSMELHW5lCGo1rqvOokwbleYDU,4373
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.2.0)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp311-cp311-macosx_11_0_arm64
5
5
 
@@ -1,16 +0,0 @@
1
- cqasm/__init__.py,sha256=MsSFjiLMLJZ7QhUPpVBWKiyDnCzryquRyr329NoCACI,2
2
- cqasm/v3x/values.py,sha256=YY_41YQ7iU2te7FqtstGnQJd4W3CFH7LmkawSKh5e_A,61680
3
- cqasm/v3x/semantic.py,sha256=Zmi8Vx7-0NKw2VJnsqXUFlMXeoSF6oOu21PUVtAubG8,114603
4
- cqasm/v3x/primitives.py,sha256=aB-srIVOWSAmEWfmDk9-kHgKqTcvHQzSXCfCivUj4ic,2038
5
- cqasm/v3x/__init__.py,sha256=4MVCcT7wu69SVoJ6sQ_tXFeHdEUILyVDtvyZ_eqd3Tw,4774
6
- cqasm/v3x/types.py,sha256=izXYdNmYvJUcRSZVLJ-blPnU2TmhOGR1Z3Rhtk8rTOQ,63328
7
- cqasm/v3x/ast.py,sha256=jzywgJ3_x7eQ3Nq15rkzRoXidjHqWFHov42QKOgXt4o,420114
8
- cqasm/v3x/instruction.py,sha256=AEOwKV2riafpyTiJvgq7azwOhyhhZfpKV12uWWJ5M2A,1177
9
- libqasm/__init__.py,sha256=liVJFi24VHbmUU-9lBA6hm-xPpF1DgzXMsZ0f1dqO3E,727
10
- libqasm/_libqasm.cpython-311-darwin.so,sha256=PEn8oIplm-hQ0uH9wOXoeomk_qjtoF1eEGW_qlTBYtY,4142744
11
- libqasm/libqasm.py,sha256=WVRqVvVJY0MABhWZJrnuY9eyNJuZI5fQLYNevrQYPe4,30619
12
- libqasm-0.6.8.dist-info/LICENSE.md,sha256=duRlJgy46W8Cw_IQjOmud5xJUvgJkX6pkBmBJkoKi4I,566
13
- libqasm-0.6.8.dist-info/RECORD,,
14
- libqasm-0.6.8.dist-info/WHEEL,sha256=wZi4olA0NR6c8yfzURN7DX9ImcSoHfH-g7UT7-9uFnE,109
15
- libqasm-0.6.8.dist-info/top_level.txt,sha256=iZ8PSLyg3lJwvSUCvWE8VCJGU-nmQY2YIrbMe7M7kLw,14
16
- libqasm-0.6.8.dist-info/METADATA,sha256=E7LHVGvGudRBpwPi8yhqik2SbzYdpCRH4v1yKL9QJp4,4035