Repository: astropy/astroscrappy (language: python)

Issue:
Update cython version
The pinned version of Cython was a bit old. 
Related to #55.
Avoid deprecation warning with np.bool
`np.bool` is deprecated since Numpy 1.20


Discussion / hints:

Fix patch:
diff --git a/MANIFEST.in b/MANIFEST.in
index b964c2d..8dc53b4 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -5,7 +5,9 @@ include LICENSE.rst
 include pyproject.toml
 include astroscrappy/tests/coveragerc
 
-recursive-include astroscrappy *.pyx *.c *.pxd *.h
+recursive-exclude . astroscrappy.c
+recursive-exclude astroscrappy/utils image_utils.c median_utils.c
+recursive-include astroscrappy *.pyx *.pxd
 recursive-include docs *
 recursive-include licenses *
 recursive-include scripts *
diff --git a/astroscrappy/astroscrappy.pyx b/astroscrappy/astroscrappy.pyx
index d3d2fe5..b41a1a0 100644
--- a/astroscrappy/astroscrappy.pyx
+++ b/astroscrappy/astroscrappy.pyx
@@ -1,6 +1,5 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
-# cython: boundscheck=False, nonecheck=False, wraparound=False
-# cython: language_level=3, cdivision=True
+# cython: boundscheck=False, nonecheck=False, wraparound=False, language_level=3, cdivision=True
 """
 Name : astroscrappy: The Speedy Cosmic Ray Annihilation Package in Python
 Author : Curtis McCully
@@ -417,7 +416,7 @@ def detect_cosmics(indat, inmask=None, inbkg=None, invar=None, float sigclip=4.5
 
     cleanarr /= gain
 
-    return crmask.astype(np.bool), cleanarr
+    return crmask.astype(np.bool_), cleanarr
 
 
 def update_mask(np.ndarray[np.float32_t, ndim=2, mode='c', cast=True] data,
diff --git a/astroscrappy/utils/image_utils.pyx b/astroscrappy/utils/image_utils.pyx
index 44f7eda..1fb1232 100644
--- a/astroscrappy/utils/image_utils.pyx
+++ b/astroscrappy/utils/image_utils.pyx
@@ -1,6 +1,5 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
-# cython: boundscheck=False, nonecheck=False, wraparound=False
-# cython: language_level=3, cdivision=True
+# cython: boundscheck=False, nonecheck=False, wraparound=False, language_level=3, cdivision=True
 """
 Name : image_utils
 Author : Curtis McCully
@@ -210,7 +209,7 @@ def dilate3(np.ndarray[np.uint8_t, ndim=2, mode='c', cast=True] dgrow):
 
     # Allocate the output array here so that Python tracks the memory and will
     # free the memory when we are finished with the output array.
-    output = np.zeros((ny, nx), dtype=np.bool)
+    output = np.zeros((ny, nx), dtype=np.bool_)
 
     cdef uint8_t * dgrowptr = < uint8_t * > np.PyArray_DATA(dgrow)
     cdef uint8_t * outdgrowptr = < uint8_t * > np.PyArray_DATA(output)
@@ -256,7 +255,7 @@ def dilate5(np.ndarray[np.uint8_t, ndim=2, mode='c', cast=True] ddilate,
 
     # Allocate the output array here so that Python tracks the memory and will
     # free the memory when we are finished with the output array.
-    output = np.zeros((ny, nx), dtype=np.bool)
+    output = np.zeros((ny, nx), dtype=bool)
 
     cdef uint8_t * ddilateptr = < uint8_t * > np.PyArray_DATA(ddilate)
     cdef uint8_t * outddilateptr = < uint8_t * > np.PyArray_DATA(output)
diff --git a/astroscrappy/utils/median_utils.pyx b/astroscrappy/utils/median_utils.pyx
index 72d7e04..58e51de 100644
--- a/astroscrappy/utils/median_utils.pyx
+++ b/astroscrappy/utils/median_utils.pyx
@@ -1,6 +1,5 @@
 # Licensed under a 3-clause BSD style license - see LICENSE.rst
-# cython: boundscheck=False, nonecheck=False, wraparound=False
-# cython: language_level=3, cdivision=True
+# cython: boundscheck=False, nonecheck=False, wraparound=False, language_level=3, cdivision=True
 """
 Name : median_utils
 Author : Curtis McCully
diff --git a/pyproject.toml b/pyproject.toml
index 6c989ab..8002596 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -5,6 +5,6 @@ requires = ["setuptools",
             "wheel",
             "extension-helpers",
             "oldest-supported-numpy",
-            "cython==0.29.14"]
+            "Cython>=0.29.21,<3.0"]
 
 build-backend = 'setuptools.build_meta'


Test patch:
diff --git a/astroscrappy/tests/fake_data.py b/astroscrappy/tests/fake_data.py
index afc8e04..cf641a4 100644
--- a/astroscrappy/tests/fake_data.py
+++ b/astroscrappy/tests/fake_data.py
@@ -60,6 +60,6 @@ def make_fake_data():
     imdata = imdata.astype('f4')
 
     # Make a mask where the detected cosmic rays should be
-    crmask = np.zeros((1001, 1001), dtype=np.bool)
+    crmask = np.zeros((1001, 1001), dtype=bool)
     crmask[cr_y, cr_x] = True
     return imdata, crmask
diff --git a/astroscrappy/tests/test_utils.py b/astroscrappy/tests/test_utils.py
index fafc511..e3057c0 100644
--- a/astroscrappy/tests/test_utils.py
+++ b/astroscrappy/tests/test_utils.py
@@ -139,7 +139,7 @@ def test_sepmedfilt9():
 
 def test_dilate5():
     # Put 5% of the pixels into a mask
-    a = np.zeros((1001, 1001), dtype=np.bool)
+    a = np.zeros((1001, 1001), dtype=bool)
     a[np.random.random((1001, 1001)) < 0.05] = True
     kernel = np.ones((5, 5))
     kernel[0, 0] = 0
@@ -147,7 +147,7 @@ def test_dilate5():
     kernel[4, 0] = 0
     kernel[4, 4] = 0
     # Make a zero padded array for the numpy version to operate
-    paddeda = np.zeros((1005, 1005), dtype=np.bool)
+    paddeda = np.zeros((1005, 1005), dtype=bool)
     paddeda[2:-2, 2:-2] = a[:, :]
     npdilate = binary_dilation(np.ascontiguousarray(paddeda),
                                structure=kernel, iterations=2)
@@ -158,7 +158,7 @@ def test_dilate5():
 
 def test_dilate3():
     # Put 5% of the pixels into a mask
-    a = np.zeros((1001, 1001), dtype=np.bool)
+    a = np.zeros((1001, 1001), dtype=bool)
     a[np.random.random((1001, 1001)) < 0.05] = True
     kernel = np.ones((3, 3))
     npgrow = binary_dilation(np.ascontiguousarray(a),