rizer.misc.check_utils#
Functions#
Check if the value is a positive, finite, number. |
|
|
Return None unchanged, otherwise validate_positive(name, value, allow_zero). |
|
Raise ValueError unless source_type is "resistive". |
|
Check if the required keys are present in the dictionary. |
Module Contents#
- rizer.misc.check_utils.validate_positive(name: str, value: _Number, allow_zero: bool = False) _Number#
- rizer.misc.check_utils.validate_positive(name: str, value, allow_zero: bool = False) int | float
Check if the value is a positive, finite, number.
- Parameters:
- Raises:
TypeError – Raised if the value is not a number.
ValueError – Raised if the value is not finite.
ValueError – Raised if the value is not positive.
- rizer.misc.check_utils.validate_positive_optional(name: str, value, allow_zero: bool = False) int | float | None#
Return None unchanged, otherwise validate_positive(name, value, allow_zero).
For a genuinely optional numeric input, where None means “not given” rather than a value to validate.
- Parameters:
- Raises:
TypeError – Raised if value is neither None nor a number.
ValueError – Raised if value is not finite, or not positive.
- rizer.misc.check_utils.require_resistive_source(source_type: str, field_name: str) None#
Raise ValueError unless source_type is “resistive”.
Shared by every caller that only accepts a TransmissionLineResistiveCircuit/TransmissionLineRCLoadCircuit (e.g. PulsedPlasmaReactor), so a “c_shunt”/”c_parallel” source is rejected here rather than silently dropped.
- Parameters:
- Raises:
ValueError – If source_type is not “resistive”.