LSST Applications g0d97872fb5+4fd969bb9d,g1653933729+34a971ddd9,g28da252d5a+072f89fe25,g2bbee38e9b+a99b0ab4cd,g2bc492864f+a99b0ab4cd,g2ca4be77d2+c0e3b27cd8,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+a99b0ab4cd,g35bb328faa+34a971ddd9,g3a166c0a6a+a99b0ab4cd,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9ed5ed841a,g569e0e2b34+cb4faa46ad,g5a97de2502+520531a62c,g717e5f8c0f+29153700a5,g7ede599f99+367733290c,g80478fca09+17051a22cc,g82479be7b0+f2f1ea0a87,g858d7b2824+29153700a5,g8b782ad322+29153700a5,g8cd86fa7b1+05420e7f7d,g9125e01d80+34a971ddd9,ga5288a1d22+e7f674aaf3,gae0086650b+34a971ddd9,gae74b0b5c6+45ef5cdc51,gb58c049af0+ace264a4f2,gc28159a63d+a99b0ab4cd,gcf0d15dbbd+8051a81198,gda6a2b7d83+8051a81198,gdaeeff99f8+7774323b41,gdf4d240d4a+34a971ddd9,ge2409df99d+cb167bac99,ge33fd446bb+29153700a5,ge79ae78c31+a99b0ab4cd,gf0baf85859+890af219f9,gf5289d68f6+9faa5c5784,w.2024.36
LSST Data Management Base Package
Loading...
Searching...
No Matches
Functions | Variables
test_ellipse Namespace Reference

Functions

 test_Covariance ()
 
 test_Ellipse ()
 
 test_EllipseMajor ()
 

Variables

 rho_min = math.nextafter(-1, -2)
 
 rho_max = math.nextafter(1, 2)
 
 pos_min = math.nextafter(0, 1)
 
str prefix_namespace = "lsst.gauss2d."
 

Function Documentation

◆ test_Covariance()

test_ellipse.test_Covariance ( )

Definition at line 33 of file test_ellipse.py.

33def test_Covariance():
34 with pytest.raises(ValueError):
36 with pytest.raises(ValueError):
37 g2d.Covariance(0, -1)
38 for rho_bad in (rho_min, rho_max):
39 with pytest.raises(ValueError):
40 g2d.Covariance(0, 0, rho_bad)
41
42 covar_0 = g2d.Covariance()
43 assert (covar_0.sigma_x_sq, covar_0.sigma_y_sq, covar_0.cov_xy) == (0, 0, 0)
44 assert covar_0.xyc == [0, 0, 0]
45 assert covar_0 != g2d.Covariance(pos_min, 0, 0)
46 assert covar_0 != g2d.Covariance(0, pos_min, 0)
47 assert g2d.Covariance(1, 1, 0) != g2d.Covariance(1, 1, pos_min)
48
49 covar_conv = g2d.Covariance(9., 9., 0).make_convolution(g2d.Covariance(16., 16., 0))
50 assert covar_conv == g2d.Covariance(25., 25., 0)
51
52 str_covar_conv = "Covariance(sigma_x_sq=2.500000e+01, sigma_y_sq=2.500000e+01, cov_xy=0.000000e+00)"
53 assert str(str_covar_conv) == str_covar_conv
54 assert repr(covar_conv) == f"{prefix_namespace}{str_covar_conv}"
55
56
A representation of a 2D Gaussian with x and y standard deviations and a covariance value.
Definition ellipse.h:57

◆ test_Ellipse()

test_ellipse.test_Ellipse ( )

Definition at line 57 of file test_ellipse.py.

57def test_Ellipse():
58 with pytest.raises(ValueError):
59 g2d.Ellipse(-1)
60 with pytest.raises(ValueError):
61 g2d.Ellipse(0, -1)
62 for rho_bad in (rho_min, rho_max):
63 with pytest.raises(ValueError):
64 g2d.Ellipse(0, 0, rho_bad)
65
66 ell_0 = g2d.Ellipse()
67 assert ell_0.xyr == [0, 0, 0]
68 assert ell_0 != g2d.Ellipse(pos_min, 0, 0)
69 assert ell_0 != g2d.Ellipse(0, pos_min, 0)
70 ell_1 = g2d.Ellipse(sigma_x=1, sigma_y=1, rho=-0.1)
71 assert (ell_1.sigma_x, ell_1.sigma_y, ell_1.rho) == (1, 1, -0.1)
72 assert [ell_1.hwhm_x, ell_1.hwhm_y, ell_1.rho] == ell_1.hxyr
73 ell_1.set_h(hwhm_x=1, hwhm_y=1, rho=0.1)
74 assert (ell_1.hwhm_x, ell_1.hwhm_y, ell_1.rho) == (1, 1, 0.1)
75 assert ell_1 != g2d.Ellipse(1, 1, pos_min)
76
77 ell_conv = g2d.Ellipse(3., 3., 0).make_convolution(g2d.Ellipse(4., 4., 0))
78 assert ell_conv == g2d.Ellipse(5., 5., 0)
79 assert ell_conv.get_radius_trace() == pytest.approx(5*math.sqrt(2.), rel=1e-10, abs=1e-10)
80
81 str_data = "EllipseValues(sigma_x=5.000000e+00, sigma_y=5.000000e+00, rho=0.000000e+00)"
82 assert str(ell_conv) == f"Ellipse(data={str_data})"
83 assert repr(ell_conv) == f"{prefix_namespace}Ellipse(data={prefix_namespace}{str_data})"
84
85 ell_conv.set(g2d.Covariance(ell_0))
86 print(g2d.Covariance(ell_0))
87 assert ell_conv == ell_0
88 ell_1_maj = g2d.EllipseMajor(ell_1)
89 ell_conv.set(ell_1_maj)
90 assert ell_conv == g2d.Ellipse(ell_1_maj)
91
92
An Ellipse with sigma_x, sigma_y, and rho values.
Definition ellipse.h:283
An Ellipse with r_major, axrat and angle values.
Definition ellipse.h:337

◆ test_EllipseMajor()

test_ellipse.test_EllipseMajor ( )

Definition at line 93 of file test_ellipse.py.

93def test_EllipseMajor():
94 covar = g2d.Covariance(0.08333332098858685, 0.08333332098858683, 1.337355953645e-13)
95 ellipse_maj = g2d.EllipseMajor(covar)
96 assert ellipse_maj.r_major > 0

Variable Documentation

◆ pos_min

test_ellipse.pos_min = math.nextafter(0, 1)

Definition at line 29 of file test_ellipse.py.

◆ prefix_namespace

str test_ellipse.prefix_namespace = "lsst.gauss2d."

Definition at line 30 of file test_ellipse.py.

◆ rho_max

test_ellipse.rho_max = math.nextafter(1, 2)

Definition at line 28 of file test_ellipse.py.

◆ rho_min

test_ellipse.rho_min = math.nextafter(-1, -2)

Definition at line 27 of file test_ellipse.py.