Skip to content

TST: move and reformat latex_na_rep test #37717

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

Merged
merged 1 commit into from
Nov 9, 2020

Conversation

ivanovmg
Copy link
Member

@ivanovmg ivanovmg commented Nov 9, 2020

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Move test to a more suitable location (class TestToLatexFormatters)
and reformat using _dedent and raw string for better readability.

@ivanovmg ivanovmg requested a review from dsaxton November 9, 2020 14:08
Copy link
Member

@jbrockmendel jbrockmendel left a comment

Choose a reason for hiding this comment

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

LGTM

columns=["Group", "Data"],
)
result = df.to_latex(na_rep=na_rep, float_format="{:.2f}".format)
expected = _dedent(
Copy link
Member

Choose a reason for hiding this comment

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

Nice. I think this same pattern appears in other places, could push this definition higher up and use elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean _dedent (without the preceding newline?)

Copy link
Member

@dsaxton dsaxton Nov 9, 2020

Choose a reason for hiding this comment

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

Ah, maybe the other cases aren't using the preceding newline so could probably use dedent alone for those

Copy link
Member Author

@ivanovmg ivanovmg Nov 9, 2020

Choose a reason for hiding this comment

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

Here I used custom _dedent only to make it compatible with raw strings.
In general I would simply use this

dedent(
    """\
    content
    """
)

I guess that raw strings are mostly present here, in latex-related tests, because of the number of backslashes.
In other places we may want to use just built-in dedent

@jreback jreback added IO LaTeX to_latex Testing pandas testing functions or related to the test suite labels Nov 9, 2020
@jreback jreback added this to the 1.2 milestone Nov 9, 2020
@jreback jreback merged commit 71a3375 into pandas-dev:master Nov 9, 2020
@jreback
Copy link
Contributor

jreback commented Nov 9, 2020

thanks @ivanovmg

@ivanovmg ivanovmg deleted the cleanup/test-latex branch November 10, 2020 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO LaTeX to_latex Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants