@@ -767,3 +767,36 @@ def test_fkp_normalization_errors():
767767 # Two potentially different catalog fields
768768 with pytest .raises (ValueError ):
769769 nmt .NmtWorkspace .from_fields (fc , fcb , b , normalization = 'FKP' )
770+
771+
772+ def test_general_mcmc ():
773+ # Create disc mask
774+ nside = 256
775+ nell = 3 * nside
776+ npix = hp .nside2npix (nside )
777+ mask = np .zeros (npix )
778+ mask [hp .query_disc (nside , [1 , 0 , 0 ], np .radians (30 ))] = 1
779+
780+ f0 = nmt .NmtField (mask , None , spin = 0 )
781+ f2 = nmt .NmtField (mask , None , spin = 2 )
782+ b = nmt .NmtBin .from_nside_linear (nside , nlb = 10 )
783+ w00 = nmt .NmtWorkspace .from_fields (f0 , f0 , b )
784+ w02 = nmt .NmtWorkspace .from_fields (f0 , f2 , b )
785+ w22 = nmt .NmtWorkspace .from_fields (f2 , f2 , b )
786+
787+ mcm00 = w00 .get_coupling_matrix ()
788+ mcm02 = w02 .get_coupling_matrix ().reshape ([nell , 2 , nell , 2 ])
789+ mcm02 = mcm02 [:, 0 , :, 0 ]
790+ mcm22 = w22 .get_coupling_matrix ().reshape ([nell , 4 , nell , 4 ])
791+ mcmee_ee = mcm22 [:, 0 , :, 0 ]
792+ mcmee_bb = mcm22 [:, 0 , :, 3 ]
793+ mcm22 = mcmee_ee + mcmee_bb
794+
795+ pclm = hp .anafast (mask )
796+ m00 = nmt .get_general_coupling_matrix (pclm , 0 , 0 , 0 , 0 )
797+ m02 = nmt .get_general_coupling_matrix (pclm , 0 , 2 , 0 , 2 )
798+ m22 = nmt .get_general_coupling_matrix (pclm , 2 , 2 , 2 , 2 )
799+
800+ assert np .amax (np .fabs (m00 - mcm00 )/ np .amax (mcm00 )) < 1E-10
801+ assert np .amax (np .fabs (m02 - mcm02 )/ np .amax (mcm02 )) < 1E-10
802+ assert np .amax (np .fabs (m22 - mcm22 )/ np .amax (mcm22 )) < 1E-10
0 commit comments