Skip to content

Commit

Permalink
Removed some spurious debug code. Fixed formatting for pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
swright87 committed Apr 5, 2024
1 parent 88589bc commit 1b36850
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 185 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include p3/data/coverage-0.1.0.schema
include p3/data/coverage-0.2.0.schema
include p3/plot/backend/pgftemplates/cascade.tex
include p3/plot/backend/pgftemplates/navchart.tex
include p3/plot/backend/pgftemplates/navchart.tex

6 changes: 3 additions & 3 deletions p3/metrics/_pp.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) 2022-2023 Intel Corporation
# SPDX-License-Identifier: MIT

import pandas as pd
from itertools import product

from statistics import harmonic_mean

import pandas as pd

from p3._utils import _require_columns, _require_numeric


Expand Down Expand Up @@ -109,7 +109,7 @@ def pp(df):
"fom": None,
"arch eff": None,
"app eff": None,
}
},
]
df = pd.concat([df, pd.DataFrame(rows)], ignore_index=True)

Expand Down
2 changes: 1 addition & 1 deletion p3/plot/_cascade.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def cascade(df, eff=None, size=(6, 5), **kwargs):

if len(df["problem"].unique()) > 1:
raise NotImplementedError(
"Handling multiple problems is currently not implemented."
"Handling multiple problems is currently not implemented.",
)

kwargs.setdefault("backend", "matplotlib")
Expand Down
2 changes: 1 addition & 1 deletion p3/plot/_navchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def navchart(pp, cd, eff=None, size=(5, 5), goal=None, **kwargs):

if len(cd["problem"].unique()) > 1:
raise NotImplementedError(
"Handling multiple problems is currently not implemented."
"Handling multiple problems is currently not implemented.",
)

kwargs.setdefault("backend", "matplotlib")
Expand Down
25 changes: 12 additions & 13 deletions p3/plot/backend/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
:py:mod:`matplotlib` backend.
"""

import string

import matplotlib
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from matplotlib.path import Path
import matplotlib.pyplot as plt
import numpy as np
import p3.metrics
import string
import pandas as pd
from matplotlib.path import Path

from . import CascadePlot
from . import NavChart
import p3.metrics
from p3._utils import _require_numeric
from p3.plot._common import Legend, ApplicationStyle, PlatformStyle

from p3.plot._common import ApplicationStyle, Legend, PlatformStyle
from p3.plot.backend import CascadePlot, NavChart

class _PlatformLegendHandler(matplotlib.legend_handler.HandlerBase):
def __init__(self, colors, labels):
Expand Down Expand Up @@ -75,7 +74,7 @@ class CascadePlot(CascadePlot):
"""

def __init__(
self, df, eff=None, size=(6, 5), fig=None, axes=None, **kwargs
self, df, eff=None, size=(6, 5), fig=None, axes=None, **kwargs,
):
"""
Plot a `cascade`_ summarizing the efficiency and performance
Expand Down Expand Up @@ -169,7 +168,7 @@ def __init__(
app_style.colors = getattr(plt.cm, "tab10")
if not app_style.markers:
app_style.markers = getattr(
matplotlib.markers.MarkerStyle, "filled_markers"
matplotlib.markers.MarkerStyle, "filled_markers",
)

# Choose the efficiency column based on eff parameter and available
Expand Down Expand Up @@ -237,7 +236,7 @@ def __init__(

# Plot the efficiency cascade in the top-left (0, 0)
app_handles = self.__efficiency_cascade(
axes[0][0], df, eff_column, app_colors, app_markers
axes[0][0], df, eff_column, app_colors, app_markers,
)

# Plot the platform chart in the bottom-left (1, 0)
Expand Down Expand Up @@ -521,7 +520,7 @@ def __init__(
style.colors = getattr(plt.cm, "tab10")
if not style.markers:
style.markers = getattr(
matplotlib.markers.MarkerStyle, "filled_markers"
matplotlib.markers.MarkerStyle, "filled_markers",
)

# Choose the PP column based on eff parameter and available columns
Expand Down Expand Up @@ -613,7 +612,7 @@ def __init__(
]
path = Path(verts, codes)
patch = mpatches.PathPatch(
path, facecolor="yellow", lw=2, alpha=0.5
path, facecolor="yellow", lw=2, alpha=0.5,
)
ax.add_patch(patch)

Expand Down
37 changes: 15 additions & 22 deletions p3/plot/backend/pgfplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
:py:mod:`pgfplots` backend.
"""

import os
import string

import jinja2
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import p3.metrics
import string
import pandas as pd
import jinja2
import os

from . import CascadePlot, NavChart
import p3.metrics
from p3._utils import _require_numeric
from p3.plot._common import Legend, ApplicationStyle, PlatformStyle

from p3.plot._common import ApplicationStyle, Legend, PlatformStyle
from p3.plot.backend import CascadePlot, NavChart

class CascadePlot(CascadePlot):
"""
Expand Down Expand Up @@ -196,7 +196,7 @@ def __init__(self, df, eff=None, stream=None, **kwargs):
app_colors_rgb = {}
for k in app_colors:
app_colors_rgb[app_to_tex_name[k]] = str(
matplotlib.colors.to_rgb(app_colors[k])
matplotlib.colors.to_rgb(app_colors[k]),
).strip("()")

# Build a dictionary of platforms to labels
Expand All @@ -208,7 +208,7 @@ def __init__(self, df, eff=None, stream=None, **kwargs):
plat_colors_rgb = {}
for k in plat_colors:
plat_colors_rgb[plat_labels[k]] = str(
matplotlib.colors.to_rgb(plat_colors[k])
matplotlib.colors.to_rgb(plat_colors[k]),
).strip("()")

# Choose markers for each application
Expand All @@ -219,9 +219,9 @@ def __init__(self, df, eff=None, stream=None, **kwargs):
# build a dictionary of app line specifications for TeX
app_line_specs = {}
for app, mark in zip(applications, markers):
app_line_specs[app] = (
f"{app_to_tex_name[app]}, thick, solid, mark={mark}"
)
app_line_specs[
app
] = f"{app_to_tex_name[app]}, thick, solid, mark={mark}"

# Choose labels for each platform
plat_labels = dict(zip(platforms, string.ascii_uppercase))
Expand Down Expand Up @@ -287,7 +287,7 @@ def __init__(self, df, eff=None, stream=None, **kwargs):
trim_blocks=True,
autoescape=True,
loader=jinja2.FileSystemLoader(
os.path.dirname(p3.__file__) + "/plot/backend/pgftemplates/"
os.path.dirname(p3.__file__) + "/plot/backend/pgftemplates/",
),
)

Expand Down Expand Up @@ -410,7 +410,7 @@ def __init__(self, pp, cd, eff=None, stream=None, **kwargs):
app_colors_rgb = {}
for k in app_colors:
app_colors_rgb[app_to_tex_name[k]] = str(
matplotlib.colors.to_rgb(app_colors[k])
matplotlib.colors.to_rgb(app_colors[k]),
).strip("()")

markers = style.markers
Expand All @@ -435,13 +435,6 @@ def __init__(self, pp, cd, eff=None, stream=None, **kwargs):
convergence = 1 - row["divergence"]
app_coords[app_name] = f"({convergence}, {app_pp})"

"""print("COORDS")
print(app_coords)
print("MARK SPECS")
print(app_mark_specs)
print("COLORS")
print(app_colors_rgb)"""

# Build a jinja environment that can parse the TeX template
latex_jinja_env = jinja2.Environment(
block_start_string=r"\BLOCK{",
Expand All @@ -455,7 +448,7 @@ def __init__(self, pp, cd, eff=None, stream=None, **kwargs):
trim_blocks=True,
autoescape=True,
loader=jinja2.FileSystemLoader(
os.path.dirname(p3.__file__) + "/plot/backend/pgftemplates/"
os.path.dirname(p3.__file__) + "/plot/backend/pgftemplates/",
),
)

Expand Down
Loading

0 comments on commit 1b36850

Please sign in to comment.