Skip to content

Commit

Permalink
Updated AstroImage tests to account for new method signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffenhir authored and schmelly committed Dec 30, 2023
1 parent 1a3baa7 commit 73e06a8
Showing 1 changed file with 17 additions and 25 deletions.
42 changes: 17 additions & 25 deletions tests/test_AstroImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,15 @@ def get(self):


def test_set_from_array_mono():
stretch = DummyStretchOption()
saturation = DummySaturationOption()
a = AstroImage(stretch,saturation)
a = AstroImage(do_update_display=False)

a.set_from_array(array_mono)
assert_array_almost_equal(a.img_array, array_mono, decimal=5)
assert a.width == 6
assert a.height == 5

def test_set_from_array_color():
stretch = DummyStretchOption()
saturation = DummySaturationOption()
a = AstroImage(stretch,saturation)
a = AstroImage(do_update_display=False)

a.set_from_array(array_color)
assert_array_almost_equal(a.img_array, array_color, decimal=5)
Expand All @@ -63,22 +59,18 @@ def test_set_from_array_color():

@pytest.mark.parametrize("img", test_images_mono)
def test_set_from_file_mono(img):
stretch = DummyStretchOption()
saturation = DummySaturationOption()
a = AstroImage(stretch,saturation)
a = AstroImage(do_update_display=False)

a.set_from_file("./tests/test_images/" + img)
a.set_from_file("./tests/test_images/" + img, None, None)
assert_array_almost_equal(a.img_array, array_mono, decimal=5)
assert a.width == 6
assert a.height == 5

@pytest.mark.parametrize("img", test_images_color)
def test_set_from_file_color(img):
stretch = DummyStretchOption()
saturation = DummySaturationOption()
a = AstroImage(stretch,saturation)
a = AstroImage(do_update_display=False)

a.set_from_file("./tests/test_images/" + img)
a.set_from_file("./tests/test_images/" + img, None, None)
assert_array_almost_equal(a.img_array, array_color, decimal=5)
assert a.width == 6
assert a.height == 5
Expand All @@ -88,20 +80,20 @@ def test_set_from_file_color(img):
def test_update_display_mono():
stretch = DummyStretchOption()
saturation = DummySaturationOption()
a = AstroImage(stretch,saturation)
a = AstroImage(do_update_display=False)

a.set_from_array(array_mono)
a.update_display()
a.update_display(stretch, saturation)
assert np.asarray(a.img_display).shape == (5,6)
assert np.asarray(a.img_display_saturated).shape == (5,6)

def test_update_display_color():
stretch = DummyStretchOption()
saturation = DummySaturationOption()
a = AstroImage(stretch,saturation)
a = AstroImage(do_update_display=False)

a.set_from_array(array_color)
a.update_display()
a.update_display(stretch, saturation)
assert np.asarray(a.img_display).shape == (5,6,3)
assert np.asarray(a.img_display_saturated).shape == (5,6,3)

Expand All @@ -110,9 +102,9 @@ def test_update_display_color():
def test_save_mono(tmp_path, file_type):
stretch = DummyStretchOption()
saturation = DummySaturationOption()
a = AstroImage(stretch,saturation)
a = AstroImage()

a.set_from_file("./tests/test_images/mono_32bit.fits")
a.set_from_file("./tests/test_images/mono_32bit.fits", stretch, saturation)
file_ending = file_type[-4::].lower()
file_dir = os.path.join(tmp_path, file_type + "." + file_ending)
a.save(file_dir, file_type)
Expand Down Expand Up @@ -141,9 +133,9 @@ def test_save_mono(tmp_path, file_type):
def test_save_color(tmp_path, file_type):
stretch = DummyStretchOption()
saturation = DummySaturationOption()
a = AstroImage(stretch,saturation)
a = AstroImage()

a.set_from_file("./tests/test_images/color_32bit.fits")
a.set_from_file("./tests/test_images/color_32bit.fits", stretch, saturation)
file_ending = file_type[-4::].lower()
file_dir = os.path.join(tmp_path, file_type + "." + file_ending)
a.save(file_dir, file_type)
Expand Down Expand Up @@ -171,9 +163,9 @@ def test_save_color(tmp_path, file_type):
def test_save_stretched_mono(tmp_path, file_type):
stretch = DummyStretchOption()
saturation = DummySaturationOption()
a = AstroImage(stretch,saturation)
a = AstroImage()

a.set_from_file("./tests/test_images/mono_32bit.fits")
a.set_from_file("./tests/test_images/mono_32bit.fits", stretch, saturation)
file_ending = file_type[-4::].lower()
file_dir = os.path.join(tmp_path, file_type + "." + file_ending)
a.save_stretched(file_dir, file_type)
Expand Down Expand Up @@ -204,7 +196,7 @@ def test_save_stretched_color(tmp_path, file_type):
saturation = DummySaturationOption()
a = AstroImage(stretch,saturation)

a.set_from_file("./tests/test_images/color_32bit.fits")
a.set_from_file("./tests/test_images/color_32bit.fits", stretch, saturation)
file_ending = file_type[-4::].lower()
file_dir = os.path.join(tmp_path, file_type + "." + file_ending)
a.save_stretched(file_dir, file_type)
Expand Down

0 comments on commit 73e06a8

Please sign in to comment.