You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Error type for conversion between tket2 ops and pytket operations.
283
+
#[derive(derive_more::Debug,Display,Error)]
284
+
#[non_exhaustive]
285
+
pubenumTk1DecodeError{
286
+
/// The pytket circuit uses multi-indexed registers.
287
+
//
288
+
// This could be supported in the future, if there is a need for it.
289
+
#[display("Register {register} in the circuit has multiple indices. Tket2 does not support multi-indexed registers.")]
290
+
MultiIndexedRegister{
291
+
/// The register name.
292
+
register:String,
293
+
},
294
+
/// Found an unexpected register name.
295
+
#[display("Found an unknown qubit register name: {register}.")]
296
+
UnknownQubitRegister{
297
+
/// The unknown register name.
298
+
register:String,
299
+
},
300
+
/// Found an unexpected bit register name.
301
+
#[display("Found an unknown bit register name: {register}.")]
302
+
UnknownBitRegister{
303
+
/// The unknown register name.
304
+
register:String,
305
+
},
306
+
/// The given signature to use for the HUGR's input wires is not compatible with the number of qubits and bits in the pytket circuit.
307
+
///
308
+
/// The expected number of qubits and bits may be different depending on the [`PytketTypeTranslator`][extension::PytketTypeTranslator]s used in the decoder config.
309
+
#[display(
310
+
"The given input types {input_types} to use for the HUGR's input wires are not compatible with the number of qubits and bits in the pytket circuit. Expected {expected_qubits} qubits and {expected_bits} bits, but found {circ_qubits} qubits and {circ_bits} bits.",
311
+
input_types = input_types.iter().join(", "),
312
+
)]
313
+
InvalidInputSignature{
314
+
/// The given input types.
315
+
input_types:Vec<String>,
316
+
/// The expected number of qubits in the signature.
317
+
expected_qubits:usize,
318
+
/// The expected number of bits in the signature.
319
+
expected_bits:usize,
320
+
/// The number of qubits in the pytket circuit.
321
+
circ_qubits:usize,
322
+
/// The number of bits in the pytket circuit.
323
+
circ_bits:usize,
324
+
},
325
+
/// The signature to use for the HUGR's output wires is not compatible with the number of qubits and bits in the pytket circuit.
326
+
///
327
+
/// We don't do any kind of type conversion, so this depends solely on the last operation to update each register.
328
+
#[display(
329
+
"The expected output types {expected_types} are not compatible with the actual output types {actual_types}, obtained from decoding the pytket circuit.",
/// A pytket operation had some input registers that couldn't be mapped to hugr wires.
340
+
//
341
+
// Some of this errors will be avoided in the future once we are able to decompose complex types automatically.
342
+
#[display(
343
+
"Could not find a wire with the required qubit arguments [{qubit_args:?}] and bit arguments [{bit_args:?}] for operation {operation}.",
344
+
qubit_args = qubit_args.iter().join(", "),
345
+
bit_args = bit_args.iter().join(", "),
346
+
)]
347
+
ArgumentCouldNotBeMapped{
348
+
/// The operation type that was being decoded.
349
+
operation:String,
350
+
/// The qubit arguments that couldn't be mapped.
351
+
qubit_args:Vec<String>,
352
+
/// The bit arguments that couldn't be mapped.
353
+
bit_args:Vec<String>,
354
+
},
355
+
/// Found an unexpected number of input wires when decoding an operation.
356
+
#[display(
357
+
"Expected {expected_values} input value wires{expected_types} and {expected_params} input parameters when decoding a {operation}, but found {actual_values} values{actual_types} and {actual_params} parameters.",
358
+
expected_types = match expected_types {
359
+
None => "".to_string(),
360
+
Some(tys) => format!(" with types [{}]", tys.iter().join(", ")),
361
+
},
362
+
actual_types = match actual_types {
363
+
None => "".to_string(),
364
+
Some(tys) => format!(" with types [{}]", tys.iter().join(", ")),
365
+
},
366
+
)]
367
+
UnexpectedInputWires{
368
+
/// The expected amount of input wires.
369
+
expected_values:usize,
370
+
/// The expected amount of input parameters.
371
+
expected_params:usize,
372
+
/// The actual amount of input wires.
373
+
actual_values:usize,
374
+
/// The actual amount of input parameters.
375
+
actual_params:usize,
376
+
/// The expected types of the input wires.
377
+
expected_types:Option<Vec<String>>,
378
+
/// The actual types of the input wires.
379
+
actual_types:Option<Vec<String>>,
380
+
/// The operation type that was being decoded.
381
+
operation:String,
382
+
},
383
+
/// Tried to track the output wires of a node, but the number of tracked elements didn't match the ones in the output wires.
384
+
#[display(
385
+
"Tried to track the output wires of a node, but the number of tracked elements didn't match the ones in the output wires. Expected {expected_qubits} qubits and {expected_bits} bits, but found {circ_qubits} qubits and {circ_bits} bits in the node outputs."
386
+
)]
387
+
UnexpectedNodeOutput{
388
+
/// The expected number of qubits.
389
+
expected_qubits:usize,
390
+
/// The expected number of bits.
391
+
expected_bits:usize,
392
+
/// The number of qubits in HUGR node outputs.
393
+
circ_qubits:usize,
394
+
/// The number of bits in HUGR node output.
395
+
circ_bits:usize,
396
+
},
397
+
/// Custom user-defined error raised while encoding an operation.
398
+
#[display("Error while decoding operation: {msg}")]
399
+
CustomError{
400
+
/// The custom error message
401
+
msg:String,
402
+
},
403
+
/// Input parameter was defined multiple times.
404
+
#[display("Parameter {param} was defined multiple times in the input signature")]
405
+
DuplicatedParameter{
406
+
/// The parameter name.
407
+
param:String,
408
+
},
409
+
/// Not enough parameter names given for the input signature.
410
+
#[display("Tried to initialize a pytket circuit decoder with {num_params_given} given parameter names, but more were required by the input signature.")]
411
+
MissingParametersInInput{
412
+
/// The number of parameters given.
413
+
num_params_given:usize,
414
+
},
415
+
/// We don't support complex types containing parameters in the input.
416
+
//
417
+
// This restriction may be relaxed in the future.
418
+
#[display("Complex type {ty} contains {num_params} inside it. We only support input parameters in standalone 'float' or 'rotation'-typed wires.")]
419
+
UnsupportedParametersInInput{
420
+
/// The type that contains the parameters.
421
+
ty:String,
422
+
/// The number of parameters in the type.
423
+
num_params:usize,
424
+
},
425
+
}
426
+
427
+
implTk1DecodeError{
428
+
/// Create a new error with a custom message.
429
+
pubfncustom(msg:implToString) -> Self{
430
+
Self::CustomError{
431
+
msg: msg.to_string(),
432
+
}
433
+
}
434
+
435
+
/// Create an error for an unknown qubit register.
0 commit comments