Skip to content

Harmonize doctest imports - #8234

Merged
matthew-brett merged 2 commits into
scikit-image:mainfrom
matthew-brett:explicit-doctest-imports
Jun 23, 2026
Merged

matthew-brett merged 2 commits into
scikit-image:mainfrom
matthew-brett:explicit-doctest-imports

Conversation

@matthew-brett

Copy link
Copy Markdown
Contributor

Only implicitly use own callable, and np, in doctests, import
everything else explicitly.

This implements the rule that doctests should always explicitly import stuff
that they use, except the function / method being tested, and np.

@greptile-apps

greptile-apps Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "Harmonize doctest imports" | Re-trigger Greptile

Comment on lines +476 to +478
>>> from _skimage2 import data
>>> from _skimage2.io import ImageCollection
>>> data_dir = Path(data.__file__).parent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we expose data_dir in skimage.data's dunder all. Might be easier to use here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good idea, I used that instead.

@lagru lagru left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a quick improvement if it helps you address other work.

Though in the past we decided to recommend import skimage as ski (and skimage2 equivalent) and use that in all our documentation ourselves. Probably want to tackle that eventually. So maybe we should make sure that the doctest adapter you are working on, doesn't make that more difficult?

@matthew-brett
matthew-brett force-pushed the explicit-doctest-imports branch from 8e1eb59 to ffac4c4 Compare June 23, 2026 11:22
@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "Harmonize doctest imports" | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Reviews (3): Last reviewed commit: "Add fix for warning on SimpleITK" | Re-trigger Greptile

Only implicitly use own callable, and `np`, in doctests, import
everything else explicitly.
@matthew-brett
matthew-brett force-pushed the explicit-doctest-imports branch from 7f74528 to 255904a Compare June 23, 2026 12:21
@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Reviews (4): Last reviewed commit: "Add fix for warning on SimpleITK" | Re-trigger Greptile

@matthew-brett
matthew-brett marked this pull request as ready for review June 23, 2026 12:55
@matthew-brett

Copy link
Copy Markdown
Contributor Author

Planning to merge soon - OK with y'all? (Note extra fix for SimpleITK error on main).

@matthew-brett
matthew-brett merged commit cd0a3d2 into scikit-image:main Jun 23, 2026
26 checks passed
@stefanv stefanv added this to the 0.27 milestone Jun 23, 2026
matthew-brett added a commit to matthew-brett/scikit-image that referenced this pull request Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants