quantum_launcher.base.adapter_structure#
Summary#
Classes:
Converts input problem to a given format (input and output types determined by formatter and adapters in __init__) |
Functions:
Register a function as an adapter from one problem format to another. |
|
Register a function as a formatter for a given problem type to a given format. |
|
Creates a ProblemFormatter that converts a given Problem subclass into the requested format. |
Reference#
- class quantum_launcher.base.adapter_structure.ProblemFormatter(formatter: Callable, adapters: list[Callable] | None = None)[source]#
Bases:
object
Converts input problem to a given format (input and output types determined by formatter and adapters in __init__)
Probably shouldn’t be constructed directly, call
get_formatter()
- get_pipeline() str [source]#
- Returns:
problem -> formatter -> adapters (if applicable)
- Return type:
String representing the conversion process
- quantum_launcher.base.adapter_structure.adapter(translates_from: str, translates_to: str, **kwargs) Callable [source]#
Register a function as an adapter from one problem format to another.
- Parameters:
translates_from (str) – Input format
translates_to (str) – Output format
- Returns:
Same function
- Return type:
Callable
- quantum_launcher.base.adapter_structure.formatter(problem: type[Problem] | None, alg_format: str)[source]#
Register a function as a formatter for a given problem type to a given format.
- Parameters:
problem (type[Problem]) – Input problem type
alg_format (str) – Output format
- Returns:
Same function
- quantum_launcher.base.adapter_structure.get_formatter(problem: type[Problem], alg_format: str) ProblemFormatter [source]#
Creates a ProblemFormatter that converts a given Problem subclass into the requested format.
- Parameters:
problem (type[Problem]) – Input problem type
alg_format (str) – Desired output format
- Returns:
ProblemFormatter meeting the desired criteria.
- Raises:
ValueError – If no combination of adapters can achieve conversion from problem to desired format.
- Return type: