Compute fragments
ComputeFragmentsMixin
¶
alert
staticmethod
¶
alert(headline, message, style=..., show=True, help_text='')
Adds an alert to the calculation report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The headline of the alert, displayed prominently in bold. |
required |
|
str
|
The detailed message of the alert. |
required |
|
str
|
The style of the alert. Defaults to AlertStyle.Normal. |
...
|
|
bool
|
Whether the alert is visible in the report. Default is True. |
True
|
|
str
|
Tooltip text to display in the web app. Default is an empty string. |
''
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Examples:
1 2 3 4 5 | |
calc
staticmethod
¶
calc(key, equation=None, value=None, description='', reference='', unit='', format_str='{:.4g}', show=True, help_text='', override_previous=False)
Adds a calculation to the report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
A unique identifier for the calculation. |
required |
|
Optional[str]
|
The equation to compute. Variables must match previously defined keys. |
None
|
|
Optional[NumericValueT]
|
The numerical value of the calculation. Default is None. |
None
|
|
str
|
A description of the calculation. Default is an empty string. |
''
|
|
str
|
A reference or citation for the calculation. Default is an empty string. |
''
|
|
str
|
The unit of the calculation result. Default is an empty string. |
''
|
|
str
|
The format string for displaying the result. Default is '{:.4g}'. |
'{:.4g}'
|
|
bool
|
Whether the calculation is visible in the report. Default is True. |
True
|
|
str
|
Tooltip text to display in the web app. Default is an empty string. |
''
|
|
bool
|
Whether to override a previously defined calculation with the same key. Default is False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
NumericValueT |
NumericValueT
|
The computed value of the calculation. |
Examples:
1 2 3 4 5 6 | |
collapsible
staticmethod
¶
collapsible(end=False, title='', show=True, help_text='')
Adds a container collapsible to the calculation report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Marks whether the container has ended or not. Default = False. |
False
|
|
str
|
Text to show in the collapsible bar. Default = "". |
''
|
|
bool
|
Whether the image is visible in the app. Defaults to True. |
True
|
|
str
|
Tooltip text to display in the web app. Defaults to an empty string. |
''
|
Returns:
| Type | Description |
|---|---|
None
|
None |
dataframe
staticmethod
¶
dataframe(key, data, show_index=False, description='', show=True, help_text='')
Adds a dataFrame to the report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
A unique identifier for the DataFrame. |
required |
|
DataFrame
|
The DataFrame to be added to the report. |
required |
|
bool
|
Whether to include the index in the displayed DataFrame. Defaults to False. |
False
|
|
str
|
A description of the DataFrame. Defaults to an empty string. |
''
|
|
bool
|
Whether the DataFrame is visible in the report. Defaults to True. |
True
|
|
str
|
Tooltip text to display in the web app. Defaults to an empty string. |
''
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: The processed DataFrame (with or without the index, based on |
decision
staticmethod
¶
decision(key, calc_key, headlines=None, messages=None, role_styles=None, util_bands=None, show_base_calc=False, description='', show=True, help_text='')
Adds a decision to the calculation report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
A unique identifier for the decision. |
required |
|
str
|
The key of the calculation this decision is based on. |
required |
|
Optional[List[str]]
|
A list of headline strings for the decision. Defaults to None. |
None
|
|
Optional[List[str]]
|
A list of messages corresponding to the decision. Defaults to None. |
None
|
|
Optional[List[AlertStyle]]
|
A list of styles for each role in the decision. Defaults to None. |
None
|
|
Optional[List[float]]
|
Utility bands for decision thresholds. Defaults to None. |
None
|
|
bool
|
Whether to show the base calculation in the report. Defaults to False. |
False
|
|
str
|
A description of the calculation. Default is an empty string. |
''
|
|
bool
|
Whether the decision is visible in the report. Defaults to True. |
True
|
|
str
|
Tooltip text to display in the web app. Defaults to an empty string. |
''
|
Returns:
| Type | Description |
|---|---|
None
|
None |
image
staticmethod
¶
image(image_filename, is_local=True, width=450, caption='', label='', image_renderer=None, description='', show=True, help_text='')
Adds an image to the calculation report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The name of the image file to be added. |
required |
|
bool
|
Whether the image is stored locally in the app folder or in the shared folder. Defaults to True. |
True
|
|
int
|
The width of the image in pixels. Defaults to 450. |
450
|
|
str
|
A caption for the image. Defaults to an empty string. |
''
|
|
str
|
A label for the image. Defaults to an empty string. |
''
|
|
Optional[ImageRendererBase]
|
The renderer to use for the image.
If not provided, defaults to |
None
|
|
str
|
A description of the image. Defaults to an empty string. |
''
|
|
bool
|
Whether the image is visible in the app. Defaults to True. |
True
|
|
str
|
Tooltip text to display in the web app. Defaults to an empty string. |
''
|
Returns:
| Type | Description |
|---|---|
None
|
None |
plotly_chart
staticmethod
¶
plotly_chart(key, figure, width_override=None, description='', caption='', show=True, new_window_only=False, help_text='')
Adds a Plotly chart to the report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
A unique identifier for the chart. |
required |
|
Figure
|
The Plotly figure to be added to the report. |
required |
|
Optional[int]
|
Overrides the default width of the chart. Defaults to None. |
None
|
|
str
|
The description of the chart. Defaults to an empty string. |
''
|
|
str
|
A caption for the chart. Defaults to an empty string. |
''
|
|
bool
|
Whether the chart is visible in the report. Defaults to True. |
True
|
|
bool
|
If True, the chart will only be displayed in a new window. Defaults to False. |
False
|
|
str
|
Tooltip text to display in the web app. Defaults to an empty string. |
''
|
Returns:
| Type | Description |
|---|---|
None
|
None |
plotly_chart_many
staticmethod
¶
plotly_chart_many(key, figures, description='', captions='', labels='', width_override=None, show=True, new_window_only=False, help_text='')
Adds Multiple Plotly charts to the calculation report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
A unique identifier for the chart. |
required |
|
List[Figure]
|
The Plotly figures to be added to the report. |
required |
|
str
|
The description of the group of charts. Defaults to an empty string. |
''
|
|
Optional[int]
|
Overrides the default width of all charts. Defaults to None. |
None
|
|
Optional[List[str]]
|
The titles of the plotly charts. Defaults to a list of empty strings. |
''
|
|
Optional[List[str]]
|
The captions for each plotly chart. Defaults to a list of empty strings. |
''
|
|
bool
|
Whether the chart is visible. Defaults to True. |
True
|
|
bool
|
If True, the charts will only be displayed in a new window. Defaults to False. |
False
|
|
str
|
Tooltip text to display in the web app. Defaults to an empty string. |
''
|
Returns:
| Type | Description |
|---|---|
None
|
None |
pyplot
staticmethod
¶
pyplot(figure, width=450, caption='', label='', description='', show=True, is_expanded=True, help_text='')
Adds a Matplotlib figure to the calculation report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Figure
|
The Matplotlib figure to be added to the report. |
required |
|
int
|
The width of the figure in pixels. Defaults to 450. |
450
|
|
str
|
A caption for the figure. Defaults to an empty string. |
''
|
|
str
|
A label for the figure. Defaults to an empty string. |
''
|
|
str
|
A description of the figure. Defaults to an empty string. |
''
|
|
bool
|
Whether the figure is visible in the report. Defaults to True. |
True
|
|
bool
|
Whether the figure is displayed in an expandable view. Defaults to True. |
True
|
|
str
|
Tooltip text to display in the web app. Defaults to an empty string. |
''
|
Returns:
| Type | Description |
|---|---|
None
|
None |
write
staticmethod
¶
write(text, style=None, show=True, help_text='')
Adds a text element to the calculation report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The string to represent within the calculation report. |
required |
|
Optional[str]
|
The style of the text. Options are ["p", "h1", "h2", "h3", "h4", "h5", "h6"]. If no style is provided, the text will be rendered in Markdown. Default is None. |
None
|
|
bool
|
Whether the component is visible in the report. Default is True. |
True
|
|
str
|
Tooltip text to display in the web app. Default is an empty string. |
''
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Examples:
1 | |