Skip to content

Base

Report

Report(data, metas, geos, name='')
Source code in src/bloqade/task/base.py
def __init__(self, data, metas, geos, name="") -> None:
    self.dataframe = data  # df
    self._bitstrings = None  # bitstring cache
    self._counts = None  # counts cache
    self.metas = metas
    self.geos = geos
    self.name = name + " " + str(datetime.datetime.now())

counts property

counts

Get the statistic for the counts for each configuration(s)

Return

statistic of configuration (str): counts (int) for each task

bitstrings

bitstrings(filter_perfect_filling=True)

Get the bitstrings from the data.

Parameters:

Name Type Description Default
filter_perfect_filling bool

whether return will

True
Source code in src/bloqade/task/base.py
def bitstrings(self, filter_perfect_filling: bool = True) -> List[NDArray]:
    """
    Get the bitstrings from the data.

    Args:
        filter_perfect_filling (bool): whether return will
        only contain perfect filling shots.

    """
    perfect_sorting = self.dataframe.index.get_level_values("perfect_sorting")
    pre_sequence = self.dataframe.index.get_level_values("pre_sequence")
    if filter_perfect_filling:
        df = self.dataframe[perfect_sorting == pre_sequence]
    else:
        df = self.dataframe

    task_numbers = df.index.get_level_values("task_number").unique()

    bitstrings = []
    for task_number in task_numbers:
        bitstrings.append(df.loc[task_number, ...].to_numpy())

    return bitstrings

list_param

list_param(field_name)

List the parameters associate with the given variable field_name for each tasks.

Parameters:

Name Type Description Default
field_name str

variable name

required
Source code in src/bloqade/task/base.py
def list_param(self, field_name: str) -> List[Union[Number, None]]:
    """
    List the parameters associate with the given variable field_name
    for each tasks.

    Args:
        field_name (str): variable name

    """

    def cast(x):
        try:
            return float(x)
        except ValueError:
            return x

    return list(map(cast, (meta.get(field_name) for meta in self.metas)))

rydberg_densities

rydberg_densities(filter_perfect_filling=True)

Get rydberg density for each task.

Parameters:

Name Type Description Default
filter_perfect_filling bool

whether return will

True
Return

per-site rydberg density for each task

Source code in src/bloqade/task/base.py
def rydberg_densities(self, filter_perfect_filling: bool = True) -> pd.Series:
    """
    Get rydberg density for each task.

    Args:
        filter_perfect_filling (bool):  whether return will
        only contain perfect filling shots.

    Return:
        per-site rydberg density for each task

    """
    # TODO: implement nan for missing task numbers
    perfect_sorting = self.dataframe.index.get_level_values("perfect_sorting")
    pre_sequence = self.dataframe.index.get_level_values("pre_sequence")

    if filter_perfect_filling:
        df = self.dataframe[perfect_sorting == pre_sequence]
    else:
        df = self.dataframe

    return 1 - (df.groupby("task_number").mean())

show

show()

Interactive Visualization of the Report

Source code in src/bloqade/task/base.py
def show(self):
    """
    Interactive Visualization of the Report

    """
    display_report(self)