Skip to content

Improved sliding windows#1116

Open
schrf wants to merge 16 commits into
scverse:mainfrom
schrf:improved_sliding_windows
Open

Improved sliding windows#1116
schrf wants to merge 16 commits into
scverse:mainfrom
schrf:improved_sliding_windows

Conversation

@schrf

@schrf schrf commented Feb 10, 2026

Copy link
Copy Markdown

Description

replaced the drop_partial_windows argument with partial_windows, adding two new options:

  1. "adaptive": adjust window sizes such that all windows have almost the exact same size
  2. "split": recursively split a slide into windows such that they do not exceed a maximum number of cells defined by max_nr_cells.

The old arguments are None and drop now.

How has this been tested?

Tested using imc pancreas and visium datasets, running sliding_windows with different argument combinations and visually inspecting the windows by plotting them.

Closes

closes #908

@codecov

codecov Bot commented Feb 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.85714% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.43%. Comparing base (a9966fd) to head (935096f).

Files with missing lines Patch % Lines
src/squidpy/tl/_sliding_window.py 82.85% 6 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1116      +/-   ##
==========================================
+ Coverage   75.32%   75.43%   +0.10%     
==========================================
  Files          56       56              
  Lines        7936     7991      +55     
  Branches     1295     1308      +13     
==========================================
+ Hits         5978     6028      +50     
- Misses       1447     1449       +2     
- Partials      511      514       +3     
Files with missing lines Coverage Δ
src/squidpy/tl/_sliding_window.py 82.97% <82.85%> (+5.07%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timtreis

Copy link
Copy Markdown
Member

Hey @schrf, thank you for your contribution! Quite a lot of the changes are inconsequential (removing comments, renaming things, etc) which I'd guess are introduced by some LLM. While that's totally acceptable, I'd be great if you could clean up this PR to only touch things that are actually relevant to the new functionality you're implementing.

Thank you!

@selmanozleyen

Copy link
Copy Markdown
Member

yes also if you could make the notebook changes in a separate PR for the notebook repo I would appreciate it

@schrf

schrf commented Feb 23, 2026

Copy link
Copy Markdown
Author

Hey, thanks for the feedback. I'll simplify the changes as soon as I have time. @selmanozleyen I made a pull request for the notebook, I just didn't mention it here. It is #156

@schrf

schrf commented Mar 8, 2026

Copy link
Copy Markdown
Author

@timtreis I cleaned up the code. Let me know what you think

@selmanozleyen selmanozleyen self-requested a review June 9, 2026 14:23
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.

Add parameter to sliding_window to end up with windows of (approximately) same number of cells

3 participants