Skip to content

Unit handling needs many more tests #18278

Open

Description

@QuLogic

Problem

I've gone down a bit of a rabbit hole with #17930, and I've noticed that our testing for units is rather sparse. lib/matplotlib/tests/test_units.py only really checks plot, scatter, axhline, axvline, and bar, but we have many more artists that are peppered with unit conversion handling.

Proposed Solution

We need to expand test_units.py to cover almost all artist-creating functions that need to handle units. Now we have check_figures_equal, so we can do something about it that doesn't explore the number of test images, with a plot reference figure with non-unit functions, and a plot test figure with unitized functions.

I don't really understand what the expected unit conversion interface is, so I don't know how exactly to write the tests. I tried to do one for errorbar using Quantity, but it didn't work and I don't know if that's because Quantity does not implement enough for the unit registry, or whether errorbar doesn't correctly handle units.

Activity

  1. timhoffm commented on Aug 18, 2020

    @timhoffm
    Member

    We need to expand test_units.py to cover almost all artist-creating functions that need to handle units.

    I'd rather put that next to the respective Artist tests. You won't easily notice that an Artist is missing among 15 or so artist unit tests. But you might see that there is no tests for units among the tests for a specific artist.

  2. QuLogic commented on Aug 18, 2020

    @QuLogic
    MemberAuthor

    Sure, that might work too. I went with test_units.py because it already has Quantity (which may or may not be fully implemented), though we also have jpl_units that could be used. Also, test_axes.py is already kind of huge.

  3. dopplershift commented on Aug 18, 2020

    @dopplershift
    Contributor

    Quantity was created for me to test what I've needed to fix to work with pint. It's entirely possible it could use some more things to work across all the possible uses.

  4. github-actions commented on Aug 16, 2023

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  5. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Aug 16, 2023
  6. QuLogic commented on Aug 17, 2023

    @QuLogic
    MemberAuthor

    Probably something for @ksunden to look into, though this is a bit of a broad issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions