Esempio n. 1
0
def test_package_conflict():
    section = pl.Section(['woo'], title='Section')
    section.init_data()
    section.add_package(pl.Package('hyperref', modifier_str='hidelinks'))
    # Without eq_on_modifier=False, raises error for package options conflict
    section.add_package(
        pl.Package('hyperref',
                   modifier_str='linktoc=all',
                   eq_on_modifier=False))
    doc = pl.Document([section])
    doc.to_pdf(GENERATED_FILES_DIR, outname='package conflict document')
    compare_pdfs(INPUT_FILES_DIR / 'package conflict document.pdf',
                 GENERATED_FILES_DIR / 'package conflict document.pdf')
Esempio n. 2
0
def test_inline_graphic_in_document():
    ig = pl.InlineGraphic(str(EXAMPLE_IMAGE_PATH), width=0.1)
    ig2 = pl.InlineGraphic(str(EXAMPLE_IMAGE_PATH), width=0.1)
    contents = [
        'Some inline text before', ig,
        'and after and then wrapping onto the next line so that '
        'I can make sure that it is working properly in the case '
        'that it is used in a real document', ig2
    ]
    doc = pl.Document(contents)
    assert EXPECT_DEFINITION in str(doc)
    assert EXPECT_GRAPHIC in str(doc)
    doc.to_pdf(GENERATED_FILES_DIR, outname='inline graphic document')
    compare_pdfs(INPUT_FILES_DIR / 'inline graphic document.pdf',
                 GENERATED_FILES_DIR / 'inline graphic document.pdf')
Esempio n. 3
0
def variables_drop_obs_doc(df: pd.DataFrame,
                           var_groups: Dict[str, Sequence[Variable]],
                           id_var: Optional[str] = None,
                           sources_outfolder: str = '.') -> pl.Document:
    """
    Generates a summary document of coverage of variables

    Produce a summary document of first a table which shows for each variable,
    the count of non-missing observations, and the count of coins which have
    at least one non-missing observation. Then it shows statistics on what
    would happen to the observations if the variable was dropped from the sample.
    These numbers are calculated by looking at every combination of the
    variables and how much the observation count would increase if this
    variable was excluded from the analysis. Summary statistics are shown for that.
    Then the following pages in the document are histograms of the same analysis,
    showing the distribution of observation counts that could be regained if we
    excluded that variable across the combinations of the other variables.

    :param df:
    :param var_groups: keys are names of variable groups, values are variables in the group
    :param id_var:
    :param sources_outfolder:
    :return:
    """
    panels = []
    all_figures = []
    for group_name, selected_vars in var_groups.items():
        var_names = [var.name for var in selected_vars]
        summ_df, figs = variables_drop_count_df_and_plt_figs(
            df, var_names, id_var)
        panel = variables_drop_panel(summ_df, group_name, id_var)
        panels.append(panel)
        figures = variables_latex_figures(figs, group_name, sources_outfolder)
        all_figures.extend(figures)
    tab = pl.Table.from_panel_list(panels, caption='Variable Drop Analysis')
    doc = pl.Document([tab] + all_figures)
    return doc
Esempio n. 4
0
def get_outputs() -> List[BuildConfig]:
    document = pl.Document(get_content(), title=TITLE, authors=AUTHORS)
    options = BuildOptions(output_folder=OUTPUT_LOCATION,
                           file_name=OUTPUT_NAME)
    return [BuildConfig(model=document, options=options)]
Esempio n. 5
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)
Esempio n. 6
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)
Esempio n. 7
0
def _get_document(contents) -> pl.Document:
    doc = pl.Document(contents, title='Project Report')
    return doc