示例#1
0
    def from_matrices(labels, commute, inverse, same):
        logger.info('Creating PlanReducer from matrices:\n' +
                    formatm('same', same, 'oppo', inverse, 'swap', commute))
        pr = PlanReducer()
        for i, j in iterate_indices(commute.shape):
            li = labels[i]
            lj = labels[j]
            if commute[i, j]:
                assert commute[j, i]
                pr.set_commute(li, lj)

            if same[i, j]:
                assert same[j, i]
                pr.set_same(li, lj)

            if inverse[i, j]:
                assert inverse[j, i]
                pr.set_inverse(li, lj)
        return pr
    def show_compositions(self, report):
        # f_ba = report.figure()
        n = len(self.dds.actions)
        f_ab_norm = report.figure(cols=n, caption='Norm of AB')
        f_ab_phase = report.figure(cols=n, caption='Phase of AB')
        f_ab_info = report.figure(cols=n, caption='Certainty of AB')
        for a, b in iterate_indices((n, n)):
            A = self.dds.actions[a]
            B = self.dds.actions[b]
            AB = DiffeoAction.compose(A, B)
            norm_rgb = diffeo_to_rgb_norm(AB.diffeo.d)
            phase_rgb = diffeo_to_rgb_angle(AB.diffeo.d)
            info_rgb = scalaruncertainty2rgb(AB.diffeo.variance)

            label = '%s-%s' % (A.label, B.label)
            caption = '%s, %s' % (A.label, B.label)
            f_ab_norm.data_rgb('%s_norm' % label, norm_rgb, caption=caption)
            f_ab_phase.data_rgb('%s_phase' % label, phase_rgb, caption=caption)
            f_ab_info.data_rgb('%s_info' % label, info_rgb, caption=caption)
示例#3
0
    def show_compositions(self, report):
        # f_ba = report.figure()
        n = len(self.dds.actions)
        f_ab_norm = report.figure(cols=n, caption='Norm of AB')
        f_ab_phase = report.figure(cols=n, caption='Phase of AB')
        f_ab_info = report.figure(cols=n, caption='Certainty of AB')
        for a, b in iterate_indices((n, n)):
            A = self.dds.actions[a]
            B = self.dds.actions[b]
            AB = DiffeoAction.compose(A, B)
            norm_rgb = diffeo_to_rgb_norm(AB.diffeo.d)
            phase_rgb = diffeo_to_rgb_angle(AB.diffeo.d)
            info_rgb = scalaruncertainty2rgb(AB.diffeo.variance)

            label = '%s-%s' % (A.label, B.label)
            caption = '%s, %s' % (A.label, B.label)
            f_ab_norm.data_rgb('%s_norm' % label, norm_rgb, caption=caption)
            f_ab_phase.data_rgb('%s_phase' % label, phase_rgb, caption=caption)
            f_ab_info.data_rgb('%s_info' % label, info_rgb, caption=caption)
示例#4
0
    def from_matrices(labels, commute, inverse, same):
        logger.info('Creating PlanReducer from matrices:\n' + 
                    formatm('same', same, 'oppo', inverse, 'swap', commute))
        pr = PlanReducer()
        for i, j in iterate_indices(commute.shape):
            li = labels[i]
            lj = labels[j]
            if commute[i, j]:
                assert commute[j, i]
                pr.set_commute(li, lj)
        
            if same[i, j]:
                assert same[j, i]
                pr.set_same(li, lj)

            if inverse[i, j]:
                assert inverse[j, i]
                pr.set_inverse(li, lj)
        return pr