X Tutup
Skip to content

MNT: test that table doesn't try to convert unitized data#26953

Merged
QuLogic merged 1 commit intomatplotlib:mainfrom
story645:test_table
Jan 24, 2024
Merged

MNT: test that table doesn't try to convert unitized data#26953
QuLogic merged 1 commit intomatplotlib:mainfrom
story645:test_table

Conversation

@story645
Copy link
Copy Markdown
Member

Tests that table doesn't participate in the unit pipeline by testing that it doesn't convert datetimes.

@story645
Copy link
Copy Markdown
Member Author

story645 commented Oct 2, 2023

Wrote a mock convertor and checked it wasn't called. Wondering if it'd be useful to have a unit registry context manager, but that's very very outside the scope of this PR. (ETA: also a dummy units fixture)

@QuLogic QuLogic added this to the v3.9.0 milestone Oct 14, 2023
fig_test.subplots().table(data)
fig_ref.subplots().table([["Hello", "Hello"], ["Hello", "Hello"]])

assert not fake_convertor.convert.called
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need to trigger a draw as well? That won't have happened at this point.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah converts seem to be called in .draw methods

@jklymak
Copy link
Copy Markdown
Member

jklymak commented Oct 15, 2023

I'm not following the purpose of this PR. It would be like testing that set_xlabel or the string argument of ax.text doesn't participate in the units pipeline. It is hard to understand how anyone could ever screw that up to justify the extra complexity and compute time.

@story645
Copy link
Copy Markdown
Member Author

story645 commented Oct 15, 2023

It is hard to understand how anyone could ever screw that up to justify the extra complexity and compute time.

It's a unit test that takes almost no time .9 second at most to run, and the complexity is the most straightforward unit + conversion you can write.

Yes, it's testing that table does what we expect it to so that it someone refractors table (which is a thing lots of folks have wanted to do) we have a test that it still behaves as expected. Also depending on where units go, it may make sense for table to participate in units...

I'm all for dumb tests that verify things do exactly what we say they do given the amount of side quests involved in making almost any medium sized change.

It would be like testing that set_xlabel or the string argument of ax.text doesn't participate in the units pipeline.

ax.text takes numbers for the positions so arguably it should (and maybe does?) participate in the units pipeline.

@dstansby
Copy link
Copy Markdown
Member

I'm also slightly confused as to what this is testing? Are you trying to check that e.g., a datetime in a table doesn't get converted by the units machinery to a floating point number before being converted to a string to go in the table?

@story645
Copy link
Copy Markdown
Member Author

Are you trying to check that e.g., a datetime in a table doesn't get converted by the units machinery to a floating point number before being converted to a string to go in the table?

Basically. Since table is doing an internal conversion using string, just double checking that that's what it's doing. This is a "this is our underlying assumption" test.

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>

Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>
@QuLogic QuLogic merged commit c5b9343 into matplotlib:main Jan 24, 2024
@story645 story645 deleted the test_table branch January 24, 2024 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

X Tutup