general_superstaq.validation

Functions

validate_bitmap(→ None)

Checks that bitmap is in an array format acceptable by the Atom picture API.

validate_integer_param(→ None)

Validates that integer_param is an integer and positive (or above a minimum value).

validate_noise_type(→ None)

Validates that an ACES noise model is valid.

validate_qubo(→ None)

Validates that the input can be converted into a valid QUBO.

validate_target(→ str)

Checks that target conforms to a valid Superstaq format and device type.

Module Contents

general_superstaq.validation.validate_bitmap(bitmap: numpy.typing.ArrayLike) None

Checks that bitmap is in an array format acceptable by the Atom picture API.

Parameters:

bitmap – The array-like object to validate.

Raises:
  • TypeError – If bitmap is not a two-dimensional array.

  • TypeError – If bitmap is not a square two-dimensional array.

  • ValueError – If bitmap contains any values outside of {0, 1, 2}.

general_superstaq.validation.validate_integer_param(integer_param: object, min_val: int = 1) None

Validates that integer_param is an integer and positive (or above a minimum value).

Parameters:
  • integer_param – The input parameter to validate.

  • min_val – Optional parameter to validate if integer_param is greater than min_val.

Raises:
  • TypeError – If integer_param is not an integer.

  • ValueError – If integer_param is less than min_val.

general_superstaq.validation.validate_noise_type(noise: dict[str, object], n_qubits: int) None

Validates that an ACES noise model is valid.

Parameters:
  • noise – A noise model parameter.

  • n_qubits – Number of qubits the noise model is applied to.

Raises:

ValueError – If noise is not valid.

general_superstaq.validation.validate_qubo(qubo: object) None

Validates that the input can be converted into a valid QUBO.

Parameters:

qubo – The input value to validate.

Raises:
  • TypeError – If qubo is not a dict-like object.

  • TypeError – If the keys of qubo are of an invalid type.

  • ValueError – If qubo contains cubic or further higher degree terms.

  • TypeError – If the values in qubo are not real numbers.

general_superstaq.validation.validate_target(target: str) str

Checks that target conforms to a valid Superstaq format and device type.

Parameters:

target – A string containing the name of a target device.

Raises:

ValueError – If target has an invalid format or device type.