Skip to content

Conversation

@noamteyssier
Copy link
Collaborator

No description provided.

@noamteyssier noamteyssier linked an issue Nov 3, 2025 that may be closed by this pull request
@gemini-code-assist
Copy link

Summary of Changes

Hello @noamteyssier, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the guess_is_lognorm function that prevented it from properly processing AnnData views, which are common in single-cell data analysis workflows. The fix ensures that the function can robustly determine if data is log-normalized, regardless of whether it's a full AnnData object or a view. This enhances the reliability of data preprocessing steps and includes a new test to prevent regressions.

Highlights

  • Bug Fix: The guess_is_lognorm utility function now correctly handles AnnData objects that are views (subsets) of larger AnnData objects. Previously, it would fail when encountering such views.
  • Improved Data Handling: A new condition has been added to guess_is_lognorm to explicitly convert the data matrix (adata.X) of an AnnData view to a dense array using toarray() before processing, ensuring compatibility with np.modf.
  • New Test Case: A dedicated test, test_is_lognorm_vew, has been introduced to validate the correct behavior of guess_is_lognorm when provided with an AnnData view.
  • Version Update: The project version has been incremented from 0.6.3 to 0.6.4 in pyproject.toml, reflecting this bug fix and improvement.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug in guess_is_lognorm when handling AnnData views. The fix correctly adds a condition to handle view objects by converting adata.X to a dense array. A new test case is also included to validate this fix. The changes are logical and well-tested. I have a couple of minor suggestions for improving code style and fixing a typo.

Returns:
bool: True if the input is lognorm, False otherwise
"""
if isinstance(adata.X, csr_matrix) or isinstance(adata.X, csc_matrix):

Choose a reason for hiding this comment

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

medium

For conciseness, the two isinstance checks can be combined into a single call by passing a tuple of the types to check against.

Suggested change
if isinstance(adata.X, csr_matrix) or isinstance(adata.X, csc_matrix):
if isinstance(adata.X, (csr_matrix, csc_matrix)):

assert guess_is_lognorm(data)


def test_is_lognorm_vew():

Choose a reason for hiding this comment

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

medium

There's a typo in the test function name. It appears vew should be view. Correcting this will improve readability and maintainability.

Suggested change
def test_is_lognorm_vew():
def test_is_lognorm_view():

@noamteyssier noamteyssier merged commit d468df0 into main Nov 3, 2025
2 checks passed
@noamteyssier noamteyssier deleted the 205-bug-with-guess-is-lognorm-when-anndatas-are-views branch November 3, 2025 20:58
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.

bug with guess is lognorm when anndatas are views

2 participants