PKG add scikit-image package (#866)

Co-authored-by: Chigozie Nri <chigozie@gmail.com>
This commit is contained in:
Nicolas Ollinger 2020-12-16 21:46:27 +01:00 committed by GitHub
parent 1cae0208e3
commit e79c1ab238
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 283 additions and 0 deletions

View File

@ -0,0 +1,9 @@
package:
name: cloudpickle
version: 1.5.0
source:
sha256: 820c9245cebdec7257211cbe88745101d5d6a042bca11336d78ebd4897ddbc82
url: https://files.pythonhosted.org/packages/2b/42/1a742ae7a85e8e15a60696b0519f71db8ee04839fef6007c3859184fbe71/cloudpickle-1.5.0.tar.gz
test:
imports:
- cloudpickle

View File

@ -0,0 +1,21 @@
def test_cloudpickle(selenium):
selenium.load_package("cloudpickle")
selenium.run(
r"""
import cloudpickle
squared = lambda x: x ** 2
pickled_lambda = cloudpickle.dumps(squared)
import pickle
new_squared = pickle.loads(pickled_lambda)
assert new_squared(2) == 4
CONSTANT = 42
def my_function(data: int) -> int:
return data + CONSTANT
pickled_function = cloudpickle.dumps(my_function)
depickled_function = pickle.loads(pickled_function)
assert depickled_function(43) == 85
"""
)

View File

@ -0,0 +1,16 @@
package:
name: pywavelets
version: 1.1.1
source:
sha256: 1a64b40f6acb4ffbaccce0545d7fc641744f95351f62e4c6aaa40549326008c9
url: https://files.pythonhosted.org/packages/17/6b/ef989cfb3acff2ea966c5f28a7443ccaec2ee136675dfa0366db2635f78a/PyWavelets-1.1.1.tar.gz
patches:
- patches/fft.patch
requirements:
run:
- numpy
- matplotlib
- scipy
test:
imports:
- pywt

View File

@ -0,0 +1,13 @@
This patch can be removed once scipy is updated to >= 0.18
AttributeError is raised by the absence of next_fast_len
--- PyWavelets-1.1.1/pywt/_cwt.py.old 2020-12-16 08:19:13.000000000 +0100
+++ PyWavelets-1.1.1/pywt/_cwt.py 2020-12-16 08:20:23.000000000 +0100
@@ -20,7 +20,7 @@
import scipy.fftpack
fftmodule = scipy.fftpack
next_fast_len = fftmodule.next_fast_len
- except ImportError:
+ except (AttributeError, ImportError):
fftmodule = np.fft
# provide a fallback so scipy is an optional requirement

View File

@ -0,0 +1,19 @@
def test_pywt(selenium):
selenium.load_package("pywavelets")
selenium.run(
r"""
import pywt
import numpy as np
def checkit(a,v):
assert (np.rint(a) == v).all()
x = [3, 7, 1, 1, -2, 5, 4, 6]
cA, cD = pywt.dwt(x, 'db2')
w = pywt.Wavelet('sym3')
checkit(pywt.idwt(cA, cD, 'db2'),x)
cA, cD = pywt.dwt(x, wavelet=w, mode='periodization')
checkit(pywt.idwt(cA, cD, 'sym3', 'symmetric'),[1,1,-2,5])
checkit(pywt.idwt(cA, cD, 'sym3', 'periodization'),x)
"""
)

View File

@ -0,0 +1,21 @@
package:
name: scikit-image
version: 0.15.0
source:
patches:
- patches/no-openmp.patch
- patches/unwrap.patch
- patches/preferred_plugins.patch
sha256: df111e654b47e5ea456c50553debe4c5ddd97258894c7ad3b7f2f9f10798e053
url: https://files.pythonhosted.org/packages/e0/46/ca035f5d7d3414124a3a5ef22cd2e75c0c5149042a668375f1d44eb69f8f/scikit-image-0.15.0.tar.gz
requirements:
run:
- numpy
- scipy
- matplotlib
- networkx
- pillow
- pywavelets
test:
imports:
- skimage

View File

@ -0,0 +1,11 @@
This patch is integrated upstream in scikit-image 0.18.0
--- a/setup.py 2019-04-01 22:30:11.000000000 +0000
+++ b/setup.py 2020-12-16 06:21:52.600722138 +0000
@@ -67,6 +67,7 @@
class ConditionalOpenMP(build_ext):
def can_compile_link(self):
+ return False
cc = self.compiler
fname = 'test.c'

View File

@ -0,0 +1,11 @@
--- a/skimage/io/manage_plugins.py 2019-03-19 07:17:05.000000000 +0100
+++ b/skimage/io/manage_plugins.py 2020-12-16 12:03:52.000000000 +0100
@@ -41,7 +41,7 @@
# the following preferences.
preferred_plugins = {
# Default plugins for all types (overridden by specific types below).
- 'all': ['imageio', 'pil', 'matplotlib', 'qt'],
+ 'all': ['pil', 'matplotlib'],
'imshow': ['matplotlib'],
'imshow_collection': ['matplotlib']
}

View File

@ -0,0 +1,115 @@
This patch is integrated in scikit-image v0.18.0
diff --git a/skimage/restoration/_unwrap_2d.pyx b/skimage/restoration/_unwrap_2d.pyx
index ad0dfa2280..8e2d6ee3ae 100644
--- a/skimage/restoration/_unwrap_2d.pyx
+++ b/skimage/restoration/_unwrap_2d.pyx
@@ -3,13 +3,17 @@
# cython: nonecheck=False
# cython: wraparound=False
-cdef extern from *:
- void unwrap2D(double* wrapped_image,
- double* unwrapped_image,
- unsigned char* input_mask,
- int image_width, int image_height,
- int wrap_around_x, int wrap_around_y,
- char use_seed, unsigned int seed) nogil
+
+cdef extern from "unwrap_2d_ljmu.h":
+ void unwrap2D(
+ double *wrapped_image,
+ double *UnwrappedImage,
+ unsigned char *input_mask,
+ int image_width, int image_height,
+ int wrap_around_x, int wrap_around_y,
+ char use_seed, unsigned int seed
+ ) nogil
+
def unwrap_2d(double[:, ::1] image,
unsigned char[:, ::1] mask,
diff --git a/skimage/restoration/_unwrap_3d.pyx b/skimage/restoration/_unwrap_3d.pyx
index eac50e70fb..2c9bbfbb1d 100644
--- a/skimage/restoration/_unwrap_3d.pyx
+++ b/skimage/restoration/_unwrap_3d.pyx
@@ -3,13 +3,18 @@
# cython: nonecheck=False
# cython: wraparound=False
-cdef extern from *:
- void unwrap3D(double* wrapped_volume,
- double* unwrapped_volume,
- unsigned char* input_mask,
- int image_width, int image_height, int volume_depth,
- int wrap_around_x, int wrap_around_y, int wrap_around_z,
- char use_seed, unsigned int seed) nogil
+
+cdef extern from "unwrap_3d_ljmu.h":
+ void unwrap3D(
+ double *wrapped_volume,
+ double *unwrapped_volume,
+ unsigned char *input_mask,
+ int volume_width, int volume_height, int volume_depth,
+ int wrap_around_x, int wrap_around_y, int wrap_around_z,
+ char use_seed, unsigned int seed
+ ) nogil
+
+
def unwrap_3d(double[:, :, ::1] image,
unsigned char[:, :, ::1] mask,
diff --git a/skimage/restoration/unwrap_2d_ljmu.c b/skimage/restoration/unwrap_2d_ljmu.c
index 690a8d7741..ac60a7d98e 100644
--- a/skimage/restoration/unwrap_2d_ljmu.c
+++ b/skimage/restoration/unwrap_2d_ljmu.c
@@ -39,6 +39,7 @@
#define NOMASK 0
#define MASK 1
+
typedef struct {
double mod;
int x_connectivity;
diff --git a/skimage/restoration/unwrap_2d_ljmu.h b/skimage/restoration/unwrap_2d_ljmu.h
new file mode 100644
index 0000000000..9b26d808ff
--- /dev/null
+++ b/skimage/restoration/unwrap_2d_ljmu.h
@@ -0,0 +1,9 @@
+void unwrap2D(
+ double *wrapped_image,
+ double *UnwrappedImage,
+ unsigned char *input_mask,
+ int image_width, int image_height,
+ int wrap_around_x, int wrap_around_y,
+ char use_seed, unsigned int seed
+ );
+
diff --git a/skimage/restoration/unwrap_3d_ljmu.c b/skimage/restoration/unwrap_3d_ljmu.c
index fdd9847ae8..301414cb5e 100644
--- a/skimage/restoration/unwrap_3d_ljmu.c
+++ b/skimage/restoration/unwrap_3d_ljmu.c
@@ -40,6 +40,8 @@
#define NOMASK 0
#define MASK 1
+
+
typedef struct {
double mod;
int x_connectivity;
diff --git a/skimage/restoration/unwrap_3d_ljmu.h b/skimage/restoration/unwrap_3d_ljmu.h
new file mode 100644
index 0000000000..8038639073
--- /dev/null
+++ b/skimage/restoration/unwrap_3d_ljmu.h
@@ -0,0 +1,9 @@
+void unwrap3D(
+ double *wrapped_volume,
+ double *unwrapped_volume,
+ unsigned char *input_mask,
+ int volume_width, int volume_height, int volume_depth,
+ int wrap_around_x, int wrap_around_y, int wrap_around_z,
+ char use_seed, unsigned int seed
+ );
+

View File

@ -0,0 +1,47 @@
def test_skimage(selenium):
selenium.load_package("scikit-image")
selenium.run(
r"""
import numpy as np
from skimage import data
from skimage import color
from skimage.util import view_as_blocks
# get astronaut from skimage.data in grayscale
l = color.rgb2gray(data.astronaut())
assert l.size == 262144
assert l.shape == (512,512)
# size of blocks
block_shape = (4, 4)
# see astronaut as a matrix of blocks (of shape block_shape)
view = view_as_blocks(l, block_shape)
assert view.shape == (128, 128, 4, 4)
from skimage.filters import threshold_otsu
to=threshold_otsu(l)
assert to.hex() == '0x1.8e00000000000p-2'
from skimage.data import astronaut
from skimage.color import rgb2gray
from skimage.filters import sobel
from skimage.segmentation import felzenszwalb, slic, quickshift, watershed
from skimage.segmentation import mark_boundaries
from skimage.util import img_as_float
img = img_as_float(astronaut()[::2, ::2])
segments_fz = felzenszwalb(img, scale=100, sigma=0.5, min_size=50)
segments_slic = slic(img, n_segments=250, compactness=10, sigma=1)
segments_quick = quickshift(img, kernel_size=3, max_dist=6, ratio=0.5)
gradient = sobel(rgb2gray(img))
segments_watershed = watershed(gradient, markers=250, compactness=0.001)
assert len(np.unique(segments_fz)) == 194
assert len(np.unique(segments_slic)) == 190
assert len(np.unique(segments_quick)) == 695
"""
)