<jupyter_start><jupyter_text>Previews--------Previews are typically invoked before running the often time-consuming generation process triggered by:meth:`.ContainerFlowGenerationManager.generate`.A preview provides a first impression on what kind of data will be generated based on the input distributions and schedules.At this stage, some simplifications are made to actually save some time.Among others, no container instances are generated and operational constraints are neglected.The steps are explained according to the database created by the`demo script for CTA `_ ,but you can still use any other ConFlowGen database.<jupyter_code>import datetime

from IPython.display import Markdown
import matplotlib
import matplotlib.pyplot as plt

import conflowgen

database_chooser = conflowgen.DatabaseChooser(
    sqlite_databases_directory="./data/prepared_dbs"  # subdirectory relative to Jupyter Notebook
)
database_chooser.load_existing_sqlite_database("demo_deham_cta.sqlite")<jupyter_output><empty_output><jupyter_text>Instantiating a PreviewEach preview is a standardized approach of how the data existent in the database is digested.The resulting objects are part of the API but it requires some programming to further work with them.<jupyter_code>inbound_and_outbound_vehicle_capacity_preview = conflowgen.InboundAndOutboundVehicleCapacityPreview(
    start_date=datetime.date(2021, 7, 1),
    end_date=datetime.date(2021, 7, 31),
    transportation_buffer=0.2
)
display(inbound_and_outbound_vehicle_capacity_preview.get_inbound_capacity_of_vehicles())
outbound_capacities = inbound_and_outbound_vehicle_capacity_preview.get_outbound_capacity_of_vehicles()
display(outbound_capacities.used)
display(outbound_capacities.maximum)<jupyter_output><empty_output><jupyter_text>Instantiating a Preview ReportThe data structures returned by a preview are further digestible by code.If you, however, prefer to have the data in a format better to read, you might rather look for the report.For every preview, a corresponding report exists.It auto-fills the parameters for the preview with the data already stored in the database.Thus, we do not need to provide a `start_date`, `end_date`, or a `transportation_buffer`.<jupyter_code>preview_report = conflowgen.InboundAndOutboundVehicleCapacityPreviewReport()
print(preview_report.get_report_as_text())<jupyter_output><empty_output><jupyter_text>Instead of reading tables, one might prefer to see the data visualized.Occasionally, the visualization and text of some reports will be slightly different, but here they complement each other well.<jupyter_code>preview_report.show_report_as_graph()<jupyter_output><empty_output><jupyter_text>Furthermore, there is also the option to obtain the graph as an object without it being plotted.This allows you to further manipulate the visuals according to your needs.Each report might return a different kind of object, so please check the documentation of the respective report.<jupyter_code>plt_ax = preview_report.get_report_as_graph()

rectangles = list(filter(lambda x: isinstance(x, matplotlib.patches.Rectangle), plt_ax.get_children()))

first_bar = rectangles[0]

first_bar.set_color("black")

plt.show()<jupyter_output><empty_output><jupyter_text>For more informaiton on this preview report, please check:class:`.InboundAndOutboundVehicleCapacityPreviewReport`.A list of all previews including their corresponding reports shipped with ConFlowGen is available at:ref:`Getting previews`.<jupyter_code>### Showing all Previews as Text

Following the approach sketched out above, you could generate every preview report you are interested in.
If you are interested in all of then, a convencience function exists.
It can simply print all information to the standard output.<jupyter_output><empty_output><jupyter_text>conflowgen.run_all_previews(    as_text=True,    display_text_func=print,)<jupyter_code>### Displaying Previews as Graphs

The same is possible for the graph reports.
For emphasis, in the following the text version and graph version of the report are presented side-by-side.
In addition, we also use the Markdown capabilities of the convenience function.
This makes the presented previews blend into the remaining content.<jupyter_output><empty_output><jupyter_text>conflowgen.run_all_previews(    as_text=True,    as_graph=True,    display_text_func=lambda text: display(Markdown(text)),    display_in_markup_language="markdown",    static_graphs=True)<jupyter_code>Formulating Your Own Previews
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A preview is a description of what the output is expected to look like before it is actually generated.
Some previews are already shipped with ConFlowGen and more are planned in the future.
If you have an idea for a preview that might be worth sharing, please have a look at
:ref:`Contributing`.
In addition, it is suggested to cross-check your expectations separately, e.g. by usind spreadsheets or simple pen and paper.<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06372745490981964, 'fraction_numerical': 0.0032064128256513026, 'mean_word_length': 6.884676145339652, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '398904', 'license': 'MIT', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1340, 'n_words': 498, 'path': 'docs/notebooks/previews.ipynb', 'repo_name': '1kastner/conflowgen', 'size': '4990'}