Skip to content

Improved sliding windows#1116

Open
schrf wants to merge 15 commits intoscverse:mainfrom
schrf:improved_sliding_windows
Open

Improved sliding windows#1116
schrf wants to merge 15 commits intoscverse:mainfrom
schrf:improved_sliding_windows

Conversation

@schrf
Copy link

@schrf schrf commented Feb 10, 2026

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
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 82.85714% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.11%. Comparing base (240dcfe) to head (4c7d9b1).

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   72.96%   73.11%   +0.15%     
==========================================
  Files          38       38              
  Lines        6484     6539      +55     
  Branches     1151     1164      +13     
==========================================
+ Hits         4731     4781      +50     
- Misses       1270     1272       +2     
- Partials      483      486       +3     
Files with missing lines Coverage Δ
src/squidpy/tl/_sliding_window.py 81.69% <82.85%> (+5.82%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timtreis
Copy link
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
Member

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

@schrf
Copy link
Author

schrf commented Feb 23, 2026

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
Copy link
Author

schrf commented Mar 8, 2026

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

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