Skip to content

Commit

Permalink
infra: Update formatting to follow new black rules (amazon-braket#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
amazon-braket-ci-bot authored Sep 1, 2020
1 parent ab31d2a commit f5da7f1
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 75 deletions.
28 changes: 14 additions & 14 deletions src/braket/device_schema/device_action_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class DeviceActionType(str, Enum):
"""
These are the actions supported by braket.
These are the actions supported by braket.
"""

JAQCD = "braket.ir.jaqcd.program"
Expand All @@ -28,19 +28,19 @@ class DeviceActionType(str, Enum):

class DeviceActionProperties(BaseModel):
"""
This class defines the actions that can be performed by a device
Attributes:
version: List of versions for the actions the device supports
actionType: Enum for the action type. Type of the action to be performed.
Examples:
>>> import json
>>> input_json = {
... "actionType": "braket.ir.jaqcd.program",
... "version": ["1"],
... }
>>> DeviceActionProperties.parse_raw(json.dumps(input_json))
This class defines the actions that can be performed by a device
Attributes:
version: List of versions for the actions the device supports
actionType: Enum for the action type. Type of the action to be performed.
Examples:
>>> import json
>>> input_json = {
... "actionType": "braket.ir.jaqcd.program",
... "version": ["1"],
... }
>>> DeviceActionProperties.parse_raw(json.dumps(input_json))
"""

version: List[str]
Expand Down
90 changes: 45 additions & 45 deletions src/braket/device_schema/device_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,53 @@

class DeviceCapabilities(BaseModel):
"""
DeviceCapabilities are the properties specific to device, this schema defines what is common
across all the devices
DeviceCapabilities are the properties specific to device, this schema defines what is common
across all the devices
Attributes:
service: properties which are common to the braket service
action: Map of the action to its properties
deviceParameters: It is the json schema of the deviceParameters for each device. for
example the deviceParameter for IonqDeviceCapabilities will be
IonqDeviceParameters.json_schema()
Attributes:
service: properties which are common to the braket service
action: Map of the action to its properties
deviceParameters: It is the json schema of the deviceParameters for each device. for
example the deviceParameter for IonqDeviceCapabilities will be
IonqDeviceParameters.json_schema()
Examples:
>>> import json
>>> input_json = {
... "service": {
... "braketSchemaHeader": {
... "name": "braket.device_schema.device_service_properties",
... "version": "1",
... },
... "executionWindows": [
... {
... "executionDay": "Everyday",
... "windowStartHour": "09:00",
... "windowEndHour": "19:00",
... }
... ],
... "shotsRange": [1, 10],
... "deviceCost": {
... "price": 0.25,
... "unit": "minute"
... },
... "deviceDocumentation": {
... "imageUrl": "image_url",
... "summary": "Summary on the device",
... "externalDocumentationUrl": "exter doc link",
... },
... "deviceLocation": "us-east-1",
... "updatedAt": "2020-06-16T19:28:02.869136"
... },
... "action": {
... "braket.ir.jaqcd.program": {
... "actionType": "braket.ir.jaqcd.program",
... "version": ["1"],
... }
... },
... "deviceParameters": {#Schema of specific device parameter instance},
... }
>>> DeviceCapabilities.parse_raw(json.dumps(input_json))
Examples:
>>> import json
>>> input_json = {
... "service": {
... "braketSchemaHeader": {
... "name": "braket.device_schema.device_service_properties",
... "version": "1",
... },
... "executionWindows": [
... {
... "executionDay": "Everyday",
... "windowStartHour": "09:00",
... "windowEndHour": "19:00",
... }
... ],
... "shotsRange": [1, 10],
... "deviceCost": {
... "price": 0.25,
... "unit": "minute"
... },
... "deviceDocumentation": {
... "imageUrl": "image_url",
... "summary": "Summary on the device",
... "externalDocumentationUrl": "exter doc link",
... },
... "deviceLocation": "us-east-1",
... "updatedAt": "2020-06-16T19:28:02.869136"
... },
... "action": {
... "braket.ir.jaqcd.program": {
... "actionType": "braket.ir.jaqcd.program",
... "version": ["1"],
... }
... },
... "deviceParameters": {#Schema of specific device parameter instance},
... }
>>> DeviceCapabilities.parse_raw(json.dumps(input_json))
"""

service: DeviceServiceProperties
Expand Down
2 changes: 1 addition & 1 deletion src/braket/device_schema/ionq/ionq_device_parameters_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class IonqDeviceParameters(BraketSchemaBase):
"""
This defines the parameters common to all the Ion-Q devices.
This defines the parameters common to all the IonQ devices.
Attributes:
paradigmParameters: Parameters that are common to gatemodel paradigm
Expand Down
4 changes: 2 additions & 2 deletions src/braket/ir/annealing/problem_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


class ProblemType(str, Enum):
""" The type of annealing problem.
"""The type of annealing problem.
QUBO: Quadratic Unconstrained Binary Optimization, with values 1 and 0
ISING: Ising model, with values +/-1
Expand All @@ -31,7 +31,7 @@ class ProblemType(str, Enum):


class Problem(BraketSchemaBase):
""" Specifies a quantum annealing problem.
"""Specifies a quantum annealing problem.
Attributes:
braketSchemaHeader (BraketSchemaHeader): Schema header. Users do not need
Expand Down
4 changes: 3 additions & 1 deletion test/unit_tests/braket/ir/jaqcd/test_program_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def test_partial_non_rotation_basis_instruction():


def test_no_rotation_basis_instruction():
Program(instructions=[CNot(control=0, target=1)],)
Program(
instructions=[CNot(control=0, target=1)],
)


def test_rotation_basis_instruction():
Expand Down
12 changes: 10 additions & 2 deletions test/unit_tests/braket/schema_common/test_schema_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ def test_header_name_incorrect():


def test_import_schema_module():
schema = TaskMetadata(id="test_id", deviceId="device_id", shots=1000,)
schema = TaskMetadata(
id="test_id",
deviceId="device_id",
shots=1000,
)
module = BraketSchemaBase.import_schema_module(schema)
assert schema == module.TaskMetadata.parse_raw(schema.json())

Expand All @@ -51,6 +55,10 @@ def test_import_schema_module_error():


def test_parse_raw_schema():
schema = TaskMetadata(id="test_id", deviceId="device_id", shots=1000,)
schema = TaskMetadata(
id="test_id",
deviceId="device_id",
shots=1000,
)
assert schema == BraketSchemaBase.parse_raw_schema(schema.json())
assert isinstance(schema, TaskMetadata)
5 changes: 4 additions & 1 deletion test/unit_tests/braket/task_result/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def dwave_timing():

@pytest.fixture
def dwave_metadata(active_variables, dwave_timing, braket_schema_header):
return DwaveMetadata(activeVariables=active_variables, timing=dwave_timing,)
return DwaveMetadata(
activeVariables=active_variables,
timing=dwave_timing,
)


@pytest.fixture
Expand Down
8 changes: 6 additions & 2 deletions test/unit_tests/braket/task_result/test_dwave_metadata_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def test_missing_properties():


def test_dwave_metadata_correct(active_variables, dwave_timing):
metadata = DwaveMetadata(activeVariables=active_variables, timing=dwave_timing,)
metadata = DwaveMetadata(
activeVariables=active_variables,
timing=dwave_timing,
)
assert metadata.activeVariables == active_variables
assert metadata.timing == dwave_timing
assert DwaveMetadata.parse_raw(metadata.json()) == metadata
Expand All @@ -34,7 +37,8 @@ def test_dwave_metadata_correct(active_variables, dwave_timing):
@pytest.mark.xfail(raises=ValidationError)
def test_active_variables_incorrect(active_variables, dwave_timing):
DwaveMetadata(
activeVariables=active_variables, timing=dwave_timing,
activeVariables=active_variables,
timing=dwave_timing,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def test_incorrect_header(


def test_correct_result_measurements(
task_metadata, additional_metadata_gate_model, measured_qubits, measurements,
task_metadata,
additional_metadata_gate_model,
measured_qubits,
measurements,
):
result = GateModelTaskResult(
measurements=measurements,
Expand All @@ -81,7 +84,10 @@ def test_correct_result_measurements(


def test_correct_result_measurement_probabilities(
task_metadata, additional_metadata_gate_model, measured_qubits, measurement_probabilities,
task_metadata,
additional_metadata_gate_model,
measured_qubits,
measurement_probabilities,
):
result = GateModelTaskResult(
measurementProbabilities=measurement_probabilities,
Expand All @@ -94,7 +100,10 @@ def test_correct_result_measurement_probabilities(


def test_correct_result_types(
task_metadata, additional_metadata_gate_model, measured_qubits, result_types,
task_metadata,
additional_metadata_gate_model,
measured_qubits,
result_types,
):
result = GateModelTaskResult(
resultTypes=result_types,
Expand All @@ -120,7 +129,10 @@ def test_incorrect_measured_qubits(measured_qubits, task_metadata, additional_me
@pytest.mark.parametrize("measurements", [([]), ([[]]), ([[-1]]), ([[2]])])
@pytest.mark.xfail(raises=ValidationError)
def test_incorrect_measurements(
measurements, measured_qubits, task_metadata, additional_metadata_gate_model,
measurements,
measured_qubits,
task_metadata,
additional_metadata_gate_model,
):
GateModelTaskResult(
measurements=measurements,
Expand All @@ -133,7 +145,10 @@ def test_incorrect_measurements(
@pytest.mark.parametrize("measurement_probabilities", [({"hello": 0.5}), ({"01": 2})])
@pytest.mark.xfail(raises=ValidationError)
def test_incorrect_measurement_probabilities(
measurement_probabilities, measured_qubits, task_metadata, additional_metadata_gate_model,
measurement_probabilities,
measured_qubits,
task_metadata,
additional_metadata_gate_model,
):
GateModelTaskResult(
measurementProbabilities=measurement_probabilities,
Expand All @@ -146,7 +161,10 @@ def test_incorrect_measurement_probabilities(
@pytest.mark.parametrize("result_types", [([1, 2, 3]), (3)])
@pytest.mark.xfail(raises=ValidationError)
def test_incorrect_result_types(
task_metadata, additional_metadata_gate_model, measured_qubits, result_types,
task_metadata,
additional_metadata_gate_model,
measured_qubits,
result_types,
):
GateModelTaskResult(
resultTypes=result_types,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def test_rigetti_metadata_correct(compiled_program, native_quil_metadata):
@pytest.mark.xfail(raises=ValidationError)
def test_compiled_program_incorrect(compiled_program, native_quil_metadata):
RigettiMetadata(
compiledProgram=compiled_program, nativeQuilMetadata=native_quil_metadata,
compiledProgram=compiled_program,
nativeQuilMetadata=native_quil_metadata,
)


Expand Down

0 comments on commit f5da7f1

Please sign in to comment.