From 3d6b4ffa794d9cdf1142ab891730eef6eba97b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6hm?= Date: Fri, 22 Sep 2023 08:06:40 +0200 Subject: [PATCH 1/2] Fixes docs break with matplotlib >=3.8 (#837) --- docs/source/conf.py | 4 ++++ docs/source/vara-ts-api/tools/vara-cs-gui.rst | 1 + varats/varats/data/metrics.py | 12 +++++++----- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index ef57a97cf..54392b0f2 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -87,6 +87,10 @@ # modules that require this module before setting the type checking flag. import scipy.stats # isort:skip +# Matplotlib >=3.8 has a type-checking-flag-guarded import of a symbol that does +# not exist in the shipped version. +import matplotlib.pyplot # isort:skip + # The autodocs typehints plugin does not resolve circular imports caused by type # annotations, so we have to manually break the circles. import rich.console # isort:skip diff --git a/docs/source/vara-ts-api/tools/vara-cs-gui.rst b/docs/source/vara-ts-api/tools/vara-cs-gui.rst index 96c3493a7..dcdd6219c 100644 --- a/docs/source/vara-ts-api/tools/vara-cs-gui.rst +++ b/docs/source/vara-ts-api/tools/vara-cs-gui.rst @@ -10,6 +10,7 @@ The gui is started by:: The gui provides 3 Strategies to generate case studies: - Manual revision selection: Select revision from the revision history of a project. Multiple revisions can be selected by holding `ctrl` and ranges by holding `shift`. Revisions which are blocked because of bugs in the compilation of the project are marked blue. + .. figure:: vara-cs-gui-manual.png - Random Sampling: Sample a number of revisions using a random a Normal or HalfNormal Distribution. diff --git a/varats/varats/data/metrics.py b/varats/varats/data/metrics.py index 78102735e..4524dc205 100644 --- a/varats/varats/data/metrics.py +++ b/varats/varats/data/metrics.py @@ -28,7 +28,7 @@ def gini_coefficient(distribution: pd.Series) -> float: Calculates the Gini coefficient of the data. For more information see online - `gini coefficient `_. + `Gini coefficient `_. Args: distribution: sorted series to calculate the Gini coefficient for @@ -141,10 +141,12 @@ class ConfusionMatrix(tp.Generic[T]): """ Helper class to automatically calculate classification results. - | Predicted Positive (PP) | Predicted Negative (PN) - --------------------|---------------------------|-------------------------- - Actual Positive (P) | True Positive (TP) | False Negative (FN) - Actual Negative (N) | False Positive (FP) | True Negative (TN) + +---------------------+-------------------------+-------------------------+ + | | Predicted Positive (PP) | Predicted Negative (PN) | + +---------------------+-------------------------+-------------------------+ + | Actual Positive (P) | True Positive (TP) | False Negative (FN) | + | Actual Negative (N) | False Positive (FP) | True Negative (TN) | + +---------------------+-------------------------+-------------------------+ Reference: https://en.wikipedia.org/wiki/Precision_and_recall """ From b344eb428c12803502515143b3459b76dfc243dd Mon Sep 17 00:00:00 2001 From: Lukas Abelt Date: Fri, 22 Sep 2023 08:27:43 +0200 Subject: [PATCH 2/2] Adds support for SingleRevision for the only_valid_in parameter of RevisionBinaryMap (#836) resolves se-sic/VaRA#1040 --- tests/utils/test_git_util.py | 13 ++++++++++++- varats-core/varats/utils/git_util.py | 10 +++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/utils/test_git_util.py b/tests/utils/test_git_util.py index 1450add2a..c11818665 100644 --- a/tests/utils/test_git_util.py +++ b/tests/utils/test_git_util.py @@ -2,7 +2,7 @@ import unittest from pathlib import Path -from benchbuild.utils.revision_ranges import RevisionRange +from benchbuild.utils.revision_ranges import RevisionRange, SingleRevision from varats.project.project_util import ( get_local_project_git, @@ -568,6 +568,17 @@ def test_specification_validity_range_multiple_binaries(self) -> None: self.assertIn("SingleLocalMultipleRegions", self.rv_map) self.assertIn("SingleLocalSimple", self.rv_map) + def test_specification_single_revision(self) -> None: + """Check if we can add binaries that are only valid with a single + revision.""" + self.rv_map.specify_binary( + "build/bin/SingleLocalMultipleRegions", + BinaryType.EXECUTABLE, + only_valid_in=SingleRevision("162db88346") + ) + + self.assertIn("SingleLocalMultipleRegions", self.rv_map) + def test_specification_binaries_with_special_name(self) -> None: """Check if we can add binaries that have a special name.""" self.rv_map.specify_binary( diff --git a/varats-core/varats/utils/git_util.py b/varats-core/varats/utils/git_util.py index 413ecd269..6f0cd1c1d 100644 --- a/varats-core/varats/utils/git_util.py +++ b/varats-core/varats/utils/git_util.py @@ -1063,7 +1063,9 @@ def specify_binary( override_entry_point = kwargs.get("override_entry_point", None) if override_entry_point: override_entry_point = Path(override_entry_point) - validity_range = kwargs.get("only_valid_in", None) + validity_range: AbstractRevisionRange = kwargs.get( + "only_valid_in", None + ) valid_exit_codes = kwargs.get("valid_exit_codes", None) wrapped_binary = ProjectBinaryWrapper( @@ -1072,6 +1074,7 @@ def specify_binary( ) if validity_range: + validity_range.init_cache(self.__repo_location) self.__revision_specific_mappings[validity_range].append( wrapped_binary ) @@ -1087,10 +1090,7 @@ def __getitem__(self, for validity_range, wrapped_binaries \ in self.__revision_specific_mappings.items(): - if revision in get_all_revisions_between( - validity_range.id_start, validity_range.id_end, ShortCommitHash, - self.__repo_location - ): + if revision in map(ShortCommitHash, validity_range): revision_specific_binaries.extend(wrapped_binaries) revision_specific_binaries.extend(self.__always_valid_mappings)