How to use the temci.utils.util.InsertionTimeOrderedDict function in temci

To help you get started, we’ve selected a few temci examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github parttimenerd / temci / temci / misc / game.py View on Github external
Returns the html for a table that has a row for each implementation and several columns (the first is the
        implementation column).
        """
        columns = [col() if not isinstance(col, BOTableColumn) else col for col in columns]
        tex = """
        \\begin{{tabular}}{{l{cs}}}\\toprule
           & {header} \\\\ \\midrule
        """.format(cs="".join("r" * len(columns)), header=" & ".join(col.title for col in columns))
        html = """
        {header}
        """.format(header="".join("".format(col.title) for col in columns))
        cells = [["", ]]
        for col in columns:
            cells[0].append(col.title)
        values = InsertionTimeOrderedDict() # t.Dict[t.List[str]]
        for (i, col) in enumerate(columns):
            xes = self.get_reduced_x_per_impl(col.property, col.reduce, x_per_impl_func)
            for (j, impl) in enumerate(xes):
                if impl not in values:
                    values[impl] = []
                values[impl].append(col.format_str.format(xes[impl]))
                if j + 1 >= len(cells):
                    cells.append([repr(impl)])
                cells[j + 1].append(repr(col.format_str.format(xes[impl])))
        for impl in values:
            html += """
                {}
            """.format(impl, "".join("".format(val) for val in values[impl]))
            tex += """
                {} & {} \\\\
            """.format(impl, " &amp; ".join(str(val).replace("%", "\\%") for val in values[impl]))<table class="table">
            <tbody><tr><th></th></tr><tr><th>{}</th></tr><tr><td scope="row">{}</td></tr><tr><td>{}</td></tr></tbody></table>
github parttimenerd / temci / temci / misc / game.py View on Github external
def get_x_per_impl_and_input(self, property: StatProperty, input: str) -> t.Dict[str, t.List[float]]:
        scores_per_impl = InsertionTimeOrderedDict()
        for prog in self.programs:
            prog_val = self.programs[prog]
            scores = prog_val.prog_inputs[input].get_x_per_impl(property)
            #pprint(scores._dict)
            for impl in scores:
                if impl not in scores_per_impl:
                    scores_per_impl[impl] = []
                scores_per_impl[impl].extend(scores[impl])
        typecheck(scores_per_impl._dict, Dict(key_type=Str(), value_type=List(Float()|Int()), unknown_keys=True))
        return scores_per_impl
github parttimenerd / temci / temci / misc / game.py View on Github external
def get_x_per_impl_and_input(self, property: StatProperty, input_num: int) -&gt; t.Dict[str, t.List[float]]:
        means = InsertionTimeOrderedDict()  # type: t.Dict[str, t.List[float]]
        for child in self.categories.values():
            inputs = child.get_input_strs()
            if len(inputs) &lt;= input_num:
                continue
            child_means = child.get_x_per_impl_and_input(property, inputs[input_num])
            for impl in child_means:
                if impl not in means:
                    means[impl] = []
                means[impl].extend(child_means[impl])
        typecheck(means._dict, Dict(key_type=Str(), value_type=List(Float()|Int()), unknown_keys=True))
        return means
github parttimenerd / temci / temci / misc / game.py View on Github external
def last_inputs(inputs_per_category: InputsPerCategory) -> t.Dict[str, t.List[Input]]:
    ret = InsertionTimeOrderedDict()
    for key in inputs_per_category:
        if len(inputs_per_category[key]) > 0:
            ret[key] = [inputs_per_category[key][-1]]
    return ret
github parttimenerd / temci / temci / misc / game.py View on Github external
def get_statistical_property_scores(self, func: StatisticalPropertyFunc) -> t.Dict[str, t.List[float]]:
        d = InsertionTimeOrderedDict()  # type: t.Dict[str, t.List[float]]
        for input in self.prog_inputs:
            rel_vals = self.prog_inputs[input].get_statistical_properties_for_each(func)
            for impl in rel_vals:
                if impl not in d:
                    d[impl] = []
                d[impl].append(rel_vals[impl])
        return d
github parttimenerd / temci / temci / misc / game.py View on Github external
def get_statistical_property_scores_per_impl(self, func: StatisticalPropertyFunc) -> t.Dict[str, t.List[float]]:
        impl_scores = InsertionTimeOrderedDict()
        for cat in self.categories:
            scores = self.categories[cat].get_statistical_property_scores(func)
            for impl in scores:
                if impl not in impl_scores:
                    impl_scores[impl] = []
                impl_scores[impl].append(scores[impl])
        return impl_scores
github parttimenerd / temci / temci / misc / game.py View on Github external
def get_statistical_properties_for_each(self, func: StatisticalPropertyFunc) -> t.Dict[str, float]:
        sps = self.get_single_properties()
        means = [sp.mean() for (impl, sp) in sps]
        d = InsertionTimeOrderedDict()
        for (impl, sp) in sps:
            d[impl] = func(sp, means)
        return d