Skip to content

Manual Inference

ManualInference assigns a specific label to a specific mode number, regardless of its properties.

Usage

To use an inference, call the .infer() method with eigenmode results:

from quansys.simulation.quantum_epr.modes_to_labels import ManualInference

# Example eigenmode data  
eigenmode_results = {
    1: {'frequency': 3.5, 'quality_factor': 100},
    2: {'frequency': 5.1, 'quality_factor': 120}, 
}

# Create inference: always assign mode 2 as 'bus'
inference = ManualInference(mode_number=2, label="readout")

# Apply inference
result = inference.infer(eigenmode_results)
print(result)  # Output: {2: 'readout'}

.infer

The method .infer() only validate the mode number exists in the eigenmode results. Any other properties of the mode (like frequency or quality factor) are ignored.

Use Cases

  • Reference modes: Fixed assignment for comparison across parameter sweeps
  • Can be chained: can be combined with other inference strategies like OrderInference for more complex labeling scenarios

Bases: InferenceBase

Manual inference strategy to explicitly label a specific mode.

Attributes:

Name Type Description
type Literal['manual']

Discriminator field with value 'manual'.

mode_number int

The eigenmode index to which the label should be assigned.

label str

The label to assign.

infer

infer(
    eigenmode_results: dict[int, dict[str, float]],
) -> dict[int, str]

Assigns a predefined label to a specific mode number.

Parameters:

Name Type Description Default
eigenmode_results dict[int, dict[str, float]]

Dictionary of available modes and their corresponding properties.

required

Returns:

Type Description
dict[int, str]

dict[int, str]: A dictionary with a single key-value pair mapping the mode number to the label.

Raises:

Type Description
ValueError

If the mode number is not present in eigenmode_results.

Source code in src/quansys/simulation/quantum_epr/modes_to_labels/inferences.py
def infer(self, eigenmode_results: dict[int, dict[str, float]]) -> dict[int, str]:
    """
    Assigns a predefined label to a specific mode number.

    Args:
        eigenmode_results (dict[int, dict[str, float]]):
            Dictionary of available modes and their corresponding properties.

    Returns:
        dict[int, str]: A dictionary with a single key-value pair mapping the mode number to the label.

    Raises:
        ValueError: If the mode number is not present in `eigenmode_results`.
    """
    # check it is a valid number
    if eigenmode_results.get(self.mode_number) is None:
        raise ValueError(f'mode not exists in the given result {eigenmode_results}')

    return {self.mode_number: self.label}