Open
Conversation
zhan4329
reviewed
Feb 20, 2026
server/nearest_neighbor_server.py
Outdated
Comment on lines
266
to
270
| if df is None: | ||
| return None | ||
| csv_string = df.to_csv(index=False) | ||
| csv_bytes = csv_string.encode("utf-8") | ||
| return csv_bytes, "text/csv" |
Contributor
There was a problem hiding this comment.
I guess there is a missing "else:" or an indentation error?
Contributor
There was a problem hiding this comment.
Resolved. Thanks for pointing that out!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR cleans up legacy control-flow logic across the codebase by replacing inverted if-not patterns with standard if/else statements and removing the redundant flipper variable. These changes improve readability and maintainability without altering application behavior.
Changes
Replace if x is not False / inverted boolean logic with standard if x checks
Remove the flipper variable and simplify affected logic paths
Normalize conditional flow across server and data input modules
Testing
Manually tested core app flows to ensure no behavior changes
Verified plots, downloads, and dataset loading still function correctly
Reviewed Docker logs during testing; no errors or concerning logs observed.
Additional Context
This branch isolates code cleanup work originally included in core_refactor, separating it from feature and performance changes.
Contributors (with original commits linked):
@Saran-Nag : Formatting changes (link), effect_update_server.py, feat_vs_anno_server.py, features_server.py (link), nearest_neighbor_server.py, ripleyL_server.py, spatial_server.py, umap_server.py (link)
@NLee: anno_vs_anno_server.py, annotations_server.py, boxplot_server.py, data_input_server.py (link), Flipper variable removal
@risingmin : Flipper variable removal
Detailed Review (AI generated)
Logic Simplification (Multiple Files) Status: ✅ Improved
Change: Replaced flipper = shared['data_loaded'].get() followed by if flipper is not False: with direct usage if shared['data_loaded'].get():. Locations: umap_server.py, spatial_server.py, annotations_server.py, etc. Impact: drastically improves readability. The previous is not False check was unusually specific and likely a vestige of debugging.
Change: if adata is not None: changed to if adata:.
Context: adata is an AnnData object.
Review: While AnnData objects generally support boolean evaluation (evaluating to True), relying on implicit truthiness for complex data structures can sometimes be risky if the library changes how bool or len is implemented (like Pandas, where it raises a ValueError).
Verdict: It is safe for now with AnnData, but sticking to if adata is not None: is generally more defensive for data containers.
Change: python
Old
if df is not None: # process
New
if df is None: return None else: # process
Impact: This avoids nested indentation and makes the "early exit" strategy clear. Crucially, it avoids accidentally doing if df: which would crash if df is a DataFrame.
Change: Wrapped long lines in ui.input_select and function calls (e.g., server/feat_vs_anno_server.py , server/spatial_server.py ).
Impact: Much better readability on standard screens and standardizes the codebase.