Skip to content

rename img_as_* to rescale_to_* - #6318

Draft
grlee77 wants to merge 5 commits into
scikit-image:pre-megamove-integrationfrom
grlee77:rescale_as_float
Draft

grlee77 wants to merge 5 commits into
scikit-image:pre-megamove-integrationfrom
grlee77:rescale_as_float

Conversation

@grlee77

@grlee77 grlee77 commented Apr 5, 2022

Copy link
Copy Markdown
Contributor

Description

This PR implements a prior suggestion to rename img_as_float to rescale_to_float, etc. This is done primarily to make it clearer that these function rescale the range of the inputs. This change has been discussed a few of times in the past (#1234, #3009 (comment) and #5439)

At the moment, img_as_float, img_as_float32 and img_as_float64 are also still here, but no longer rescale the range. We can likely just go ahead and remove this as astype can already be used to convert dtypes without scaling.

Checklist

  • Docstrings for all functions
  • Gallery example in ./doc/examples (new features only)
  • Benchmark in ./benchmarks, if your changes aren't covered by an
    existing benchmark
  • Unit tests
  • Clean style in the spirit of PEP8
  • Descriptive commit messages (see below)

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.
  • There is a bot to help automate backporting a PR to an older branch. For
    example, to backport to v0.19.x after merging, add the following in a PR
    comment: @meeseeksdev backport to v0.19.x
  • To run benchmarks on a PR, add the run-benchmark label. To rerun, the label
    can be removed and then added again. The benchmark output can be checked in
    the "Actions" tab.

update docs and gallery to use rescale_to_*
@grlee77 grlee77 added the 📜 type: API Involves API change(s) label Apr 5, 2022
@grlee77 grlee77 added this to the skimage2 milestone Apr 5, 2022
@pep8speaks

pep8speaks commented Apr 5, 2022 •

Copy link
Copy Markdown

Hello @grlee77! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 198:1: E402 module level import not at top of file

Line 99:1: E402 module level import not at top of file

Comment last updated at 2022-04-05 17:52:16 UTC

@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 @grlee77. I'm not through yet but I have a few comments.

Also there still is a lonely img_as_float in doc/CONTRIBUTING.rst under "Stylistic Guidelines".

Comment thread skimage/util/dtype.py Outdated
return _img_as_float(image, force_copy, preserve_range=False)


def _img_as_float(image, force_copy=False, *, preserve_range=True, dtype=None):

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 _rescale_to_float would be the clearer and more consistent name.

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.

_img_as_float has been removed and _convert is just used directy now.

Comment thread skimage/util/dtype.py Outdated
Comment on lines +468 to +470
return _convert(image, np.floating, force_copy)
return _img_as_float(image, force_copy, preserve_range=False)

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 don't understand this change. Why did you wrap _convert with the new function _img_as_float?

Also one could argue that it would be more explicit to use dtype=np.floating here and not rely on _img_as_float's implicit behavior for dtype=None. Or rather use np.floating as the default in the function signature?

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.

not sure why I did that, will take a look again.

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.

_img_as_float has been removed and _convert is just used directy now.

@grlee77

grlee77 commented Apr 15, 2022

Copy link
Copy Markdown
Contributor Author

Per #1234 (comment), we need to decide on rescale_to_* vs. convert_to_*. I prefer rescale_to because it is clearer that it rescales the range of the input and is not just a dtype conversion.

Also, we do already have a private convert_to_float utility that is used in a few places internally, although that one has a preserve_range kwarg.

@grlee77

grlee77 commented Apr 15, 2022

Copy link
Copy Markdown
Contributor Author

We will need to hold off on merging this PR until after we branch 1.0

@lagru
lagru marked this pull request as draft April 16, 2022 16:02
@github-actions

This comment was marked as outdated.

@github-actions github-actions Bot added the 😴 Dormant No recent activity label Dec 12, 2022
@lagru

lagru commented Aug 8, 2024 •

Copy link
Copy Markdown
Member

We will need to hold off on merging this PR until after we branch 1.0

Why? I'm assuming that 1.0 was the former "breaking API" milestone. This seems like a deprecation that doesn't require a major version or namespace change.

If this was decided on I would like to pick it up again. I'm also +1 on rescale_to over convert_to.

@lagru lagru removed the 😴 Dormant No recent activity label Aug 8, 2024
@stefanv stefanv added this to skimage2 Mar 1, 2025
@stefanv stefanv moved this to To Do in skimage2 Mar 1, 2025
@matthew-brett
matthew-brett changed the base branch from main to pre-megamove-integration June 19, 2026 15:23
@matthew-brett

Copy link
Copy Markdown
Contributor

We have changed the base branch for this PR from the main branch to the pre-megamove-integration branch.

Summary - what this means for your PR

You can continue to work on your PR, now based on pre-megamove-integration. You should update your branch to the current state of pre-megamove-integration (this is what the Github "Update branch" button does). Please do not merge the scikit-image main branch into your PR branch.

Once we've merged your PR into the pre-megamove-integration branch, we'll update your changes for Megamove, and merge into the main branch.

In addition - our automated script detected that your branch had merge conflicts with the pre-Megamove branch. Please make sure to merge in the pre-megamove-integration branch, and resolve the merge conflicts in the way that you want.

Read on for the Megamove rationale, and more detailed instructions.

Details

Rationale

We've changed the base branch to make it easier and smoother to continue to work on your PR, while we work through a rather large change in the directory structure of the repository - a change that we have called Megamove.

See the Megamove explanation issue for more detail.

Changing the base branch means you do not see merge conflicts related to the Megamove change, and can continue to work with the repository in its original state, without worrying about porting those changes across to the new post-Megamove structure.

As you'll see in the linked issue, you can continue to work on your PR as before, and you can continue to use the Github GUI to "Update branch" - this updates from the new pre-megamove-integration branch. However, there is one caveat: please, do not try and merge the scikit-image main branch into this one, but instead, keep track of the pre-megamove-integration branch. The issue explains more.

To emphasize again, do not try and merge the scikit-image main branch. You will get Megamove related merge conflicts that are rather tricky to resolve correctly.

When we've approved your PR, we'll merge into the pre-megamove-integration branch, and then process it so we can merge it into the main branch. We'll let you know when we've merged your PR changes into main.

Any questions, please reply here.

@stefanv stefanv added 🥾 Path to skimage2 A step towards the new "API 2.0" and removed ✋ Wait for skimage2 labels Nov 3, 2026

This branch has not been deployed

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

Labels

🥾 Path to skimage2 A step towards the new "API 2.0" 📜 type: API Involves API change(s)

Projects

Status: To Do

Development

Successfully merging this pull request may close these issues.

6 participants