예제 #1
0
def write_report_files(report, basename):
    # TODO: hdf output
    filename = basename + ".html"
    dirname = os.path.dirname(filename)
    if not os.path.exists(dirname):
        os.makedirs(dirname)

    logger.info("Writing to %r." % filename)
    report.to_html(filename, write_pickle=True)
예제 #2
0
def write_report_files(report, basename):
    # TODO: hdf output
    filename = basename + '.html'
    dirname = os.path.dirname(filename)
    if not os.path.exists(dirname):
        os.makedirs(dirname)

    logger.info('Writing to %r.' % filename)
    report.to_html(filename, write_pickle=True)
예제 #3
0
def DDSFromSymbolic(resolution, symdiffeosystem):  # @UnusedVariable
    """ 
        Creates a DiffeoSystem from synthetic diffeomorphisms. 
    """
    diffeo2s_config = get_diffeo2s_config()
    diffeo2dds_config = get_diffeo2dds_config()

    _, symdds = diffeo2dds_config.symdds.instance_smarter(symdiffeosystem)

    logger.info('Creating symbolic diffeomorphism (resolution = %d)' %
                resolution)

    diffeoactions = []
    for _, action in enumerate(symdds.actions):

        id_diffeo, diffeo = parse_diffeo_spec(diffeo2s_config,
                                              action['diffeo'])
        label = action.get('label', id_diffeo)

        original_cmd = np.array(action['original_cmd'])

        logger.info('Getting symbolic diffeomorphism %r' % id_diffeo)

        shape = (resolution, resolution)
        viewport = SquareDomain([[-1, +1], [-1, +1]])
        manifold = diffeo.get_topology()
        D, Dinfo = diffeo_from_function_viewport(diffeo, manifold, viewport,
                                                 shape)
        D2d = Diffeomorphism2D(D, Dinfo)

        diffeo_inv = diffeo.get_inverse()
        D_inv, Dinfo_inv = \
            diffeo_from_function_viewport(diffeo_inv, manifold, viewport, shape)
        D2d_inv = Diffeomorphism2D(D_inv, Dinfo_inv)

        action = DiffeoAction(label=label,
                              diffeo=D2d,
                              diffeo_inv=D2d_inv,
                              original_cmd=original_cmd)
        diffeoactions.append(action)

    dds = DiffeoSystem('unnamed', actions=diffeoactions)
    return dds
예제 #4
0
def DDSFromSymbolic(resolution, symdiffeosystem):  # @UnusedVariable
    """ 
        Creates a DiffeoSystem from synthetic diffeomorphisms. 
    """  
    diffeo2s_config = get_diffeo2s_config()
    diffeo2dds_config = get_diffeo2dds_config()
    
    _, symdds = diffeo2dds_config.symdds.instance_smarter(symdiffeosystem)
    
    logger.info('Creating symbolic diffeomorphism (resolution = %d)' % 
                resolution)
    
    diffeoactions = []
    for _, action in enumerate(symdds.actions):
        
        id_diffeo, diffeo = parse_diffeo_spec(diffeo2s_config, action['diffeo'])
        label = action.get('label', id_diffeo)
        
        original_cmd = np.array(action['original_cmd'])
        
        logger.info('Getting symbolic diffeomorphism %r' % id_diffeo)
        
        shape = (resolution, resolution)
        viewport = SquareDomain([[-1, +1], [-1, +1]])
        manifold = diffeo.get_topology()
        D, Dinfo = diffeo_from_function_viewport(diffeo, manifold, viewport, shape)    
        D2d = Diffeomorphism2D(D, Dinfo)
        
        diffeo_inv = diffeo.get_inverse()
        D_inv, Dinfo_inv = \
            diffeo_from_function_viewport(diffeo_inv, manifold, viewport, shape)    
        D2d_inv = Diffeomorphism2D(D_inv, Dinfo_inv) 

        action = DiffeoAction(label=label,
                              diffeo=D2d,
                              diffeo_inv=D2d_inv,
                              original_cmd=original_cmd)
        diffeoactions.append(action)
        
    dds = DiffeoSystem('unnamed', actions=diffeoactions)
    return dds
예제 #5
0
 def make_hard(dd):
     assert isinstance(dd, Diffeomorphism2D)
     if use_isomorphism_heuristics:
         stats = diffeo_stats(dd.d)
         per = np.percentile(stats.norm, norm_percentile)
         limit = per * factor
         # / 3.0
         # print('norm mean/mean: %g %g' % (np.mean(stats.norm), np.median(stats.norm)))            
         # for i in range(0, 100, 5):
         #    print(' %3d%% = %g' % (i, np.percentile(stats.norm, i)))
         # limit = np.percentile(stats.norm, info_percentile)
         # if limit <= 1:
         #    print('limit was %g' % limit)
         #    limit = 4
         variance = (stats.norm > limit).astype('float')
         logger.info('---hard choices---')
         logger.info('  per: %g pixels * %g =' % (per, factor))
         logger.info('limit: %g pixels' % limit)
         logger.info('  vis: %.1f%% ' % (100 * np.mean(variance)))
     else:
         variance = (dd.variance > info_threshold).astype('float')
     return Diffeomorphism2D(dd.d, variance)