def driver_spher_lim(): def spherical_limits(x, y, z): """ Checks that the field is inside a sphere of radius 2 """ return np.sqrt(x**2 + y**2 + z**2) <= 2 mips_sl = MercuryiPS('mips_sl', address='GPIB::1::INSTR', visalib=visalib, field_limits=spherical_limits) yield mips_sl mips_sl.close()
def driver_cyl_lim(): def cylindrical_limits(x, y, z): """ Checks that the field is inside a particular cylinder """ rho_check = np.sqrt(x**2 + y**2) <= 2 z_check = z < 3 and z > -1 return rho_check and z_check mips_cl = MercuryiPS('mips_cl', address='GPIB::1::INSTR', visalib=visalib, field_limits=cylindrical_limits) yield mips_cl mips_cl.close()
def test_wrong_field_limit_raises(): # check that a non-callable input fails with pytest.raises(ValueError): MercuryiPS('mips', address='GPIB::1::INSTR', visalib=visalib, field_limits=0)
def driver(): mips = MercuryiPS('mips', address='GPIB::1::INSTR', visalib=visalib) yield mips mips.close()