diff --git a/.github/workflows/build-unittest.yml b/.github/workflows/build-unittest.yml index 5998c49..0609c6f 100644 --- a/.github/workflows/build-unittest.yml +++ b/.github/workflows/build-unittest.yml @@ -8,14 +8,14 @@ on: push: branches: [ "main" ] paths: - - 'p3/**' + - 'p3analysis/**' - 'tests/**' - 'pyproject.toml' - 'MANIFEST.in' pull_request: branches: [ "main" ] paths: - - 'p3/**' + - 'p3analysis/**' - 'tests/**' - 'pyproject.toml' - 'MANIFEST.in' @@ -31,7 +31,7 @@ jobs: uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - - name: Install p3 and its dependencies + - name: Install p3analysis and its dependencies run: pip install --no-cache-dir './[dev]' - name: Run unittest run: python -m unittest discover -s tests --verbose diff --git a/.github/workflows/test-gallery.yml b/.github/workflows/test-gallery.yml index 33681fe..766077f 100644 --- a/.github/workflows/test-gallery.yml +++ b/.github/workflows/test-gallery.yml @@ -9,7 +9,7 @@ on: push: branches: [ "main" ] paths: - - 'p3/**' + - 'p3analysis/**' - 'examples/**' - 'case-studies/**' - 'pyproject.toml' @@ -17,7 +17,7 @@ on: pull_request: branches: [ "main" ] paths: - - 'p3/**' + - 'p3analysis/**' - 'examples/**' - 'case-studies/**' - 'pyproject.toml' @@ -35,7 +35,7 @@ jobs: uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - - name: Install p3 and its dependencies + - name: Install p3analysis and its dependencies run: pip install --no-cache-dir './[dev]' - name: Run examples run: | diff --git a/case-studies/babelstream/plot_babelstream_cascade.py b/case-studies/babelstream/plot_babelstream_cascade.py index 214fd18..9a1726c 100644 --- a/case-studies/babelstream/plot_babelstream_cascade.py +++ b/case-studies/babelstream/plot_babelstream_cascade.py @@ -20,12 +20,14 @@ # Load Data into Pandas # --------------------- +#sphinx_gallery_start_ignore +import os + # import libraries import pandas as pd -import p3 -#sphinx_gallery_start_ignore -import os +import p3analysis + dpath = os.path.realpath(os.getcwd()) performance_csv = os.path.join(dpath, "performance.csv") #sphinx_gallery_end_ignore @@ -36,11 +38,11 @@ # %% # Project Labels into Expected Forms # ---------------------------------- -# The :py:func:`p3.data.projection` method can be used to project column names +# The :py:func:`p3analysis.data.projection` method can be used to project column names # from the original data into names required by the P3 Analysis Library. -df = p3.data.projection( - df, problem=["name"], platform=["arch"], application=["language"] +df = p3analysis.data.projection( + df, problem=["name"], platform=["arch"], application=["language"], ) # %% @@ -67,14 +69,14 @@ # (problem, platform) combination; any row with an `app eff` of 1 represents # an application achieving the best-known performance. -effs = p3.metrics.application_efficiency(df) +effs = p3analysis.metrics.application_efficiency(df) print(effs) # %% # Generate a Cascade Plot # ----------------------- -cascade = p3.plot.cascade(effs) +cascade = p3analysis.plot.cascade(effs) cascade.save("cascade.png") # %% diff --git a/case-studies/babelstream/plot_babelstream_navchart.py b/case-studies/babelstream/plot_babelstream_navchart.py index 4c4ba59..67e2b33 100644 --- a/case-studies/babelstream/plot_babelstream_navchart.py +++ b/case-studies/babelstream/plot_babelstream_navchart.py @@ -16,12 +16,14 @@ # Load Data into Pandas # --------------------- +#sphinx_gallery_start_ignore +import os + # import libraries import pandas as pd -import p3 -#sphinx_gallery_start_ignore -import os +import p3analysis + dpath = os.path.realpath(os.getcwd()) performance_csv = os.path.join(dpath, "performance.csv") coverage_csv = os.path.join(dpath, "coverage.csv") @@ -40,11 +42,11 @@ # %% # Project Labels into Expected Forms # ---------------------------------- -# The :py:func:`p3.data.projection` method can be used to project column names +# The :py:func:`p3analysis.data.projection` method can be used to project column names # from the original data into names required by the P3 Analysis Library. -df = p3.data.projection( - df, problem=["name"], platform=["arch"], application=["language"] +df = p3analysis.data.projection( + df, problem=["name"], platform=["arch"], application=["language"], ) # %% @@ -74,7 +76,7 @@ # (problem, platform) combination; any row with an `app eff` of 1 represents # an application achieving the best-known performance. -effs = p3.metrics.application_efficiency(df) +effs = p3analysis.metrics.application_efficiency(df) print(effs) # %% @@ -85,7 +87,7 @@ # has a non-zero divergence, as it is the only implementation containing # different code paths for different platforms. -div = p3.metrics.divergence(df, df_cov) +div = p3analysis.metrics.divergence(df, df_cov) print(div) # %% @@ -96,14 +98,14 @@ # to achieve a non-zero performance portability score. For BabelStream, # Language 0 is the only programming model that runs across all 11 platforms. -pp = p3.metrics.pp(effs) +pp = p3analysis.metrics.pp(effs) print(pp) # %% # Generate a Navigation Chart # --------------------------- -navchart = p3.plot.navchart(pp, div) +navchart = p3analysis.plot.navchart(pp, div) navchart.save("navchart.png") # %% diff --git a/docs/source/analysis.rst b/docs/source/analysis.rst index 44d1034..2876d17 100644 --- a/docs/source/analysis.rst +++ b/docs/source/analysis.rst @@ -41,5 +41,5 @@ The terminology used by the P3 Analysis Library was first introduced in Some of these definitions are flexible, allowing the same performance data to be used for multiple case studies with different interpretations of these terms. The library is designed with this flexibility in mind (see -:py:func:`p3.data.projection`); concrete definitions are not required when +:py:func:`p3analysis.data.projection`); concrete definitions are not required when collecting data. diff --git a/docs/source/data.rst b/docs/source/data.rst index d507a6c..d4da415 100644 --- a/docs/source/data.rst +++ b/docs/source/data.rst @@ -37,7 +37,7 @@ The following fields have special meaning: It is recommended not to store *application*, *problem* and *platform* fields when results are initially collected, and to instead construct them using the -:py:func:`p3.data.projection` function. This makes it simpler to re-use the +:py:func:`p3analysis.data.projection` function. This makes it simpler to re-use the same data across multiple analyses using different meanings of *application*, *problem*, and *platform*. diff --git a/docs/source/index.rst b/docs/source/index.rst index a910408..6380f4a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -23,7 +23,7 @@ Performance, Portability, and Productivity Analysis Library :hidden: :caption: Reference - p3 + p3analysis .. toctree:: :maxdepth: 1 @@ -38,11 +38,11 @@ The Performance, Portability, and Productivity Analysis Library (P3 Analysis Library) enables a simpler workflow for the collection and interpretation of P3 data. -- Compute :doc:`metrics ` like "performance portability" and +- Compute :doc:`metrics ` like "performance portability" and "code divergence" to quantify the trade-offs between performance, portability and productivity made by applications targeting multiple platforms. -- :doc:`Plot ` cascades and navigation charts to visualize and gain +- :doc:`Plot ` cascades and navigation charts to visualize and gain deeper insight into the "performance portability" and "code divergence" scores achieved by different applications. diff --git a/docs/source/modules.rst b/docs/source/modules.rst index d3bc919..ada94ff 100644 --- a/docs/source/modules.rst +++ b/docs/source/modules.rst @@ -1,7 +1,7 @@ -p3 -== +p3analysis +========== .. toctree:: :maxdepth: 4 - p3 + p3analysis diff --git a/docs/source/p3.plot.backend.rst b/docs/source/p3.plot.backend.rst deleted file mode 100644 index 7c1c116..0000000 --- a/docs/source/p3.plot.backend.rst +++ /dev/null @@ -1,29 +0,0 @@ -p3.plot.backend package -======================= - -Submodules ----------- - -p3.plot.backend.matplotlib module ---------------------------------- - -.. automodule:: p3.plot.backend.matplotlib - :members: - :undoc-members: - :show-inheritance: - -p3.plot.backend.pgfplots module -------------------------------- - -.. automodule:: p3.plot.backend.pgfplots - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: p3.plot.backend - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/source/p3.plot.rst b/docs/source/p3.plot.rst deleted file mode 100644 index f539090..0000000 --- a/docs/source/p3.plot.rst +++ /dev/null @@ -1,18 +0,0 @@ -p3.plot package -=============== - -Subpackages ------------ - -.. toctree:: - :maxdepth: 4 - - p3.plot.backend - -Module contents ---------------- - -.. automodule:: p3.plot - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/source/p3.report.rst b/docs/source/p3.report.rst deleted file mode 100644 index dc5bf95..0000000 --- a/docs/source/p3.report.rst +++ /dev/null @@ -1,10 +0,0 @@ -p3.report package -================= - -Module contents ---------------- - -.. automodule:: p3.report - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/source/p3.data.rst b/docs/source/p3analysis.data.rst similarity index 52% rename from docs/source/p3.data.rst rename to docs/source/p3analysis.data.rst index 966bd62..bd82026 100644 --- a/docs/source/p3.data.rst +++ b/docs/source/p3analysis.data.rst @@ -1,10 +1,10 @@ -p3.data package -=============== +p3analysis.data package +======================= Module contents --------------- -.. automodule:: p3.data +.. automodule:: p3analysis.data :members: :undoc-members: :show-inheritance: diff --git a/docs/source/p3analysis.metrics.rst b/docs/source/p3analysis.metrics.rst new file mode 100644 index 0000000..aa429f9 --- /dev/null +++ b/docs/source/p3analysis.metrics.rst @@ -0,0 +1,10 @@ +p3analysis.metrics package +========================== + +Module contents +--------------- + +.. automodule:: p3analysis.metrics + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/p3analysis.plot.backend.rst b/docs/source/p3analysis.plot.backend.rst new file mode 100644 index 0000000..84a13ff --- /dev/null +++ b/docs/source/p3analysis.plot.backend.rst @@ -0,0 +1,29 @@ +p3analysis.plot.backend package +=============================== + +Submodules +---------- + +p3analysis.plot.backend.matplotlib module +----------------------------------------- + +.. automodule:: p3analysis.plot.backend.matplotlib + :members: + :undoc-members: + :show-inheritance: + +p3analysis.plot.backend.pgfplots module +--------------------------------------- + +.. automodule:: p3analysis.plot.backend.pgfplots + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: p3analysis.plot.backend + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/p3.rst b/docs/source/p3analysis.plot.rst similarity index 57% rename from docs/source/p3.rst rename to docs/source/p3analysis.plot.rst index f968d66..6cd7687 100644 --- a/docs/source/p3.rst +++ b/docs/source/p3analysis.plot.rst @@ -1,5 +1,5 @@ -p3 package -========== +p3analysis.plot package +======================= Subpackages ----------- @@ -7,15 +7,12 @@ Subpackages .. toctree:: :maxdepth: 4 - p3.data - p3.metrics - p3.plot - p3.report + p3analysis.plot.backend Module contents --------------- -.. automodule:: p3 +.. automodule:: p3analysis.plot :members: :undoc-members: :show-inheritance: diff --git a/docs/source/p3.metrics.rst b/docs/source/p3analysis.report.rst similarity index 50% rename from docs/source/p3.metrics.rst rename to docs/source/p3analysis.report.rst index 025ca9e..343ba4c 100644 --- a/docs/source/p3.metrics.rst +++ b/docs/source/p3analysis.report.rst @@ -1,10 +1,10 @@ -p3.metrics package -================== +p3analysis.report package +========================= Module contents --------------- -.. automodule:: p3.metrics +.. automodule:: p3analysis.report :members: :undoc-members: :show-inheritance: diff --git a/docs/source/p3analysis.rst b/docs/source/p3analysis.rst new file mode 100644 index 0000000..ceac7b6 --- /dev/null +++ b/docs/source/p3analysis.rst @@ -0,0 +1,21 @@ +p3analysis package +================== + +Subpackages +----------- + +.. toctree:: + :maxdepth: 4 + + p3analysis.data + p3analysis.metrics + p3analysis.plot + p3analysis.report + +Module contents +--------------- + +.. automodule:: p3analysis + :members: + :undoc-members: + :show-inheritance: diff --git a/examples/cascade/plot_customized_cascade.py b/examples/cascade/plot_customized_cascade.py index c006b79..ca1f691 100755 --- a/examples/cascade/plot_customized_cascade.py +++ b/examples/cascade/plot_customized_cascade.py @@ -15,8 +15,8 @@ maximum value for the y-axis can improve readability. Instead of trying to expose all possible customization options as arguments to -:py:func:`p3.plot.cascade`, the function returns a -:py:class:`p3.plot.CascadePlot` object that provides direct access to library +:py:func:`p3analysis.plot.cascade`, the function returns a +:py:class:`p3analysis.plot.CascadePlot` 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 @@ -28,20 +28,20 @@ .. TIP:: If you have any trouble customizing a plot, or the - :py:class:`~p3.plot.backend.CascadePlot` object does not provide access to + :py:class:`~p3analysis.plot.backend.CascadePlot` object does not provide access to the internals you are looking for, then please `open an issue `_. """ -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 @@ -68,10 +68,10 @@ df = pd.DataFrame(data) # Generate a cascade plot with custom style options -legend = p3.plot.Legend(loc="center left", bbox_to_anchor=(0.91, 0.225), ncols=2) -pstyle = p3.plot.PlatformStyle(colors="GnBu") -astyle = p3.plot.ApplicationStyle(markers=["x", "s", "p", "h", "H", "v"]) -cascade = p3.plot.cascade(df, size=(6, 5), platform_legend=legend, platform_style=pstyle, application_style=astyle) +legend = p3analysis.plot.Legend(loc="center left", bbox_to_anchor=(0.91, 0.225), ncols=2) +pstyle = p3analysis.plot.PlatformStyle(colors="GnBu") +astyle = p3analysis.plot.ApplicationStyle(markers=["x", "s", "p", "h", "H", "v"]) +cascade = p3analysis.plot.cascade(df, size=(6, 5), platform_legend=legend, platform_style=pstyle, application_style=astyle) # Further customize the cascade plot using matplotlib # In this example, we adjust the range of the y-axis to improve readability diff --git a/examples/cascade/plot_simple_cascade.py b/examples/cascade/plot_simple_cascade.py index 47505be..2c51bdb 100755 --- a/examples/cascade/plot_simple_cascade.py +++ b/examples/cascade/plot_simple_cascade.py @@ -32,15 +32,15 @@ .. _Interpreting and Visualizing Performance Portability Metrics: https://doi.org/10.1109/P3HPC51967.2020.00007 """ -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 @@ -69,5 +69,5 @@ df = pd.DataFrame(data) # Generate a cascade plot -cascade = p3.plot.cascade(df, size=(6, 5)) +cascade = p3analysis.plot.cascade(df, size=(6, 5)) cascade.save("cascade.png") diff --git a/examples/metrics/application_efficiency.py b/examples/metrics/application_efficiency.py index 9ad5898..908b5ba 100755 --- a/examples/metrics/application_efficiency.py +++ b/examples/metrics/application_efficiency.py @@ -88,7 +88,7 @@ # %% # After loading this data into a :py:class:`pandas.DataFrame` (`df`), we can -# use the :py:func:`p3.metrics.application_efficiency` function to calculate a +# use the :py:func:`p3analysis.metrics.application_efficiency` function to calculate a # table of application efficiencies. #sphinx_gallery_start_ignore @@ -96,7 +96,7 @@ import numpy as np import pandas as pd -import p3 +import p3analysis myapp_data = { "problem": ["Test"] * 5, @@ -109,7 +109,7 @@ df = pd.DataFrame(myapp_data) #sphinx_gallery_end_ignore -effs = p3.metrics.application_efficiency(df) +effs = p3analysis.metrics.application_efficiency(df) print(effs) # %% @@ -182,7 +182,7 @@ df = pd.concat([df, pd.DataFrame(yourapp_data)], ignore_index=True) #sphinx_gallery_end_ignore -effs = p3.metrics.application_efficiency(df) +effs = p3analysis.metrics.application_efficiency(df) print(effs) # %% @@ -282,7 +282,7 @@ df = pd.concat([df, pd.DataFrame(new_myapp_data)], ignore_index=True) #sphinx_gallery_end_ignore -effs = p3.metrics.application_efficiency(df) +effs = p3analysis.metrics.application_efficiency(df) print(effs) # %% diff --git a/examples/metrics/multiple_components.py b/examples/metrics/multiple_components.py index dff5cd6..8a2eabf 100755 --- a/examples/metrics/multiple_components.py +++ b/examples/metrics/multiple_components.py @@ -94,7 +94,7 @@ import numpy as np import pandas as pd -import p3 +import p3analysis data = { "component": ["Component 1", "Component 2"] * 4, @@ -106,7 +106,7 @@ df = pd.DataFrame(data) # sphinx_gallery_end_ignore -proj = p3.data.projection( +proj = p3analysis.data.projection( df, problem=["component"], application=["implementation"], @@ -125,7 +125,7 @@ # Having projected the performance data onto P3 definitions, we can now compute # the application efficiency for each component: -effs = p3.metrics.application_efficiency(proj) +effs = p3analysis.metrics.application_efficiency(proj) print(effs) # %% @@ -179,7 +179,7 @@ # %% # Then, we can use this data to compute application efficiency, as below: -effs = p3.metrics.application_efficiency(package) +effs = p3analysis.metrics.application_efficiency(package) print(effs) # %% @@ -229,7 +229,7 @@ # by mixing and matching different implementations. And if we now re-compute # application efficiency with this data included: -effs = p3.metrics.application_efficiency(package) +effs = p3analysis.metrics.application_efficiency(package) print(effs) # %% diff --git a/examples/metrics/projection.py b/examples/metrics/projection.py index 2b40115..355cdcc 100755 --- a/examples/metrics/projection.py +++ b/examples/metrics/projection.py @@ -136,7 +136,7 @@ # %% # After loading our data into a :py:class:`pandas.DataFrame` # (``df``), we can use the -# :py:func:`p3.data.projection` function to perform this +# :py:func:`p3analysis.data.projection` function to perform this # projection, renaming the columns as described above. # sphinx_gallery_start_ignore @@ -144,7 +144,7 @@ import matplotlib.pyplot as plt import pandas as pd -import p3 +import p3analysis rename_data = { "size": ["128x128x128", "256x256x256"] * 4, @@ -156,7 +156,7 @@ df = pd.DataFrame(rename_data) # sphinx_gallery_end_ignore -proj = p3.data.projection( +proj = p3analysis.data.projection( df, problem=["size"], application=["implementation"], @@ -166,7 +166,7 @@ # %% # Following projection, our performance data is now ready to be passed to -# functions in the :py:mod:`p3.metrics` module. +# functions in the :py:mod:`p3analysis.metrics` module. # %% # Using Projection to Combine Columns @@ -304,7 +304,7 @@ # Neither of these options is more correct than the other. Rather, they # represent different studies. # -# Both projections can be performed with the :py:func:`p3.data.projection` +# Both projections can be performed with the :py:func:`p3analysis.data.projection` # function, by passing different arguments. # # For the first projection, we now need to specify the names of two columns @@ -322,7 +322,7 @@ df = pd.concat([df, pd.DataFrame(combine_data)], ignore_index=True) # sphinx_gallery_end_ignore -proj1 = p3.data.projection( +proj1 = p3analysis.data.projection( df, problem=["size", "precision"], application=["implementation"], @@ -337,7 +337,7 @@ # For the second projection, we just need to specify "size", exactly as we did # before: -proj2 = p3.data.projection( +proj2 = p3analysis.data.projection( df, problem=["size"], application=["implementation"], diff --git a/examples/navchart/plot_customized_navchart.py b/examples/navchart/plot_customized_navchart.py index 9f00183..9edb1c1 100755 --- a/examples/navchart/plot_customized_navchart.py +++ b/examples/navchart/plot_customized_navchart.py @@ -14,8 +14,8 @@ points and/or provide some additional context. Instead of trying to expose all possible customization options as arguments to -:py:func:`p3.plot.navchart`, the function returns a -:py:class:`p3.plot.NavChart` object that provides direct access to library +: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 @@ -29,21 +29,21 @@ .. TIP:: If you have any trouble customizing a navigation chart, or the - :py:class:`~p3.plot.backend.NavChart` object does not provide access to the + :py:class:`~p3analysis.plot.backend.NavChart` object does not provide access to the internals you are looking for, then please `open an issue `_. """ -import matplotlib.pyplot as plt -import pandas as pd - -import p3 - # 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]: @@ -64,17 +64,19 @@ cd = pd.DataFrame(cd_data) # Generate a navigation chart with custom style options -legend = p3.plot.Legend(loc="center left", bbox_to_anchor=(1.0, 0.5)) -astyle = p3.plot.ApplicationStyle(markers=["x", "*", "s", "o", "P"]) -navchart = p3.plot.navchart(pp, cd, size=(5, 5), legend=legend, style=astyle) +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.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)]) diff --git a/examples/navchart/plot_simple_navchart.py b/examples/navchart/plot_simple_navchart.py index fafcfc1..1b5b72b 100755 --- a/examples/navchart/plot_simple_navchart.py +++ b/examples/navchart/plot_simple_navchart.py @@ -25,15 +25,15 @@ of the P3 space and reasoning about how to reach development goals. """ -import pandas as pd - -import p3 - # Initialize synthetic data # (not shown, but available in script download) # sphinx_gallery_start_ignore from collections import defaultdict +import pandas as pd + +import p3analysis + pp_data = defaultdict(list) cd_data = defaultdict(list) for data in [pp_data, cd_data]: @@ -54,5 +54,5 @@ cd = pd.DataFrame(cd_data) # Generate a navigation chart -navchart = p3.plot.navchart(pp, cd, size=(5, 5)) +navchart = p3analysis.plot.navchart(pp, cd, size=(5, 5)) navchart.save("navchart.png") diff --git a/p3/metrics/__init__.py b/p3/metrics/__init__.py deleted file mode 100644 index 5cd6eab..0000000 --- a/p3/metrics/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (c) 2022-2023 Intel Corporation -# SPDX-License-Identifier: MIT - -from p3.metrics._efficiency import application_efficiency -from p3.metrics._pp import pp -from p3.metrics._divergence import divergence - -__all__ = ["application_efficiency", "pp", "divergence"] diff --git a/p3/__init__.py b/p3analysis/__init__.py similarity index 50% rename from p3/__init__.py rename to p3analysis/__init__.py index 999aa8f..abfe312 100644 --- a/p3/__init__.py +++ b/p3analysis/__init__.py @@ -1,9 +1,9 @@ # Copyright (c) 2022-2023 Intel Corporation # SPDX-License-Identifier: MIT -import p3.data -import p3.metrics -import p3.plot -import p3.report +import p3analysis.data +import p3analysis.metrics +import p3analysis.plot +import p3analysis.report __version__ = "0.2.0" diff --git a/p3/_utils.py b/p3analysis/_utils.py similarity index 100% rename from p3/_utils.py rename to p3analysis/_utils.py diff --git a/p3/data/__init__.py b/p3analysis/data/__init__.py similarity index 66% rename from p3/data/__init__.py rename to p3analysis/data/__init__.py index 4df0bed..f11fdad 100644 --- a/p3/data/__init__.py +++ b/p3analysis/data/__init__.py @@ -1,6 +1,6 @@ # Copyright (c) 2022-2023 Intel Corporation # SPDX-License-Identifier: MIT -from p3.data._projection import projection +from p3analysis.data._projection import projection __all__ = ["projection"] diff --git a/p3/data/_projection.py b/p3analysis/data/_projection.py similarity index 93% rename from p3/data/_projection.py rename to p3analysis/data/_projection.py index 46b75bb..0202981 100644 --- a/p3/data/_projection.py +++ b/p3analysis/data/_projection.py @@ -3,7 +3,7 @@ import pandas as pd -from p3._utils import _require_columns +from p3analysis._utils import _require_columns def _join(series): @@ -38,8 +38,8 @@ def projection( Project data onto definitions of problem, application and platform. The result of a projection is a DataFrame suitable for use with - functionality provided by the :py:mod:`p3.metrics`, :py:mod:`p3.plot` and - :py:mod:`p3.report` modules. + functionality provided by the :py:mod:`p3analysis.metrics`, + :py:mod:`p3analysis.plot` and :py:mod:`p3analysis.report` modules. Parameters ---------- @@ -79,7 +79,7 @@ def projection( ... 'M': ['1024', '1024'], ... 'N': ['1024', '1024'], ... 'K': ['1024', '1024']}) - >>> df = p3.data.projection(df, + >>> df = p3analysis.data.projection(df, ... problem=['kernel', 'M', 'N', 'K'], ... application=['language', 'branch'], ... platform=['architecture', 'compiler']) diff --git a/p3/data/_validation.py b/p3analysis/data/_validation.py similarity index 99% rename from p3/data/_validation.py rename to p3analysis/data/_validation.py index d34399d..51c403c 100644 --- a/p3/data/_validation.py +++ b/p3analysis/data/_validation.py @@ -2,9 +2,10 @@ # SPDX-License-Identifier: MIT import json -import jsonschema import pkgutil +import jsonschema + def _validate_coverage_json(json_string: str) -> object: """ diff --git a/p3/data/coverage-0.1.0.schema b/p3analysis/data/coverage-0.1.0.schema similarity index 100% rename from p3/data/coverage-0.1.0.schema rename to p3analysis/data/coverage-0.1.0.schema diff --git a/p3/data/coverage-0.2.0.schema b/p3analysis/data/coverage-0.2.0.schema similarity index 100% rename from p3/data/coverage-0.2.0.schema rename to p3analysis/data/coverage-0.2.0.schema diff --git a/p3/data/coverage-0.3.0.schema b/p3analysis/data/coverage-0.3.0.schema similarity index 100% rename from p3/data/coverage-0.3.0.schema rename to p3analysis/data/coverage-0.3.0.schema diff --git a/p3analysis/metrics/__init__.py b/p3analysis/metrics/__init__.py new file mode 100644 index 0000000..b9c157b --- /dev/null +++ b/p3analysis/metrics/__init__.py @@ -0,0 +1,8 @@ +# Copyright (c) 2022-2023 Intel Corporation +# SPDX-License-Identifier: MIT + +from p3analysis.metrics._divergence import divergence +from p3analysis.metrics._efficiency import application_efficiency +from p3analysis.metrics._pp import pp + +__all__ = ["application_efficiency", "pp", "divergence"] diff --git a/p3/metrics/_divergence.py b/p3analysis/metrics/_divergence.py similarity index 97% rename from p3/metrics/_divergence.py rename to p3analysis/metrics/_divergence.py index 9fe8ed3..b0e7b96 100644 --- a/p3/metrics/_divergence.py +++ b/p3analysis/metrics/_divergence.py @@ -4,8 +4,8 @@ import collections import itertools as it -from p3._utils import _require_columns -from p3.data._validation import _validate_coverage_json +from p3analysis._utils import _require_columns +from p3analysis.data._validation import _validate_coverage_json def _extract_platforms(setmap): diff --git a/p3/metrics/_efficiency.py b/p3analysis/metrics/_efficiency.py similarity index 97% rename from p3/metrics/_efficiency.py rename to p3analysis/metrics/_efficiency.py index 1a82aee..ed86198 100644 --- a/p3/metrics/_efficiency.py +++ b/p3analysis/metrics/_efficiency.py @@ -3,7 +3,7 @@ import numpy -from p3._utils import _require_columns, _require_numeric +from p3analysis._utils import _require_columns, _require_numeric def application_efficiency(df, foms="lower"): diff --git a/p3/metrics/_pp.py b/p3analysis/metrics/_pp.py similarity index 98% rename from p3/metrics/_pp.py rename to p3analysis/metrics/_pp.py index b256fc6..ea4ed9a 100644 --- a/p3/metrics/_pp.py +++ b/p3analysis/metrics/_pp.py @@ -6,7 +6,7 @@ import pandas as pd -from p3._utils import _require_columns, _require_numeric +from p3analysis._utils import _require_columns, _require_numeric def _hmean(series): diff --git a/p3/plot/__init__.py b/p3analysis/plot/__init__.py similarity index 51% rename from p3/plot/__init__.py rename to p3analysis/plot/__init__.py index 740388e..07531ce 100644 --- a/p3/plot/__init__.py +++ b/p3analysis/plot/__init__.py @@ -1,9 +1,9 @@ # Copyright (c) 2022-2023 Intel Corporation # SPDX-License-Identifier: MIT -from p3.plot._cascade import cascade -from p3.plot._navchart import navchart -from p3.plot._common import Legend, ApplicationStyle, PlatformStyle +from p3analysis.plot._cascade import cascade +from p3analysis.plot._common import ApplicationStyle, Legend, PlatformStyle +from p3analysis.plot._navchart import navchart __all__ = [ "cascade", diff --git a/p3/plot/_cascade.py b/p3analysis/plot/_cascade.py similarity index 91% rename from p3/plot/_cascade.py rename to p3analysis/plot/_cascade.py index dabb400..4510145 100644 --- a/p3/plot/_cascade.py +++ b/p3analysis/plot/_cascade.py @@ -6,7 +6,7 @@ # Copyright (c) 2020 Performance Portability authors # SPDX-License-Identifier: MIT -from p3._utils import _require_columns, _require_numeric +from p3analysis._utils import _require_columns, _require_numeric def cascade(df, eff=None, size=None, **kwargs): @@ -49,24 +49,24 @@ def cascade(df, eff=None, size=None, **kwargs): - Description * - `platform_legend` - - p3.plot.Legend + - p3analysis.plot.Legend - Styling options for platform legend. * - `application_legend` - - p3.plot.Legend + - p3analysis.plot.Legend - Styling options for application legend. * - `platform_style` - - p3.plot.PlatformStyle + - p3analysis.plot.PlatformStyle - Styling options for platforms. * - `application_style` - - p3.plot.ApplicationStyle + - p3analysis.plot.ApplicationStyle - Styling options for applications. Returns ------- - ~p3.plot.backend.CascadePlot + ~p3analysis.plot.backend.CascadePlot An object providing direct access to backend-specific components of the cascade plot. @@ -124,11 +124,11 @@ def cascade(df, eff=None, size=None, **kwargs): kwargs.setdefault("backend", "matplotlib") backend = kwargs["backend"] if backend == "matplotlib": - from p3.plot.backend.matplotlib import CascadePlot + from p3analysis.plot.backend.matplotlib import CascadePlot return CascadePlot(df, eff_column, size, **kwargs) elif backend == "pgfplots": - from p3.plot.backend.pgfplots import CascadePlot + from p3analysis.plot.backend.pgfplots import CascadePlot return CascadePlot(df, eff_column, size, **kwargs) else: diff --git a/p3/plot/_common.py b/p3analysis/plot/_common.py similarity index 87% rename from p3/plot/_common.py rename to p3analysis/plot/_common.py index ba2bb70..82447c4 100644 --- a/p3/plot/_common.py +++ b/p3analysis/plot/_common.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: MIT -class Legend(object): +class Legend: """ Container for legend styling options. """ @@ -11,7 +11,7 @@ def __init__(self, **kwargs): self.kwargs = kwargs -class ApplicationStyle(object): +class ApplicationStyle: """ Container for application styling options. """ @@ -22,7 +22,7 @@ def __init__(self, colors=None, markers=None, **kwargs): self.kwargs = kwargs -class PlatformStyle(object): +class PlatformStyle: """ Container for platform styling options. """ diff --git a/p3/plot/_navchart.py b/p3analysis/plot/_navchart.py similarity index 91% rename from p3/plot/_navchart.py rename to p3analysis/plot/_navchart.py index 05d5aa0..1d14b18 100644 --- a/p3/plot/_navchart.py +++ b/p3analysis/plot/_navchart.py @@ -1,7 +1,7 @@ # Copyright (c) 2022-2023 Intel Corporation # SPDX-License-Identifier: MIT -from p3._utils import _require_columns, _require_numeric +from p3analysis._utils import _require_columns, _require_numeric def navchart(pp, cd, eff=None, size=None, goal=None, **kwargs): @@ -54,16 +54,16 @@ def navchart(pp, cd, eff=None, size=None, goal=None, **kwargs): - Description * - `legend` - - p3.plot.Legend + - p3analysis.plot.Legend - Styling options for platform legend. * - `style` - - p3.plot.ApplicationStyle + - p3analysis.plot.ApplicationStyle - Styling options for applications. Returns ------- - ~p3.plot.backend.NavChart + ~p3analysis.plot.backend.NavChart An object providing direct access to backend-specific components of the navigation chart. @@ -90,11 +90,11 @@ def navchart(pp, cd, eff=None, size=None, goal=None, **kwargs): kwargs.setdefault("backend", "matplotlib") backend = kwargs["backend"] if backend == "matplotlib": - from p3.plot.backend.matplotlib import NavChart + from p3analysis.plot.backend.matplotlib import NavChart return NavChart(pp, cd, eff, size, goal, **kwargs) elif backend == "pgfplots": - from p3.plot.backend.pgfplots import NavChart + from p3analysis.plot.backend.pgfplots import NavChart return NavChart(pp, cd, eff, size, goal, **kwargs) else: diff --git a/p3/plot/backend/__init__.py b/p3analysis/plot/backend/__init__.py similarity index 100% rename from p3/plot/backend/__init__.py rename to p3analysis/plot/backend/__init__.py diff --git a/p3/plot/backend/matplotlib.py b/p3analysis/plot/backend/matplotlib.py similarity index 98% rename from p3/plot/backend/matplotlib.py rename to p3analysis/plot/backend/matplotlib.py index 835a6df..387ef33 100644 --- a/p3/plot/backend/matplotlib.py +++ b/p3analysis/plot/backend/matplotlib.py @@ -14,10 +14,10 @@ import pandas as pd from matplotlib.path import Path -import p3.metrics -from p3._utils import _require_numeric -from p3.plot._common import ApplicationStyle, Legend, PlatformStyle -from p3.plot.backend import CascadePlot, NavChart +import p3analysis.metrics +from p3analysis._utils import _require_numeric +from p3analysis.plot._common import ApplicationStyle, Legend, PlatformStyle +from p3analysis.plot.backend import CascadePlot, NavChart def _get_colors(applications, kwarg): @@ -386,7 +386,7 @@ def __pp_bars(self, ax, df, pp_column, colors, markers): ax.yaxis.tick_right() ax.grid(visible=True) - pp = p3.metrics.pp(df) + pp = p3analysis.metrics.pp(df) edgecolors = [colors[app] for app in pp["application"]] ax.bar( diff --git a/p3/plot/backend/pgfplots.py b/p3analysis/plot/backend/pgfplots.py similarity index 97% rename from p3/plot/backend/pgfplots.py rename to p3analysis/plot/backend/pgfplots.py index ae9edb0..ef509a4 100644 --- a/p3/plot/backend/pgfplots.py +++ b/p3analysis/plot/backend/pgfplots.py @@ -13,10 +13,10 @@ import numpy as np import pandas as pd -import p3.metrics -from p3._utils import _require_numeric -from p3.plot._common import ApplicationStyle, Legend, PlatformStyle -from p3.plot.backend import CascadePlot, NavChart +import p3analysis.metrics +from p3analysis._utils import _require_numeric +from p3analysis.plot._common import ApplicationStyle, Legend, PlatformStyle +from p3analysis.plot.backend import CascadePlot, NavChart # Define 19 default markers for LaTeX plots _pgfplots_markers = [ @@ -72,7 +72,7 @@ def _get_tex_template(filename): line_comment_prefix="%#", trim_blocks=True, autoescape=True, - loader=jinja2.PackageLoader("p3.plot.backend"), + loader=jinja2.PackageLoader("p3analysis.plot.backend"), ) # Load the template @@ -194,7 +194,7 @@ def __init__(self, df, eff_column, size=None, stream=None, **kwargs): # Build a dictionary with "application name, (application name, qp)" # for the pp bar plot - pp = p3.metrics.pp(df) + pp = p3analysis.metrics.pp(df) pp_column = eff_column.replace("eff", "pp") pp_bars = { app: f"({app}, {app_pp})" diff --git a/p3/plot/backend/templates/cascade.tex b/p3analysis/plot/backend/templates/cascade.tex similarity index 100% rename from p3/plot/backend/templates/cascade.tex rename to p3analysis/plot/backend/templates/cascade.tex diff --git a/p3/plot/backend/templates/navchart.tex b/p3analysis/plot/backend/templates/navchart.tex similarity index 100% rename from p3/plot/backend/templates/navchart.tex rename to p3analysis/plot/backend/templates/navchart.tex diff --git a/p3/report/__init__.py b/p3analysis/report/__init__.py similarity index 67% rename from p3/report/__init__.py rename to p3analysis/report/__init__.py index 29e6f8c..3134a9a 100644 --- a/p3/report/__init__.py +++ b/p3analysis/report/__init__.py @@ -1,6 +1,6 @@ # Copyright (c) 2022-2023 Intel Corporation # SPDX-License-Identifier: MIT -from p3.report._snapshot import snapshot +from p3analysis.report._snapshot import snapshot __all__ = ["snapshot"] diff --git a/p3/report/_snapshot.py b/p3analysis/report/_snapshot.py similarity index 94% rename from p3/report/_snapshot.py rename to p3analysis/report/_snapshot.py index 7e43bd4..4b39980 100644 --- a/p3/report/_snapshot.py +++ b/p3analysis/report/_snapshot.py @@ -6,10 +6,10 @@ import matplotlib.pyplot as plt -import p3.metrics -import p3.plot -from p3._utils import _require_columns -from p3.metrics._divergence import _coverage_string_to_json +import p3analysis.metrics +import p3analysis.plot +from p3analysis._utils import _require_columns +from p3analysis.metrics._divergence import _coverage_string_to_json def _tmpdir(prefix): @@ -57,8 +57,8 @@ def snapshot(df, cov=None, directory=None): Generate an HTML report representing a snapshot of P3 characteristics. The report includes: - - A cascade plot (see :py:func:`p3.plot.cascade`) - - A navigation chart (see :py:func:`p3.plot.navchart`) + - A cascade plot (see :py:func:`p3analysis.plot.cascade`) + - A navigation chart (see :py:func:`p3analysis.plot.navchart`) - A table breaking down the lines of code shared between applications .. _Code Base Investigator: https://github.com/intel/code-base-investigator @@ -141,7 +141,7 @@ def _safe_opener(path, flags): app_order = df["application"].unique() # Calculate the efficiencies using all available data - effs = p3.metrics.application_efficiency(df) + effs = p3analysis.metrics.application_efficiency(df) # Limit the plots to the latest results snap = effs.drop_duplicates( @@ -152,20 +152,20 @@ def _safe_opener(path, flags): snap = _sort_by_app_order(snap, app_order) plt.figure(figsize=(6, 5)) - p3.plot.cascade(snap) + p3analysis.plot.cascade(snap) with open("cascade.png", "xb", opener=_safe_opener) as fp: plt.savefig(fp, bbox_inches="tight") plt.clf() - pp = p3.metrics.pp(snap) + pp = p3analysis.metrics.pp(snap) pp = _sort_by_app_order(pp, app_order) - div = p3.metrics.divergence(df, cov) + div = p3analysis.metrics.divergence(df, cov) div = _sort_by_app_order(div, app_order) plt.figure(figsize=(5, 5)) - p3.plot.navchart(pp, div) + p3analysis.plot.navchart(pp, div) plt.tight_layout() with open("navchart.png", "xb", opener=_safe_opener) as fp: plt.savefig(fp, bbox_inches="tight") diff --git a/pyproject.toml b/pyproject.toml index 036d200..07a5013 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ authors = [ description = "Performance, Portability and Productivity Analysis Library" dynamic = ["version", "readme"] keywords = ["performance", "portability", "productivity"] -name = "p3" +name = "p3analysis" requires-python = ">=3.9" classifiers = [ "Programming Language :: Python :: 3", @@ -37,8 +37,8 @@ dev = [ [tool.setuptools.packages.find] where = ["."] -include = ["p3*"] +include = ["p3analysis*"] [tool.setuptools.dynamic] readme = {file = ["README.md"]} -version = {attr = "p3.__version__"} +version = {attr = "p3analysis.__version__"} diff --git a/tests/data/test_projection.py b/tests/data/test_projection.py index 9b87dec..1ca2e16 100644 --- a/tests/data/test_projection.py +++ b/tests/data/test_projection.py @@ -5,17 +5,17 @@ import pandas as pd -from p3.data import projection -from p3.data._projection import _collapse +from p3analysis.data import projection +from p3analysis.data._projection import _collapse class TestProjection(unittest.TestCase): """ - Test p3.data.projection functionality. + Test p3analysis.data.projection functionality. """ def test_collapse(self): - """p3.data.projection.collapse""" + """p3analysis.data.projection.collapse""" data = {"c1": ["x", "y", "z"], "c2": ["1", "2", "3"]} df = pd.DataFrame(data) @@ -39,7 +39,7 @@ def test_collapse_null(self): pd.testing.assert_frame_equal(df, expected_df) def test_required_columns(self): - """p3.data.projection.required_columns""" + """p3analysis.data.projection.required_columns""" df = pd.DataFrame() with self.assertRaises(ValueError): @@ -58,7 +58,7 @@ def test_required_columns(self): projection(df, platform=[1]) def test_side_effects(self): - """p3.data.projection.side_effects""" + """p3analysis.data.projection.side_effects""" data = { "c1": ["x", "y"], "c2": ["1", "2"], @@ -77,7 +77,7 @@ def test_side_effects(self): pd.testing.assert_frame_equal(df, result) def test_projection(self): - """p3.data.projection""" + """p3analysis.data.projection""" data = { "c1": ["x", "y"], "c2": ["1", "2"], @@ -101,7 +101,7 @@ def test_projection(self): pd.testing.assert_frame_equal(result, expected_df, check_like=True) def test_empty_projection(self): - """p3.data.empty_projection""" + """p3analysis.data.empty_projection""" data = {"problem": ["x"], "platform": ["X"], "application": ["A"]} df = pd.DataFrame(data) diff --git a/tests/data/test_validation.py b/tests/data/test_validation.py index 632200d..f266512 100644 --- a/tests/data/test_validation.py +++ b/tests/data/test_validation.py @@ -3,23 +3,23 @@ import unittest -from p3.data._validation import _validate_coverage_json +from p3analysis.data._validation import _validate_coverage_json class TestValidation(unittest.TestCase): """ - Test p3.data.validation functionality. + Test p3analysis.data.validation functionality. """ def test_coverage_json_valid(self): - """p3.data.validation.coverage_json_valid""" + """p3analysis.data.validation.coverage_json_valid""" json_string = '[{"file": "path", "id": "sha", "lines": [1, 2, [3, 5]]}]' result_object = _validate_coverage_json(json_string) expected_object = [{"file": "path", "id": "sha", "lines": [1, 2, [3, 5]]}] self.assertTrue(result_object == expected_object) def test_coverage_json_invalid(self): - """p3.data.validation.coverage_json_invalid""" + """p3analysis.data.validation.coverage_json_invalid""" json_string = '[{"file": "path", "id": "sha", "lines": [["1"]]}]' with self.assertRaises(ValueError): _validate_coverage_json(json_string) diff --git a/tests/metrics/test_divergence.py b/tests/metrics/test_divergence.py index 4f91c3a..649515a 100644 --- a/tests/metrics/test_divergence.py +++ b/tests/metrics/test_divergence.py @@ -2,14 +2,16 @@ # SPDX-License-Identifier: MIT import json -import pandas as pd -from p3.metrics import divergence import unittest +import pandas as pd + +from p3analysis.metrics import divergence + class TestDivergence(unittest.TestCase): """ - Test p3.data.divergence functionality. + Test p3analysis.data.divergence functionality. """ def test_required_columns(self): @@ -36,8 +38,8 @@ def test_side_effects(self): "file": "file.cpp", "id": "0", "lines": [0], - } - ] + }, + ], ) cov = pd.DataFrame({"coverage_key": [key], "coverage": [json_string]}) @@ -68,8 +70,8 @@ def test_divergence(self): "file": "foo.cpp", "id": "0", "lines": [[0, 9]], - } - ] + }, + ], ) source2_json_string = json.dumps( @@ -84,14 +86,14 @@ def test_divergence(self): "id": "1", "lines": [[0, 9]], }, - ] + ], ) cov = pd.DataFrame( { "coverage_key": ["source1", "source2"], "coverage": [source1_json_string, source2_json_string], - } + }, ) result = divergence(df, cov) @@ -122,8 +124,8 @@ def test_divergence_single(self): "file": "file.cpp", "id": "0", "lines": [0], - } - ] + }, + ], ) cov = pd.DataFrame({"coverage_key": [key], "coverage": [json_string]}) @@ -155,8 +157,8 @@ def test_divergence_duplicate(self): "file": "foo.cpp", "id": "0", "lines": [[0, 9]], - } - ] + }, + ], ) # Second file called "foo.cpp" has a different id ("1"). @@ -168,14 +170,14 @@ def test_divergence_duplicate(self): "id": "1", "lines": [[0, 9]], }, - ] + ], ) cov = pd.DataFrame( { "coverage_key": ["source1", "source2"], "coverage": [source1_json_string, source2_json_string], - } + }, ) result = divergence(df, cov) diff --git a/tests/metrics/test_efficiency.py b/tests/metrics/test_efficiency.py index 4d72ca1..b004a3c 100644 --- a/tests/metrics/test_efficiency.py +++ b/tests/metrics/test_efficiency.py @@ -1,25 +1,27 @@ # Copyright (C) 2022-2023 Intel Corporation # SPDX-License-Identifier: MIT -import pandas as pd -from p3.metrics import application_efficiency import unittest +import pandas as pd + +from p3analysis.metrics import application_efficiency + class TestEfficiency(unittest.TestCase): """ - Test p3.data.efficiency functionality. + Test p3analysis.data.efficiency functionality. """ def test_required_columns(self): - """p3.data.efficiency.required_columns""" + """p3analysis.data.efficiency.required_columns""" df = pd.DataFrame() with self.assertRaises(ValueError): application_efficiency(df) def test_foms(self): - """p3.data.efficiency.foms""" + """p3analysis.data.efficiency.foms""" data = {"problem": [], "platform": [], "application": [], "fom": []} df = pd.DataFrame(data) @@ -27,7 +29,7 @@ def test_foms(self): application_efficiency(df, foms="invalid") def test_side_effects(self): - """p3.data.efficiency.side_effects""" + """p3analysis.data.efficiency.side_effects""" data = { "problem": ["test"] * 10, "platform": ["A", "B", "C", "D", "E"] * 2, @@ -47,7 +49,7 @@ def test_side_effects(self): pd.testing.assert_frame_equal(df, result) def test_efficiency(self): - """p3.data.efficiency""" + """p3analysis.data.efficiency""" # Test foms = lower # fom interpretations are time @@ -63,7 +65,7 @@ def test_efficiency(self): result = application_efficiency(df, foms="lower") eff_data = { - "app eff": [1.0, 0.8, 0.5, 0.0, 0.2] + [1.0, 1.0, 1.0, 1.0, 1.0] + "app eff": [1.0, 0.8, 0.5, 0.0, 0.2] + [1.0, 1.0, 1.0, 1.0, 1.0], } expected_data = data.copy() expected_data.update(eff_data) @@ -84,7 +86,7 @@ def test_efficiency(self): result = application_efficiency(df, foms="higher") eff_data = { - "app eff": [1.0, 0.8, 0.5, 0.0, 0.2] + [1.0, 1.0, 1.0, 1.0, 1.0] + "app eff": [1.0, 0.8, 0.5, 0.0, 0.2] + [1.0, 1.0, 1.0, 1.0, 1.0], } expected_data = data.copy() expected_data.update(eff_data) diff --git a/tests/metrics/test_pp.py b/tests/metrics/test_pp.py index 567b3c2..40bf88f 100644 --- a/tests/metrics/test_pp.py +++ b/tests/metrics/test_pp.py @@ -5,23 +5,23 @@ import pandas as pd -from p3.metrics import pp +from p3analysis.metrics import pp class TestPP(unittest.TestCase): """ - Test p3.data.pp functionality. + Test p3analysis.data.pp functionality. """ def test_required_columns(self): - """p3.data.pp.required_columns""" + """p3analysis.data.pp.required_columns""" df = pd.DataFrame() with self.assertRaises(ValueError): pp(df) def test_effs(self): - """p3.data.pp.effs""" + """p3analysis.data.pp.effs""" data = { "problem": ["test"], "platform": ["test"], @@ -47,7 +47,7 @@ def test_effs(self): pp(df) def test_side_effects(self): - """p3.data.pp.side_effects""" + """p3analysis.data.pp.side_effects""" data = { "problem": ["test"] * 15, "platform": ["A", "B", "C", "D", "E"] * 3, @@ -72,7 +72,7 @@ def test_side_effects(self): pd.testing.assert_frame_equal(df, result) def test_pp(self): - """p3.data.pp""" + """p3analysis.data.pp""" data = { "problem": ["test"] * 15, @@ -111,7 +111,7 @@ def test_pp(self): pp(df) def test_pp_single(self): - """p3.data.pp.single""" + """p3analysis.data.pp.single""" # Regression for trivial case with one record data = { diff --git a/tests/plot/test_cascade.py b/tests/plot/test_cascade.py index 799e9b3..ef41ff7 100644 --- a/tests/plot/test_cascade.py +++ b/tests/plot/test_cascade.py @@ -1,19 +1,20 @@ # Copyright (C) 2022-2023 Intel Corporation # SPDX-License-Identifier: MIT +import unittest + import matplotlib import pandas as pd -from p3.plot import cascade -from p3.plot import ApplicationStyle, PlatformStyle -import unittest + +from p3analysis.plot import ApplicationStyle, PlatformStyle, cascade class TestCascade(unittest.TestCase): """ - Test p3.plot.cascade functionality. + Test p3analysis.plot.cascade functionality. """ def test_required_columns(self): - """p3.plot.cascade.required_columns""" + """p3analysis.plot.cascade.required_columns""" df = pd.DataFrame() with self.assertRaises(ValueError): @@ -31,7 +32,7 @@ def test_required_columns(self): cascade(df, eff="invalid") def test_options(self): - """p3.plot.cascade.options""" + """p3analysis.plot.cascade.options""" data = { "problem": ["test"] * 2, diff --git a/tests/plot/test_navchart.py b/tests/plot/test_navchart.py index e1d4cc4..24753b2 100644 --- a/tests/plot/test_navchart.py +++ b/tests/plot/test_navchart.py @@ -1,19 +1,20 @@ # Copyright (C) 2022-2023 Intel Corporation # SPDX-License-Identifier: MIT +import unittest + import matplotlib import pandas as pd -from p3.plot import navchart -from p3.plot import ApplicationStyle -import unittest + +from p3analysis.plot import ApplicationStyle, navchart class TestNavchart(unittest.TestCase): """ - Test p3.plot.navchart functionality. + Test p3analysis.plot.navchart functionality. """ def test_required_columns(self): - """p3.plot.navchart.required_columns""" + """p3analysis.plot.navchart.required_columns""" pp = pd.DataFrame() cd = pd.DataFrame() @@ -28,13 +29,13 @@ def test_required_columns(self): navchart(pp, cd, eff="arch") pp = pd.DataFrame( - columns=["problem", "platform", "application", "app pp"] + columns=["problem", "platform", "application", "app pp"], ) with self.assertRaises(ValueError): navchart(pp, cd, eff="invalid") def test_options(self): - """p3.plot.navchart.options""" + """p3analysis.plot.navchart.options""" perf = { "problem": ["test"] * 2,