code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def step(self): <NEW_LINE> <INDENT> return self.source_func() | Raises StopIteration if the routine has nothing more to do | 625941bfab23a570cc2500c4 |
def judgeCircle(self, moves): <NEW_LINE> <INDENT> return False if (moves.count("U") != moves.count("D") or moves.count("L") != moves.count("R")) else True | :type moves: str
:rtype: bool | 625941bfdd821e528d63b0ee |
def individual_stats(df): <NEW_LINE> <INDENT> ind_prompt1 = input('Would you like to see stats at an individual level? Y/N\n') <NEW_LINE> x = 0 <NEW_LINE> while ind_prompt1.lower() == 'y': <NEW_LINE> <INDENT> print('\n',df.loc[x]) <NEW_LINE> x += 1 <NEW_LINE> print('-'*40) <NEW_LINE> print('\n',df.loc[x]) <NEW_LINE> x... | Displays statistics on bikeshare users. | 625941bf30c21e258bdfa3df |
def test_adhoc_sign_package_one_app(package_command, first_app): <NEW_LINE> <INDENT> package_command.apps = { "first": first_app, } <NEW_LINE> options = package_command.parse_options(["--adhoc"]) <NEW_LINE> package_command(**options) <NEW_LINE> assert package_command.actions == [ ("verify", ), ( "package", "first", { '... | If there is one app,and an --adhoc argument, package signs the app using adhoc option | 625941bfc4546d3d9de72975 |
def delete (self): <NEW_LINE> <INDENT> self._ruleset.remove_language(self) <NEW_LINE> self._ruleset = None | Deletes this language, removing it from its `.Ruleset`. | 625941bfff9c53063f47c138 |
def add_to_assignees(self, *assignees): <NEW_LINE> <INDENT> assert all( isinstance(element, (github.NamedUser.NamedUser, str)) for element in assignees ), assignees <NEW_LINE> post_parameters = { "assignees": [ assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees ] ... | :calls: `POST /repos/{owner}/{repo}/issues/{number}/assignees <https://docs.github.com/en/rest/reference/issues#assignees>`_
:param assignee: :class:`github.NamedUser.NamedUser` or string
:rtype: None | 625941bf7d43ff24873a2be2 |
def RegQueryValueEx(key, valueName=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> (dataType, data, dataLength) = c_api.RegQueryValueExW(key=key, name=valueName) <NEW_LINE> data = (dtypes.BYTE * dataLength.value)() <NEW_LINE> (dataType, data, dataLength) = c_api.RegQueryValueExW(key=key, name=valueName, data=data, ... | Retrieves the type and data for the specified registry value.
Parameters
key A handle to an open registry key.
The key must have been opened with the KEY_QUERY_VALUE access right
valueName The name of the registry value. it is optional.
Return Value
If the function succeeds, the return a tuple o... | 625941bfb830903b967e9851 |
def _get_fp(y_pred, y_true): <NEW_LINE> <INDENT> return torch.sum((1 - y_true) * y_pred).float() | args:
y_true : 3-d ndarray in [batch_size, img_rows, img_cols]
y_pred : 3-d ndarray in [batch_size, img_rows, img_cols]
return [float] false_positive | 625941bf1f5feb6acb0c4a97 |
def cap(self): <NEW_LINE> <INDENT> if self.rwcap == None: <NEW_LINE> <INDENT> return self.rocap <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return self.rwcap | Get the least attenuated sparse capability available for this Node | 625941bfe64d504609d74783 |
def genReadAsyncDataOutputType(*args): <NEW_LINE> <INDENT> return _libvncxx.Packet_genReadAsyncDataOutputType(*args) | genReadAsyncDataOutputType(vn::protocol::uart::ErrorDetectionMode errorDetectionMode, char * buffer, size_t size, uint8_t port) -> size_t
genReadAsyncDataOutputType(vn::protocol::uart::ErrorDetectionMode errorDetectionMode, char * buffer, size_t size) -> size_t | 625941bf67a9b606de4a7dff |
def test_add_test_record(): <NEW_LINE> <INDENT> test_run = mock.MagicMock() <NEW_LINE> obj_cache = { 'test_run': test_run, 'user': 'testuser', 'testcases': { 'module.NameTestCase.test_name': 'caffa7b0-fb9e-430b-903f-3f37fa28e0da', }, } <NEW_LINE> with mock.patch.dict('betelgeuse.OBJ_CACHE', obj_cache): <NEW_LINE> <INDE... | Check if test record creation works. | 625941bf956e5f7376d70db2 |
def __ne__(self, other): <NEW_LINE> <INDENT> return not (self == other) | Check whether ``self`` and ``other`` are not equal.
TESTS::
sage: F3 = GF(3).algebraic_closure()
sage: F3 != F3
False
sage: F5 = GF(5).algebraic_closure()
sage: F3 != F5
True | 625941bfeab8aa0e5d26da9b |
def test_coerce_number_set(self): <NEW_LINE> <INDENT> field = Field(data_type=set_(int), coerce=True) <NEW_LINE> ret = field.coerce([2, '4']) <NEW_LINE> self.assertEqual(ret, set([2, 4])) | Coerce to number set | 625941bfd6c5a10208143f8c |
@register.tag <NEW_LINE> def bookmark_form(parser, token): <NEW_LINE> <INDENT> return BookmarkFormNode(**_parse_args(parser, token, BOOKMARK_FORM_EXPRESSION)) | Return, as html or as a template variable, a Django form to add or remove
a bookmark for the given instance and key, and for current user.
Usage:
.. code-block:: html+django
{% bookmark_form for *instance* [using *key*] [as *varname*] %}
The key can be given hardcoded (surrounded by quotes)
or as a template var... | 625941bf44b2445a33931fdb |
def _runtime_initialize(self): <NEW_LINE> <INDENT> pass | This is called once everytime engine.run method is executed.
It is meant to be used as a final setup call for all constraints. | 625941bf5fdd1c0f98dc0176 |
def __init__(self, persistent=False, virsh_dargs=None): <NEW_LINE> <INDENT> if virsh_dargs is None: <NEW_LINE> <INDENT> virsh_dargs = {} <NEW_LINE> <DEDENT> if persistent: <NEW_LINE> <INDENT> self.super_set('__virsh__', virsh.VirshPersistent(**virsh_dargs)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.super_set('... | Initialize instance's internal virsh interface from virsh_dargs
@param: persistent: Use persistent virsh connection for this instance
@param: virsh_dargs: virsh module Virsh class dargs API keywords | 625941bf293b9510aa2c31dc |
def test_validTabStructure_2(): <NEW_LINE> <INDENT> result = validTabStructure("1\t2\t3\t4\t5\t6\t7\t8\t9\n") <NEW_LINE> assert result == True | passes 8 tab structure | 625941bf15fb5d323cde0a50 |
def compile_statements(self): <NEW_LINE> <INDENT> self.write_non_terminal_start('statements') <NEW_LINE> while True: <NEW_LINE> <INDENT> if self.is_token(KEYWORD, 'do'): <NEW_LINE> <INDENT> self.compile_do() <NEW_LINE> <DEDENT> elif self.is_token(KEYWORD, 'let'): <NEW_LINE> <INDENT> self.compile_let() <NEW_LINE> <DEDEN... | Compiles a sequence of statements, not including the enclosing {}. | 625941bf0383005118ecf528 |
def __init__(self, filepath): <NEW_LINE> <INDENT> self.file = open(filepath, 'w') <NEW_LINE> self.chemin = filepath <NEW_LINE> self.contenu = [] <NEW_LINE> self.nbLigne = 0 <NEW_LINE> self.ro = False | Constructeur de classe. Un fichier est initialisé à partir de son chemin d'accès
:param filepath: chemin d'accès du fichier
:type filepath: str | 625941bf55399d3f055885f7 |
def __init__(self, num_units,num_mels,outputs_per_step): <NEW_LINE> <INDENT> super(AttentionDecoder, self).__init__() <NEW_LINE> self.num_units = num_units <NEW_LINE> self.v = nn.Linear(num_units, 1, bias=False) <NEW_LINE> self.W1 = nn.Linear(num_units, num_units, bias=False) <NEW_LINE> self.W2 = nn.Linear(num_units, n... | :param num_units: dimension of hidden units | 625941bfd10714528d5ffc24 |
def validate_email(value): <NEW_LINE> <INDENT> if not value: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> django_validate_email(value) <NEW_LINE> <DEDENT> except ValidationError: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> vali... | Validate a single email. | 625941bf26068e7796caec1e |
def is_empty(self): <NEW_LINE> <INDENT> return self.head is None | Returns True if stack is empty | 625941bf283ffb24f3c55847 |
def get_test_set(self): <NEW_LINE> <INDENT> return FULLVIDTIMIT(which_set='test', center=self.center, rescale=self.rescale, axes=self.axes) | .. todo::
WRITEME | 625941bf9b70327d1c4e0d18 |
def write_to_parquet(cls, self): <NEW_LINE> <INDENT> write_to_parquet(self.df, self.fpath) | Write data to local json file. | 625941bf07f4c71912b113c4 |
def IsDisplayValid(*args): <NEW_LINE> <INDENT> return _DigitalMicrograph.IsDisplayValid(*args) | IsDisplayValid(Image argument_1) -> bool | 625941bf3346ee7daa2b2cae |
def _build_loss(self, y_pred, y_true, **kwargs): <NEW_LINE> <INDENT> weight_decay = kwargs.pop('weight_decay', 0.0005) <NEW_LINE> variables = self.trainable_variables() <NEW_LINE> l2_reg_loss = tf.add_n([tf.nn.l2_loss(var) for var in variables]) <NEW_LINE> softmax_losses = tf.nn.softmax_cross_entropy_with_logits(labels... | Build loss function for the model training.
:param kwargs: dict, extra arguments for regularization term.
- weight_decay: float, L2 weight decay regularization coefficient.
:return tf.Tensor. | 625941bf31939e2706e4cdb1 |
def test_initialisation(self): <NEW_LINE> <INDENT> if self.__class__ != TestPlayer: <NEW_LINE> <INDENT> player = self.player() <NEW_LINE> self.assertEqual(player.history, []) <NEW_LINE> self.assertEqual(player.tournament_attributes, {'length': -1, 'game': DefaultGame, 'noise': 0}) <NEW_LINE> self.assertEqual(player.coo... | Test that the player initiates correctly. | 625941bf30dc7b76659018ad |
def test(D, P, fields=fields, values=values): <NEW_LINE> <INDENT> correct = 0 <NEW_LINE> for i in range(len(D)): <NEW_LINE> <INDENT> if predict(D[i], P, fields, values) == D[i]['result']: <NEW_LINE> <INDENT> correct += 1 <NEW_LINE> <DEDENT> <DEDENT> return(correct / len(D)) | returns the % our train/predict functions got correct vs the results
D is list of respondants dictionaries
P is result of train | 625941bf2eb69b55b151c7f0 |
def Optimization(self, L0, maxiter): <NEW_LINE> <INDENT> result = minimize(self.objective_function, self.to_vector(L0), method='trust-constr', constraints=self.cons, options={'maxiter': maxiter, 'verbose': 3, 'gtol': 1e-8}) <NEW_LINE> result.x = self.to_matrix(result.x) <NEW_LINE> return result | Optimization, method a Trust region
param L0: initial guess
param maxiter: maximum of iterations
return: result (Laplacian) | 625941bfd4950a0f3b08c295 |
def un_gz(self, infile, outfile): <NEW_LINE> <INDENT> import subprocess <NEW_LINE> try: <NEW_LINE> <INDENT> subprocess.check_call('gunzip -c %s > %s', shell=True) <NEW_LINE> <DEDENT> except subprocess.CalledProcessError as e: <NEW_LINE> <INDENT> raise | Decompress gzip file. | 625941bfd268445f265b4db2 |
def parse_td(row_html): <NEW_LINE> <INDENT> return row_html.find_all(("td", "th"), recursive=False) | Return the td elements from a row element.
Parameters
----------
obj : node-like
A DOM <tr> node.
Returns
-------
list of node-like
These are the elements of each row, i.e., the columns. | 625941bffb3f5b602dac35d4 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, GETAccountSummaryTypeTaxInfo): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941bf99cbb53fe6792b2b |
def _get_best_move(_board: Board, _depth: int, _base_move: Move, _board_eval: Callable): <NEW_LINE> <INDENT> alpha = LOW_BOUND <NEW_LINE> beta = HIGH_BOUND <NEW_LINE> _counter = 0 <NEW_LINE> _player = _board.turn <NEW_LINE> _board.make_move(_base_move) <NEW_LINE> _value, _counter = _alpha_beta_max(_board, _depth - 1, a... | Helper function for running alpha_beta on multiple threads. | 625941bf3d592f4c4ed1cfb8 |
def hashes(self, trust_internet=True): <NEW_LINE> <INDENT> good_hashes = self.options.get('hashes', {}).copy() <NEW_LINE> link = self.link if trust_internet else self.original_link <NEW_LINE> if link and link.hash: <NEW_LINE> <INDENT> good_hashes.setdefault(link.hash_name, []).append(link.hash) <NEW_LINE> <DEDENT> retu... | Return a hash-comparer that considers my option- and URL-based
hashes to be known-good.
Hashes in URLs--ones embedded in the requirements file, not ones
downloaded from an index server--are almost peers with ones from
flags. They satisfy --require-hashes (whether it was implicitly or
explicitly activated) but do not a... | 625941bf6fece00bbac2d681 |
def output_multiple(self): <NEW_LINE> <INDENT> return _blocks_swig4.or_ii_sptr_output_multiple(self) | output_multiple(or_ii_sptr self) -> int | 625941bf21a7993f00bc7c30 |
@pytest.fixture() <NEW_LINE> def create_db_instance(null_db_instances, clean_db): <NEW_LINE> <INDENT> database = Database(of_type='MongoDB', name='orion_test', username='user', password='pass') <NEW_LINE> return database | Create and save a singleton database instance. | 625941bf71ff763f4b5495cb |
def getCommunity(self, communityId): <NEW_LINE> <INDENT> return self._communities[communityId] | Getter
@param communityId: ID of the community to return
@type communityId: C{String}
@return: The community with the given id from the community repository.
@rtype: L{Community} | 625941bf6e29344779a62558 |
def get_roc(self): <NEW_LINE> <INDENT> return self.get_statistics() | See :meth:`get_statistics` | 625941bfb57a9660fec337c5 |
def _create_chord_entry(task_id, task_class, message_body, user_id): <NEW_LINE> <INDENT> args = message_body['args'] <NEW_LINE> kwargs = message_body['kwargs'] <NEW_LINE> arguments_dict = task_class.arguments_as_dict(*args, **kwargs) <NEW_LINE> name = task_class.generate_name(arguments_dict) <NEW_LINE> total_steps = ta... | Create and update status records for a new :py:class:`UserTaskMixin` in a Celery chord. | 625941bf925a0f43d2549db9 |
def numWays(self, n, k): <NEW_LINE> <INDENT> if n==0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> if n==1: <NEW_LINE> <INDENT> return k <NEW_LINE> <DEDENT> pre1 = k <NEW_LINE> pre2 = k*k <NEW_LINE> ans = k*k <NEW_LINE> for i in xrange(2,n): <NEW_LINE> <INDENT> ans = (k-1)*pre1+(k-1)*pre2 <NEW_LINE> pre1 = pre2 <NE... | :type n: int
:type k: int
:rtype: int | 625941bf5fcc89381b1e1601 |
def _paste(self, box): <NEW_LINE> <INDENT> x = self.x[self.yi_remaining] <NEW_LINE> res_dim = determine_restricted_dims(box._box_lims[-1], self._box_init) <NEW_LINE> possible_pastes = [] <NEW_LINE> for u in res_dim: <NEW_LINE> <INDENT> logging.getLogger(__name__).info("pasting "+u) <NEW_LINE> dtype = self.x.dtype.field... | Executes the pasting phase of the PRIM. Delegates pasting to data
type specific helper methods. | 625941bf60cbc95b062c6487 |
def _dvr_router_notifications_for_live_migration( self, with_floatingip=False): <NEW_LINE> <INDENT> HOST1, HOST2 = 'host1', 'host2' <NEW_LINE> for host in [HOST1, HOST2]: <NEW_LINE> <INDENT> helpers.register_l3_agent( host=host, agent_mode=constants.L3_AGENT_MODE_DVR) <NEW_LINE> <DEDENT> router = self._create_router() ... | Check the router notifications go to the right hosts
with live migration without hostbinding on the port. | 625941bf15baa723493c3eb8 |
def test_caches_init_2(self): <NEW_LINE> <INDENT> cache = Caches(True) <NEW_LINE> self.assertEqual(cache.rmse, 0) | Tests to see that Caches' rmse value is initialized to 0 | 625941bf56b00c62f0f1459c |
def exp(x): <NEW_LINE> <INDENT> return Variable.from_jvalue(callBigDlFunc("float", "exp", x)) | Element-wise exponential.
:param x: A variable.
:return: A variable. | 625941bfd164cc6175782c92 |
def sort(read_filename, write_filename): <NEW_LINE> <INDENT> formatter = '%Y-%m-%d %H' <NEW_LINE> read_fp = file(read_filename, 'rb') <NEW_LINE> reader = csv.reader(read_fp) <NEW_LINE> data = {} <NEW_LINE> for line in reader: <NEW_LINE> <INDENT> if reader.line_num == 1: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> ... | Extract features from the dataset. | 625941bfcc40096d61595896 |
def execute_and_get(self, query): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with self.connection: <NEW_LINE> <INDENT> cursor = self.connection.cursor() <NEW_LINE> cursor.execute(query) <NEW_LINE> return cursor <NEW_LINE> <DEDENT> <DEDENT> except sqlite3.Error as e: <NEW_LINE> <INDENT> print("Error executing query: \... | Unsafe query executor. Used when query output matters.
:param query: query to execute
:return: Cursor object that was used to execute the query. None if query was unsuccessful | 625941bfa8370b77170527e5 |
def take_fast_steps(): <NEW_LINE> <INDENT> active_canidates = list(self.dispersy_yield_verified_candidates()) <NEW_LINE> if len(active_canidates) > FAST_WALKER_CANDIDATE_TARGET: <NEW_LINE> <INDENT> self._logger.debug("there are %d active candidates available, " "quitting fast walker", len(active_canidates)) <NEW_LINE> ... | Walk to all the initial and new eligible candidates.
Stop if we got enough active candidates. | 625941bfa05bb46b383ec768 |
def refreshBrowser(self): <NEW_LINE> <INDENT> self.driver.refresh() | :return: | 625941bf7c178a314d6ef39f |
def get_session_seats(self, session_number, availability=0): <NEW_LINE> <INDENT> message = VIFMessage() <NEW_LINE> message.set_request_header(request_code=20, **self.header_data()) <NEW_LINE> body_data = { 'session_number': session_number, 'availability': availability } <NEW_LINE> body_record = VIFRecord(record_code='q... | Record code: 20
Description: Can be used to retrieve a snapshot of the current seating
status for the specified session.
Availability:
0=Get All Seats
1=Available
2=Unavailable
Body: q20 record
Response: pl4 record | 625941bf4e4d5625662d431f |
def test_check_haproxy_percents_for_backend_test_ok(self): <NEW_LINE> <INDENT> with patch("check_haproxy_stats.check_haproxy_stats_up.get_haproxy_services_up_count_for_backends") as get_backend_counts: <NEW_LINE> <INDENT> get_backend_counts.return_value = { 'backend-1': { 'count': 2, 'up_count': 2, }, 'backend-2': { 'c... | Test backend-1 check only tests backend-1 up percent with warning ratio and critical ratio of 0.90 and 0.60.
check_haproxy_up_rates should return OK code. | 625941bfd268445f265b4db3 |
def test_run_entire_full_x_full_y(init_entire, create_db_instance): <NEW_LINE> <INDENT> experiment = EVCBuilder().build_view_from({'name': 'full_x_full_y'}) <NEW_LINE> assert len(experiment.fetch_trials_tree({})) == 23 <NEW_LINE> assert len(experiment.fetch_trials({})) == 4 <NEW_LINE> kleio.core.cli.main(("-vv hunt --m... | Test if branched experiment can be executed without triggering a branching event again | 625941bf71ff763f4b5495cc |
def run_experiment(self): <NEW_LINE> <INDENT> return self.algorithms[self.algorithm]() | Runs the specified prediction experiment for the given user and returns the results
:return: A dict containing a list of predictions, the corresponding ground truth values, and patient level
performance measures TODO: refine | 625941bf30c21e258bdfa3e0 |
def create_lun(self): <NEW_LINE> <INDENT> path = '/vol/%s/%s' % (self.flexvol_name, self.name) <NEW_LINE> lun_create = netapp_utils.zapi.NaElement.create_node_with_children( 'lun-create-by-size', **{'path': path, 'size': str(self.size), 'ostype': self.ostype, 'space-reservation-enabled': str(self.space_reserve), 'space... | Create LUN with requested name and size | 625941bf7b25080760e3939e |
def diff_cost(diff): <NEW_LINE> <INDENT> return tf.reduce_mean(tf.square(diff)) | Returns a tf scalar that's the cost due to the difference between
the two images. | 625941bf9c8ee82313fbb6b9 |
def main_c2(): <NEW_LINE> <INDENT> application = tornado.web.Application([ (ROOT_PATH_QUERY, RPQ), (SITE_PATH_QUERY, SPQ), (r'/.*', UnknownPageHandler) ]) <NEW_LINE> if SSL: <NEW_LINE> <INDENT> http_server = tornado.httpserver.HTTPServer( application, ssl_options={'certfile': CERT_FILE, 'ssl_version': ssl.PROTOCOL_TLSv... | Start C2 Server. | 625941bfdc8b845886cb5478 |
def sign(self, digest): <NEW_LINE> <INDENT> raise NotImplementedError() | Sign the specified message.
:param digest: An AMQP message digest.
:type digest: str
:return: The message signature.
:rtype: str | 625941bf462c4b4f79d1d615 |
def test_rule_create_after_invalid(self): <NEW_LINE> <INDENT> rule = dict(name='one_rule', source='any', destination='any', interface='lan', after='admin_bypass') <NEW_LINE> self.do_rule_creation_test(rule, failed=True, msg='Failed to insert after rule=admin_bypass interface=lan') | test creation of a new rule after an invalid rule | 625941bf0a50d4780f666dd5 |
def sigcheck(a_key, a_hash_for_sig, a_sig): <NEW_LINE> <INDENT> r, s = sigdecode_der(a_sig) <NEW_LINE> return ecdsa_verify(generator_secp256k1, a_key.public_pair(), a_hash_for_sig, ( r, s )) | Returns True if a_key was used to generate a_sig from a_hash_for_sig;
False otherwise. | 625941bfc432627299f04b89 |
def draw_dt_gt_dets(image, dt_boxes, dt_label, gt_boxes, gt_label, vis_diff=False): <NEW_LINE> <INDENT> if vis_diff: <NEW_LINE> <INDENT> assert len(gt_label) == len(dt_label) <NEW_LINE> assert len(gt_boxes) == len(dt_boxes) <NEW_LINE> for i in range(len(gt_label)): <NEW_LINE> <INDENT> if dt_label[i] == gt_label[i]: <NE... | 显示ground true和Detection bbox
:param image:
:param dt_boxes:
:param dt_label:
:param gt_boxes:
:param gt_label:
:param vis_diff: 是否显示差异,
vis_diff=True :使用不同颜色标记gt_label和dt_label的差异
要求len(gt_label) == len(dt_label)
vis_diff=False:使用不同颜色显示dt_boxes和gt_boxes
... | 625941bf2eb69b55b151c7f1 |
def format_element(bfo): <NEW_LINE> <INDENT> pagination = bfo.field('300__a') <NEW_LINE> return pagination | Prints the record pagination
@see: date.py, publisher.py, reprints.py, imprint.py, place.py | 625941bf1b99ca400220a9f6 |
def plot_redblue(party, x='date', y='daily_positives', days=0): <NEW_LINE> <INDENT> df = get_state_data() <NEW_LINE> fig, ax = plt.subplots(figsize=(8, 8)) <NEW_LINE> fig.autofmt_xdate() <NEW_LINE> ax.fmt_xdata = mdates.DateFormatter('%m-%d') <NEW_LINE> df = df[df['Governor'] == party] <NEW_LINE> if party == 'republica... | plot states with red or blue governors | 625941bf004d5f362079a27a |
def test_exclude_should_work_on_sequence_too(self): <NEW_LINE> <INDENT> class PersonTable(tables.Table): <NEW_LINE> <INDENT> first_name = tables.Column() <NEW_LINE> last_name = tables.Column() <NEW_LINE> occupation = tables.Column() <NEW_LINE> class Meta: <NEW_LINE> <INDENT> sequence = ('first_name', 'last_name', 'occu... | It should be possible to define a sequence on a table
and exclude it in a child of that table. | 625941bfeab8aa0e5d26da9c |
def __init__(self, lexer, grammar): <NEW_LINE> <INDENT> self.lexer = lexer <NEW_LINE> self.grammar = grammar <NEW_LINE> self.cur_token = None <NEW_LINE> self.parser_tree = [] | Create a grammar parser.
Arguments
---------
lexer -- Lexer instance to use as input
grammar -- A list of rules
Each entry is a rule which is a tuple
(`symbol`, `expression`, `action`)
`symbol` is the name of a nonterminal symbol to be
... | 625941bf24f1403a92600aad |
def generate_char(dark, mode, char_set): <NEW_LINE> <INDENT> import random <NEW_LINE> if len(char_set[dark]) > 0: <NEW_LINE> <INDENT> if "l" in mode: <NEW_LINE> <INDENT> char = char_set[dark][0] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> char = char_set[dark][random.randint(0, len(char_set[dark]) - 1)] <NEW_LINE> <D... | Select a courier character based on a darkness level. | 625941bf2ae34c7f2600d076 |
def ParticleFilterSearch_ExperimentalTests(pop_size = 50, iterations = 40): <NEW_LINE> <INDENT> if True: <NEW_LINE> <INDENT> imf, imd , pat_list, pose_list = pattern_utils.make_test_image_1(True) <NEW_LINE> ipat = 2 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> imf, imd , pat_list, pose_list = pattern_utils.make_test_i... | We created this function in order to be able to test the particle filter seach and find the experimental results.
This function is very similar to the test_particle_filter_search function with minor changes to make testing simpler. | 625941bf656771135c3eb7b1 |
def get_xpath(path: str, tree: html.HtmlElement): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> element = tree.xpath(path)[0] <NEW_LINE> <DEDENT> except IndexError as e: <NEW_LINE> <INDENT> ebay_logger.error(f'{e.__class__}: {path}: {e}') <NEW_LINE> return None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return elemen... | Looks for path/element in tree
:param path: str, valid xpath search string
:param tree: html.HtmlElement from lxml
:return: element, based on path; or None if not found | 625941bf8a43f66fc4b53fac |
def upload_example_old(): <NEW_LINE> <INDENT> response.files.append(URL(r=request, c='static/js', f='fileuploader.js')) <NEW_LINE> response.files.append(URL(r=request, c='static/css', f='fileuploader.css')) <NEW_LINE> response.files.append(URL(r=request, c='static/js/thatsit/global', f='use_fileuploader.js')) <NEW_LINE... | Renomeei em 2013/1/14 para old, para utilizar
o SQLFORM disponibilizado out-of-the-box pelo
web2py (permite nao guardar imediatamente na
BD, pelo que podemos em vez disso fazer o
upload via WebService para o cliente -
realizado nas actions upload_first() e upload_new() | 625941bf187af65679ca5063 |
def event_data_dict_to_list(event_data_dict): <NEW_LINE> <INDENT> run_dicts = event_data_dict.values() <NEW_LINE> return reduce(lambda x, y: x + y, [d.values() for d in run_dicts]) | Converts the dict-based representation of event data for a label to
a flat list of event data objects. | 625941bfab23a570cc2500c5 |
def register_filter(filter_dir, filter_type, filter_name): <NEW_LINE> <INDENT> cmd = ['git', 'config', '--local', 'filter.rcs-keywords.%s' % filter_type, '%s %s' % (os.path.join(filter_dir, filter_name), '%f')] <NEW_LINE> execute_cmd(cmd=cmd) | Register a git filter for rcs-keywords functionality
Arguments:
filter_dir: Directory to hold the filter program
filter_type: Type of the filter program
filter_name: Source program of the filter to be copied
Returns:
None | 625941bf2ae34c7f2600d077 |
def removeRemote(self, remote, clear=True): <NEW_LINE> <INDENT> super(RoadStack, self).removeRemote(remote=remote, clear=clear) <NEW_LINE> for transaction in remote.transactions.values(): <NEW_LINE> <INDENT> transaction.nack() | Remove remote at key uid.
If clear then also remove from disk | 625941bf5fc7496912cc38c3 |
def is_relative_to(path1: pathlib.Path, path2: os.PathLike) -> bool: <NEW_LINE> <INDENT> result = False <NEW_LINE> try: <NEW_LINE> <INDENT> path1.relative_to(path2) <NEW_LINE> result = True <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> return result | Returns whether or not `path1` is relative to `path2`.
Parameters
----------
path1
path compared with `path2`
path2
path compared with `path1`
Returns
-------
bool
True, if `path1` is relative to `path2` | 625941bf56b00c62f0f1459d |
def configure(self, default_settings=global_settings, **options): <NEW_LINE> <INDENT> if self._wrapped is not empty: <NEW_LINE> <INDENT> raise RuntimeError('Settings already configured.') <NEW_LINE> <DEDENT> holder = UserSettingsHolder(default_settings) <NEW_LINE> for name, value in options.items(): <NEW_LINE> <INDENT>... | Called to manually configure the settings. The 'default_settings'
parameter sets where to retrieve any unspecified values from (its
argument must support attribute access (__getattr__)). | 625941bf7cff6e4e811178cb |
def _get_version_family(): <NEW_LINE> <INDENT> current_version = CASSANDRA_VERSION_FROM_BUILD <NEW_LINE> version_family = 'unknown' <NEW_LINE> if current_version.vstring.startswith('2.0'): <NEW_LINE> <INDENT> version_family = '2.0.x' <NEW_LINE> <DEDENT> elif current_version.vstring.startswith('2.1'): <NEW_LINE> <INDENT... | Detects the version family (line) using dtest.py:CASSANDRA_VERSION_FROM_BUILD | 625941bf5f7d997b871749da |
def __init__(self): <NEW_LINE> <INDENT> Language.__init__(self) <NEW_LINE> self.name = 'lexicon' | Initializes lexicon according to super class RuleDict. | 625941bf91f36d47f21ac435 |
def keys(self): <NEW_LINE> <INDENT> queue = Queue() <NEW_LINE> x = self._first <NEW_LINE> while x is not None: <NEW_LINE> <INDENT> queue.enqueue(x._key) <NEW_LINE> x = x._next <NEW_LINE> <DEDENT> return queue | Returns all keys in the symbol table as an Iterable. | 625941bfa219f33f346288b2 |
def mangle_build_prop_hook(prop, overrides): <NEW_LINE> <INDENT> prop.put("ro.com.android.dateformat", "yyyy-MM-dd") <NEW_LINE> pass | call mangle_build_prop_hook | 625941bf3346ee7daa2b2caf |
def _is_iter(lst): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return list(lst) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return False | Is ``lst`` an iterator?
| 625941bf009cb60464c632f9 |
def set_cron_job(backup_time,backup_dir,cloud_loc): <NEW_LINE> <INDENT> os.system("sudo touch cron_container.txt") <NEW_LINE> os.system("crontab -l > cron_container.txt") <NEW_LINE> crontab_cmd = backup_time + " sudo backuputil -p " + backup_dir + " -b " + cloud_loc <NEW_LINE> os.system('echo "' + crontab_cmd + '" >> c... | Sets a cron job at the specified backup_time to back up the
files in the specified directory at the specified cloud location | 625941bf55399d3f055885f8 |
def projector(detector_name, inj, hp, hc, distance_scale=1): <NEW_LINE> <INDENT> detector = Detector(detector_name) <NEW_LINE> hp /= distance_scale <NEW_LINE> hc /= distance_scale <NEW_LINE> try: <NEW_LINE> <INDENT> tc = inj.tc <NEW_LINE> ra = inj.ra <NEW_LINE> dec = inj.dec <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDE... | Use the injection row to project the polarizations into the
detector frame | 625941bf99cbb53fe6792b2c |
def _best_affine_patch(self, point): <NEW_LINE> <INDENT> point = list(point) <NEW_LINE> try: <NEW_LINE> <INDENT> abs_point = [abs(_) for _ in point] <NEW_LINE> <DEDENT> except ArithmeticError: <NEW_LINE> <INDENT> abs_point = point <NEW_LINE> <DEDENT> i_max = 0 <NEW_LINE> p_max = abs_point[i_max] <NEW_LINE> for i in ran... | Return the best affine patch of the ambient projective space.
The "best" affine patch is where you end up dividing by the
homogeneous coordinate with the largest absolute
value. Division by small numbers is numerically unstable.
INPUT:
- ``point`` -- a point of the algebraic subscheme.
OUTPUT:
Integer. The index o... | 625941bf76d4e153a657ea75 |
def validate_name(self, name): <NEW_LINE> <INDENT> chat = Chat.query.filter_by(name=name.data).first() <NEW_LINE> if chat is not None: <NEW_LINE> <INDENT> raise ValidationError('Пожалуста, используйте другое название для беседы.') | метод проверки названия чата
:param name: название чата
:type name: строка
:return: ничего не возвращает | 625941bf63b5f9789fde702a |
def check_hardlinked_pkg(env:Environment, Pkg:Package) -> list: <NEW_LINE> <INDENT> bad_linked = [] <NEW_LINE> expected_linked = Pkg.files - Pkg.has_prefix.keys() - Pkg.no_link <NEW_LINE> for f in expected_linked: <NEW_LINE> <INDENT> src = join(Pkg.path, f) <NEW_LINE> tgt = join(env.path, f) <NEW_LINE> if not is_hardli... | Check that pkg in cache is correctly (or completely) hardlinked into env.
Returns a list of improperly hardlinked files. | 625941bfcb5e8a47e48b79f2 |
def correctInPlace(x): <NEW_LINE> <INDENT> s = np.sum(x, axis=1) <NEW_LINE> s /= np.mean(s[s != 0]) <NEW_LINE> s[s == 0] = 1 <NEW_LINE> s2 = np.sum(x, axis=0) <NEW_LINE> s2 /= np.mean(s2[s2 != 0]) <NEW_LINE> s2[s2 == 0] = 1 <NEW_LINE> x /= (s2[None, :] * s[:, None]) | works for non-symmetric and symmetric data | 625941bf090684286d50ec28 |
def filter_bad_stats(stats, settings): <NEW_LINE> <INDENT> mmr = stats['minor_axis_length'] / stats['major_axis_length'] <NEW_LINE> stats = stats[mmr > settings.Process.min_deformation] <NEW_LINE> stats = stats[(stats['major_axis_length'] * settings.PostProcess.pix_size) < settings.Process.max_length] <NEW_LINE> return... | remove unacceptable particles from the stats
Note that for oil and gas analysis, this filtering is handled by the functions in the pysilcam.oilgas module.
Args:
stats (DataFrame) : particle statistics from silcam process
settings (PySilcamSettings) : settings associated with the data, loaded with Py... | 625941bf10dbd63aa1bd2aeb |
def modified_We_model(D, rho_gas, m_gas, mu_gas, sigma_gas, rho_oil, m_oil, mu_oil, sigma_oil, rho): <NEW_LINE> <INDENT> if not isinstance(m_gas, np.ndarray): <NEW_LINE> <INDENT> if not isinstance(m_gas, list): <NEW_LINE> <INDENT> m_gas = np.array([m_gas]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> m_gas = np.array(... | This function is deprecated: Use psf.sintef() instead.
Compute the initial oil droplet and gas bubble sizes from the SINTEF model
Apply the SINTEF modified Weber number model to estimate the initial
oil and gas particle sizes. This function calculates the adjusted exit
velocity based on a void fraction and buoyanc... | 625941bf3cc13d1c6d3c72c0 |
@manager.command <NEW_LINE> def load_initial_data(): <NEW_LINE> <INDENT> with open("states.csv", "r") as states_file: <NEW_LINE> <INDENT> preload_data(csv.reader(states_file)) | Load initial data into database. | 625941bf67a9b606de4a7e00 |
def union(self, x, y): <NEW_LINE> <INDENT> parent_x = self.find(x) <NEW_LINE> parent_y = self.find(y) <NEW_LINE> if parent_x != parent_y: <NEW_LINE> <INDENT> merge_from, merge_to = sorted([parent_x, parent_y], key=lambda i: self._items[i][1]) <NEW_LINE> self._items[merge_from][0] = merge_to <NEW_LINE> self._items[merge... | Merges sets containing two different items together. If items already
belong to same set does nothing.
Args:
x: First item.
y: Second item. | 625941bf97e22403b379cede |
def render_and_write(template_name, context, output_name, output_dir): <NEW_LINE> <INDENT> template = templates_env.get_template(template_name) <NEW_LINE> f = open(path.join(output_dir, output_name), "w") <NEW_LINE> f.write(template.render(**context)) <NEW_LINE> f.close() | Render `template_name` with `context` and write the result in the file
`output_dir`/`output_name`. | 625941bfe64d504609d74785 |
def resolve_bg_path(bgpth0): <NEW_LINE> <INDENT> if not os.path.isfile(bgpth0): <NEW_LINE> <INDENT> bgpth = os.path.join(gt.BACKGROUND_PATH, os.path.basename(bgpth0)) <NEW_LINE> if not os.path.isfile(bgpth): <NEW_LINE> <INDENT> raise IOError("Not a valid background file: %s" % bgpth) <NEW_LINE> <DEDENT> <DEDENT> else: ... | Finds a valid background path. | 625941bf4c3428357757c26f |
def constants(self): <NEW_LINE> <INDENT> const_dict = {} <NEW_LINE> constants_ = self.objective.constants() <NEW_LINE> for constr in self.constraints: <NEW_LINE> <INDENT> constants_ += constr.constants() <NEW_LINE> <DEDENT> const_dict = {id(constant): constant for constant in constants_} <NEW_LINE> return list(const_di... | Accessor method for parameters.
Returns
-------
list of :class:`~cvxpy.expressions.constants.constant.Constant`
A list of the constants in the problem. | 625941bf566aa707497f44b2 |
def typecheck(value, type: t.Union[Type, type], value_name: str = None): <NEW_LINE> <INDENT> if not bool(isinstance(value, type)): <NEW_LINE> <INDENT> ret = verbose_isinstance(value, type, value_name) <NEW_LINE> if not ret: <NEW_LINE> <INDENT> raise TypeError(str(ret)) | Like verbose_isinstance but raises an error if the value hasn't the expected type.
:param value: passed value
:param type: expected type of the value
:param value_name: optional description of the value
:raises: TypeError | 625941bfb830903b967e9853 |
def __sub__(self, other): <NEW_LINE> <INDENT> return Vector2(self.x - other.x, self.y - other.y) | Subtract the two vectors component wise.
Example:
.. code-block:: python
from pygorithm.geometry import vector2
vec1 = vector2.Vector2(5, 5)
vec2 = vector2.Vector2(2, 3)
vec3 = vec1 - vec2
vec4 = vec2 - vec1
# prints <3, 2>
print(vec3)
# prints <2, 3>
print(ve... | 625941bfeab8aa0e5d26da9d |
def list_topics(self, page_size=None, page_token=None): <NEW_LINE> <INDENT> api = self.publisher_api <NEW_LINE> return api.list_topics( self.project, page_size, page_token) | List topics for the project associated with this client.
See:
https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/list
Example:
.. literalinclude:: pubsub_snippets.py
:start-after: [START client_list_topics]
:end-before: [END client_list_topics]
:type page_size: int
:param page_size: maximu... | 625941bf07d97122c41787cc |
def post_payload_to_ingest_service(insights_upload, local_path): <NEW_LINE> <INDENT> insights_account_id = os.environ.get("INSIGHTS_ACCOUNT_ID") <NEW_LINE> insights_org_id = os.environ.get("INSIGHTS_ORG_ID") <NEW_LINE> insights_user = os.environ.get("INSIGHTS_USER") <NEW_LINE> insights_password = os.environ.get("INSIGH... | POST the payload to Insights via header or basic auth. | 625941bf21a7993f00bc7c31 |
def update_gui (self): <NEW_LINE> <INDENT> self.update_stbv_list() <NEW_LINE> self.update_package_list() <NEW_LINE> return | Update the GUI.
This method should be called upon package loading, or when a
new view or type is created, or when an existing one is
modified, in order to reflect changes. | 625941bfd18da76e23532419 |
def run(self): <NEW_LINE> <INDENT> jobs = self.store.get_jobs() <NEW_LINE> for job in jobs: <NEW_LINE> <INDENT> id_ = job['id'] <NEW_LINE> try: <NEW_LINE> <INDENT> self._initialize_job(id_, load_events=True) <NEW_LINE> <DEDENT> except JobDeleted: <NEW_LINE> <INDENT> print('Warning: job', id_, 'has vanished') <NEW_LINE>... | Monitor thread main run function.
When the thread is started, this function will run. It begins
by fetching a list of jobs and using them to populate its
data structures. When this is complete, the Event status_ready
is fired.
It then goes into a loop, and every few seconds it checks
for new events, processing any ... | 625941bf76e4537e8c3515b6 |
def test_state_sls_id_test(self): <NEW_LINE> <INDENT> self._add_runtime_pillar(pillar={'test': True}) <NEW_LINE> ret = self.run_function('state.sls', ['core']) <NEW_LINE> for key, val in ret.items(): <NEW_LINE> <INDENT> self.assertEqual(val['comment'], 'The file /tmp/salt-tests-tmpdir/testfile is set to be changed') <N... | test state.sls_id when test is set
to true in pillar data | 625941bf6fece00bbac2d682 |
def build_data(self, training_instances="all_events", log=True): <NEW_LINE> <INDENT> variables = self.extractor.get_variable_names() <NEW_LINE> self.training_instances = training_instances <NEW_LINE> self.data = self.extractor.build_dataframe(training_instances) <NEW_LINE> self.log("There are " + str(len(variables)) + ... | (3)
Method that builds the data to be used by the graphical model library.
-----------------
Parameters:
training_instances :
support -- to use duplicated training instances based on the support of the frequent sets
all_events -- to generate one training instance per event (in "disti... | 625941bf5fdd1c0f98dc0178 |
def fixProgram(p): <NEW_LINE> <INDENT> ret = None <NEW_LINE> for i,val in enumerate(program): <NEW_LINE> <INDENT> cmd = program[i][0] <NEW_LINE> if cmd == 'nop': <NEW_LINE> <INDENT> program[i][0] = 'jmp' <NEW_LINE> <DEDENT> elif cmd == 'jmp': <NEW_LINE> <INDENT> program[i][0] = 'nop' <NEW_LINE> <DEDENT> else: <NEW_LINE... | A program `p` is correct, if it terminates
without a cycle detected. This function tries
to fix a corrupted program changing exactly
one jmp instruction to nop or nop to jmp. | 625941bf293b9510aa2c31de |
def get(self, request): <NEW_LINE> <INDENT> alloy_type_query_set = alloy_model.AlloyType.objects.defer("version", "create_time", "update_time").filter( is_delete=False) <NEW_LINE> total_alloy_type = len(alloy_type_query_set) <NEW_LINE> try: <NEW_LINE> <INDENT> page_num = int(request.GET.get("page", 1)) <NEW_LINE> <DEDE... | 合金展示 | 625941bfd164cc6175782c93 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.