code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def set_user_source_profile(self, method, z0=0, sVec=None, sFunc=None): <NEW_LINE> <INDENT> self.source = np.zeros(self.zNumFull, dtype='complex') <NEW_LINE> if method == 'vector': <NEW_LINE> <INDENT> sNum = len(sVec) <NEW_LINE> j = 0 <NEW_LINE> for i in range(self.zNumFull): <NEW_LINE> <INDENT> if self.zFull[i] >= z0:... | set the spatial source profile explicitly (no frequency / signal information)
Precondition: index of refraction profile is already set
Parameters
----------
method : string
'vector' for vector defined profile
'func' for function defined profile
z0 : float
Precondition: z0>=0
reference starting point... | 625941f56aa9bd52df0373e3 |
def remove_terminal_events(self, df, cfg): <NEW_LINE> <INDENT> df['temp'] = df.groupby([cfg['ID_COL']])[cfg['EVENT_DATE']].transform('max') <NEW_LINE> df['temp_2'] = np.where(df['temp'] == df[cfg['EVENT_DATE']], 1,0) <NEW_LINE> ids = df[df[cfg['REF_EVENT_COL']] == 1][cfg['ID_COL']].unique() <NEW_LINE> churners = df[df[... | Removes data for events in the churn date
Parameters:
df (dataframe): dataframe.
cfg (dict): configuration dictionary.
Returns:
df: dataframe. | 625941f510dbd63aa1bd31dd |
def d_softmax(rows): <NEW_LINE> <INDENT> rows = np.asarray(rows) <NEW_LINE> return np.apply_along_axis(_d_softmax, arr=rows, axis=1) | The derivative of the softmax activation function.
Parameters
----------
rows : array_like
Returns
-------
array_like
The derivative evaluated at each row in `rows`. | 625941f5be383301e01b5ab4 |
def _minimize_towers(tower_specs): <NEW_LINE> <INDENT> return tower_specs[-1].train_op | `train_op` of the last tower applies aggregated gradients. | 625941f524f1403a9260119c |
def prox_qp(v, t = 1, Q = None, q = None, F = None, g = None, *args, **kwargs): <NEW_LINE> <INDENT> if Q is None: <NEW_LINE> <INDENT> raise ValueError("Q must be a matrix") <NEW_LINE> <DEDENT> if q is None: <NEW_LINE> <INDENT> raise ValueError("q must be a vector") <NEW_LINE> <DEDENT> if F is None: <NEW_LINE> <INDENT> ... | Proximal operator of :math:`tf(ax-b) + c^Tx + d\|x\|_2^2`, where :math:`f(x) = x^TQx+q^Tx+I{Fx<=g}`
for scalar t > 0, and the optional arguments are a = scale, b = offset, c = lin_term, and d = quad_term.
We must have t > 0, a = non-zero, and d >= 0. By default, t = 1, a = 1, b = 0, c = 0, and d = 0. | 625941f5de87d2750b8603d5 |
def _recreate(self, proto, node_id, nodes): <NEW_LINE> <INDENT> registered_class = registration.get_registered_class(proto.registered_name) <NEW_LINE> if registered_class is None: <NEW_LINE> <INDENT> registered_class = _BUILT_IN_REGISTRATIONS.get(proto.WhichOneof("kind")) <NEW_LINE> <DEDENT> dependencies = {} <NEW_LINE... | Creates a Python object from a SavedObject protocol buffer.
Args:
proto: a SavedObject proto
node_id: int, the index of this object in the SavedObjectGraph node list.
nodes: dict mapping int node_ids -> created objects.
Returns:
The recreated object, and the set-attribute function for reconnecting
the track... | 625941f5627d3e7fe0d6948d |
def probe_operating_system() -> str: <NEW_LINE> <INDENT> logger.debug('Determining operating system') <NEW_LINE> operating_system = sys.platform <NEW_LINE> logger.debug('Found platform: {}'.format(operating_system)) <NEW_LINE> if operating_system.startswith('linux'): <NEW_LINE> <INDENT> operating_system = get_linux_dis... | Probes the system to determine the operating system.
:return: The name of the operating system, e.g. win32, darwin, ubuntu16.04, centos7, etc. | 625941f545492302aab5e905 |
def _runcommand(self, cmd, env, normalizenewlines=False, linecallback=None): <NEW_LINE> <INDENT> if self._debug: <NEW_LINE> <INDENT> proc = subprocess.Popen(cmd, shell=True, cwd=self._testtmp, env=env) <NEW_LINE> ret = proc.wait() <NEW_LINE> return (ret, []) <NEW_LINE> <DEDENT> proc = Popen4(cmd, self._testtmp, self._t... | Run command in a sub-process, capturing the output (stdout and
stderr).
Return a tuple (exitcode, output). output is None in debug mode. | 625941f5a05bb46b383ece56 |
def parallel_load_wrapper(input_arg): <NEW_LINE> <INDENT> (filename, zone, varnames, szplt, include_geom, gridfile) = input_arg <NEW_LINE> _,_,_,data_i,dataset = load_tec_file(filename, szplt=szplt, verbose=False, varnames=varnames, load_zones=zone, coords=False, deletezones=False, replace=True, include_geom=include_ge... | Helper function for read_series_parallel | 625941f507f4c71912b11ac1 |
def parse_game_urls(scoreboard_url=None, url_params=None): <NEW_LINE> <INDENT> soup = make_soup(scoreboard_url, url_params) <NEW_LINE> all_links = soup.find_all('a') <NEW_LINE> game_urls = [] <NEW_LINE> for link in all_links: <NEW_LINE> <INDENT> if 'Play‑By‑Play' in link.text: <NEW_LINE> <INDENT> game_urls.append(link[... | Scrape <scoreboard_url> and extract any URLs that lead to Play-by-Plays.
Returns relative URLs (such as '/nba/playbyplay?gameId=400489876')
to be joined with the base ESPN url | 625941f5d486a94d0b98e782 |
def forward(self, facts, G) -> torch.tensor: <NEW_LINE> <INDENT> batch_num, seq_num, hidden_size = facts.size() <NEW_LINE> c = torch.zeros(batch_num, hidden_size, device=facts.device) <NEW_LINE> for sid in range(seq_num): <NEW_LINE> <INDENT> fact = facts[:, sid, :] <NEW_LINE> g = G[:, sid] <NEW_LINE> c = self.AGRUCell.... | forwar step
Arguments:
facts {tensor} -- shape '(batch, seq_len, hidden_size)'
G {tensor} -- shape '(batch, sentence)'
Returns:
c {tensor} -- shape '(batch, hidden_size)' | 625941f597e22403b379d5d7 |
def hsv_to_rgb(hue, sat, val): <NEW_LINE> <INDENT> h = hue / 360 <NEW_LINE> s = sat / 100 <NEW_LINE> v = val / 100 <NEW_LINE> if s == 0.0: <NEW_LINE> <INDENT> v *= 255 <NEW_LINE> return (v, v, v) <NEW_LINE> <DEDENT> i = int(h * 6.0) <NEW_LINE> f = (h * 6.0) - i <NEW_LINE> p, q, t = ( int(255 * (v * (1.0 - s))), int(255... | Adapted from https://stackoverflow.com/questions/24852345/hsv-to-rgb-color-conversion | 625941f597e22403b379d5d8 |
def p_exp(p): <NEW_LINE> <INDENT> pass | exp : IF_KEYWORD exp THEN_KEYWORD exp ELSE_KEYWORD exp
| LET_KEYWORD defplus IN_KEYWORD exp
| MAP_KEYWORD idList TO_KEYWORD exp
| term binop exp
| term
defplus : def
| def defplus | 625941f5cc0a2c11143dd4cd |
def highlyRandomName(self, filename, longitud=20): <NEW_LINE> <INDENT> lista_letras_numeros = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" <NEW_LINE> name="".join([random.choice(lista_letras_numeros) for i in xrange(longitud)]) <NEW_LINE> root, ext = os.path.splitext(filename) <NEW_LINE> return name... | retorna un nombre aleatorio de longitud igual a 'longitud',
manteniendo la extension de la imagen | 625941f582261d6c526abae5 |
def _addFlags(kwargs, flags): <NEW_LINE> <INDENT> kwargs["flags"] = ",".join((kwargs["flags"], flags)) if "flags" in kwargs else flags | Add flags to dictmapping entry. | 625941f5009cb60464c639e8 |
def create_double_wall_box(box_dimensions): <NEW_LINE> <INDENT> width = box_dimensions['width'] <NEW_LINE> height = box_dimensions['height'] <NEW_LINE> depth = box_dimensions['depth'] <NEW_LINE> thickness = box_dimensions['thickness'] <NEW_LINE> fold_margin = box_dimensions['fold_margin'] <NEW_LINE> wing = box_dimensio... | width, depth, height, thickness,
fold_margin, wing_width
returns ShapeArray | 625941f5462c4b4f79d1dd0b |
def k4curvaturefractal(cs=(-10,18,23,27),nx=None,returnfull=False,ordering='tree'): <NEW_LINE> <INDENT> cs=sorted(cs) <NEW_LINE> if not nx:nx=combinations(range(len(cs)),3) <NEW_LINE> if ordering=='tree': <NEW_LINE> <INDENT> nx=collections.deque(map(sorted,nx)) <NEW_LINE> for l in count(len(cs)): <NEW_LINE> <INDENT> i,... | Repeatedly applies Descartes' theorem to generate curvatures.
For 4 starting curvatures with the first negative, produces an
Apollonian gasket.
Ordering can be tree or sorted. | 625941f50a50d4780f6674d3 |
def add_mock_s3_data(mock_s3_fs, data, time_modified=None): <NEW_LINE> <INDENT> if time_modified is None: <NEW_LINE> <INDENT> time_modified = datetime.utcnow() <NEW_LINE> <DEDENT> for bucket_name, key_name_to_bytes in data.items(): <NEW_LINE> <INDENT> mock_s3_fs.setdefault(bucket_name, {'keys': {}, 'location': ''}) <NE... | Update mock_s3_fs (which is just a dictionary mapping bucket to
key to contents) with a map from bucket name to key name to data and
time last modified. | 625941f54527f215b584ca8d |
def exit(): <NEW_LINE> <INDENT> if no_exitfunc: <NEW_LINE> <INDENT> import atexit <NEW_LINE> atexit._clear() <NEW_LINE> <DEDENT> capture_warnings(False) <NEW_LINE> sys.exit(0) | Exit subprocess, possibly after first clearing exit functions.
If config-main.cfg/.def 'General' 'delete-exitfunc' is True, then any
functions registered with atexit will be removed before exiting.
(VPython support) | 625941f5435de62698dfe289 |
def default(self, ci='unused'): <NEW_LINE> <INDENT> if not self.component_instance.capturing: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> points = self.data['points'] <NEW_LINE> width = self.component_instance.image_width * self.component_instance.image_height <NEW_LINE> size = len(points) <NEW_LINE> pc2 = PointClou... | Publish the data of the Camera as a ROS PointCloud2 message | 625941f5596a89723608a0f3 |
def leaky_relu(x, leakiness): <NEW_LINE> <INDENT> return tf.maximum(x, leakiness * x) | Leaky RELU
Parameters
----------
x : tf.Tensor
input tensor
leakiness : float
leakiness of RELU
Returns
-------
tf.Tensor
Tensor with applied leaky RELU | 625941f5ad47b63b2c50a5bc |
def get_target_pos_row_relation(self): <NEW_LINE> <INDENT> return self.target_pos_row_relation | docstring | 625941f563f4b57ef0001742 |
def mki_(args): <NEW_LINE> <INDENT> x, = args <NEW_LINE> return x._values.new_string().from_str(bytes(to_integer(x).to_bytes())) | MKI$: return the byte representation of an int. | 625941f5d7e4931a7ee9e55c |
def didIPass(*args, **kwargs): <NEW_LINE> <INDENT> passedScores = scoreMetrics(*args, **kwargs) <NEW_LINE> didAllPass = True <NEW_LINE> for (metric, filter), passed in passedScores.iteritems(): <NEW_LINE> <INDENT> if not passed: <NEW_LINE> <INDENT> print("Failed metric, filter: %s, %s" % (metric, filter)) <NEW_LINE> di... | Did this set pass.
Returns
-------
bool
Did all of the measured and requiremd metrics pass. | 625941f58a43f66fc4b5469a |
@app.template_filter("extract_hostname") <NEW_LINE> def extract_hostname(backend): <NEW_LINE> <INDENT> return proxies.parse_backend(backend).get("hostname", "404") | Extract a hostname from a backend description. | 625941f5c4546d3d9de73076 |
def get(self): <NEW_LINE> <INDENT> directory = os.path.dirname(__file__) <NEW_LINE> values = dict((k, cgi.escape(self.request.get(k))) for k in ( 'salutation', 'receiver_name', 'feeling_type', 'thinking_activity', 'will_be', 'good_bye', 'secret_name')) <NEW_LINE> if not values['secret_name'].strip(): <NEW_LINE> <INDENT... | PostMail handler get method.
The email is generated in potentially two forms, text and HTML.
Each form of the mail has its own template each of which takes
the same parameters. The main function of this method is to
pass the form parameters to one or both of the templates and
pass the generated text to the email API. | 625941f5b5575c28eb68e642 |
def itemrecord(): <NEW_LINE> <INDENT> session.forget(response) <NEW_LINE> Query = QUERY() <NEW_LINE> RecordQuery = RECORDQUERY(Query) <NEW_LINE> return RecordQuery.setItem() | Saves a record to the database, typically organizations, projects, queries.
See also [M:RECORD.setItem][record.RECORD.setItem].
Client code: [{querytree.Tree.record}][treerecord]. | 625941f5cb5e8a47e48b80db |
def load_train_data(file_name): <NEW_LINE> <INDENT> trainingFileList = os.listdir(file_name) <NEW_LINE> m = len(trainingFileList) <NEW_LINE> trainMat = np.zeros((m,1024)) <NEW_LINE> for i in range(m): <NEW_LINE> <INDENT> fileNameStr = trainingFileList[i] <NEW_LINE> trainMat[i,:] = img2vector(file_name + '/%s'%fileNameS... | 导入训练数据
input:file_name(str):训练数据存储文件夹
output:trainMat(array):训练数据 | 625941f5a4f1c619b28b0665 |
def get_form(self, form_class): <NEW_LINE> <INDENT> self.form = super(SmartFormMixin, self).get_form(form_class) <NEW_LINE> fields = list(self.derive_fields()) <NEW_LINE> exclude = self.derive_exclude() <NEW_LINE> exclude += self.derive_readonly() <NEW_LINE> for field in exclude: <NEW_LINE> <INDENT> if field in self.fo... | Returns an instance of the form to be used in this view. | 625941f5046cf37aa974d37d |
def download_box_file(file_name, file_id, client, destination_file_name=None): <NEW_LINE> <INDENT> local_path = os.path.normpath(f'{os.getcwd()}/{destination_file_name}') <NEW_LINE> with open(local_path, 'wb') as new_blob: <NEW_LINE> <INDENT> client.file(file_id).download_to(new_blob) <NEW_LINE> <DEDENT> print(f'{file_... | Download a selected file from Box to local storage in
the current working directory. | 625941f56e29344779a62c4d |
def delete_files(self, keep_mef=True): <NEW_LINE> <INDENT> delete_keys = [] <NEW_LINE> for one_key in self.ext_names.keys(): <NEW_LINE> <INDENT> if keep_mef and one_key == 'MEF': <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> delete_keys.append(one_key) <NEW_LINE> <DEDENT> for one_key in delete_keys: <NEW_LINE> <INDE... | Delete all files | 625941f5bd1bec0571d90c6b |
def onButtonPressed(self, event): <NEW_LINE> <INDENT> if event.xdata and event.ydata: <NEW_LINE> <INDENT> self.currentStartPoint =(int(round(event.xdata)),int(round(event.ydata))) | ‘key_press_event’ KeyEvent - key is pressed
Retrieve the actual coordinate of point starting a line
Solitaire UI is in state moveStarted true
:return: | 625941f57c178a314d6efaa7 |
def writePayload(self, stream, pdu): <NEW_LINE> <INDENT> stream.write(pdu.payload) | Write the PDU payload.
:type stream: BytesIO
:type pdu: SecurityPDU | 625941f566673b3332b926cd |
def _build_windows_actions(): <NEW_LINE> <INDENT> actions = defaultdict(lambda: 'unknown') <NEW_LINE> actions['Delete'] = 'deleted' <NEW_LINE> actions['Read Control'] = 'read' <NEW_LINE> actions['Write DAC'] = 'acl_modified' <NEW_LINE> actions['Write Owner'] = 'modified' <NEW_LINE> actions['Synchronize'] = 'modified' <... | Helper function that builds the actions defaultdict for Windows - win_pulsar | 625941f5b5575c28eb68e643 |
def initialize_from_seed(self, seed, mode=0): <NEW_LINE> <INDENT> self.state = [[] for _ in range(self.n)] <NEW_LINE> self.index = self.n <NEW_LINE> self.state[0] = seed <NEW_LINE> if mode == 0: <NEW_LINE> <INDENT> for i in range(1, self.n): <NEW_LINE> <INDENT> pre_state = self.f * (self.state[i-1] ^ (self.state[i-1] >... | initialize generator from seed
modes:
0 :: reference implementation
1 :: python implementation [EXPERIMENTAL] | 625941f560cbc95b062c6b80 |
def _get_wrapped_script(self, script): <NEW_LINE> <INDENT> def _wrapped_script(*args, **kwargs): <NEW_LINE> <INDENT> timeout_timer = None <NEW_LINE> if self.timeout: <NEW_LINE> <INDENT> def timeout_handler(): <NEW_LINE> <INDENT> self._timedout = True <NEW_LINE> self._result = TestResult( TestResult.FAILED, 'test timedo... | Wraps the given script in a function that handles script results and
errors. | 625941f5711fe17d82542999 |
def copy(self, entity_name, new_name): <NEW_LINE> <INDENT> view = self.navigate_to(self, 'Copy', entity_name=entity_name) <NEW_LINE> view.new_name.fill(new_name) <NEW_LINE> view.create.click() <NEW_LINE> view.flash.assert_no_error() <NEW_LINE> view.flash.dismiss() | Make a copy of existing content view | 625941f530c21e258bdfaae1 |
def get_model_name(jobs): <NEW_LINE> <INDENT> return re.search("modelname='(.*?)'", next(iter(jobs.values()))).group(1) | Get a job and find the model name | 625941f51f037a2d8b946838 |
def setUp(self) -> None: <NEW_LINE> <INDENT> cache.clear() | Clears the cache before each test | 625941f5dc8b845886cb5b73 |
def getSponsor(self): <NEW_LINE> <INDENT> stype = self.data.sponsorType <NEW_LINE> if stype == 'Major': <NEW_LINE> <INDENT> sponsorType = 'major_sponsor' <NEW_LINE> <DEDENT> elif stype == 'Minor': <NEW_LINE> <INDENT> sponsorType = 'minor_sponsor' <NEW_LINE> <DEDENT> elif stype == 'Second Minor': <NEW_LINE> <INDENT> spo... | return the page/section sponsor | 625941f5ff9c53063f47c82c |
def get_chunks(self): <NEW_LINE> <INDENT> counts = self.filediff.get_line_counts() <NEW_LINE> if (self.filediff.binary or self.filediff.source_revision == '' or ((self.filediff.is_new or self.filediff.deleted or self.filediff.moved or self.filediff.copied) and counts['raw_insert_count'] == 0 and counts['raw_delete_coun... | Return the chunks for the given diff information.
If the file is binary or is an added or deleted 0-length file, or if
the file has moved with no additional changes, then an empty list of
chunks will be returned.
If there are chunks already computed in the cache, they will be
yielded. Otherwise, new chunks will be ge... | 625941f58da39b475bd655b9 |
def _refresh_token(self): <NEW_LINE> <INDENT> if self.refresh_from_memcache: <NEW_LINE> <INDENT> key="appnexus{}".format(self.env) <NEW_LINE> token = self.mcache.get(key) <NEW_LINE> if not token: <NEW_LINE> <INDENT> raise AuthException("Unable to get token from cache with {}".format(key)) <NEW_LINE> <DEDENT> self.token... | gets a token from memcache, if so configured, or goes out to get it from
the appnexus auth api. Note that we do NOT attempt to store the token in memcache
here; the whole point of memcache is to avoid concurrent auth calls: if memcache is
used, there ought to be a separate process to populate it | 625941f52c8b7c6e89b35df8 |
def index(request): <NEW_LINE> <INDENT> if request.method == "GET": <NEW_LINE> <INDENT> return render(request, 'student/index.html') <NEW_LINE> <DEDENT> elif request.method == "POST": <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> pass | :param request:
:return: | 625941f566656f66f7cbc7e9 |
def __init__(self, show_deleted=None, *args, **kwargs): <NEW_LINE> <INDENT> super(SyncedModelManager, self).__init__(*args, **kwargs) <NEW_LINE> self.show_deleted = show_deleted is None and getattr(settings, "SHOW_DELETED_OBJECTS", False) or show_deleted | Pass in 'show_deleted=True' to return a model manager that will also show
deleted objects in the queryset. | 625941f53eb6a72ae02ecb2c |
def _compute_gradients(self, loss, var_list, grad_loss=None): <NEW_LINE> <INDENT> with backprop.GradientTape() as tape: <NEW_LINE> <INDENT> if not callable(var_list): <NEW_LINE> <INDENT> tape.watch(var_list) <NEW_LINE> <DEDENT> loss_value = loss() <NEW_LINE> <DEDENT> if callable(var_list): <NEW_LINE> <INDENT> var_list ... | Compute gradients of `loss` for the variables in `var_list`.
This is the first part of `minimize()`. It returns a list
of (gradient, variable) pairs where "gradient" is the gradient
for "variable". Note that "gradient" can be a `Tensor`, an
`IndexedSlices`, or `None` if there is no gradient for the
given variable.
... | 625941f5091ae35668667590 |
def info_classes(self, focal_node_id): <NEW_LINE> <INDENT> focal_node = self.tree.tree_sequence.node(focal_node_id) <NEW_LINE> classes = set() <NEW_LINE> classes.add(f"node n{focal_node_id}") <NEW_LINE> if focal_node.individual != NULL: <NEW_LINE> <INDENT> classes.add(f"i{focal_node.individual}") <NEW_LINE> <DEDENT> if... | For a focal node id, return a set of classes that encode this useful information:
"a<X>" or "root": where <X> == id of immediate ancestor (parent) node
"n<Y>": where <Y> == focal node id
"m<A>": where <A> == mutation id
"s<B>": where <B> == site id of all mutations | 625941f596565a6dacc8fd05 |
def _list(self): <NEW_LINE> <INDENT> raise NotImplemented | Subclasses should override. | 625941f576d4e153a657f16f |
def user(): <NEW_LINE> <INDENT> db.auth_user.email.writable=(request.args(0)!='profile') <NEW_LINE> db.auth_user.first_name.writable=(request.args(0)!='profile') <NEW_LINE> db.auth_user.last_name.writable=(request.args(0)!='profile') <NEW_LINE> db.auth_user.introduction.writable=(request.args(0)!='register') <NEW_LINE>... | exposes:
http://..../[app]/default/user/login
http://..../[app]/default/user/logout
http://..../[app]/default/user/register
http://..../[app]/default/user/profile
http://..../[app]/default/user/retrieve_password
http://..../[app]/default/user/change_password
http://..../[app]/default/user/manage_users (requires members... | 625941f51f5feb6acb0c5186 |
def remove_account(self, account): <NEW_LINE> <INDENT> self._accounts.remove(account) | Will be able to remove accounts from the _accounts property of
the MarketSegment class | 625941f53346ee7daa2b33af |
def deleteDuplicates(self, head): <NEW_LINE> <INDENT> cur = head <NEW_LINE> while cur is not None and cur.next is not None: <NEW_LINE> <INDENT> if cur.next.val == cur.val: <NEW_LINE> <INDENT> cur.next = cur.next.next <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> cur = cur.next <NEW_LINE> <DEDENT> <DEDENT> return head | :type head: ListNode
:rtype: ListNode | 625941f523849d37ff7b36c6 |
@subjectToTracking(fnLoc=True, fnEntry=True, fnExit=True) <NEW_LINE> def cmndExampleMenuItem( commandLine, icmName=None, verbosity='basic', comment='none', icmWrapper=None, ): <NEW_LINE> <INDENT> G_myFullName = sys.argv[0] <NEW_LINE> G_myName = os.path.basename(G_myFullName) <NEW_LINE> if comment == 'none': <NEW_LINE> ... | vebosity is one of: 'none', 'little', 'some', 'full'
| 625941f594891a1f4081c0e9 |
def negate(self): <NEW_LINE> <INDENT> self.x = -self.x <NEW_LINE> self.y = -self.y <NEW_LINE> self.z = -self.z <NEW_LINE> return self | Method to negate the current vector in place. | 625941f5004d5f362079a96b |
def currentConstraint(self): <NEW_LINE> <INDENT> sel = self.viewConstraints.selectionModel() <NEW_LINE> indexes = sel.selectedRows() <NEW_LINE> if len(indexes) == 0: <NEW_LINE> <INDENT> QMessageBox.information(self, self.tr("DB Manager"), self.tr("No constraints were selected.")) <NEW_LINE> return -1 <NEW_LINE> <DEDENT... | returns row index of selected index | 625941f523849d37ff7b36c7 |
def get_jk_kmean(map1, map2, map2_ran, mask, jk_label, bias_model, nn): <NEW_LINE> <INDENT> jk_label = np.load(jk_label)['labels'] <NEW_LINE> N_jk = int(np.max(jk_label)+1) <NEW_LINE> jk_sample = [] <NEW_LINE> for i in range(N_jk): <NEW_LINE> <INDENT> mask_temp = mask*1.0 <NEW_LINE> mask_temp[jk_label==i] = 0 <NEW_LINE... | Kmeans gridding for jackknife samples. | 625941f5aad79263cf391087 |
def to_dict(self) -> dict: <NEW_LINE> <INDENT> if self.is_set: <NEW_LINE> <INDENT> if self._comment: <NEW_LINE> <INDENT> return {self._check_name: f"{self.checked_target}: " f"{self._verdict.value}: " f"{self._comment}"} <NEW_LINE> <DEDENT> return { self._check_name: f"{self.checked_target}: {self._verdict.value}"} <NE... | Return dict representation of check
Returns: | 625941f599cbb53fe6793221 |
def _new_packet_cb(self, packet): <NEW_LINE> <INDENT> chan = packet.channel <NEW_LINE> if (chan != 0): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> payload = packet.data[1:] <NEW_LINE> if (self.state == GET_TOC_INFO): <NEW_LINE> <INDENT> if self._useV2: <NEW_LINE> <INDENT> [self.nbr_of_items, self._crc] = struct.unpa... | Handle a newly arrived packet | 625941f5287bf620b61d409c |
def _before(self, *args, **kw): <NEW_LINE> <INDENT> super(self.__class__, self)._before(args, kw) <NEW_LINE> api = UserApi(tg.tmpl_context.current_user) <NEW_LINE> user_id = tg.request.controller_state.routing_args.get('user_id') <NEW_LINE> user = api.get_one(user_id) <NEW_LINE> tg.tmpl_context.user_id = user_id <NEW_L... | Instantiate the current workspace in tg.tmpl_context
:param args:
:param kw:
:return: | 625941f576e4537e8c351cb5 |
def setUp(self): <NEW_LINE> <INDENT> self.list = dl.List(self.dl) | Initialize the test case | 625941f5442bda511e8bea4b |
def prop_exists(self, prop_name): <NEW_LINE> <INDENT> return hasattr(self.aq_base, prop_name) | The safe way to check whether a schema property exists on object.
(bypasses properties from context throughout acquisition)
E.g.
<span tal:condition='here/topics'> may return true if you happen
to have a 'topics' container in your context. Always use
<span tal:condition='python:here.prop_exists('topics')'> | 625941f5a17c0f6771cbe68b |
def format_value(self, value): <NEW_LINE> <INDENT> if len(value) > 0: <NEW_LINE> <INDENT> if value[0] == ".": <NEW_LINE> <INDENT> value = self.package + value <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> v_dot = value.find(".") <NEW_LINE> if v_dot == 0: <NEW_LINE> <INDENT> value = self.package + "." + value <NEW_LINE>... | Format a value with packagename, if not already set
:param value:
:return: | 625941f526068e7796caf326 |
@pytest.mark.skip <NEW_LINE> def test_numpydoc_function(): <NEW_LINE> <INDENT> doc = FunctionDoc(func=test_numpydoc_function.__doc__) <NEW_LINE> assert doc["Parameters"] == [ Parameter(name="a", type="int, default: 5", desc=["Does something cool"]), Parameter(name="b", type="str", desc=["Wow"]), ] <NEW_LINE> assert doc... | Summary line.
Extended description of function.
Parameters
----------
arg1 : int, default: 5
Description of arg1
arg2 : str
Description of arg2
arg3 : str
The [JMESpath](https://jmespath.org) query.
Returns
-------
bool
Description of return value
Raises
------
AttributeError
The ``Raises`` sect... | 625941f5498bea3a759ba0ea |
def merge(self): <NEW_LINE> <INDENT> self.frame["merged_to_next"] = not self.frame["merged_to_next"] | Merge a frame with the one below. | 625941f5851cf427c661ab46 |
def send_managers_mail(attachment_content, attachment_name, subject): <NEW_LINE> <INDENT> send_mail(MANAGERS_MAIL_RECIPIENT, attachment_content, attachment_name, subject) | Send a mail for manager's user.
:param attachment_content: attachment content.
:param attachment_name: attachment name.
:param subject: mail subject.
| 625941f57b180e01f3dc4e2c |
def resample_reid_params(size=None): <NEW_LINE> <INDENT> kdefile = Path(__file__).parent / "reid19_params.pkl" <NEW_LINE> with open(kdefile, "rb") as f: <NEW_LINE> <INDENT> kde = dill.load(f) <NEW_LINE> <DEDENT> if size is None: <NEW_LINE> <INDENT> samples = kde["full"].resample(1) <NEW_LINE> params = { "R0": samples[0... | Resample the Reid+2019 rotation curve parameters within their
uncertainties using the Wenger+2020 kernel density estimator
to include parameter covariances.
Parameters:
size :: integer
The number of random samples to generate. If None, generate
only one sample and return a scalar.
Returns: params
params :... | 625941f526238365f5f0f4b3 |
def turn_on(self,): <NEW_LINE> <INDENT> self.logger.info("Received diy/system/who ON, publish: %s ", self.default_who_message) <NEW_LINE> if not self.waiting_for_client: <NEW_LINE> <INDENT> self.client.publish(self.status_topic, self.default_who_message, 0, True) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.logge... | Response to MQTT diy/system/who message. | 625941f5236d856c2ad44e21 |
def L2_norm(u, v): <NEW_LINE> <INDENT> return sqrt(sum((ui - vi) ** 2.0 for ui, vi in izip(u, v))) | L2 hash metric - Euclidean distance | 625941f54e696a04525c9a8b |
def expression(self, ast, code): <NEW_LINE> <INDENT> expression = self.__walk_tree ( { 'symbol': self.symbol, 'string': self.string, 'variable_string': self.variable_string, 'object_dereference': self.object_dereference, 'array': self.array, 'modifier': self.modifier }, ast, "" ) <NEW_LINE> for k, v in self.replacement... | A top level expression in Smarty that statements
are built out of mostly expressions and/or symbols (which are
encompassed in the expression type. | 625941f507d97122c4178ed8 |
def getAmplitude(histo): <NEW_LINE> <INDENT> Max = np.max(histo) <NEW_LINE> Min = np.min(histo) <NEW_LINE> print('Min: %f \n Max: %f' % (Min,Max)) <NEW_LINE> return Max-Min | return the Amplitude of an timedepented-Variable | 625941f5a8370b7717052eda |
def _set_paths(self, raw_path, path_vars): <NEW_LINE> <INDENT> self.paths = [] <NEW_LINE> for path2 in expand_multi_var(raw_path, path_vars): <NEW_LINE> <INDENT> path3 = os.path.expanduser(os.path.expandvars(path2)) <NEW_LINE> if os.name == 'nt' and path3: <NEW_LINE> <INDENT> path3 = os.path.normpath(path3) <NEW_LINE> ... | Set the list of paths to work on | 625941f566673b3332b926ce |
def concentration_of_charge_carriers(self): <NEW_LINE> <INDENT> nk = self.medium.nk <NEW_LINE> nv = self.medium.nv <NEW_LINE> n_e = np.sum(self.rho_diagonal[:, nv:]) <NEW_LINE> n_h = np.sum(1 - self.rho_diagonal[:, :nv]) <NEW_LINE> normalization_factor = self.medium.spin_factor / (self.medium.volume * nk) <NEW_LINE> re... | Return the concentration of charge carriers.
The function returns a tuple with two numbers: the first one is the
concentration of electrons, and the second one is the concentration
of holes. Ideally, the two numbers must be the same, but they generally
differ due to discretization errors. | 625941f55e10d32532c5f561 |
def find_webhook_with_http_info(self, webhook_id, **kwargs): <NEW_LINE> <INDENT> all_params = ['webhook_id'] <NEW_LINE> all_params.append('callback') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE> params = locals() <NEW_LINE> for key, val in iteritems(... | Retrieve a Webhook
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(response):
>>> pprint(response)
>>>
>>> thread = api.find_webhook_with_http_info(webhook_id, ca... | 625941f5293b9510aa2c38cd |
def create_snmp(self, snmp_community, action_map=None, error_map=None): <NEW_LINE> <INDENT> return CommandTemplateExecutor(cli_service=self._cli_service, command_template=aireos_enbl_disbl_snmp.CREATE_SNMP, action_map=action_map, error_map=error_map).execute_command(snmp_community=snmp_community) | Enable SNMP on the device
:param snmp_community: community name
:param action_map: actions will be taken during executing commands, i.e. handles yes/no prompts
:param error_map: errors will be raised during executing commands, i.e. handles Invalid Commands errors | 625941f50a366e3fb873ee5d |
def list_cash_drawer_shifts(self, location_id, sort_order=None, begin_time=None, end_time=None, limit=None, cursor=None): <NEW_LINE> <INDENT> _url_path = '/v2/cash-drawers/shifts' <NEW_LINE> _query_builder = self.config.get_base_uri() <NEW_LINE> _query_builder += _url_path <NEW_LINE> _query_parameters = { 'location_id'... | Does a GET request to /v2/cash-drawers/shifts.
Provides the details for all of the cash drawer shifts for a location
in a date range.
Args:
location_id (string): The ID of the location to query for a list
of cash drawer shifts.
sort_order (SortOrder, optional): The order in which cash drawer
s... | 625941f526238365f5f0f4b4 |
def export_test_charts(self, test_id, api="/api/tests/", path="./"): <NEW_LINE> <INDENT> export_url = self._url+api+test_id+"/export_charts" <NEW_LINE> LOGGER.info("export all charts to CSV for test: %s", export_url) <NEW_LINE> postfix = ".zip" <NEW_LINE> log_name = path + str(test_id) + postfix <NEW_LINE> content = ut... | Export test charts into a file
:param test_id: test id
:param api: REST API for a test
:param path: path to save test result
:return: :str: file name containing full path
:rtype: str | 625941f5adb09d7d5db6cdc9 |
def add_student(student_id, first_name, last_name, password, email_address, course_list, view_url, pic_url): <NEW_LINE> <INDENT> new_User = User.objects.get_or_create(email = email_address)[0] <NEW_LINE> new_User.first_name = first_name <NEW_LINE> new_User.last_name = last_name <NEW_LINE> new_User.password = password <... | Enable creation of a new user, Return the newly added student. | 625941f58c0ade5d55d3effe |
def __init__(self, body='Session Expired'): <NEW_LINE> <INDENT> HttpError.__init__(self, 408, body) | Inits error
:param body: Text to be supplied with this error | 625941f5f8510a7c17cf9d3f |
def deploy_contract_tx(self, options): <NEW_LINE> <INDENT> tx = Transaction(self, None) <NEW_LINE> if not options: <NEW_LINE> <INDENT> tx.tx_json['obj'] = Exception('invalid options type') <NEW_LINE> return tx <NEW_LINE> <DEDENT> account = options['account'] <NEW_LINE> amount = options['amount'] <NEW_LINE> payload = op... | 创建部署合约对象
* @param options
* account, required
* amount, required
* payload, required
* @returns {Transaction} | 625941f57d847024c06be8ff |
def sendToParent(self, continuous=True, cancel=False): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self.parentCouchUrl and self.queueUrl: <NEW_LINE> <INDENT> self.server.replicate(source="%s" % self.inbox.name, destination=self.parentCouchUrlWithAuth, filter='WorkQueue/queueFilter', query_params={'childUrl': self.q... | Replicate to parent couch - blocking: used only int test | 625941f5eab8aa0e5d26e197 |
def update_content(self, page_id: str, html_markup: str = None, wiki_markup: str = None, update_type: str = UPDATE_REPLACE): <NEW_LINE> <INDENT> page = self.get_content(page_id, expand=("space", "body.view", "version", "container", "ancestors")) <NEW_LINE> if not page: <NEW_LINE> <INDENT> raise ConfluenceContentNotFoun... | Update a page either by replacing the entire page or prepending or appending content
:param page_id: The page_id of the page to update
:param html_markup: The HTML markup to update with ('storage' representation)
:param wiki_markup: The Wiki markup to update with ('wiki' representation)
:param update_type: Whether to ... | 625941f5d53ae8145f87a8a0 |
def test_cart_update(self): <NEW_LINE> <INDENT> login = self.autheniticate() <NEW_LINE> token = json.loads(login.data.decode()).get('token') <NEW_LINE> self.app.post(product_url, data=json.dumps(self.product_data), headers=dict(Authorization="Bearer " + token), content_type='application/json') <NEW_LINE> self.app.post(... | Test for the cart update endpoint. | 625941f524f1403a9260119e |
@app.route('/from_cloud/<filename>') <NEW_LINE> def from_cloud(filename, url): <NEW_LINE> <INDENT> return redirect(url) | Server url for file saved on server | 625941f5e5267d203edce2d2 |
def initial_2plot(data1, data2, transpose = False): <NEW_LINE> <INDENT> if transpose == True: <NEW_LINE> <INDENT> dataA = initial_processdata(data1, transpose = True) <NEW_LINE> dataB = initial_processdata(data2, transpose = True) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> dataA = initial_processdata(data1) <NEW_LIN... | Basic pair-plot function; will likely not be extended. Because every
set of data needs a particular set of code.
data1 and data2: (2-D numpy arrays)
::: The data which needs to be plotted; the initial_processdata
function is called. | 625941f5be383301e01b5ab6 |
def testFloat(self, value): <NEW_LINE> <INDENT> return self.test(value, float) | Tests value for being a float
:param value:
:return: | 625941f54e4d5625662d4a0b |
def from_response(response, body, url, method=None): <NEW_LINE> <INDENT> cls = _code_map.get(response.status_code, ClientException) <NEW_LINE> try: <NEW_LINE> <INDENT> kwargs = yaml.safe_load(body) <NEW_LINE> <DEDENT> except yaml.YAMLError as e: <NEW_LINE> <INDENT> kwargs = None <NEW_LINE> LOG.debug('Could not convert ... | Return an instance of a ``ClientException`` or subclass based on a
request's response. | 625941f53cc13d1c6d3c79b4 |
def serve_static_content(self, project_id: str, bucket_name: str, static_content_dir: str): <NEW_LINE> <INDENT> self._static_content_serve_client.collect_static_content() <NEW_LINE> self._static_content_serve_client.create_bucket(project_id, bucket_name) <NEW_LINE> self._static_content_serve_client.make_bucket_public(b... | Do all the work for serving static content of the provided project.
The static content is served with a public Google Cloud Storage Bucket.
Args:
project_id: Id of GCP project.
bucket_name: Name of the bucket to create and serve static content.
static_content_dir: Absolute path of the directory for static... | 625941f55fcc89381b1e1d02 |
def set_max_noutput_items(self, *args, **kwargs): <NEW_LINE> <INDENT> return _blocks_swig5.repack_bits_bb_sptr_set_max_noutput_items(self, *args, **kwargs) | set_max_noutput_items(repack_bits_bb_sptr self, int m) | 625941f591f36d47f21acb37 |
def ReadConvolutionCoefficients(conv, array): <NEW_LINE> <INDENT> return lib.vxReadConvolutionCoefficients(conv, array) | :brief: Gets the convolution data (copy).
:param: [in] conv The reference to the convolution.
:param: [out] array The array to place the convolution.
:see: vxQueryConvolution and *VX_CONVOLUTION_ATTRIBUTE_SIZE* to get the
needed number of bytes of the array.
:return: A *vx_status_e* enumeration.
:ingroup: group_convolu... | 625941f57047854f462a1a3f |
def test_can_shutdown_slave_only(self): <NEW_LINE> <INDENT> master_store = IMasterStore(Person) <NEW_LINE> slave_store = ISlaveStore(Person) <NEW_LINE> master_store.get(Person, 1) <NEW_LINE> slave_store.get(Person, 1) <NEW_LINE> self.pgbouncer_fixture.stop() <NEW_LINE> master_store.get(Person, 2) <NEW_LINE> self.assert... | Confirm that this TestCase's test infrastructure works as needed.
| 625941f5a05bb46b383ece59 |
def _perform_http_request( self, *, body: Dict[str, any], headers: Dict[str, str] ) -> WebhookResponse: <NEW_LINE> <INDENT> body = json.dumps(body) <NEW_LINE> headers["Content-Type"] = "application/json;charset=utf-8" <NEW_LINE> if self.logger.level <= logging.DEBUG: <NEW_LINE> <INDENT> self.logger.debug( f"Sending a r... | Performs an HTTP request and parses the response.
:param url: a complete URL to send data (e.g., https://hooks.slack.com/XXX)
:param body: request body data
:param headers: complete set of request headers
:return: API response | 625941f5a17c0f6771cbe68c |
def test_feed(self, client, root): <NEW_LINE> <INDENT> blog = self.type.model(node=root, title="blog", state="published").save() <NEW_LINE> spoke = blog.spoke() <NEW_LINE> e1 = ValveEntryType.model(title="e1", state="published", node=root.add("e1")).save() <NEW_LINE> e2 = ValveEntryType.model(title="e2", state="publish... | the feed() method is used by wheelcms_rss | 625941f5167d2b6e312191d2 |
def coin_snapshot(self, fsym, tsym): <NEW_LINE> <INDENT> self._is_params_valid(fsym=fsym, tsym=tsym) <NEW_LINE> return self._fetch_data(self.COIN_SNAPSHOT_URL+'?fsym='+fsym+'&tsym='+tsym) | https://www.cryptocompare.com/api/#-api-data-coinsnapshot-
Keyword arguments:
fsym - The symbol of the currency you want to get that for
tsym - The symbol of the currency that data will be in. | 625941f53617ad0b5ed68534 |
def parse_east_asian_language_page(self, response): <NEW_LINE> <INDENT> east_asian_sel = University() <NEW_LINE> sel = Selector(response) <NEW_LINE> name = sel.xpath('//h1[@class="page-title"]/text()').extract() <NEW_LINE> if name: <NEW_LINE> <INDENT> east_asian_sel['name'] = name <NEW_LINE> <DEDENT> title = sel.xpath(... | Parse faculty members profile from the department of East Asian Languages and Culture | 625941f5f548e778e58cdbbe |
def update_remote(self): <NEW_LINE> <INDENT> self._execute(self._cmd_update_remote) | Updates remote repository. | 625941f5711fe17d8254299a |
@services_torp.route('/torpfleet', methods = ['GET', 'POST']) <NEW_LINE> @services_torp.route('/torpfleet/', methods = ['GET', 'POST']) <NEW_LINE> def npsi(): <NEW_LINE> <INDENT> if request.method == 'GET': <NEW_LINE> <INDENT> return render_template('services-npsi-landing.html') <NEW_LINE> <DEDENT> elif request.method ... | Form for sending Slack invites for the WDS BLOPS/NPSI community | 625941f57047854f462a1a40 |
def open_spider(self, spider): <NEW_LINE> <INDENT> self.dbcon = pymysql.connect(host=self.mysql_host, user=self.mysql_user, passwd=self.mysql_password, db=self.mysql_db, port=self.mysql_port, charset=self.mysql_charset) <NEW_LINE> self.cursor = self.dbcon.cursor() <NEW_LINE> print('mysql:连接mysql') <NEW_LINE> print(self... | 连接mysql | 625941f5925a0f43d254a4bb |
def configuration(self, item=None): <NEW_LINE> <INDENT> count, startdate, starttime = self.xfer('d', 24).split() <NEW_LINE> start = " ".join([startdate, starttime]) <NEW_LINE> mode, interval, _date, _time = self.xfer("o", 24).split() <NEW_LINE> configuration = { 'count' : int(count), "start" : datetime.datetime.str... | Return a dictionary (or an element from this dictionary) with the
current logger configuration.
Args:
item: Either the name of an item to return or None to return the
full dictionary. | 625941f57cff6e4e81117fc3 |
def check_if_vlan_interface_exists(session, vlan_interface, cluster=None, host=None): <NEW_LINE> <INDENT> if host is None: <NEW_LINE> <INDENT> host_mor = vm_util.get_host_ref(session, cluster) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> host_mor = host <NEW_LINE> <DEDENT> physical_nics_ret = session._call_method(vuti... | Checks if the vlan_interface exists on the esx host. | 625941f5ab23a570cc2507c6 |
def multbstage(nb): <NEW_LINE> <INDENT> doublemod(nb) <NEW_LINE> caddmod(nb) <NEW_LINE> with declare('multbstage{}'.format(nb), '{s},{a},{n},{z},g,x'.format(s=arg_list('s',nb), a=arg_list('a',nb), n=arg_list('n',nb), z=arg_list('z',nb+2))) as src: <NEW_LINE> <INDENT> src.append(' caddmod{nb} {s},{a},{n},{z},x;'.format... | Basic modular multiplication module stage | 625941f54a966d76dd551654 |
def backward(self, input, grad_output): <NEW_LINE> <INDENT> grad_loss_input = np.matmul(grad_output, self.weights.T) <NEW_LINE> grad_loss_weights = np.matmul(input.T, grad_output) <NEW_LINE> grad_loss_biases = np.matmul(np.ones(input.shape[0]), grad_output) <NEW_LINE> self.weights -= self.learning_rate * grad_loss_weig... | input shape: [batch, input_units]
grad_output: [batch, output units]
Returns: grad_input, gradient of output w.r.t input | 625941f5283ffb24f3c55f38 |
def generate_timing_response(arguments): <NEW_LINE> <INDENT> timing_set = Timing.objects.filter(**arguments) <NEW_LINE> if timing_set.count() == 0: <NEW_LINE> <INDENT> return False, HttpResponse("Did not find anything matching that query.") <NEW_LINE> <DEDENT> timing_set_values = timing_set.values("start_time", "end_ti... | Generate data on number of seconds each submission has taken
Input:
Arguments to query on, title of graph
Output:
PNG image | 625941f5c4546d3d9de73078 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.