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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3873, Wed May 18 13:38:23 2016 UTC revision 3874, Wed May 18 16:45:54 2016 UTC
# Line 1  Line 1 
1  import re  import re
 from test_examples import value_probe  
 from test_examples import value_negation  
 from test_examples import value_gradient  
 from test_examples import value_scalarFd2  
 from test_examples import value_vec2Fd2  
2  from test_examples import value_scalarT  from test_examples import value_scalarT
3  from test_examples import value_vec2T  from test_examples import value_vec2T
4    from test_examples import value_mat2x2T
5    
6  #fixed variables  #needs output tensor types
 op_probe = value_probe()  
 op_negation = value_negation()  
 op_gradient = value_gradient()  
 ty_scalarF_d2 = value_scalarFd2()  
 ty_vec2F_d2 = value_vec2Fd2()  
7  ty_scalarT = value_scalarT()  ty_scalarT = value_scalarT()
8  ty_vec2T = value_vec2T()  ty_vec2T = value_vec2T()
9    ty_mat2x2T=value_mat2x2T()
10  # read observed data  # read observed data
11  #programs organized by number of output per line  #programs organized by number of output per line
12  #one input per line  #one input per line
# Line 27  Line 18 
18      for line in obsf:      for line in obsf:
19          m = re.split(r'\n',line)          m = re.split(r'\n',line)
20          if m:          if m:
21              u = m[0]              u0 = m[0]
22              obs.append(float(u))              obs.append(float(u0))
23      return obs      return obs
24    
25  #two input per line  #two input per line
# Line 39  Line 30 
30      for line in obsf:      for line in obsf:
31          m = re.split(r'\s',line)          m = re.split(r'\s',line)
32          if m:          if m:
33              u = m[0]              u0 = m[0]
34              v = m[1]              u1 = m[1]
35              obs.append((float(u),float(v)))              obs.append((float(u0),float(u1)))
36    
37        return obs
38    
39    #two input per line
40    def getObserv_2x2(p_out):
41        obs = []
42        obsf = open(p_out+".txt", 'r')
43        obsf.readline()
44        for line in obsf:
45            m = re.split(r'\s',line)
46            if m:
47                u0 = m[0]
48                u1 = m[1]
49                u2 = m[2]
50                u3 = m[3]
51                obs.append((float(u0),float(u1),float(u2),float(u3)))
52    
53      return obs      return obs
54    
# Line 51  Line 58 
58          return getObserv_1(p_out)          return getObserv_1(p_out)
59      elif(ex_rtn==ty_vec2T):      elif(ex_rtn==ty_vec2T):
60          return getObserv_2(p_out)          return getObserv_2(p_out)
61        elif(ex_rtn==ty_mat2x2T):
62            return getObserv_2x2(p_out)
63      else:      else:
         raise ("unsupported output type "+ex_rtn)  
64            raise Exception("unsupported output type ", ex_rtn)

Legend:
Removed from v.3873  
changed lines
  Added in v.3874

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