code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def test_user_profile_update_with_invalid_jwt_part_fails(self, client): <NEW_LINE> <INDENT> response = client.put(f'{API_BASE_URL}/users/profile', data={}, content_type=FORM_CONTENT_TYPE, headers={'Authorization': 'Bearer token'}) <NEW_LINE> assert response.status_code == 400 <NEW_LINE> assert response.json['status'] =... | Testing User profile update with invalid jwt part | 625941cbcc40096d61595a27 |
def _format (self, n, address = False): <NEW_LINE> <INDENT> spec = '%%0*%c' % ('d' if self.base == 10 else 'x') <NEW_LINE> digits = self.address_digits if address else self.word_digits <NEW_LINE> return spec % (digits, n) | Internal: Format the contents of a register for pretty printing. | 625941cb56ac1b37e62642a6 |
def _store(self): <NEW_LINE> <INDENT> dir = os.path.dirname(self._filename) <NEW_LINE> if dir and not os.path.isdir(dir): <NEW_LINE> <INDENT> os.makedirs(dir) <NEW_LINE> <DEDENT> with open(self._filename, 'w') as fd: <NEW_LINE> <INDENT> yaml.safe_dump(dict(self), fd) | store dict data into the current object | 625941cbd53ae8145f87a347 |
def test_checking_valid_operations(self): <NEW_LINE> <INDENT> class EqualityOperand(Operand): <NEW_LINE> <INDENT> operations = set(["equality"]) <NEW_LINE> def to_python(self, value, context): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def equals(self, value, context): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> <DE... | Valid operations should just work. | 625941cb0a50d4780f666f68 |
def is_valid_hex(hex): <NEW_LINE> <INDENT> if hex is None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if HEX_REGEX.search(hex): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False | Validate hexadecimal color code. | 625941cb4428ac0f6e5ba8c8 |
def __asbase64(self, msg): <NEW_LINE> <INDENT> return (base64.b64encode(msg)).decode("utf-8") | Encodes a message in base64 and then converts it to a string. | 625941cb4d74a7450ccd429a |
def p_expr_uminus(p): <NEW_LINE> <INDENT> p[0] = -p[2] | numeric_expression : MINUS numeric_expression %prec UMINUS | 625941cb2c8b7c6e89b35897 |
def interactivity(self, min_val=None, max_val=None, qt_app=None): <NEW_LINE> <INDENT> from .seed_editor_qt import QTSeedEditor <NEW_LINE> from PyQt4.QtGui import QApplication <NEW_LINE> if min_val is None: <NEW_LINE> <INDENT> min_val = np.min(self.img) <NEW_LINE> <DEDENT> if max_val is None: <NEW_LINE> <INDENT> max_val... | Interactive seed setting with 3d seed editor | 625941cbb830903b967e99e2 |
def marginal(self, rvar): <NEW_LINE> <INDENT> clique = self.select_clique_with(rvar) <NEW_LINE> undesired = set(clique.scope) - {rvar} <NEW_LINE> return Factor.marginalize(clique.emit(), undesired) | Return the marginal over all but the input RandomVariable.
This is a Factor whose scope is just [rvar]. Only well-defined
when the model is calibrated. | 625941cb5e10d32532c5effd |
def getForegroundOverride(self, value): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> value = float(value) <NEW_LINE> if value > 0: <NEW_LINE> <INDENT> color = Qt.red <NEW_LINE> <DEDENT> elif value < 0: <NEW_LINE> <INDENT> color = Qt.darkGreen <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> color = None <NEW_LINE> <DEDENT... | 可由子类重载,这样可以根据不同的值设置不同的前景色 | 625941cbadb09d7d5db6c866 |
def hook_function(project, ea, cls): <NEW_LINE> <INDENT> project.hook(ea, cls(project=project)) | Hook the function `ea` with the SimProcedure `cls`. | 625941cb283ffb24f3c559d8 |
def get_command(self) -> str: <NEW_LINE> <INDENT> return 'item' | Returns the command of this node, i.e. item. | 625941cbeab8aa0e5d26dc2e |
def make_config(settings): <NEW_LINE> <INDENT> s = '' <NEW_LINE> for section, defs in six.iteritems(settings): <NEW_LINE> <INDENT> s += '[%s]\n' % section <NEW_LINE> for key, value in six.iteritems(defs): <NEW_LINE> <INDENT> s += '%s = %s\n' % (key, value) <NEW_LINE> <DEDENT> <DEDENT> return s | Generate a config file string from a settings object. | 625941cbf9cc0f698b1406d2 |
def test_save(self): <NEW_LINE> <INDENT> comm1 = 'Schedule (non-pillar items) saved to ///schedule.conf.' <NEW_LINE> with patch.dict(schedule.__opts__, {'config_dir': '', 'schedule': {}, 'default_include': '/tmp'}): <NEW_LINE> <INDENT> self.assertDictEqual(schedule.save(), {'comment': comm1, 'result': True}) | Test if it save all scheduled jobs on the minion. | 625941cb596a897236089b97 |
def method_inheritdocstring(mthd): <NEW_LINE> <INDENT> if not mthd.__doc__: <NEW_LINE> <INDENT> pass | Use as decorator on a method to inherit doc from parent method of same name | 625941cb046cf37aa974ce1f |
def _save_data(self, private_key, certificate, root_ca): <NEW_LINE> <INDENT> self._save_private_key(private_key) <NEW_LINE> self._save_certificate_pem(certificate) <NEW_LINE> self._save_root_ca_crt(root_ca) | "
Saves data to the device storage | 625941cba05bb46b383ec8f8 |
def add_cotizacionmueble(request, idcotizacionambiente): <NEW_LINE> <INDENT> if request.method == 'POST': <NEW_LINE> <INDENT> form_cotizacionmueble = CotizacionMuebleForm(request.POST) <NEW_LINE> if form_cotizacionmueble.is_valid(): <NEW_LINE> <INDENT> id_reg = form_cotizacionmueble.save() <NEW_LINE> id_cot = Cotizacio... | docstring | 625941cb30c21e258bdfa574 |
def forward(self, features, captions, lengths): <NEW_LINE> <INDENT> embeddings = self.embed(captions) <NEW_LINE> embeddings = torch.cat((features.unsqueeze(1), embeddings), 1) <NEW_LINE> packed = pack_padded_sequence(embeddings, lengths, batch_first=True) <NEW_LINE> hiddens, _ = self.unit(packed) <NEW_LINE> outputs = s... | Decode image feature vectors and generates captions. | 625941cb60cbc95b062c661a |
def _input_heat_setpoint(self, client, data, message): <NEW_LINE> <INDENT> LOG.info("Thermostat message %s %s", message.topic, message.payload) <NEW_LINE> data = self.heat_sp_command.to_json(message.payload) <NEW_LINE> if not data: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> LOG.info("Thermostat heat setpoint comman... | Handle an input mode change MQTT message.
This is called when we receive a message on the mode change MQTT
topic subscription. Parse the message and pass the command to the
Insteon device.
Value should be in the form of:
{ temp_f: float } or { temp_c: float}
If temp_c is present, it will be used, regardless of if ... | 625941cb76d4e153a657ec08 |
def cmdForwardedMessage(self, msg, user, fwd_from): <NEW_LINE> <INDENT> chat = self.last_addq_chat.get(user['id']) <NEW_LINE> if chat is None: <NEW_LINE> <INDENT> self.conn.sendMessage(user['id'], 'Virhe: Mistä tämä tuli? Merkitse keskustelukanava ensin komentamalla siellä /addq') <NEW_LINE> return <NEW_LINE> <DEDENT> ... | Received a private forward, interpreted as a quote to be added | 625941cb4f6381625f114b11 |
def insert_data_batch(table_name): <NEW_LINE> <INDENT> sql = "select * from {}".format(table_name) <NEW_LINE> with TwoDB() as twodb: <NEW_LINE> <INDENT> twodb.mssql_cur.execute(sql) <NEW_LINE> rows = twodb.mssql_cur.fetchall() <NEW_LINE> rows_count = twodb.mssql_cur.rowcount <NEW_LINE> if rows_count == 0: <NEW_LINE> <I... | 串行 total:367311
commit_num=1000 2:16
commit_num=10000 2:04 | 625941cbc4546d3d9de72b0b |
def test_load_only_allows_lists(self): <NEW_LINE> <INDENT> steps = 'This is not a list' <NEW_LINE> with self.assertRaises((runsteps.RunnerException, SystemExit)): <NEW_LINE> <INDENT> self.runner.load(steps) | New instances will raise an Exception if given a non-list object | 625941cb97e22403b379d070 |
@t16000m.hat(1) <NEW_LINE> def trim_digital(event, vjoy, joy): <NEW_LINE> <INDENT> global g_trim_offset <NEW_LINE> g_trim_offset[0] += g_step_size * event.value[0] <NEW_LINE> g_trim_offset[1] += g_step_size * event.value[1] <NEW_LINE> update_axis(vjoy, joy) | Performs trimming using the hat to indicate the direction.
:param event the hat event containing which direction it was pushed in
:param vjoy vjoy proxy
:param joy joy proxy | 625941cb627d3e7fe0d68f26 |
def test_deps1(self): <NEW_LINE> <INDENT> tg = self.generate_task_graph("branch") <NEW_LINE> self.assertEqual(tg["tasks"][1]["task"]["dependencies"][0], tg["tasks"][0]["taskId"]) | Second task should require first task | 625941cb66656f66f7cbc282 |
def removeNonAscii(text): <NEW_LINE> <INDENT> return nonAsciiRE.sub(' ',text) | return a string with all the non-ascii characters in text replaced
by a space.
Gets rid of those nasty unicode characters. | 625941cbad47b63b2c50a056 |
def aktivitaet_speichern(name, date, beginn, ende, verantwortung, beteiligung): <NEW_LINE> <INDENT> date = date.split("-") <NEW_LINE> DD = str(date[2]) <NEW_LINE> MM = str(date[1]) <NEW_LINE> YYYY = str(date[0]) <NEW_LINE> date = DD + "." + MM + "." + YYYY <NEW_LINE> seperator = ", " <NEW_LINE> beteiligung = seperator... | Summary:
Gets added content for new entry and adds it to dict in json file.
Returns:
current json file. | 625941cbf9cc0f698b1406d3 |
def lessThan(self, left, right): <NEW_LINE> <INDENT> left_is_folder = left.data(QtCore.Qt.UserRole) <NEW_LINE> left_data = left.data(QtCore.Qt.DisplayRole) <NEW_LINE> right_is_folder = right.data(QtCore.Qt.UserRole) <NEW_LINE> right_data = right.data(QtCore.Qt.DisplayRole) <NEW_LINE> sort_order = self.sortOrder() <NEW_... | Perform sorting comparison.
Since we know the sort order, we can ensure that folders always come first. | 625941cb76e4537e8c351749 |
def get_total_cell_count(self): <NEW_LINE> <INDENT> if self.cell_array is not None: <NEW_LINE> <INDENT> return np.size(self.cell_array) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return 0 | The total number of cells in the currently defined grid.
:return: The total cell count (basically equal to grid width * grid height). | 625941cb7cff6e4e81117a5d |
def decode_by_chardet(self, content, url): <NEW_LINE> <INDENT> result = content <NEW_LINE> if self.encoding: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> result = content.decode(self.encoding) <NEW_LINE> <DEDENT> except UnicodeDecodeError: <NEW_LINE> <INDENT> encoding = chardet.detect(content)['encoding'] <NEW_LINE> tr... | 有双级缓存的解码器
第一级缓存是上一篇文章的编码,第二级缓存是数据库保存的此网站编码 | 625941cb73bcbd0ca4b2c14d |
def get_position(self) -> tuple: <NEW_LINE> <INDENT> return self.x, self.y | Returns a position of the object in the scene.
Returns
-------
tuple | 625941cbbe7bc26dc91cd6d7 |
def find_number_of_uncompleted_tasks(tasks: list) -> int: <NEW_LINE> <INDENT> number_of_uncompleted_tasks = 0 <NEW_LINE> for task in tasks: <NEW_LINE> <INDENT> if task[COMPLETED_INDEX] == UNCOMPLETED_VALUE: <NEW_LINE> <INDENT> number_of_uncompleted_tasks += 1 <NEW_LINE> <DEDENT> <DEDENT> return number_of_uncompleted_ta... | Find the number of tasks uncompleted. | 625941cb7b180e01f3dc48d5 |
def connect(database, keyspace=None, database_type=None, allow_connection_pooling=False, read_only=False, delete_all_contents=False, **kargs): <NEW_LINE> <INDENT> db = kargs.pop("db", None) <NEW_LINE> if db is not None: <NEW_LINE> <INDENT> if database_type is not None and db != database_type: <NEW_LINE> <INDENT> raise ... | Connect to a Sina store.
Given a uri/path (and, if required, the name of a keyspace),
figures out which backend is required.
:param database: The URI of the store to connect to.
:type database: str
:param keyspace: The keyspace to connect to (Cassandra only).
:type keyspace: str
:param database_type: Type of backend ... | 625941cbbe8e80087fb20d1a |
def insert_cols(self, idx, amount=1): <NEW_LINE> <INDENT> self._move_cells(min_col=idx, offset=amount, row_or_col="col_idx") | Insert column or columns before col==idx | 625941cb5e10d32532c5effe |
def connect_sequentially(nodes): <NEW_LINE> <INDENT> for idx in range(len(nodes)): <NEW_LINE> <INDENT> if idx < len(nodes) - 1: <NEW_LINE> <INDENT> nodes[idx].add_peer(nodes[idx+1].addr()) <NEW_LINE> <DEDENT> <DEDENT> nodes = None | given a list of nodes connect 0 to 1, 1 to 2 ... N-1 to N | 625941cb2eb69b55b151c986 |
def test_assign_office(self): <NEW_LINE> <INDENT> self.me.assign_office('Staff') <NEW_LINE> self.assertIsNotNone(self.me.office_room, 'office room cannot be assigned to person') | test person can be assigned an office | 625941cbd8ef3951e3243614 |
def splitter(): <NEW_LINE> <INDENT> new_folder_path = "D:\\ETUDES\\3A\\OSY\\Deep_learning\\projet\\FlickrLogos_47\\val" <NEW_LINE> try: <NEW_LINE> <INDENT> os.mkdir(new_folder_path) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> for i in range(47): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> ... | A partir du dossier classes créé par le parser, splitter train/val (80%-20%) | 625941cbb5575c28eb68e0d7 |
def days_sorted(self): <NEW_LINE> <INDENT> return [(d, self.days[d]) for d in sorted(self.days)] | Return a sorted list of (date, lessons) tuples | 625941cb76e4537e8c35174a |
def forecast_cov(ma_coefs, sigma_u, steps): <NEW_LINE> <INDENT> neqs = len(sigma_u) <NEW_LINE> forc_covs = np.zeros((steps, neqs, neqs)) <NEW_LINE> prior = np.zeros((neqs, neqs)) <NEW_LINE> for h in range(steps): <NEW_LINE> <INDENT> phi = ma_coefs[h] <NEW_LINE> var = chain_dot(phi, sigma_u, phi.T) <NEW_LINE> forc_covs[... | Parameters
----------
steps : int
Number of steps ahead
Returns
-------
forc_covs : ndarray (steps x neqs x neqs) | 625941cb293b9510aa2c336e |
def __make_test_case(self, ref_obj, clnm, title, elapsed_time, counter): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> obj_name = ref_obj.get_label() <NEW_LINE> <DEDENT> except Exception as eee: <NEW_LINE> <INDENT> obj_name = "" <NEW_LINE> <DEDENT> t_title = '{:05n} [{:s}] {:.100}'.format(counter, obj_name, title.replac... | INTERNAL USAGE
| 625941cb004d5f362079a40a |
def getClosestPattern(self, Pattern, seed=None): <NEW_LINE> <INDENT> raise NotImplementedError("Not Implemented.") | Returns the closest pattern in this style. | 625941cb50812a4eaa59c3f9 |
def search(self, nums, target): <NEW_LINE> <INDENT> l, r = 0, len(nums) - 1 <NEW_LINE> while l < r - 1: <NEW_LINE> <INDENT> m = l + (r - l) / 2 <NEW_LINE> if nums[m] < target: <NEW_LINE> <INDENT> l = m <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> r = m <NEW_LINE> <DEDENT> <DEDENT> if nums[l] == target: <NEW_LINE> <IND... | :type nums: List[int]
:type target: int
:rtype: int | 625941cb9f2886367277a965 |
def query_feed(ser_if): <NEW_LINE> <INDENT> ser_if.write('q') <NEW_LINE> return check_response(ser_if) | Query the arduino to check if the card container ist empty
---------------
IN: Serial interface object
OUT: Boolean TRUE if empty, FALSE if non-empty | 625941cb4a966d76dd5510e6 |
def test_viewing_challenge(): <NEW_LINE> <INDENT> app = create_ctfd() <NEW_LINE> with app.app_context(): <NEW_LINE> <INDENT> register_user(app) <NEW_LINE> client = login_as_user(app) <NEW_LINE> gen_challenge(app.db) <NEW_LINE> r = client.get("/api/v1/challenges/1") <NEW_LINE> assert r.get_json() <NEW_LINE> <DEDENT> des... | Test that users can see individual challenges | 625941cbe76e3b2f99f3a8e3 |
def test_checks_object_none(self): <NEW_LINE> <INDENT> self.info.UpdateInfo(None) <NEW_LINE> assert self.result == 'Item is None or has been destroyed.' | Should set message that object is None | 625941cb01c39578d7e74f13 |
def test_api_inventory_default_none_instantiation(self, check): <NEW_LINE> <INDENT> inv = soi.Inventory() <NEW_LINE> check.is_none(inv.project) <NEW_LINE> check.is_none(inv.version) <NEW_LINE> check.equal(inv.count, 0) <NEW_LINE> check.is_(inv.source_type, soi.SourceTypes.Manual) | Confirm 'manual' instantiation with None. | 625941cb24f1403a92600c3e |
def twoSum(self, nums, target): <NEW_LINE> <INDENT> length = len(nums) <NEW_LINE> index = [] <NEW_LINE> for x in range(0,length): <NEW_LINE> <INDENT> for y in range(x,length): <NEW_LINE> <INDENT> if nums[x]+nums[y] == target and x != y: <NEW_LINE> <INDENT> index.append(x) <NEW_LINE> index.append(y) <NEW_LINE> return in... | :type nums: List[int]
:type target: int
:rtype: List[int] | 625941cb4c3428357757c3ff |
def initialise_gates_generic(self, n_gates, x): <NEW_LINE> <INDENT> gates = np.zeros((n_gates, 2)) <NEW_LINE> gates[:, 0] = x <NEW_LINE> if n_gates == 1: <NEW_LINE> <INDENT> gates[0, 1] = self.height / 2 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> gates[:, 1] = np.linspace(self.height / 4, 3 * self.height / 4, n_gate... | General method for initialising gates.
Note: This method relies on a lot of class attributes, many of which are
not explicitly required in the init method - perhaps we should be
careful of this? Answer: see note cm at top | 625941cbd4950a0f3b08c427 |
def validate_input(self): <NEW_LINE> <INDENT> from digipal import utils <NEW_LINE> content = None <NEW_LINE> try: <NEW_LINE> <INDENT> content = utils.read_file(self.infile.name) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> if content: <NEW_LINE> <INDENT> if '@import' in content and KEYWORD_A... | Raises an exception if the LESS file contains @import and not the
KEYWORD_ALLOW_IMPORT keyword. | 625941cb283ffb24f3c559d9 |
def write(text, time): <NEW_LINE> <INDENT> pyautogui.typewrite(text, interval=time) | :param text: The message to write
:param time: The seconds between each word | 625941cbe5267d203edcdd76 |
def filter(self, **kw): <NEW_LINE> <INDENT> coll = self.cells <NEW_LINE> singles = kw.pop("singles", False) <NEW_LINE> if not singles: <NEW_LINE> <INDENT> coll = [x for x in coll if len(x) > 1] <NEW_LINE> <DEDENT> if "length" in kw: <NEW_LINE> <INDENT> coll = [x for x in coll if len(x) == kw["length"]] <NEW_LINE> <DEDE... | post processes the result, possibly filtering it somemore
singles: keep the singles, default is False
length: django style syntax for filtering, supports lt, lte, gt
and gte
digits: filter by a digit or list of digits
row, box, col: filters by matching row, box or col
func: filter by a c... | 625941cb97e22403b379d071 |
def __init__(self, model_path, disable_GPU=True): <NEW_LINE> <INDENT> global tf <NEW_LINE> import tensorflow as tf <NEW_LINE> if disable_GPU: <NEW_LINE> <INDENT> gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.01) <NEW_LINE> config = tf.ConfigProto( device_count={'GPU': 0}, gpu_options=gpu_options ) <NEW_... | Create a new track classifier.
:param model_path: the path to load the model from
:param disable_GPU: defaults to on because it takes quite a lot of GPU memory and is not any faster for single
segment classification | 625941cbd53ae8145f87a348 |
def hex_to_rgb(hex): <NEW_LINE> <INDENT> hex = hex.strip('#') <NEW_LINE> r, g, b = int(hex[:2], 16), int(hex[2:4], 16), int(hex[4:6], 16) <NEW_LINE> return r, g, b | converts hexadecimal color value to its rgb counterpart | 625941cb1d351010ab855bf3 |
def expected_file_tuple(path): <NEW_LINE> <INDENT> size, date = INTERESTING_FILES[path] <NEW_LINE> return (path, size, date) | Returns a tuple repsenting the file at the given path | 625941cbfbf16365ca6f629c |
def generate_links(sort_order): <NEW_LINE> <INDENT> links = {} <NEW_LINE> columns = ('time', 'view', 'vote', 'title', 'message') <NEW_LINE> if sort_order: <NEW_LINE> <INDENT> sorted_columns = [item[0] for item in sort_order] <NEW_LINE> for column in columns: <NEW_LINE> <INDENT> if len(sort_order) == 1: <NEW_LINE> <INDE... | Generate links for ordering the table for all 5 columns.
@param sort_order list List of tuples containing the request path parameters
@return list List of tuples containing the links as (column, order) | 625941cbb7558d58953c4fed |
def get_close_nodes(node, all_nodes, dist_th=8000): <NEW_LINE> <INDENT> result_nodes = [] <NEW_LINE> for n in all_nodes: <NEW_LINE> <INDENT> if n.id == node.id: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> if straight_line_dist_bw_nodes(node, n) < dist_th: <NEW_LINE> <INDENT> result_nodes.append(n) <NEW_LINE> <DEDE... | :param node: the node in question
:param all_nodes: list of all nodes to check against
:param dist_th: return all nodes closer than this threshold
:return: list of nodes | 625941cb435de62698dfdd24 |
@instrumented <NEW_LINE> def s2_hidden_region(r, e): <NEW_LINE> <INDENT> status = return_status.UNHANDLED <NEW_LINE> if(e.signal == signals.to_p): <NEW_LINE> <INDENT> status = r.trans(s2_region) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> r.temp.fun = r.top <NEW_LINE> status = return_status.SUPER <NEW_LINE> <DEDENT> ... | A hidden state which permits the exit feature of the
s2_region to work.
**Note**:
This will not appear in the spy instrumentation
**Args**:
| ``p`` (HsmWithQueues): Hsm with queues with no thread
| ``e`` (Event): event
**Returns**:
(type): return_status | 625941cb44b2445a3393216e |
def ExportViews(self): <NEW_LINE> <INDENT> print >> sys.stderr, "Describing views..." <NEW_LINE> self.ExportObjects(Object.ObjectIterator(self.environment, "AllViews", Statements.VIEWS, "where o.owner %s" % self.schemasClause, Object.View)) | Export all of the views. | 625941cbd99f1b3c44c67667 |
def _retry_send_messages(): <NEW_LINE> <INDENT> max_retry_value = getattr(settings, 'DJMAIL_MAX_RETRY_NUMBER', 3) <NEW_LINE> queryset = models.Message.objects.filter(retry_count__lte=max_retry_value, status=models.STATUS_FAILED) .order_by('-priority', 'created_at') <NEW_LINE> connect... | Retry to send failed messages. | 625941cb097d151d1a222f32 |
def _just_save_bb(self): <NEW_LINE> <INDENT> import matplotlib <NEW_LINE> if self._plot_outfile_format == 'svg': <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> matplotlib.use('SVG') <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> matplotlib.use('Agg') <NEW_LINE> <DEDENT> <DEDENT> elif self._plot_outfile_format == 'pdf': ... | Internal method for saving the beachball unit sphere plot into a given
file.
This method tries to setup the approprite backend according to the
requested file format first. 'AGG' is used in most cases. | 625941cb3c8af77a43ae3878 |
def format(self): <NEW_LINE> <INDENT> result = [] <NEW_LINE> if self.pronunciation != '': <NEW_LINE> <INDENT> result.append( FMT_PRONUNCIATION.format(xmlescape(self.pronunciation)) ) <NEW_LINE> <DEDENT> if self.wtype != '': <NEW_LINE> <INDENT> result.append(FMT_DETAILS.format(xmlescape(self.wtype))) <NEW_LINE> <DEDENT>... | Returns formatted dictionary entry. | 625941cbbf627c535bc132a7 |
def peakIndexInMountainArray(self, A): <NEW_LINE> <INDENT> for i in range(1, len(A) - 1): <NEW_LINE> <INDENT> if A[i - 1] < A[i] > A[i + 1]: <NEW_LINE> <INDENT> return i <NEW_LINE> <DEDENT> <DEDENT> return len(A) - 1 | :type A: List[int]
:rtype: | 625941cb26068e7796caedb6 |
def __setup_user_group(self): <NEW_LINE> <INDENT> import params <NEW_LINE> User(params.pxf_user, groups=[params.hdfs_superuser_group, params.user_group, params.tomcat_group], shell="/bin/bash") | Creates PXF user with the required groups and bash as default shell | 625941cb73bcbd0ca4b2c14e |
def canonicalise(equation): <NEW_LINE> <INDENT> for name, value in equation.namespace.iteritems(): <NEW_LINE> <INDENT> coordinates = equation.namespace['x'] <NEW_LINE> if isinstance(value, (ufl.form.Form, tuple)): <NEW_LINE> <INDENT> form = as_form(value) <NEW_LINE> form_data = form.compute_form_data() <NEW_LINE> form_... | Execute code in namespace and return an AST represenation of the code
and a collection of UFL objects (preprocessed forms, coefficients,
arguments) | 625941cb30c21e258bdfa575 |
def upload_stream( self, file_stream, file_name, preflight_check=False, preflight_expected_size=0, upload_using_accelerator=False, ): <NEW_LINE> <INDENT> if preflight_check: <NEW_LINE> <INDENT> self.preflight_check(size=preflight_expected_size, name=file_name) <NEW_LINE> <DEDENT> url = '{0}/files/content'.format(API.UP... | Upload a file to the folder.
The contents are taken from the given file stream, and it will have the given name.
:param file_stream:
The file-like object containing the bytes
:type file_stream:
`file`
:param file_name:
The name to give the file on Box.
:type file_name:
`unicode`
:param preflight_check:... | 625941cbf8510a7c17cf97d5 |
def create_primer(DNA, temp_or_coding="Coding", len_primer=6): <NEW_LINE> <INDENT> if temp_or_coding == "Template": <NEW_LINE> <INDENT> tmp = DNA[0:len_primer] <NEW_LINE> tmp = make_ds(tmp) <NEW_LINE> return tmp <NEW_LINE> <DEDENT> elif temp_or_coding == "Coding": <NEW_LINE> <INDENT> tmp = make_ds(tmp) <NEW_LINE> retur... | This function will always return the DNA in the 5' to 3' direction | 625941cb5fcc89381b1e1797 |
def get_breadcrumb(category): <NEW_LINE> <INDENT> breadcrumb = dict( cat1='', cat2='', cat3='' ) <NEW_LINE> if category.parent is None: <NEW_LINE> <INDENT> breadcrumb['cat1'] = category <NEW_LINE> <DEDENT> elif category.subs.count() == 0: <NEW_LINE> <INDENT> breadcrumb['cat3'] = category <NEW_LINE> cat2 = category.pare... | 获取面包屑导航
:param category: 商品类别
:return: 面包屑导航字典 | 625941cbb830903b967e99e3 |
def get(self, key): <NEW_LINE> <INDENT> res = self.data.get(key) <NEW_LINE> if res: <NEW_LINE> <INDENT> self.data.pop(key) <NEW_LINE> self.data[key] = res <NEW_LINE> return res <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return -1 | :type key: int
:rtype: int | 625941cba4f1c619b28b0112 |
def tap_frame(self): <NEW_LINE> <INDENT> self.driver.switch_to.default_content() | 切换到默认的frame
:return: | 625941cbe8904600ed9f2004 |
def post(self): <NEW_LINE> <INDENT> value = self.calculate_metric() <NEW_LINE> self.generate_metrics_dict(value) <NEW_LINE> self.response = requests.post(self.url, data=self.metrics_jso, headers=self.HEADERS) <NEW_LINE> return self.response | Obtain metric, build dictionary, convert to json and send POST request | 625941cbfff4ab517eb2f514 |
def VerifyPassword(self, password): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return pbkdf2_sha256.verify(password, self.PASSWORD_HASH) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return False | Use pbkdf2_sha256 to verify password against the stored hash.
Args:
password: The password to be verified.
Returns:
True: if password match.
False: if password does not match. | 625941cbbe383301e01b555e |
def register_commands(subparsers, context): <NEW_LINE> <INDENT> if context.fixed_setup: <NEW_LINE> <INDENT> parser_runqemu = subparsers.add_parser('runqemu', help='Run QEMU on the specified image', description='Runs QEMU to boot the specified image', group='testbuild', order=-20) <NEW_LINE> parser_runqemu.add_argument(... | Register devtool subcommands from this plugin | 625941cbac7a0e7691ed41a5 |
def __init__(self, host=None, port=8006, username=None, password=None, api=CORE, domain='DOMAIN'): <NEW_LINE> <INDENT> self.username = username <NEW_LINE> self.baseurl = "https://%s:%s/" % (host, port) <NEW_LINE> if api == CORE: <NEW_LINE> <INDENT> self.apiurl = self.baseurl + CORE_API_URL <NEW_LINE> self.loginurl = se... | The default domain of 'DOMAIN' is used because this value is
only relevant if you are authenticating against Active Directory.
Be sure to set this to the appropriate value if you use Active
Directory in your network. | 625941cbd18da76e235325ae |
def test_all_templates_item_register(self): <NEW_LINE> <INDENT> admin_session = self.get_session('admin') <NEW_LINE> admin_session.create_country_generic() <NEW_LINE> session = self.get_session('ABC_reg') <NEW_LINE> forbid_classes = {'badge_type', 'consent_form', 'event', 'rss', 'user'} <NEW_LINE> self.all_templates_it... | Test that all page templates for existing items load without
errors, for a registering user. | 625941cbde87d2750b85fe6b |
def get_call_leg(self, call_leg_id): <NEW_LINE> <INDENT> return self._callLegs_callLegID_node_(call_leg_id) | Retrieve information on a single call leg.
:param call_leg_id: The ID of the call leg to get
:type call_leg_id: String
.. seealso:: https://www.acano.com/publications/2015/09/Solution-API-Reference-R1_8.pdf#page=47
.. note:: v1.8 upward | 625941cbe64d504609d74918 |
def _parse_playlist_info(self): <NEW_LINE> <INDENT> last_entry = None <NEW_LINE> for pl_entry in self._pl_info: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if pl_entry['album'] not in self._albums: <NEW_LINE> <INDENT> self._albums.append(pl_entry['album']) <NEW_LINE> if last_entry: <NEW_LINE> <INDENT> self._last_song_... | Returns a list of albums from the playlist info. | 625941cbec188e330fd5a878 |
def weekends_between(self, day1, day2): <NEW_LINE> <INDENT> if day2 < day1: <NEW_LINE> <INDENT> return self.weekends_between(day2, day1) <NEW_LINE> <DEDENT> delta = day2 - day1 <NEW_LINE> weeks = delta.days // 7 <NEW_LINE> extra = delta.days % 7 <NEW_LINE> n = weeks * len(self.weekends) <NEW_LINE> while extra: <NEW_LIN... | Returns the number of weekends between two dates, including upper boundary.
>>> policy = Policy(weekends=(SAT, SUN))
>>> policy.weekends_between(date(2011, 6, 3), date(2011, 6, 15))
4
>>> policy.weekends_between(date(2011, 6, 4), date(2011, 6, 11)) # SAT to SAT
2 | 625941cb925a0f43d2549f4f |
def get_edge_label(self, a, b): <NEW_LINE> <INDENT> a, b = min(a, b), max(a, b) <NEW_LINE> return self.edge_labels[(a, b)] | Return the label on edge (a) -- (b) of this tetrahedron. | 625941cb287bf620b61d3b3c |
def confirm_code(self, arg): <NEW_LINE> <INDENT> if arg.isdigit() and int(arg) == self.conf_code: <NEW_LINE> <INDENT> self.player.playerize(self.world.db.select('* FROM player WHERE dbid=?', [self.dbid])[0]) <NEW_LINE> self.player.update_output(CLEAR + 'Type in your new password: ' + CONCEAL) <NEW_LINE> self.password =... | Confirm the user is who they say they are. If they have
the magic code (e-mailed to them), then we will give them
their account back.
PREV STATE: self.reset_password
NEXT STATE: self.create_password | 625941cb5fc7496912cc3a56 |
def calculateStackSize(self, hours): <NEW_LINE> <INDENT> result = hours*3600 <NEW_LINE> if result > config['min_stack_size']: <NEW_LINE> <INDENT> return config['min_stack_size'] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return result | This function calculate density for given hours. Add to because we
show only 'stack_size - 2' samples.
Args:
hours: number of hours to display.
Returns:
Integer value which show that we need every n-th sample | 625941cb3eb6a72ae02ec5b5 |
def test_scale_input(self): <NEW_LINE> <INDENT> t = Time(100.0, format='cxcsec', scale='utc') <NEW_LINE> assert t.scale == 'utc' <NEW_LINE> t = Time(100.0, format='unix', scale='tai') <NEW_LINE> assert t.scale == 'tai' <NEW_LINE> t = Time(100.0, format='gps', scale='utc') <NEW_LINE> assert t.scale == 'utc' <NEW_LINE> w... | Test for issues related to scale input | 625941cb85dfad0860c3af33 |
def _uses_mandatory_method_param(self, node): <NEW_LINE> <INDENT> return self._is_mandatory_method_param(node.expr) | Check that attribute lookup name use first attribute variable name.
Name is `self` for method, `cls` for classmethod and `mcs` for metaclass. | 625941cb7cff6e4e81117a5e |
def p_expr_pre9(p): <NEW_LINE> <INDENT> p[0] = ast.UnaryExp(ast.UnaryExp.SIZEOF, p[2], p.lineno(1)) | expr : SIZEOF expr | 625941cb6aa9bd52df036e7c |
def select_with_main_images(self, limit=None, **kwargs): <NEW_LINE> <INDENT> objects = self.get_query_set().filter(**kwargs)[:limit] <NEW_LINE> self.image_model_class.injector.inject_to(objects,'main_image', is_main=True) <NEW_LINE> return objects | Select all objects with filters passed as kwargs.
For each object it's main image instance is accessible as ``object.main_image``.
Results can be limited using ``limit`` parameter.
Selection is performed using only 2 or 3 sql queries. | 625941cb4d74a7450ccd429c |
def _final_lines(self): <NEW_LINE> <INDENT> lines = self._get_lines() <NEW_LINE> lines = [line.rstrip('\n') for line in lines] <NEW_LINE> return lines | Return final lines | 625941cb2ae34c7f2600d20a |
def by_date(date=None): <NEW_LINE> <INDENT> return (sorted([e for e in entries()[0] if e.get('date') == date], key=lambda d: d.get('device')), sorted([e for e in entries()[1] if e.get('date') == date], key=lambda d: d.get('device')), sorted([e for e in entries()[2] if e.get('date') == date], key=lambda d: d.get('device... | return all manifest_entries (tuple) for selected {date}, sorted by device
| 625941cb9b70327d1c4e0ead |
def __init__(self, *args, **kwds): <NEW_LINE> <INDENT> if args or kwds: <NEW_LINE> <INDENT> super(DockingInteractorActionResult, self).__init__(*args, **kwds) <NEW_LINE> if self.header is None: <NEW_LINE> <INDENT> self.header = std_msgs.msg.Header() <NEW_LINE> <DEDENT> if self.status is None: <NEW_LINE> <INDENT> self.s... | Constructor. Any message fields that are implicitly/explicitly
set to None will be assigned a default value. The recommend
use is keyword arguments as this is more robust to future message
changes. You cannot mix in-order arguments and keyword arguments.
The available fields are:
header,status,result
:param args:... | 625941cb1f5feb6acb0c4c2a |
def set_explicit(self, explicit: bool) -> None: <NEW_LINE> <INDENT> self.explicit = explicit | Marks this song as explicit or clear.
:param explicit: If set to "True" the song will be marked as explicit, otherwise it will be considered clear.
:type explicit: bool | 625941cb16aa5153ce362551 |
def find_next_char(char, chars, direction='right', bound=False): <NEW_LINE> <INDENT> if direction in ['right', 'left']: <NEW_LINE> <INDENT> sign = 1 if direction == 'right' else -1 <NEW_LINE> pre_sel = [(c, sign*hor_dist(char, c)) for c in chars if sign*hor_dist(char, c) > 0 and on_same_line(char, c)] <NEW_LINE> <DEDEN... | returns a single char or False if found none
If bound is given, then one will not search further
than this bound. Still to work out! | 625941cb8e71fb1e9831d882 |
def createPhotomosaic(target_image, input_images, grid_size, reuse_images=True): <NEW_LINE> <INDENT> print('splitting input image...') <NEW_LINE> target_images = splitImage(target_image, grid_size) <NEW_LINE> print('finding image matches...') <NEW_LINE> output_images = [] <NEW_LINE> count = 0 <NEW_LINE> batch_size = in... | 图片马赛克生成
@param {Image} target_image 目标图像
@param {image} input_images 替换图像列表
@param {Tuple[int, int]} grid_size 网格行数和列数
@param {bool} reuse_images 是否允许重复使用替换图像
@return {Image} 马赛克图像 | 625941cb293b9510aa2c336f |
def rm_accents(text: str): <NEW_LINE> <INDENT> text = rm_unicode(text) <NEW_LINE> match = [ (r"\c{c}", "c"), (r"\`{e}", "e"), (r"\'{e}", "e"), (r"\'{E}", "E"), (r"\"{e}", "e"), (r"\^{o}", "o"), (r"\"{o}", "o"), (r"\"{y}", "y"), (r"\~{g}", "g"), (r"\~{n}", "n"), (r"\.{I}", "I"), (r"\'{a}", "a"), (r"\v{a}", "a"), (r"\v{r... | Remove accents. | 625941cb31939e2706e4cf43 |
def get_git_abstract_project(self, parser: InterfaceParser): <NEW_LINE> <INDENT> file = self._download.get_archieve( parser.get_name(), parser.get_abstract_name(), parser.get_abstract_version() ) <NEW_LINE> return file | Get the archieve on gitlab
:param parser: InterfaceParser
:return: file path | 625941cb21bff66bcd684a2c |
@u.deprecated("Deprecated; see method from_clifford in PauliClass.") <NEW_LINE> def paulify(cliff_in): <NEW_LINE> <INDENT> nq=len(cliff_in.xout) <NEW_LINE> test_ex,test_zed=elem_gens(nq) <NEW_LINE> for ex_clif,zed_clif,ex_test,zed_test in zip(cliff_in.xout, cliff_in.zout,test_ex,test_zed): <NEW_LINE> <INDENT> if ex_cli... | Tests an input Clifford ``cliff_in`` to determine if it is, in
fact, a Pauli. If so, it outputs the Pauli. If not, it
returns the Clifford.
:arg cliff_in: Representation of Clifford operator to be converted,
if possible.
:rtype: :class:`qecc.Pauli`
Example:
>>> import qecc as q
>>> cliff=q.Clifford([q.Pauli('XI',2),q... | 625941cb1b99ca400220ab8a |
def get_parent(self, value, position, height=1): <NEW_LINE> <INDENT> if not position: <NEW_LINE> <INDENT> return None, height <NEW_LINE> <DEDENT> if value == position.value: <NEW_LINE> <INDENT> return position, height <NEW_LINE> <DEDENT> lessThan = value < position.value <NEW_LINE> if lessThan and position.left: <NEW_L... | Get parent node for value in the Tree from a position | 625941cb4428ac0f6e5ba8cb |
def ws(): <NEW_LINE> <INDENT> session.forget() <NEW_LINE> return service() | exposes services. for example:
http://..../[app]/default/call/jsonrpc
decorate with @services.jsonrpc the functions to expose
supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv | 625941cb55399d3f0558878d |
def remove_at(self, position): <NEW_LINE> <INDENT> unwanted = self.find_at(position) <NEW_LINE> if unwanted is None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if unwanted.next is not None: <NEW_LINE> <INDENT> unwanted.next.prev = unwanted.prev if unwanted.prev is not None else None <NEW_LINE> <DEDENT> if unw... | Remove a Node from the LinkedList.
Time - O(n)
:param position: The position the data will be removed. | 625941cba934411ee375176c |
def get_db(): <NEW_LINE> <INDENT> return sqlite3.connect('db.db', timeout=1) | Returns a database connection | 625941cb76d4e153a657ec09 |
def load_resultspace_environment(result_space_path, base_env=None, cached=True): <NEW_LINE> <INDENT> env_dict = get_resultspace_environment(result_space_path, base_env=base_env, cached=cached) <NEW_LINE> try: <NEW_LINE> <INDENT> os.environ.update(env_dict) <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> for k... | Load the environemt variables which result from sourcing another
workspace path into this process's environment.
:param result_space_path: path to a Catkin result-space whose environment should be loaded, ``str``
:type result_space_path: str
:param cached: use the cached environment
:type cached: bool | 625941cbf9cc0f698b1406d4 |
def get_cpu_implementer(): <NEW_LINE> <INDENT> return get_cpu_info("CPU implementer") | Get the CPU implementer.
:returns: The CPU implementer.
:rtype: string | 625941cb498bea3a759b9b88 |
def remove_punct(text): <NEW_LINE> <INDENT> no_punct = "" <NEW_LINE> for char in text: <NEW_LINE> <INDENT> if not (char in string.punctuation): <NEW_LINE> <INDENT> no_punct = no_punct + char <NEW_LINE> <DEDENT> <DEDENT> return no_punct | This function is used to remove all punctuation
marks from a string. Spaces do not count as punctuation and should
not be removed. The funcion takes a string and returns a new string
which does not contain any puctuation. For movemoveexample:
>>> remove_punct("Hello, World!")
'Hello World'
>>> remove_punct("-- ...Hey!... | 625941cbfb3f5b602dac376b |
def p_primary_id(p): <NEW_LINE> <INDENT> p[0] = p[1] | primary : sid | 625941cb377c676e91272281 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.