validators#

Module containing pydantic validators.

Module Contents#

Classes#

Numbers

A custom qcodes Numbers validator that allows for nan values.

_Durations

Validator used for durations. It allows all numbers greater than or equal to 0.

_Amplitudes

Validator used for amplitudes. It allows all numbers and nan.

_NonNegativeFrequencies

Validator used for frequencies. It allows positive numbers and nan.

_Delays

Validator used for delays. It allows all numbers.

_Hashable

Validator used for hashables.

class Numbers(min_value: qcodes.validators.validators.numbertypes = -np.inf, max_value: qcodes.validators.validators.numbertypes = np.inf, allow_nan: bool = False)[source]#

Bases: qcodes.utils.validators.Numbers

A custom qcodes Numbers validator that allows for nan values.

Requires a number of type int, float, numpy.integer or numpy.floating.

Parameters:
  • min_value – Minimal value allowed, default -inf.

  • max_value – Maximal value allowed, default inf.

  • allow_nan – if nan values are allowed, default False.

Raises:

TypeError – If min or max value not a number. Or if min_value is: larger than the max_value.

_allow_nan[source]#
validate(value: qcodes.validators.validators.numbertypes, context: str = '') None[source]#

Validate if number else raises error.

Parameters:
  • value – A number.

  • context – Context for validation.

Raises:
  • TypeError – If not int or float.:

  • ValueError – If number is not between the min and the max value.:

class _Durations[source]#

Bases: Numbers

Validator used for durations. It allows all numbers greater than or equal to 0.

class _Amplitudes[source]#

Bases: Numbers

Validator used for amplitudes. It allows all numbers and nan.

class _NonNegativeFrequencies[source]#

Bases: Numbers

Validator used for frequencies. It allows positive numbers and nan.

class _Delays[source]#

Bases: Numbers

Validator used for delays. It allows all numbers.

class _Hashable[source]#

Bases: qcodes.utils.validators.Validator[Hashable]

Validator used for hashables.

_valid_values = (0, 'str')[source]#
validate(value: Hashable, context: str = '') None[source]#

Validates if hashable else raises error.

Parameters:
  • value – Value to validate

  • context – Context for validation.

Raises:

TypeError – If value is not hashable.