Skip to content

Change old import convention in the gallery examples#7630

Merged
mkcor merged 10 commits intoscikit-image:mainfrom
jgyasu:new-import-convention
Jan 8, 2025
Merged

Change old import convention in the gallery examples#7630
mkcor merged 10 commits intoscikit-image:mainfrom
jgyasu:new-import-convention

Conversation

@jgyasu
Copy link
Copy Markdown
Contributor

@jgyasu jgyasu commented Dec 11, 2024

Old import convention is used in the gallery examples, this PR changes it to new import convention in all the examples on the applications directory

Resolves part of #7454.

Description

Checklist

Release note

For maintainers and optionally contributors, please refer to the instructions on how to document this PR for the release notes.

...

Old import convention is used in the gallery examples, this PR changes it to new import convention in all the examples on the applications directory

Resolves: scikit-image#7454
@jgyasu
Copy link
Copy Markdown
Contributor Author

jgyasu commented Dec 11, 2024

Hi, @mkcor, based on the comments in #7454, I made the changes in all the examples of docs/examples/applications, I ran the pre-commit on my local machine and passed all the checks but now I get this pre-commit.ci failure. Can you please help?

@mkcor mkcor added the 📄 type: Documentation Updates, fixes and additions to documentation label Dec 11, 2024
@lagru
Copy link
Copy Markdown
Member

lagru commented Dec 11, 2024

but now I get this pre-commit.ci failure

That automatic check makes sure that the code is formatted properly and also checks for common errors. If you click on the job's "Details" you can see the result.

The check fails because the file doc/source/release_notes/release_dev.rst isn't formatted properly. That's a file you haven't touched, and that error was caused by us. I'll fix it in a separate PR. For now, you don't need to worry about it. 😉

@Schefflera-Arboricola
Copy link
Copy Markdown
Contributor

fixed in #7631

@jgyasu
Copy link
Copy Markdown
Contributor Author

jgyasu commented Dec 11, 2024

but now I get this pre-commit.ci failure

That automatic check makes sure that the code is formatted properly and also checks for common errors. If you click on the job's "Details" you can see the result.

The check fails because the file doc/source/release_notes/release_dev.rst isn't formatted properly. That's a file you haven't touched, and that error was caused by us. I'll fix it in a separate PR. For now, you don't need to worry about it. 😉

Ah, thank you! This makes sense now, I was confused. I chose this issue since I'm a first time contributor to Scikit-image and now that the development environment is set, I can contribute to more issues. :)

Copy link
Copy Markdown
Member

@lagru lagru left a comment

Choose a reason for hiding this comment

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

Thank you @jgyasu for working on this. It looks like you still missed a few files in the doc/examples/applications/ directory. E.g., plot_coins_segmentation.py.

You can easily find those cases by searching specifically for "skimage." (notice the dot) in the applications/ directory. For example with

grep "skimage." -R doc/examples/applications/

@jgyasu
Copy link
Copy Markdown
Contributor Author

jgyasu commented Dec 11, 2024

Thank you @jgyasu for working on this. It looks like you still missed a few files in the doc/examples/applications/ directory. E.g., plot_coins_segmentation.py.

You can easily find those cases by searching specifically for "skimage." (notice the dot) in the applications/ directory. For example with

grep "skimage." -R doc/examples/applications/

grep was really helpful, I earlier used VS Code's find and replace function and missed a few instances of the old-convention imports

@jgyasu jgyasu requested a review from lagru December 11, 2024 15:16
Copy link
Copy Markdown
Member

@mkcor mkcor left a comment

Choose a reason for hiding this comment

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

Thank you for getting started with scikit-image contributions, @jgyasu! Welcome aboard!

Comment thread doc/examples/applications/plot_coins_segmentation.py Outdated
Comment thread doc/examples/applications/plot_coins_segmentation.py Outdated
Comment thread doc/examples/applications/plot_coins_segmentation.py Outdated
Comment thread doc/examples/applications/plot_thresholding_guide.py Outdated
Comment thread doc/examples/applications/plot_morphology.py Outdated
Comment thread doc/examples/applications/plot_rank_filters.py Outdated
Comment thread doc/examples/applications/plot_thresholding_guide.py Outdated
Comment thread doc/examples/applications/plot_thresholding_guide.py Outdated
Comment thread doc/examples/applications/plot_thresholding_guide.py Outdated
Comment thread doc/examples/applications/plot_thresholding_guide.py Outdated
# The following example shows how local auto-level enhances the camara man
# picture.

from skimage.filters.rank import autolevel
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.

Here and in other places, you typically want to remove a blank line as well (either the one above or the one below) in addition to the import line. Otherwise you end up with an extra blank line.

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.

Thank you, I will fix it. I contributed to an another open-source project once and it used pre-commit and before committing, it automatically edited out all the style issues. I want to know if there exists any tool like that for Scikit-image?

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.

Hi @jgyasu,

Yes, "we recommend that you use a pre-commit hook, which runs code checkers and formatters each time you do a git commit" (Development process). It looks like you have installed it, and that it ran successfully, since CI says:

pre-commit.ci - pr — checks completed successfully

@mkcor
Copy link
Copy Markdown
Member

mkcor commented Dec 14, 2024

@jgyasu don't worry about the CI failure, it's unrelated!

Looking at the failing workflow, I can see: matplotlib-3.10.0 and AttributeError: 'QuadContourSet' object has no attribute 'collections'. A quick search gave: “MatplotlibDeprecationWarning: The collections attribute was deprecated in Matplotlib 3.8 and will be removed two minor releases later” (from https://discourse.matplotlib.org/t/collections-attribute-deprecation-in-version-3-8/24164).

I'll open an issue.

@jgyasu
Copy link
Copy Markdown
Contributor Author

jgyasu commented Dec 15, 2024

Also @mkcor is there any issue or feature that I can work on? I want a good understanding of the codebase and I'm ready to work on something even if it takes time

@mkcor
Copy link
Copy Markdown
Member

mkcor commented Dec 20, 2024

Hi @jgyasu,

I have updated your branch with the latest changes in main so CI should pass (fix was #7638).

Also @mkcor is there any issue or feature that I can work on? I want a good understanding of the codebase and I'm ready to work on something even if it takes time

Thank you for this generous offer! 🙏

Here we have a list of changes we would like to implement (independently of the skimage2 migration/transition). You are more than welcome to pick one, start/continue a discussion in an issue, and/or submit a (draft) PR. Feel free to ping us to get feedback.

For example, one goal is to make the default behavior of all our thresholding functions consistent. It's not something that will happen over a quick PR! Also, you'll have to learn how to deprecate a function or some of its parameters: See https://github.com/scikit-image/scikit-image/pull/7225/files for example.

I hope the learning curve isn't too steep. That would be a great investment for future contributions, for sure! Thanks again.

@mkcor
Copy link
Copy Markdown
Member

mkcor commented Jan 4, 2025

The CI failure for linux-cp3.13-default is reminiscent of what #7612 should have fixed:

FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/work/scikit-image/scikit-image/doc/examples/applications/plot_3d_interaction.png'

That thumbnail is generated from a Plotly figure. Although, from https://pypi.org/project/plotly/,

kaleido_deps

I'm surprised to read that "The kaleido package has no dependencies..." 🤔

Copy link
Copy Markdown
Member

@lagru lagru left a comment

Choose a reason for hiding this comment

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

I left a minor nitpick, but looks ready to merge otherwise. Thanks @jgyasu. :)

I'll trigger another CI check just to make sure that the failures are unrelated.

Comment thread doc/examples/applications/plot_rank_filters.py Outdated
@mkcor
Copy link
Copy Markdown
Member

mkcor commented Jan 6, 2025

I guess there's a change with Python 3.12, perhaps when specifying a random seed...? The failing test is

def test_reproducibility():
"""ensure cut_normalized returns the same output for the same input,
when specifying random seed

and the error only occurs with Python 3.12: "FAILED graph/tests/test_rag.py::test_reproducibility - AssertionError."

Locally, for me,

spin test skimage/graph/tests/test_rag.py::test_reproducibility

passes either on main or this feature branch (I fetched it), but I'm running Python 3.11 precisely.

Edit: Nevermind, current CI is green on main and it also runs Python 3.12 (even 3.13), so that can't be it. 😓

@lagru
Copy link
Copy Markdown
Member

lagru commented Jan 8, 2025

@mkcor I made an issue for what you describe in your comment directly above. It's #7651.

@mkcor
Copy link
Copy Markdown
Member

mkcor commented Jan 8, 2025

Thanks, @lagru. Ok, I'll approve and merge, since the CI failures are unrelated (and still mysterious).

@mkcor mkcor merged commit e514cc9 into scikit-image:main Jan 8, 2025
@stefanv stefanv added this to the 0.25.1 milestone Jan 8, 2025
@mkcor
Copy link
Copy Markdown
Member

mkcor commented Jan 8, 2025

@jgyasu congrats on getting your first scikit-image contribution merged! 🎉

@jgyasu
Copy link
Copy Markdown
Contributor Author

jgyasu commented Jan 9, 2025

@jgyasu congrats on getting your first scikit-image contribution merged! 🎉

Thank you! After my exams, I hope to contribute more 🙂

@stefanv
Copy link
Copy Markdown
Member

stefanv commented Jan 9, 2025

🙏 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📄 type: Documentation Updates, fixes and additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants