当前位置: 首页>>代码示例>>Python>>正文


Python DotDict.rounded_in_sig_ratio方法代码示例

本文整理汇总了Python中socorrolib.lib.util.DotDict.rounded_in_sig_ratio方法的典型用法代码示例。如果您正苦于以下问题:Python DotDict.rounded_in_sig_ratio方法的具体用法?Python DotDict.rounded_in_sig_ratio怎么用?Python DotDict.rounded_in_sig_ratio使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在socorrolib.lib.util.DotDict的用法示例。


在下文中一共展示了DotDict.rounded_in_sig_ratio方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _summary_for_a_product_version_pair

# 需要导入模块: from socorrolib.lib.util import DotDict [as 别名]
# 或者: from socorrolib.lib.util.DotDict import rounded_in_sig_ratio [as 别名]
    def _summary_for_a_product_version_pair(self, an_accumulator):
        """in the original code, the counter structures were walked and
        manipulated to form the statistics.  Once a stat was determined,
        it was printed to stdout.  Since we want to have various means of
        outputting the data, instead of printing to stdout, this method
        save the statistic in a "summary_structure"  This structure will
        later be walked for printing or output to some future storage scheme

        The summary structure looks like this:

        summary[product_version*]
            .note - a list of comments by the algorithm
            [os_name]
                .count
                .signatures[signame*]
                    .name
                    .count
                    .cores[number_of_cores]
                        .in_sig_count
                        .in_sig_ratio
                        .rounded_in_sig_ratio
                        .in_os_count
                        .in_os_ratio
                        .rounded_in_os_ratio

        """
        pv_summary = {
            'notes': [],
        }
        if (len(self.date_suffix) > 1):
            message = (
                "crashes from more than one day %s" %
                str(tuple(self.date_suffix.keys()))
            )
            pv_summary['notes'].append(message)
        pv_summary['date_key'] = self.date_suffix.keys()[0]

        MIN_CRASHES = self.config.min_crashes
        osyses = an_accumulator.osyses

        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # begin - minimally altered section from original code
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        infostr_re = re.compile("^(.*) with (\d+) cores$")

        #----------------------------------------------------------------------
        def cmp_infostr(x, y):
            (familyx, coresx) = infostr_re.match(x).groups()
            (familyy, coresy) = infostr_re.match(y).groups()
            if familyx != familyy:
                return cmp(familyx, familyy)
            return cmp(int(coresx), int(coresy))

        #----------------------------------------------------------------------
        sorted_osyses = osyses.keys()
        sorted_osyses.sort()

        for osname in sorted_osyses:
            osys = osyses[osname]

            pv_summary[osname] = SocorroDotDict()
            pv_summary[osname].count = osys['count']
            pv_summary[osname].signatures = {}

            sorted_signatures = [sig for sig in osys["signatures"].items()
                                 if sig[1]["count"] >= MIN_CRASHES]
            sorted_signatures.sort(
                key=lambda tuple: tuple[1]["count"],
                reverse=True
            )
            sorted_cores = osys["core_counts"].keys()
            # strongly suspect that sorting is useless here
            sorted_cores.sort(cmp=cmp_infostr)
            for signame, sig in sorted_signatures:
                pv_summary[osname].signatures[signame] = SocorroDotDict({
                    'name': signame,
                    'count': sig['count'],
                    'cores': {},
                })
                by_number_of_cores = \
                    pv_summary[osname].signatures[signame].cores
                for cores in sorted_cores:
                    by_number_of_cores[cores] = SocorroDotDict()
                    in_sig_count = sig["core_counts"].get(cores, 0)
                    in_sig_ratio = float(in_sig_count) / sig["count"]
                    in_os_count = osys["core_counts"][cores]
                    in_os_ratio = float(in_os_count) / osys["count"]

                    rounded_in_sig_ratio = int(round(in_sig_ratio * 100))
                    rounded_in_os_ratio = int(round(in_os_ratio * 100))
                    by_number_of_cores[cores].in_sig_count = in_sig_count
                    by_number_of_cores[cores].in_sig_ratio = in_sig_ratio
                    by_number_of_cores[cores].rounded_in_sig_ratio = \
                        rounded_in_sig_ratio
                    by_number_of_cores[cores].in_os_count = in_os_count
                    by_number_of_cores[cores].in_os_ratio = in_os_ratio
                    by_number_of_cores[cores].rounded_in_os_ratio = \
                        rounded_in_os_ratio
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # end - minimally altered code section
#.........这里部分代码省略.........
开发者ID:4thAce,项目名称:socorro,代码行数:103,代码来源:core_count_rule.py


注:本文中的socorrolib.lib.util.DotDict.rounded_in_sig_ratio方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。