piel.flows.digital_electro_optic#

Attributes#

Functions#

add_truth_table_bit_to_phase_data(→ piel.types.TruthTable)

This function converts the bit column of a dataframe into a phase tuple using the phase_bit_dataframe. The

add_truth_table_phase_to_bit_data(→ piel.types.TruthTable)

This function converts the phase column of a dataframe into a bit tuple using the phase_bit_dataframe. The

convert_optical_transitions_to_truth_table(...)

convert_phase_to_bit_iterable(→ tuple)

This function converts a phase array or tuple iterable, into the corresponding mapping of their bitstring

find_nearest_bit_for_phase(→ tuple)

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

find_nearest_phase_for_bit(→ piel.types.PhaseMapType)

Maps a bitstring to the nearest phase(s) in a phase-bit mapping dataframe.

filter_and_correct_truth_table(truth_table_dictionary, ...)

Ensures each unique value of the specified input connection maps to a unique set of values of the output connection.

Module Contents#

logger#
add_truth_table_bit_to_phase_data(truth_table: piel.types.TruthTable, bit_phase_map: piel.types.BitPhaseMap, bit_phase_column_name: str = None) piel.types.TruthTable[source]#

This function converts the bit column of a dataframe into a phase tuple using the phase_bit_dataframe. The phase_bit_dataframe is a dataframe that maps the phase to the bit. The phase_series_name is the name of the phase series in the phase_bit_dataframe. The bit_series_name is the name of the bit series in the phase_bit_dataframe. The bit_column_name is the name of the bit column in the dataframe. The function returns a tuple of phases that correspond to the bit column of the dataframe.

Parameters:
  • truth_table (pd.DataFrame) – The dataframe that contains the bit column.

  • bit_phase_map (BitPhaseMap) – The dataframe that maps the phase to the bit.

  • bit_phase_column_name (str) – The name of the bit column in the dataframe.

Returns:

a TruthTable object with the phase columns added.

Return type:

truth_table (TruthTable)

add_truth_table_phase_to_bit_data(truth_table: piel.types.TruthTable, bit_phase_map: piel.types.BitPhaseMap, phase_column_name: str = None, rounding_function: Callable | None = None) piel.types.TruthTable[source]#

This function converts the phase column of a dataframe into a bit tuple using the phase_bit_dataframe. The phase_bit_dataframe is a dataframe that maps the phase to the bit. The phase_series_name is the name of the phase series in the phase_bit_dataframe. The bit_series_name is the name of the bit series in the phase_bit_dataframe. The phase_column_name is the name of the phase column in the dataframe. The function returns a tuple of bits that correspond to the phase column of the dataframe.

Parameters:
  • truth_table (pd.DataFrame) – The dataframe that contains the phase column.

  • bit_phase_map (BitPhaseMap) – The dataframe that maps the phase to the bit.

  • rounding_function (Optional[Callable]) – The rounding function that is used to round the phase to the nearest phase in the phase_bit_dataframe.

Returns:

A tuple of bits that correspond to the phase column of the dataframe.

Return type:

tuple

convert_optical_transitions_to_truth_table(optical_state_transitions: piel.types.OpticalStateTransitionCollection, bit_phase_map=BitPhaseMap, logic: piel.types.TruthTableLogicType = 'implementation') piel.types.TruthTable[source]#
convert_phase_to_bit_iterable(phase: piel.types.PhaseMapType, bit_phase_map: piel.types.BitPhaseMap, 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 (Iterable) – Iterable of phases to map to bitstrings.

  • bit_phase_map (BitPhaseMap) – Dataframe containing the phase-bits mapping.

  • 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, bit_phase_map: piel.types.BitPhaseMap, 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.

  • bit_phase_map (pd.DataFrame) – Dataframe containing the phase-bits mapping.

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

Returns:

Bitstring corresponding to the nearest phase.

Return type:

bitstring(str)

find_nearest_phase_for_bit(bits: piel.types.BitsType, phase_map: piel.types.BitPhaseMap) piel.types.PhaseMapType[source]#

Maps a bitstring to the nearest phase(s) in a phase-bit mapping dataframe.

Parameters:
  • bits (AbstractBitsType) – Bitstring to map to a phase.

  • phase_map (BitPhaseMap) – Dataframe containing the phase-bits mapping.

Returns:

Tuple of phases or an empty tuple if no match is found.

Return type:

Tuple[str, …]

filter_and_correct_truth_table(truth_table_dictionary: dict, input_ports: list, output_ports: list)[source]#

Ensures each unique value of the specified input connection maps to a unique set of values of the output connection. If conflicts are found (i.e., the same input maps to different outputs), it retains the first unique mapping. It returns a corrected truth table dictionary with only the unique mappings.

Parameters:
  • input_ports (list of str) – List of input port names.

  • output_ports (list of str) – List of output port names.

  • truth_table_dictionary (dict) – Dictionary containing input and output files. Keys are port names, and values are lists of values.

Returns:

A corrected truth table dictionary with unique mappings.

Return type:

dict

Raises:

ValueError – If input_ports or output_ports are not found in truth_table_dictionary.