rules.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:mitre 作者: gerberlab 项目源码 文件源码
def sort_base_rules(self):
        """ Sort the population lexicographically by truth vector.

        This should help speed up likelihood calculations.

        Note, resets the filter.

        """ 
        # np.lexsort will sort columns by rows, with the last
        # row as the primary sort key, etc; so we rotate the 
        # truth array by 90 degrees to get it to do what we want.
        new_order = np.lexsort(np.rot90(self.base_flat_truth))
        self._reordering_cache = new_order

        self.base_flat_durations = self.base_flat_durations[new_order]
        self.base_flat_variable_weights = self.base_flat_variable_weights[new_order]
        new_flat_rules = [self.base_flat_rules[i] for i in new_order]
        self.base_flat_rules = new_flat_rules
        self.base_flat_truth = self.base_flat_truth[new_order]
        self.base_primitive_index = {
            t:i for i,t in enumerate(new_flat_rules)
        }

        self.reset_filter()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号