def setUp(self): self.testSheaf1 = ps.Sheaf([]) # Small sheaf self.testSheaf2 = ps.Sheaf([ ps.SheafCell(dimension=1, stalkDim=1, cofaces=[ ps.SheafCoface(index=2, orientation=np.array(1), restriction=np.array([0.5])) ]), ps.SheafCell(dimension=1, stalkDim=1, cofaces=[ ps.SheafCoface(index=2, orientation=np.array(-1), restriction=np.array([1])) ]), ps.SheafCell(dimension=2, stalkDim=1, cofaces=[]), ps.SheafCell(dimension=0, stalkDim=1, cofaces=[ ps.SheafCoface(index=0, orientation=np.array(1), restriction=np.array([2])), ps.SheafCoface(index=1, orientation=np.array(1), restriction=np.array([1])) ]) ]) self.asg2_1 = ps.Section([ ps.SectionCell(support=0, value=np.array(0.)), ps.SectionCell(support=1, value=np.array(1.)) ]) self.asg2_3 = ps.Section([ ps.SectionCell(support=0, value=np.array(0.)), ps.SectionCell(support=1, value=np.array(1.)), ps.SectionCell(support=2, value=np.array(0.5)), ps.SectionCell(support=3, value=np.array(1. / 3)) ])
sdim=np.ts.size #number of samples for u & v; n+m. For n or m, use sdim/2 s1=py.Sheaf([py.SheafCell(dimension=1,stalkDim=(sdim/2),cofaces=[]), \ py.SheafCell(dimension=1,stalkDim=(sdim/2),cofaces=[]), \ py.SheafCell(dimension=1,stalkDim=(sdim/2),cofaces=[]), \ py.SheafCell(dimension=1,stalkDim=(sdim/2),cofaces=[]), \ py.SheafCell \ (dimension=0,stalkDim=sdim,cofaces=[py.SheafCoface(index=0, orientation=1, restriction=py.LinearMorphism(pr1(ts))), \ py.SheafCoface(index=1, orientation=1, restriction=py.LinearMorphism(pr2(ts))), \ py.SheafCoface(index=3, orientation=1, restriction=py.SetMorphism(eqn1(ts)))]), \ py.SheafCell \ (dimension=0,stalkDim=sdim,cofaces=[py.SheafCoface(index=0, orientation=-1, restriction=py.LinearMorphism(pr1(ts))), \ py.SheafCoface(index=1, orientation=-1, restriction=py.LinearMorphism(pr2(ts))), \ py.SheafCoface(index=2, orientation=-1, restriction=py.SetMorphism(eqn2(ts)))]), \ py.SheafCell \ (dimension=0,stalkDim=(sdim/2),cofaces=[py.SheafCoface(index=0, orientation=1, restriction=py.LinearMorphism(iden(ts))), \ py.SheafCoface(index=2, orientation=1, restriction=py.LinearMorphism(ddt(ts)))]), \ py.SheafCell \ (dimension=0,stalkDim=(sdim/2),cofaces=[py.SheafCoface(index=1, orientation=1, restriction=py.LinearMorphism(iden(ts))), \ py.SheafCoface(index=3, orientation=-1, restriction=py.LinearMorphism(ddt(ts)))])]) #How to construct? Taken from search_rescue_test.py input_data=[py.Section([py.SectionCell(support=0,value=np.array(ts[:(sdim/2)])), # U py.SectionCell(support=1,value=np.array(ts[(sdim/2):]))])] # V # Exhibit the consistency radius of the partially-filled Section with the input data #consistency_radii=[s1.consistencyRadius(case) for case in input_data] cr=checkradii() print "The consistency_radii is " +str(cr)
ps.SheafCell(dimension=0, cofaces=[ ps.SheafCoface(index=2, orientation=-1, restriction=np.matrix(1)) ]), ps.SheafCell(dimension=0, cofaces=[ ps.SheafCoface(index=2, orientation=1, restriction=np.matrix(1)) ]), ps.SheafCell(dimension=1, cofaces=[], stalkDim=1) ]) sec1 = ps.Section([ps.SectionCell(0, 1), ps.SectionCell(1, 1)]) sec2 = ps.Section([ps.SectionCell(0, 1)]) sec3 = ps.Section([ps.SectionCell(0, 1), ps.SectionCell(1, 2)]) # Extending section over two vertices to a common coface if sec1.extend(sh1, 2) and sec2.extend( sh1, 2) and not sec3.extend(sh1, 2) and sec2.extend(sh1, 1): print "Test 1 passed" else: print "Test 1 failed" sh2 = ps.Sheaf([ ps.SheafCell(dimension=0, cofaces=[ ps.SheafCoface(index=1, orientation=-1,
]) # V3 # Structure the data from Table 1 in the paper into various partially-filled Sections, one for each Case listed global scene_bounds_0 scene_bounds_0 = [(65, 75), (40, 50), (11000, 11700), (400, 600), (150, 350), (.5, 1.5)] #Construct Sheaf construct_sheaf() #Define Input Data input_data = [ ps.Section([ ps.SectionCell(support=0, value=np.array([-70.668, 42.809, 11431, 495, 164, 1.05])) ]), # X (Verify that the sheaf's maps are commutative) ps.Section([ ps.SectionCell(support=0, value=np.array([-70.668, 42.809, 11431, 495, 164, 1.05])), # X ps.SectionCell(support=1, value=np.array([-70.663, 42.752, 11299])), # U1 ps.SectionCell(support=2, value=np.array([-70.657, 42.773, 11346, 495, 164])), # U2 ps.SectionCell(support=3, value=np.array([77.2, 0.930])), # U3 ps.SectionCell(support=4, value=np.array([63.2, 0.974])), # U4 ps.SectionCell(support=5, value=np.array([-64.630, 44.287])) ]), # U5
ps.SheafCell( dimension=1, compactClosure=True, stalkDim=4, #THIS IS THE NUMBER OF rows cofaces=[]), ps.SheafCell( dimension=1, compactClosure=True, stalkDim=2, #THIS IS THE NUMBER OF rows cofaces=[]) ]) #SUPPORT NEEDS TO MATCH INDEX OF THAT ARRAY input_data = [ ps.Section([ ps.SectionCell(support=0, value=np.array([0.5, 0.5])), # X #ps.SectionCell(support=1,value=np.array([]), U1 WE DON'T ACTUALLY REFERENCE U1 SINCE NOT IN DIAGRAM ps.SectionCell(support=1, value=np.array([0.5, 0.5, 0.5, 0.5])), # U2 ps.SectionCell(support=2, value=np.array([0.5, 0.5, 0.5, 0.5])), # U3 ps.SectionCell(support=3, value=np.array([0.5, 0.5])), # U4 ps.SectionCell(support=4, value=np.array([0, 0])), # V1 ps.SectionCell(support=5, value=np.array([0, 0, 0, 0])), # V2 ps.SectionCell(support=6, value=np.array([0, 0])) ]) ] # V3 """ THIS IS ALL BOTTOM CELLS HAVE 1/2 input_data=[ps.Section([ps.SectionCell(support=0,value=np.array([0.5, 0.5])), # X #ps.SectionCell(support=1,value=np.array([]), U1 WE DON'T ACTUALLY REFERENCE U1 SINCE NOT IN DIAGRAM ps.SectionCell(support=1,value=np.array([0.5, 0.5, 0.5, 0.5])), # U2 ps.SectionCell(support=2,value=np.array([0.5, 0.5, 0.5, 0.5])), # U3 ps.SectionCell(support=3,value=np.array([0.5, 0.5])), # U4
def setUp(self): self.testSheaf = ps.Sheaf([ ps.SheafCell(dimension=0, stalkDim=1, cofaces=[ ps.SheafCoface(index=1, restriction=np.array([1])), ps.SheafCoface(index=2, restriction=np.array([1])) ]), ps.SheafCell(dimension=1, stalkDim=1), ps.SheafCell(dimension=1, stalkDim=1) ]) self.asg = ps.Section([ ps.SectionCell(support=0, value=0), ps.SectionCell(support=1, value=0), ps.SectionCell(support=2, value=1) ]) self.testSheaf2 = ps.Sheaf([ ps.SheafCell(dimension=0, stalkDim=1, cofaces=[ ps.SheafCoface(index=1, restriction=np.array([1])), ps.SheafCoface(index=2, restriction=np.array([1])) ]), ps.SheafCell(dimension=1, stalkDim=1), ps.SheafCell(dimension=1, stalkDim=1), ps.SheafCell( dimension=0, stalkDim=1, cofaces=[ps.SheafCoface(index=1, restriction=np.array([1]))]) ]) self.asg2 = ps.Section([ ps.SectionCell(support=0, value=0), # A ps.SectionCell(support=1, value=0), # C ps.SectionCell(support=2, value=1), # B ps.SectionCell(support=3, value=0) ]) # D self.asg3 = ps.Section([ ps.SectionCell(support=0, value=0), # A ps.SectionCell(support=1, value=0), # C ps.SectionCell(support=2, value=1), # B ps.SectionCell(support=3, value=1) ]) # D
restriction=ps.LinearMorphism(np.array([[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1]])))]), ps.SheafCell(dimension=3, compactClosure=True, stalkDim=4, metric=distance, cofaces=[]), ]) # Structure the data into various partially-filled Sections, #Define Input Data input_data=[ps.Section([ps.SectionCell(support=0,value=np.array([1,1,1,1,1,1]).T)]), # A (Verify that the sheaf's maps are commutative) ps.Section([ps.SectionCell(support=0,value=np.array([1,1,1,1,1,1]).T), # A ps.SectionCell(support=1,value=np.array([1,1,1,1,3]).T), # B (expected error of 2 for s1) ps.SectionCell(support=2,value=np.array([1,1,1,2,2]).T), # C (expected error of 1 for s1) ps.SectionCell(support=3,value=np.array([4,1,1,2]).T), # D (expected error of 3 for s1) ]), ps.Section([ps.SectionCell(support=0,value=np.array([1,1,1,1,1,1]).T), # A ps.SectionCell(support=1,value=np.array([1,1,1,1,1]).T), # B (expected error of 0 for s2) #ps.SectionCell(support=2,value=np.array([1,1,1,2,1]).T), # C (expected error of 1 for s2) #ps.SectionCell(support=3,value=np.array([4,1,1,2]).T), # D (expected error of sqrt(10) for s2) ]), ps.Section([ps.SectionCell(support=0,value=np.array([1,1,1,1,1,1]).T), # A #ps.SectionCell(support=1,value=np.array([1,1,1,1,1]).T), # B (expected error of 0 for s2) #ps.SectionCell(support=2,value=np.array([1,1,1,2,1]).T), # C (expected error of 1 for s2) ps.SectionCell(support=3,value=np.array([4,1,1,2]).T), # D (expected error of 2 for s2)
py.SheafCoface(index=1, orientation=1, restriction=py.LinearMorphism(pr2(ts))), \ py.SheafCoface(index=3, orientation=1, restriction=py.SetMorphism(lambda x: eqn1(x,alpha,beta,sigma)))]), \ py.SheafCell \ (dimension=0,stalkDim=sdim,cofaces=[py.SheafCoface(index=0, orientation=-1, restriction=py.LinearMorphism(pr1(ts))), \ py.SheafCoface(index=1, orientation=-1, restriction=py.LinearMorphism(pr2(ts))), \ py.SheafCoface(index=2, orientation=-1, restriction=py.SetMorphism(lambda x:eqn2(x,alpha,gamma,rho)))]), \ py.SheafCell \ (dimension=0,stalkDim=(sdim/2),cofaces=[py.SheafCoface(index=0, orientation=1, restriction=py.LinearMorphism(iden(tsu))), \ py.SheafCoface(index=2, orientation=1, restriction=py.LinearMorphism(ddt(tsu)))]), \ py.SheafCell \ (dimension=0,stalkDim=(sdim/2),cofaces=[py.SheafCoface(index=1, orientation=1, restriction=py.LinearMorphism(iden(tsv))), \ py.SheafCoface(index=3, orientation=-1, restriction=py.LinearMorphism(ddt(tsv)))])]) input_data = [ py.Section([ py.SectionCell(support=0, value=tsu), # U py.SectionCell(support=1, value=tsv), #V py.SectionCell(support=4, value=ts), #(U,V) py.SectionCell(support=5, value=ts), #(U,V) py.SectionCell(support=6, value=tsu), #U py.SectionCell(support=7, value=tsv) ]) ] # V # Exhibit the consistency radius of the partially-filled Section with the input data consistency_radii = [s1.consistencyRadius(case) for case in input_data] print "The consistency_radii is " + str(consistency_radii) fused_data = [s1.fuseAssignment(case) for case in input_data] fused_consistency_radii = [s1.consistencyRadius(case) for case in fused_data] """sample vars for input: (.1,.13,1.5,2.8,1.5) The consistency_radii is [6.7134851213605433]