How to use the temci.utils.number.FNumber 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 / report / report.py View on Github external
def _report_block_with_baseline(self, block: RunData, print_func: t.Callable[[str], None], baseline: RunData,
                                    descr_size: int):
        print_func("{descr:<20} ({num:>5}) with baseline {descr2:<20} ({num2:>5})"
                   .format(descr=block.description(), num=len(block.data[block.properties[0]]),
                           descr2=block.description(), num2=len(block.data[block.properties[0]])))
        combined_props = set(block.properties) & set(baseline.properties)
        tester = TesterRegistry.get_tester()
        for prop in sorted(combined_props):
            mean = np.mean(block[prop])
            std = np.std(block[prop])
            base_mean = baseline.get_single_properties()[prop].mean()
            base_std = baseline.get_single_properties()[prop].std()
            mean_str = str(FNumber(mean / base_mean, abs_deviation=std / base_mean, is_percent=True))
            dev = "{:>5.5%}".format(std / mean) if mean != 0 else "{:>5.5}".format(std)
            print_func("\t {{prop:<{}}} mean = {{mean:>15s}}, confidence = {{conf:>5.0%}}, dev = {{dev:>11s}}, "
                       "{{dbase:>11s}}".format(descr_size)
                .format(
                    prop=prop,
                    mean=mean_str,
                    dev=dev,
                    conf=tester.test(block[prop], baseline[prop]),
                    dbase="{:>5.5%}".format(base_std / base_mean) if base_mean != 0 else "{:>5.5}".format(base_std)))
        rels = [(block.get_single_properties()[prop].mean() / baseline.get_single_properties()[prop].mean())
                            for prop in combined_props]
        gmean = stats.gmean(rels)
        gstd = util.geom_std(rels)
        print_func("geometric mean of relative mean = {:>15}, std dev = {:>15}"
                   .format(FNumber(gmean, is_percent=True).format(), FNumber(gstd, is_percent=True).format()))
github parttimenerd / temci / temci / report / report.py View on Github external
mean_str = str(FNumber(mean / base_mean, abs_deviation=std / base_mean, is_percent=True))
            dev = "{:>5.5%}".format(std / mean) if mean != 0 else "{:>5.5}".format(std)
            print_func("\t {{prop:<{}}} mean = {{mean:>15s}}, confidence = {{conf:>5.0%}}, dev = {{dev:>11s}}, "
                       "{{dbase:>11s}}".format(descr_size)
                .format(
                    prop=prop,
                    mean=mean_str,
                    dev=dev,
                    conf=tester.test(block[prop], baseline[prop]),
                    dbase="{:>5.5%}".format(base_std / base_mean) if base_mean != 0 else "{:>5.5}".format(base_std)))
        rels = [(block.get_single_properties()[prop].mean() / baseline.get_single_properties()[prop].mean())
                            for prop in combined_props]
        gmean = stats.gmean(rels)
        gstd = util.geom_std(rels)
        print_func("geometric mean of relative mean = {:>15}, std dev = {:>15}"
                   .format(FNumber(gmean, is_percent=True).format(), FNumber(gstd, is_percent=True).format()))
github parttimenerd / temci / temci / report / report.py View on Github external
lying.<p></p>
                        <p>The geometric standard deviation is <b>%s</b></p>.
                    """ % self._percent_format.format(pair.first_rel_to_second_std())
                    rel_diff = fnumber(pair.first_rel_to_second(), rel_deviation=pair.first_rel_to_second_std() - 1, is_percent=True)
                    popover.trigger = "hover click"
                else:
                    pair = pair[property]
                    popover.content="""First mean relative to the second mean:
                    \\begin{align}
                        &amp; \\frac{\\overline{\\text{first[%s]}}}{\\overline{\\text{second[%s]}}} \\\\
                        &amp;= \\frac{%5.4f}{%5.4f}
                    \\end{align}
                    <p>The maximum standard deviation of both benchmarks relative to the mean of the second one is <b>%s</b>.</p>
                    """ % (property, property, pair.first.mean(), pair.second.mean(),
                           self._percent_format.format(pair.max_std_dev() / pair.second.mean()))
                    rel_diff = FNumber(pair.first_rel_to_second(), rel_deviation=pair.max_std_dev() / pair.second.mean(), is_percent=True)
                cell = _Cell(self, content=str(rel_diff), popover=popover, color_class_obj=pair, show_click_on_info=True)
                cell.modal_id = self._short_summary_modal(pair)
                table[i, j] = cell
        return table
github parttimenerd / temci / temci / scripts / cli.py View on Github external
def temci__format(number, abs_deviation, **kwargs):
    print(FNumber(number, abs_deviation=abs_deviation).format())
github parttimenerd / temci / temci / report / report.py View on Github external
def __init__(self, misc_settings = None, stats_helper: RunDataStatsHelper = None,
                 excluded_properties: t.List[str] = None):
        """
        Creates an instance.

        :param misc_settings: configuration
        :param stats_helper: used stats helper instance
        :param excluded_properties: measured properties that are excluded from the reports
        """
        FNumber.init_settings(Settings()["report/number"])
        excluded_properties = excluded_properties or Settings()["report/excluded_properties"]
        self.misc = misc_settings
        """ Configuration """
        self.stats_helper = None  # type: RunDataStatsHelper
        """ Used starts helper """
        if stats_helper is None:
            report_in = Settings()["report/in"]
            typecheck(report_in, Either(ValidYamlFileName(), ListOrTuple(ValidYamlFileName())))
            if isinstance(report_in, str):
                report_in = [report_in]
            runs = []
            for file in report_in:
                with open(file, "r") as f:
                    runs.extend(yaml.safe_load(f))
            self.stats_helper = RunDataStatsHelper.init_from_dicts(runs)
        else: