689 |
else: |
else: |
690 |
out[i0,i1,i2,i3]=arg0[i0,i1,i2,i3] |
out[i0,i1,i2,i3]=arg0[i0,i1,i2,i3] |
691 |
return out |
return out |
692 |
|
#======================================================================================================= |
693 |
|
# trace |
694 |
|
#======================================================================================================= |
695 |
|
def traceTest(r,offset): |
696 |
|
sh=r.shape |
697 |
|
r1=1 |
698 |
|
for i in range(offset): r1*=sh[i] |
699 |
|
r2=1 |
700 |
|
for i in range(offset+2,len(sh)): r2*=sh[i] |
701 |
|
r_s=numarray.reshape(r,(r1,sh[offset],sh[offset],r2)) |
702 |
|
s=numarray.zeros([r1,r2],numarray.Float) |
703 |
|
for i1 in range(r1): |
704 |
|
for i2 in range(r2): |
705 |
|
for j in range(sh[offset]): s[i1,i2]+=r_s[i1,j,j,i2] |
706 |
|
return s.resize(sh[:offset]+sh[offset+2:]) |
707 |
|
name,tt="trace",traceTest |
708 |
|
for case0 in ["array","Symbol","constData","taggedData","expandedData"]: |
709 |
|
for sh0 in [ (4,5), (6,2,2),(3,2,3,4)]: |
710 |
|
for offset in range(len(sh0)-1): |
711 |
|
text=" #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" |
712 |
|
tname="test_%s_%s_rank%s_offset%s"%(name,case0,len(sh0),offset) |
713 |
|
text+=" def %s(self):\n"%tname |
714 |
|
sh_t=list(sh0) |
715 |
|
sh_t[offset+1]=sh_t[offset] |
716 |
|
sh_t=tuple(sh_t) |
717 |
|
sh_r=[] |
718 |
|
for i in range(offset): sh_r.append(sh0[i]) |
719 |
|
for i in range(offset+2,len(sh0)): sh_r.append(sh0[i]) |
720 |
|
sh_r=tuple(sh_r) |
721 |
|
a_0=makeArray(sh_t,[-1.,1]) |
722 |
|
if case0 in ["taggedData", "expandedData"]: |
723 |
|
a1_0=makeArray(sh_t,[-1.,1]) |
724 |
|
else: |
725 |
|
a1_0=a_0 |
726 |
|
r=tt(a_0,offset) |
727 |
|
r1=tt(a1_0,offset) |
728 |
|
text+=mkText(case0,"arg",a_0,a1_0) |
729 |
|
text+=" res=%s(arg,%s)\n"%(name,offset) |
730 |
|
if case0=="Symbol": |
731 |
|
text+=mkText("array","s",a_0,a1_0) |
732 |
|
text+=" sub=res.substitute({arg:s})\n" |
733 |
|
res="sub" |
734 |
|
text+=mkText("array","ref",r,r1) |
735 |
|
else: |
736 |
|
res="res" |
737 |
|
text+=mkText(case0,"ref",r,r1) |
738 |
|
text+=mkTypeAndShapeTest(case0,sh_r,"res") |
739 |
|
text+=" self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res |
740 |
|
|
741 |
|
if case0 == "taggedData" : |
742 |
|
t_prog_with_tags+=text |
743 |
|
else: |
744 |
|
t_prog+=text |
745 |
|
|
746 |
|
print test_header |
747 |
|
# print t_prog |
748 |
|
print t_prog_with_tags |
749 |
|
print test_tail |
750 |
|
1/0 |
751 |
|
|
752 |
#======================================================================================================= |
#======================================================================================================= |
753 |
# clip |
# clip |
791 |
print t_prog_with_tags |
print t_prog_with_tags |
792 |
print test_tail |
print test_tail |
793 |
1/0 |
1/0 |
794 |
|
|
795 |
#======================================================================================================= |
#======================================================================================================= |
796 |
# maximum, minimum, clipping |
# maximum, minimum, clipping |
797 |
#======================================================================================================= |
#======================================================================================================= |