def testBasic(self): self.compileMandel() handle = fract4dc.pf_load("./test-pf.so") pfunc = fract4dc.pf_create(handle) fract4dc.pf_init(pfunc,pos_params, [self.gradient, 4.0, 0.5]) # a point which doesn't bail out result = fract4dc.pf_calc(pfunc,[0.15, 0.0, 0.0, 0.0],100,0,0,0) self.assertEqual(result,(100, 32, 0.0,0)) # one which does result = fract4dc.pf_calc(pfunc,[1.0, 1.0, 0.0, 0.0],100,0,0,0) self.assertEqual(result,(1,0, 0.0,0)) # one which is already out result = fract4dc.pf_calc(pfunc,[17.5, 14.0, 0.0, 0.0],100,0,0,0) self.assertEqual(result,(0, 0, 0.0,0)) # without optional args result = fract4dc.pf_calc(pfunc,[17.5, 14.0, 0.0, 0.0],100) self.assertEqual(result,(0, 0, 0.0,0)) pfunc = None handle = None
def testHyperSphereFormula(self): # check that a formula consisting of a simple 2.0-radius hypersphere # can be effectively ray-traced (iter,fate,dist,solid) = fract4dc.pf_calc(self.pfunc, [0.0, 0.0, 0.0, 0.0], 100) self.assertEqual(fate,32) # should be inside (iter,fate,dist,solid) = fract4dc.pf_calc(self.pfunc, [-2.5, 0.0, 0.0, 0.0], 100) self.assertEqual(fate,0) # should be outside
def testHyperSphereFormula(self): # check that a formula consisting of a simple 2.0-radius hypersphere # can be effectively ray-traced (iter, fate, dist, solid) = fract4dc.pf_calc(self.pfunc, [0.0, 0.0, 0.0, 0.0], 100) self.assertEqual(fate, 32) # should be inside (iter, fate, dist, solid) = fract4dc.pf_calc(self.pfunc, [-2.5, 0.0, 0.0, 0.0], 100) self.assertEqual(fate, 0) # should be outside
def testMiniTextRender(self): self.compileMandel() handle = fract4dc.pf_load("./test-pf.so") pfunc = fract4dc.pf_create(handle) fract4dc.pf_init(pfunc,pos_params,[0,4.0]) image = [] for y in xrange(-20,20): line = [] for x in xrange(-20,20): (iter,fate,dist,solid) = fract4dc.pf_calc(pfunc,[x/10.0,y/10.0,0,0],100) if(fate == 32): line.append("#") else: line.append(" ") image.append(string.join(line,"")) printable_image = string.join(image,"\n") self.assertEqual(printable_image[0], " ", printable_image) self.assertEqual(printable_image[20*41+20],"#", printable_image) # in the middle