Skip to content

Commit

Permalink
Alow both ratio and displots
Browse files Browse the repository at this point in the history
  • Loading branch information
gevtushenko committed May 5, 2023
1 parent fad1886 commit 997723a
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions benchmarks/scripts/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,19 @@ def variant_ratio(data, variant, ax):
quantiles = []
ratios = []

base_x = min(base_samples)
variant_x = min(variant_samples)

for i in range(1, len(variant_heights) - 1):
variant_height = variant_heights[i]
base_height = base_heights[i]
base_x += base_widths[i] / 2
variant_x += variant_widths[i] / 2
quantiles.append(i * precision)
ratios.append(variant_height / base_height)
ratios.append(base_x / variant_x)

ax.plot(quantiles, ratios, label=variant, color=color)
ax.axhline(1, color='red', alpha=0.7)
ax.legend()
ax.tick_params(axis='both', direction='in', pad=-22)


def ratio(data, ax):
Expand All @@ -390,7 +394,7 @@ def ratio(data, ax):
variant_ratio(data, variant, ax)


def case_variants(pattern, algname, ct_point_name, case_df):
def case_variants(pattern, mode, algname, ct_point_name, case_df):
title = "{}[{}]:".format(algname, ct_point_name)
df = case_df[case_df['variant'].str.contains(pattern, regex=True)].reset_index(drop=True)
rt_axes = get_rt_axes(df)
Expand Down Expand Up @@ -462,9 +466,11 @@ def extract_horizontal_space(df):
data['base'] = horizontal_df[horizontal_df['variant'] == variant_name].iloc[0]['base_samples']
data[variant_name] = horizontal_df[horizontal_df['variant'] == variant_name].iloc[0]['samples']

# sns.histplot(data=data, ax=ax, kde=True)
# displot(data, ax)
ratio(data, ax)
if mode == 'pdf':
# sns.histplot(data=data, ax=ax, kde=True)
displot(data, ax)
else:
ratio(data, ax)

if len(horizontal_axes) > 0:
ax=axes[vertical_id, horizontal_id]
Expand All @@ -477,17 +483,16 @@ def extract_horizontal_space(df):

for ax in axes.flat:
ax.set_xticklabels([])
ax.set_yticklabels([])

fig.suptitle(title)
plt.tight_layout()
plt.show()



def variants(args):
pattern = re.compile(args.variants)
iterate_case_dfs(args, functools.partial(case_variants, pattern))
def variants(args, mode):
pattern = re.compile(args.variants_pdf) if mode == 'pdf' else re.compile(args.variants_ratio)
iterate_case_dfs(args, functools.partial(case_variants, pattern, mode))


def parse_arguments():
Expand All @@ -504,7 +509,9 @@ def parse_arguments():
parser.add_argument(
'--alpha', default=1.0, type=float)
parser.add_argument(
'--variants', type=str, help="Show matching variants data.")
'--variants-pdf', type=str, help="Show matching variants data.")
parser.add_argument(
'--variants-ratio', type=str, help="Show matching variants data.")
return parser.parse_args()


Expand All @@ -522,8 +529,12 @@ def main():
coverage(args)
return

if args.variants:
variants(args)
if args.variants_pdf:
variants(args, 'pdf')
return

if args.variants_ratio:
variants(args, 'ratio')
return

top(args)
Expand Down

0 comments on commit 997723a

Please sign in to comment.