From 444d6123f3c13e77f03c7dbc7b66e0dd2ff8aec6 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sat, 30 Mar 2024 10:01:31 -0700 Subject: [PATCH] Fix issues --- .rtd-environment.yml | 2 +- pyproject.toml | 1 + sunkit_image/tests/test_asda.py | 6 +++--- sunkit_image/tests/test_enhance.py | 6 +++--- sunkit_image/tests/test_granule.py | 2 +- sunkit_image/trace.py | 5 ++++- sunkit_image/utils/tests/test_utils.py | 2 +- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.rtd-environment.yml b/.rtd-environment.yml index 9f84aa4a..d620fc83 100644 --- a/.rtd-environment.yml +++ b/.rtd-environment.yml @@ -2,6 +2,6 @@ name: rtd_sunkit_image channels: - conda-forge dependencies: - - python=3.10 + - python=3.12 - pip - graphviz!=2.42.*,!=2.43.* diff --git a/pyproject.toml b/pyproject.toml index 0cf6e478..181b9657 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,7 @@ repository = "https://github.com/LM-SAL/irispy-lmsal" all = ["sunkit_image"] tests = [ "sunkit_image[all]", + 'dask', 'pytest-astropy', 'pytest-mpl', ] diff --git a/sunkit_image/tests/test_asda.py b/sunkit_image/tests/test_asda.py index 62869088..11d59f92 100644 --- a/sunkit_image/tests/test_asda.py +++ b/sunkit_image/tests/test_asda.py @@ -14,13 +14,13 @@ def test_asda_artificial(): vmax = 2.0 # rotating speed rmax = 50 # radius ratio = 0.2 # ratio of expanding speed over rotating speed - with pytest.raises(ValueError, match="Keyword 'r' must be an integer"): + with pytest.raises(TypeError, match="Keyword 'r' must be an integer"): lo = asda.Lamb_Oseen(vmax=vmax, rmax=rmax, ratio_vradial=ratio, factor=1, r=1.2) - with pytest.raises(ValueError, match="Keyword 'factor' must be an integer"): + with pytest.raises(TypeError, match="Keyword 'factor' must be an integer"): lo = asda.Lamb_Oseen(vmax=vmax, rmax=rmax, ratio_vradial=ratio, factor=1.2, r=1) - with pytest.raises(ValueError, match="Keyword 'factor' must be an integer"): + with pytest.raises(TypeError, match="Keyword 'factor' must be an integer"): lo = asda.Lamb_Oseen(vmax=vmax, rmax=rmax, ratio_vradial=ratio, factor=1.2, r=1) with pytest.warns(UserWarning, match="One of the input parameters is missing, setting both to 'None'"): diff --git a/sunkit_image/tests/test_enhance.py b/sunkit_image/tests/test_enhance.py index 1e03f14c..7ce21ef9 100644 --- a/sunkit_image/tests/test_enhance.py +++ b/sunkit_image/tests/test_enhance.py @@ -23,12 +23,12 @@ def map_test(): def test_multiscale_gaussian(map_test): # Assuming the algorithm works fine then the below two should be equal. - expect1 = enhance.mgn(map_test, [1]) - expect2 = enhance.mgn(map_test, [1, 1]) + expect1 = enhance.mgn(map_test, sigma=[1]) + expect2 = enhance.mgn(map_test, sigma=[1, 1]) assert np.allclose(expect1, expect2) result1 = np.zeros((4, 4), dtype=float) - expect3 = enhance.mgn(map_test, [1]) + expect3 = enhance.mgn(map_test, sigma=[1]) assert np.allclose(result1, expect3) # This is a dummy test. diff --git a/sunkit_image/tests/test_granule.py b/sunkit_image/tests/test_granule.py index 2f25d22c..f5ac9619 100644 --- a/sunkit_image/tests/test_granule.py +++ b/sunkit_image/tests/test_granule.py @@ -48,7 +48,7 @@ def test_get_threshold_range(): def test_get_threshold_errors(): - with pytest.raises(ValueError, match="Input data must be an instance of a np.ndarray"): + with pytest.raises(TypeError, match="Input data must be an instance of a np.ndarray"): _get_threshold([], "li") with pytest.raises(ValueError, match="Method must be one of: li, otsu, yen, mean, minimum, triangle, isodata"): _get_threshold(np.array([[1, 2], [1, 2]]), "banana") diff --git a/sunkit_image/trace.py b/sunkit_image/trace.py index a714afa9..a0c511ea 100644 --- a/sunkit_image/trace.py +++ b/sunkit_image/trace.py @@ -368,7 +368,7 @@ def _erase_loop_in_image(image, istart, jstart, width, xloop, yloop): return image -def _loop_add(lengths, xloop, yloop, iloop, loops): +def _loop_add(lengths, xloop, yloop, zloop, iloop, loops): # NOQA: ARG001 """ Adds the current loop to the output structures by interpolating the coordinates. @@ -381,6 +381,9 @@ def _loop_add(lengths, xloop, yloop, iloop, loops): The ``x`` coordinates of all the points of the loop. yloop : `numpy.ndarray` The ``y`` coordinates of all the points of the loop. + zloop : `numpy.ndarray` + The flux intensity at every point of the loop. + TODO: Unuzed variable. Determine if it is needed. iloop : `int` The current loop number. loops : `list` diff --git a/sunkit_image/utils/tests/test_utils.py b/sunkit_image/utils/tests/test_utils.py index bc84cdda..54946cb0 100644 --- a/sunkit_image/utils/tests/test_utils.py +++ b/sunkit_image/utils/tests/test_utils.py @@ -160,7 +160,7 @@ def test_points_in_poly(): def test_reform_2d(): test_data = np.asarray([[0, 0], [1, 2], [3, 4]]) - with pytest.raises(ValueError, match="Parameter 'factor' must be an integer!"): + with pytest.raises(TypeError, match="Parameter 'factor' must be an integer!"): utils.reform2d(test_data, 2.2) with pytest.raises(ValueError, match="Input array must be 2d!"): utils.reform2d(test_data[0], 2)