rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
lock = lambda: SemLock(lock_file, self.conf['concurrent_requests']) | lock = lambda: SemLock(lock_file, concurrent_requests) | def source(self, context, params=None): if not context.seed and self.conf.get('seed_only'): return DummySource() if params is None: params = {} request_format = self.conf['req'].get('format') if request_format: params['format'] = request_format transparent = self.conf['req'].get('transparent', 'false') transparent =... |
bbox, geom = load_polygons(poly_file) | bbox, geom = load_polygons(view_conf['polygons']) | def seed_from_yaml_conf(conf_file, verbose=True, rebuild_inplace=True, dry_run=False, concurrency=2): from mapproxy.core.conf_loader import load_services if hasattr(conf_file, 'read'): seed_conf = yaml.load(conf_file) else: with open(conf_file) as conf_file: seed_conf = yaml.load(conf_file) services = load_services()... |
assert validate_with_dtd(xml, dtd_name='wms/1.1.1/WMS_MS_CAPABILITIES.dtd') | assert validate_with_dtd(xml, dtd_name='wms/1.1.1/WMS_MS_Capabilities.dtd') | def test_wms_capabilities(self): req = WMS111CapabilitiesRequest(url='/service?').copy_with_request_params(self.common_req) resp = self.app.get(req) eq_(resp.content_type, 'application/vnd.ogc.wms_xml') xml = resp.lxml eq_(xml.xpath('//GetMap//OnlineResource/@xlink:href', namespaces=dict(xlink="http://www.w3.org/1999/x... |
meta_buffer = context.globals.get_value('meta_buffer', self.conf) meta_size = context.globals.get_value('meta_size', self.conf) | meta_buffer = context.globals.get_value('meta_buffer', self.conf, global_key='grid.meta_buffer') meta_size = context.globals.get_value('meta_size', self.conf, global_key='grid.meta_size') | def caches(self, context): request_format = self.conf.get('request_format') or self.conf['format'] caches = [] |
print base_config().cache.base_dir | def run(self): print base_config().cache.base_dir while True: tiles, progress = self.tiles_queue.get() if tiles is None: return print '[%s] %6.2f%% %s \tETA: %s\r' % ( timestamp(), progress[1]*100, progress[0], progress[2] ), sys.stdout.flush() if not self.dry_run: exp_backoff(self.tile_mgr.load_tile_coords, args=(tile... | |
print base_config().cache.base_dir | def __init__(self, tile_mgr, task, seed_pool, skip_geoms_for_last_levels=0): self.tile_mgr = tile_mgr self.task = task self.seed_pool = seed_pool self.skip_geoms_for_last_levels = skip_geoms_for_last_levels num_seed_levels = task.max_level - task.start_level + 1 self.report_till_level = task.start_level + int(num_seed... | |
','.join(request.params.layers), request=request) | ','.join(map_request.params.layers), request=map_request) | def render(self, map_request): params = map_request.params req_bbox = params.bbox size = params.size req_srs = SRS(params.srs) bbox, level = self.cache.grid.get_affected_bbox_and_level(req_bbox, size, req_srs) if level >= self.direct_from_level: for client in self.direct_clients: try: yield client.get_map(map_request)... |
tile = _Tile(tile) | tile = Tile(tile) | def is_cached(self, tile): """ Return True if the tile is cached. """ if isinstance(tile, tuple): tile = _Tile(tile) max_mtime = self.expire_timestamp(tile) cached = self.cache.is_cached(tile) if cached and max_mtime is not None: stale = self.cache.timestamp_created(tile) < max_mtime if stale: cached = False return cac... |
(minx, miny, maxx, maxy)) | (minx, miny, maxx, maxy), image_filter[self.resampling]) | def _transform_simple(self, src_img, src_bbox, dst_size, dst_bbox): """ Do a simple crop transformation. """ src_quad = (0, 0, src_img.size[0], src_img.size[1]) to_src_px = make_lin_transf(src_bbox, src_quad) minx, miny = to_src_px((dst_bbox[0], dst_bbox[3])) maxx, maxy = to_src_px((dst_bbox[2], dst_bbox[1])) result = ... |
parts = [] for c in self.clients: parts.append(c.request_template.url) parts.append(c.request_template.params.layer) self.identifier = ''.join(parts) | self.identifier = legend_identifier( [(c.request_template.url, c.request_template.params.layer) for c in self.clients]) | def __init__(self, clients, legend_cache): self.clients = clients parts = [] for c in self.clients: parts.append(c.request_template.url) parts.append(c.request_template.params.layer) self.identifier = ''.join(parts) self._cache = legend_cache self._size = None |
class ProjError(RuntimeError): pass class ProjInitError(ProjError): pass | def finder(self, name): if self.path is None: return None if name in self.path: result = self.path[name] else: sysname = os.path.join(self.path, name) result = self.finder_results[name] = create_string_buffer(sysname) return addressof(result) | |
return validate_with_dtd(xml, dtd_name='wms/1.1.1/WMS_MS_CAPABILITIES.dtd') | return validate_with_dtd(xml, dtd_name='wms/1.1.1/WMS_MS_Capabilities.dtd') | def is_111_capa(xml): return validate_with_dtd(xml, dtd_name='wms/1.1.1/WMS_MS_CAPABILITIES.dtd') |
link_single_color_images): | link_single_color_images=False): | def __init__(self, cache_dir, file_ext, pre_store_filter=None, link_single_color_images): """ :param cache_dir: the path where the tile will be stored :param file_ext: the file extension that will be appended to each tile (e.g. 'png') :param pre_store_filter: a list with filter. each filter will be called with a tile b... |
optional_keys = set('''type supported_srs supported_formats request_format image use_direct_from_level wms_opts http concurrent_requests'''.split()) | optional_keys = set('''type supported_srs supported_formats image wms_opts http concurrent_requests'''.split()) | def load(cls, **kw): source_type = kw['type'] for subclass in cls.__subclasses__(): if source_type in subclass.source_type: return subclass(**kw) raise ValueError("unknown source type '%s'" % source_type) |
def __init__(self, cache, size=4): | def __init__(self, cache, size=8, dry_run=False): | def __init__(self, cache, size=4): self.tiles_queue = multiprocessing.Queue(16) self.cache = cache self.procs = [] for _ in xrange(size): worker = SeedWorker(cache, self.tiles_queue) worker.start() self.procs.append(worker) |
worker = SeedWorker(cache, self.tiles_queue) | worker = SeedWorker(cache, self.tiles_queue, dry_run=dry_run) | def __init__(self, cache, size=4): self.tiles_queue = multiprocessing.Queue(16) self.cache = cache self.procs = [] for _ in xrange(size): worker = SeedWorker(cache, self.tiles_queue) worker.start() self.procs.append(worker) |
def __init__(self, cache, tiles_queue): | def __init__(self, cache, tiles_queue, dry_run=False): | def __init__(self, cache, tiles_queue): multiprocessing.Process.__init__(self) self.cache = cache self.tiles_queue = tiles_queue |
print seed_id load_tiles = lambda: self.cache.cache_mgr.load_tile_coords(tiles) exp_backoff(load_tiles, exceptions=(TileSourceError, IOError)) | print '[%s] %s\r' % (timestamp(), seed_id), sys.stdout.flush() time.sleep(0.1) if not self.dry_run: load_tiles = lambda: self.cache.cache_mgr.load_tile_coords(tiles) exp_backoff(load_tiles, exceptions=(TileSourceError, IOError)) | def run(self): while True: seed_id, tiles = self.tiles_queue.get() if tiles is None: return print seed_id load_tiles = lambda: self.cache.cache_mgr.load_tile_coords(tiles) exp_backoff(load_tiles, exceptions=(TileSourceError, IOError)) |
seed_pool = SeedPool(cache) | seed_pool = SeedPool(cache, dry_run=self.dry_run) num_seed_levels = level[1] - level[0] + 1 report_till_level = level[0] + int(num_seed_levels * 0.8) print level, num_seed_levels, report_till_level | def _seed_location(self, cache, bbox, level, srs): if cache.grid.srs != srs: bbox = srs.transform_bbox_to(cache.grid.srs, bbox) print cache if self.remove_before: cache.cache_mgr.expire_timestamp = lambda tile: self.remove_before seed_pool = SeedPool(cache) grid = cache.grid status = list('.oO0') def _seed(cur_bbox, ... |
bbox, tiles, subtiles = grid.get_affected_level_tiles(cur_bbox, level) | bbox_, tiles_, subtiles = grid.get_affected_level_tiles(cur_bbox, level) | def _seed(cur_bbox, level, max_level, id=''): bbox, tiles, subtiles = grid.get_affected_level_tiles(cur_bbox, level) subtiles = list(subtiles) if level < max_level: for i, subtile in enumerate(subtiles): if subtile is None: continue sub_bbox = grid.tile_bbox(subtile) if bbox_intersects(sub_bbox, bbox): seed_id = id + (... |
seed_id = id + (status[i] if i <=3 else 'x') | seed_id = id + (status[i] if i <=3 else str(i)) | def _seed(cur_bbox, level, max_level, id=''): bbox, tiles, subtiles = grid.get_affected_level_tiles(cur_bbox, level) subtiles = list(subtiles) if level < max_level: for i, subtile in enumerate(subtiles): if subtile is None: continue sub_bbox = grid.tile_bbox(subtile) if bbox_intersects(sub_bbox, bbox): seed_id = id + (... |
def _seed_tiles(self, cache, tiles): if not self.dry_run: cache.cache_mgr.load_tile_coords(tiles) | def _seed_tiles(self, cache, tiles): if not self.dry_run: cache.cache_mgr.load_tile_coords(tiles) | |
def timestamp(): return datetime.datetime.now().strftime('%H:%M:%S') def format_bbox(bbox): return ('(%.5f, %.5f, %.5f, %.5f)') % bbox | def file_handler(filename): self.progress.print_msg('removing ' + filename) | |
rms1 = rms(rec['wv_500_1000_50'], wv[500:1000:50]) rms2 = rms(rec['wv_1500_2000_50'], wv[1500:2000:50]) self.assertEqual(True, rms1 < 1e-3) self.assertEqual(True, rms2 < 1e-3) | rms1 = rms(rec['wv_250_500_25'], wv[250:500:25]) rms2 = rms(rec['wv_750_1000_25'], wv[750:1000:25]) self.assertEqual(True, rms1 < 1e-6) self.assertEqual(True, rms2 < 1e-6) | def test_wignerVille(self): """ Test for wigner_ville_spectrum. Test uses only a fraction of the whole spectrum due to space consumtions. """ datafile = os.path.join(os.path.dirname(__file__), 'data', 'wv.npz') rec = np.load(datafile) wv = abs(wigner_ville_spectrum(signal_bursts(), 10, 3.5, smoothing_filter='gauss', ve... |
value = np.sqrt( (x**2 - y**2).mean() / (x**2).mean() ) if np.isnan(value): return 0.0 return value | return np.sqrt( ((x - y)**2).mean() / (x**2).mean() ) | def rms(x, y): """Normalized RMS""" value = np.sqrt( (x**2 - y**2).mean() / (x**2).mean() ) if np.isnan(value): return 0.0 return value |
pass | library_dirs = [] | def __init__(self, *args, **kwargs): Extension.__init__(self, *args, **kwargs) self.export_symbols = finallist(self.export_symbols) |
gp_src = os.path.join('mtspec', 'src', 'gplot', 'src') + os.sep | def __init__(self, *args, **kwargs): Extension.__init__(self, *args, **kwargs) self.export_symbols = finallist(self.export_symbols) | |
MSVCCompiler._c_extensions.append(".f90") def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): if output_dir: try: os.makedirs(output_dir) except OSError: pass objects = [] for src in sources: file, ext = os.path.splitext(src) if ou... | def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): compiler_so = self.compiler_so if sys.platform == 'darwin': compiler_so = _darwin_compiler_fixup(compiler_so, cc_args + extra_postargs) if ext == ".f90": if sys.platform == 'darwin' or sys.platform == 'linux2': compiler_so = ["gfortran"] cc_args = ["-... | |
author='Lion Krischer, Moritz Beyreuther, German A. Prieto' | author='Lion Krischer, Moritz Beyreuther, German A. Prieto', | def __init__(self, *args, **kwargs): Extension.__init__(self, *args, **kwargs) self.export_symbols = finallist(self.export_symbols) |
cc_args = ["-O", "-c", "-ffree-form"] | cc_args = ["-c"] | def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): if output_dir: try: os.makedirs(output_dir) except OSError: pass objects = [] for src in sources: file, ext = os.path.splitext(src) if output_dir: obj = os.path.join(output_dir, o... |
macros = [] extra_link_args = [] extra_compile_args = [] library_dirs = [] | def __init__(self, *args, **kwargs): Extension.__init__(self, *args, **kwargs) self.export_symbols = finallist(self.export_symbols) | |
src + 'qi_nsqi2.f90', src + 'qi_nsqi3.f90', | src + 'qi_nsqi2.f90', src + 'qi_nsqi3.f90'], | def __init__(self, *args, **kwargs): Extension.__init__(self, *args, **kwargs) self.export_symbols = finallist(self.export_symbols) |
src = os.path.join('src', 'mtspec', 'src') + os.sep gp_src = os.path.join('src', 'gplot', 'src') + os.sep sp_src = os.path.join('src', 'splines', 'src') + os.sep | src = os.path.join('mtspec', 'src', 'mtspec', 'src') + os.sep gp_src = os.path.join('mtspec', 'src', 'gplot', 'src') + os.sep sp_src = os.path.join('mtspec', 'src', 'splines', 'src') + os.sep | #def has_fortran(self): |
long_description="""Python (ctypes) Bindings for multitaper mtspec f90 Library | long_description="""Python Bindings for multitaper Library | #def has_fortran(self): |
ext_package='lib', | ext_package='mtspec.lib', | #def has_fortran(self): |
def test_multitaperSpectrum(self): """ Test for mtspec. The result is compared to the output of test_recreatePaperFigures.py in the same directory. This is assumed to be correct because they are identical to the figures in the paper on the machine that created these. """ data = load_mtdata('PASC.dat.gz') spec, freq = ... | def test_multitaperSpectrum(self): """ Test for mtspec. The result is compared to the output of test_recreatePaperFigures.py in the same directory. This is assumed to be correct because they are identical to the figures in the paper on the machine that created these. """ data = load_mtdata('PASC.dat.gz') # Calculate th... | |
self.logger('uiready(%s)' % ui) | self.logger('on_uiready(%s)' % ui) def on_closed(self): self.logger('on_closed()') def on_terminate(self): self.logger('on_terminate()') | def on_uiready(self, ui): self.logger('uiready(%s)' % ui) |
token = md5(self.password + timestamp) | if self.password and self.username: token = md5(self.password + timestamp) elif self.network.api_key and self.network.api_secret and self.network.session_key: if not self.username: self.username = self.network.get_authenticated_user().get_name() token = md5(self.network.api_secret + timestamp) | def _do_handshake(self): """Handshakes with the server""" timestamp = str(int(time.time())) token = md5(self.password + timestamp) params = {"hs": "true", "p": "1.2.1", "c": self.client_id, "v": self.client_version, "u": self.username, "t": timestamp, "a": token} server = self.network.submission_server response = _S... |
"a": token} | "a": token, "sk": self.network.session_key, "api_key": self.network.api_key} | def _do_handshake(self): """Handshakes with the server""" timestamp = str(int(time.time())) token = md5(self.password + timestamp) params = {"hs": "true", "p": "1.2.1", "c": self.client_id, "v": self.client_version, "u": self.username, "t": timestamp, "a": token} server = self.network.submission_server response = _S... |
tracks = [] for track in _collect_nodes(limit, self, "user.getLovedTracks", False): title = _extract(track, 'name', 0) artist = _extract(track, 'name', 1) tracks.append(Track(artist, title, self.network)) return tracks def get_neighbours(self, limit = 50): """Returns a list of the user's friends.""" | def get_loved_tracks(self, limit=50): """Returns the loved tracks by this user if limit is None, it will return all of them """ tracks = [] for track in _collect_nodes(limit, self, "user.getLovedTracks", False): title = _extract(track, 'name', 0) artist = _extract(track, 'name', 1) tracks.append(Track(artist, title, ... | |
def get_recent_tracks(self, limit = None): """Returns this user's recent listened-to tracks as a sequence of PlayedTrack objects. | def get_recent_tracks(self, limit = 10): """Returns this user's played track as a sequence of PlayedTrack objects in reverse order of their playtime, all the way back to the first track. If limit==None, it will try to pull all the available data. This method uses caching. Enable caching only if you're pulling a large... | def get_recent_tracks(self, limit = None): """Returns this user's recent listened-to tracks as a sequence of PlayedTrack objects. Use extract_items() with the return of this function to get only a sequence of Track objects with no playback dates. """ params = self._get_params() if limit: params['limit'] = _unicode(lim... |
doc = self._request('user.getRecentTracks', False, params) seq = [] for track in doc.getElementsByTagName('track'): | seq = [] for track in _collect_nodes(limit, self, "user.getRecentTracks", True, params): if track.hasAttribute('nowplaying'): continue | def get_recent_tracks(self, limit = None): """Returns this user's recent listened-to tracks as a sequence of PlayedTrack objects. Use extract_items() with the return of this function to get only a sequence of Track objects with no playback dates. """ params = self._get_params() if limit: params['limit'] = _unicode(lim... |
if track.hasAttribute('nowplaying'): continue | def get_recent_tracks(self, limit = None): """Returns this user's recent listened-to tracks as a sequence of PlayedTrack objects. Use extract_items() with the return of this function to get only a sequence of Track objects with no playback dates. """ params = self._get_params() if limit: params['limit'] = _unicode(lim... | |
seq.append(i.get_item()) | seq.append(i.item) | def extract_items(topitems_or_libraryitems): """Extracts a sequence of items from a sequence of TopItem or LibraryItem objects.""" seq = [] for i in topitems_or_libraryitems: seq.append(i.get_item()) return seq |
def get_id(self): """Returns the user id.""" doc = self._request("user.getInfo", True) return _extract(doc, "id") def get_cover_image(self): """Returns the user's avatar.""" doc = self._request("user.getInfo", True) return _extract(doc, "image") def get_language(self): """Returns the language code of the language... | def get_name(self): """Returns the name of the authenticated user.""" doc = self._request("user.getInfo", True, {"user": ""}) # hack self.name = _extract(doc, "name") return self.name | |
"a": token, "sk": self.network.session_key, "api_key": self.network.api_key} | "a": token} if self.network.session_key and self.network.api_key: params["sk"] = self.network.session_key params["api_key"] = self.network.api_key | def _do_handshake(self): """Handshakes with the server""" timestamp = str(int(time.time())) if self.password and self.username: token = md5(self.password + timestamp) elif self.network.api_key and self.network.api_secret and self.network.session_key: if not self.username: self.username = self.network.get_authenticate... |
history_of_best.sort() | history_of_best.sort(key = lambda x: -x) | def addSubset(subset): if not subset in existing_subsets: r = getSubsetResultDict(algo_key, data, attributes, subset) results.append(r) existing_subsets.append(subset) results.sort(key = lambda x: -x['score']) best_score = results[0]['score'] |
if not len(sys.argv) < 3: | if len(sys.argv) < 3: | def addSplit(split_vector): if not split_vector in existing_splits: results.append(getScoreDict(split_vector)) existing_splits.append(split_vector) |
else: raise ValueError("Either a serial port or an XBee must be provided to construct a Dispatch") | def __init__(self, ser=None, xbee=None): if xbee: self.xbee = xbee elif ser: self.xbee = XBee(ser) else: raise ValueError("Either a serial port or an XBee must be provided to construct a Dispatch") self.handlers = [] | |
Packages the given binary data in an API frame and _writes the | Packages the given binary data in an API frame and writes the | def _write(self, data): """ _write: binary data -> None Packages the given binary data in an API frame and _writes the result to the serial port """ self.serial._write(APIFrame(data).output()) |
self.serial._write(APIFrame(data).output()) | self.serial.write(APIFrame(data).output()) | def _write(self, data): """ _write: binary data -> None Packages the given binary data in an API frame and _writes the result to the serial port """ self.serial._write(APIFrame(data).output()) |
def callback(name, data): self.count += 1 | def test_callback_not_called_when_filter_not_satisfied(self): """ After registerring a callback function with a filter function, the callback should not be called if a packet which does not satisfy the callback's filter arrives. """ self.dispatch.register("test1", self.callback_check.call, lambda data: False) self.disp... | def callback(name, data): self.count += 1 |
self.dispatch.register("test1", callback, lambda data: True) | def callback(name, data): self.count += 1 | |
self.assertEqual(self.count, 1) | for callback in callbacks: if not callback.called: self.fail("All callback methods should be called") | def callback(name, data): self.count += 1 |
xbee = XBee(ser, callback=dispatch.dispatch) | try: dispatch.run() except KeyboardInterrupt: pass | def io_sample_handler(name, packet): print "Samples Received: ", packet['samples'] |
while True: try: time.sleep(.1) except KeyboardInterrupt: break xbee.halt() | def io_sample_handler(name, packet): print "Samples Received: ", packet['samples'] | |
'CefWindowHandle' : 'cef_window_handle_t' | 'CefWindowHandle' : 'cef_window_handle_t', 'CefRect' : 'cef_rect_t', | def _get_basic(self, value): # check for string values if value == "std::wstring": return { 'result_type' : 'string', 'result_value' : None } # check for simple direct translations structuretypes = { 'CefPrintInfo' : 'cef_print_info_t', 'CefWindowInfo' : 'cef_window_info_t' } if value in structuretypes.keys(): return ... |
if line.startswith("["): | if line.startswith("Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id="): bug = line[53:] elif line.startswith("["): | def parseLogLine(logInfo): mapping = { "e": "editorial", "a": "authors", "c": "conformance-checkers", "g": "gecko", "i": "internet-explorer", "o": "opera", "w": "webkit", "r": "google-gears", "t": "tools", "0": "draft-content", "1": "stable-draft", "2": "implemented", "3": "stable" } changes = [] classes = [] for line ... |
return {"changes": changes, "classes": classes} | return {"changes": changes, "classes": classes, "bug": bug} | def parseLogLine(logInfo): mapping = { "e": "editorial", "a": "authors", "c": "conformance-checkers", "g": "gecko", "i": "internet-explorer", "o": "opera", "w": "webkit", "r": "google-gears", "t": "tools", "0": "draft-content", "1": "stable-draft", "2": "implemented", "3": "stable" } changes = [] classes = [] for line ... |
"date": date | "date": date, "bug" : bug | def getRevisionData(revision): revInfo = revision["info"] # This is the info line for a revision revChanges = parseLogLine(revision["changes"]) # Changes for the revision iconClasses = ["authors", "conformance-checkers", "gecko", "internet-explorer", "opera", "webkit", "google-gears", "tools"] titleClasses = ["editori... |
<html lang="en"> | <html lang=en> | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
<meta name="robots" content="index, nofollow"> | <meta name=robots content="index, nofollow"> | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
<link rel=icon href="http://www.whatwg.org/images/icon"> | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 | |
form[hidden] { display:none } except: revTo = 0 | form[hidden] { display:none } | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
form p { margin:0 } | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 | |
table table table | table { border-collapse:collapse } table td { padding:.1em .5em } table td:last-child { white-space:nowrap } | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
.draft-content { background-color: .stable-draft { background-color: .implemented { background-color: .stable { background-color: body .editorial { color:gray; } :link { background-color:transparent; color: :visited { background-color:transparent; color: img { border-style:none; vertical-align:middle; } td :link { co... | .draft-content { background-color: .stable-draft { background-color: .implemented { background-color: .stable { background-color: body .editorial { color:gray } :link { background:transparent; color: :visited { background:transparent; color: img { border:0; vertical-align:middle } td :link { color:inherit } td a { te... | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
function createCookie(name,value,days) { var expires = "" if(days) { var date = new Date() date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)) expires = "; expires=" + date.toGMTString() } document.cookie = "%s"+name+"="+value+expires+"; path=/" | function setCookie(name,value) { localStorage["tracker-" + "%s"] = value } function readCookie(name) { return localStorage["tracker-" + "%s"] } function setFieldValue(idName, n) { document.getElementById(idName).value = n } function getFieldValue(idName) { return document.getElementById(idName).value } function setFrom... | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
function readCookie(name) { name = "%s"+name+"=" var ca = document.cookie.split(';') for(var i=0; i < ca.length; i++) { var c = ca[i] while(c.charAt(0)==' ') c = c.substring(1,c.length) if(c.indexOf(name) == 0) return c.substring(name.length,c.length) } return null; } function getFieldValue(idName) { return document.ge... | function showEdits() { return document.getElementById("editorial").checked } function updateEditorial() { var editorial = showEdits() ? "" : "editorial" setCookie("editorial", editorial) document.body.className = editorial | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
<input type="submit" value="Generate diff"> | <input type=submit value="Generate diff"> | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
<form%s> | <form> | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
<!-- <p>Affects: <label><input type=checkbox name=affects_authors checked> <img src="icons/authors" alt=""> Authors</label> <label><input type=checkbox name=affects_conformance-checkers checked> <img src="icons/conformance-checkers" alt=""> Validators</label> <label><input type=checkbox name=affects_gecko checked> <img... | <label class="editorial">Show editorial changes <input type="checkbox" id="editorial" checked="" onchange="updateEditorial()"></label> | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
if(getFieldValue('from') == "" && readCookie('from') != null) setFrom(readCookie('from')) | if(getFieldValue("from") == "" && readCookie("from") != null) setFrom(readCookie("from")) if(readCookie("editorial") == "editorial") { document.getElementById("editorial").checked = false updateEditorial() } | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
print document % (title, identifier, identifier, title, "", "", "", formattedLog) | print document % (title, identifier, identifier, title, "", "", formattedLog) | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
print document % (title, identifier, identifier, title, revFrom, revTo, " hidden", result) | print document % (title, identifier, identifier, title, revFrom, revTo, result) | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
print document % (title, identifier, identifier, title, revFrom, "", " hidden", "No result.") | print document % (title, identifier, identifier, title, revFrom, "", "No result.") | def startFormatting(title, identifier, source): document = """Content-Type:text/html;charset=UTF-8 |
def z_slab(self, lowerMargin=0, upperMargin=0): | def z_slab(self, bottom, top, allTimes=True): | def z_slab(self, lowerMargin=0, upperMargin=0): """remove all trajectories that are not in the slab defined by lowerMargin and upperMargin""" m = np.amin(self.positions[:,:,-1], axis=1)+lowerMargin M = np.amax(self.positions[:,:,-1], axis=1)-upperMargin self.positions = self.positions[ :, np.bitwise_and( np.amin(self.p... |
defined by lowerMargin and upperMargin""" m = np.amin(self.positions[:,:,-1], axis=1)+lowerMargin M = np.amax(self.positions[:,:,-1], axis=1)-upperMargin self.positions = self.positions[ :, np.bitwise_and( np.amin(self.positions[:,:,-1].T>m, axis=1), np.amin(self.positions[:,:,-1].T<M, axis=1) ) ] | defined by [bottom, top]""" if allTimes: selection = np.unique1d(np.where( np.bitwise_and( self.positions[:,:,-1]>180, self.positions[:,:,-1]<280 ))[1]) else: selection = np.unique1d(np.where( np.bitwise_and( self.positions[:,:,-1].max(axis=0)>180, self.positions[:,:,-1].min(axis=0)<280 ))) self.trajs = self.trajs[sele... | def z_slab(self, lowerMargin=0, upperMargin=0): """remove all trajectories that are not in the slab defined by lowerMargin and upperMargin""" m = np.amin(self.positions[:,:,-1], axis=1)+lowerMargin M = np.amax(self.positions[:,:,-1], axis=1)-upperMargin self.positions = self.positions[ :, np.bitwise_and( np.amin(self.p... |
def time_correlation(self, postfix='',ext='dat', col=0): | def time_correlation(self, postfix='',ext='dat', col=0, av=10): | def time_correlation(self, postfix='',ext='dat', col=0): """read the particle-wise scalar from a time serie of files and compute the time correlation""" data = np.zeros_like(self.trajs, dtype=float) for t, fname in enum(self.xp): data[:,t] = np.readtxt(fname, usecols=[col])[trajs[:,t]] c=zeros_like(data) for p in range... |
data = np.zeros_like(self.trajs, dtype=float) for t, fname in enum(self.xp): data[:,t] = np.readtxt(fname, usecols=[col])[trajs[:,t]] c=zeros_like(data) for p in range(len(data)): c[p] = np.correlate(data[p],data[p],mode='full')[traj.shape[1]-1:] ret = c.mean(axis=1) ret /= ret[0] return ret | data = np.zeros((self.trajs.shape[1], self.trajs.shape[0])) for t, fname in enum(self.xp, postfix=postfix, ext=ext): data[t] = np.loadtxt(fname, usecols=[col])[self.trajs[:,t]] c=np.zeros((data.shape[0]-av+1)) if av==0: for t0, a in enumerate(data): for dt, b in enumerate(data[t0:]): c[dt] += (b*a).mean() for dt, n in... | def time_correlation(self, postfix='',ext='dat', col=0): """read the particle-wise scalar from a time serie of files and compute the time correlation""" data = np.zeros_like(self.trajs, dtype=float) for t, fname in enum(self.xp): data[:,t] = np.readtxt(fname, usecols=[col])[trajs[:,t]] c=zeros_like(data) for p in range... |
def voroVolume(fname): | def volume(fname): | def voroVolume(fname): """Use voro++ to output to disk the volume of the voronoi cell of each particle in file.vol""" outName = splitext(fname)[0] with open(fname) as f: f.readline() bb = [float(x)-6 for x in f.readline()[:-1].split()] with open(outName, 'w') as out: for i, p in enumerate(f): out.write('%i %s' % (i, p)... |
bb = [float(x)-6 for x in f.readline()[:-1].split()] | bb = [float(x)-5 for x in f.readline()[:-1].split()] | def voroVolume(fname): """Use voro++ to output to disk the volume of the voronoi cell of each particle in file.vol""" outName = splitext(fname)[0] with open(fname) as f: f.readline() bb = [float(x)-6 for x in f.readline()[:-1].split()] with open(outName, 'w') as out: for i, p in enumerate(f): out.write('%i %s' % (i, p)... |
'voro++ -c "%i %v" '+('10 6 %f 6 %f 6 %f' % tuple(bb)) | 'voro++ -c "%i %v" '+('10 5 %g 5 %g 5 %g' % tuple(bb)) | def voroVolume(fname): """Use voro++ to output to disk the volume of the voronoi cell of each particle in file.vol""" outName = splitext(fname)[0] with open(fname) as f: f.readline() bb = [float(x)-6 for x in f.readline()[:-1].split()] with open(outName, 'w') as out: for i, p in enumerate(f): out.write('%i %s' % (i, p)... |
np.savetxt(outName+'.vol', vol, fmt='%f') | np.savetxt(outName+'.vol', vol, fmt='%g') | def voroVolume(fname): """Use voro++ to output to disk the volume of the voronoi cell of each particle in file.vol""" outName = splitext(fname)[0] with open(fname) as f: f.readline() bb = [float(x)-6 for x in f.readline()[:-1].split()] with open(outName, 'w') as out: for i, p in enumerate(f): out.write('%i %s' % (i, p)... |
np.amin(tx.positions[:,:,-1].T>m, axis=1), np.amin(tx.positions[:,:,-1].T<M, axis=1) | np.amin(self.positions[:,:,-1].T>m, axis=1), np.amin(self.positions[:,:,-1].T<M, axis=1) | def z_slab(self, lowerMargin=0, upperMargin=0): """remove all trajectories that are not in the slab defined by lowerMargin and upperMargin""" m = np.amin(self.positions[:,:,-1], axis=1)+lowerMargin M = np.amax(self.positions[:,:,-1], axis=1)-upperMargin self.positions = self.positions[ :, np.bitwise_and( np.amin(tx.pos... |
lngb = np.loadtxt(self.get_format_string(ext='lngb')%t) | lngb = np.loadtxt(self.get_format_string('_post', ext='lngb')%t) | def lost_ngb_profile(self, t, Nbins=50, vf=False): """output the lost neighbour profile. Default unit is pixel^-3, or volume fraction""" lngb = np.loadtxt(self.get_format_string(ext='lngb')%t) pos = np.loadtxt(self.get_format_string()%t, skiprows=2) H, xedges, yedges = np.histogram2d(pos[:,-1], lngb, bins=[Nbins,2]) H ... |
def br(radius, T=28, eta28C=2.00139e-3, detadT=-0.03): | def br(radius, T=28, eta28C=2.00139e-3, detadT=-0.03e-3): | def br(radius, T=28, eta28C=2.00139e-3, detadT=-0.03): """Brownian time is the time for a particle to diffuse over it\'s own radius (in meters)""" return const.pi * (eta28C+(T-28)*detadT) * (radius**3) / (const.k * const.C2K(T)) |
['linkboo', self.get_format_string(absPath=False)%0, self.token, self.dt, self.offset,self.size]) | ['linkboo', self.get_format_string(absPath=False)%0, self.token, self.dt,self.size, self.offset]) | def linkboo(self): """calculate total g(r), radius, BOO for each time step and link trajectories.""" actual = os.getcwd() os.chdir(self.path) subprocess.check_call(map(str, ['linkboo', self.get_format_string(absPath=False)%0, self.token, self.dt, self.offset,self.size]) ) os.chdir(actual) |
for t,name in enum(self): | for t,name in self.enum(): | def mean_Nb(self): """Calculate the time averaged number of particles in a frame""" if not hasattr(self,'__mean_Nb'): nb = 0L for t,name in enum(self): with open(name,'r') as f: nb += int(re.split("\t",f.readline())[1]) self.__mean_Nb = float(nb) / self.size return self.__mean_Nb |
for t,name in enum(self): | for t,name in self.enum(): | def mean_V(self): """Calculate the time averaged volume""" if not hasattr(self,'__mean_V'): V=0 for t,name in enum(self): V += np.ptp( np.loadtxt(name, delimiter='\t', skiprows=2), axis=0).prod() self.__mean_V = V / self.size return self.__mean_V |
name = os.path.join(self.path, self.head + '_total.rdf') | name = os.path.join(self.path, self.head + '.rdf') | def rdf_radius(self,force=False): """Return the place of the largest (first) peak of the g(r), in pixel unit""" name = os.path.join(self.path, self.head + '_total.rdf') if force or not os.path.exists(name): subprocess.check_call(map(str, ['totalRdf',self.get_format_string()%0, self.token, 200, 15]) ) r,g = np.loadtxt(n... |
for t,fname in enum(self): | for t,fname in self.enum(): | def get_Nb_density(self, averaged=True): nbs = np.empty((self.size)) Vs = np.empty((self.size)) for t,fname in enum(self): coords = np.loadtxt(fname,delimiter='\t', skiprows=2) nbs[t-self.offset] = len(coords) Vs[t-self.offset] = np.ptp(coords, axis=0).prod() if averaged: return (nbs/Vs).mean() else: return (nbs, Vs) |
for t,fname in enum(self): | for t,fname in self.enum(): | def get_zPortion_Nbd(self, lowerMargin=0, upperMargin=0, averaged=True): """Get the number density of a z-slab""" nbs = np.empty((self.size)) Vs = np.empty((self.size)) for t,fname in enum(self): coords = np.loadtxt(fname,delimiter='\t', skiprows=2) m = np.amin(coords[:,-1])+lowerMargin M = np.amax(coords[:,-1])-upperM... |
for t, name in enum(self,ext='g6'): | for t, name in self.enum(ext='g6'): | def g6(self, Nbins=200, nbDiameters=4.5, force=False): """ Calculate g6 and g for each time step and return the time average output is (r,g6,g) """ if not force: for t, name in enum(self,ext='g6'): if not os.path.exists(name): force=True break if force: for t, name in enum(self): subprocess.check_call(map(str, ['g6', n... |
for t, name in enum(self): | for t, name in self.enum(): | def g6(self, Nbins=200, nbDiameters=4.5, force=False): """ Calculate g6 and g for each time step and return the time average output is (r,g6,g) """ if not force: for t, name in enum(self,ext='g6'): if not os.path.exists(name): force=True break if force: for t, name in enum(self): subprocess.check_call(map(str, ['g6', n... |
def __init__(self, xp, start=None, size=None): self.xp = xp if not start or start < self.xp.offset: start = self.xp.offset if not size or start+size > self.xp.offset+self.xp.size: size = self.xp.size + self.xp.offset - start self.trajs = self.read_trajs(start, size) self.positions = self.read_pos(start, size) self.remo... | def __init__(self, xp=None, start=None, size=None, copy=None): if copy is not None: self.xp = copy.xp self.trajs = np.copy(copy.trajs) self.positions = np.copy(copy.positions) return if xp is not None: self.xp = xp if not start or start < self.xp.offset: start = self.xp.offset if not size or start+size > self.xp.offset... | def __init__(self, xp, start=None, size=None): self.xp = xp if not start or start < self.xp.offset: start = self.xp.offset if not size or start+size > self.xp.offset+self.xp.size: size = self.xp.size + self.xp.offset - start self.trajs = self.read_trajs(start, size) self.positions = self.read_pos(start, size) self.remo... |
for t, fname in enum(self.xp): | for t, fname in self.xp.enum(): | def read_pos(self, start, size): """Reads the usefull positions from the .dat files""" pos = np.empty((self.trajs.shape[1],self.trajs.shape[0],3)) for t, fname in enum(self.xp): if t<start or t>= start+size: continue raw_pos = np.loadtxt(fname,delimiter='\t',skiprows=2) pos[t-start] = raw_pos[self.trajs[:,t-start]] ret... |
self.positions[:,:,-1]>180, self.positions[:,:,-1]<280 | self.positions[:,:,-1]>bottom, self.positions[:,:,-1]<top | def z_slab(self, bottom, top, allTimes=True): """remove all trajectories that are not in the slab defined by [bottom, top]""" if allTimes: selection = np.unique1d(np.where( np.bitwise_and( self.positions[:,:,-1]>180, self.positions[:,:,-1]<280 ))[1]) else: selection = np.unique1d(np.where( np.bitwise_and( self.position... |
self.positions[:,:,-1].max(axis=0)>180, self.positions[:,:,-1].min(axis=0)<280 | self.positions[:,:,-1].max(axis=0)>bottom, self.positions[:,:,-1].min(axis=0)<top | def z_slab(self, bottom, top, allTimes=True): """remove all trajectories that are not in the slab defined by [bottom, top]""" if allTimes: selection = np.unique1d(np.where( np.bitwise_and( self.positions[:,:,-1]>180, self.positions[:,:,-1]<280 ))[1]) else: selection = np.unique1d(np.where( np.bitwise_and( self.position... |
for t, fname in enum(self.xp, postfix=postfix, ext=ext): | for t, fname in self.xp.enum(postfix=postfix, ext=ext): | def exclude_null(self, postfix='_space',ext='cloud', col=1): """Remove trajectories having at least a null value in the field given by postfix, ext and col""" field = np.zeros((self.trajs.shape[1], self.trajs.shape[0])) for t, fname in enum(self.xp, postfix=postfix, ext=ext): field[t] = np.loadtxt(fname, usecols=[col])... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.