def cycle1(self): t0 = time.time() changed = False out = self.map for pos, cell in self.iter_map(): x,y = pos #print neighbors = self.get_rect(pos,1) #print pos, cell == self.max, cell==self.wall, cell == 0 #print neighbors if len(neighbors[0]) == 0: print 'ack' continue #for l in neighbors: # print (x,y), l #print min_neighbor = numpy.min(neighbors) if cell > min_neighbor + 1: self[x,y] = min_neighbor + 1 changed = True #if cell > min_neighbor + 1: # changed = True # self[x,y] = min_neighbor + 1 if changed: self.iters += 1 return changed
def normalize(cls, input_list, **kwargs): """ Normalize list elements """ list_min = numpypy.min(input_list, **kwargs) list_norm = 1.0 / (numpypy.max(input_list, **kwargs) - list_min) if kwargs.pop("round", True): output_list = map(lambda x: round((x - list_min) * list_norm, cls.default_round), input_list) else: output_list = map(lambda x: (x - list_min) * list_norm, input_list) return output_list
def test_min_max_after_import(self): import __builtin__ from __builtin__ import * from numpypy import * assert min is __builtin__.min assert max is __builtin__.max assert min(1, 100) == 1 assert min(100, 1) == 1 assert max(1, 100) == 100 assert max(100, 1) == 100 assert min(4, 3, 2, 1) == 1 assert max(1, 2, 3, 4) == 4 from numpypy import min, max, amin, amax assert min is not __builtin__.min assert max is not __builtin__.max assert min is amin assert max is amax
def cycle(self): changed = False out = self.map for pos, cell in self.iter_map(): x,y = pos neighbors = numpy.min(self.get_rect(pos, 1)) if cell > neighbors + 1: changed = True self[x,y] = neighbors + 1 if changed: self.iters += 1 return changed
def min(cls, input_list, **kwargs): """ Calculate floor """ return round(numpypy.min(input_list, **kwargs), cls.default_round)