piel.models.logic.electro_optic#

Submodules#

Package Contents#

Functions#

bits_array_from_bits_amount(→ numpy.ndarray)

Returns an array of bits from a given amount of bits.

convert_phase_array_to_bit_array(→ tuple)

This function converts a phase array or tuple iterable, into the corresponding mapping of their bitstring required within a particular bit-phase mapping. A phase_array iterable is provided, and each phase is mapped to a particular bitstring based on the phase_bit_dataframe. A tuple is composed of strings that represent the bitstrings of the phases provided.

find_nearest_bit_for_phase(→ tuple)

This is a mapping function between a provided target phase that might be more analogous, with the closest

format_electro_optic_fock_transition(...)

Formats the electro-optic state into a standard electro_optic_fock_state_type format. This is useful for the

linear_bit_phase_map(→ dict | pandas.DataFrame)

Returns a linear direct mapping of bits to phase.

return_phase_array_from_data_series(→ list)

Returns a list of phases from a given data series and phase map.

Attributes#

electro_optic_fock_state_type

bits_array_from_bits_amount(bits_amount: int, bit_format: Literal[int, str] = 'int') numpy.ndarray[source]#

Returns an array of bits from a given amount of bits.

Parameters:

bits_amount (int) – Amount of bits to generate.

Returns:

Array of bits.

Return type:

bit_array(np.ndarray)

convert_phase_array_to_bit_array(phase_array: Iterable, phase_bit_dataframe: pandas.DataFrame, phase_series_name: str = 'phase', bit_series_name: str = 'bit', rounding_function: Callable | None = None) tuple[source]#

This function converts a phase array or tuple iterable, into the corresponding mapping of their bitstring required within a particular bit-phase mapping. A phase_array iterable is provided, and each phase is mapped to a particular bitstring based on the phase_bit_dataframe. A tuple is composed of strings that represent the bitstrings of the phases provided.

Parameters:
  • phase_array (Iterable) – Iterable of phases to map to bitstrings.

  • phase_bit_dataframe (pd.DataFrame) – Dataframe containing the phase-bit mapping.

  • phase_series_name (str) – Name of the phase series in the dataframe.

  • bit_series_name (str) – Name of the bit series in the dataframe.

  • rounding_function (Callable) – Rounding function to apply to the target phase.

Returns:

Tuple of bitstrings corresponding to the phases.

Return type:

bit_array(tuple)

find_nearest_bit_for_phase(target_phase: float, phase_bit_dataframe: pandas.DataFrame, phase_series_name: str = 'phase', bit_series_name: str = 'bit', rounding_function: Callable | None = None) tuple[source]#

This is a mapping function between a provided target phase that might be more analogous, with the closest bit-value in a bit-phase ideal relationship. The error between the target phase and the applied phase is limited to the discretisation error of the phase mapping.

Parameters:
  • target_phase (float) – Target phase to map to.

  • phase_bit_dataframe (pd.DataFrame) – Dataframe containing the phase-bit mapping.

  • phase_series_name (str) – Name of the phase series in the dataframe.

  • bit_series_name (str) – Name of the bit series in the dataframe.

  • rounding_function (Callable) – Rounding function to apply to the target phase.

Returns:

Bitstring corresponding to the nearest phase.

Return type:

bitstring(str)

format_electro_optic_fock_transition(switch_state_array: piel.integration.type_conversion.array_types, input_fock_state_array: piel.integration.type_conversion.array_types, raw_output_state: piel.integration.type_conversion.array_types) piel.models.logic.electro_optic.types.electro_optic_fock_state_type[source]#

Formats the electro-optic state into a standard electro_optic_fock_state_type format. This is useful for the electro-optic model to ensure that the output state is in the correct format. The output state is a dictionary that contains the phase, input fock state, and output fock state. The idea is that this will allow us to standardise and compare the output states of the electro-optic model across multiple formats.

Parameters:
  • switch_state_array (array_types) – Array of switch states.

  • input_fock_state_array (array_types) – Array of valid input fock states.

  • raw_output_state (array_types) – Array of raw output state.

Returns:

Electro-optic state.

Return type:

electro_optic_state(electro_optic_fock_state_type)

linear_bit_phase_map(bits_amount: int, final_phase_rad: float, initial_phase_rad: float = 0, return_dataframe: bool = True, quantization_error: float = 1e-06, bit_format: Literal[int, str] = 'int') dict | pandas.DataFrame[source]#

Returns a linear direct mapping of bits to phase.

Parameters:
  • bits_amount (int) – Amount of bits to generate.

  • final_phase_rad (float) – Final phase to map to.

  • initial_phase_rad (float) – Initial phase to map to.

Returns:

Mapping of bits to phase.

Return type:

bit_phase_mapping(dict)

return_phase_array_from_data_series(data_series: pandas.Series, phase_map: pandas.DataFrame | pandas.Series) list[source]#

Returns a list of phases from a given data series and phase map. # TODO optimise lookup table speed

Parameters:
  • data_series (pd.Series) – Data series to map.

  • phase_map (pd.DataFrame | pd.Series) – Phase map to use.

Returns:

List of phases.

Return type:

phase_array(list)

electro_optic_fock_state_type#