@@ -301,107 +301,6 @@ def test__convolved_array_from__not_odd_x_odd_kernel__raises_error():
301301
302302
303303def test__convolved_array_from ():
304- array_2d = aa .Array2D .no_mask (
305- values = [[0.0 , 0.0 , 0.0 ], [0.0 , 1.0 , 0.0 ], [0.0 , 0.0 , 0.0 ]], pixel_scales = 1.0
306- )
307-
308- kernel_2d = aa .Kernel2D .no_mask (
309- values = [[0.0 , 1.0 , 0.0 ], [1.0 , 2.0 , 1.0 ], [0.0 , 1.0 , 0.0 ]], pixel_scales = 1.0
310- )
311-
312- blurred_array_2d = kernel_2d .convolved_array_from (array_2d )
313-
314- assert (blurred_array_2d == kernel_2d ).all ()
315-
316- array_2d = aa .Array2D .no_mask (
317- values = [
318- [0.0 , 0.0 , 0.0 , 0.0 ],
319- [0.0 , 1.0 , 0.0 , 0.0 ],
320- [0.0 , 0.0 , 0.0 , 0.0 ],
321- [0.0 , 0.0 , 0.0 , 0.0 ],
322- ],
323- pixel_scales = 1.0 ,
324- )
325-
326- kernel_2d = aa .Kernel2D .no_mask (
327- values = [[0.0 , 1.0 , 0.0 ], [1.0 , 2.0 , 1.0 ], [0.0 , 1.0 , 0.0 ]], pixel_scales = 1.0
328- )
329-
330- blurred_array_2d = kernel_2d .convolved_array_from (array = array_2d )
331-
332- assert (
333- blurred_array_2d .native
334- == np .array (
335- [
336- [0.0 , 1.0 , 0.0 , 0.0 ],
337- [1.0 , 2.0 , 1.0 , 0.0 ],
338- [0.0 , 1.0 , 0.0 , 0.0 ],
339- [0.0 , 0.0 , 0.0 , 0.0 ],
340- ]
341- )
342- ).all ()
343-
344- array_2d = aa .Array2D .no_mask (
345- values = [[0.0 , 0.0 , 0.0 ], [0.0 , 1.0 , 0.0 ], [0.0 , 0.0 , 0.0 ], [0.0 , 0.0 , 0.0 ]],
346- pixel_scales = 1.0 ,
347- )
348-
349- kernel_2d = aa .Kernel2D .no_mask (
350- values = [[0.0 , 1.0 , 0.0 ], [1.0 , 2.0 , 1.0 ], [0.0 , 1.0 , 0.0 ]], pixel_scales = 1.0
351- )
352-
353- blurred_array_2d = kernel_2d .convolved_array_from (array_2d )
354-
355- assert (
356- blurred_array_2d .native
357- == np .array (
358- [[0.0 , 1.0 , 0.0 ], [1.0 , 2.0 , 1.0 ], [0.0 , 1.0 , 0.0 ], [0.0 , 0.0 , 0.0 ]]
359- )
360- ).all ()
361-
362- array_2d = aa .Array2D .no_mask (
363- values = [[0.0 , 0.0 , 0.0 , 0.0 ], [0.0 , 1.0 , 0.0 , 0.0 ], [0.0 , 0.0 , 0.0 , 0.0 ]],
364- pixel_scales = 1.0 ,
365- )
366-
367- kernel_2d = aa .Kernel2D .no_mask (
368- values = [[0.0 , 1.0 , 0.0 ], [1.0 , 2.0 , 1.0 ], [0.0 , 1.0 , 0.0 ]], pixel_scales = 1.0
369- )
370-
371- blurred_array_2d = kernel_2d .convolved_array_from (array_2d )
372-
373- assert (
374- blurred_array_2d .native
375- == np .array ([[0.0 , 1.0 , 0.0 , 0.0 ], [1.0 , 2.0 , 1.0 , 0.0 ], [0.0 , 1.0 , 0.0 , 0.0 ]])
376- ).all ()
377-
378- array_2d = aa .Array2D .no_mask (
379- values = [
380- [0.0 , 0.0 , 0.0 , 0.0 ],
381- [0.0 , 1.0 , 0.0 , 0.0 ],
382- [0.0 , 0.0 , 1.0 , 0.0 ],
383- [0.0 , 0.0 , 0.0 , 0.0 ],
384- ],
385- pixel_scales = 1.0 ,
386- )
387-
388- kernel_2d = aa .Kernel2D .no_mask (
389- values = [[1.0 , 1.0 , 1.0 ], [2.0 , 2.0 , 1.0 ], [1.0 , 3.0 , 3.0 ]], pixel_scales = 1.0
390- )
391-
392- blurred_array_2d = kernel_2d .convolved_array_from (array_2d )
393-
394- assert (
395- blurred_array_2d .native
396- == np .array (
397- [
398- [1.0 , 1.0 , 1.0 , 0.0 ],
399- [2.0 , 3.0 , 2.0 , 1.0 ],
400- [1.0 , 5.0 , 5.0 , 1.0 ],
401- [0.0 , 1.0 , 3.0 , 3.0 ],
402- ]
403- )
404- ).all ()
405304
406305 array_2d = aa .Array2D .no_mask (
407306 [
@@ -460,7 +359,7 @@ def test__convolved_array_from():
460359 ).all ()
461360
462361
463- def test__convolve_mapping_matrix__asymetric_convolver__matrix_blurred_correctly ():
362+ def test__convolve_mapping_matrix ():
464363 mask = np .array (
465364 [
466365 [True , True , True , True , True , True ],
@@ -472,12 +371,10 @@ def test__convolve_mapping_matrix__asymetric_convolver__matrix_blurred_correctly
472371 ]
473372 )
474373
475- asymmetric_kernel = aa .Kernel2D .no_mask (
374+ kernel = aa .Kernel2D .no_mask (
476375 values = [[0 , 0.0 , 0 ], [0.4 , 0.2 , 0.3 ], [0 , 0.1 , 0 ]], pixel_scales = 1.0
477376 )
478377
479- convolver = aa .Convolver (mask = mask , kernel = asymmetric_kernel )
480-
481378 mapping = np .array (
482379 [
483380 [0 , 0 , 0 ],
@@ -503,7 +400,7 @@ def test__convolve_mapping_matrix__asymetric_convolver__matrix_blurred_correctly
503400 ]
504401 )
505402
506- blurred_mapping = convolver .convolve_mapping_matrix (mapping )
403+ blurred_mapping = kernel .convolve_mapping_matrix (mapping )
507404
508405 assert (
509406 blurred_mapping
@@ -529,12 +426,10 @@ def test__convolve_mapping_matrix__asymetric_convolver__matrix_blurred_correctly
529426 )
530427 ).all ()
531428
532- asymmetric_kernel = aa .Kernel2D .no_mask (
429+ kernel = aa .Kernel2D .no_mask (
533430 values = [[0 , 0.0 , 0 ], [0.4 , 0.2 , 0.3 ], [0 , 0.1 , 0 ]], pixel_scales = 1.0
534431 )
535432
536- convolver = aa .Convolver (mask = mask , kernel = asymmetric_kernel )
537-
538433 mapping = np .array (
539434 [
540435 [0 , 1 , 0 ],
@@ -560,7 +455,7 @@ def test__convolve_mapping_matrix__asymetric_convolver__matrix_blurred_correctly
560455 ]
561456 )
562457
563- blurred_mapping = convolver .convolve_mapping_matrix (mapping )
458+ blurred_mapping = kernel .convolve_mapping_matrix (mapping )
564459
565460 assert blurred_mapping == pytest .approx (
566461 np .array (
@@ -587,39 +482,6 @@ def test__convolve_mapping_matrix__asymetric_convolver__matrix_blurred_correctly
587482 )
588483
589484
590- def test__convolution__cross_mask_with_blurring_entries__returns_array ():
591- cross_mask = aa .Mask2D (
592- mask = [
593- [True , True , True , True , True ],
594- [True , True , False , True , True ],
595- [True , False , False , False , True ],
596- [True , True , False , True , True ],
597- [True , True , True , True , True ],
598- ],
599- pixel_scales = 0.1 ,
600- )
601-
602- kernel = aa .Kernel2D .no_mask (
603- values = [[0 , 0.2 , 0 ], [0.2 , 0.4 , 0.2 ], [0 , 0.2 , 0 ]], pixel_scales = 0.1
604- )
605-
606- convolver = aa .Convolver (mask = cross_mask , kernel = kernel )
607-
608- image_array = aa .Array2D (values = [1 , 0 , 0 , 0 , 0 ], mask = cross_mask )
609-
610- blurring_mask = cross_mask .derive_mask .blurring_from (
611- kernel_shape_native = kernel .shape_native
612- )
613-
614- blurring_array = aa .Array2D (
615- values = [0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ], mask = blurring_mask
616- )
617-
618- result = convolver .convolve_image (image = image_array , blurring_image = blurring_array )
619-
620- assert (np .round (result , 1 ) == np .array ([0.6 , 0.2 , 0.2 , 0.0 , 0.0 ])).all ()
621-
622-
623485def test__compare_to_full_2d_convolution ():
624486 # Setup a blurred data, using the PSF to perform the convolution in 2D, then masks it to make a 1d array.
625487
@@ -649,11 +511,9 @@ def test__compare_to_full_2d_convolution():
649511 kernel_shape_native = kernel .shape_native
650512 )
651513
652- convolver = aa .Convolver (mask = mask , kernel = kernel )
653-
654514 blurring_image = aa .Array2D (values = image .native , mask = blurring_mask )
655515
656- blurred_masked_im_1 = convolver .convolve_image (
516+ blurred_masked_im_1 = kernel .convolve_image (
657517 image = masked_image , blurring_image = blurring_image
658518 )
659519
@@ -688,33 +548,6 @@ def test__compare_to_full_2d_convolution__no_blurring_image():
688548
689549 masked_image = aa .Array2D (values = image .native , mask = mask )
690550
691- convolver = aa .Convolver (mask = mask , kernel = kernel )
692-
693- blurred_masked_im_1 = convolver .convolve_image_no_blurring (image = masked_image )
551+ blurred_masked_im_1 = kernel .convolve_image_no_blurring (image = masked_image )
694552
695553 assert blurred_masked_image_via_scipy == pytest .approx (blurred_masked_im_1 , 1e-4 )
696-
697-
698- def test__summed_convolved_array_from ():
699- mask = aa .Mask2D (
700- mask = [
701- [True , True , True , True , True ],
702- [True , True , True , True , True ],
703- [True , False , False , False , True ],
704- [True , True , True , True , True ],
705- [True , True , True , True , True ],
706- ],
707- pixel_scales = 0.1 ,
708- )
709-
710- kernel = aa .Kernel2D .no_mask (
711- values = [[0 , 0.0 , 0 ], [0.5 , 1.0 , 0.5 ], [0 , 0.0 , 0 ]], pixel_scales = 0.1
712- )
713-
714- convolver = aa .Convolver (mask = mask , kernel = kernel )
715-
716- image_array = aa .Array2D (values = [1.0 , 2.0 , 3.0 ], mask = mask )
717-
718- summed_convolved_array = convolver .convolve_image_no_blurring (image = image_array )
719-
720- assert summed_convolved_array == pytest .approx (np .array ([2.0 , 4.0 , 4.0 ]), 1.0e-4 )
0 commit comments