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

AMI430 3D driver: add docstring, extra test for initializing from AMI430 by name #2951

Merged
merged 3 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions qcodes/instrument_drivers/american_magnetics/AMI430.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,26 @@ def __init__(self,
field_limit: Union[numbers.Real,
Iterable[CartesianFieldLimitFunction]],
**kwargs: Any):
"""
Driver for controlling three American Magnetics Model 430 magnet power
supplies simultaneously for setting magnetic field vectors.

The individual magnet power supplies can be passed in as either
instances of AMI430 driver or as names of existing AMI430 instances.
In the latter case, the instances will be found via the passed names.

Args:
name: a name for the instrument
instrument_x: AMI430 instance or a names of existing AMI430
instance for controlling the X axis of magnetic field
instrument_y: AMI430 instance or a names of existing AMI430
instance for controlling the X axis of magnetic field
astafan8 marked this conversation as resolved.
Show resolved Hide resolved
instrument_z: AMI430 instance or a names of existing AMI430
instance for controlling the X axis of magnetic field
astafan8 marked this conversation as resolved.
Show resolved Hide resolved
field_limit: a number for maximum allows magnetic field or an
iterable of callable field limit functions that define
region(s) of allowed values in 3D magnetic field space
"""
super().__init__(name, **kwargs)

if not isinstance(name, str):
Expand Down
29 changes: 27 additions & 2 deletions qcodes/tests/drivers/test_ami430.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
from hypothesis.strategies import floats, tuples

import qcodes.instrument.sims as sims
from qcodes.instrument.base import Instrument
from qcodes.instrument.ip_to_visa import AMI430_VISA
from qcodes.instrument_drivers.american_magnetics.AMI430 import (AMI430_3D,
from qcodes.instrument_drivers.american_magnetics.AMI430 import (AMI430,
AMI430_3D,
AMI430Warning)
from qcodes.math_utils.field_vector import FieldVector
from qcodes.utils.types import (numpy_concrete_floats, numpy_concrete_ints,
Expand Down Expand Up @@ -124,7 +126,7 @@ def test_instantiation_from_names(magnet_axes_instances, request):
assert driver._instrument_z is mag_z


def test_instantiation_from_name_of_nonexistent_instrument(
def test_instantiation_from_name_of_nonexistent_ami_instrument(
magnet_axes_instances, request
):
mag_x, mag_y, mag_z = magnet_axes_instances
Expand All @@ -143,6 +145,29 @@ def test_instantiation_from_name_of_nonexistent_instrument(
)


def test_instantiation_from_name_of_existing_non_ami_instrument(
magnet_axes_instances, request
):
mag_x, mag_y, mag_z = magnet_axes_instances
request.addfinalizer(AMI430_3D.close_all)

non_ami_existing_instrument = Instrument("foo")

with pytest.raises(
TypeError,
match=re.escape(
f"Instrument {non_ami_existing_instrument.name} is "
f"{type(non_ami_existing_instrument)} but {AMI430} "
f"was requested"
)
):
AMI430_3D(
"AMI430-3D",
mag_x.name, non_ami_existing_instrument.name, mag_z.name,
field_limit
)


def test_instantiation_from_badly_typed_argument(
magnet_axes_instances, request
):
Expand Down