Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
- Switches to furo theme (#47)
- Updates examples to new style (#51, #67)
- Adds new examples (#54, #55, #58)
- Marks the documentation unstable (#72)

Signed-off-by: John Pennycook <[email protected]>
  • Loading branch information
Pennycook committed Oct 18, 2024
1 parent 0c50550 commit e5f1d77
Show file tree
Hide file tree
Showing 160 changed files with 20,378 additions and 3,765 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -26,7 +15,7 @@
},
"outputs": [],
"source": [
"import matplotlib as mpl\nimport matplotlib.pyplot as plt\nimport pandas as pd\n\nimport p3\n\n# Initialize synthetic performance efficiency data\n# (not shown, but available in script download)\n\n# Read performance efficiency data into pandas DataFrame\ndf = pd.DataFrame(data)\n\n# Generate a cascade plot\nfig = plt.figure(figsize=(6, 5))\nax = p3.plot.cascade(df)\nplt.savefig(\"cascade.png\", bbox_inches=\"tight\")"
"# Initialize synthetic performance efficiency data\n# (not shown, but available in script download)\n\n# Read performance efficiency data into pandas DataFrame\ndf = pd.DataFrame(data)\n\n# Generate a cascade plot\ncascade = p3analysis.plot.cascade(df, size=(6, 5))\ncascade.save(\"cascade.png\")"
]
}
],
Expand All @@ -46,7 +35,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Customized Navigation Chart\n\nA customized navigation chart.\n\nIn this example, we show how to customize a navigation chart by increasing the\nnumber of axis ticks and by annotating one of the datapoints. Adjusting the\nnumber of axis ticks can improve a reader's ability to discern between two\nsimilar values, while annotations can be useful to draw attention to certain\npoints and/or provide some additional context.\n\nInstead of trying to expose all possible customization options as arguments to\n:py:func:`p3analysis.plot.navchart`, the function returns a\n:py:class:`p3analysis.plot.NavChart` object that provides direct access to library\ninternals. When using the :py:mod:`matplotlib` backend it is possible to\naccess the :py:class:`matplotlib.axes.Axes` that were used and subsequently\ncall any number of :py:mod:`matplotlib` functions. In our example, we can\nuse :py:meth:`matplotlib.axes.Axes.set_xticks` and\n:py:meth:`matplotlib.axes.Axes.set_yticks` to control the ticks, and can use\n:py:meth:`matplotlib.axes.Axes.annotate` for annotations.\n\n.. NOTE::\n :py:mod:`matplotlib` is currently the only backend supported by the P3\n Analysis Library, but this is subject to change.\n\n.. TIP::\n If you have any trouble customizing a navigation chart, or the\n :py:class:`~p3analysis.plot.backend.NavChart` object does not provide access to the\n internals you are looking for, then please [open an issue](https://github.com/intel/p3-analysis-library/issues/new/choose).\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Initialize synthetic data\n# (not shown, but available in script download)\n\n# Read performance portability and code divergence data into pandas DataFrame\npp = pd.DataFrame(pp_data)\ncd = pd.DataFrame(cd_data)\n\n# Generate a navigation chart with custom style options\nlegend = p3analysis.plot.Legend(loc=\"center left\", bbox_to_anchor=(1.0, 0.5))\nastyle = p3analysis.plot.ApplicationStyle(markers=[\"x\", \"*\", \"s\", \"o\", \"P\"])\nnavchart = p3analysis.plot.navchart(pp, cd, size=(5, 5), legend=legend, style=astyle)\n\n# Further customize the navigation chart using matplotlib\n# In this example, we add a label and adjust the ticks\nax = navchart.get_axes()\nax.annotate(\n \"Balances performance and code re-use.\",\n xy=(0.7, 0.7),\n xytext=(0.2, 0.55),\n arrowprops=dict(facecolor='black', shrink=0.05),\n)\nax.set_xticks([x * 0.1 for x in range(0, 11)])\nax.set_yticks([y * 0.1 for y in range(0, 11)])\n\nnavchart.save(\"customized-navchart.png\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@
.. _Interpreting and Visualizing Performance Portability Metrics: https://doi.org/10.1109/P3HPC51967.2020.00007
"""

import matplotlib as mpl
import matplotlib.pyplot as plt
import pandas as pd

import p3

# Initialize synthetic performance efficiency data
# (not shown, but available in script download)
# sphinx_gallery_start_ignore
from collections import defaultdict

import pandas as pd

import p3analysis

data = defaultdict(list)
for (i, platform) in enumerate(["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]):
data["problem"] += ["Synthetic"] * 6
Expand Down Expand Up @@ -71,6 +69,5 @@
df = pd.DataFrame(data)

# Generate a cascade plot
fig = plt.figure(figsize=(6, 5))
ax = p3.plot.cascade(df)
plt.savefig("cascade.png", bbox_inches="tight")
cascade = p3analysis.plot.cascade(df, size=(6, 5))
cascade.save("cascade.png")
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -33,14 +22,14 @@
},
"outputs": [],
"source": [
"# import libraries\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport p3\n\n\n# Load performance data from BabelStream results\ndf = pd.read_csv(performance_csv)"
"# Load performance data from BabelStream results\ndf = pd.read_csv(performance_csv)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Project Labels into Expected Forms\nThe :py:func:`p3.data.projection` method can be used to project column names\nfrom the original data into names required by the P3 Analysis Library.\n\n"
"## Project Labels into Expected Forms\nThe :py:func:`p3analysis.data.projection` method can be used to project column names\nfrom the original data into names required by the P3 Analysis Library.\n\n"
]
},
{
Expand All @@ -51,7 +40,7 @@
},
"outputs": [],
"source": [
"df = p3.data.projection(\n df, problem=[\"name\"], platform=[\"arch\"], application=[\"language\"]\n)"
"df = p3analysis.data.projection(\n df, problem=[\"name\"], platform=[\"arch\"], application=[\"language\"],\n)"
]
},
{
Expand All @@ -76,7 +65,7 @@
},
"outputs": [],
"source": [
"effs = p3.metrics.application_efficiency(df)\nprint(effs)"
"effs = p3analysis.metrics.application_efficiency(df)\nprint(effs)"
]
},
{
Expand All @@ -94,7 +83,7 @@
},
"outputs": [],
"source": [
"fig = plt.figure(figsize=(6, 5))\nax = p3.plot.cascade(effs) \nplt.savefig(\"cascade.png\", bbox_inches=\"tight\")"
"cascade = p3analysis.plot.cascade(effs)\ncascade.save(\"cascade.png\")"
]
},
{
Expand All @@ -121,7 +110,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env python3
# Copyright (c) 2023 Intel Corporation
# SPDX-License-Identifier: 0BSD
"""
Customized Navigation Chart
===========================
A customized navigation chart.
In this example, we show how to customize a navigation chart by increasing the
number of axis ticks and by annotating one of the datapoints. Adjusting the
number of axis ticks can improve a reader's ability to discern between two
similar values, while annotations can be useful to draw attention to certain
points and/or provide some additional context.
Instead of trying to expose all possible customization options as arguments to
:py:func:`p3analysis.plot.navchart`, the function returns a
:py:class:`p3analysis.plot.NavChart` object that provides direct access to library
internals. When using the :py:mod:`matplotlib` backend it is possible to
access the :py:class:`matplotlib.axes.Axes` that were used and subsequently
call any number of :py:mod:`matplotlib` functions. In our example, we can
use :py:meth:`matplotlib.axes.Axes.set_xticks` and
:py:meth:`matplotlib.axes.Axes.set_yticks` to control the ticks, and can use
:py:meth:`matplotlib.axes.Axes.annotate` for annotations.
.. NOTE::
:py:mod:`matplotlib` is currently the only backend supported by the P3
Analysis Library, but this is subject to change.
.. TIP::
If you have any trouble customizing a navigation chart, or the
:py:class:`~p3analysis.plot.backend.NavChart` object does not provide access to the
internals you are looking for, then please `open an issue
<https://github.com/intel/p3-analysis-library/issues/new/choose>`_.
"""

# Initialize synthetic data
# (not shown, but available in script download)
# sphinx_gallery_start_ignore
from collections import defaultdict

import matplotlib.pyplot as plt
import pandas as pd

import p3analysis

pp_data = defaultdict(list)
cd_data = defaultdict(list)
for data in [pp_data, cd_data]:
data["problem"] += ["Synthetic"] * 5
data["application"] += [
"Unportable",
"Ideal",
"Per-Platform Source",
"Portability Framework",
"Specialized",
]
pp_data["app pp"] += [0, 1, 1, 0.5, 0.7]
cd_data["divergence"] += [1, 0, 1, 0, 0.3]
# sphinx_gallery_end_ignore

# Read performance portability and code divergence data into pandas DataFrame
pp = pd.DataFrame(pp_data)
cd = pd.DataFrame(cd_data)

# Generate a navigation chart with custom style options
legend = p3analysis.plot.Legend(loc="center left", bbox_to_anchor=(1.0, 0.5))
astyle = p3analysis.plot.ApplicationStyle(markers=["x", "*", "s", "o", "P"])
navchart = p3analysis.plot.navchart(pp, cd, size=(5, 5), legend=legend, style=astyle)

# Further customize the navigation chart using matplotlib
# In this example, we add a label and adjust the ticks
ax = navchart.get_axes()
ax.annotate(
"Balances performance and code re-use.",
xy=(0.7, 0.7),
xytext=(0.2, 0.55),
arrowprops=dict(facecolor='black', shrink=0.05),
)
ax.set_xticks([x * 0.1 for x in range(0, 11)])
ax.set_yticks([y * 0.1 for y in range(0, 11)])

navchart.save("customized-navchart.png")
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Customized Cascade\n\nA customized cascade plot.\n\nIn this example, we show how to customize a cascade plot by changing the limits\nof the y-axis. Although the default limit (of 1) is useful for comparing many\nplots side-by-side, in practice it is often useful to be able to zoom-in on\nspecific regions of data. For example, when dealing with applications that do\nnot achieve very high levels of architectural efficiency, setting a lower\nmaximum value for the y-axis can improve readability.\n\nInstead of trying to expose all possible customization options as arguments to\n:py:func:`p3analysis.plot.cascade`, the function returns a\n:py:class:`p3analysis.plot.CascadePlot` object that provides direct access to library\ninternals. When using the :py:mod:`matplotlib` backend it is possible to\naccess the :py:class:`matplotlib.axes.Axes` that were used and subsequently\ncall any number of :py:mod:`matplotlib` functions. In our example, we can\nuse :py:meth:`matplotlib.axes.Axes.set_ylim` to update the y-axis.\n\n.. NOTE::\n :py:mod:`matplotlib` is currently the only backend supported by the P3\n Analysis Library, but this is subject to change.\n\n.. TIP::\n If you have any trouble customizing a plot, or the\n :py:class:`~p3analysis.plot.backend.CascadePlot` object does not provide access to\n the internals you are looking for, then please [open an issue](https://github.com/intel/p3-analysis-library/issues/new/choose).\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Initialize synthetic performance efficiency data\n# (not shown, but available in script download)\n\n# Read performance efficiency data into pandas DataFrame\ndf = pd.DataFrame(data)\n\n# Generate a cascade plot with custom style options\nlegend = p3analysis.plot.Legend(loc=\"center left\", bbox_to_anchor=(0.91, 0.225), ncols=2)\npstyle = p3analysis.plot.PlatformStyle(colors=\"GnBu\")\nastyle = p3analysis.plot.ApplicationStyle(markers=[\"x\", \"s\", \"p\", \"h\", \"H\", \"v\"])\ncascade = p3analysis.plot.cascade(df, size=(6, 5), platform_legend=legend, platform_style=pstyle, application_style=astyle)\n\n# Further customize the cascade plot using matplotlib\n# In this example, we adjust the range of the y-axis to improve readability\n# This may be necessary for studies using architectural efficiency\ncascade.get_axes(\"eff\").set_ylim([0, 0.12])\ncascade.get_axes(\"pp\").set_ylim([0, 0.12])\n\ncascade.save(\"customized-cascade.png\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -26,7 +15,7 @@
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\nimport pandas as pd\n\nimport p3\n\n# Initialize synthetic data\n# (not shown, but available in script download)\n\n# Read performance portability and code divergence data into pandas DataFrame\npp = pd.DataFrame(pp_data)\ncd = pd.DataFrame(cd_data)\n\n# Generate a navigation chart\nfig = plt.figure(figsize=(5, 5))\nax = p3.plot.navchart(pp, cd)\nplt.savefig(\"navchart.png\")"
"# Initialize synthetic data\n# (not shown, but available in script download)\n\n# Read performance portability and code divergence data into pandas DataFrame\npp = pd.DataFrame(pp_data)\ncd = pd.DataFrame(cd_data)\n\n# Generate a navigation chart\nnavchart = p3analysis.plot.navchart(pp, cd, size=(5, 5))\nnavchart.save(\"navchart.png\")"
]
}
],
Expand All @@ -46,7 +35,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit e5f1d77

Please sign in to comment.