Skip to content

Conversation

@vanshika-hgnis
Copy link

@vanshika-hgnis vanshika-hgnis commented Jan 18, 2026

Description

This PR adds a small clarification to the vis.image documentation to explicitly highlight the required image shape (C × H × W).
The existing documentation mentions the expected shape, but it is easy for new users to miss, especially since most Python image libraries return images in H × W × C format.

Motivation and Context

While using Visdom as a first-time user, passing images in H × W × C format resulted in a non-obvious runtime error originating from PIL. This change makes the shape requirement explicit at the point of use to help prevent common confusion and reduce avoidable errors for
new users.

How Has This Been Tested?

  • Verified that vis.image works correctly when passing images in
    C × H × W format.
  • Reproduced the runtime error when passing images in H × W × C format
    to confirm the documented behavior.
  • No code paths were modified; this change only affects documentation.

Screenshots (if appropriate):

N/A (documentation-only change)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactor or cleanup (changes to existing code for improved readability or performance)

Checklist:

  • I adapted the version number under py/visdom/VERSION according to Semantic Versioning
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Summary by Sourcery

Documentation:

  • Expand the vis.image README documentation to explicitly warn that many Python image libraries return HxWxC images, which will error or render incorrectly if passed directly.

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 18, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Documentation-only change updating the vis.image README section to explicitly call out that the function expects images in C×H×W format and that common Python image libraries instead return H×W×C, which can cause errors or incorrect rendering.

File-Level Changes

Change Details Files
Clarify vis.image expected image tensor shape and contrast it with typical library output shapes to prevent misuse.
  • Expanded the vis.image description to keep the C×H×W requirement in a single, continuous sentence for readability.
  • Added an explicit note that popular Python image libraries (OpenCV, PIL, matplotlib) usually return images in H×W×C format.
  • Documented that passing H×W×C images into vis.image may raise errors or render images incorrectly.
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • There appears to be a missing space after the first sentence in the new text (image.Mostimage. Most).
  • Consider briefly showing how to convert from HxWxC to CxHxW (e.g., with a small code snippet using NumPy or PyTorch) to make the guidance immediately actionable for users.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There appears to be a missing space after the first sentence in the new text (`image.Most``image. Most`).
- Consider briefly showing how to convert from `HxWxC` to `CxHxW` (e.g., with a small code snippet using NumPy or PyTorch) to make the guidance immediately actionable for users.

## Individual Comments

### Comment 1
<location> `README.md:322` </location>
<code_context>
 #### vis.image
-This function draws an `img`. It takes as input an `CxHxW` tensor `img`
-that contains the image.
+This function draws an `img`. It takes as input an `CxHxW` tensor `img` that contains the image.Most Python image libraries (e.g. OpenCV, PIL, matplotlib) return images in `HxWxC` format. Passing images in that format will raise errors or lead to incorrect rendering.

 The following `opts` are supported:
</code_context>

<issue_to_address>
**issue (typo):** Missing space after the period in "image.Most".

Add a space after the period so it reads "image. Most".

```suggestion
This function draws an `img`. It takes as input an `CxHxW` tensor `img` that contains the image. Most Python image libraries (e.g. OpenCV, PIL, matplotlib) return images in `HxWxC` format. Passing images in that format will raise errors or lead to incorrect rendering.
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

#### vis.image
This function draws an `img`. It takes as input an `CxHxW` tensor `img`
that contains the image.
This function draws an `img`. It takes as input an `CxHxW` tensor `img` that contains the image.Most Python image libraries (e.g. OpenCV, PIL, matplotlib) return images in `HxWxC` format. Passing images in that format will raise errors or lead to incorrect rendering.
Copy link

Choose a reason for hiding this comment

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

issue (typo): Missing space after the period in "image.Most".

Add a space after the period so it reads "image. Most".

Suggested change
This function draws an `img`. It takes as input an `CxHxW` tensor `img` that contains the image.Most Python image libraries (e.g. OpenCV, PIL, matplotlib) return images in `HxWxC` format. Passing images in that format will raise errors or lead to incorrect rendering.
This function draws an `img`. It takes as input an `CxHxW` tensor `img` that contains the image. Most Python image libraries (e.g. OpenCV, PIL, matplotlib) return images in `HxWxC` format. Passing images in that format will raise errors or lead to incorrect rendering.

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