Skip to content

Commit

Permalink
More clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
vulder committed Jan 23, 2024
1 parent 1848abc commit 78d7a3d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
23 changes: 11 additions & 12 deletions varats/varats/data/databases/feature_perf_precision_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ def _is_feature_relevant(
old_mean = np.mean(old_measurements)
new_mean = np.mean(new_measurements)

if old_mean < self.absolute_cut_off and new_mean < self.absolute_cut_off:
if old_mean < self.absolute_cut_off and \
new_mean < self.absolute_cut_off:
return False

old_rel_cut_off = old_mean * self.relative_cut_off
Expand All @@ -251,22 +252,21 @@ def _precise_pim_regression_check(

new_values = current_pim[feature]

# Skip features that seem not to be relevant for regressions testing
# Skip features that seem not to be relevant
# for regressions testing
if not self._is_feature_relevant(old_values, new_values):
continue

is_regression = is_regression or self._is_significantly_different(
old_values, new_values
)
is_regression = is_regression or \
self._is_significantly_different(
old_values, new_values
)
else:
if np.mean(old_values) > self.absolute_cut_off:
print(
f"Could not find feature {feature} in new trace. "
f"({np.mean(old_values)}us lost)"
)
# TODO: how to handle this?
# raise NotImplementedError()
# is_regression = True

return is_regression

Expand Down Expand Up @@ -302,8 +302,8 @@ def _sum_pim_regression_check(

mean_baseline = np.mean(baseline_pim_total)
mean_diff = abs(mean_baseline - np.mean(current_pim_total))
if mean_diff < self.absolute_cut_off \
or mean_diff < mean_baseline * self.relative_cut_off:
if mean_diff < self.absolute_cut_off or \
mean_diff < mean_baseline * self.relative_cut_off:
return False

return self._is_significantly_different(
Expand Down Expand Up @@ -596,14 +596,13 @@ def compute_profiler_predictions(
report_files[0], patch_name
)
except Exception as exception: # pylint: disable=W0718
# Print exception information but continue working on the plot/table
print(
f"FAILURE: Skipping {config_id=} of {project_name=}, "
f"profiler={profiler.name}"
)
print(exception)
print(traceback.format_exc())
# TODO: clean up
# raise exception

return result_dict

Expand Down
19 changes: 10 additions & 9 deletions varats/varats/tables/feature_perf_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@


def cmap_map(
function, cmap: colors.LinearSegmentedColormap
function: tp.Callable[[np.ndarray[np.float64]], np.float64],
cmap: colors.LinearSegmentedColormap
) -> colors.LinearSegmentedColormap:
"""
Applies function (which should operate on vectors of shape 3: [r, g, b]), on
colormap cmap.
This routine will break any discontinuous points in a colormap.
"""
c_dict = cmap._segmentdata # pylint: disable=protected-access # type: ignore
# pylint: disable=protected-access,attr-defined

Check warning on line 48 in varats/varats/tables/feature_perf_precision.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/tables/feature_perf_precision.py#L48 <12>

Unknown option value for 'disable', expected a valid pylint message and got 'attr-defined' (unknown-option-value)
Raw output
varats/varats/tables/feature_perf_precision.py:48:0: W0012: Unknown option value for 'disable', expected a valid pylint message and got 'attr-defined' (unknown-option-value)
c_dict = cmap._segmentdata # type: ignore
# pylint: enable=protected-access,attr-defined

Check warning on line 50 in varats/varats/tables/feature_perf_precision.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/tables/feature_perf_precision.py#L50 <12>

Unknown option value for 'enable', expected a valid pylint message and got 'attr-defined' (unknown-option-value)
Raw output
varats/varats/tables/feature_perf_precision.py:50:0: W0012: Unknown option value for 'enable', expected a valid pylint message and got 'attr-defined' (unknown-option-value)
step_dict: tp.Dict[str, tp.List[tp.Any]] = {}

# First get the list of points where the segments start or end
Expand Down Expand Up @@ -83,7 +86,7 @@ class FeaturePerfPrecisionTable(Table, table_name="fperf_precision"):
@staticmethod
def _prepare_data_table(
case_studies: tp.List[CaseStudy], profilers: tp.List[Profiler]
):
) -> pd.DataFrame:
df = pd.DataFrame()
table_rows = []

Expand All @@ -109,7 +112,6 @@ def _prepare_data_table(
}

for profiler in profilers:
# TODO: multiple patch cycles
predicted = compute_profiler_predictions(
profiler, project_name, case_study,
case_study.get_config_ids_for_revision(rev), patch_name
Expand Down Expand Up @@ -285,8 +287,6 @@ def tabulate(self, table_format: TableFormat, wrap_table: bool) -> str:
"CaseStudy", "Profiler", "time", "memory", "overhead_time",
"overhead_memory"
]]
# print(f"{overhead_df=}")
# TODO: double check and refactor
overhead_df['overhead_time_rel'] = overhead_df['time'] / (
overhead_df['time'] - overhead_df['overhead_time']
) * 100 - 100
Expand Down Expand Up @@ -354,7 +354,10 @@ def add_extras(doc: Document) -> None:
]
style.format({col: "{:.0f}" for col in mv_columns}, precision=2)

ryg_map = cmap_map(lambda x: x / 1.2 + 0.2, plt.get_cmap('RdYlGn'))
ryg_map = cmap_map(
lambda x: x / 1.2 + 0.2,

Check failure on line 358 in varats/varats/tables/feature_perf_precision.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/tables/feature_perf_precision.py#L358

error: Argument 1 to "cmap_map" has incompatible type "Callable[[ndarray[Any, Any]], ndarray[Any, dtype[floating[Any]]]]"; expected "Callable[[ndarray[Any, Any]], floating[_64Bit]]" [arg-type]
Raw output
varats/varats/tables/feature_perf_precision.py:358:17: error: Argument 1 to "cmap_map" has incompatible type "Callable[[ndarray[Any, Any]], ndarray[Any, dtype[floating[Any]]]]"; expected "Callable[[ndarray[Any, Any]], floating[_64Bit]]"  [arg-type]

Check failure on line 358 in varats/varats/tables/feature_perf_precision.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/tables/feature_perf_precision.py#L358

error: Incompatible return value type (got "ndarray[Any, dtype[floating[Any]]]", expected "floating[_64Bit]") [return-value]
Raw output
varats/varats/tables/feature_perf_precision.py:358:27: error: Incompatible return value type (got "ndarray[Any, dtype[floating[Any]]]", expected "floating[_64Bit]")  [return-value]
tp.cast(colors.LinearSegmentedColormap, plt.get_cmap('RdYlGn'))
)

style.background_gradient(
cmap=ryg_map,
Expand Down Expand Up @@ -462,9 +465,7 @@ def _calc_folder_locs_dune(repo_path: Path, rev_range: str) -> int:

for sub_project in dune_sub_projects:
sub_project_path = repo_path / sub_project
# TODO: get sub_rpoject hashes
locs = calc_repo_loc(sub_project_path, "HEAD")
# print(f"Calculated {locs} for {sub_project_path}")
total_locs += locs

return total_locs
Expand Down

0 comments on commit 78d7a3d

Please sign in to comment.