def val_by_type(pds, valtype, dim, fid): fid = resolve_fid(fid) if valtype == "rank": return val_rank(pds, dim=dim, funcId=fid) elif valtype.startswith("slowdown2"): m = re.match("slowdown2(.*)", valtype) if m: strat = m.group(1) return val_slowdown(pds, baseline_name=strat, dim=dim, funcId=fid) raise ValueError('valtype ' + valtype) raise ValueError('valtype ' + valtype)
def plot_by_type(pds, ax, plottype, dim, fid): fid = resolve_fid(fid) if plottype == "fval_by_budget": return cplot.fval_by_budget(ax, pds, dim=dim, funcId=fid) elif plottype.startswith("fval2"): m = re.match("fval2(.*)_by_budget", plottype) if m: strat = m.group(1) stratds = get_stratds(pds, strat, dim, fid) return cplot.fval_by_budget(ax, pds, baseline_ds=stratds, baseline_label=strat, dim=dim, funcId=fid) raise ValueError('plottype ' + plottype) elif plottype == "rank_by_budget": return cplot.rank_by_budget(ax, pds, dim=dim, funcId=fid) elif plottype == "evals_by_target": return cplot.evals_by_target(ax, pds, dim=dim, funcId=fid) elif plottype.startswith("evals2") and plottype.endswith("_by_target"): # e.g. evals2mUNIF7_by_target for data relative to mUNIF7 # evals2oracle_by_target is a special case that gives nice plots! m = re.match("evals2(.*)_by_target", plottype) if m: strat = m.group(1) stratds = get_stratds(pds, strat, dim, fid) return cplot.evals_by_target(ax, pds, baseline_ds=stratds, baseline_label=strat, dim=dim, funcId=fid) raise ValueError('plottype ' + plottype) elif plottype.startswith("evals2"): # e.g. evals2mUNIF7_by_evals2oracle m = re.match("evals2(.*)_by_evals(?:2(.*))?", plottype) if m: strat1 = m.group(1) strat1ds = get_stratds(pds, strat1, dim, fid) strat2 = m.group(2) if strat2 is not None: strat2ds = get_stratds(pds, strat2, dim, fid) else: strat2 = '' strat2ds = None return cplot.evals_by_evals(ax, pds, baseline1_ds=strat1ds, baseline1_label=strat1, baseline2_ds=strat2ds, baseline2_label=strat2, dim=dim, funcId=fid) raise ValueError('plottype ' + plottype) raise ValueError('plottype ' + plottype)