qubiter.SEO_pre_reader module

class qubiter.SEO_pre_reader.SEO_pre_reader(file_prefix, num_qbits)[source]

Bases: object

This class’ constructor scans (pre-reads) an English file (a type of txt file). It skips all lines except the ones starting with LOOP or NEXT. By doing so, it collects information about LOOPs (where they start and end, their id number and their number of reps). This class is inherited by class SEO_reader which uses its information to handle embedded loops.

See docstring for class SEO_writer for more info about English files.

Variables:
  • english_in (_io.TextIOWrapper) – file object for input text file that stores English description of circuit
  • file_prefix (str) – beginning of the name of English file being scanned
  • loop_queue (list[int]) – a queue of loops labelled by their id number
  • loop_to_nreps (dict[int, int]) – a dictionary mapping loop number TO total number of repetitions of loop
  • loop_to_start_line (dict[int, int]) – a dictionary mapping loop number TO loop line + 1
  • loop_to_start_offset (dict[int, int]) – a dictionary mapping loop number TO offset of loop’s start
  • num_qbits (int) – number of qubits in whole circuit
  • split_line (list[str]) – storage space for a list of strings obtained by splitting a line
  • tot_num_lines (int) – number of lines in English file
__init__(file_prefix, num_qbits)[source]

Constructor

Parameters:
  • file_prefix (str) – file must be called file_prefix + ‘_’ + num_qbits + “_eng.txt”
  • num_qbits (int) – total number of qubits of circuit.
scan_LOOP()[source]

Parses and uses line starting with “LOOP”.

Returns:
Return type:None
scan_NEXT()[source]

Parses and uses line starting with “NEXT”.

Returns:
Return type:None
scan_next_line()[source]

Scans one line. Skips over any line that doesn’t start with LOOP or NEXT.

Returns:
Return type:None