Repository: scikit-image/scikit-image

Issue:
should data_dir.load be a public function
https://github.com/scikit-image/scikit-image/blob/822ad3edddaba91e43dfc1adf2fe4339dbefb97b/skimage/data/__init__.py#L23

it seems like it is mostly an internal function. In migrating to pooch, ~~I would like to really add some hacks that make it really only for our internal data~~
https://github.com/scikit-image/scikit-image/pull/3945



Discussion:
I think you're right: this should be deprecated. @stefanv?
On Mon, 03 Jun 2019 02:27:50 -0700, Juan Nunez-Iglesias wrote:
> I think you're right: this should be deprecated. @stefanv?

Yes, should be private.


Resolving patch:
diff --git a/skimage/data/__init__.py b/skimage/data/__init__.py
--- a/skimage/data/__init__.py
+++ b/skimage/data/__init__.py
@@ -9,8 +9,8 @@
 import os as _os
 
 import numpy as _np
+from warnings import warn
 
-from .._shared._warnings import expected_warnings, warn
 from ..util.dtype import img_as_bool
 from ._binary_blobs import binary_blobs
 from ._detect import lbp_frontal_face_cascade_filename
@@ -52,6 +52,31 @@
 def load(f, as_gray=False):
     """Load an image file located in the data directory.
 
+    Parameters
+    ----------
+    f : string
+        File name.
+    as_gray : bool, optional
+        Whether to convert the image to grayscale.
+
+    Returns
+    -------
+    img : ndarray
+        Image loaded from ``skimage.data_dir``.
+
+    Note
+    ----
+    This functions is deprecated and will be removed in 0.18.
+    """
+    warn('This function is deprecated and will be removed in 0.18. '
+         'Use `skimage.io.load` or `imageio.imread` directly.',
+         stacklevel=2)
+    return _load(f, as_gray=as_gray)
+
+
+def _load(f, as_gray=False):
+    """Load an image file located in the data directory.
+
     Parameters
     ----------
     f : string
@@ -80,7 +105,7 @@ def camera():
     camera : (512, 512) uint8 ndarray
         Camera image.
     """
-    return load("camera.png")
+    return _load("camera.png")
 
 
 def astronaut():
@@ -102,7 +127,7 @@ def astronaut():
         Astronaut image.
     """
 
-    return load("astronaut.png")
+    return _load("astronaut.png")
 
 
 def brick():
@@ -168,7 +193,7 @@ def brick():
     >>> brick = rotate(brick, -90)
     >>> imwrite('brick.png', img_as_ubyte(rgb2gray(brick)))
     """
-    return load("brick.png", as_gray=True)
+    return _load("brick.png", as_gray=True)
 
 
 def grass():
@@ -216,7 +241,7 @@ def grass():
     >>> grass = skimage.img_as_ubyte(skimage.color.rgb2gray(grass_orig[:512, :512]))
     >>> imageio.imwrite('grass.png', grass)
     """
-    return load("grass.png", as_gray=True)
+    return _load("grass.png", as_gray=True)
 
 
 def rough_wall():
@@ -287,7 +312,7 @@ def gravel():
     >>> gravel = skimage.img_as_ubyte(skimage.color.rgb2gray(gravel[:512, :512]))
     >>> imageio.imwrite('gravel.png', gravel)
     """
-    return load("gravel.png", as_gray=True)
+    return _load("gravel.png", as_gray=True)
 
 
 def text():
@@ -306,7 +331,7 @@ def text():
         Text image.
     """
 
-    return load("text.png")
+    return _load("text.png")
 
 
 def checkerboard():
@@ -321,7 +346,7 @@ def checkerboard():
     checkerboard : (200, 200) uint8 ndarray
         Checkerboard image.
     """
-    return load("chessboard_GRAY.png")
+    return _load("chessboard_GRAY.png")
 
 
 def cell():
@@ -352,7 +377,7 @@ def cell():
            for spherical objects in quantitative phase imaging." Optics Express
            26(8): 10729-10743 (2018). :DOI:`10.1364/OE.26.010729`
     """
-    return load('cell.png')
+    return _load('cell.png')
 
 
 def coins():
@@ -377,7 +402,7 @@ def coins():
     coins : (303, 384) uint8 ndarray
         Coins image.
     """
-    return load("coins.png")
+    return _load("coins.png")
 
 
 def logo():
@@ -388,7 +413,7 @@ def logo():
     logo : (500, 500, 4) uint8 ndarray
         Logo image.
     """
-    return load("logo.png")
+    return _load("logo.png")
 
 
 def microaneurysms():
@@ -416,7 +441,7 @@ def microaneurysms():
            2013.
            :DOI:`10.1155/2013/154860`
     """
-    return load("microaneurysms.png")
+    return _load("microaneurysms.png")
 
 
 def moon():
@@ -430,7 +455,7 @@ def moon():
     moon : (512, 512) uint8 ndarray
         Moon image.
     """
-    return load("moon.png")
+    return _load("moon.png")
 
 
 def page():
@@ -444,7 +469,7 @@ def page():
     page : (191, 384) uint8 ndarray
         Page image.
     """
-    return load("page.png")
+    return _load("page.png")
 
 
 def horse():
@@ -460,7 +485,7 @@ def horse():
     horse : (328, 400) bool ndarray
         Horse image.
     """
-    return img_as_bool(load("horse.png", as_gray=True))
+    return img_as_bool(_load("horse.png", as_gray=True))
 
 
 def clock():
@@ -477,7 +502,7 @@ def clock():
     clock : (300, 400) uint8 ndarray
         Clock image.
     """
-    return load("clock_motion.png")
+    return _load("clock_motion.png")
 
 
 def immunohistochemistry():
@@ -497,7 +522,7 @@ def immunohistochemistry():
     immunohistochemistry : (512, 512, 3) uint8 ndarray
         Immunohistochemistry image.
     """
-    return load("ihc.png")
+    return _load("ihc.png")
 
 
 def chelsea():
@@ -515,7 +540,7 @@ def chelsea():
     chelsea : (300, 451, 3) uint8 ndarray
         Chelsea image.
     """
-    return load("chelsea.png")
+    return _load("chelsea.png")
 
 
 def coffee():
@@ -534,7 +559,7 @@ def coffee():
     coffee : (400, 600, 3) uint8 ndarray
         Coffee image.
     """
-    return load("coffee.png")
+    return _load("coffee.png")
 
 
 def hubble_deep_field():
@@ -558,7 +583,7 @@ def hubble_deep_field():
     hubble_deep_field : (872, 1000, 3) uint8 ndarray
         Hubble deep field image.
     """
-    return load("hubble_deep_field.jpg")
+    return _load("hubble_deep_field.jpg")
 
 
 def retina():
@@ -585,7 +610,7 @@ def retina():
     retina : (1411, 1411, 3) uint8 ndarray
         Retina image in RGB.
     """
-    return load("retina.jpg")
+    return _load("retina.jpg")
 
 
 def shepp_logan_phantom():
@@ -602,7 +627,7 @@ def shepp_logan_phantom():
     phantom: (400, 400) float64 image
         Image of the Shepp-Logan phantom in grayscale.
     """
-    return load("phantom.png", as_gray=True)
+    return _load("phantom.png", as_gray=True)
 
 
 def colorwheel():
@@ -613,7 +638,7 @@ def colorwheel():
     colorwheel: (370, 371, 3) uint8 image
         A colorwheel.
     """
-    return load("color.png")
+    return _load("color.png")
 
 
 def rocket():
@@ -636,7 +661,7 @@ def rocket():
     rocket : (427, 640, 3) uint8 ndarray
         Rocket image.
     """
-    return load("rocket.jpg")
+    return _load("rocket.jpg")
 
 
 def stereo_motorcycle():
@@ -693,8 +718,8 @@ def stereo_motorcycle():
     .. [2] http://vision.middlebury.edu/stereo/data/scenes2014/
 
     """
-    return (load("motorcycle_left.png"),
-            load("motorcycle_right.png"),
+    return (_load("motorcycle_left.png"),
+            _load("motorcycle_right.png"),
             _np.load(_os.path.join(data_dir, "motorcycle_disp.npz"))["arr_0"])
 
 


Test patch: