Commit c6d20700 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

add docstring for unit tests

parent 0e5089b8
Pipeline #1471 passed with stage
in 0 seconds
...@@ -9,7 +9,19 @@ from csst_proto import flip_multiple_images_jl, flip_multiple_images_mp ...@@ -9,7 +9,19 @@ from csst_proto import flip_multiple_images_jl, flip_multiple_images_mp
class FlipImageTestCase(unittest.TestCase): class FlipImageTestCase(unittest.TestCase):
def test_flip_image(self): def test_flip_image(self):
"""test flip image""" """
Aim
---
Test `flip_image` function with package data.
Criteria
--------
The flipped image is consistent with answer.
Details
-------
The input image is in package data.
"""
self.assertTrue( self.assertTrue(
np.all(flip_image(read_default_image()) == np.array([[4, 3], [2, 1]])) np.all(flip_image(read_default_image()) == np.array([[4, 3], [2, 1]]))
) )
...@@ -19,7 +31,19 @@ class FlipImageTestCase(unittest.TestCase): ...@@ -19,7 +31,19 @@ class FlipImageTestCase(unittest.TestCase):
flip_image(np.array([1, 2, 3, 4])) flip_image(np.array([1, 2, 3, 4]))
def test_flip_image_on_server(self): def test_flip_image_on_server(self):
"""test flip image on server""" """
Aim
---
Test `flip_image` function with server data.
Criteria
--------
The flipped image is consistent with answer at 1e-6 level.
Details
-------
This is the same case with `test_flip_image` but the data is on server.
"""
image_input = np.loadtxt( image_input = np.loadtxt(
os.path.join( os.path.join(
os.environ["UNIT_TEST_DATA_ROOT"], os.environ["UNIT_TEST_DATA_ROOT"],
...@@ -43,7 +67,19 @@ class FlipImageTestCase(unittest.TestCase): ...@@ -43,7 +67,19 @@ class FlipImageTestCase(unittest.TestCase):
) )
def test_flip_multiple_images_mp(self): def test_flip_multiple_images_mp(self):
"""test flip multiple images with multiprocessing""" """
Aim
---
Test `flip_multiple_images_mp` function with package data.
Criteria
--------
The flipped image equals answer.
Details
-------
The input image is in package data.
"""
n_jobs = 10 n_jobs = 10
imgs = [read_default_image() for _ in range(n_jobs)] imgs = [read_default_image() for _ in range(n_jobs)]
flipped_imgs = flip_multiple_images_mp(imgs, n_jobs) flipped_imgs = flip_multiple_images_mp(imgs, n_jobs)
...@@ -51,7 +87,19 @@ class FlipImageTestCase(unittest.TestCase): ...@@ -51,7 +87,19 @@ class FlipImageTestCase(unittest.TestCase):
self.assertTrue(np.all(flipped_imgs[i_job] == np.array([[4, 3], [2, 1]]))) self.assertTrue(np.all(flipped_imgs[i_job] == np.array([[4, 3], [2, 1]])))
def test_flip_multiple_images_jl(self): def test_flip_multiple_images_jl(self):
"""test flip multiple images with joblib""" """
Aim
---
Test `flip_multiple_images_jl` function with package data.
Criteria
--------
The flipped image equals answer.
Details
-------
The input image is in package data.
"""
n_jobs = 10 n_jobs = 10
imgs = [read_default_image() for _ in range(n_jobs)] imgs = [read_default_image() for _ in range(n_jobs)]
flipped_imgs = flip_multiple_images_jl(imgs, n_jobs) flipped_imgs = flip_multiple_images_jl(imgs, n_jobs)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment