Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unitary-Hack][Task-Base] Docstring for "tasks/base" #970

Merged
merged 12 commits into from
Jun 3, 2024
31 changes: 29 additions & 2 deletions src/bloqade/task/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
@Serializer.register
@dataclass(frozen=True)
class Geometry:
"""Class representing geometry of an atom arrangement.

Members:
Manvi-Agrawal marked this conversation as resolved.
Show resolved Hide resolved
sites (List[Tuple[float, float]]): Atom site arrangement
filling (List[int]): Which sites are filled
parallel_decoder: Decoder object for decoding Geometry object
"""

sites: List[Tuple[float, float]]
filling: List[int]
parallel_decoder: Optional[ParallelDecoder] = None
Expand Down Expand Up @@ -95,9 +103,9 @@ def run(self, **kwargs):
raise NotImplementedError


# Report is now just a helper class for
# organize and analysis data:
class Report:
"""Report is a helper class for organizing and analysing data"""

dataframe: pd.DataFrame
metas: List[Dict]
geos: List[Geometry]
Expand Down Expand Up @@ -133,6 +141,7 @@ def cast(x):

@property
def markdown(self) -> str:
"""Get the markdown representation of the dataframe"""
return self.dataframe.to_markdown()

def _filter(
Expand All @@ -142,6 +151,15 @@ def _filter(
filter_perfect_filling: bool = True,
clusters: Union[tuple[int, int], Sequence[Tuple[int, int]]] = [],
):
"""
Manvi-Agrawal marked this conversation as resolved.
Show resolved Hide resolved
Filter the tasks

Args:
task_number (Optional[int]): task number. Defaults to None.
filter_perfect_filling (bool): whether return will
only contain perfect filling shots. Defaults to True.
clusters: cluster of atom sites
"""
mask = np.ones(len(self.dataframe), dtype=bool)

if task_number is not None:
Expand Down Expand Up @@ -234,6 +252,15 @@ def counts(
"""

def generate_counts(bitstring):
"""Get the counts associated with a particular bitstring

Args:
Manvi-Agrawal marked this conversation as resolved.
Show resolved Hide resolved
bitstring: Bitstring representation
only contain perfect filling shots. Defaults to True.

Return:
counts associated with a particular bitstring
"""
output = np.unique(bitstring, axis=0, return_counts=True)

count_list = [
Expand Down