22from os import path
33import os
44import numpy as np
5+ import pytest
56import shutil
67
78import autoarray as aa
@@ -39,7 +40,7 @@ def clean_fits(fits_path):
3940 shutil .rmtree (fits_path )
4041
4142
42- def test__constructor ():
43+ def test__constructor__with_partial_mask__masked_pixels_set_to_zero_in_native ():
4344 mask = aa .Mask1D (
4445 mask = [True , False , False , True , False , False ],
4546 pixel_scales = 1.0 ,
@@ -55,7 +56,7 @@ def test__constructor():
5556 assert array_1d .origin == (0.0 ,)
5657
5758
58- def test__no_mask ():
59+ def test__no_mask__4_element_array__native_slim_and_grid_radial_correct ():
5960 array_1d = aa .Array1D .no_mask (values = [1.0 , 2.0 , 3.0 , 4.0 ], pixel_scales = 1.0 )
6061
6162 assert type (array_1d ) == aa .Array1D
@@ -67,7 +68,7 @@ def test__no_mask():
6768 assert array_1d .origin == (0.0 ,)
6869
6970
70- def test__full ():
71+ def test__full__fill_value_1_shape_4__all_elements_equal_fill_value ():
7172 array_1d = aa .Array1D .full (
7273 fill_value = 1.0 , shape_native = 4 , pixel_scales = 1.0 , origin = (4.0 ,)
7374 )
@@ -80,7 +81,7 @@ def test__full():
8081 assert array_1d .origin == (4.0 ,)
8182
8283
83- def test__ones ():
84+ def test__ones__shape_3_pixel_scale_3__all_native_elements_are_one ():
8485 array_1d = aa .Array1D .ones (shape_native = 3 , pixel_scales = 3.0 , origin = (4.0 ,))
8586
8687 assert type (array_1d ) == aa .Array1D
@@ -91,7 +92,7 @@ def test__ones():
9192 assert array_1d .origin == (4.0 ,)
9293
9394
94- def test__zeros ():
95+ def test__zeros__shape_3_pixel_scale_3__all_native_elements_are_zero ():
9596 array_1d = aa .Array1D .zeros (shape_native = 3 , pixel_scales = 3.0 , origin = (4.0 ,))
9697
9798 assert type (array_1d ) == aa .Array1D
@@ -102,7 +103,7 @@ def test__zeros():
102103 assert array_1d .origin == (4.0 ,)
103104
104105
105- def test__from_fits ():
106+ def test__from_fits__3_element_fits__native_and_slim_are_ones ():
106107 create_fits (fits_path = fits_path )
107108
108109 arr = aa .Array1D .from_fits (
@@ -113,6 +114,12 @@ def test__from_fits():
113114 assert (arr .native == np .ones ((3 ,))).all ()
114115 assert (arr .slim == np .ones (3 )).all ()
115116
117+ clean_fits (fits_path = fits_path )
118+
119+
120+ def test__from_fits__4_element_fits__native_slim_and_array_are_ones ():
121+ create_fits (fits_path = fits_path )
122+
116123 arr = aa .Array1D .from_fits (
117124 file_path = path .join (fits_path , "4_ones.fits" ), hdu = 0 , pixel_scales = 1.0
118125 )
@@ -125,7 +132,7 @@ def test__from_fits():
125132 clean_fits (fits_path = fits_path )
126133
127134
128- def test__from_fits__loads_and_stores_header_info ():
135+ def test__from_fits__3_element_fits__header_bitpix_is_minus_64 ():
129136 create_fits (fits_path = fits_path )
130137
131138 arr = aa .Array1D .from_fits (
@@ -135,6 +142,12 @@ def test__from_fits__loads_and_stores_header_info():
135142 assert arr .header .header_sci_obj ["BITPIX" ] == - 64
136143 assert arr .header .header_hdu_obj ["BITPIX" ] == - 64
137144
145+ clean_fits (fits_path = fits_path )
146+
147+
148+ def test__from_fits__4_element_fits__header_bitpix_is_minus_64 ():
149+ create_fits (fits_path = fits_path )
150+
138151 arr = aa .Array1D .from_fits (
139152 file_path = path .join (fits_path , "4_ones.fits" ), hdu = 0 , pixel_scales = 1.0
140153 )
@@ -145,7 +158,7 @@ def test__from_fits__loads_and_stores_header_info():
145158 clean_fits (fits_path = fits_path )
146159
147160
148- def test__output_to_fits ():
161+ def test__output_to_fits__ones_array__fits_file_has_correct_values_and_header ():
149162 arr = aa .Array1D .ones (shape_native = (3 ,), pixel_scales = 1.0 )
150163
151164 if path .exists (test_data_path ):
@@ -169,12 +182,14 @@ def test__output_to_fits():
169182 assert header_load ["ORIGIN" ] == 0.0
170183
171184
172- def test__recursive_shape_storage ():
185+ def test__recursive_shape_storage__no_mask__native_slim_native_roundtrip_correct ():
173186 array_1d = aa .Array1D .no_mask (values = [1.0 , 2.0 , 3.0 , 4.0 ], pixel_scales = 1.0 )
174187
175188 assert (array_1d .native .slim .native == np .array ([1.0 , 2.0 , 3.0 , 4.0 ])).all ()
176189 assert (array_1d .slim .native .slim == np .array ([1.0 , 2.0 , 3.0 , 4.0 ])).all ()
177190
191+
192+ def test__recursive_shape_storage__with_partial_mask__native_slim_native_roundtrip_correct ():
178193 mask = aa .Mask1D (
179194 mask = [True , False , False , True , False , False ],
180195 pixel_scales = 1.0 ,
0 commit comments