def test_fail(): surface = batoid.Sphere(1.0) ray = batoid.Ray([0, 10, -1], [0, 0, 1]) ray = surface.intersect(ray) assert ray.failed do_pickle(ray)
def test_sag(): rng = np.random.default_rng(57) for i in range(100): R = 1. / rng.normal(0.0, 0.3) sphere = batoid.Sphere(R) for j in range(10): x = rng.uniform(-0.7 * abs(R), 0.7 * abs(R)) y = rng.uniform(-0.7 * abs(R), 0.7 * abs(R)) result = sphere.sag(x, y) np.testing.assert_allclose( result, R * (1 - np.sqrt(1.0 - (x * x + y * y) / R / R))) # Check that it returned a scalar float and not an array assert isinstance(result, float) # Check 0,0 np.testing.assert_allclose(sphere.sag(0, 0), 0.0, rtol=0, atol=1e-17) # Check vectorization x = rng.uniform(-0.7 * abs(R), 0.7 * abs(R), size=(10, 10)) y = rng.uniform(-0.7 * abs(R), 0.7 * abs(R), size=(10, 10)) np.testing.assert_allclose( sphere.sag(x, y), R * (1 - np.sqrt(1.0 - (x * x + y * y) / R / R))) # Make sure non-unit stride arrays also work np.testing.assert_allclose( sphere.sag(x[::5, ::2], y[::5, ::2]), R * (1 - np.sqrt(1.0 - (x * x + y * y) / R / R))[::5, ::2]) do_pickle(sphere)
def test_properties(): rng = np.random.default_rng(5) for i in range(100): R = rng.normal(0.0, 0.3) # negative allowed sphere = batoid.Sphere(R) assert sphere.R == R do_pickle(sphere)
def test_positionAtTime(): import random random.seed(5) for i in range(100): x = random.gauss(0.1, 2.3) y = random.gauss(2.1, 4.3) z = random.gauss(-0.13, 1.3) vx = random.gauss(3.1, 6.3) vy = random.gauss(5.1, 24.3) vz = random.gauss(-1.13, 31.3) t0 = random.gauss(0.1, 1.1) t = random.gauss(5.5, 1.3) # Test both ways of constructing a Ray ray1 = batoid.Ray(x, y, z, vx, vy, vz, t0) ray2 = batoid.Ray([x, y, z], [vx, vy, vz], t0) ray3 = batoid.Ray((x, y, z), (vx, vy, vz), t0) ray4 = batoid.Ray(np.array([x, y, z]), np.array([vx, vy, vz]), t0) for ray in [ray1, ray2, ray3, ray4]: np.testing.assert_allclose( ray.positionAtTime(t)[0], x + vx * (t - t0)) np.testing.assert_allclose( ray.positionAtTime(t)[1], y + vy * (t - t0)) np.testing.assert_allclose( ray.positionAtTime(t)[2], z + vz * (t - t0)) assert ray1 == ray2 == ray3 == ray4 do_pickle(ray1)
def test_shift(): rng = np.random.default_rng(57) globalCoordSys = batoid.CoordSys() for i in range(30): x, y, z = rng.normal(0.1, 2.3, size=3) newCoordSys = globalCoordSys.shiftGlobal([x, y, z]) do_pickle(newCoordSys) np.testing.assert_array_equal(newCoordSys.xhat, [1, 0, 0]) np.testing.assert_array_equal(newCoordSys.yhat, [0, 1, 0]) np.testing.assert_array_equal(newCoordSys.zhat, [0, 0, 1]) np.testing.assert_array_equal(newCoordSys.origin, [x, y, z]) np.testing.assert_array_equal(newCoordSys.rot, np.eye(3)) for j in range(30): x2, y2, z2 = rng.normal(0.1, 2.3, size=3) newNewCoordSys = newCoordSys.shiftGlobal([x2, y2, z2]) np.testing.assert_array_equal(newNewCoordSys.xhat, [1, 0, 0]) np.testing.assert_array_equal(newNewCoordSys.yhat, [0, 1, 0]) np.testing.assert_array_equal(newNewCoordSys.zhat, [0, 0, 1]) np.testing.assert_array_equal(newNewCoordSys.origin, [x + x2, y + y2, z + z2]) np.testing.assert_array_equal(newNewCoordSys.rot, np.eye(3)) newNewCoordSys = newCoordSys.shiftLocal([x2, y2, z2]) np.testing.assert_array_equal(newNewCoordSys.xhat, [1, 0, 0]) np.testing.assert_array_equal(newNewCoordSys.yhat, [0, 1, 0]) np.testing.assert_array_equal(newNewCoordSys.zhat, [0, 0, 1]) np.testing.assert_array_equal(newNewCoordSys.origin, [x + x2, y + y2, z + z2]) np.testing.assert_array_equal(newNewCoordSys.rot, np.eye(3))
def test_optic(): if __name__ == '__main__': nside = 128 else: nside = 32 rays = batoid.rayGrid(20, 12.0, 0.005, 0.005, -1.0, nside, 500e-9, 1.0, batoid.ConstMedium(1.0)) nrays = len(rays) print("Tracing {} rays.".format(nrays)) t_fast = 0.0 t_slow = 0.0 fn = os.path.join(batoid.datadir, "HSC", "HSC.yaml") config = yaml.load(open(fn)) telescope = batoid.parse.parse_optic(config['opticalSystem']) do_pickle(telescope) t0 = time.time() rays_fast, _ = telescope.trace(rays) t1 = time.time() rays_slow = batoid.RayVector([telescope.trace(r)[0] for r in rays]) t2 = time.time() assert rays_fast == rays_slow t_fast = t1 - t0 t_slow = t2 - t1 print("Fast trace: {:5.3f} s".format(t_fast)) print(" {} rays per second".format(int(nrays / t_fast))) print("Slow trace: {:5.3f} s".format(t_slow)) print(" {} rays per second".format(int(nrays / t_slow)))
def test_ObscCircle(): rng = np.random.default_rng(5) size = 10_000 for i in range(100): cx = rng.normal(0.0, 1.0) cy = rng.normal(0.0, 1.0) r = rng.uniform(0.5, 1.5) obsc = batoid.ObscCircle(r, cx, cy) for i in range(100): x = rng.normal(0.0, 1.0) y = rng.normal(0.0, 1.0) assert obsc.contains(x, y) == (np.hypot(x - cx, y - cy) <= r) x = rng.normal(0.0, 1.0, size=size) y = rng.normal(0.0, 1.0, size=size) np.testing.assert_array_equal(obsc.contains(x, y), np.hypot(x - cx, y - cy) <= r) do_pickle(obsc) rv = batoid.RayVector(x, y, 0.0, 0.0, 0.0, 0.0) batoid.obscure(obsc, rv) np.testing.assert_array_equal(obsc.contains(x, y), rv.vignetted) # Check method syntax too rv = batoid.RayVector(x, y, 0.0, 0.0, 0.0, 0.0) obsc.obscure(rv) np.testing.assert_array_equal(obsc.contains(x, y), rv.vignetted)
def test_ObscAnnulus(): rng = np.random.default_rng(57) size = 10_000 for i in range(100): cx = rng.normal(0.0, 1.0) cy = rng.normal(0.0, 1.0) inner = rng.uniform(0.5, 1.5) outer = rng.uniform(1.6, 1.9) obsc = batoid.ObscAnnulus(inner, outer, cx, cy) for i in range(100): x = rng.normal(0.0, 1.0) y = rng.normal(0.0, 1.0) assert obsc.contains( x, y) == (inner <= np.hypot(x - cx, y - cy) < outer) x = rng.normal(0.0, 1.0, size=size) y = rng.normal(0.0, 1.0, size=size) r = np.hypot(x - cx, y - cy) np.testing.assert_array_equal(obsc.contains(x, y), (inner <= r) & (r < outer)) do_pickle(obsc) rv = batoid.RayVector(x, y, 0.0, 0.0, 0.0, 0.0) batoid.obscure(obsc, rv) np.testing.assert_array_equal(obsc.contains(x, y), rv.vignetted)
def test_SellmeierMedium(): rng = np.random.default_rng(57) # Silica coefficients # https://refractiveindex.info/?shelf=main&book=SiO2&page=Malitson B1 = 0.6961663 B2 = 0.4079426 B3 = 0.8974794 C1 = 0.00467914825849 C2 = 0.013512063073959999 C3 = 97.93400253792099 silica = batoid.SellmeierMedium([B1, B2, B3, C1, C2, C3]) silica2 = batoid.SellmeierMedium(B1, B2, B3, C1, C2, C3) silica3 = batoid.SellmeierMedium(C1=C1, C2=C2, C3=C3, B1=B1, B2=B2, B3=B3) assert silica == silica2 assert silica == silica3 with np.testing.assert_raises(TypeError): batoid.SellmeierMedium(B1) with np.testing.assert_raises(ValueError): batoid.SellmeierMedium(B1, B2, B3, C1, C2, C3, B1) wavelengths = rng.uniform(300e-9, 1100e-9, size=1000) indices = silica.getN(wavelengths) for w, index in zip(wavelengths, indices): assert silica.getN(w) == index # CSV also from refractiveindex.info filename = os.path.join(os.path.dirname(__file__), "testdata", "silicaDispersion.csv") wmicron, ncsv = np.loadtxt(filename, delimiter=',').T n = silica.getN(wmicron * 1e-6) np.testing.assert_allclose(n, ncsv, atol=0, rtol=1e-13) do_pickle(silica)
def test_TableMedium(): rng = np.random.default_rng(57) for i in range(100): ws = np.linspace(300e-9, 1100e-9, 6) ns = rng.uniform(1.0, 1.5, size=6) table_medium = batoid.TableMedium(ws, ns) testws = rng.uniform(300e-9, 1100e-9, size=100) for w in testws: np.testing.assert_allclose(table_medium.getN(w), np.interp(w, ws, ns), rtol=0, atol=1e-14) np.testing.assert_allclose(table_medium.getN(testws), np.interp(testws, ws, ns), rtol=0, atol=1e-14) do_pickle(table_medium) # Test load from file filename = os.path.join(os.path.dirname(__file__), "testdata", "silicaDispersion.csv") medium1 = batoid.TableMedium.fromTxt(filename, delimiter=',') wmicron, ncsv = np.loadtxt(filename, delimiter=',').T medium2 = batoid.TableMedium(wmicron * 1e-6, ncsv) assert medium1 == medium2 # Load from datadir medium3 = batoid.TableMedium.fromTxt("silica_dispersion.txt") # Raises on bad input with np.testing.assert_raises(FileNotFoundError): medium4 = batoid.TableMedium.fromTxt("blah.txt")
def test_ObscRectangle(): import random random.seed(577) for i in range(100): cx = random.gauss(0.0, 1.0) cy = random.gauss(0.0, 1.0) w = random.uniform(0.5, 2.5) h = random.uniform(0.5, 2.5) obsc = batoid.ObscRectangle(w, h, cx, cy, 0.0) for i in range(100): x = random.gauss(0.0, 2.0) y = random.gauss(0.0, 2.0) assert obsc.contains(x, y) == (x > cx - w / 2 and x < cx + w / 2 and y > cy - h / 2 and y < cy + h / 2) th = random.uniform(0.0, np.pi / 2) obsc = batoid.ObscRectangle(w, h, cx, cy, th) for i in range(100): x = random.gauss(0.0, 2.0) y = random.gauss(0.0, 2.0) xp = (x - cx) * np.cos(-th) - (y - cy) * np.sin(-th) + cx yp = (x - cx) * np.sin(-th) + (y - cy) * np.cos(-th) + cy assert obsc.contains(x, y) == (xp > cx - w / 2 and xp < cx + w / 2 and yp > cy - h / 2 and yp < cy + h / 2) do_pickle(obsc)
def test_ObscCompound(): import random random.seed(57721) for i in range(100): rx = random.gauss(0.0, 1.0) ry = random.gauss(0.0, 1.0) w = random.uniform(0.5, 2.5) h = random.uniform(0.5, 2.5) th = random.uniform(0.0, np.pi) rect = batoid.ObscRectangle(w, h, rx, ry, th) cx = random.gauss(0.0, 1.0) cy = random.gauss(0.0, 1.0) r = random.uniform(0.5, 1.5) circ = batoid.ObscCircle(r, cx, cy) union = batoid.ObscUnion([rect, circ]) do_pickle(union) union2 = batoid.ObscUnion([circ, rect]) assert union == union2 # commutative! assert hash(union) == hash(union2) intersection = batoid.ObscIntersection([rect, circ]) do_pickle(intersection) intersection2 = batoid.ObscIntersection([circ, rect]) assert intersection == intersection2 assert hash(intersection) == hash(intersection2) for i in range(100): x = random.gauss(0.0, 2.0) y = random.gauss(0.0, 2.0) assert (union.contains(x, y) == union2.contains(x, y) == (rect.contains(x, y) or circ.contains(x, y))) assert (intersection.contains(x, y) == intersection2.contains( x, y) == (rect.contains(x, y) and circ.contains(x, y)))
def test_optic(): if __name__ == '__main__': nside = 128 else: nside = 32 rays = batoid.rayGrid(20, 12.0, 0.005, 0.005, -1.0, nside, 500e-9, 1.0, batoid.ConstMedium(1.0)) nrays = len(rays) print("Tracing {} rays.".format(nrays)) t_fast = 0.0 t_slow = 0.0 telescope = batoid.Optic.fromYaml("HSC.yaml") do_pickle(telescope) t0 = time.time() rays_fast = telescope.trace(rays) t1 = time.time() rays_slow = batoid.RayVector([telescope.trace(r) for r in rays]) t2 = time.time() assert rays_fast == rays_slow t_fast = t1 - t0 t_slow = t2 - t1 print("Fast trace: {:5.3f} s".format(t_fast)) print(" {} rays per second".format(int(nrays/t_fast))) print("Slow trace: {:5.3f} s".format(t_slow)) print(" {} rays per second".format(int(nrays/t_slow)))
def test_ObscRay(): rng = np.random.default_rng(5772) size = 10_000 for i in range(100): cx = rng.normal(0.0, 1.0) cy = rng.normal(0.0, 1.0) w = rng.uniform(0.5, 2.5) th = rng.uniform(0.0, np.pi / 2) obsc = batoid.ObscRay(w, th, cx, cy) for i in range(100): x = rng.normal(0.0, 2.0) y = rng.normal(0.0, 2.0) xp = (x - cx) * np.cos(-th) - (y - cy) * np.sin(-th) yp = (x - cx) * np.sin(-th) + (y - cy) * np.cos(-th) assert obsc.contains(x, y) == (xp > 0.0 and yp > -w / 2 and yp < w / 2) x = rng.normal(0.0, 2.0, size=size) y = rng.normal(0.0, 2.0, size=size) xp = (x - cx) * np.cos(-th) - (y - cy) * np.sin(-th) yp = (x - cx) * np.sin(-th) + (y - cy) * np.cos(-th) np.testing.assert_array_equal(obsc.contains(x, y), (xp > 0.0) & (yp > -w / 2) & (yp < w / 2)) do_pickle(obsc) rv = batoid.RayVector(x, y, 0.0, 0.0, 0.0, 0.0) batoid.obscure(obsc, rv) np.testing.assert_array_equal(obsc.contains(x, y), rv.vignetted)
def test_silica_sellmeier_table(): import random import time random.seed(577) # File from phosim filename = os.path.join(batoid.datadir, "media", "silica_dispersion.txt") wave, n = np.genfromtxt(filename).T wave *= 1e-6 # microns -> meters table = batoid.Table(wave, n, batoid.Table.Interpolant.linear) table_silica = batoid.TableMedium(table) # Coefficients from # https://refractiveindex.info/?shelf=main&book=SiO2&page=Malitson sellmeier_silica = batoid.SellmeierMedium(0.6961663, 0.4079426, 0.8974794, 0.0684043**2, 0.1162414**2, 9.896161**2) # Making this a timing test too for fun ws = [] for i in range(100000): ws.append(random.uniform(0.3e-6, 1.2e-6)) table_n = [] sellmeier_n = [] t0 = time.time() for w in ws: table_n.append(table_silica.getN(w)) t1 = time.time() for w in ws: sellmeier_n.append(sellmeier_silica.getN(w)) t2 = time.time() print("TableMedium took {} s".format(t1 - t0)) print("SellmeierMedium took {} s".format(t2 - t1)) np.testing.assert_allclose(table_n, sellmeier_n, atol=1e-6, rtol=0) do_pickle(sellmeier_silica)
def test_properties(): rng = np.random.default_rng(5) for i in range(100): R = rng.normal(0.0, 0.3) # negative allowed para = batoid.Paraboloid(R) assert para.R == R do_pickle(para)
def test_SumitaMedium(): rng = np.random.default_rng(57) # K-BK-7 coefficients # https://refractiveindex.info/?shelf=glass&book=SUMITA-BK&page=K-BK7 A0 = 2.2705778 A1 = -0.010059376 A2 = 0.010414999 A3 = 0.00028872517 A4 = -2.2214495e-5 A5 = 1.4258559e-6 kbk7 = batoid.SumitaMedium([A0, A1, A2, A3, A4, A5]) kbk7_2 = batoid.SumitaMedium(A0, A1, A2, A3, A4, A5) kbk7_3 = batoid.SumitaMedium(A0=A0, A1=A1, A2=A2, A3=A3, A4=A4, A5=A5) assert kbk7 == kbk7_2 assert kbk7 == kbk7_3 with np.testing.assert_raises(TypeError): batoid.SumitaMedium(A0) with np.testing.assert_raises(ValueError): batoid.SumitaMedium(A0, A1, A2, A3, A4, A5, A0) wavelengths = rng.uniform(300e-9, 1100e-9, size=1000) indices = kbk7.getN(wavelengths) for w, index in zip(wavelengths, indices): assert kbk7.getN(w) == index # CSV also from refractiveindex.info filename = os.path.join(os.path.dirname(__file__), "testdata", "kbk7.csv") wmicron, ncsv = np.loadtxt(filename, delimiter=',').T n = kbk7.getN(wmicron * 1e-6) np.testing.assert_allclose(n, ncsv, atol=0, rtol=1e-13) do_pickle(kbk7)
def test_properties(): import random random.seed(5) for i in range(100): R = random.gauss(0.7, 0.8) para = batoid.Paraboloid(R) assert para.R == R do_pickle(para)
def test_air(): # Just spot check some comparisons with GalSim. ws = [0.3, 0.5, 0.7, 0.9, 1.1] gsn = [1.00019563, 1.00018713, 1.00018498, 1.00018412, 1.00018369] air = batoid.Air() for w, n in zip(ws, gsn): np.testing.assert_allclose(n, air.getN(w * 1e-6), rtol=0, atol=1e-8) do_pickle(air)
def test_properties(): import random random.seed(5) for i in range(100): R = random.gauss(0.7, 0.8) sphere = batoid.Sphere(R) assert sphere.R == R do_pickle(sphere)
def test_prescreen(): """Add an OPDScreen in front of LSST entrance pupil. The OPD that comes out should be _negative_ the added phase delay by convention. """ lsst = batoid.Optic.fromYaml("LSST_r.yaml") wavelength = 620e-9 z_ref = batoid.zernikeGQ( lsst, 0, 0, wavelength, rings=10, reference='chief', jmax=37, eps=0.61 ) rng = np.random.default_rng(577) for i in range(4, 38): amplitude = rng.uniform(0.1, 0.2) zern = batoid.Zernike( np.array([0]*i+[amplitude])*wavelength, R_outer=4.18, R_inner=0.61*4.18 ) tel = batoid.CompoundOptic( ( batoid.optic.OPDScreen( batoid.Plane(), zern, name='PS', obscuration=batoid.ObscNegation(batoid.ObscCircle(5.0)), coordSys=lsst.stopSurface.coordSys ), *lsst.items ), name='PS0', backDist=lsst.backDist, pupilSize=lsst.pupilSize, inMedium=lsst.inMedium, stopSurface=lsst.stopSurface, sphereRadius=lsst.sphereRadius, pupilObscuration=lsst.pupilObscuration ) do_pickle(tel) zGQ = batoid.zernikeGQ( tel, 0, 0, wavelength, rings=10, reference='chief', jmax=37, eps=0.61 ) zTA = batoid.zernikeTA( tel, 0, 0, wavelength, nrad=10, naz=60, reference='chief', jmax=37, eps=0.61 ) z_expect = np.zeros_like(zGQ) z_expect[i] = -amplitude # Longer OPL => negative OPD np.testing.assert_allclose( (zGQ-z_ref)[4:], z_expect[4:], rtol=0, atol=5e-4 ) # Distortion makes this comparison less precise np.testing.assert_allclose( zGQ[4:], zTA[4:], rtol=0, atol=5e-3 )
def test_properties(): rng = np.random.default_rng(5) for i in range(100): R = rng.normal(0.0, 0.3) # negative allowed conic = rng.uniform(-2.0, 1.0) quad = batoid.Quadric(R, conic) assert quad.R == R assert quad.conic == conic do_pickle(quad)
def test_SimpleCoating(): np.random.seed(5) for i in range(1000): reflectivity = np.random.uniform(0, 1) transmissivity = np.random.uniform(0, 1) sc = batoid.SimpleCoating(reflectivity, transmissivity) assert sc.reflectivity == reflectivity == sc.getReflect(0.1, 0.2) == sc.getReflect(0.3, 0.4) assert sc.transmissivity == transmissivity == sc.getTransmit(0.1, 0.2) == sc.getTransmit(0.3, 0.4) do_pickle(sc)
def test_properties(): import random random.seed(5) for i in range(100): R = random.gauss(0.7, 0.8) conic = random.uniform(-2.0, 1.0) quad = batoid.Quadric(R, conic) assert quad.R == R assert quad.conic == conic do_pickle(quad)
def test_const_medium(): import random random.seed(5) n = 1.4 const_medium = batoid.ConstMedium(n) for i in range(100): w = random.uniform(0.5, 1.0) assert const_medium.getN(w) == n do_pickle(const_medium)
def test_properties(): np.random.seed(5) for _ in range(100): xs = np.arange(10) ys = np.arange(10) zs = np.random.uniform(0, 1, size=(10, 10)) bc = batoid.Bicubic(xs, ys, zs) np.testing.assert_array_equal(xs, bc.xs) np.testing.assert_array_equal(ys, bc.ys) np.testing.assert_array_equal(zs, bc.zs) do_pickle(bc)
def test_ConstMedium(): rng = np.random.default_rng(5) for i in range(100): n = rng.uniform(1.0, 2.0) const_medium = batoid.ConstMedium(n) wavelengths = rng.uniform(300e-9, 1100e-9, size=100) for w in wavelengths: assert const_medium.getN(w) == n np.testing.assert_array_equal(const_medium.getN(wavelengths), np.full_like(wavelengths, n)) do_pickle(const_medium)
def test_lattice_coords(): np.random.seed(5) # Check 1D for _ in np.arange(10): N = np.random.randint(1, 2000) arr = np.ones((N, )) primitiveVector = np.random.uniform(-1.0, 1.0) lattice = batoid.Lattice(arr, primitiveVector) np.testing.assert_allclose( np.squeeze(lattice.coords), np.arange(-(N // 2), -(-N // 2)) * primitiveVector) # Check 2D for _ in np.arange(10): N1 = np.random.randint(1, 200) N2 = np.random.randint(1, 200) arr = np.ones((N1, N2)) pv1 = np.random.uniform(-1.0, 1.0, size=2) pv2 = np.random.uniform(-1.0, 1.0, size=2) lattice = batoid.Lattice(arr, np.vstack([pv1, pv2])) for _ in np.arange(100): i = np.random.randint(0, N1) j = np.random.randint(0, N2) np.testing.assert_allclose(lattice.coords[i, j], (i - N1 // 2) * pv1 + (j - N2 // 2) * pv2) # Check 3D for _ in np.arange(10): N1 = np.random.randint(1, 20) N2 = np.random.randint(1, 20) N3 = np.random.randint(1, 20) arr = np.ones((N1, N2, N3)) pv1 = np.random.uniform(-1.0, 1.0, size=3) pv2 = np.random.uniform(-1.0, 1.0, size=3) pv3 = np.random.uniform(-1.0, 1.0, size=3) lattice = batoid.Lattice(arr, np.vstack([pv1, pv2, pv3])) with np.printoptions(threshold=20**3): do_pickle(lattice) for __ in np.arange(100): i = np.random.randint(0, N1) j = np.random.randint(0, N2) k = np.random.randint(0, N3) np.testing.assert_allclose( lattice.coords[i, j, k], (i - N1 // 2) * pv1 + (j - N2 // 2) * pv2 + (k - N3 // 2) * pv3)
def test_properties(): import random random.seed(5) for i in range(100): R = random.gauss(0.7, 0.8) conic = random.uniform(-2.0, 1.0) ncoef = random.randint(0, 4) coefs = [random.gauss(0, 1e-10) for i in range(ncoef)] asphere = batoid.Asphere(R, conic, coefs) assert asphere.R == R assert asphere.conic == conic assert asphere.coefs == coefs do_pickle(asphere)
def test_properties(): rng = np.random.default_rng(57) for _ in range(10): jmax = rng.integers(4, 55) coef = rng.normal(size=jmax+1)*1e-3 R_outer = rng.uniform(0.5, 5.0) R_inner = rng.uniform(0.0, 0.65*R_outer) zernike = batoid.Zernike(coef, R_outer=R_outer, R_inner=R_inner) assert R_outer == zernike.R_outer assert R_inner == zernike.R_inner assert np.array_equal(coef, zernike.coef) do_pickle(zernike)