Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/ein16/synth/d2/test_observed.py
ViewVC logotype

View of /branches/ein16/synth/d2/test_observed.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3946 - (download) (as text) (annotate)
Sat Jun 11 00:39:19 2016 UTC (2 years, 9 months ago) by cchiw
File size: 1224 byte(s)
 added outer prod
import re
import os
from obj_ty import *
from obj_operator import *

# read observed data
#programs organized by number of output per line
#one input per line
def getObserv_1(p_out):
    obs = []
    name = p_out+".txt"
    if(os.path.exists(name)):
        obsf = open(name, 'r')
        obsf.readline()
        for line in obsf:
            m = re.split(r'\n',line)
            if m:
                u0 = m[0]
                obs.append(float(u0))
        return obs
    return []

#n inputs per line
def getObserv_t(p_out, n):
    obs = []
    name = p_out+".txt"
    if(os.path.exists(name)):
        obsf = open(name, 'r')
        obsf.readline()
        for line in obsf:
            m = re.split(r'\s',line)
            if m:
                cur= []
                for i in range(n):
                    u0 = m[i]
                    cur.append(float(u0))
                obs.append(cur)
        return obs
    return []

#chooose function based on number of input per line
def observed(app, p_out):
    ex_rtn = fty.get_tensorType(app.oty)
    if(ty_scalarT==ex_rtn):
         return getObserv_1(p_out)
    else:
        a=1
        for s in get_Tshape(ex_rtn):
          a= a*s
        return getObserv_t(p_out, a)

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0