Skip to content

Review python dependencies#489

Merged
Gab-D-G merged 5 commits intomasterfrom
review_python_dependencies
Mar 25, 2026
Merged

Review python dependencies#489
Gab-D-G merged 5 commits intomasterfrom
review_python_dependencies

Conversation

@Gab-D-G
Copy link
Copy Markdown
Collaborator

@Gab-D-G Gab-D-G commented Mar 25, 2026

Summary by CodeRabbit

  • Chores

    • Removed an external imaging dependency and bundled needed image/colormap utilities locally.
    • Updated packaging to restrict supported Python versions (<3.13).
    • Cleaned up unused imports and removed redundant local imports in visualization/preprocessing modules.
  • New Features

    • Added a built-in colormap implementation for consistent plotting.
  • Bug Fixes

    • Replaced deprecated pandas append usage with a modern concat-based approach.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 47a09423-3918-42e5-a8d1-a5e85ee61445

📥 Commits

Reviewing files that changed from the base of the PR and between 5011532 and d0c52bd.

📒 Files selected for processing (1)
  • setup.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • setup.py

📝 Walkthrough

Walkthrough

Removed Nilearn usage by adding local implementations for the cold_hot colormap and _smooth_array, updated plotting calls to use the local colormap, replaced deprecated pandas append calls, removed local Nilearn imports, and removed nilearn from dependency manifests and setup.py; Python bounds tightened to <3.13.

Changes

Cohort / File(s) Summary
Colormap & plotting updates
rabies/visualization.py, rabies/analysis_pkg/diagnosis_pkg/analysis_QC.py, rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py
Added a local cold_hot LinearSegmentedColormap in visualization.py; replaced string 'cold_hot' with the cold_hot object in plotting calls and adjusted imports to import cold_hot.
Smooth-array migration
rabies/confound_correction_pkg/utils.py
Introduced a module-level _smooth_array(...) function (local reimplementation of Nilearn's behavior) and updated smooth_image to use it.
Pandas API update
rabies/confound_correction_pkg/mod_ICA_AROMA/classification_plots.py
Replaced deprecated DataFrame.append(..., ignore_index=True) with pd.concat([...], ignore_index=True) for appending rows.
Import cleanup
rabies/preprocess_pkg/preprocess_visual_QC.py
Removed local imports of nilearn.plotting from template_info and template_masking.
Dependency / packaging
rabies_environment.dev.yml, rabies_environment.yml, setup.py
Removed nilearn from Conda environment files and install_requires; adjusted REQUIRES_PYTHON to >=3.9.0, <3.13 in setup.py.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Documentation #429: Edits the same scan_diagnosis plotting logic in diagnosis_functions.py; likely overlaps with colormap/plot changes.

Suggested reviewers

  • gdevenyi

Poem

🐇 I swapped the maps and smoothed the land,
With colored trails drawn by my pawing hand.
No Nilearn drums, just local art and care—
A tiny rabbit's patch to brighten the air. 🎨🐾

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Review python dependencies' is vague and generic, using non-descriptive language that doesn't clearly convey the specific changes made in the changeset. Use a more specific title that describes the primary change, such as 'Remove nilearn dependency and add cold_hot colormap implementation' or 'Refactor visualization to remove nilearn dependency'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch review_python_dependencies

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
Copy Markdown
Contributor

@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

🧹 Nitpick comments (2)
rabies/confound_correction_pkg/utils.py (1)

766-772: Add stacklevel parameter to warnings.warn.

The warning will point to the wrong location in the call stack without specifying stacklevel. Setting stacklevel=2 ensures the warning points to the caller of _smooth_array rather than this internal function.

📝 Suggested fix
     if isinstance(fwhm, (int, float)) and (fwhm == 0.0):
-        import warnings
-        warnings.warn("The parameter 'fwhm' for smoothing is specified "
-                      "as {0}. Setting it to None "
-                      "(no smoothing will be performed)"
-                      .format(fwhm))
+        import warnings
+        warnings.warn("The parameter 'fwhm' for smoothing is specified "
+                      "as {0}. Setting it to None "
+                      "(no smoothing will be performed)"
+                      .format(fwhm), stacklevel=2)
         fwhm = None
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@rabies/confound_correction_pkg/utils.py` around lines 766 - 772, The warning
emitted when fwhm == 0.0 inside _smooth_array uses warnings.warn without a
stacklevel, so the traceback points to this internal helper; update the
warnings.warn call that currently warns about fwhm to include stacklevel=2
(e.g., warnings.warn(..., stacklevel=2)) so the warning points to the caller of
_smooth_array rather than the utility function.
setup.py (1)

144-145: Outdated Python classifiers.

The classifiers still reference Python 3.6, which contradicts REQUIRES_PYTHON = '>=3.9.0, <=3.13'. Consider updating the classifiers to reflect the actual supported Python versions.

📝 Suggested fix
         'Programming Language :: Python',
         'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.6',
+        'Programming Language :: Python :: 3.9',
+        'Programming Language :: Python :: 3.10',
+        'Programming Language :: Python :: 3.11',
+        'Programming Language :: Python :: 3.12',
         'Programming Language :: Python :: Implementation :: CPython',
         'Programming Language :: Python :: Implementation :: PyPy'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@setup.py` around lines 144 - 145, Update the Python trove classifiers in
setup.py to match REQUIRES_PYTHON (REQUIRES_PYTHON = '>=3.9.0, <=3.13'): remove
the obsolete 'Programming Language :: Python :: 3.6' entry and add/update
entries for 3.9 through 3.13 (e.g., 'Programming Language :: Python :: 3.9',
'... :: 3.10', etc.), leaving implementation classifier 'Programming Language ::
Python :: Implementation :: CPython' as appropriate so the classifiers
accurately reflect supported versions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@rabies/confound_correction_pkg/utils.py`:
- Around line 783-785: The code raises NotImplementedError when fwhm == 'fast'
but then contains unreachable dead code calling an undefined helper
_fast_smooth_array; remove the unreachable statement `arr =
_fast_smooth_array(arr)` from the branch handling `if isinstance(fwhm, str) and
(fwhm == 'fast')` (referencing the fwhm check and the undefined symbol
_fast_smooth_array) and scan the module for any other references to
_fast_smooth_array to ensure there are no remaining undefined calls or imports.

---

Nitpick comments:
In `@rabies/confound_correction_pkg/utils.py`:
- Around line 766-772: The warning emitted when fwhm == 0.0 inside _smooth_array
uses warnings.warn without a stacklevel, so the traceback points to this
internal helper; update the warnings.warn call that currently warns about fwhm
to include stacklevel=2 (e.g., warnings.warn(..., stacklevel=2)) so the warning
points to the caller of _smooth_array rather than the utility function.

In `@setup.py`:
- Around line 144-145: Update the Python trove classifiers in setup.py to match
REQUIRES_PYTHON (REQUIRES_PYTHON = '>=3.9.0, <=3.13'): remove the obsolete
'Programming Language :: Python :: 3.6' entry and add/update entries for 3.9
through 3.13 (e.g., 'Programming Language :: Python :: 3.9', '... :: 3.10',
etc.), leaving implementation classifier 'Programming Language :: Python ::
Implementation :: CPython' as appropriate so the classifiers accurately reflect
supported versions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3ed524fa-936c-4b58-89dc-943d94a8b5d1

📥 Commits

Reviewing files that changed from the base of the PR and between f6d4ddd and 5011532.

📒 Files selected for processing (9)
  • rabies/analysis_pkg/diagnosis_pkg/analysis_QC.py
  • rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py
  • rabies/confound_correction_pkg/mod_ICA_AROMA/classification_plots.py
  • rabies/confound_correction_pkg/utils.py
  • rabies/preprocess_pkg/preprocess_visual_QC.py
  • rabies/visualization.py
  • rabies_environment.dev.yml
  • rabies_environment.yml
  • setup.py
💤 Files with no reviewable changes (3)
  • rabies_environment.yml
  • rabies/preprocess_pkg/preprocess_visual_QC.py
  • rabies_environment.dev.yml

@Gab-D-G Gab-D-G merged commit 8b260b6 into master Mar 25, 2026
3 checks passed
@Gab-D-G Gab-D-G deleted the review_python_dependencies branch March 25, 2026 23:03
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.

1 participant