Skip to content

Commit

Permalink
Autoformat with black
Browse files Browse the repository at this point in the history
  • Loading branch information
brainless-bot[bot] committed Aug 28, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 03a25ea commit fad4d57
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions panoptica/panoptica_statistics.py
Original file line number Diff line number Diff line change
@@ -43,7 +43,9 @@ def from_file(cls, file: str):
rows = [row for row in rd]

header = rows[0]
assert header[0] == "subject_name", "First column is not subject_names, something wrong with the file?"
assert (
header[0] == "subject_name"
), "First column is not subject_names, something wrong with the file?"

keys_in_order = list([tuple(c.split("-")) for c in header[1:]])
metric_names = []
@@ -77,13 +79,19 @@ def from_file(cls, file: str):
return Panoptica_Statistic(subj_names=subj_names, value_dict=value_dict)

def _assertgroup(self, group):
assert group in self.__groupnames, f"group {group} not existent, only got groups {self.__groupnames}"
assert (
group in self.__groupnames
), f"group {group} not existent, only got groups {self.__groupnames}"

def _assertmetric(self, metric):
assert metric in self.__metricnames, f"metric {metric} not existent, only got metrics {self.__metricnames}"
assert (
metric in self.__metricnames
), f"metric {metric} not existent, only got metrics {self.__metricnames}"

def _assertsubject(self, subjectname):
assert subjectname in self.__subj_names, f"subject {subjectname} not in list of subjects, got {self.__subj_names}"
assert (
subjectname in self.__subj_names
), f"subject {subjectname} not in list of subjects, got {self.__subj_names}"

def get(self, group, metric) -> list[float]:
"""Returns the list of values for given group and metric
@@ -114,7 +122,10 @@ def get_one_subject(self, subjectname: str):
"""
self._assertsubject(subjectname)
sidx = self.__subj_names.index(subjectname)
return {g: {m: self.get(g, m)[sidx] for m in self.__metricnames} for g in self.__groupnames}
return {
g: {m: self.get(g, m)[sidx] for m in self.__metricnames}
for g in self.__groupnames
}

def get_across_groups(self, metric):
"""Given metric, gives list of all values (even across groups!) Treat with care!
@@ -131,7 +142,10 @@ def get_across_groups(self, metric):
return values

def get_summary_dict(self):
return {g: {m: self.get_summary(g, m) for m in self.__metricnames} for g in self.__groupnames}
return {
g: {m: self.get_summary(g, m) for m in self.__metricnames}
for g in self.__groupnames
}

def get_summary(self, group, metric):
# TODO maybe more here? range, stuff like that
@@ -195,7 +209,9 @@ def make_curve_over_setups(
groups = [groups]
#
for setupname, stat in statistics_dict.items():
assert metric in stat.metricnames, f"metric {metric} not in statistic obj {setupname}"
assert (
metric in stat.metricnames
), f"metric {metric} not in statistic obj {setupname}"

setupnames = list(statistics_dict.keys())
convert_x_to_digit = True
@@ -260,10 +276,14 @@ def plot_box(
if sort:
df_by_spec_count = df_data.groupby(graph_name).mean()
df_by_spec_count = dict(df_by_spec_count[score].items())
df_data["mean"] = df_data[graph_name].apply(lambda x: df_by_spec_count[x] * (1 if orientation == "h" else -1))
df_data["mean"] = df_data[graph_name].apply(
lambda x: df_by_spec_count[x] * (1 if orientation == "h" else -1)
)
df_data = df_data.sort_values(by="mean")
if orientation == "v":
fig = px.strip(df_data, x=graph_name, y=score, stripmode="overlay", orientation=orientation)
fig = px.strip(
df_data, x=graph_name, y=score, stripmode="overlay", orientation=orientation
)
fig.update_traces(marker={"size": 5, "color": "#555555"})
for e in data.keys():
fig.add_trace(
@@ -274,7 +294,9 @@ def plot_box(
)
)
else:
fig = px.strip(df_data, y=graph_name, x=score, stripmode="overlay", orientation=orientation)
fig = px.strip(
df_data, y=graph_name, x=score, stripmode="overlay", orientation=orientation
)
fig.update_traces(marker={"size": 5, "color": "#555555"})
for e in data.keys():
fig.add_trace(

0 comments on commit fad4d57

Please sign in to comment.