Skip to content

Commit

Permalink
Revert deprecation of lookfor
Browse files Browse the repository at this point in the history
add a basic test for it, and make sure its docstring appears in our HTMl
documentation (wasn't the case previously).
  • Loading branch information
lagru committed Feb 25, 2024
1 parent 74a6592 commit 4d338f5
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 8 deletions.
2 changes: 0 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ Version 0.26
* In ``skimage/morphology/gray.py``, remove deprecated parameters ``shift_x``
and ``shift_y`` from ``erosion`` and ``dilation``, along with associated
function ``_shift_footprint``.
* Remove deprecated `skimage.lookfor`, `skimage/_vendored/numpy_lookfor.py`,
the associated note in `LICENSE.txt` and everything else associated with it.

Other
-----
Expand Down
10 changes: 10 additions & 0 deletions doc/source/user_guide/getting_help.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ Use the ``quick search`` field in the navigation bar of the online
documentation to find mentions of keywords (segmentation,
rescaling, denoising, etc.) in the documentation.


API Discovery
-------------

We provide a ``lookfor`` function to search API functions::

import skimage as ski
ski.util.lookfor('eigenvalue')


Ask for help
------------

Expand Down
2 changes: 2 additions & 0 deletions skimage/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from .noise import random_noise
from .shape import view_as_blocks, view_as_windows
from .unique import unique_rows
from .lookfor import lookfor


__all__ = [
Expand All @@ -56,4 +57,5 @@
'invert',
'unique_rows',
'label_points',
'lookfor',
]
15 changes: 9 additions & 6 deletions skimage/util/lookfor.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import sys

from .._shared.utils import deprecate_func
from .._vendored.numpy_lookfor import lookfor as _lookfor


@deprecate_func(deprecated_version="0.23", removed_version="0.26")
def lookfor(what):
"""Do a keyword search on scikit-image docstrings.
"""Do a keyword search on scikit-image docstrings and print results.
.. warning::
This function may also print results that are not part of
scikit-image's public API.
Parameters
----------
Expand All @@ -16,12 +19,12 @@ def lookfor(what):
Examples
--------
>>> import skimage
>>> skimage.lookfor('regular_grid') # doctest: +SKIP
>>> skimage.lookfor('regular_grid')
Search results for 'regular_grid'
---------------------------------
skimage.lookfor
Do a keyword search on scikit-image docstrings.
skimage.util.regular_grid
Find `n_points` regularly spaced along `ar_shape`.
skimage.util.lookfor.lookfor
Do a keyword search on scikit-image docstrings.
"""
return _lookfor(what, sys.modules[__name__.split('.')[0]])
1 change: 1 addition & 0 deletions skimage/util/tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ python_sources = [
'test_dtype.py',
'test_invert.py',
'test_labels.py',
'test_lookfor.py',
'test_map_array.py',
'test_montage.py',
'test_random_noise.py',
Expand Down
10 changes: 10 additions & 0 deletions skimage/util/tests/test_lookfor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import skimage as ski


def test_lookfor_basic(capsys):
assert ski.lookfor is ski.util.lookfor

ski.util.lookfor("regionprops")
search_results = capsys.readouterr().out
assert "skimage.measure.regionprops" in search_results
assert "skimage.measure.regionprops_table" in search_results

0 comments on commit 4d338f5

Please sign in to comment.