@@ -76,7 +76,11 @@ def test_cmb_lensed(model_tag, freq):
76
76
77
77
78
78
@pytest .mark .parametrize ("freq" , [100 ])
79
- def test_cmb_lensed_l01 (freq ):
79
+ def test_cmb_lensed_with_patch_object (freq ):
80
+ # The CMBLensed Model expects the CAMB power spectrum output to
81
+ # begin at l=2, resulting misalignment of ells when it is not
82
+ # included. To test the fix, the method must be patched.
83
+ # This test shows that patching works, complementing test_cmb_lensed_l01.
80
84
81
85
model_number = 5
82
86
expected_output = pysm3 .read_map (
@@ -93,7 +97,6 @@ def test_cmb_lensed_l01(freq):
93
97
c1_delens_l = temp_model .read_txt ('pysm_2/delens_ells.txt' ,
94
98
unpack = True )
95
99
96
- # This portion should always pass
97
100
with patch .object (target = pysm3 .models .cmb .CMBLensed ,
98
101
attribute = "read_txt" ,
99
102
side_effect = [c1_spectra , c1_delens_l ]):
@@ -106,16 +109,34 @@ def test_cmb_lensed_l01(freq):
106
109
)
107
110
model = pysm3 .Sky (nside = 64 , component_objects = [c1 ])
108
111
109
- try :
110
- assert_quantity_allclose (
111
- expected_output ,
112
- model .get_emission (freq * u .GHz ),
113
- rtol = 1e-5
114
- )
115
- except AssertionError :
116
- pytest .fail (f"Unexpected AssertionError. Superfail." )
112
+ assert_quantity_allclose (
113
+ expected_output ,
114
+ model .get_emission (freq * u .GHz ),
115
+ rtol = 1e-5
116
+ )
117
+
118
+
119
+ @pytest .mark .parametrize ("freq" , [100 ])
120
+ def test_cmb_lensed_l01 (freq ):
121
+ # The CMBLensed Model expects the CAMB power spectrum output to
122
+ # begin at l=2, resulting misalignment of ells when it is not
123
+ # included. This test shows that the fix works, by changing the
124
+ # input cls from the original test (test_cmb_lensed) to include l=0,1.
125
+
126
+ model_number = 5
127
+ expected_output = pysm3 .read_map (
128
+ f"pysm_2_test_data/check{ model_number } cmb_{ freq } p0_64.fits" ,
129
+ 64 ,
130
+ unit = "uK_RJ" ,
131
+ field = (0 , 1 , 2 ),
132
+ )
117
133
118
- # This portion should pass only with the fix
134
+ # Use a temporary model to get access to the read_txt method
135
+ temp_model = pysm3 .Model (nside = 64 )
136
+ c1_spectra = temp_model .read_txt ('pysm_2/camb_lenspotentialCls.dat' ,
137
+ unpack = True )
138
+ c1_delens_l = temp_model .read_txt ('pysm_2/delens_ells.txt' ,
139
+ unpack = True )
119
140
120
141
# Add rows of 0s for l=0,1
121
142
c1_spectra_l01 = np .zeros ((c1_spectra .shape [0 ], c1_spectra .shape [1 ] + 2 ))
0 commit comments