Skip to content

Commit

Permalink
entries of rows are now rounded to two decimals
Browse files Browse the repository at this point in the history
add mean and variance of tables via function
  • Loading branch information
Simon Rüdiger Steuer committed Sep 18, 2023
1 parent da584b8 commit f83e5b9
Showing 1 changed file with 41 additions and 56 deletions.
97 changes: 41 additions & 56 deletions varats/varats/tables/feature_blame_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,10 @@ def tabulate(self, table_format: TableFormat, wrap_table: bool) -> str:
)

# calc overall mean and variance for each column
for i in range(1, len(rows[0])):
# column with ranges, need different computation
if type(rows[0][i]) is tuple:
list_vals_min = [
rows[j][i][0] for j in range(0, len(case_studies))
]
list_vals_max = [
rows[j][i][1] for j in range(0, len(case_studies))
]
rows[len(case_studies)].append(
(np.mean(list_vals_min), np.mean(list_vals_max))
)
rows[len(case_studies) + 1].append(
(np.var(list_vals_min), np.var(list_vals_max))
)
continue
list_vals = [rows[j][i] for j in range(0, len(case_studies))]
rows[len(case_studies)].append(np.mean(list_vals))
rows[len(case_studies) + 1].append(np.var(list_vals))
add_mean_and_variance(rows, len(case_studies))

df = pd.DataFrame(
rows,
round_rows(rows),
columns=[
"Projects",
"Avg Num Impl Cmmts",
Expand Down Expand Up @@ -188,13 +170,10 @@ def tabulate(self, table_format: TableFormat, wrap_table: bool) -> str:
)

# calc overall mean and variance for each column
for i in range(1, len(rows[0])):
list_vals = [rows[j][i] for j in range(0, len(case_studies))]
rows[len(case_studies)].append(np.mean(list_vals))
rows[len(case_studies) + 1].append(np.var(list_vals))
add_mean_and_variance(rows, len(case_studies))

df = pd.DataFrame(
rows,
round_rows(rows),
columns=[
"Projects",
"Avg Num Ftrs Chngd",
Expand Down Expand Up @@ -267,7 +246,8 @@ def tabulate(self, table_format: TableFormat, wrap_table: bool) -> str:
rows[current_row].append(var_num_impl_authors)

range_num_impl_authors = (
min(data_num_impl_authors), max(data_num_impl_authors)
min(data_num_impl_authors),
max(data_num_impl_authors),
)
rows[current_row].append(range_num_impl_authors)

Check failure on line 252 in varats/varats/tables/feature_blame_tables.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/tables/feature_blame_tables.py#L252

error: Argument 1 to "append" of "list" has incompatible type "tuple[Any, Any]"; expected "str" [arg-type]
Raw output
varats/varats/tables/feature_blame_tables.py:252:38: error: Argument 1 to "append" of "list" has incompatible type "tuple[Any, Any]"; expected "str"  [arg-type]

Expand All @@ -280,27 +260,10 @@ def tabulate(self, table_format: TableFormat, wrap_table: bool) -> str:
)

# calc overall mean and variance for each column
for i in range(1, len(rows[0])):
if type(rows[0][i]) is tuple:
list_vals_min = [
rows[j][i][0] for j in range(0, len(case_studies))
]
list_vals_max = [
rows[j][i][1] for j in range(0, len(case_studies))
]
rows[len(case_studies)].append(
(np.mean(list_vals_min), np.mean(list_vals_max))
)
rows[len(case_studies) + 1].append(
(np.var(list_vals_min), np.var(list_vals_max))
)
continue
list_vals = [rows[j][i] for j in range(0, len(case_studies))]
rows[len(case_studies)].append(np.mean(list_vals))
rows[len(case_studies) + 1].append(np.var(list_vals))
add_mean_and_variance(rows, len(case_studies))

df = pd.DataFrame(
rows,
round_rows(rows),
columns=[
"Projects",
"Avg Num Impl Authors",
Expand Down Expand Up @@ -332,7 +295,7 @@ def tabulate(self, table_format: TableFormat, wrap_table: bool) -> str:
class SFBRAuthorEvalTableGenerator(

Check failure on line 295 in varats/varats/tables/feature_blame_tables.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/tables/feature_blame_tables.py#L295 <115>

Missing class docstring (missing-class-docstring)
Raw output
varats/varats/tables/feature_blame_tables.py:295:0: C0115: Missing class docstring (missing-class-docstring)
TableGenerator,
generator_name="sfbr-author-eval-table",
options=[REQUIRE_MULTI_CASE_STUDY]
options=[REQUIRE_MULTI_CASE_STUDY],
):

def generate(self) -> tp.List[Table]:
Expand Down Expand Up @@ -425,13 +388,10 @@ def tabulate(self, table_format: TableFormat, wrap_table: bool) -> str:
rows[current_row].append(likelihood_coincide_structural_dataflow)

# calc overall mean and variance for each column
for i in range(1, len(rows[0])):
list_vals = [rows[j][i] for j in range(0, len(case_studies))]
rows[len(case_studies)].append(np.mean(list_vals))
rows[len(case_studies) + 1].append(np.var(list_vals))
add_mean_and_variance(rows, len(case_studies))

df = pd.DataFrame(
rows,
round_rows(rows),
columns=[
"Projects",
"Avg Num Interacting Features",
Expand Down Expand Up @@ -518,13 +478,10 @@ def tabulate(self, table_format: TableFormat, wrap_table: bool) -> str:
)

# calc overall mean and variance for each column
for i in range(1, len(rows[0])):
list_vals = [rows[j][i] for j in range(0, len(case_studies))]
rows[len(case_studies)].append(np.mean(list_vals))
rows[len(case_studies) + 1].append(np.var(list_vals))
add_mean_and_variance(rows, len(case_studies))

df = pd.DataFrame(
rows,
round_rows(rows),
columns=[
"Projects",
"Corr Feature Size Num Interacting Commtis Outside DF",
Expand Down Expand Up @@ -613,3 +570,31 @@ def generate(self) -> tp.List[Table]:
self.table_config, case_study=case_study, **self.table_kwargs
)
]


def round_rows(rows) -> []:

Check failure on line 575 in varats/varats/tables/feature_blame_tables.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/tables/feature_blame_tables.py#L575

error: Function is missing a type annotation for one or more arguments [no-untyped-def]
Raw output
varats/varats/tables/feature_blame_tables.py:575:1: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
return [[
entry if type(entry) is str else

Check failure on line 577 in varats/varats/tables/feature_blame_tables.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/tables/feature_blame_tables.py#L577 <123>

Use isinstance() rather than type() for a typecheck. (unidiomatic-typecheck)
Raw output
varats/varats/tables/feature_blame_tables.py:577:17: C0123: Use isinstance() rather than type() for a typecheck. (unidiomatic-typecheck)
((round(entry[0], 2),
round(entry[1], 2)) if type(entry) is tuple else round(entry, 2))

Check failure on line 579 in varats/varats/tables/feature_blame_tables.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/tables/feature_blame_tables.py#L579 <123>

Use isinstance() rather than type() for a typecheck. (unidiomatic-typecheck)
Raw output
varats/varats/tables/feature_blame_tables.py:579:33: C0123: Use isinstance() rather than type() for a typecheck. (unidiomatic-typecheck)
for entry in row
]
for row in rows]


def add_mean_and_variance(rows, num_case_studies) -> None:

Check failure on line 585 in varats/varats/tables/feature_blame_tables.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/tables/feature_blame_tables.py#L585

error: Function is missing a type annotation for one or more arguments [no-untyped-def]
Raw output
varats/varats/tables/feature_blame_tables.py:585:1: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]

Check failure on line 585 in varats/varats/tables/feature_blame_tables.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/tables/feature_blame_tables.py#L585 <116>

Missing function or method docstring (missing-function-docstring)
Raw output
varats/varats/tables/feature_blame_tables.py:585:0: C0116: Missing function or method docstring (missing-function-docstring)
for i in range(1, len(rows[0])):
# column with ranges, need different computation
if type(rows[0][i]) is tuple:

Check failure on line 588 in varats/varats/tables/feature_blame_tables.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/tables/feature_blame_tables.py#L588 <123>

Use isinstance() rather than type() for a typecheck. (unidiomatic-typecheck)
Raw output
varats/varats/tables/feature_blame_tables.py:588:11: C0123: Use isinstance() rather than type() for a typecheck. (unidiomatic-typecheck)
list_vals_min = [rows[j][i][0] for j in range(0, num_case_studies)]
list_vals_max = [rows[j][i][1] for j in range(0, num_case_studies)]
rows[num_case_studies].append(
(np.mean(list_vals_min), np.mean(list_vals_max))
)
rows[num_case_studies + 1].append(
(np.var(list_vals_min), np.var(list_vals_max))
)
continue
list_vals = [rows[j][i] for j in range(0, num_case_studies)]
rows[num_case_studies].append(np.mean(list_vals))
rows[num_case_studies + 1].append(np.var(list_vals))

0 comments on commit f83e5b9

Please sign in to comment.