Skip to content

Fix example section in docstring of skimage.feature.graycomatrix - #7297

Merged
mkcor merged 5 commits into
scikit-image:mainfrom
FedericoWZhaw:graycomatrix-docfix#7293
Jul 19, 2024
Merged

mkcor merged 5 commits into
scikit-image:mainfrom
FedericoWZhaw:graycomatrix-docfix#7293

Conversation

@FedericoWZhaw

Copy link
Copy Markdown
Contributor

Fixed documentation according to #7293

@soupault soupault added the 📄 type: Documentation Updates, fixes and additions to documentation label Jan 16, 2024

@soupault soupault 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.

Thanks!

@mkcor

mkcor commented Jan 17, 2024

Copy link
Copy Markdown
Member

Thank you, @FedericoWZhaw! May I ask that you wrap the line at 88 characters? I'm actually surprised that pre-commit passed...

args: [--no-pycodestyle, --max-line-length=88]

@FedericoWZhaw

Copy link
Copy Markdown
Contributor Author

Thank you, @FedericoWZhaw! May I ask that you wrap the line at 88 characters? I'm actually surprised that pre-commit passed...

args: [--no-pycodestyle, --max-line-length=88]

Done

Comment thread skimage/feature/texture.py Outdated
Compute 2 GLCMs: One for a 1-pixel offset to the right, and one
for a 1-pixel offset upwards.
Compute 4 GLCMs at 1-pixel offset for 4 different angles. For example, 0 radians
refers to the pixel to the right and pi/2 to the pixel above.

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.

Thank you, @FedericoWZhaw! I would be a little more explicit; maybe:

Compute 4 GLCMs: The first one for a 1-pixel offset to the right (distance 1 and angle 0 rad); the second one for a 1-pixel offset to the first bisector (distance 1 and angle pi/4); etc.

or include it as comments in the code, when each GLCM is printed. Is it correct that pi/4 and 3*pi/4 correspond to the upward diagonal directions?

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.

"1-pixel offset" and "distance 1" seem somewhat redundant, I find the later more precise? "bisector" seems like a very technical term that's not used anywhere else in the docstring..?

@FedericoWZhaw FedericoWZhaw Jan 17, 2024 •

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.

"1-pixel offset" and "distance 1" seem somewhat redundant, I find the later more precise?

The description of the distance parameter states:
distances : array_like
List of pixel pair distance offsets.

What about:
"Compute 4 GLCMs using 1-pixel distance and 4 different angles. For example, an angle of 0 radians refers to the neighboring pixel to the right; pi/4 to the top-right diagonal neighbor (row-1,column+1); pi/2 to the pixel above, etc."

Feel free to suggest something else.

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.

Thank you both for iterating! 😃

"1-pixel offset" and "distance 1" seem somewhat redundant

Totally, but that was on purpose, to clarify the arguments, as done in the text of the gallery example: "a 1-pixel offset to the right (distance 1 and angle 0 rad)" parallels "a horizontal offset of 5 (distance=[5] and angles=[0])."

"bisector" seems like a very technical term

I must say I'm not sure how it sound to most ears... I would assume that someone using scikit-image would have some minimal computing background and, for instance, would have already heard something like "the equation of the first bisector line is y=x" (but I'm definitely not attached to this term).

I very much like @FedericoWZhaw's suggestion (minor: I would write "0 radian" instead of "0 radians"). It's just that -- and that was my original motivation for suggesting a change -- an angle refers to a direction so, e.g., an angle of 0 refers to all pixels to the right, not only to the pixel to the right; the fact that it's the pixel to the right comes from the pair (distance=1, angle=0); same with all other angles (angle pi/2 means one of the pixels straight above, and it's the pixel right above because it's at distance 1).

@mkcor

mkcor commented Feb 1, 2024

Copy link
Copy Markdown
Member

@FedericoWZhaw are you able to wrap this up? Or would you like us to take over and co-author a third/final commit? Thanks!

@FedericoWZhaw

Copy link
Copy Markdown
Contributor Author

@FedericoWZhaw are you able to wrap this up? Or would you like us to take over and co-author a third/final commit? Thanks!

Thanks for the inputs and the interesting discussion! Since it is not fully clear to me if we want to go for a variant of :

"Compute 4 GLCMs using 1-pixel distance and 4 different angles. For example, an angle of 0 radians refers to the neighboring pixel to the right; pi/4 to the top-right diagonal neighbor (row-1,column+1); pi/2 to the pixel above, etc."

or

"Compute 4 GLCMs: The first one for a 1-pixel offset to the right (distance 1 and angle 0 rad); the second one for a 1-pixel offset to the first bisector (distance 1 and angle pi/4); etc."

I think it's best you take over the final commit, that should be the fastest solution.

@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.

Thanks everyone! I'm happy with the first suggestion and committed it. Since this is a helpful but minor doc update, I don't think we need to perfect the wording here too much. 😉

@mkcor please feel welcome to merge!

@lagru
lagru requested a review from mkcor July 17, 2024 15:09
@stefanv

stefanv commented Jul 17, 2024

Copy link
Copy Markdown
Member

It would be helpful to add a sentence to explicitly state what each of the four co-occurrence matrices represent. We could do that as a follow-up PR.

Compute 2 GLCMs: One for a 1-pixel offset to the right, and one
for a 1-pixel offset upwards.
Compute 4 GLCMs using 1-pixel distance and 4 different angles. For example,
an angle of 0 radians refers to the neighboring pixel to the right;

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.

Suggested change
an angle of 0 radians refers to the neighboring pixel to the right;
an angle of 0 radian refers to the neighboring pixel to the right;

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 used "radians" intentionally since that's the convention I found on https://en.wikipedia.org/wiki/Radian. My logic is that anything that's not precisely 1 radian, should be plural. But I don't feel strongly at all about this.

I'll leave the decision to you since you are often more informed on things like this. 😉

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.

Oh, thanks for the reference (although I definitely don't consider Wikipedia to be the ultimate reference)! I have quickly searched the page but couldn't find any instance of "0 radians" nor "zero radians" though...

The logic/grammar is that the plural applies to quantities > 1 (that's what I remember learning in fourth grade, but we could probably find written references).

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'd say that's the more common form in English: 5 degrees Celcius, 2 radians, etc., even though my physics professor hated it 😅

@mkcor

mkcor commented Jul 18, 2024

Copy link
Copy Markdown
Member

I wonder what this error could be about:

[skimage_extensions] created D:\a\1\s\doc\build\html\_static\random.js with 0 possible targets

Warning, treated as error:
Summarised items should not include the current module. Replace 'skimage.color' with 'color'. [autosummary.import_cycle]
make: *** [Makefile:50: html] Error 2
make: Leaving directory 'D:/a/1/s/doc'

Apparently that's when CI builds the docs, it finishes properly with ./doc/source/user_guide/ but then, under ./doc/source/_static/, something goes wrong in random.js...

@stefanv

stefanv commented Jul 18, 2024

Copy link
Copy Markdown
Member

Re-running should bring in Sphinx 7.4.6, which may be enough!

sphinx-doc/sphinx#12589

@mkcor

mkcor commented Jul 19, 2024

Copy link
Copy Markdown
Member

Re-running should bring in Sphinx 7.4.6, which may be enough!

Apparently it didn't (I re-ran from the DevOps dashboard). I'll merge anyway, since the issue is unrelated (to this PR) and has a fix in the pipeline.

sphinx-doc/sphinx#12589

Thanks!

@mkcor
mkcor merged commit e5e1742 into scikit-image:main Jul 19, 2024
@stefanv stefanv added this to the 0.25 milestone Jul 19, 2024
@AA-Turner

Copy link
Copy Markdown

Hi @stefanv / @mkcor -- if at all possible, would you be able to test with sphinx-doc/sphinx#12626? (pip install "Sphinx @ git+https://github.com/sphinx-doc/sphinx@refs/pull/12626/merge")

Hopefully it should fix the issue here, which I believe is with autolink.

A

@mkcor

mkcor commented Jul 23, 2024

Copy link
Copy Markdown
Member

Hi @AA-Turner,

I'm getting fatal: couldn't find remote ref refs/pull/12626/merge when trying to install this version...

@AA-Turner

Copy link
Copy Markdown

Perhaps as that PR has been merged?

Try pip install Sphinx==7.4.7, which contains that commit.

A

@mkcor

mkcor commented Jul 23, 2024

Copy link
Copy Markdown
Member

Thanks, @AA-Turner, this install worked. Unfortunately, I'm getting the same error as with 7.4.5 and 7.4.6, i.e.,

Warning, treated as error:
Summarised items should not include the current module. Replace 'skimage.color' with 'color'.
[autosummary.import_cycle]
make: *** [Makefile:50: html] Error 2

@lagru lagru changed the title Fixed skimage.feature.graycomatrix example documentation. Fix example section in docstring of skimage.feature.graycomatrix Oct 5, 2024
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.

6 participants