-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add property getters for all deprecated regionprops names #6000
add property getters for all deprecated regionprops names #6000
Conversation
This is done for backwards compatibility.
skimage/measure/_regionprops.py
Outdated
if value is not None: | ||
return value | ||
else: # backwards compatibility | ||
return getattr(self, PROPS[key]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this if/else case since all old properties now have attributes via the DeprecatedProperties
mixin class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grlee77 perhaps we can keep this and just add the old property names to the dict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right but that doesn't help with attribute access. Perhaps we can add a __getattr__
to the class?
these have been missing for multiple releases without complaint so no need to pollute the API with them now
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
whoops. let me fix the conflicts here... |
…-legacy-properties
This PR was updated to remove properties for the CamelCase names per discussion with @jni. Those have not been there for multiple releases without complaint, so let's not add them back in now... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grlee77 I'm approving, but what do you think of my suggestion of using a class getattr instead? I don't love that the old names now live in a dictionary and a class at the same time...
add __setattr__ as well to disallow setting deprecated properties as well
There is already a To prevent the user from being able to do assignments to the legacy property names (e.g. calling something like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grlee77 I like this better! I've just suggested reverting a couple of strange formatting choices. I'll try pushing them up to your branch.
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Description
This is a backwards compatibility PR addressing the following issue raised on image.sc: https://forum.image.sc/t/scikit-image-regionprops-minor-axis-length-versus-axis-minor-length/59223/4. Prior to this PR, the old names were accessable via
region['old_name']
, but not via an attribute likeregion.old_name
. After this PR, both forms of access will work.I think we can drop all these old names for skimage2, but it is probably best to keep them working for now. To discourage use, these outdated names were not added to the
regionprops
function docstring and the autogenerated property docstrings have a line stating the property was deprecated.I created a mixin class with the deprecated property methods by pasting the text output of the following script into _regionprops.py.
I thought about also adding a
UserWarning
to each outdated property, but was not sure it wouldn't be more annoying than useful.Checklist
./doc/examples
(new features only)./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.