Пример #1
0
def test_single_figure_from_graphic():
    graphic = pl.Graphic(str(EXAMPLE_IMAGE_PATH))
    fig = pl.Figure([graphic])
    assert str(
        fig
    ) == '\\begin{figure}\n\\includegraphics[width=1.0\\textwidth]{Sources/nd-logo.png}\n\\end{figure}'
    fig = pl.Figure([graphic], position_str='[h!]')
    assert str(
        fig
    ) == '\\begin{figure}\n[h!]\n\\includegraphics[width=1.0\\textwidth]{Sources/nd-logo.png}\n\\end{figure}'
    fig = pl.Figure([graphic], caption='image')
    assert str(
        fig
    ) == '\\begin{figure}\n\\includegraphics[width=1.0\\textwidth]{Sources/nd-logo.png}\n\\caption{image}\n\\end{figure}'
    fig = pl.Figure.from_dict_of_names_and_filepaths(
        {'image': str(EXAMPLE_IMAGE_PATH)})
    assert str(
        fig
    ) == '\\begin{figure}\n\\includegraphics[width=0.45\\linewidth]{Sources/nd-logo.png}\n\\caption{image}\n\\end{figure}'
    fig = pl.Figure([graphic], caption='woo', short_caption='yeah')
    assert str(
        fig
    ) == '\\begin{figure}\n\\includegraphics[width=1.0\\textwidth]{Sources/nd-logo.png}\n\\caption[yeah]{woo}\n\\end{figure}'
    fig = pl.Figure([graphic],
                    caption='woo',
                    label='yeah',
                    centering=False,
                    landscape=True,
                    position_str=r'[h!]')
    assert str(
        fig
    ) == '\\begin{lfigure}\n[h!]\n\\includegraphics[width=1.0\\textwidth]{Sources/nd-logo.png}\n\\caption{woo}\n\\label{yeah}\n\\end{lfigure}'
    name = 'figure from single graphic document'
    fig.to_pdf_and_move(outfolder=GENERATED_FILES_DIR, outname=name)
    compare_pdfs_in_generated_vs_input_by_name(name)
Пример #2
0
def test_basic_resume():
    contents = [
        pl.Section(
            [
                'An overview'
            ],
            title='Normal section'
        ),
        lr.SpacedSection(
            [
                JOB,
                EDUCATION,
                PUBLICATION,
                AWARD,
                REFERENCE
            ],
            title='Spaced Section'
        )
    ]
    doc = lr.Resume(
        contents,
        contact_lines=CONTACT_LINES
    )
    assert str(doc) == '\\documentclass[11pt]{resume}\n\\newenvironment{absolutelynopagebreak}{\\par\\nobreak\\vfil\\penalty0\\vfilneg\\vtop\\bgroup}{\\par\\xdef\\tpd{\\the\\prevdepth}\\egroup\\prevdepth=\\tpd}\n\\usepackage[left=0.75in,top=0.6in,right=0.75in,bottom=0.6in]{geometry}\n\\usepackage{xcolor}\n\\definecolor{darkblue}{RGB}{50,82,209}\n\\usepackage[hidelinks]{hyperref}\n\\usepackage{ragged2e}\n\\address{Nick DeRobertis}\n\\address{Location, here}\n\\address{Contact 1 \\\\ Contact 2}\n\\begin{document}\n\\begin{section}{Normal section}\nAn overview\n\\end{section}\n\\begin{section}{Spaced Section}\n\\vspace{0.2cm}\n\\begin{absolutelynopagebreak}\n\\begin{employment}{Company Name}{2015 - Present}{Job Title}{Location, Here}\n\\item \\begin{itemize}\n\\item I did\n\\item some things\n\\item today\n\\end{itemize}\nExtra contents\n\\end{employment}\n\\end{absolutelynopagebreak}\n\n\\begin{absolutelynopagebreak}\n\\textbf{Some School}\n (GPA 4.0/4.0)\n\\hfill\n\\textbf{May 2020}\n\\\\\n\\textit{Bachelor of Science in Something}\n\\hfill\nLocation, Here\n\\\\[-8pt]\n\\end{absolutelynopagebreak}\n\n\\begin{absolutelynopagebreak}\n\\hangindent=1cm\n\\href{https://www.example.com/}{\\underline{\\textcolor{darkblue}{Publication Title}}},\n\\textit{Journal of Awesome}\n with \nCoauthor One\n and \nCoauthor Two\nThis was a really neat paper\n\n\\justifying\nA description of the paper\n\\vspace{0.2cm}\n\\vspace{0.2cm}\n\\end{absolutelynopagebreak}\n\n\\begin{absolutelynopagebreak}\n\\textbf{Cool Award}\n (Some extra info)\n\\hfill\nMay 2020\n\\\\[-8pt]\n\\end{absolutelynopagebreak}\n\n\\begin{absolutelynopagebreak}\n\\textsc{\\textbf{My Reference}}\n\\\\\n\\textit{Reference Title}\n\\\\\n\\textit{Can be Multiple Lines}\n\\\\\nOrganization\n\\\\\nAddress\n\\\\\nPhone\n\\\\\nWhatever contact\n\\\\\[email protected]\n\\\\\n\\\\[-8pt]\n\\end{absolutelynopagebreak}\n\\vspace{-0.2cm}\n\\end{section}\n\\end{document}'
    name = 'resume basic'
    doc.to_pdf(outfolder=GENERATED_FILES_DIR, outname=name)
    compare_pdfs_in_generated_vs_input_by_name(name)
def test_presentation_options():
    doc = pl.Presentation(
        [
            pl.Section([
                pl.Frame(['woo'], title='One-One'),
                pl.Frame(['woo2'], title='One-Two')
            ],
                       title="One"),
            pl.Section([
                pl.Frame(['woo3'], title='Two-One'),
                pl.Frame(['woo4'], title='Two-Two')
            ],
                       title="Two")
        ],
        packages=['hyperref'],
        title='Test Presentation',
        authors=['Nick DeRobertis', 'Someone Else'],
        date='2020-10-19',
        short_title='Pres',
        subtitle='A Presentation for Testing Purposes',
        short_author='People',
        institutions=[['University of Florida', 'Line two'],
                      ['Virginia Commonwealth University']],
        short_institution='UF & VCU',
        font_size=15,
        nav_header=True,
        toc_sections=True,
    )
    name = 'presentation with options'
    assert_same_or_generate_presentation(doc, name)
    doc.to_pdf(outfolder=GENERATED_FILES_DIR, outname=name)
    compare_pdfs_in_generated_vs_input_by_name(name)
def test_figure_in_presentation():
    graphic = pl.Graphic(str(EXAMPLE_IMAGE_PATH), width=0.4)
    fig = pl.Figure([graphic], caption='My Figure')
    doc = pl.Presentation([
        pl.Section([
            pl.Frame([fig], title='Figure'),
        ], title="Section"),
    ], )
    name = 'presentation with figure'
    assert_same_or_generate_presentation(doc, name)
    doc.to_pdf(outfolder=GENERATED_FILES_DIR, outname=name)
    compare_pdfs_in_generated_vs_input_by_name(name)
Пример #5
0
def test_figure_from_matplotlib():
    plot = pd.Series([1, 2, 3, 4]).plot().get_figure()
    fig = pl.Figure.from_dict_of_names_and_plt_figures({'plot': plot},
                                                       GENERATED_FILES_DIR,
                                                       figure_name='my capt',
                                                       short_caption='woo')
    assert str(
        fig
    ) == '\\begin{figure}\n\\includegraphics[width=0.45\\linewidth]{Sources/plot.pdf}\n\\caption[woo]{my capt}\n\\end{figure}'
    name = 'figure from matplotlib'
    fig.to_pdf_and_move(outfolder=GENERATED_FILES_DIR, outname=name)
    compare_pdfs_in_generated_vs_input_by_name(name)
    fig = pl.Figure.from_dict_of_names_and_plt_figures({'plot': plot},
                                                       GENERATED_FILES_DIR,
                                                       position_str='[h!]')
    assert str(
        fig
    ) == '\\begin{figure}\n[h!]\n\\includegraphics[width=0.45\\linewidth]{Sources/plot.pdf}\n\\caption{plot}\n\\end{figure}'
def test_table_in_presentation():
    df = pd.DataFrame([(1, 2, 3.546), (4, 5, 66546.4), (7, 8, 96.54)],
                      columns=['a', 'b', 'c'])
    table = pl.Table.from_list_of_lists_of_dfs(
        [[df]],
        caption='My Table Title',
        below_text='My below text',
        align='L{5cm}c.',
        mid_rules=False,
    )
    doc = pl.Presentation([
        pl.Section([
            pl.Frame([table], title='Table'),
        ], title="Section"),
    ], )
    name = 'presentation with table'
    assert_same_or_generate_presentation(doc, name)
    doc.to_pdf(outfolder=GENERATED_FILES_DIR, outname=name)
    compare_pdfs_in_generated_vs_input_by_name(name)
def test_tabular_list_from_table_in_presentation():
    df = pd.DataFrame([(1, 2, 3.546), (4, 5, 66546.4), (7, 8, 96.54)],
                      columns=['a', 'b', 'c'])
    table = pl.Table.from_list_of_lists_of_dfs([[df], [df + 10]],
                                               caption='My Table Title',
                                               below_text='My below text',
                                               align='L{5cm}c.')
    frames = [
        pl.Frame(tab, title=f'Tabular {i + 1}') for i, tab in enumerate(
            table.tex_obj(as_document=False, as_panel_tabular_list=True))
    ]

    doc = pl.Presentation([
        pl.Section([
            frames,
        ], title="Section"),
    ], )
    name = 'presentation with tabular list'
    assert_same_or_generate_presentation(doc, name)
    doc.to_pdf(outfolder=GENERATED_FILES_DIR, outname=name)
    compare_pdfs_in_generated_vs_input_by_name(name)
Пример #8
0
 def test_spacing_adjust_aligns_table_in_document(self):
     doc = pl.Document([self.table_with_spacing_adjust_aligns])
     name = 'document with spacing adjust aligns table'
     assert_same_or_generate_document(doc, name)
     doc.to_pdf(outfolder=GENERATED_FILES_DIR, outname=name)
     compare_pdfs_in_generated_vs_input_by_name(name)
Пример #9
0
 def test_two_panel_table_in_document(self):
     doc = pl.Document([self.two_panel_table_from_lol_with_index])
     name = 'document with two panel table'
     assert_same_or_generate_document(doc, name)
     doc.to_pdf(outfolder=GENERATED_FILES_DIR, outname=name)
     compare_pdfs_in_generated_vs_input_by_name(name)
def test_basic_presentation():
    doc = pl.Presentation(['woo'])
    name = 'basic presentation'
    assert_same_or_generate_presentation(doc, name)
    doc.to_pdf(outfolder=GENERATED_FILES_DIR, outname=name)
    compare_pdfs_in_generated_vs_input_by_name(name)