Skip to content

Commit

Permalink
tox fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Coull committed Apr 8, 2024
1 parent 536b0ff commit ab1d30e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
9 changes: 5 additions & 4 deletions src/braket/ir/ahs/hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from braket.ir.ahs.driving_field import DrivingField
from braket.ir.ahs.local_detuning import LocalDetuning


class Hamiltonian(BaseModel):
"""
Specifies the Hamiltonian
Expand All @@ -34,21 +35,21 @@ class Hamiltonian(BaseModel):

drivingFields: List[DrivingField]
localDetuning: List[LocalDetuning] = Field(alias="shiftingFields")

def __getattr__(self, name):
if name == "shiftingFields":
name = "localDetuning"
return self.__dict__[name]

def __setattr__(self, name, value):
if name == "shiftingFields":
name = "localDetuning"
self.__dict__[name] = value

Check warning on line 47 in src/braket/ir/ahs/hamiltonian.py

View check run for this annotation

Codecov / codecov/patch

src/braket/ir/ahs/hamiltonian.py#L46-L47

Added lines #L46 - L47 were not covered by tests

def __delattr__(self, name):
if name == "shiftingFields":
name = "localDetuning"
del self.__dict__[name]

Check warning on line 52 in src/braket/ir/ahs/hamiltonian.py

View check run for this annotation

Codecov / codecov/patch

src/braket/ir/ahs/hamiltonian.py#L51-L52

Added lines #L51 - L52 were not covered by tests

class Config:
allow_population_by_field_name = True
4 changes: 2 additions & 2 deletions src/braket/ir/ahs/shifting_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

from braket.ir.ahs.local_detuning import LocalDetuning


# The class `ShiftingField` is deprecated. Please use `LocalDetuning` instead.
# This file and class will be removed in a future version.
# We are retaining this now to avoid breaking backwards compatibility for users already utilizing this nomenclature.
# We are retaining this now to avoid breaking backwards compatibility for users already
# utilizing this nomenclature.
ShiftingField = LocalDetuning
12 changes: 8 additions & 4 deletions test/unit_tests/braket/ir/ahs/test_ahs_program_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@
[3.0e-6, 0.0],
[3.0e-6, 3.0e-6],
[3.0e-6, 6.0e-6],
],
],
"filling": [1, 1, 1, 1, 0, 0],
}
}

@pytest.fixture(params=[
"shiftingFields", "localDetuning",
])

@pytest.fixture(
params=[
"shiftingFields",
"localDetuning",
]
)
def valid_hamiltonian_input(request):
return {
"drivingFields": [
Expand Down
4 changes: 1 addition & 3 deletions test/unit_tests/braket/task_result/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ def blackbird_program():
)


@pytest.fixture(params=[
"shiftingFields", "localDetuning"
])
@pytest.fixture(params=["shiftingFields", "localDetuning"])
def ahs_program(request):
return AHSProgram(
setup={
Expand Down

0 comments on commit ab1d30e

Please sign in to comment.