From 6a2665cfb241c503856f7583bd06d709e70fbf89 Mon Sep 17 00:00:00 2001 From: Karel Vaculik Date: Fri, 15 Sep 2023 07:47:29 +0200 Subject: [PATCH] Remove examples from repo now that we have them in documentation. --- README.md | 15 - examples/__init__.py | 0 examples/custom_arguments.html | 100 --- examples/custom_arguments.py | 29 - examples/longer_report.html | 1458 -------------------------------- examples/longer_report.py | 132 --- examples/report.html | 768 ----------------- examples/report.py | 29 - examples/sample_plots.html | 737 ---------------- examples/sample_plots.py | 62 -- examples/simple.html | 103 --- examples/simple.py | 8 - 12 files changed, 3441 deletions(-) delete mode 100644 examples/__init__.py delete mode 100644 examples/custom_arguments.html delete mode 100644 examples/custom_arguments.py delete mode 100644 examples/longer_report.html delete mode 100644 examples/longer_report.py delete mode 100644 examples/report.html delete mode 100644 examples/report.py delete mode 100644 examples/sample_plots.html delete mode 100644 examples/sample_plots.py delete mode 100644 examples/simple.html delete mode 100644 examples/simple.py diff --git a/README.md b/README.md index af0fb21..b830122 100644 --- a/README.md +++ b/README.md @@ -85,21 +85,6 @@ pyreball report.py ![Pyreball Screenshot](pyreball_result_screenshot.png) -## Other Examples - -Script `report.py` and a few other examples can be found in `examples` folder. For example, `longer_report.py` -illustrates most of the Pyreball's features, while `sample_plots.py` shows different plotting libraries. -To install all dependencies needed for these examples, run: - -```shell -pip install -r requirements_examples.txt -``` - -The command above is assumed to work with Python 3.9 - 3.11. -If you are using Python 3.8, older dependencies are needed, so `requirements_examples_py38.txt` -can be used. -Although the versions are fixed in these requirements files, Pyreball works with many other versions, too. - ## Documentation See [documentation](https://pyreball.readthedocs.io/) for more examples and information about Pyreball. diff --git a/examples/__init__.py b/examples/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/examples/custom_arguments.html b/examples/custom_arguments.html deleted file mode 100644 index b51b443..0000000 --- a/examples/custom_arguments.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - -Custom Arguments - - - - -
-

Custom Arguments

-
- - - \ No newline at end of file diff --git a/examples/custom_arguments.py b/examples/custom_arguments.py deleted file mode 100644 index 87ffbf9..0000000 --- a/examples/custom_arguments.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Simple report showing how to pass custom arguments to your script. - -Example of a call: -pyreball --page-width=90 custom_arguments.py -- --sum 23 25 24 -""" -import argparse - -import pyreball as pb - -pb.set_title("Custom Arguments") - -# based on example at https://docs.python.org/3/library/argparse.html#example -parser = argparse.ArgumentParser(description="Process some integers.") -parser.add_argument( - "integers", metavar="N", type=int, nargs="+", help="an integer for the accumulator" -) -parser.add_argument( - "--sum", - dest="accumulate", - action="store_const", - const=sum, - default=max, - help="sum the integers (default: find the max)", -) - -args = parser.parse_args() -pb.print_div( - f"The {args.accumulate.__name__} of the arg values is {args.accumulate(args.integers)}." -) diff --git a/examples/longer_report.html b/examples/longer_report.html deleted file mode 100644 index 0205fda..0000000 --- a/examples/longer_report.html +++ /dev/null @@ -1,1458 +0,0 @@ - - - - -Sample Report - - - - - - - - - - -
-

Sample Report

-1  Displaying Texts
- -2  Inspecting Data
- -

1  Displaying Texts

-
We can always start inserting custom raw HTML code.
-
-
However, we can use special function to write text into a <br> element.
-
-

It is possible to pass several values and optionally a separator.
The values will be joined and automatically converted to strings, as with the following number and list.
42
[11, 13, 19]
-

1.1  Basic String-wrapping Formatting Functions

-
This is a text with bold word and with emphasised word.You can also use inline code formatting.
-
In the previous section, we pasted string values on separate lines. Let's use lists instead:
  • Each argument is one element in the list
  • We can even make nested lists as with the following ordered list:
    1. First
    2. Second
  • And we can of course mix the lists:
    • Nested list again, but now an unordered one.
-

1.2  Other Special Functions

-
We can also add a link to Python documentation if necessary. Talking about links, note that each heading has a clickable anchor.
-
-
We already used code function for inline formatting. There is also print_code function that creates a text block formatted as code, which can be useful when we want to print various data structures, such as matrices:
-
[[4.17022005e-01 7.20324493e-01 1.14374817e-04]
- [3.02332573e-01 1.46755891e-01 9.23385948e-02]
- [1.86260211e-01 3.45560727e-01 3.96767474e-01]]
- -
-
... or even a piece of code:
-
def factorial(n):
-    result = 1
-    for i in range(1, n + 1):
-        result *= i
-    return result
-
- -
-
Before going further, let's return to the very first function we used: set_title. As the name suggests, it sets the title of the HTML page. It is optional and can be actually placed in any part of the report.
-

2  Inspecting Data

-

2.1  Tables and Plots

-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
xy
15.155267
24.676778
35.740878
43.817809
56.512470
63.109550
75.681870
84.669219
95.234759
103.561548
-
-
- -
- - - - - - - 2023-09-15T07:33:04.898046 - image/svg+xml - - - Matplotlib v3.7.2, https://matplotlib.org/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

2.2  References to Plots and Tables

-
It is also possible to create references to tables and figures. For example Table 2 shows sortable columns and Fig. 2 displays a scatterplot.
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
xy
15.155267
24.676778
35.740878
43.817809
56.512470
63.109550
75.681870
84.669219
95.234759
103.561548
-
-
- -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
xy
15.155267
24.676778
35.740878
43.817809
56.512470
63.109550
75.681870
84.669219
95.234759
103.561548
-
-
- -
- - - - - - - 2023-09-15T07:33:04.924057 - image/svg+xml - - - Matplotlib v3.7.2, https://matplotlib.org/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
Note that you can use the references in your text multiple times, see again the reference to Table 2 and Fig. 2. Of course, we cannot use a single reference for multiple tables or figures.
-
- - - \ No newline at end of file diff --git a/examples/longer_report.py b/examples/longer_report.py deleted file mode 100644 index 0d77168..0000000 --- a/examples/longer_report.py +++ /dev/null @@ -1,132 +0,0 @@ -"""Simple report showing various features of Pyreball.""" -import matplotlib.pyplot as plt -import numpy as np -import pandas as pd - -import pyreball as pb -import seaborn as sns - -pb.set_title("Sample Report") - -pb.print_h1("Displaying Texts") - -pb.print("
We can always start inserting custom raw HTML code.
") -pb.print("
") -pb.print_div( - "However, we can use special function to write text into a <br> element." -) -pb.print("
") -pb.print_div( - "It is possible to pass several values and optionally a separator.", - "The values will be joined and automatically converted to strings, " - "as with the following number and list. ", - 42, - [11, 13, 19], - sep="
", -) - -pb.print_h2("Basic String-wrapping Formatting Functions") -pb.print_div( - f"This is a text with {pb.bold('bold')} word and with {pb.em('emphasised')} word.", - f"You can also use {pb.code('inline code formatting')}.", -) - -pb.print_div( - "In the previous section, we pasted string values on separate lines. " - "Let's use lists instead:", - pb.ulist( - "Each argument is one element in the list", - "We can even make nested lists as with the following ordered list:", - pb.olist("First", "Second"), - "And we can of course mix the lists:", - pb.ulist("Nested list again, but now an unordered one."), - ), -) - -pb.print_h2("Other Special Functions") -pb.print_div( - f"We can also add a link to {pb.link('Python documentation', 'https://www.python.org/doc/')} " - f"if necessary. Talking about links, note that each heading has a clickable anchor." -) -pb.print("
") -pb.print_div( - f"We already used {pb.code('code')} function for inline formatting. There is also {pb.code('print_code')} " - f"function that creates a text block formatted as code, " - f"which can be useful when we want to print various data structures, such as matrices:" -) - -np.random.seed(1) -array = np.random.random((3, 3)) -pb.print_code_block(str(array)) - -pb.print_div("... or even a piece of code:") - - -def factorial(n): - result = 1 - for i in range(1, n + 1): - result *= i - return result - - -import inspect - -pb.print_code_block(inspect.getsource(factorial)) - -pb.print_div( - f"Before going further, let's return to the very first function we used: " - f"{pb.code('set_title')}. " - f"As the name suggests, it sets the title of the HTML page. " - f"It is optional and can be actually placed in any part of the report." -) - -pb.print_h1("Inspecting Data") - -pb.print_h2("Tables and Plots") - -# Print a table -N = 10 -df = pd.DataFrame({"x": np.arange(1, N + 1), "y": np.random.random(N) * 4 + 3}) -pb.print_table(df, caption="A data table.", index=False) - -# Plot a graph -fig, ax = plt.subplots() -sns.lineplot(x="x", y="y", ax=ax, data=df) -ax.set(xlabel="x", ylabel="y") -pb.print_figure(fig, caption="The first plot.") - -pb.print_h2("References to Plots and Tables") - -# Creating a reference to a graph and a table: -img_reference = pb.Reference() -table_ref = pb.Reference() -pb.print_div( - f"It is also possible to create references to tables and figures. " - f"For example Table {table_ref} shows sortable columns and Fig. {img_reference} " - f"displays a scatterplot." -) -pb.print_table( - df, - caption="A sortable table with a reference", - reference=table_ref, - sortable=True, - index=False, -) - -pb.print_table( - df, - caption="A table sorted by y column", - sorting_definition=[(df.columns.get_loc("y"), "asc")], - index=False, -) -fig, ax = plt.subplots() -sns.scatterplot(x="x", y="y", ax=ax, data=df) -ax.set(xlabel="x", ylabel="y") -pb.print_figure(fig, caption="A plot with a reference.", reference=img_reference) - - -pb.print_div( - f"Note that you can use the references in your text multiple times, " - f"see again the reference to Table {table_ref} and Fig. {img_reference}. " - f"Of course, we cannot use a single reference for multiple tables or figures." -) diff --git a/examples/report.html b/examples/report.html deleted file mode 100644 index 7fd8f22..0000000 --- a/examples/report.html +++ /dev/null @@ -1,768 +0,0 @@ - - - - -Pyreball Illustration - - - - - - - - - - -
-

Pyreball Illustration

-1  Introduction
-2  Tables and Figures
-

1  Introduction

-
Pyreball has many features, among others:
  • Charts in altair, plotly, bokeh, and matplotlib (and thus also seaborn etc.).
  • Sortable and scrollable tables from pandas DataFrame.
  • Basic text formatting such as headings, emphasis, and lists.
  • hyperlinks, references and table of contents.
-

2  Tables and Figures

-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - -
xy
014
126
235
-
-
- -
- - - - - - - 2023-09-15T07:33:04.107188 - image/svg+xml - - - Matplotlib v3.7.2, https://matplotlib.org/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - \ No newline at end of file diff --git a/examples/report.py b/examples/report.py deleted file mode 100644 index 6a6640c..0000000 --- a/examples/report.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Simple report showing various features of Pyreball.""" -import matplotlib.pyplot as plt -import pandas as pd -import pyreball as pb -import seaborn as sns - -pb.set_title("Pyreball Illustration") - -pb.print_h1("Introduction") - -pb.print_div( - "Pyreball has many features, among others:", - pb.ulist( - "Charts in altair, plotly, bokeh, and matplotlib (and thus also seaborn etc.).", - "Sortable and scrollable tables from pandas DataFrame.", - f'Basic text formatting such as {pb.bold("headings")}, {pb.em("emphasis")}, and {pb.code("lists")}.', - f'{pb.link("hyperlinks", "https://www.python.org/")}, references and table of contents.', - ), -) - -pb.print_h1("Tables and Figures") - -df = pd.DataFrame({"x": [1, 2, 3], "y": [4, 6, 5]}) -pb.print_table(df, caption="A data table.") - -fig, ax = plt.subplots() -sns.lineplot(x="x", y="y", ax=ax, data=df) -ax.set(xlabel="x", ylabel="y") -pb.print_figure(fig, caption="The first figure.") diff --git a/examples/sample_plots.html b/examples/sample_plots.html deleted file mode 100644 index 8ee3f83..0000000 --- a/examples/sample_plots.html +++ /dev/null @@ -1,737 +0,0 @@ - - - - -Sample Plots - - - - - - - - - - - - - - - -
-

Sample Plots

-
All supported plots are embedded directly into the final HTML file, except matplotllib plots with png format. For such plots, a folder with png images is created.
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - -
xy
014
123
236
-
-
- - -
- - - - - - - 2023-09-15T07:33:03.272875 - image/svg+xml - - - Matplotlib v3.7.2, https://matplotlib.org/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
- -
-
-
- -
-
- - - \ No newline at end of file diff --git a/examples/sample_plots.py b/examples/sample_plots.py deleted file mode 100644 index aa11492..0000000 --- a/examples/sample_plots.py +++ /dev/null @@ -1,62 +0,0 @@ -"""This example shows different libraries used for plotting.""" -import altair as alt -import matplotlib.pyplot as plt -import numpy as np -import pandas as pd -import plotly.express as px - -import pyreball as pb -import seaborn as sns -from bokeh.models import ColumnDataSource -from bokeh.plotting import figure - -pb.set_title("Sample Plots") - -pb.print_div( - "All supported plots are embedded directly into the final HTML file, except matplotllib plots " - "with png format. For such plots, a folder with png images is created." -) - -df = pd.DataFrame({"x": np.array([1, 2, 3]), "y": np.array([4, 3, 6])}) -pb.print_table(df, caption="Data table.") - -# seaborn -fig, ax = plt.subplots() -sns.barplot(x="x", y="y", data=df, ax=ax, color=sns.xkcd_rgb["windows blue"]) -ax.set(xlabel="x", ylabel="y") -pb.print_figure( - fig, caption="Seaborn barchart as png.", matplotlib_format="png", embedded=False -) - -fig, ax = plt.subplots() -sns.barplot(x="x", y="y", data=df, ax=ax, color=sns.xkcd_rgb["windows blue"]) -ax.set(xlabel="x", ylabel="y") -pb.print_figure(fig, caption="Seaborn barchart as embedded svg.") - -# altair -fig = ( - alt.Chart(df) - .mark_bar() - .encode( - x=alt.X("x", type="nominal", sort=None, title="x"), - y=alt.Y("y", type="quantitative", title="y"), - tooltip=["x", "y"], - ) - .configure_axisX(labelAngle=-45) - .properties( - width=800, - height=480, - ) -) -pb.print_figure(fig, caption="Altair barchart.") - -# plotly -fig = px.bar(df, x="x", y="y") -pb.print_figure(fig, caption="Plotly graph.") - -# bokeh -df_bokeh = df.copy() -df_bokeh["x"] = df_bokeh["x"].astype(str) -fig = figure(x_range=df_bokeh["x"]) -fig.vbar(x="x", top="y", width=0.9, source=ColumnDataSource(data=df_bokeh)) -pb.print_figure(fig, caption="Bokeh barchart.") diff --git a/examples/simple.html b/examples/simple.html deleted file mode 100644 index 756e4ef..0000000 --- a/examples/simple.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - -Simple report - - - - -
-

Simple report

-1  Heading
-

1  Heading

-
This is my div with important text.
-
- - - \ No newline at end of file diff --git a/examples/simple.py b/examples/simple.py deleted file mode 100644 index 69d4623..0000000 --- a/examples/simple.py +++ /dev/null @@ -1,8 +0,0 @@ -"""This is a trivial example that does need any 3rd party dependencies.""" -import pyreball as pb - -pb.set_title("Simple report") - -pb.print_h1("Heading") - -pb.print_div(f"This is my div with {pb.bold('important')} text.")