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
Cython style: prefer cnp.float32_t and cnp.float64_t for clarity #6303
Cython style: prefer cnp.float32_t and cnp.float64_t for clarity #6303
Conversation
replace double with cnp.float64_t
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.
Thank you @grlee77! I proposed fixes for the few cnp
imports that made the CI fail. I also suggest to cimport
numpy as cnp
instead of np
in _marching_cubes_lewiner_cy.pyx
for consistency. Otherwise everything looks good ;)
Co-authored-by: Riadh <r.fezzani@vitadx.com>
Thanks @rfezzani, I had missed uploading a second commit where I had fixed the missing imports. I have now incorporated the other suggestions here as well. |
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.
The proposed changes look good so far. However I think you missed at a few files:
- float in _hoghistogram.pyx line 59
- doubles in _texture.pyx, e.g. 12, 137, ...
- a lot of doubles in _draw.pyx, e.g. 297, 298, ...
- censure_cy.pyx
- _find_contours_cy.pyx
- ...
Are those intentional? I didn't know how to comment in those unchanged files directly, sorry. But I'm happy to push to this PR if you want.
We can potentially follow up with a PR to exclude these style-based commits from the Git Blame view here: |
I wasn't sure whether to keep "double" for the extern function definition e.g. in _unwrap_2d.pyx and _unwrap_3d.pyx but I opted for the explicit and consistent option.
cnp.float64_t *wrapped_image, | ||
cnp.float64_t *UnwrappedImage, |
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 wasn't sure whether to keep "double" for the extern function
definition e.g. in _unwrap_2d.pyx and _unwrap_3d.pyx but I opted for the
explicit and consistent option.
@grlee77 I took the liberty of converting a few left-over doubles and pushing. I hope that was alright. :) |
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.
Looks all good. Thanks @grlee77.
…kit-image#6303) * change cdef float types to cnp.float32_t replace double with cnp.float64_t * Fix missing numpy cimport statements Co-authored-by: Riadh <r.fezzani@vitadx.com> * fix missing import * more double->cnp.float64_t * np.double -> np.float64 * fix a couple remaining float->cnp.float32_t * pep8 fix * Convert a few left-over double to cnp.float64_t I wasn't sure whether to keep "double" for the extern function definition e.g. in _unwrap_2d.pyx and _unwrap_3d.pyx but I opted for the explicit and consistent option. Co-authored-by: Riadh <r.fezzani@vitadx.com> Co-authored-by: Lars Grüter <lagru@mailbox.org>
Description
closes #3496
Replaces use of
float
types for 32-bit floating point variables withcnp.float32_t
to avoid confusion with Python's float (which is 64-bit).For consistency, also replace
double
withcnp.float64_t
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
.example, to backport to v0.19.x after merging, add the following in a PR
comment:
@meeseeksdev backport to v0.19.x
run-benchmark
label. To rerun, the labelcan be removed and then added again. The benchmark output can be checked in
the "Actions" tab.