• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(236855)  |  Call(235990)  |  Derive(865)  |  Import(0)
int(x[, base]) -> integer

Convert a string or number to an integer, if possible.  A floating point
argument will be truncated towards zero (this does not include a string
representation of a floating point number!)  When converting a string, use
the optional base.  It is an error to supply a base when converting a
non-string.  If base is zero, the proper base is guessed based on the
string content.  If the argument is outside the integer range a
long object will be returned instead.

src/b/a/badger-lib-HEAD/packages/pyparsing/examples/wordsToNum.py   badger-lib(Download)
hundreds = makeLit("hundred", 100)
 
majorDefinitions = [
    ("thousand",    int(1e3)),
    ("million",     int(1e6)),
    ("billion",     int(1e9)),
    ("trillion",    int(1e12)),
    ("quadrillion", int(1e15)),
    ("quintillion", int(1e18)),

src/b/a/badger-lib-HEAD/packages/pyparsing/examples/pymicko.py   badger-lib(Download)
    #bit size of variables
    TYPE_BIT_SIZE = 16
    #min/max values of constants
    MIN_INT = -2 ** (TYPE_BIT_SIZE - 1)
    MAX_INT = 2 ** (TYPE_BIT_SIZE - 1) - 1
    MAX_UNSIGNED = 2 ** TYPE_BIT_SIZE - 1
    #available working registers (the last one is the register for function's return value!)
    def insert_constant(self, cname, ctype):
        """Inserts a constant (or returns index if the constant already exists)
           Additionally, checks for range.
        """
        index = self.lookup_symbol(cname, stype=ctype)
        if index == None:
            num = int(cname)
    def global_variable_action(self, text, loc, var):
        """Code executed after recognising a global variable"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "GLOBAL_VAR:",var
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def local_variable_action(self, text, loc, var):
        """Code executed after recognising a local variable"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "LOCAL_VAR:",var, var.name, var.type
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def parameter_action(self, text, loc, par):
        """Code executed after recognising a parameter"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "PARAM:",par
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def constant_action(self, text, loc, const):
        """Code executed after recognising a constant"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "CONST:",const
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        return self.symtab.insert_constant(const[0], const[1])
 
    def function_begin_action(self, text, loc, fun):
        """Code executed after recognising a function definition (type and function name)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
    def function_begin_action(self, text, loc, fun):
        """Code executed after recognising a function definition (type and function name)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "FUN_BEGIN:",fun
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def function_body_action(self, text, loc, fun):
        """Code executed after recognising the beginning of function's body"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "FUN_BODY:",fun
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        self.codegen.function_body()
 
    def function_end_action(self, text, loc, fun):
        """Code executed at the end of function definition"""
        if DEBUG > 0:
            print "FUN_END:",fun
            if DEBUG == 2: self.symtab.display()
    def function_end_action(self, text, loc, fun):
        """Code executed at the end of function definition"""
        if DEBUG > 0:
            print "FUN_END:",fun
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        #set function's attribute to number of function parameters
    def return_action(self, text, loc, ret):
        """Code executed after recognising a return statement"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "RETURN:",ret
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def lookup_id_action(self, text, loc, var):
        """Code executed after recognising an identificator in expression"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "EXP_VAR:",var
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def assignment_action(self, text, loc, assign):
        """Code executed after recognising an assignment statement"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "ASSIGN:",assign
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def mulexp_action(self, text, loc, mul):
        """Code executed after recognising a mulexp expression (something *|/ something)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "MUL_EXP:",mul
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def numexp_action(self, text, loc, num):
        """Code executed after recognising a numexp expression (something +|- something)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "NUM_EXP:",num
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def function_call_prepare_action(self, text, loc, fun):
        """Code executed after recognising a function call (type and function name)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "FUN_PREP:",fun
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def argument_action(self, text, loc, arg):
        """Code executed after recognising each of function's arguments"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "ARGUMENT:",arg.exp
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def function_call_action(self, text, loc, fun):
        """Code executed after recognising the whole function call"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "FUN_CALL:",fun
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def relexp_action(self, text, loc, arg):
        """Code executed after recognising a relexp expression (something relop something)"""
        if DEBUG > 0:
            print "REL_EXP:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        exshared.setpos(loc, text)
    def andexp_action(self, text, loc, arg):
        """Code executed after recognising a andexp expression (something and something)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "AND+EXP:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def logexp_action(self, text, loc, arg):
        """Code executed after recognising logexp expression (something or something)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "LOG_EXP:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def if_begin_action(self, text, loc, arg):
        """Code executed after recognising an if statement (if keyword)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "IF_BEGIN:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def if_body_action(self, text, loc, arg):
        """Code executed after recognising if statement's body"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "IF_BODY:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def if_else_action(self, text, loc, arg):
        """Code executed after recognising if statement's else body"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "IF_ELSE:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def if_end_action(self, text, loc, arg):
        """Code executed after recognising a whole if statement"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "IF_END:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        self.codegen.newline_label("exit{0}".format(self.label_stack.pop()), True, True)
 
    def while_begin_action(self, text, loc, arg):
        """Code executed after recognising a while statement (while keyword)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
    def while_begin_action(self, text, loc, arg):
        """Code executed after recognising a while statement (while keyword)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "WHILE_BEGIN:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def while_body_action(self, text, loc, arg):
        """Code executed after recognising while statement's body"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "WHILE_BODY:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def while_end_action(self, text, loc, arg):
        """Code executed after recognising a whole while statement"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "WHILE_END:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def program_end_action(self, text, loc, arg):
        """Checks if there is a 'main' function and the type of 'main' function"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "PROGRAM_END:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return

src/b/i/bioimagexd-HEAD/bioimagexd/trunk/GUI/ResampleDialog.py   bioimagexd(Download)
 
		rx, ry, rz = self.dims
		try:
			rx = int(self.newDimX.GetValue())
			ry = int(self.newDimY.GetValue())
			rz = int(self.newDimZ.GetValue())
		except:
		for obj in [self.factorLabel, self.dimLabel, self.newDimX, self.newDimY, self.newDimZ, self.factorX, self.factorY, self.factorZ]:
			obj.Enable(1)
		try:
			rx = int(self.newDimX.GetValue())
			ry = int(self.newDimY.GetValue())
			rz = int(self.newDimZ.GetValue())
			self.currSize = (rx, ry, rz)
 
			if self.halfResampleZ.GetValue():
				zf = 0.5
			self.currSize = int(0.5 * x), int(0.5 * y), int(zf * z)
		self.fourthResampleZ.Enable(0)
		for obj in [self.factorLabel, self.dimLabel, self.newDimX, self.newDimY, self.newDimZ, self.factorX, self.factorY, self.factorZ]:
			obj.Enable(0)
 
			if self.fourthResampleZ.GetValue():
				zf = 0.25
			self.currSize = int(0.25 * x), int(0.25 * y), int(zf * z)   
		for obj in [self.factorLabel, self.dimLabel, self.newDimX, self.newDimY, self.newDimZ, self.factorX, self.factorY, self.factorZ]:
			obj.Enable(0)
 

src/s/h/shedskin-HEAD/examples/genetic2.py   shedskin(Download)
def make_random_genome(node, depth=0):
    if depth >= MAX_DEPTH or random() > 0.7:
        node.opcode = OPCODE_NONE
        node.args = None
        node.value = randrange(MUX_SIZE + DATA_SIZE)
    else:
        node.opcode = randint(OPCODE_AND, OPCODE_IF)
    def mutate(self):
        """Mutate this node."""
        # If we're a terminal node, stop so we don't exceed our depth.
        if self.opcode == OPCODE_NONE:
            return
 
        if random() > 0.5:
            # Turn this node into a terminal node.
            make_random_genome(self, MAX_DEPTH)
        else:
            # Turn this into a different node.
            make_random_genome(self, MAX_DEPTH-1)
    def execute(self, input):
        if self.opcode == OPCODE_NONE:
            return (input & (1 << self.value)) >> self.value
        elif self.opcode == OPCODE_AND:
            return self.args[0].execute(input) & \
                   self.args[1].execute(input)
        elif self.opcode == OPCODE_OR:
            return self.args[0].execute(input) | \
                   self.args[1].execute(input)
        elif self.opcode == OPCODE_NOT:
            return 1 ^ self.args[0].execute(input)
        elif self.opcode == OPCODE_IF:
    def __str__(self):
        if self.opcode == OPCODE_NONE:
            output = "(bit %s)" % self.value
        elif self.opcode == OPCODE_AND:
            output = "(and %s %s)" % self.args
        elif self.opcode == OPCODE_OR:
            output = "(or %s %s)" % self.args
        elif self.opcode == OPCODE_NOT:
            output = "(not %s)" % self.args
        elif self.opcode == OPCODE_IF:
    def get_random_node(self, max_depth=MAX_DEPTH):
        """Get a random node from the tree."""
        root = self.genome
        previous_root = root
        choice = 0
        for counter in range(max_depth):
            if root.args and random() > 1 / MAX_DEPTH:
    def update_fitness(self, full_test=False):
        """Calculate the individual's fitness and update it."""
        correct = 0
        if full_test:
            data = (1 << DATA_SIZE) - 1
            for mux in range(DATA_SIZE):
                for _ in range(2):
                    correct_output = (data & (1 << mux)) >> mux
                    if output == correct_output:
                        correct += 1
            total = DATA_SIZE * 2
        else:
            for mux in range(DATA_SIZE):
                for data in range(1 << DATA_SIZE):
                    correct_output = (data & (1 << mux)) >> mux
                    if output == correct_output:
                        correct += 1
            total = (1 << DATA_SIZE) * DATA_SIZE
 
        self.fitness = (1.0 * correct) / total
        return self.fitness
        new_population = []
 
        # Clone our best people.
        iters = int(Pool.population_size * 0.4)
        for counter in range(iters):
            new_individual = self.population[counter].copy()
            new_population.append(new_individual)
 
        # Breed our best people, producing four offspring for each couple.
        iters = int(Pool.population_size * 0.6)
        for counter in range(0, iters, 2):
            # Perform rank roulette selection.
            father = self.population[int(triangular(0, iters, 0))]
            mother = self.population[int(triangular(0, iters, 0))]

src/r/e/reporter-lib-HEAD/packages/pyparsing/examples/wordsToNum.py   reporter-lib(Download)
hundreds = makeLit("hundred", 100)
 
majorDefinitions = [
    ("thousand",    int(1e3)),
    ("million",     int(1e6)),
    ("billion",     int(1e9)),
    ("trillion",    int(1e12)),
    ("quadrillion", int(1e15)),
    ("quintillion", int(1e18)),

src/q/u/quickflash-HEAD/branch_tags/octave-swig/QuickFlash-1.0.0-Octave-1.0/examples/expansion_correct/show_map.py   quickflash(Download)
    def __init__(self, filename=None) :
 
        self.__times = list()
        self.__interfaces = list()
        self.__traj = list()
 
        self.__num_times = int(0)
        self.__num_parts = int(0)
    def read_data(self, filename) :
 
        self.__times = list()
        self.__interfaces = list()
        self.__traj = list()
 
        self.__num_times = int(0)
        self.__num_parts = int(0)
            if (len(words) != 2) :
                raise ValueError("Improper format for map file")
 
            file_timesteps = int(words[0])
 
            num_parts = int(words[1])
 
 
            num_step_values = num_parts + 2  # time, interface, pos
 
            timestep_count = int(0)
 
            for step_index in range(num_lines - 1) :
 
                     + "[ output_filename_prefix ]\n")
        exit(1)
 
    argPtr = int(1)
 
    map_file = str(argv[argPtr])
    argPtr += 1
    if (not (min_init_x < max_init_x)) :
        raise ValueError("Incompatible initial x limits")
 
    traj_skip = int(1)
 
    traj_skip = int(argv[argPtr])
    argPtr += 1

src/k/a/kamaelia-HEAD/trunk/Sketches/MH/Layout/Example/VisibleParticle.py   kamaelia(Download)
    def renderBonds(self, surface):
        """Renders lines representing the bonds going from this particle"""
        for p in self.bondedTo:
            pygame.draw.line(surface, (128,128,255), [int(i) for i in self.pos],  [int(i) for i in p.pos])
 
    def renderSelf(self, surface):
        """Renders a circle with the particle name in it"""
        pygame.draw.circle(surface, (255,128,128), (int(self.pos[0]), int(self.pos[1])), self.radius)
        surface.blit(self.label, (int(self.pos[0]) - self.label.get_width()/2, int(self.pos[1]) - self.label.get_height()/2))
    def drawGrid(self):
        for i in range(0,self.screen.get_height(), int(self.laws.maxInteractRadius)):
            pygame.draw.line(self.screen, (200,200,200),
                             (0,i),
                             (self.screen.get_width(),i) )
 
        for i in range(0,self.screen.get_width(), int(self.laws.maxInteractRadius)):

src/k/a/kamaelia-HEAD/trunk/Sketches/MH/Layout/Example/PhysApp1.py   kamaelia(Download)
    def renderBonds(self, surface):
        """Renders lines representing the bonds going from this particle"""
        for p in self.bondedTo:
            pygame.draw.line(surface, (128,128,255), [int(i) for i in self.pos],  [int(i) for i in p.pos])
 
    def renderSelf(self, surface):
        """Renders a circle with the particle name in it"""
        pygame.draw.circle(surface, (255,128,128), (int(self.pos[0]), int(self.pos[1])), self.radius)
        surface.blit(self.label, (int(self.pos[0]) - self.label.get_width()/2, int(self.pos[1]) - self.label.get_height()/2))
    def drawGrid(self):
        for i in range(0,self.screen.get_height(), int(self.laws.maxInteractRadius)):
            pygame.draw.line(self.screen, (200,200,200),
                             (0,i),
                             (self.screen.get_width(),i) )
 
        for i in range(0,self.screen.get_width(), int(self.laws.maxInteractRadius)):

src/r/e/reporter-lib-HEAD/packages/pyparsing/examples/pymicko.py   reporter-lib(Download)
    #bit size of variables
    TYPE_BIT_SIZE = 16
    #min/max values of constants
    MIN_INT = -2 ** (TYPE_BIT_SIZE - 1)
    MAX_INT = 2 ** (TYPE_BIT_SIZE - 1) - 1
    MAX_UNSIGNED = 2 ** TYPE_BIT_SIZE - 1
    #available working registers (the last one is the register for function's return value!)
    def insert_constant(self, cname, ctype):
        """Inserts a constant (or returns index if the constant already exists)
           Additionally, checks for range.
        """
        index = self.lookup_symbol(cname, stype=ctype)
        if index == None:
            num = int(cname)
    def global_variable_action(self, text, loc, var):
        """Code executed after recognising a global variable"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "GLOBAL_VAR:",var
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def local_variable_action(self, text, loc, var):
        """Code executed after recognising a local variable"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "LOCAL_VAR:",var, var.name, var.type
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def parameter_action(self, text, loc, par):
        """Code executed after recognising a parameter"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "PARAM:",par
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def constant_action(self, text, loc, const):
        """Code executed after recognising a constant"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "CONST:",const
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        return self.symtab.insert_constant(const[0], const[1])
 
    def function_begin_action(self, text, loc, fun):
        """Code executed after recognising a function definition (type and function name)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
    def function_begin_action(self, text, loc, fun):
        """Code executed after recognising a function definition (type and function name)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "FUN_BEGIN:",fun
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def function_body_action(self, text, loc, fun):
        """Code executed after recognising the beginning of function's body"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "FUN_BODY:",fun
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        self.codegen.function_body()
 
    def function_end_action(self, text, loc, fun):
        """Code executed at the end of function definition"""
        if DEBUG > 0:
            print "FUN_END:",fun
            if DEBUG == 2: self.symtab.display()
    def function_end_action(self, text, loc, fun):
        """Code executed at the end of function definition"""
        if DEBUG > 0:
            print "FUN_END:",fun
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        #set function's attribute to number of function parameters
    def return_action(self, text, loc, ret):
        """Code executed after recognising a return statement"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "RETURN:",ret
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def lookup_id_action(self, text, loc, var):
        """Code executed after recognising an identificator in expression"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "EXP_VAR:",var
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def assignment_action(self, text, loc, assign):
        """Code executed after recognising an assignment statement"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "ASSIGN:",assign
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def mulexp_action(self, text, loc, mul):
        """Code executed after recognising a mulexp expression (something *|/ something)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "MUL_EXP:",mul
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def numexp_action(self, text, loc, num):
        """Code executed after recognising a numexp expression (something +|- something)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "NUM_EXP:",num
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def function_call_prepare_action(self, text, loc, fun):
        """Code executed after recognising a function call (type and function name)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "FUN_PREP:",fun
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def argument_action(self, text, loc, arg):
        """Code executed after recognising each of function's arguments"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "ARGUMENT:",arg.exp
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def function_call_action(self, text, loc, fun):
        """Code executed after recognising the whole function call"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "FUN_CALL:",fun
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def relexp_action(self, text, loc, arg):
        """Code executed after recognising a relexp expression (something relop something)"""
        if DEBUG > 0:
            print "REL_EXP:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        exshared.setpos(loc, text)
    def andexp_action(self, text, loc, arg):
        """Code executed after recognising a andexp expression (something and something)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "AND+EXP:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def logexp_action(self, text, loc, arg):
        """Code executed after recognising logexp expression (something or something)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "LOG_EXP:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def if_begin_action(self, text, loc, arg):
        """Code executed after recognising an if statement (if keyword)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "IF_BEGIN:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def if_body_action(self, text, loc, arg):
        """Code executed after recognising if statement's body"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "IF_BODY:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def if_else_action(self, text, loc, arg):
        """Code executed after recognising if statement's else body"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "IF_ELSE:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def if_end_action(self, text, loc, arg):
        """Code executed after recognising a whole if statement"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "IF_END:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        self.codegen.newline_label("exit{0}".format(self.label_stack.pop()), True, True)
 
    def while_begin_action(self, text, loc, arg):
        """Code executed after recognising a while statement (while keyword)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
    def while_begin_action(self, text, loc, arg):
        """Code executed after recognising a while statement (while keyword)"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "WHILE_BEGIN:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def while_body_action(self, text, loc, arg):
        """Code executed after recognising while statement's body"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "WHILE_BODY:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def while_end_action(self, text, loc, arg):
        """Code executed after recognising a whole while statement"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "WHILE_END:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
    def program_end_action(self, text, loc, arg):
        """Checks if there is a 'main' function and the type of 'main' function"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print "PROGRAM_END:",arg
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return

src/m/a/matplotlib-HEAD/toolkits/basemap/examples/test.py   matplotlib(Download)
            resolution='c',area_thresh=10000.,projection='merc',\
            lon_0=0.5*(lons[0]+lons[-1]),lat_ts=20.)
# transform to nx x ny regularly spaced native projection grid
nx = len(lons); ny = int(80.*len(lats)/90.)
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
fig.add_axes([0.1,0.1,0.75,0.75])
# plot image over map.
            lat_0=54.,lon_0=-2.)
fig.add_axes([0.125,0.2,0.6,0.6])
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/20000.)+1; ny = int((m.ymax-m.ymin)/20000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
# plot image over map.
im = m.imshow(topodat,plt.cm.jet)
            lat_0=-10.,lon_0=-60.)
fig.add_axes([0.125,0.2,0.6,0.6])
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
# plot image over map.
im = m.imshow(topodat,plt.cm.jet)
            lat_0=0.,lon_0=-90.)
fig.add_axes([0.125,0.2,0.6,0.6])
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
# plot image over map.
im = m.imshow(topodat,plt.cm.jet)
            resolution='l',area_thresh=1000.,projection='omerc',\
            lon_0=-100,lat_0=15,lon_2=-120,lat_2=65,lon_1=-50,lat_1=-55)
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/20000.)+1; ny = int((m.ymax-m.ymin)/20000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
# plot image over map.
im = m.imshow(topodat,plt.cm.jet)
            lat_0=0.,lon_0=20.)
fig.add_axes([0.125,0.2,0.6,0.6])
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
# plot image over map.
im = m.imshow(topodat,plt.cm.jet)
            resolution='l',area_thresh=1000.,projection='eqdc',\
            lat_1=21.,lat_2=23.,lon_0=-80.)
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map.
            resolution='c',area_thresh=10000.,projection='lcc',\
            lat_1=50.,lon_0=-107.)
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map.
            resolution='l',projection='aea',\
            lat_1=40.,lat_2=60,lon_0=35.)
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map.
m = Basemap(lon_0=75.,boundinglat=-20,
            resolution='c',area_thresh=10000.,projection='spstere')
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map.
m = Basemap(lon_0=-105,boundinglat=20.,
            resolution='c',area_thresh=10000.,projection='nplaea')
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map.
m = Basemap(lon_0=-105,boundinglat=55.,
            resolution='c',area_thresh=10000.,projection='npaeqd')
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map.
# transform to nx x ny regularly spaced native projection grid
# nx and ny chosen to have roughly the same horizontal res as original image.
dx = 2.*np.pi*m.rmajor/len(lons)
nx = int((m.xmax-m.xmin)/dx)+1; ny = int((m.ymax-m.ymin)/dx)+1
# interpolate to native projection grid.
# values outside of projection limb will be masked.
topo = m.transform_scalar(topoin,lons,lats,nx,ny,masked=True)
# transform to nx x ny regularly spaced native projection grid
# nx and ny chosen to have roughly the same horizontal res as original image.
dx = 2.*np.pi*m.rmajor/len(lons)
nx = int((m.xmax-m.xmin)/dx)+1; ny = int((m.ymax-m.ymin)/dx)+1
# interpolate to native projection grid.
# values outside of projection limb will be masked.
topo = m.transform_scalar(topoin,lons,lats,nx,ny,masked=True)

Previous  5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13  Next