Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
2,800
def acquire_connection(settings, tag=None, logger_name=None, auto_commit=False): try: connection_properties = settings.get(tag, settings[None]) except KeyError: raise RdbmsConnection.DefaultConnectionPropertiesSettingException() return RdbmsConnection( ...
Return a connection to a Relational DataBase Management System (RDBMS) the most appropriate for the service requesting this connection. @param settings: a dictionary of connection properties:: { None: { 'rdbms_hostname': "...", ...
2,801
def plot_xtf(fignum, XTF, Fs, e, b): plt.figure(num=fignum) plt.xlabel() plt.ylabel() k = 0 Flab = [] for freq in XTF: T, X = [], [] for xt in freq: X.append(xt[0]) T.append(xt[1]) plt.plot(T, X) plt.text(T[-1], X[-1], str(int(Fs[k])) ...
function to plot series of chi measurements as a function of temperature, holding field constant and varying frequency
2,802
def distance_to_edge(labels): colors = color_labels(labels) max_color = np.max(colors) result = np.zeros(labels.shape) if max_color == 0: return result for i in range(1, max_color+1): mask = (colors==i) result[mask] = scind.distance_transform_edt(mask)[mask] ret...
Compute the distance of a pixel to the edge of its object labels - a labels matrix returns a matrix of distances
2,803
def _parse_mirteFile(path, logger=None): l = logging.getLogger() if logger is None else logger cache_path = os.path.join(os.path.dirname(path), CACHE_FILENAME_TEMPLATE % os.path.basename(path)) if (os.path.exists(cache_path) and os.path.getmtime(cache_path) >= ...
Open and parses the mirteFile at <path>.
2,804
def transform_obs(self, obs): empty = np.array([], dtype=np.int32).reshape((0, 7)) out = named_array.NamedDict({ "single_select": empty, "multi_select": empty, "build_queue": empty, "cargo": empty, "cargo_slots_available": np.array([0], dtype=np.int32), }) ...
Render some SC2 observations into something an agent can handle.
2,805
def _simplify_non_context_field_binary_composition(expression): if any((isinstance(expression.left, ContextField), isinstance(expression.right, ContextField))): raise AssertionError(u u.format(expression)) if expression.operator == u: if expression....
Return a simplified BinaryComposition if either operand is a TrueLiteral. Args: expression: BinaryComposition without any ContextField operand(s) Returns: simplified expression if the given expression is a disjunction/conjunction and one of it's operands is a TrueLiteral, and t...
2,806
def __is_valid_type(self, typ, typlist): typ_is_str = typ == "string" str_list_in_typlist = "stringlist" in typlist return typ in typlist or (typ_is_str and str_list_in_typlist)
Check if type is valid based on input type list "string" is special because it can be used for stringlist :param typ: the type to check :param typlist: the list of type to check :return: True on success, False otherwise
2,807
def dump(deposition, from_date, with_json=True, latest_only=False, **kwargs): dep_json = json.dumps(deposition.__getstate__(), default=default_serializer) dep_dict = json.loads(dep_json) dep_dict[] = {} dep_dict[][] = deposition.id dep_dict[][] = dt2utc_timestamp(...
Dump the deposition object as dictionary.
2,808
def is_valid_short_number_for_region(short_numobj, region_dialing_from): if not _region_dialing_from_matches_number(short_numobj, region_dialing_from): return False metadata = PhoneMetadata.short_metadata_for_region(region_dialing_from) if metadata is None: return False short_numb...
Tests whether a short number matches a valid pattern in a region. Note that this doesn't verify the number is actually in use, which is impossible to tell by just looking at the number itself. Arguments: short_numobj -- the short number to check as a PhoneNumber object. region_dialing_from -- the ...
2,809
def create_project(self, name=None, project_id=None, path=None): if project_id is not None and project_id in self._projects: return self._projects[project_id] project = Project(name=name, project_id=project_id, path=path) self._check_available_disk_space(project) se...
Create a project and keep a references to it in project manager. See documentation of Project for arguments
2,810
def get_vcs_details_output_vcs_details_principal_switch_wwn(self, **kwargs): config = ET.Element("config") get_vcs_details = ET.Element("get_vcs_details") config = get_vcs_details output = ET.SubElement(get_vcs_details, "output") vcs_details = ET.SubElement(output, "vcs-...
Auto Generated Code
2,811
def getPort(self): disp = self.pbmanager.dispatchers[self.portstr] return disp.port.getHost().port
Helper method for testing; returns the TCP port used for this registration, even if it was specified as 0 and thus allocated by the OS.
2,812
def _stdin_raw_block(self): try: data = sys.stdin.read(1) data = data.replace(, ) return data except WindowsError as we: if we.winerror == ERROR_NO_DATA: return None else: ...
Use a blocking stdin read
2,813
def bovy_text(*args,**kwargs): if kwargs.pop(,False): pyplot.annotate(args[0],(0.5,1.05),xycoords=, horizontalalignment=, verticalalignment=,**kwargs) elif kwargs.pop(,False): pyplot.annotate(args[0],(0.05,0.05),xycoords=,**kwargs) elif kw...
NAME: bovy_text PURPOSE: thin wrapper around matplotlib's text and annotate use keywords: 'bottom_left=True' 'bottom_right=True' 'top_left=True' 'top_right=True' 'title=True' to place the text in one of the corners or use it as ...
2,814
def generate_messages(outf, msgs): print("Generating Messages") t.write(outf, ) for msg in msgs: t.write(outf, , msg)
Generate Swift structs to represent all MAVLink messages
2,815
def _fix_component_id(self, component): theID = getattr(component, "id", None) if theID is not None: setattr(component, "id", self._fix_id(theID)) try: for c in component.children: self._fix_component_id(c) except: pass
Fix name of component ad all of its children
2,816
def get_interval_timedelta(self): now_datetime = timezone.now() current_month_days = monthrange(now_datetime.year, now_datetime.month)[1] if self.interval == reminders_choices.INTERVAL_2_WEEKS: interval_timedelta = datetime.timedelta(days=14) eli...
Spits out the timedelta in days.
2,817
def basic_qos(self, prefetch_size, prefetch_count, a_global): args = AMQPWriter() args.write_long(prefetch_size) args.write_short(prefetch_count) args.write_bit(a_global) self._send_method((60, 10), args) return self.wait(allowed_methods=[ (60, 11), ...
Specify quality of service This method requests a specific quality of service. The QoS can be specified for the current channel or for all channels on the connection. The particular properties and semantics of a qos method always depend on the content class semantics. Though t...
2,818
def from_json(cls, data): required_keys = (, , , ) for key in required_keys: assert key in data, .format(key) if not in data: data[] = return cls(data[], data[], data[], data[])
Create a Sky Condition from a dictionary. Args: data = { "solar_model": string, "month": int, "day_of_month": int, "clearness": float, "daylight_savings_indicator": string // "Yes" or "No"}
2,819
def romanize(text: str, engine: str = "royin") -> str: if not text or not isinstance(text, str): return "" if engine == "thai2rom": from .thai2rom import romanize else: from .royin import romanize return romanize(text)
Rendering Thai words in the Latin alphabet or "romanization", using the Royal Thai General System of Transcription (RTGS), which is the official system published by the Royal Institute of Thailand. ถอดเสียงภาษาไทยเป็นอักษรละติน :param str text: Thai text to be romanized :param str engine: 'royin' (d...
2,820
def deploy_api_gateway( self, api_id, stage_name, stage_description="", description="", cache_cluster_enabled=False, cache_cluster_size=, ...
Deploy the API Gateway! Return the deployed API URL.
2,821
def guess_format( filename, ext, formats, io_table ): ok = False for format in formats: output( % format ) try: ok = io_table[format].guess( filename ) except AttributeError: pass if ok: break else: raise NotImplementedError( % ext) ...
Guess the format of filename, candidates are in formats.
2,822
def get_field_lookups(field_type, nullable): return LOOKUP_TABLE.get(field_type) + [] if nullable else LOOKUP_TABLE.get(field_type)
Return lookup table value and append isnull if this is a nullable field
2,823
def total(self): total = 0 for item in self.items.all(): total += item.total return total
Total cost of the order
2,824
def element(self, inp=None): if inp is not None: s = str(inp)[:self.length] s += * (self.length - len(s)) return s else: return * self.length
Return an element from ``inp`` or from scratch.
2,825
def comment(self, text, comment_prefix=): comment = Comment(self._container) if not text.startswith(comment_prefix): text = "{} {}".format(comment_prefix, text) if not text.endswith(): text = "{}{}".format(text, ) comment.add_line(text) self._cont...
Creates a comment block Args: text (str): content of comment without # comment_prefix (str): character indicating start of comment Returns: self for chaining
2,826
def _add_default_exposure_class(layer): layer.startEditing() field = create_field_from_definition(exposure_class_field) layer.keywords[][exposure_class_field[]] = ( exposure_class_field[]) layer.addAttribute(field) index = layer.fields().lookupField(exposure_class_field[]) exposu...
The layer doesn't have an exposure class, we need to add it. :param layer: The vector layer. :type layer: QgsVectorLayer
2,827
def len_cdc_tube(FlowPlant, ConcDoseMax, ConcStock, DiamTubeAvail, HeadlossCDC, LenCDCTubeMax, temp, en_chem, KMinor): index = i_cdc(FlowPlant, ConcDoseMax, ConcStock, DiamTubeAvail, HeadlossCDC, LenCDCTubeMax, temp, en_chem, KMinor) len_cdc_tu...
The length of tubing may be longer than the max specified if the stock concentration is too high to give a viable solution with the specified length of tubing.
2,828
def current_version(): import setuptools version = [None] def monkey_setup(**settings): version[0] = settings[] old_setup = setuptools.setup setuptools.setup = monkey_setup import setup reload(setup) setuptools.setup = old_setup return version[0]
Get the current version number from setup.py
2,829
def from_json(json_data): return oauth
Returns a pyalveo.OAuth2 given a json string built from the oauth.to_json() method.
2,830
def headers(self): self.__dict__[] = hdict = HeaderDict() hdict.dict = self._headers return hdict
An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the response headers.
2,831
def extract_first_jpeg_in_pdf(fstream): parser = PDFParser(fstream) if PY2: document = PDFDocument(parser) else: document = PDFDocument() parser.set_document(document) document.set_parser(parser) document.initialize() rsrcmgr = PDFResourceManager() device...
Reads a given PDF file and scans for the first valid embedded JPEG image. Returns either None (if none found) or a string of data for the image. There is no 100% guarantee for this code, yet it seems to work fine with most scanner-produced images around. More testing might be needed though. Note th...
2,832
def load(self, filename=None): if not filename: filename = self.default_config_file files = self._cfgs_to_read() files.insert(-1, filename) try: config = self.__read_cfg(files) except ReadConfigException as e: print...
load runtime configuration from given filename. If filename is None try to read from default file from default location.
2,833
def _connect(self, config): if not in self._config: self._config[] = 480 try: self._cnx = connect(**config) self._cursor = self._cnx.cursor() self._printer(, config[]) except Error as err: if err.errno == errorcode.ER_ACCESS_D...
Establish a connection with a MySQL database.
2,834
def copy_file( host, file_path, remote_path=, username=None, key_path=None, action= ): if not username: username = shakedown.cli.ssh_user if not key_path: key_path = shakedown.cli.ssh_key_file key = validate_key(key_path) transport...
Copy a file via SCP, proxied through the mesos master :param host: host or IP of the machine to execute the command on :type host: str :param file_path: the local path to the file to be copied :type file_path: str :param remote_path: the remote path to copy the file to :...
2,835
def picard_index_ref(picard, ref_file): dict_file = "%s.dict" % os.path.splitext(ref_file)[0] if not file_exists(dict_file): with file_transaction(picard._config, dict_file) as tx_dict_file: opts = [("REFERENCE", ref_file), ("OUTPUT", tx_dict_file)] picar...
Provide a Picard style dict index file for a reference genome.
2,836
def add_file_dep(self, doc, value): if self.has_package(doc) and self.has_file(doc): self.file(doc).add_depend(value) else: raise OrderError()
Raises OrderError if no package or file defined.
2,837
def _get_kvc(kv_arg): if isinstance(kv_arg, Mapping): return six.iterkeys(kv_arg), six.itervalues(kv_arg), len(kv_arg) assert 2 <= len(kv_arg) <= 3, \ return ( kv_arg[0], kv_arg[1], kv_arg[2] if len(kv_arg) == 3 else len(kv_arg[0]))
Returns a tuple keys, values, count for kv_arg (which can be a dict or a tuple containing keys, values and optinally count.
2,838
def check_entry_points(dist, attr, value): try: pkg_resources.EntryPoint.parse_map(value) except ValueError, e: raise DistutilsSetupError(e)
Verify that entry_points map is parseable
2,839
def get_repository_state(self, relaPath=None): state = [] def _walk_dir(relaPath, dirList): dirDict = {:, :os.path.isdir(os.path.join(self.__path,relaPath)), :os.path.isfile(os.path.join(self.__path,relaPath,self.__dirInfo)), ...
Get a list representation of repository state along with useful information. List state is ordered relativeley to directories level :Parameters: #. relaPath (None, str): relative directory path from where to start. If None all repository representation is returned. :...
2,840
def toDict(self): result = _Base.toDict(self) result[] = self.score.score return result
Get information about the HSP as a dictionary. @return: A C{dict} representation of the HSP.
2,841
def get_template(self, project, template_id): route_values = {} if project is not None: route_values[] = self._serialize.url(, project, ) if template_id is not None: route_values[] = self._serialize.url(, template_id, ) response = self._send(http_method=,...
GetTemplate. Gets a specific build definition template. :param str project: Project ID or project name :param str template_id: The ID of the requested template. :rtype: :class:`<BuildDefinitionTemplate> <azure.devops.v5_0.build.models.BuildDefinitionTemplate>`
2,842
def add_source(zone, source, permanent=True): * if source in get_sources(zone, permanent): log.info() cmd = .format(zone, source) if permanent: cmd += return __firewall_cmd(cmd)
Bind a source to a zone .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_source zone 192.168.1.0/24
2,843
def delete(self, block_type, block_num): logger.info("deleting block") blocktype = snap7.snap7types.block_types[block_type] result = self.library.Cli_Delete(self.pointer, blocktype, block_num) return result
Deletes a block :param block_type: Type of block :param block_num: Bloc number
2,844
def listen_error_messages_raylet(worker, task_error_queue, threads_stopped): worker.error_message_pubsub_client = worker.redis_client.pubsub( ignore_subscribe_messages=True) error_pubsub_channel = str( ray.gcs_utils.TablePubsub.ERROR_INFO).encode("ascii") worke...
Listen to error messages in the background on the driver. This runs in a separate thread on the driver and pushes (error, time) tuples to the output queue. Args: worker: The worker class that this thread belongs to. task_error_queue (queue.Queue): A queue used to communicate with the ...
2,845
def instance(cls): if not hasattr(cls, "_instance") or cls._instance is None: cls._instance = cls() return cls._instance
Singleton to return only one instance of BaseManager. :returns: instance of BaseManager
2,846
def stats(self): load_count = self.last_level_load.MISS_count load_byte = self.last_level_load.MISS_byte if self.last_level_load.victims_to is not None: load_count -= self.last_level_load.victims_to.HIT_count load_byte -= self.last_level_load.victim...
Return dictionay with all stats at this level.
2,847
def inspect(self): last_attempt = self.get_last_failed_access_attempt( ip_address=self.ip, captcha_enabled=True, captcha_passed=False, is_expired=False ) if last_attempt is None and not self.request.user.is_authenticated(): ...
Inspect access attempt, used for catpcha flow :return:
2,848
def structure(self, obj, cl): return self._structure_func.dispatch(cl)(obj, cl)
Convert unstructured Python data structures to structured data.
2,849
def _ProcessGrepSource(self, source): attributes = source.base_source.attributes paths = artifact_utils.InterpolateListKbAttributes( attributes["paths"], self.knowledge_base, self.ignore_interpolation_errors) regex = utils.RegexListDisjunction(attributes["content_regex_list"]) condi...
Find files fulfilling regex conditions.
2,850
def bll_version(self): if not self.started(): return None status, data = self._rest.get_request(, , [, ]) return data[]
Get the BLL version this session is connected to. Return: Version string if session started. None if session not started.
2,851
def get_serializer(name): try: log.debug(, name) return SERIALIZER_LOOKUP[name] except KeyError: msg = .format(name) log.error(msg, exc_info=True) raise InvalidSerializerException(msg)
Return the serialize function.
2,852
def generate_changelog(from_version: str, to_version: str = None) -> dict: debug(.format(from_version, to_version)) changes: dict = {: [], : [], : [], : [], : []} found_the_release = to_version is None rev = None if from_version: rev = .format(from_version) f...
Generates a changelog for the given version. :param from_version: The last version not in the changelog. The changelog will be generated from the commit after this one. :param to_version: The last version in the changelog. :return: a dict with different changelog sections
2,853
def reverse_taskname(name: str) -> str: components = name.split() assert len(components) <= 3 return .join(components[::-1])
Reverses components in the name of task. Reversed convention is used for filenames since it groups log/scratch files of related tasks together 0.somejob.somerun -> somerun.somejob.0 0.somejob -> somejob.0 somename -> somename Args: name: name of task
2,854
def _validate_columns(self): geom_cols = {, , } col_overlap = set(self.style_cols) & geom_cols if col_overlap: raise ValueError( .format( col=.join(col_overlap)))
Validate the options in the styles
2,855
def nested_assign(self, key_list, value): if len(key_list) == 1: self[key_list[0]] = value elif len(key_list) > 1: if key_list[0] not in self: self[key_list[0]] = LIVVDict() self[key_list[0]].nested_assign(key_list[1:], value)
Set the value of nested LIVVDicts given a list
2,856
def _prepare_text(self, text): text = re.sub(r, , text) pattern = r.format(self._tokenizer.pattern) return re.sub(pattern, self._base_token_markup, text)
Returns `text` with each consituent token wrapped in HTML markup for later match annotation. :param text: text to be marked up :type text: `str` :rtype: `str`
2,857
def get_diff(self, rev1, rev2, path=, ignore_whitespace=False, context=3): if hasattr(rev1, ): rev1 = getattr(rev1, ) if hasattr(rev2, ): rev2 = getattr(rev2, ) if rev1 != self.EMPTY_CHANGESET: self.get_changeset(...
Returns (git like) *diff*, as plain text. Shows changes introduced by ``rev2`` since ``rev1``. :param rev1: Entry point from which diff is shown. Can be ``self.EMPTY_CHANGESET`` - in this case, patch showing all the changes since empty state of the repository until ``rev2`` ...
2,858
async def deserialize(data: dict): return await Connection._deserialize("vcx_connection_deserialize", json.dumps(data), data.get())
Create the object from a previously serialized object. :param data: The output of the "serialize" call Example: data = await connection1.serialize() connection2 = await Connection.deserialize(data) :return: A re-instantiated object
2,859
def issuer_cert_urls(self): if self._issuer_cert_urls is None: self._issuer_cert_urls = [] if self.authority_information_access_value: for entry in self.authority_information_access_value: if entry[].native == : locati...
:return: A list of unicode strings that are URLs that should contain either an individual DER-encoded X.509 certificate, or a DER-encoded CMS message containing multiple certificates
2,860
def create(self, **kwargs): obj = self.model(**kwargs) meta = obj.get_meta() meta.connection = get_es_connection(self.es_url, self.es_kwargs) meta.index=self.index meta.type=self.type obj.save(force=True) return obj
Creates a new object with the given kwargs, saving it to the database and returning the created object.
2,861
def validate(self, value): if value is None: return True else: try: with value.open() as hdulist: self.validate_hdulist(hdulist) except Exception: _type, exc, tb = sys.exc_info() six...
validate
2,862
def custom(command, user=None, conf_file=None, bin_env=None): **gunicorn* ret = __salt__[]( _ctl_cmd(command, None, conf_file, bin_env), runas=user, python_shell=False, ) return _get_return(ret)
Run any custom supervisord command user user to run supervisorctl as conf_file path to supervisord config file bin_env path to supervisorctl bin or path to virtualenv with supervisor installed CLI Example: .. code-block:: bash salt '*' supervisord.custom "...
2,863
def send_message(message, params, site, logger): client.capture( , message=message, params=tuple(params), data={ : site, : logger, }, )
Send a message to the Sentry server
2,864
async def _start(self): self.agent._alive.wait() try: await self.on_start() except Exception as e: logger.error("Exception running on_start in behaviour {}: {}".format(self, e)) self.kill(exit_code=e) await self._step() self._is_done.c...
Start coroutine. runs on_start coroutine and then runs the _step coroutine where the body of the behaviour is called.
2,865
def p_out(p): p[0] = make_sentence(, make_typecast(TYPE.uinteger, p[2], p.lineno(3)), make_typecast(TYPE.ubyte, p[4], p.lineno(4)))
statement : OUT expr COMMA expr
2,866
def update_rho(self, k, r, s): if self.opt[, ]: tau = self.rho_tau mu = self.rho_mu xi = self.rho_xi if k != 0 and np.mod(k + 1, self.opt[, ]) == 0: if self.opt[, ]: if s == 0.0 or r == 0.0: rho...
Automatic rho adjustment.
2,867
def database_renderer(self, name=None, site=None, role=None): name = name or self.env.default_db_name site = site or self.genv.SITE role = role or self.genv.ROLE key = (name, site, role) self.vprint(, key) if key not in self._database_renderers: s...
Renders local settings for a specific database.
2,868
def create_event(component, tz=UTC): event = Event() event.start = normalize(component.get().dt, tz=tz) if component.get(): event.end = normalize(component.get().dt, tz=tz) elif component.get(): event.end = event.start + component.get().dt else: event.end = even...
Create an event from its iCal representation. :param component: iCal component :param tz: timezone for start and end times :return: event
2,869
def N_to_Ntriangles(N): theta = np.array([np.pi/2*(k-0.5)/N for k in range(1, N+1)]) phi = np.array([[np.pi*(l-0.5)/Mk for l in range(1, Mk+1)] for Mk in np.array(1 + 1.3*N*np.sin(theta), dtype=int)]) Ntri = 2*np.array([len(p) for p in phi]).sum() return Ntri
@N: WD style gridsize Converts WD style grid size @N to the number of triangles on the surface. Returns: number of triangles.
2,870
def list_storages(self):
Returns a list of existing stores. The returned names can then be used to call get_storage().
2,871
def write_matrix_to_csv(self, headers, data): with open(self.path, "w") as out_file: data_writer = csv.writer(out_file, delimiter=",") data_writer.writerow(headers) data_writer.writerows(data)
Saves .csv file with data :param headers: column names :param data: Data
2,872
def pybel_to_json(molecule, name=None): atoms = [{: table.GetSymbol(atom.atomicnum), : list(atom.coords)} for atom in molecule.atoms] for json_atom, pybel_atom in zip(atoms, molecule.atoms): if pybel_atom.partialcharge != 0: json_atom[] = pybel_atom....
Converts a pybel molecule to json. Args: molecule: An instance of `pybel.Molecule` name: (Optional) If specified, will save a "name" property Returns: A Python dictionary containing atom and bond data
2,873
def start(self): t work' thread = threading.Thread(target=reactor.run) thread.start()
doesn't work
2,874
def solve(self): aLvl,trash = self.prepareToCalcEndOfPrdvP() EndOfPrdvP = self.calcEndOfPrdvP() if self.vFuncBool: self.makeEndOfPrdvFunc(EndOfPrdvP) if self.CubicBool: interpolator = self.makeCubicxFunc else: interpolator = self.make...
Solves a one period consumption saving problem with risky income and shocks to medical need. Parameters ---------- None Returns ------- solution : ConsumerSolution The solution to the one period problem, including a consumption function, ...
2,875
def removeStages(self, personID): while self.getRemainingStages(personID) > 1: self.removeStage(personID, 1) self.removeStage(personID, 0)
remove(string) Removes all stages of the person. If no new phases are appended, the person will be removed from the simulation in the next simulationStep().
2,876
def ReportConfiguration(self, f): if BoundaryCheck.chrom != -1: print >> f, BuildReportLine("CHROM", BoundaryCheck.chrom) if len(self.start_bounds) > 0: bounds = ",".join(["%s-%s" % (a[0], a[1]) for a in zip(self.start_bounds, self.end_bounds)]) ...
Report the boundary configuration details :param f: File (or standard out/err) :return: None
2,877
def getCSD (lfps,sampr,minf=0.05,maxf=300,norm=True,vaknin=False,spacing=1.0): datband = getbandpass(lfps,sampr,minf,maxf) if datband.shape[0] > datband.shape[1]: ax = 1 else: ax = 0 if vaknin: datband = Vaknin(datband) if norm: removemean(datband,ax=ax) CSD = -numpy.diff(datband,n=2...
get current source density approximation using set of local field potentials with equidistant spacing first performs a lowpass filter lfps is a list or numpy array of LFPs arranged spatially by column spacing is in microns
2,878
def get_ngroups(self, field=None): field = field if field else self._determine_group_field(field) if in self.data[][field]: return self.data[][field][] raise ValueError("ngroups not found in response. specify group.ngroups in the query.")
Returns ngroups count if it was specified in the query, otherwise ValueError. If grouping on more than one field, provide the field argument to specify which count you are looking for.
2,879
def _GetComplexConjugateArray(Array): ConjArray = _np.array([num.conj() for num in Array]) return ConjArray
Calculates the complex conjugate of each element in an array and returns the resulting array. Parameters ---------- Array : ndarray Input array Returns ------- ConjArray : ndarray The complex conjugate of the input array.
2,880
def generate_random_schema(valid): schema_type = choice([, ]) if schema_type == : type, gen = generate_random_type(valid) value = next(gen) return value, (value if valid else None for i in itertools.count()) elif schema_type == : return generate_random_type(valid) e...
Generate a random plain schema, and a sample generation function. :param valid: Generate valid samples? :type valid: bool :returns: schema, sample-generator :rtype: *, generator
2,881
def dt_day(x): import pandas as pd return pd.Series(x).dt.day.values
Extracts the day from a datetime sample. :returns: an expression containing the day extracted from a datetime column. Example: >>> import vaex >>> import numpy as np >>> date = np.array(['2009-10-12T03:31:00', '2016-02-11T10:17:34', '2015-11-12T11:34:22'], dtype=np.datetime64) >>> df = vaex.f...
2,882
def save_file(self, path=None, filters=, force_extension=None, force_overwrite=False, header_only=False, delimiter=, binary=None): if not _os.path.splitext(path)[-1][1:] == force_extension: path = path + + force_extension self.path=path ...
This will save all the header info and columns to an ascii file with the specified path. Parameters ---------- path=None Path for saving the data. If None, this will bring up a save file dialog. filters='*.dat' File filter for the fil...
2,883
def parse_expr(e): m = relation_re.match(e) if m is None: raise ValueError("error parsing expression ".format(e)) field, op, val = m.groups() try: val_int = int(val) val = val_int except ValueError: try: val_float = float(va...
Parse a single constraint expression. Legal expressions are defined by the regular expression `relation_re`. :param e: Expression :type e: str :return: Tuple of field, operator, and value :rtype: tuple
2,884
def pool(args): from jcvi.formats.base import longest_unique_prefix p = OptionParser(pool.__doc__) p.add_option("--sep", default=".", help="Separator between prefix and name") p.add_option("--sequential", default=False, action="store_true", help="Add sequential IDs") opts, args = p...
%prog pool fastafiles > pool.fasta Pool a bunch of FASTA files, and add prefix to each record based on filenames. File names are simplified to longest unique prefix to avoid collisions after getting shortened.
2,885
def _set_client_pw(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass(v,base=client_pw.client_pw, is_container=, presence=True, yang_name="client-pw", rest_name="client-pw", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths...
Setter method for client_pw, mapped from YANG variable /cluster/client_pw (container) If this variable is read-only (config: false) in the source YANG file, then _set_client_pw is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_client_pw()...
2,886
def load_requires_from_file(filepath): with open(filepath) as fp: return [pkg_name.strip() for pkg_name in fp.readlines()]
Read a package list from a given file path. Args: filepath: file path of the package list. Returns: a list of package names.
2,887
def insert_completions(self, e): u completions = self._get_completions() b = self.begidx e = self.endidx for comp in completions: rep = [ c for c in comp ] rep.append() self.l_buffer[b:e] = rep b += len(rep) e ...
u"""Insert all completions of the text before point that would have been generated by possible-completions.
2,888
def addStream(self, stream, interpolator="closest", t1=None, t2=None, dt=None, limit=None, i1=None, i2=None, transform=None,colname=None): streamquery = query_maker(t1, t2, limit, i1, i2, transform) param_stream(self.cdb, streamquery, stream) streamquery["interpolator"] = interpolator...
Adds the given stream to the query construction. Additionally, you can choose the interpolator to use for this stream, as well as a special name for the column in the returned dataset. If no column name is given, the full stream path will be used. addStream also supports Merge queries. You can insert a...
2,889
def _check_file(parameters): (filename, args) = parameters if filename == : contents = sys.stdin.read() else: with contextlib.closing( docutils.io.FileInput(source_path=filename) ) as input_file: contents = input_file.read() args = load_configuratio...
Return list of errors.
2,890
def parse_complex_fault_node(node, mfd_spacing=0.1, mesh_spacing=4.0): assert "complexFaultSource" in node.tag sf_taglist = get_taglist(node) sf_id, name, trt = (node.attrib["id"], node.attrib["name"], node.attrib["tectonicRegion"]) edges = ...
Parses a "complexFaultSource" node and returns an instance of the :class: openquake.hmtk.sources.complex_fault.mtkComplexFaultSource
2,891
def from_dict(self, d): if in d: if d[]: self._uid = d[] if in d: if d[]: self._name = d[] if in d: if isinstance(d[], str) or isinstance(d[], unicode): if d[] in states._stage_state_values.keys():...
Create a Stage from a dictionary. The change is in inplace. :argument: python dictionary :return: None
2,892
def gaussian_kernel(data_shape, sigma, norm=): r if not import_astropy: raise ImportError() if norm not in (, , ): raise ValueError() kernel = np.array(Gaussian2DKernel(sigma, x_size=data_shape[1], y_size=data_shape[0])) if norm == : return kernel ...
r"""Gaussian kernel This method produces a Gaussian kerenal of a specified size and dispersion Parameters ---------- data_shape : tuple Desiered shape of the kernel sigma : float Standard deviation of the kernel norm : str {'max', 'sum', 'none'}, optional Normalisation ...
2,893
def _get_switchports(profile): switchports = [] if profile.get(): for link in profile[]: if in link and in link: switch = link[] interface = link[] switchports.append((switch, interface)) e...
Return list of (switch_ip, interface) tuples from local_link_info
2,894
def write_results(filename,config,srcfile,samples): results = createResults(config,srcfile,samples=samples) results.write(filename)
Package everything nicely
2,895
def ustep(self): super(ConvCnstrMODMaskDcpl_Consensus, self).ustep() self.U1 += self.AX1 - self.Y1 - self.S
The parent class ystep method is overridden to allow also performing the ystep for the additional variables introduced in the modification to the baseline algorithm.
2,896
def enqueue_task(self, source, *args): yield from self.cell.coord.enqueue(self) route = Route(source, self.cell, self.spec, self.emit) self.cell.loop.create_task(self.coord_wrap(route, *args)) yield
Enqueue a task execution. It will run in the background as soon as the coordinator clears it to do so.
2,897
def _call(self, x, out=None): if out is None: return self.range.element(copy(self.constant)) else: out.assign(self.constant)
Return the constant vector or assign it to ``out``.
2,898
def trigger_audited(self, id, rev, **kwargs): kwargs[] = True if kwargs.get(): return self.trigger_audited_with_http_info(id, rev, **kwargs) else: (data) = self.trigger_audited_with_http_info(id, rev, **kwargs) return data
Triggers a build of a specific Build Configuration in a specific revision This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(respo...
2,899
def print_head(self, parent_plate_value, plate_values, interval, n=10, print_func=logging.info): if isinstance(plate_values, Plate): self.print_head(parent_plate_value, plate_values.values, interval, n, print_func) return if len(plate_values) == 1 and len(plate_values[0...
Print the first n values from the streams in the given time interval. The parent plate value is the value of the parent plate, and then the plate values are the values for the plate that are to be printed. e.g. print_head(None, ("house", "1")) :param parent_plate_value: The (fixed) pare...