rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
mb.code_creator.replace_included_headers( ["xfx.h"], False )
mb.code_creator.adopt_creator( code_creators.include_t( 'xfx.h' ), 0 )
def camel_convert(name): s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
mb.class_( lambda x: x.name.startswith( 'HWND' ) ).include( )
def camel_convert(name): s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
mb.member_functions( "Instance" ).call_policies = call_policies.return_internal_reference( ) mb.free_function( "gGetApplication" ).call_policies = call_policies.return_internal_reference( )
mb.member_functions( "Instance" ).call_policies = call_policies.return_value_policy( call_policies.reference_existing_object ) mb.free_function( "gGetApplication" ).call_policies = call_policies.return_value_policy( call_policies.reference_existing_object )
def camel_convert(name): s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
mb.class_( "Quaternion" ).member_function( "FromAxisAngle" ).call_policies = call_policies.return_internal_reference( ) mb.class_( "Mat3" ).member_function( "MakeIdentity" ).call_policies = call_policies.return_internal_reference( ) mb.class_( "Mat4" ).member_function( "MakeIdentity" ).call_policies = call_policies.ret...
mb.class_( "Quaternion" ).member_function( "FromAxisAngle" ).call_policies = call_policies.return_self( ) mb.class_( "Mat3" ).member_function( "MakeIdentity" ).call_policies = call_policies.return_self( ) mb.class_( "Mat4" ).member_function( "MakeIdentity" ).call_policies = call_policies.return_self( ) mb.class_( "Eule...
def camel_convert(name): s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
mb.member_functions( "Cache", arg_types = [] ).call_policies = call_policies.return_internal_reference( )
mb.class_( "Application" ).member_function( "HWnd" ).call_policies = call_policies.return_value_policy( call_policies.return_opaque_pointer ) mb.member_functions( "Cache", arg_types = [] ).call_policies = call_policies.return_value_policy( call_policies.reference_existing_object )
def camel_convert(name): s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
return abs(x-y)/max(1.0,abs(x)) > 1e-12
return abs(x-y)/max(1.0,abs(x)) > 1e-4
def mismatch(x,y): return abs(x-y)/max(1.0,abs(x)) > 1e-12
print ' !!!SKIPPED'
check(ga.C_SCPL, np.complex64)
def main(): if 0 == me: if MIRROR: print ' Performing tests on Mirrored Arrays' print ' GA initialized' # note that MA is not used, so no need to initialize it # "import ga" registers malloc/free as memory allocators internally #if nproc-1 == me: if 0 == me: print 'using %d process(es) %d custer nodes' % ( nproc, ga....
print ' !!!SKIPPED'
check(ga.C_DCPL, np.complex128)
def main(): if 0 == me: if MIRROR: print ' Performing tests on Mirrored Arrays' print ' GA initialized' # note that MA is not used, so no need to initialize it # "import ga" registers malloc/free as memory allocators internally #if nproc-1 == me: if 0 == me: print 'using %d process(es) %d custer nodes' % ( nproc, ga....
maxproc = 4096
def check(gatype, nptype): n = 256 m = 2*n a = np.zeros((n,n), dtype=nptype) b = np.zeros((n,n), dtype=nptype) maxloop = 100 maxproc = 4096 num_restricted = 0 restricted_list = 0 iproc = me % lprocs nloop = min(maxloop,n) if USE_RESTRICTED: num_restricted = nproc/2 restricted_list = [0]*num_restricted if (num_restricte...
if MIRROR: a[:] = np.fromfunction(lambda i,j: inode+i+j*n, (n,n), dtype=nptype) else: a[:] = np.fromfunction(lambda i,j: i+j*n, (n,n), dtype=nptype) b[:] = -1
a[:] = init_first_a(gatype, nptype, n) b[:] = init_first_b(gatype, nptype, n)
def check(gatype, nptype): n = 256 m = 2*n a = np.zeros((n,n), dtype=nptype) b = np.zeros((n,n), dtype=nptype) maxloop = 100 maxproc = 4096 num_restricted = 0 restricted_list = 0 iproc = me % lprocs nloop = min(maxloop,n) if USE_RESTRICTED: num_restricted = nproc/2 restricted_list = [0]*num_restricted if (num_restricte...
for i in range(n): for j in range(n): b[i,j] = random.random() a[i,j] = 0.1*a[i,j] + 0.9*b[i,j]
if gatype == ga.C_SCPL: for i in range(n): for j in range(n): b[i,j] = complex(random.random(),random.random()) a[i,j] = complex(0.1,-.1)*a[i,j] + complex(0.9,-.9)*b[i,j] else: for i in range(n): for j in range(n): b[i,j] = random.random() a[i,j] = 0.1*a[i,j] + 0.9*b[i,j]
def check(gatype, nptype): n = 256 m = 2*n a = np.zeros((n,n), dtype=nptype) b = np.zeros((n,n), dtype=nptype) maxloop = 100 maxproc = 4096 num_restricted = 0 restricted_list = 0 iproc = me % lprocs nloop = min(maxloop,n) if USE_RESTRICTED: num_restricted = nproc/2 restricted_list = [0]*num_restricted if (num_restricte...
ga.add(g_a, g_b, g_b, 0.1, 0.9) if not np.all(ga.get(g_b) == a):
if gatype == ga.C_SCPL: ga.add(g_a, g_b, g_b, complex(0.1,-0.1), complex(0.9,-0.9)) else: ga.add(g_a, g_b, g_b, 0.1, 0.9) b = ga.get(g_b, buffer=b) if np.any(np.vectorize(mismatch)(ga.get(g_b),a)):
def check(gatype, nptype): n = 256 m = 2*n a = np.zeros((n,n), dtype=nptype) b = np.zeros((n,n), dtype=nptype) maxloop = 100 maxproc = 4096 num_restricted = 0 restricted_list = 0 iproc = me % lprocs nloop = min(maxloop,n) if USE_RESTRICTED: num_restricted = nproc/2 restricted_list = [0]*num_restricted if (num_restricte...
test2D()
def main(): if 4 != nproc and 0 == me: ga.error('Program requires 4 GA processes') test1D() test2D() if 0 == me: print 'All tests successful'
ignore = ga.get(g_a, llo, lhi, buf[ga.zip(llo,lhi)])
ignore = ga.get(g_a, llo, lhi, buf[ilo:ihi,jlo:jhi])
def time_get(g_a, lo, hi, buf, chunk, jump, local): count = 0 rows = hi[0]-lo[0] cols = hi[1]-lo[1] shifti = [rows, 0, rows] shiftj = [0, cols, cols] seconds = time.time() # distance between consecutive patches increased by jump # to destroy locality of reference for ilo in range(lo[0], hi[0]-chunk-jump+1, chunk+jump):...
ga.put(g_a, buf[ga.zip(llo,lhi)], llo, lhi)
ga.put(g_a, buf[ilo:ihi,jlo:jhi], llo, lhi)
def time_put(g_a, lo, hi, buf, chunk, jump, local): count = 0 rows = hi[0]-lo[0] cols = hi[1]-lo[1] shifti = [rows, 0, rows] shiftj = [0, cols, cols] seconds = time.time() # distance between consecutive patches increased by jump # to destroy locality of reference for ilo in range(lo[0], hi[0]-chunk-jump+1, chunk+jump):...
ga.acc(g_a, buf[ga.zip(llo,lhi)], llo, lhi, 1)
ga.acc(g_a, buf[ilo:ihi,jlo:jhi], llo, lhi, 1)
def time_acc(g_a, lo, hi, buf, chunk, jump, local): count = 0 rows = hi[0]-lo[0] cols = hi[1]-lo[1] shifti = [rows, 0, rows] shiftj = [0, cols, cols] seconds = time.time() # distance between consecutive patches increased by jump # to destroy locality of reference for ilo in range(lo[0], hi[0]-chunk-jump+1, chunk+jump):...
TestPutGetAcc1(g_a, n, chunk, buf, lo, hi, True)
def test1D(): n = 1024*1024 buf = np.zeros(n/4, dtype=np.float64) chunk = np.asarray([1,9,16,81,256,576,900,2304,4096,8281, 16384,29241,65536,124609,193600,262144]) g_a = ga.create(ga.C_DBL, (n,), 'a') if 0 == g_a: ga.error('ga.create failed') buf[:] = 0.01 ga.zero(g_a) if 0 == me: print '' print '' print '' print (' P...
print ilo,ihi ignore = ga.get(g_a, llo, lhi, buf[llo:lhi])
ignore = ga.get(g_a, llo, lhi, buf[ilo:ihi])
def time_get1(g_a, lo, hi, buf, chunk, jump, local): count = 0 rows = hi[0]-lo[0] shift = [3*rows, 2*rows, rows] seconds = time.time() # distance between consecutive patches increased by jump # to destroy locality of reference for ilo in range(lo[0], hi[0]-chunk-jump+1, chunk+jump): ihi = ilo+chunk count += 1 if local:...
ga.put(g_a, buf[llo:lhi], llo, lhi)
ga.put(g_a, buf[ilo:ihi], llo, lhi)
def time_put1(g_a, lo, hi, buf, chunk, jump, local): count = 0 rows = hi[0]-lo[0] shift = [rows, 2*rows, 3*rows] seconds = time.time() # distance between consecutive patches increased by jump # to destroy locality of reference for ilo in range(lo[0], hi[0]-chunk-jump+1, chunk+jump): ihi = ilo+chunk count += 1 if local:...
elif gatype == ga.C_INT:
elif gatype in [ga.C_INT,ga.C_LONG]:
def create_local_a(gatype): """TODO""" nptype = ga.dtype(gatype) if gatype == ga.C_SCPL: if MIRROR: a = np.fromfunction(lambda i,j: i+inode, (n,n), dtype=np.float32) b = np.fromfunction(lambda i,j: j*n, (n,n), dtype=np.float32) return np.vectorize(complex)(a,b) else: a = np.fromfunction(lambda i,j: i, (n,n), dtyp...
check_dot(gatype) check_scale(gatype)
def check_int(): gatype = ga.C_INT check_zero(gatype) check_put_disjoint(gatype) check_get(gatype) check_accumulate_disjoint(gatype) check_accumulate_overlap(gatype) #check_add(gatype) check_dot(gatype) check_scale(gatype) check_copy(gatype) check_scatter_gather(gatype) """ ga.sync() if 0 == me and n > 7: print '' prin...
check_print_patch(gatype) check_fence_and_lock(gatype)
def check_int(): gatype = ga.C_INT check_zero(gatype) check_put_disjoint(gatype) check_get(gatype) check_accumulate_disjoint(gatype) check_accumulate_overlap(gatype) #check_add(gatype) check_dot(gatype) check_scale(gatype) check_copy(gatype) check_scatter_gather(gatype) """ ga.sync() if 0 == me and n > 7: print '' prin...
pass
gatype = ga.C_LONG check_zero(gatype) check_put_disjoint(gatype) check_get(gatype) check_accumulate_disjoint(gatype) check_accumulate_overlap(gatype) check_copy(gatype) check_scatter_gather(gatype) check_print_patch(gatype) check_fence_and_lock(gatype)
def check_long(): pass
if do_cmdline and pyfeatures.get('nmag', 'clean', raw=True): nsim.snippets.rename_old_files([logfilename])
def setup(argv=None, do_features=True, do_logging=True, do_welcome=None, log_to_console_only=None, warn_about_py_ext=True): """Carry out the various stages of the setup of Nsim. do_cmdline: the command line is parsed using the OptionParser object stored inside cmdline_parser variable. If it has not been set by the use...
["petscvec", "petscmat", "petscksp", "petscts", "petscsnes", "petscdm"],
["petsc", "petscvec", "petscmat", "petscksp", "petscts", "petscsnes", "petscdm"],
def find_file(names, prefixes, suffixes, paths): for full_name in possible_names(names, prefixes, suffixes): full_path = find_path_of_file(full_name, paths) if full_path != None: return (full_name, full_path) return None
raise "Found inconsistency between the mesh you loaded and the " \ "provided list of (region_name, materials). The mesh has " \ "%d regions but the provided list has %d pairs." \ % (self.mesh.numregions-1, len(self.region_name_list))
msg = ("Found inconsistency between the mesh you loaded and the " "provided list of (region_name, materials). The mesh has " "%d regions but the provided list has %d pairs." % (self.mesh.numregions-1, len(self.region_name_list))) raise NmagUserError(msg)
def load_mesh(self, filename, region_names_and_mag_mats, unit_length, do_reorder=False,manual_distribution=None): """ :Parameters:
return self.set_field_data(field_name, subfield_name, save_id)
return self.set_field_data(field_name, subfield_name, save_row)
def set_field_data_at_time(self, field_name, subfield_name, time, equality_tolerance=1e-19): f = self.open_handler() counters = self.get_counters_for_field(field_name, subfield_name) ids = counters['id'] times = counters['time'] rows = counters['row'] num_ids = len(ids) assert len(times) == num_ids, ("Inconsistency fou...
def split_strings(ls): s = ls.lstrip()
def split_strings(s, delim='"'): """Similar to s.split() but do not split whatherver is included between two delimiters.""" OUTSIDE, INSIDE, SPACE = range(3) state = SPACE n = len(s) i = 0 begin = 0
def split_strings(ls): s = ls.lstrip() pieces = [] while len(s) > 0: second = s.find('"', 1) assert second > 0 and s[0] == '"' and s[second] == '"', \ ("split_strings expects a number of strings delimited by \" and " "separated by spaces, but it got: '%s'." % ls) pieces.append(s[1: second]) s = s[second + 1:].lstrip...
while len(s) > 0: second = s.find('"', 1) assert second > 0 and s[0] == '"' and s[second] == '"', \ ("split_strings expects a number of strings delimited by \" and " "separated by spaces, but it got: '%s'." % ls) pieces.append(s[1: second]) s = s[second + 1:].lstrip()
while i < n: c = s[i] inc = 1 if state == SPACE: if not c.isspace(): begin = i state = OUTSIDE elif state == OUTSIDE: if c.isspace(): pieces.append(s[begin:i]) state = SPACE elif c == delim: state = INSIDE else: if c == delim: state = OUTSIDE i += inc if state != SPACE: pieces.append(s[begin:])
def split_strings(ls): s = ls.lstrip() pieces = [] while len(s) > 0: second = s.find('"', 1) assert second > 0 and s[0] == '"' and s[second] == '"', \ ("split_strings expects a number of strings delimited by \" and " "separated by spaces, but it got: '%s'." % ls) pieces.append(s[1: second]) s = s[second + 1:].lstrip...
return '%s_%s' % (field_name, subfield_name)
if subfield_name == None or len(subfield_name.strip()) == 0: return field_name else: return '%s_%s' % (field_name, subfield_name)
def build_full_field_name(field_name, subfield_name): return '%s_%s' % (field_name, subfield_name)
["DEBUG","Electric_ext","v_Electric_ext",6], ["DEBUG","grad_m","v_grad_m",18], ["DEBUG","H_magnetoelectric","v_H_magnetoelectric",6],
def E_relabeled(new_label): return map(lambda mn: ("E_" + mn, new_label + mn), material_names)
dx, dy, dz = [0.5*ssi for ssi in ss]
dx, dy, dz = [0.5*ssi.value for ssi in ss]
def get_field(self): root_node = self.content segment_node = root_node.a_segment h = segment_node.a_header ss = [h.a_xstepsize, h.a_ystepsize, h.a_zstepsize] dx, dy, dz = [0.5*ssi for ssi in ss]
return FieldLattice(min_max_dim, dim=field_dim,
return FieldLattice(min_max_ndim, dim=field_dim,
def get_field(self): root_node = self.content segment_node = root_node.a_segment h = segment_node.a_header ss = [h.a_xstepsize, h.a_ystepsize, h.a_zstepsize] dx, dy, dz = [0.5*ssi for ssi in ss]
"""contribs : | contrib
"""contribs : contrib
def p_contribs(t): """contribs : | contrib | contribs SIGN contrib""" # { [$1] } # { let (c1, t2) = $3 in ($2*.c1, t2)::$1 } pass
"""fields : | field
"""fields : field
def p_fields(t): """fields : | field | field COMMA fields""" #{ [$1] } #{ $1::$3 } pass
"""region_logic_atomic : | LPAREN region_logic RPAREN
"""region_logic_atomic : LPAREN region_logic RPAREN
def p_region_logic_atomic(t): """region_logic_atomic : | LPAREN region_logic RPAREN | INT | STRING | DOF_REGION_ALL EQUALS INT | DOF_REGION_SOME EQUALS INT | DOF_REGION_ALL EQUALS STRING | DOF_REGION_SOME EQUALS STRING | HASH EQUALS INT """ # {$2} # {DLOG_some (string_of_int $1)} # {DLOG_some $1} # {DLOG_all (string_of...
"""region_logic_opt_not : | DOF_REGION_NOT region_logic_atomic
"""region_logic_opt_not : DOF_REGION_NOT region_logic_atomic
def p_region_logic_opt_not(t): """region_logic_opt_not : | DOF_REGION_NOT region_logic_atomic | region_logic_atomic """ # {DLOG_not $2} # {$1} pass
"""region_logic_and : | region_logic_opt_not DOF_REGION_AND region_logic_and
"""region_logic_and : region_logic_opt_not DOF_REGION_AND region_logic_and
def p_region_logic_and(t): """region_logic_and : | region_logic_opt_not DOF_REGION_AND region_logic_and | region_logic_opt_not """ # {DLOG_and [$1;$3]} # {$1} pass
"""region_logic_or : | region_logic_and DOF_REGION_OR region_logic_or
"""region_logic_or : region_logic_and DOF_REGION_OR region_logic_or
def p_region_logic_or(t): """region_logic_or : | region_logic_and DOF_REGION_OR region_logic_or | region_logic_and""" # {DLOG_or [$1;$3]} # {$1} pass
if physical_quantity == 0: return True physical_quantity = Physical(float(physical_quantity)) if self._value == 0.0 or physical_quantity._dims == self._dims:
return ((physical_quantity == 0) or reduce(lambda x, y: x and (y == 0), self._dims, True)) elif self._value == 0.0:
def is_compatible_with(self, physical_quantity): """ Returns True when the given physical quantity is compatible with the object itself.
try: return self.is_compatible_with(Physical(float(physical_quantity))) except: return False
elif isinstance(physical_quantity, SI): return (physical_quantity._dims == self._dims) else: try: x = float(physical_quantity) except: return False return self.is_compatible_with(x)
def is_compatible_with(self, physical_quantity): """ Returns True when the given physical quantity is compatible with the object itself.
return svnversion.svnversion
try: import svnversion return svnversion.svnversion except: return "(unknown)"
def get_version_string(): return svnversion.svnversion
msg += "\n\tnsim.svnversion =" + str(nsim.svnversion.svnversion)
msg += "\n\tnsim.version =" + str(v)
def get_nmag_release_dist_svn_string(): msg = "Versions:" msg += "\n\tnsim.svnversion =" + str(nsim.svnversion.svnversion) msg += "\n\tnmag-release =" + str(get_nmag_release()) msg += "\n\tnmag-distribution-mode =" + str(get_nmag_distmode()) msg += "\n\tnmag-release-date =" + str(get_nmag_release...
u = hdf5.get_mesh_unit(filehandle)
u = SI(1e-9, "m")
def set_from_file(self, filehandle, field_name, subfield_name): """Read the field info from the given hdf5 file handle or file name. """ full_name = build_full_field_name(field_name, subfield_name)
configs["petsc-libdir"] = (
configs["petsc-libdir"] = [
def find_file(names, prefixes, suffixes, paths): for full_name in possible_names(names, prefixes, suffixes): full_path = find_path_of_file(full_name, paths) if full_path != None: return (full_name, full_path) return None
["petsc", "petscvec", "petscmat", "petscksp", "petscts", "petscsnes", "petscdm"],
["petscvec", "petscmat", "petscksp", "petscts", "petscsnes", "petscdm"],
def find_file(names, prefixes, suffixes, paths): for full_name in possible_names(names, prefixes, suffixes): full_path = find_path_of_file(full_name, paths) if full_path != None: return (full_name, full_path) return None
)
]
def find_file(names, prefixes, suffixes, paths): for full_name in possible_names(names, prefixes, suffixes): full_path = find_path_of_file(full_name, paths) if full_path != None: return (full_name, full_path) return None
mwe_field_by_name = self._master_mwes_and_fields_by_name
def dump_fields(self, fields=None, filename=None, inspect=None, format="binary"): """Dump the given field to a vtk file and launch Mayavi for visualisation, if required (useful for interactive work).""" if filename == None: filename = "%s-dump.vtk" % self.name
fields = [f for _, f in mwe_field_by_name.values()]
fields = [self._fields[name] for name in self._fields.keys()]
def dump_fields(self, fields=None, filename=None, inspect=None, format="binary"): """Dump the given field to a vtk file and launch Mayavi for visualisation, if required (useful for interactive work).""" if filename == None: filename = "%s-dump.vtk" % self.name
fields = [mwe_field_by_name[name][1] for name in fields]
fields = [self._fields[name] for name in fields]
def dump_fields(self, fields=None, filename=None, inspect=None, format="binary"): """Dump the given field to a vtk file and launch Mayavi for visualisation, if required (useful for interactive work).""" if filename == None: filename = "%s-dump.vtk" % self.name
if int(mapid) >= 100:
if int(mapid) in (100, 101):
def mapcols(mapid): # "i" and "o" are omitted from barrington atlas columns in maps 100-102 if int(mapid) >= 100: return 'abcdefghjklmnpqrstuvwxyz' else: return 'abcdefghijklmnopqrstuvwxyz'
site = container.portal_url.getPortalObject()
site = getToolByName(container, 'portal_url').getPortalObject()
def getTemplate(self, container): site = container.portal_url.getPortalObject() parent = container container_base = Acquisition.aq_base(container) while parent is not None: template = component.queryMultiAdapter( (parent, self), interfaces.ITemplate) parent_base = Acquisition.aq_base(parent) if template is not None and...
if list1[x+y] != list2[y]: break else: counter += 1
try: if list1[x+y] != list2[y]: break else: counter += 1 except IndexError: return -1
def locateInArray(list1, list2): x = 0 y = 0 for x in xrange(len(list1)): if list1[x] == list2[0]: counter = 0 for y in xrange(len(list2)): if list1[x+y] != list2[y]: break else: counter += 1 if counter == len(list2): return x return -1
for d in self.lib_dirs: sys.path.insert(0, os.path.join(root, d))
sys.path.append(root)
def configure(self, options, config): super(NoseGAE, self).configure(options, config) if not self.enabled: return self.config = config if options.gae_app is not None: self._path = options.gae_app else: self._path = config.workingDir if options.gae_lib_root is not None: root = self._gae_path = options.gae_lib_root for d...
warn("Google App Engine not found in %s" % options.gae_lib_root, RuntimeWarning)
raise
def configure(self, options, config): super(NoseGAE, self).configure(options, config) if not self.enabled: return self.config = config if options.gae_app is not None: self._path = options.gae_app else: self._path = config.workingDir if options.gae_lib_root is not None: root = self._gae_path = options.gae_lib_root for d...
try: self.cur.execute("UPDATE highscore SET score='"+str(score)+"' WHERE name='"+name+"'") except sqlite3.Error, e: print "Ooops:", e.args[0]
def update(self, name, score, font): player = [] i = 1 try: self.cur.execute('INSERT INTO highscore VALUES (null, ?, ?)', (name, score))
connection = sqlite.connect('test.db')
connection = sqlite3.connect('test.db')
def main(): pygame.init() try: w = 640 h = 480 screen = pygame.display.set_mode((w, h)) font = pygame.font.SysFont('Arial Black', 20) pygame.mouse.set_visible(False) clock = pygame.time.Clock() ch = CollisionHandler() TIMEEVENT = USEREVENT + 1 pygame.time.set_timer(TIMEEVENT, 15) # Load our balls balls = [ Ball(scre...
except sqlite.Error, e:
except sqlite3.Error, e:
def main(): pygame.init() try: w = 640 h = 480 screen = pygame.display.set_mode((w, h)) font = pygame.font.SysFont('Arial Black', 20) pygame.mouse.set_visible(False) clock = pygame.time.Clock() ch = CollisionHandler() TIMEEVENT = USEREVENT + 1 pygame.time.set_timer(TIMEEVENT, 15) # Load our balls balls = [ Ball(scre...
if str(user_agent).find(ua.keyword) != -1:
if unicode(user_agent).find(ua.keyword) != -1:
def process_request(self, request): # don't process AJAX requests if request.is_ajax(): return
visitor.save()
try: visitor.save() except DatabaseError: pass
def process_request(self, request): # don't process AJAX requests if request.is_ajax(): return
'R':[]
def cvecs( self ): """ Return centering vectors for this space group. """ typ = self.mydata['symb'][0] ##TODO: find vectors for B and test for A and C and R ##TODO: http://img.chem.ucl.ac.uk/sgp/large/146az1.htm vs = { 'A':[ Vec( 0, 0.5, 0.5 ) ], 'C':[ Vec( 0.5, 0.5, 0 ) ], 'B':[], ##TODO: <<< error 'F':[ Vec( 0, 0.5, ...
return vs[ typ ]
if typ in vs: return vs[ typ ] elif typ == 'R': if self.snum == 2: return [] elif self.snum == 1: return [ Vec( 2/3.0, 1/3.0, 1/3.0 ), Vec( 1/3.0, 2/3.0, 2/3.0 ) ]
def cvecs( self ): """ Return centering vectors for this space group. """ typ = self.mydata['symb'][0] ##TODO: find vectors for B and test for A and C and R ##TODO: http://img.chem.ucl.ac.uk/sgp/large/146az1.htm vs = { 'A':[ Vec( 0, 0.5, 0.5 ) ], 'C':[ Vec( 0.5, 0.5, 0 ) ], 'B':[], ##TODO: <<< error 'F':[ Vec( 0, 0.5, ...
("M21" , (1, 2, 3, 4, 5, 1)),
("M21" , (1, 0, 2, 3, 4, 1)),
def to_sort( self ): cond = ( ("K1" , (1, 1, 1, 1, 1, 1)), ("K3" , (1, 0, 1, 1, 0, 1)), ("K5" , (0, 0, 0, 1, 1, 1)), ("H4" , (0, 1, 0, 1, 2, 1)), ("Q1" , (1, 2, 1, 1, 2, 1)), ("Q2" , (1, 0, 1, 1, 2, 1)), ("Q5" , (0, 0, 0, 1, 2, 1)), ("R1" , (1, 1, 1, 2, 2, 2)), ("R3" , (1, 0, 1, 1, 0, 2)), ("O11" , (...
print ds
def testMakeDS(self): ds = dns.dnssec.make_ds(abs_dnspython_org, sep_key, 'SHA256') print ds self.failUnless(ds == good_ds)
if tok.get_string() != r'\
token = tok.get() if not token.is_identifier() or token.value != '\
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True): if tok.get_string() != r'\#': raise dns.exception.SyntaxError, \ r'generic rdata does not start with \#' length = tok.get_int() chunks = [] while 1: token = tok.get() if token.is_eol_or_eof(): break chunks.append(token.value) hex = ''.join(chun...
if token.is_identifier and \
if token.is_identifier() and \
def from_text(rdclass, rdtype, tok, origin = None, relativize = True): """Build an rdata object from text format. This function attempts to dynamically load a class which implements the specified rdata class and type. If there is no class-and-type-specific implementation, the GenericRdata class is used. Once a class...
hashes[dns.name.from_text('HMAC-MD5.SIG-ALG.REG.INT')] = md5.md5 hashes[dns.name.from_text('hmac-sha1')] = sha.sha
hashes[dns.name.from_text('HMAC-MD5.SIG-ALG.REG.INT')] = md5 hashes[dns.name.from_text('hmac-sha1')] = sha
def new(self, *args, **kwargs): return self.basehash(*args, **kwargs)
@param fudge: TSIG time fudge; default is 300 seconds.
@param fudge: TSIG time fudge
def add_tsig(self, keyname, secret, fudge, id, tsig_error, other_data, request_mac, algorithm=dns.tsig.default_algorithm): """Add a TSIG signature to the message.
if opt in ('-z', '--reset'): self.q_record, self.q_data = None, None
def ParseArgs(self, argv): opts, args = self.ParseWithCommonArgs(argv, OPT_FLAGS, OPT_ARGS)
bpy.ops.transform.resize(value=(1,1,-1), constraint_axis=(False, False, True), constraint_orientation='GLOBAL')
def export_char(outputFile, meshObj = None): '''Exports a mesh as a LoL .skn file. outputFile: Name of file to save the mesh as meshObj: Blender mesh object to export. If none is given we will look for one named 'lolMesh' ''' import bpy if meshObj == None: #If no mesh object was supplied, try the active selection ...
import_sco(self.filepath)
import_sco(self.properties.filepath)
def execute(self, context): import_sco(self.filepath) return {'FINISHED'}
group_licenses.append(licenses[license_id])
license = licenses[license_id] group_licenses.append(license.copy())
def license_cmp(x, y): return cmp(x['title'].lower(), y['title'].lower())
import urllib2 import simplejson
def get_names(self): from pylons import config import urllib2 import simplejson url = config.get('licenses_service_url', self.default_url) try: response = urllib2.urlopen(url) response_body = response.read() except Exception, inst: msg = "Couldn't connect to licenses service: %s" % inst raise Exception, msg try: licens...
license_names = simplejson.loads(response_body)
license_names = loads(response_body)
def get_names(self): from pylons import config import urllib2 import simplejson url = config.get('licenses_service_url', self.default_url) try: response = urllib2.urlopen(url) response_body = response.read() except Exception, inst: msg = "Couldn't connect to licenses service: %s" % inst raise Exception, msg try: licens...
pafser.add_option("-s", "--sensor", action="append", type="string",
parser.add_option("-s", "--sensor", action="append", type="string",
def main(): parser = OptionParser() parser.add_option("-i", "--input", dest="root", default="/lsst/DC3/data/obstest/ImSim", help="input root") parser.add_option("-o", "--output", dest="outRoot", default=".", help="output root") parser.add_option("-f", "--force", action="store_true", default=False, help="execute even if...
def isrProcess(f):
def isrProcess(f, doJobOffice=False):
def isrProcess(f): print >>f, """ appStage: { name: isrInputRaw parallelClass: lsst.pex.harness.IOStage.InputStageParallel eventTopic: None stagePolicy: { parameters: { butler: @PT1Pipe/butlerInput.paf inputItems: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): for snap in (0, 1): channelName = '...
eventTopic: None
eventTopic: """ + ("None" if doJobOffice else "jobIdentity") + """
def isrProcess(f): print >>f, """ appStage: { name: isrInputRaw parallelClass: lsst.pex.harness.IOStage.InputStageParallel eventTopic: None stagePolicy: { parameters: { butler: @PT1Pipe/butlerInput.paf inputItems: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): for snap in (0, 1): channelName = '...
outputKeys: { darkSubtractedExposure: isrExposure""" + channelSnap + """ }
def isrProcess(f): print >>f, """ appStage: { name: isrInputRaw parallelClass: lsst.pex.harness.IOStage.InputStageParallel eventTopic: None stagePolicy: { parameters: { butler: @PT1Pipe/butlerInput.paf inputItems: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): for snap in (0, 1): channelName = '...
exposure: isrExposure""" + channelSnap + """
exposureKey: isrExposure""" + channelSnap + """
def isrProcess(f): print >>f, """ appStage: { name: isrInputRaw parallelClass: lsst.pex.harness.IOStage.InputStageParallel eventTopic: None stagePolicy: { parameters: { butler: @PT1Pipe/butlerInput.paf inputItems: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): for snap in (0, 1): channelName = '...
inputKeys: { exposureList: exposureList""" + str(snap) + """ } outputKeys: { assembledCcdExposure: isrExposure""" + str(snap) + """
stagePolicy: { inputKeys: { exposureList: exposureList""" + str(snap) + """ } outputKeys: { assembledCcdExposure: isrExposure""" + str(snap) + """ }
def ccdAssemblyProcess(f): for snap in (0, 1): print >>f, """ appStage: { name: ccdAssemblyCcdList""" + str(snap) + """ parallelClass: lsst.datarel.ObjectListStageParallel eventTopic: None stagePolicy: { inputKeys: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): channelId = "%d%d" % (channelX, ch...
inputKeys: { ccdExposure: isrExposure""" + str(snap) + """ } outputKeys: { ccdExposure: isrExposure""" + str(snap) + """
stagePolicy: { inputKeys: { ccdExposure: isrExposure""" + str(snap) + """ } outputKeys: { defectMaskedCcdExposure: isrExposure""" + str(snap) + """ }
def ccdAssemblyProcess(f): for snap in (0, 1): print >>f, """ appStage: { name: ccdAssemblyCcdList""" + str(snap) + """ parallelClass: lsst.datarel.ObjectListStageParallel eventTopic: None stagePolicy: { inputKeys: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): channelId = "%d%d" % (channelX, ch...
inputKeys: { ccdExposure: isrExposure""" + str(snap) + """ } outputKeys: { sdqaCcdExposure: isrExposure""" + str(snap) + """
stagePolicy: { inputKeys: { ccdExposure: isrExposure""" + str(snap) + """ } outputKeys: { sdqaCcdExposure: isrExposure""" + str(snap) + """ }
def ccdAssemblyProcess(f): for snap in (0, 1): print >>f, """ appStage: { name: ccdAssemblyCcdList""" + str(snap) + """ parallelClass: lsst.datarel.ObjectListStageParallel eventTopic: None stagePolicy: { inputKeys: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): channelId = "%d%d" % (channelX, ch...
inputKeys: { exposureKey: isrExposure""" + str(snap) + """ } parameters: @PT1Pipe/ISR-sdqaCcd.paf outputKeys: { isrPersistableSdqaRatingVectorKey: sdqaRatingVector""" + str(snap) + """
stagePolicy: { inputKeys: { exposureKey: isrExposure""" + str(snap) + """ } parameters: @PT1Pipe/ISR-sdqaCcd.paf outputKeys: { isrPersistableSdqaRatingVectorKey: sdqaRatingVector""" + str(snap) + """ }
def ccdAssemblyProcess(f): for snap in (0, 1): print >>f, """ appStage: { name: ccdAssemblyCcdList""" + str(snap) + """ parallelClass: lsst.datarel.ObjectListStageParallel eventTopic: None stagePolicy: { inputKeys: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): channelId = "%d%d" % (channelX, ch...
parallelClass: lsst.meas.pipeline.WcsVerificationStageParallel
parallelClass: lsst.meas.pipeline.WcsVerificationParallel
def imgCharProcess(f): print >>f, """ appStage: { name: icSourceDetect parallelClass: lsst.meas.pipeline.SourceDetectionStageParallel eventTopic: None stagePolicy: { inputKeys: { exposure: visitExposure } outputKeys: { positiveDetection: positiveFootprintSet negativeDetection: negativeFootprintSet psf: simplePsf } psfP...
def createPolicy(f):
def createPolicy(f, doJobOffice=False):
def createPolicy(f): pipelinePolicy(f) jobStart(f) isrProcess(f) ccdAssemblyProcess(f) crSplitProcess(f) imgCharProcess(f) sfmProcess(f) jobFinish(f) print >>f, "}"
jobStart(f)
if doJobOffice: jobStart(f)
def createPolicy(f): pipelinePolicy(f) jobStart(f) isrProcess(f) ccdAssemblyProcess(f) crSplitProcess(f) imgCharProcess(f) sfmProcess(f) jobFinish(f) print >>f, "}"
jobFinish(f)
if doJobOffice: jobFinish(f)
def createPolicy(f): pipelinePolicy(f) jobStart(f) isrProcess(f) ccdAssemblyProcess(f) crSplitProcess(f) imgCharProcess(f) sfmProcess(f) jobFinish(f) print >>f, "}"
if len(sys.argv) > 1: with open(sys.argv[1], "w") as f: createPolicy(f)
parser = OptionParser() parser.add_option("-j", "--jobOffice", action="store_true", default=False, help="write JobOffice stages into the pipeline") options, args = parser.parse_args() if len(args) > 0: with open(args[0], "w") as f: createPolicy(f, options.jobOffice)
def main(): if len(sys.argv) > 1: with open(sys.argv[1], "w") as f: createPolicy(f) else: createPolicy(sys.stdout)
createPolicy(sys.stdout)
createPolicy(sys.stdout, options.jobOffice)
def main(): if len(sys.argv) > 1: with open(sys.argv[1], "w") as f: createPolicy(f) else: createPolicy(sys.stdout)
parser.add_option("-r", "--registry", help="registry")
parser.add_option("-R", "--registry", help="registry")
def cfhtMain(processFunction, outDatasetType, need=(), defaultRoot="."): parser = OptionParser() parser.add_option("-i", "--input", dest="root", default=defaultRoot, help="input root") parser.add_option("-o", "--output", dest="outRoot", default=".", help="output root") parser.add_option("-f", "--force", action="store_t...
parser.add_option("-r", "--registry", help="registry")
parser.add_option("-R", "--registry", help="registry")
def lsstSimMain(processFunction, outDatasetType, need=(), defaultRoot="."): parser = OptionParser() parser.add_option("-i", "--input", dest="root", default=defaultRoot, help="input root") parser.add_option("-o", "--output", dest="outRoot", default=".", help="output root") parser.add_option("-f", "--force", action="stor...
"***** Processing " + \
("***** Processing " + \
def lsstSimMain(processFunction, outDatasetType, need=(), defaultRoot="."): parser = OptionParser() parser.add_option("-i", "--input", dest="root", default=defaultRoot, help="input root") parser.add_option("-o", "--output", dest="outRoot", default=".", help="output root") parser.add_option("-f", "--force", action="stor...
"sensor %s channel %s" % \
"sensor %s channel %s") % \
def lsstSimMain(processFunction, outDatasetType, need=(), defaultRoot="."): parser = OptionParser() parser.add_option("-i", "--input", dest="root", default=defaultRoot, help="input root") parser.add_option("-o", "--output", dest="outRoot", default=".", help="output root") parser.add_option("-f", "--force", action="stor...
"***** Processing visit %d " + \ "snap %d raft %s sensor %s" % \
("***** Processing visit %d " + \ "snap %d raft %s sensor %s") % \
def lsstSimMain(processFunction, outDatasetType, need=(), defaultRoot="."): parser = OptionParser() parser.add_option("-i", "--input", dest="root", default=defaultRoot, help="input root") parser.add_option("-o", "--output", dest="outRoot", default=".", help="output root") parser.add_option("-f", "--force", action="stor...
"***** Processing visit %d " + \ "raft %s sensor %s channel %s" % \
("***** Processing visit %d " + \ "raft %s sensor %s channel %s") % \
def lsstSimMain(processFunction, outDatasetType, need=(), defaultRoot="."): parser = OptionParser() parser.add_option("-i", "--input", dest="root", default=defaultRoot, help="input root") parser.add_option("-o", "--output", dest="outRoot", default=".", help="output root") parser.add_option("-f", "--force", action="stor...
"***** Processing visit %d " + \ "raft %s sensor %s" % \
("***** Processing visit %d " + \ "raft %s sensor %s") % \
def lsstSimMain(processFunction, outDatasetType, need=(), defaultRoot="."): parser = OptionParser() parser.add_option("-i", "--input", dest="root", default=defaultRoot, help="input root") parser.add_option("-o", "--output", dest="outRoot", default=".", help="output root") parser.add_option("-f", "--force", action="stor...
clip = sfmPipe(calexp, psf)
clip = sfmPipe(calexp, psf, apCorr)
def sfmProcess(root=None, outRoot=None, registry=None, inButler=None, outButler=None, **keys): inButler, outButler = lsstSimSetup(root, outRoot, registry, None, inButler, outButler) calexp = inButler.get("calexp", **keys) psf = inButler.get("psf", **keys) apCorr = inButler.get("apCorr", **keys) clip = sfmPipe(calexp,...
def sfmPipe(calexp, psf):
def sfmPipe(calexp, psf, apCorr):
def sfmPipe(calexp, psf): clip = { 'scienceExposure': calexp, 'psf': psf } clip = runStage(measPipe.SourceDetectionStage, """#<?cfg paf policy?> inputKeys: { exposure: scienceExposure psf: psf } outputKeys: { positiveDetection: positiveFootprintSet } backgroundPolicy: { algorithm: NONE } """, clip) clip = runStage(me...
'psf': psf
'psf': psf, 'apCorr': apCorr
def sfmPipe(calexp, psf): clip = { 'scienceExposure': calexp, 'psf': psf } clip = runStage(measPipe.SourceDetectionStage, """#<?cfg paf policy?> inputKeys: { exposure: scienceExposure psf: psf } outputKeys: { positiveDetection: positiveFootprintSet } backgroundPolicy: { algorithm: NONE } """, clip) clip = runStage(me...
clip = runStage(measPipe.ComputeSourceSkyCoordsStage,
clip = runStage(measPipe.ApertureCorrectionApplyStage,
def sfmPipe(calexp, psf): clip = { 'scienceExposure': calexp, 'psf': psf } clip = runStage(measPipe.SourceDetectionStage, """#<?cfg paf policy?> inputKeys: { exposure: scienceExposure psf: psf } outputKeys: { positiveDetection: positiveFootprintSet } backgroundPolicy: { algorithm: NONE } """, clip) clip = runStage(me...