Skip to content

Commit

Permalink
Fix spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Richard McKinsey authored and michaelmckinsey1 committed Feb 20, 2024
1 parent c61387d commit 7f03c36
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions thicket/external/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def render(self, roots, dataframe, **kwargs):
self.colormap_annotations = kwargs["colormap_annotations"]
self.min_value = kwargs["min_value"]
self.max_value = kwargs["max_value"]
self.indicies = kwargs["indicies"]
self.indices = kwargs["indices"]

if self.color:
self.colors = self.colors_enabled
Expand Down Expand Up @@ -164,8 +164,8 @@ def render_label(index, low, high):
+ str(self.primary_metric)
+ " Min: {:.2f}".format(self.min_metric)
+ " Max: {:.2f}".format(self.max_metric)
+ " Indicies: "
+ str(self.indicies)
+ " indices: "
+ str(self.indices)
+ ")\n"
)

Expand Down
10 changes: 5 additions & 5 deletions thicket/tests/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import thicket as th


def test_indicies(rajaperf_july_2023):
def test_indices(rajaperf_july_2023):
files = [f for f in rajaperf_july_2023 if "quartz/clang14.0.6_1048576/O0/1" in f]
tk = th.Thicket.from_caliperreader(files)

# No error
tk.tree(metric_column="Avg time/rank", indicies=tk.profile[0])
tk.tree(metric_column="Avg time/rank", indices=tk.profile[0])

tk.metadata_column_to_perfdata("variant")
tk.metadata_column_to_perfdata("tuning")
Expand All @@ -32,10 +32,10 @@ def test_indicies(rajaperf_july_2023):
tk.tree(metric_column="Avg time/rank")

# No error
tk.tree(metric_column="Avg time/rank", indicies=["Base_OpenMP", "default"])
tk.tree(metric_column="Avg time/rank", indices=["Base_OpenMP", "default"])

with pytest.raises(
KeyError,
match=r"The indicies, \{\'tuning\': \'hi\'\}, do not exist in the index \'self.dataframe.index\'",
match=r"The indices, \{\'tuning\': \'hi\'\}, do not exist in the index \'self.dataframe.index\'",
):
tk.tree(metric_column="Avg time/rank", indicies=["Base_OpenMP", "hi"])
tk.tree(metric_column="Avg time/rank", indices=["Base_OpenMP", "hi"])
32 changes: 16 additions & 16 deletions thicket/thicket.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def tree(
render_header=True,
min_value=None,
max_value=None,
indicies=None,
indices=None,
):
"""Visualize the Thicket as a tree
Expand All @@ -607,7 +607,7 @@ def tree(
render_header (bool, optional): Shows the Preamble. Defaults to True.
min_value (int, optional): Overwrites the min value for the coloring legend. Defaults to None.
max_value (int, optional): Overwrites the max value for the coloring legend. Defaults to None.
indicies(tuple, list, optional): Index/Indicies to display on the DataFrame. Defaults to None.
indices(tuple, list, optional): Index/indices to display on the DataFrame. Defaults to None.
Returns:
(str): String representation of the tree, ready to print
Expand All @@ -633,44 +633,44 @@ def tree(
elif sys.version_info.major == 3:
unicode = True

if indicies is None:
if indices is None:
# Create slice out of first values found starting after the first index.
indicies = self.dataframe.index[0][1:]
elif isinstance(indicies, tuple):
indices = self.dataframe.index[0][1:]
elif isinstance(indices, tuple):
pass
elif isinstance(indicies, list): # Convert list to tuple
indicies = tuple(indicies)
elif isinstance(indices, list): # Convert list to tuple
indices = tuple(indices)
else: # Support for non-iterable types (int, str, ...)
try:
indicies = tuple([indicies])
indices = tuple([indices])
except TypeError:
raise TypeError(
f"Value provided to 'indicies' = {indicies} is an unsupported type {type(indicies)}"
f"Value provided to 'indices' = {indices} is an unsupported type {type(indices)}"
)
# For tree legend
idx_dict = {
self.dataframe.index.names[k + 1]: indicies[k] for k in range(len(indicies))
self.dataframe.index.names[k + 1]: indices[k] for k in range(len(indices))
}
# Slices the DataFrame to simulate a single-level index
try:
slice_df = (
self.dataframe.loc[(slice(None),) + indicies, :]
self.dataframe.loc[(slice(None),) + indices, :]
.reset_index()
.set_index("node")
)
except KeyError:
missing_indicies = {
missing_indices = {
list(idx_dict.keys())[i]: idx
for i, idx in enumerate(indicies)
for i, idx in enumerate(indices)
if all(idx not in df_idx[1:] for df_idx in self.dataframe.index)
}
raise KeyError(
f"The indicies, {missing_indicies}, do not exist in the index 'self.dataframe.index'"
f"The indices, {missing_indices}, do not exist in the index 'self.dataframe.index'"
)
# Check for compatibility
if len(slice_df) != len(self.graph):
raise KeyError(
f"Either dataframe cannot be represented as a single index or provided slice, '{indicies}' results in a multi-index. See self.dataframe.loc[(slice(None),)+{indicies},{metric_column}]"
f"Either dataframe cannot be represented as a single index or provided slice, '{indices}' results in a multi-index. See self.dataframe.loc[(slice(None),)+{indices},{metric_column}]"
)

# Prep DataFrame by filling None rows in the "name" column with the node's name.
Expand All @@ -697,7 +697,7 @@ def tree(
render_header=render_header,
min_value=min_value,
max_value=max_value,
indicies=idx_dict,
indices=idx_dict,
)

@staticmethod
Expand Down

0 comments on commit 7f03c36

Please sign in to comment.