Skip to content

Conversation

@pieleric
Copy link
Member

@pieleric pieleric commented Jan 28, 2026

Remove usage of old numpy API.
Define the cython module in a separate setuptool command.
In practice, this doesn't seem to yield any performance change. Just less warnings when compiling the cython module.

Add comment to indicate the cDataArray2RGB will not raise any exception.
This would improve performance (~30% faster)... but only works on Ubunut 24.04, so for now disabled.

Copilot AI review requested due to automatic review settings January 28, 2026 09:23
@coderabbitai
Copy link

coderabbitai bot commented Jan 28, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The PR refactors the Cython build in setup.py: imports Extension from setuptools, creates an explicit extensions list containing an Extension for odemis.util.img_fast (with define_macros and include_dirs using numpy.get_include()), and updates setup() to use cythonize(extensions, language_level="3") instead of cythonize(glob(...), language_level=3). In src/odemis/util/img_fast.pyx a TODO comment was added about possible future noexcept use with nogil; the function signature and behavior are unchanged.

Sequence Diagram(s)

(omitted — conditions for diagram generation not met)

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title '[config] Modernize cython module compilation' directly summarizes the main change—modernizing the Cython build configuration with the setuptools Extension approach and updated NumPy API usage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description accurately describes the changeset, covering the removal of old numpy API usage, the separation of the cython module definition, and the added comment about cDataArray2RGB.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@setup.py`:
- Around line 120-128: The Extension in setup.py is named "img_fast" but should
use the full package path so the compiled module lands in the package namespace;
update the Extension call that currently sets the name "img_fast" to
"odemis.util.img_fast" (i.e., change the first argument of Extension) so Cython
builds the module into the odemis.util package and imports like
odemis.util.img_fast (used by img.py and img_test.py) will succeed.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Modernizes the build configuration for the Cython-based image conversion module to reduce compile-time warnings (NumPy deprecated API) and clarify exception behavior.

Changes:

  • Mark cDataArray2RGB as noexcept in the Cython implementation.
  • Switch setup.py to define a Cython Extension explicitly and set NPY_NO_DEPRECATED_API to avoid deprecated NumPy C-API usage warnings.
  • Adjust cythonize() invocation to use the defined Extension list.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/odemis/util/img_fast.pyx Declares the core nogil conversion helper as noexcept.
setup.py Introduces an explicit Extension configuration for Cython build and adds NumPy deprecation macro.

@pieleric pieleric force-pushed the config-modernize-cython-module-compilation branch 3 times, most recently from c3675fe to adf17a0 Compare January 28, 2026 10:28
Remove usage of old numpy API.
Define the cython module in a separate setuptool command.
In practice, this doesn't seem to yield any performance change. Just
less warnings when compiling the cython module.

Add comment to indicate the cDataArray2RGB will not raise any exception.
This would improve performance (~30% faster)... but only works on Ubunut 24.04, so for
now disabled.
@pieleric pieleric force-pushed the config-modernize-cython-module-compilation branch from adf17a0 to aa00a00 Compare January 30, 2026 09:29
@pieleric pieleric merged commit 13c2f5a into delmic:master Jan 30, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants