LineManager#

qualtran.drawing.LineManager

Methods to manage allocation and de-allocation of lines representing a register of qubits.

Methods#

new_y

View source

Allocate a new y position (i.e. a new qubit or register).

reserve_n

View source

Reserve n lines until further notice.

To have fine-grained control over the vertical layout of HLines, consider overriding maybe_reserve which can call this method to reserve lines depending on the musical score context.

unreserve

View source

Go through our reservations and rescind them depending on the until predicate.

maybe_reserve

View source

Override this method to provide custom control over line allocation.

After a new y position is allocated and after a y position is freed, this method is called with the current binst, reg, idx. You can inspect these elements to determine whether you want to continue allocating lines first-come-first-serve by returning without doing anything; or you can call self.reserve_n(n, until) to keep the next n lines unavailable until the until callback predicate evaluates to True.

Whenever a new register is encountered, we first go through existing reservations and call the until predicate on binst, reg.

new

View source

Allocate a position or positions for reg.

binst and reg can optionally modify the allocation strategy. seq_x and topo_gen are passed through.

finish_hline

View source

Update self.hlines once we know where an HLine ends.

free

View source

De-allocate a position or positions for reg.

This will free the position for future allocation. This will find the in-progress HLine associate with reg and update it to indicate the end point.