Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
speller26 committed Aug 19, 2024
1 parent 9b0b479 commit a9f4706
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/braket/circuits/observable.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def __init__(self, ascii_symbols: Sequence[str], target: QubitInput | None = Non
super().__init__(
qubit_count=1,
ascii_symbols=ascii_symbols,
targets=[target] if target is not None else None
targets=[target] if target is not None else None,
)
self._eigenvalues = (1.0, -1.0) # immutable

Expand Down
20 changes: 10 additions & 10 deletions src/braket/circuits/observables.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class H(StandardObservable):
"""Hadamard operation as an observable."""

def __init__(self, target: QubitInput | None = None):
""" Initializes Hadamard observable.
"""Initializes Hadamard observable.
Args:
target (QubitInput | None): The target qubit to measure the observable on
Expand Down Expand Up @@ -82,15 +82,15 @@ class I(Observable): # noqa: E742
"""Identity operation as an observable."""

def __init__(self, target: QubitInput | None = None):
""" Initializes Identity observable.
"""Initializes Identity observable.
Args:
target (QubitInput | None): The target qubit to measure the observable on
Examples:
>>> Observable.I()
"""
super().__init__(qubit_count=1, ascii_symbols=["I"], target=target)
super().__init__(qubit_count=1, ascii_symbols=["I"], targets=target)

def _unscaled(self) -> Observable:
return I()
Expand Down Expand Up @@ -137,7 +137,7 @@ class X(StandardObservable):
"""Pauli-X operation as an observable."""

def __init__(self, target: QubitInput | None = None):
""" Initializes Pauli-X observable.
"""Initializes Pauli-X observable.
Args:
target (QubitInput | None): The target qubit to measure the observable on
Expand Down Expand Up @@ -180,7 +180,7 @@ class Y(StandardObservable):
"""Pauli-Y operation as an observable."""

def __init__(self, target: QubitInput | None = None):
""" Initializes Pauli-Y observable.
"""Initializes Pauli-Y observable.
Args:
target (QubitInput | None): The target qubit to measure the observable on
Expand Down Expand Up @@ -223,7 +223,7 @@ class Z(StandardObservable):
"""Pauli-Z operation as an observable."""

def __init__(self, target: QubitInput | None = None):
""" Initializes Pauli-Z observable.
"""Initializes Pauli-Z observable.
Args:
target (QubitInput | None): The target qubit to measure the observable on
Expand Down Expand Up @@ -309,7 +309,7 @@ def __init__(self, observables: list[Observable]):
all_targets = [factor.targets for factor in unscaled_factors]
if all(targets is None for targets in all_targets):
merged_targets = None
elif all(isinstance(targets, QubitSet) for targets in all_targets):
elif all(targets is not None for targets in all_targets):
flat_targets = [qubit for target in all_targets for qubit in target]
merged_targets = QubitSet(flat_targets)

Check warning on line 314 in src/braket/circuits/observables.py

View check run for this annotation

Codecov / codecov/patch

src/braket/circuits/observables.py#L314

Added line #L314 was not covered by tests
if len(merged_targets) != len(flat_targets):
Expand All @@ -320,7 +320,7 @@ def __init__(self, observables: list[Observable]):
super().__init__(
qubit_count=qubit_count,
ascii_symbols=[display_name] * qubit_count,
targets=merged_targets
targets=merged_targets,
)
self._coef = coefficient
self._factors = unscaled_factors
Expand Down Expand Up @@ -495,7 +495,7 @@ def __init__(self, observables: list[Observable], display_name: str = "Hamiltoni
all_targets = [observable for observable in flattened_observables]
if all(targets is None for targets in all_targets):
targets = None

Check warning on line 497 in src/braket/circuits/observables.py

View check run for this annotation

Codecov / codecov/patch

src/braket/circuits/observables.py#L497

Added line #L497 was not covered by tests
elif all(isinstance(targets, QubitSet) for targets in all_targets):
elif all(targets is not None for targets in all_targets):
targets = all_targets
else:
raise ValueError("Cannot mix observables with and without targets")

Check warning on line 501 in src/braket/circuits/observables.py

View check run for this annotation

Codecov / codecov/patch

src/braket/circuits/observables.py#L501

Added line #L501 was not covered by tests
Expand Down Expand Up @@ -581,7 +581,7 @@ def __init__(
self,
matrix: np.ndarray,
display_name: str = "Hermitian",
targets: QubitSetInput | None = None
targets: QubitSetInput | None = None,
):
"""Inits a `Hermitian`.
Expand Down

0 comments on commit a9f4706

Please sign in to comment.