def testProperties01(self): """The magnitudue of the product is the product of the magnitudes""" q1 = Quaternion(tuple(RA.uniform(self.min, self.max, (1, 4)).tolist()[0])) q2 = Quaternion(tuple(RA.uniform(self.min, self.max, (1, 4)).tolist()[0])) self.assertEqual((q1*q2).magnitude(), q1.magnitude()*q2.magnitude())
def testProperties01(self): """The magnitudue of the product is the product of the magnitudes""" q1 = Quaternion( tuple(RA.uniform(self.min, self.max, (1, 4)).tolist()[0])) q2 = Quaternion( tuple(RA.uniform(self.min, self.max, (1, 4)).tolist()[0])) self.assertEqual((q1 * q2).magnitude(), q1.magnitude() * q2.magnitude())
def __init__(self, **kw): VisionEgg.Core.Stimulus.__init__(self,**kw) # store positions normalized between 0 and 1 so that re-sizing is ok num_dots = self.constant_parameters.num_dots # shorthand self.x_positions = RandomArray.uniform(0.0,1.0,(num_dots,)) self.y_positions = RandomArray.uniform(0.0,1.0,(num_dots,)) self.random_directions_radians = RandomArray.uniform(0.0,2*math.pi,(num_dots,)) self.last_time_sec = VisionEgg.time_func() self.start_times_sec = None # setup variable, assign later self._gave_alpha_warning = 0
def test_computeRMSD_Random(self): """3. for two random sets of points, rmsd(x,y) == rmsd(y,x)""" min = -10000. max = 10000. num_points = 20 dimension = 3 point_list_1 = RandomArray.uniform(min, max, (num_points, dimension)) point_list_2 = RandomArray.uniform(min, max, (num_points, dimension)) self.assertEqual( rmsd.RMSDCalculator(point_list_1).computeRMSD(point_list_2), rmsd.RMSDCalculator(point_list_2).computeRMSD(point_list_1))
def testProperties00(self): """The product of the conjugate is the conjucate of the product""" q1 = Quaternion(tuple(RA.uniform(self.min, self.max, (1, 4)).tolist()[0])) q2 = Quaternion(tuple(RA.uniform(self.min, self.max, (1, 4)).tolist()[0])) ## pc = q1.conjugate()*q2.conjugate() ## qp = q1*q2 ## cp = qp.conjugate() ## self.assertEqual( pc, cp) # the commented code fails with the same error as this line... self.assertEqual( q1.conjugate()*q2.conjugate(), (q2*q1).conjugate())
def testProperties00(self): """The product of the conjugate is the conjucate of the product""" q1 = Quaternion( tuple(RA.uniform(self.min, self.max, (1, 4)).tolist()[0])) q2 = Quaternion( tuple(RA.uniform(self.min, self.max, (1, 4)).tolist()[0])) ## pc = q1.conjugate()*q2.conjugate() ## qp = q1*q2 ## cp = qp.conjugate() ## self.assertEqual( pc, cp) # the commented code fails with the same error as this line... self.assertEqual(q1.conjugate() * q2.conjugate(), (q2 * q1).conjugate())
def setUp(self): """Called for every test.""" self.decimals = 2 # for rounding; 7 is SciPy default. self.known_points = [ [1., 0., 2.], [1., 0., 1.], [1., 1., 1.], [0., 0., 1.], [0., 0., 0.], [0., 1., 0.], [0., 1., -1.], [1., 1., -1.], [1., 2., -1.], [1., 1., -2.]] # create a simple torsion system for known_points torTree = TestTorTree() torTree.append(TestTorsion(4, 3, [0,1,2])) torTree.append(TestTorsion(3, 1, [0,2])) torTree.append(TestTorsion(6, 7, [8,9])) self.torTree = torTree npts = 5 dim = 3 self.max = 9999. self.min = -self.max self.random_points = RandomArray.uniform(self.min, self.max, (npts,dim)).tolist()
def test_applyTranslation03(self): """applyTranslation03 -- random pts x (random there and back)""" state = StateToCoords(self.random_points, tolist=1) trn = RandomArray.uniform(self.min, self.max, (3,)) state.applyTranslation(trn) trn = -1*trn self.assertArrayEqual(self.random_points, state.applyTranslation(trn))
def test_applyQuaternion04(self): """applyQuaternion04 -- random pts 360 about random-axis""" state = StateToCoords(self.random_points, tolist=1) q = RandomArray.uniform(self.min, self.max, (4, )) q[3] = 360.0 result = state.applyQuaternion(q) self.assertArrayEqual(self.random_points, result)
def test_applyQuaternion04(self): """applyQuaternion04 -- random pts 360 about random-axis""" state = StateToCoords(self.random_points, tolist=1) q = RandomArray.uniform(self.min, self.max, (4,)) q[3] = 360.0 result = state.applyQuaternion(q) self.assertArrayEqual(self.random_points, result)
def setUp(self): """Called for every test.""" self.decimals = 4 # for Numeric.around; 7 is SciPy default. self.idmtx = Transformation().getMatrix(transpose=1) self.known_points = [ [1.0, 0.0, 2.0], [1.0, 0.0, 1.0], [1.0, 1.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 1.0, -1.0], [1.0, 1.0, -1.0], [1.0, 2.0, -1.0], [1.0, 1.0, -2.0], ] npts = len(self.known_points) dim = 3 self.max = 9999999.0 self.min = -self.max self.random_points = RandomArray.uniform(self.min, self.max, (npts, dim)).tolist() # create a simple torsion system for both point lists torTree = TestTorTree() torTree.append(TestTorsion(4, 3, [0, 1, 2])) torTree.append(TestTorsion(3, 1, [0, 2])) torTree.append(TestTorsion(6, 7, [8, 9])) self.torTree = torTree
def test_applyTranslation03(self): """applyTranslation03 -- random pts x (random there and back)""" state = StateToCoords(self.random_points, tolist=1) trn = RandomArray.uniform(self.min, self.max, (3, )) state.applyTranslation(trn) trn = -1 * trn self.assertArrayEqual(self.random_points, state.applyTranslation(trn))
def makeTests(self, scale): """ Creates a scaled random AABB inside self""" p = permutation(3) size = self.height.array * uniform(0.5, 1.5, (3, )) * scale size = (size[p[0]], size[p[1]], size[p[2]]) where = self.uniformWithin() return AABB(where + Vector(size), where)
def test_applyQuaternion06(self): """applyQuaternion06 -- random pts 2*180 about random-axis""" state = StateToCoords(self.random_points, tolist=1) q = RandomArray.uniform(self.min, self.max, (4,)) q[3] = 180.0 for n in xrange(2): result = state.applyQuaternion(q) self.assertArrayEqual(self.random_points, result)
def test_applyQuaternion06(self): """applyQuaternion06 -- random pts 2*180 about random-axis""" state = StateToCoords(self.random_points, tolist=1) q = RandomArray.uniform(self.min, self.max, (4, )) q[3] = 180.0 for n in xrange(2): result = state.applyQuaternion(q) self.assertArrayEqual(self.random_points, result)
def __init__(self, **kw): VisionEgg.Core.Stimulus.__init__(self,**kw) # store positions normalized between 0 and 1 so that re-sizing is ok num_dots = self.constant_parameters.num_dots # shorthand self.x_positions = RandomArray.uniform(0.0,1.0,(num_dots,)) self.y_positions = RandomArray.uniform(0.0,1.0,(num_dots,)) if self.parameters.mode == "wind": self.random_directions_radians = RandomArray.uniform(0.0,2*math.pi,(num_dots,)) self.velocities = RandomArray.uniform(self.parameters.velocity_max-1, self.parameters.velocity_max,(num_dots,)) elif self.parameters.mode == "Gaussian": self.random_directions_radians = numpy.random.normal(self.parameters.signal_direction_deg/180.0*math.pi, self.parameters.signal_fraction,(num_dots,)) self.velocities = RandomArray.uniform(self.parameters.velocity_min, self.parameters.velocity_max,(num_dots,)) self.last_time_sec = VisionEgg.time_func() self.start_times_sec = None # setup variable, assign later self._gave_alpha_warning = 0
def setUp(self): """Called for every test.""" npts = 500 dim = 3 self.max = 9999999. self.min = -self.max self.random_points = RandomArray.uniform(self.min, self.max, (npts, dim)).tolist()
def setUp(self): """Called for every test.""" npts = 500 dim = 3 self.max = 9999999. self.min = -self.max self.random_points = RandomArray.uniform(self.min, self.max, (npts,dim)).tolist()
def test_computeRMSD_RandomOffset(self): """5. offset point by random value returns offset*sqrt(3)""" min = -10000. max = 10000. num_points = 20 dimension = 3 point_list_1 = RandomArray.uniform(min, max, (num_points, dimension)) delta = point_list_1[0][0] point_list_2 = point_list_1 + delta answer = rmsd.RMSDCalculator(point_list_1).computeRMSD(point_list_2) self.assertEqual(round(answer, self.decimals), round(abs(delta) * math.sqrt(3.0), self.decimals))
def test_computeRMSD_RandomOffset(self): """5. offset point by random value returns offset*sqrt(3)""" min = -10000. max = 10000. num_points = 20 dimension = 3 point_list_1 = RandomArray.uniform(min, max, (num_points, dimension)) delta = point_list_1[0][0] point_list_2 = point_list_1 + delta answer = rmsd.RMSDCalculator(point_list_1).computeRMSD(point_list_2) self.assertEqual( round(answer, self.decimals), round(abs(delta)*math.sqrt(3.0), self.decimals))
def draw(self): # XXX This method is not speed-optimized. I just wrote it to # get the job done. (Nonetheless, it seems faster than the C # version commented out above.) p = self.parameters # shorthand now_sec = VisionEgg.time_func() if self.start_times_sec is not None: # compute extinct dots and generate new positions replace_indices = Numeric.nonzero( Numeric.greater( now_sec - self.start_times_sec, p.dot_lifespan_sec) ) Numeric.put( self.start_times_sec, replace_indices, now_sec ) new_centers = np.random.standard_normal((3,len(replace_indices))) for i in range(3): Numeric.put( self.centers[i,:], replace_indices, new_centers[i,:] ) else: # initialize dot extinction values to random (uniform) distribution self.start_times_sec = RandomArray.uniform( now_sec - p.dot_lifespan_sec, now_sec, (self.constant_parameters.num_dots,)) time_delta_sec = now_sec - self.last_time_sec self.last_time_sec = now_sec # reset for next loop self.centers = self.centers + np.array(p.signal_vec)[:,np.newaxis]*time_delta_sec xyz = self.centers*p.start_position_variance + np.array(p.start_position_mean)[:,np.newaxis] xs = xyz[0,:] ys = xyz[1,:] zs = xyz[2,:] if p.on: gl.glEnable( gl.GL_POINT_SMOOTH ) # allow max_alpha value to control blending gl.glEnable( gl.GL_BLEND ) gl.glBlendFunc( gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA ) gl.glPointSize(p.dot_size) # Clear the modeview matrix gl.glMatrixMode(gl.GL_MODELVIEW) gl.glPushMatrix() gl.glDisable(gl.GL_TEXTURE_2D) draw_dots(xs,ys,zs,self.colors) gl.glDisable( gl.GL_POINT_SMOOTH ) # turn off gl.glPopMatrix()
def __init__(self, size_I=10, size_J=20, size_K=10): random_array.seed(3, 3) self.I = size_I self.J = size_J self.K = size_K self.W = random_array.uniform(-10, 10, (self.I, self.J, self.K)) #self.W= zeros((self.I,self.J,self.K),Float) self.Y = sum(self.W, 2) self.T = 0.0 self.Alpha0 = 0.9 self.Alpha = self.Alpha0 self.N_Iterations = 1 self.H = zeros((self.I, self.J, self.K)) self.i_min = 0 self.j_min = 0 self.min_val = 9999999999999999 self.Ratio0 = 1.0 self.Ratio0 = max(self.J, self.I) #self.Ratio0=0.0 self.Ratio = self.Ratio0
def setUp(self): """Called for every test.""" self.decimals = 2 # for rounding; 7 is SciPy default. self.known_points = [[1., 0., 2.], [1., 0., 1.], [1., 1., 1.], [0., 0., 1.], [0., 0., 0.], [0., 1., 0.], [0., 1., -1.], [1., 1., -1.], [1., 2., -1.], [1., 1., -2.]] # create a simple torsion system for known_points torTree = TestTorTree() torTree.append(TestTorsion(4, 3, [0, 1, 2])) torTree.append(TestTorsion(3, 1, [0, 2])) torTree.append(TestTorsion(6, 7, [8, 9])) self.torTree = torTree npts = 5 dim = 3 self.max = 9999. self.min = -self.max self.random_points = RandomArray.uniform(self.min, self.max, (npts, dim)).tolist()
def setUp(self): """Called for every test.""" self.decimals = 4 # for Numeric.around; 7 is SciPy default. self.idmtx = Transformation().getMatrix(transpose=1) self.known_points = [[1., 0., 2.], [1., 0., 1.], [1., 1., 1.], [0., 0., 1.], [0., 0., 0.], [0., 1., 0.], [0., 1., -1.], [1., 1., -1.], [1., 2., -1.], [1., 1., -2.]] npts = len(self.known_points) dim = 3 self.max = 9999999. self.min = -self.max self.random_points = RandomArray.uniform(self.min, self.max, (npts, dim)).tolist() # create a simple torsion system for both point lists torTree = TestTorTree() torTree.append(TestTorsion(4, 3, [0, 1, 2])) torTree.append(TestTorsion(3, 1, [0, 2])) torTree.append(TestTorsion(6, 7, [8, 9])) self.torTree = torTree
def __init__(self, size_I=10, size_J=20, size_K=10): #random_array.seed(3,3) self.I = size_I self.J = size_J self.K = size_K #mascara = randint(-2,2,(self.I,self.J,self.K)) #mascara = where (mascara <=0,0,1) #self.W = array(uniform(-1000,1000,(self.I,self.J,self.K)),mask=mascara ) self.W = random_array.uniform(-1000, 1000, (self.I, self.J, self.K)) # array of standar deviations #self.S = random_array.uniform(10.0,20,(self.I,self.J,self.K)).astype(float) self.S = ones((self.I, self.J, self.K)).astype(float) + 20.0 self.Y = zeros((self.I, self.J)).astype(float) #self.Generality = sum(self.W.mask(),2) self.T = 0.0 self.N_Iterations = 1 # Matrix for calculating the neigborhood self.H = zeros((self.I, self.J, self.K)) # Matrix for calculating the neigborhood for the stdev self.HS = zeros((self.I, self.J, self.K)).astype(float) #Winer Neuron self.i_min = 0 self.j_min = 0 self.activation = 0 # factor or learning self.Alpha0 = 0.9 self.Alpha = self.Alpha0 # factor or neigborhood self.Ratio0 = sqrt(self.J**2 + self.I**2) self.Ratio = self.Ratio0
def testProperties02(self): """The conjugate of a unit quaternion is it's inverse""" q1 = Quaternion( tuple(RA.uniform(self.min, self.max, (1, 4)).tolist()[0])) self.assertEqual(q1.conjugate(), q1.inverse())
def draw(self): # XXX This method is not speed-optimized. I just wrote it to # get the job done. (Nonetheless, it seems faster than the C # version commented out above.) p = self.parameters # shorthand if p.center is not None: if not hasattr(VisionEgg.config, "_GAVE_CENTER_DEPRECATION"): logger = logging.getLogger('VisionEgg.Dots') logger.warning("Specifying DotArea2D by deprecated " "'center' parameter deprecated. Use " "'position' parameter instead. (Allows " "use of 'anchor' parameter to set to " "other values.)") VisionEgg.config._GAVE_CENTER_DEPRECATION = 1 p.anchor = 'center' p.position = p.center[0], p.center[ 1] # copy values (don't copy ref to tuple) if p.on: # calculate center center = VisionEgg._get_center(p.position, p.anchor, p.size) if p.anti_aliasing: if len(p.color) == 4 and not self._gave_alpha_warning: if p.color[3] != 1.0: logger = logging.getLogger('VisionEgg.Dots') logger.warning("The parameter anti_aliasing is " "set to true in the DotArea2D " "stimulus class, but the color " "parameter specifies an alpha " "value other than 1.0. To " "acheive the best anti-aliasing, " "ensure that the alpha value for " "the color parameter is 1.0.") self._gave_alpha_warning = 1 gl.glEnable(gl.GL_POINT_SMOOTH) # allow max_alpha value to control blending gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) else: gl.glDisable(gl.GL_BLEND) now_sec = VisionEgg.time_func() if self.start_times_sec is not None: # compute extinct dots and generate new positions replace_indices = Numeric.nonzero( Numeric.greater(now_sec - self.start_times_sec, p.dot_lifespan_sec)) Numeric.put(self.start_times_sec, replace_indices, now_sec) new_x_positions = RandomArray.uniform(0.0, 1.0, (len(replace_indices), )) Numeric.put(self.x_positions, replace_indices, new_x_positions) new_y_positions = RandomArray.uniform(0.0, 1.0, (len(replace_indices), )) Numeric.put(self.y_positions, replace_indices, new_y_positions) new_random_directions_radians = RandomArray.uniform( 0.0, 2 * math.pi, (len(replace_indices), )) Numeric.put(self.random_directions_radians, replace_indices, new_random_directions_radians) else: # initialize dot extinction values to random (uniform) distribution self.start_times_sec = RandomArray.uniform( now_sec - p.dot_lifespan_sec, now_sec, (self.constant_parameters.num_dots, )) signal_num_dots = int( round(p.signal_fraction * self.constant_parameters.num_dots)) time_delta_sec = now_sec - self.last_time_sec self.last_time_sec = now_sec # reset for next loop x_increment_normalized = math.cos( p.signal_direction_deg / 180.0 * math.pi ) * p.velocity_pixels_per_sec / p.size[0] * time_delta_sec y_increment_normalized = -math.sin( p.signal_direction_deg / 180.0 * math.pi ) * p.velocity_pixels_per_sec / p.size[1] * time_delta_sec self.x_positions[:signal_num_dots] += x_increment_normalized self.y_positions[:signal_num_dots] += y_increment_normalized num_random_dots = self.constant_parameters.num_dots - signal_num_dots random_x_increment_normalized = Numeric.cos( self.random_directions_radians[signal_num_dots:] ) * p.velocity_pixels_per_sec / p.size[0] * time_delta_sec random_y_increment_normalized = -Numeric.sin( self.random_directions_radians[signal_num_dots:] ) * p.velocity_pixels_per_sec / p.size[1] * time_delta_sec self.x_positions[signal_num_dots:] += random_x_increment_normalized self.y_positions[signal_num_dots:] += random_y_increment_normalized self.x_positions = Numeric.fmod(self.x_positions, 1.0) # wrap self.y_positions = Numeric.fmod(self.y_positions, 1.0) self.x_positions = Numeric.fmod(self.x_positions + 1, 1.0) # wrap again for values < 1 self.y_positions = Numeric.fmod(self.y_positions + 1, 1.0) xs = (self.x_positions - 0.5) * p.size[0] + center[0] ys = (self.y_positions - 0.5) * p.size[1] + center[1] if len(p.color) == 3: gl.glColor3f(*p.color) elif len(p.color) == 4: gl.glColor4f(*p.color) gl.glPointSize(p.dot_size) # Clear the modeview matrix gl.glMatrixMode(gl.GL_MODELVIEW) gl.glPushMatrix() gl.glDisable(gl.GL_TEXTURE_2D) if p.depth is None: depth = 0.0 else: gl.glEnable(gl.GL_DEPTH_TEST) depth = p.depth zs = (depth, ) * len(xs) # make N tuple with repeat value of depth draw_dots(xs, ys, zs) if p.anti_aliasing: gl.glDisable(gl.GL_POINT_SMOOTH) # turn off gl.glPopMatrix()
def randomDirection(self): return Vector( uniform(0.5, 1.5, (3, )) * (randint(0, 1, (3, )) * 2 - 1)).normal()
def __init__(self): Weapon.__init__(self, "sourStraw", uniform(1.0, 1.75), 2)
def uniformWithin(self): """Returns a random point inside self""" return Vector( uniform(0., 1., (3, )) * self.height.array + self.down.array)
def testProperties02(self): """The conjugate of a unit quaternion is it's inverse""" q1 = Quaternion(tuple(RA.uniform(self.min, self.max, (1, 4)).tolist()[0])) self.assertEqual( q1.conjugate(), q1.inverse())
def __init__(self): Weapon.__init__(self, "chocolateBar", uniform(2, 2.4), 4)
def __init__(self): Weapon.__init__(self, "nerdBomb", uniform(3.5, 5), 1)
def draw(self): # XXX This method is not speed-optimized. I just wrote it to # get the job done. (Nonetheless, it seems faster than the C # version commented out above.) p = self.parameters # shorthand if p.center is not None: if not hasattr(VisionEgg.config,"_GAVE_CENTER_DEPRECATION"): logger = logging.getLogger('VisionEgg.Dots') logger.warning("Specifying DotArea2D by deprecated " "'center' parameter deprecated. Use " "'position' parameter instead. (Allows " "use of 'anchor' parameter to set to " "other values.)") VisionEgg.config._GAVE_CENTER_DEPRECATION = 1 p.anchor = 'center' p.position = p.center[0], p.center[1] # copy values (don't copy ref to tuple) if p.on: # calculate center center = VisionEgg._get_center(p.position,p.anchor,p.size) if p.anti_aliasing: if len(p.color) == 4 and not self._gave_alpha_warning: if p.color[3] != 1.0: logger = logging.getLogger('VisionEgg.Dots') logger.warning("The parameter anti_aliasing is " "set to true in the DotArea2D " "stimulus class, but the color " "parameter specifies an alpha " "value other than 1.0. To " "acheive the best anti-aliasing, " "ensure that the alpha value for " "the color parameter is 1.0.") self._gave_alpha_warning = 1 gl.glEnable( gl.GL_POINT_SMOOTH ) # allow max_alpha value to control blending gl.glEnable( gl.GL_BLEND ) gl.glBlendFunc( gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA ) else: gl.glDisable( gl.GL_BLEND ) now_sec = VisionEgg.time_func() if self.start_times_sec is not None: # compute extinct dots and generate new positions replace_indices = Numeric.nonzero( Numeric.greater( now_sec - self.start_times_sec, p.dot_lifespan_sec) ) Numeric.put( self.start_times_sec, replace_indices, now_sec ) new_x_positions = RandomArray.uniform(0.0,1.0, (len(replace_indices),)) Numeric.put( self.x_positions, replace_indices, new_x_positions ) new_y_positions = RandomArray.uniform(0.0,1.0, (len(replace_indices),)) Numeric.put( self.y_positions, replace_indices, new_y_positions ) new_random_directions_radians = RandomArray.uniform(0.0,2*math.pi, (len(replace_indices),)) Numeric.put( self.random_directions_radians, replace_indices, new_random_directions_radians ) else: # initialize dot extinction values to random (uniform) distribution self.start_times_sec = RandomArray.uniform( now_sec - p.dot_lifespan_sec, now_sec, (self.constant_parameters.num_dots,)) signal_num_dots = int(round(p.signal_fraction * self.constant_parameters.num_dots)) time_delta_sec = now_sec - self.last_time_sec self.last_time_sec = now_sec # reset for next loop x_increment_normalized = math.cos(p.signal_direction_deg/180.0*math.pi) * p.velocity_pixels_per_sec / p.size[0] * time_delta_sec y_increment_normalized = -math.sin(p.signal_direction_deg/180.0*math.pi) * p.velocity_pixels_per_sec / p.size[1] * time_delta_sec self.x_positions[:signal_num_dots] += x_increment_normalized self.y_positions[:signal_num_dots] += y_increment_normalized num_random_dots = self.constant_parameters.num_dots - signal_num_dots random_x_increment_normalized = Numeric.cos(self.random_directions_radians[signal_num_dots:]) * p.velocity_pixels_per_sec / p.size[0] * time_delta_sec random_y_increment_normalized = -Numeric.sin(self.random_directions_radians[signal_num_dots:]) * p.velocity_pixels_per_sec / p.size[1] * time_delta_sec self.x_positions[signal_num_dots:] += random_x_increment_normalized self.y_positions[signal_num_dots:] += random_y_increment_normalized self.x_positions = Numeric.fmod( self.x_positions, 1.0 ) # wrap self.y_positions = Numeric.fmod( self.y_positions, 1.0 ) self.x_positions = Numeric.fmod( self.x_positions+1, 1.0 ) # wrap again for values < 1 self.y_positions = Numeric.fmod( self.y_positions+1, 1.0 ) xs = (self.x_positions - 0.5) * p.size[0] + center[0] ys = (self.y_positions - 0.5) * p.size[1] + center[1] if len(p.color)==3: gl.glColor3f(*p.color) elif len(p.color)==4: gl.glColor4f(*p.color) gl.glPointSize(p.dot_size) # Clear the modeview matrix gl.glMatrixMode(gl.GL_MODELVIEW) gl.glPushMatrix() gl.glDisable(gl.GL_TEXTURE_2D) if p.depth is None: depth = 0.0 else: gl.glEnable(gl.GL_DEPTH_TEST) depth = p.depth zs = (depth,)*len(xs) # make N tuple with repeat value of depth draw_dots(xs,ys,zs) if p.anti_aliasing: gl.glDisable( gl.GL_POINT_SMOOTH ) # turn off gl.glPopMatrix()
def test_applyTranslation01(self): """applyTranslation01 -- random pts x (random translation)""" state = StateToCoords(self.random_points, tolist=0) trn = RandomArray.uniform(self.min, self.max, (3, )) expected = (Numeric.array(self.random_points) + trn) self.assertArrayEqual(expected, state.applyTranslation(trn))
import matplotlib.pyplot as p from numpy import * from numpy.oldnumeric.random_array import uniform lower_limit = -10 upper_limit = 10 npts = 500 xi = linspace(lower_limit-0.1, upper_limit+0.1, npts) yi = linspace(lower_limit-0.1, upper_limit+0.1, npts) x = [] y = [] z = [] # Fun to test functionXY = function_SIN_XY x = uniform(lower_limit, upper_limit, npts) y = uniform(lower_limit, upper_limit, npts) for index in range(0,len(x)): z.append(functionXY(x[index],y[index])) zgrid = griddata(x,y,z,xi,yi) p.cla() p.contour(xi, yi, zgrid,linewidths=0.5,colors='k') p.contourf(xi, yi, zgrid) p.draw() p.show()
def test_applyTranslation01(self): """applyTranslation01 -- random pts x (random translation)""" state = StateToCoords(self.random_points, tolist=0) trn = RandomArray.uniform(self.min, self.max, (3,)) expected = (Numeric.array(self.random_points) + trn) self.assertArrayEqual(expected, state.applyTranslation(trn))