Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataFrame examples are nearly unreadable #3114

Closed
inglesp opened this issue Oct 9, 2021 · 2 comments · Fixed by #3171
Closed

DataFrame examples are nearly unreadable #3114

inglesp opened this issue Oct 9, 2021 · 2 comments · Fixed by #3171
Labels
legibility make errors helpful and Hypothesis grokable

Comments

@inglesp
Copy link
Contributor

inglesp commented Oct 9, 2021

I have a test that takes a couple of Pandas DataFrames as input. When the test fails, the examples in the output can be very hard to make sense of:

Falsifying example: test_always_increasing(
    df_a=            A
    2021-01-01  1, df_b=            A
    2021-01-01  0
    2021-01-02  0,
)

If I add the following line in my test setup:

pd.DataFrame._repr_pretty_ = lambda self, p, cycle: p.text(f"\n{self}\n")

then the output is much clearer:

Falsifying example: test_always_increasing(
    df_a=
            A
2021-01-01  1
,
    df_b=
            A
2021-01-01  0
2021-01-02  0
,
)

Would you accept a patch that always sets pd.DataFrame._repr_pretty_? (Assuming Pandas is installed and that pd.DataFrame._repr_pretty_ isn't already set...)

@Zac-HD Zac-HD added the legibility make errors helpful and Hypothesis grokable label Oct 9, 2021
@inglesp
Copy link
Contributor Author

inglesp commented Dec 2, 2021

Hey @Zac-HD, I'm sorry I never got around to fixing this myself. Thanks!

@Zac-HD
Copy link
Member

Zac-HD commented Dec 2, 2021

No worries! I happened to be poking around in the pretty-printer last week, and at that point it was (ahem) pretty easy to fix 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legibility make errors helpful and Hypothesis grokable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants