code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def main(): <NEW_LINE> <INDENT> args = get_args() <NEW_LINE> results, timestamps = [], [] <NEW_LINE> prev_kp, prev_des, prev_name = None, None, None <NEW_LINE> for img_path in sorted(args.frames_dir.glob('*.*')): <NEW_LINE> <INDENT> timestamps.append(time.time()) <NEW_LINE> img = cv2.imread(str(img_path)) <NEW_LINE> kp... | Application entry point. | 625941e23cc13d1c6d3c772e |
@cli.command() <NEW_LINE> @click.option('--source', 'source', help='source.') <NEW_LINE> @click.option('--destination', 'destination', help='destination.') <NEW_LINE> def copy(source, destination): <NEW_LINE> <INDENT> fc = FileCopier() <NEW_LINE> source_content = fc.get_source(source) <NEW_LINE> success = fc.put_destin... | Copy one file. | 625941e263b5f9789fde749b |
def update(item): <NEW_LINE> <INDENT> global w,b,history <NEW_LINE> w[0] += 1* item[1] * item[0][0] <NEW_LINE> w[1] += 1* item[1]* item[0][1] <NEW_LINE> b += 1* item[1] <NEW_LINE> print(w,b) <NEW_LINE> history.append([copy.copy(w),b]) | update parameters using stochastic gradient descent
:param item: an item which is classified into wrong class
:return: nothing | 625941e2097d151d1a22320d |
def _make_new_obs(obs, im): <NEW_LINE> <INDENT> psf_obs=Observation(obs.psf.image, jacobian=obs.psf.jacobian, gmix=obs.psf.gmix.copy()) <NEW_LINE> newobs=Observation(im, jacobian=obs.jacobian, weight=obs.weight, psf=psf_obs) <NEW_LINE> return newobs | only diff is im | 625941e2bf627c535bc13585 |
def dumpLabels(f=None): <NEW_LINE> <INDENT> if f==None: <NEW_LINE> <INDENT> import sys <NEW_LINE> f = sys.stdout <NEW_LINE> <DEDENT> f.write("LABELS:\n") <NEW_LINE> for label in defines: <NEW_LINE> <INDENT> f.write(" " + label + ":" + str(defines[label]) + "\n") | Dump the whole symbol table to stdout | 625941e273bcbd0ca4b2c42b |
def write(self, text): <NEW_LINE> <INDENT> with self._stdout_lock: <NEW_LINE> <INDENT> sys.stdout.write("\r") <NEW_LINE> self._clear_line() <NEW_LINE> _text = to_unicode(text) <NEW_LINE> if PY2: <NEW_LINE> <INDENT> _text = _text.encode(ENCODING) <NEW_LINE> <DEDENT> assert isinstance(_text, builtin_str) <NEW_LINE> sys.s... | Write text in the terminal without breaking the spinner. | 625941e23617ad0b5ed682ac |
def test_iter_returns_correctly_sized_slice(iterable_with_correct_size): <NEW_LINE> <INDENT> iterable, n = iterable_with_correct_size <NEW_LINE> items = slicer.iter_slice(iterable, n) <NEW_LINE> assert len(items) == n | Assert that :func:`~pai_parser.slicer.iter_slice` returns 'n' number of items. | 625941e28e7ae83300e4b383 |
def read_info_plc(self): <NEW_LINE> <INDENT> returndict = dict() <NEW_LINE> sheetnames = self._workbook.sheetnames <NEW_LINE> if 'info_PLC' in sheetnames: <NEW_LINE> <INDENT> sheet_object = self._workbook['info_PLC'] <NEW_LINE> for rowOfCellObjects in sheet_object['A1':self.get_last_entry_sheet(sheet_object)]: <NEW_LIN... | returns a dict with the keys IP_adress, rack and slot with it's values | 625941e20383005118ecf997 |
def superuser_required( function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None): <NEW_LINE> <INDENT> actual_decorator = user_passes_test( lambda u: u.is_superuser, login_url=login_url, redirect_field_name=redirect_field_name ) <NEW_LINE> if function: <NEW_LINE> <INDENT> return actual_decorator(function)... | Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary. | 625941e23d592f4c4ed1d419 |
def connect_cells_with_flux(cells, connection, start_at_layer=0): <NEW_LINE> <INDENT> if (hasattr(connection, 'cell_connector') and isinstance(connection.cell_connector, CellConnector)): <NEW_LINE> <INDENT> __ccwf(list(cells), connection.cell_connector, start_at_layer) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> rais... | Connects all cells in cells (sequence or generator) with a flux connection
connection is an subclass of cmf.FluxConnection which exposes the cell_connector callable
(e.g. lateral subsurface fluxes and surface manning flux)
start_at_layer : if the flux connection should only be used for deeper layers | 625941e2d99f1b3c44c6793e |
def get_type(self) -> str: <NEW_LINE> <INDENT> return self.udev_property('ID_FS_TYPE') | Get the filesystem type, e.g. 'ext3' or 'vfat'.
:return: The filesystem type.
:rtype: str | 625941e266673b3332b92447 |
def test_app_model_in_delete_confirmation_body_class(self): <NEW_LINE> <INDENT> response = self.client.get( reverse('admin:admin_views_section_delete', args=(1,))) <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_LINE> self.assertContains(response, '<body class=" app-admin_views model-section ') | Ensure app and model tag are correctly read by delete_confirmation
template | 625941e2283ffb24f3c55cb3 |
def init_option(): <NEW_LINE> <INDENT> Option.objects.create(id=1, weather='晴', api_mode=True) | 共通オプションの生成 | 625941e2e5267d203edce04e |
def __getitem__(self, key): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if not key.start: <NEW_LINE> <INDENT> start = self.offset <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> start = self.offset + key.start <NEW_LINE> <DEDENT> end = self.offset + key.stop <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> raise TypeErro... | Get a slice | 625941e2fb3f5b602dac3a4d |
def pull_and_build_sites(self, all_registered_sites): <NEW_LINE> <INDENT> sites = {} <NEW_LINE> for site_name, registered_site in all_registered_sites.iteritems(): <NEW_LINE> <INDENT> nodes = self._build_nodes_from_bambino_dicts(registered_site['nodes']) <NEW_LINE> site = Site(registered_site['name'], status='unknown',... | Pulls the sites as dicts, creates a site object
and ask the site object to update itself from all the nodes
Example sites_as_dicts:
[
{
"nodes": {
"mtclone-pyweb01": {
"url": "http://192.168.4.13:6666",
"ip": "192.168.4.13",
"name": "mtclone-p... | 625941e2046cf37aa974d0fa |
def _search(self, trans, q, page=1, page_size=10): <NEW_LINE> <INDENT> conf = self.app.config <NEW_LINE> if not conf.toolshed_search_on: <NEW_LINE> <INDENT> raise exceptions.ConfigDoesNotAllowException( "Searching the TS through the API is turned off for this instance." ) <NEW_LINE> <DEDENT> if not conf.whoosh_index_di... | Perform the search over TS tools index.
Note that search works over the Whoosh index which you have
to pre-create with scripts/tool_shed/build_ts_whoosh_index.sh manually.
Also TS config option toolshed_search_on has to be True and
whoosh_index_dir has to be specified. | 625941e2ac7a0e7691ed447c |
def __init__(self, recipes=ALLRECIPES_DICT, search_ingredients=SEARCH_INGREDIENTS): <NEW_LINE> <INDENT> self.recipes = json.loads(open(recipes).read()) <NEW_LINE> for (k, v) in json.loads(open(IDEORECIPES_DICT).read()).items(): <NEW_LINE> <INDENT> self.recipes[k] = v <NEW_LINE> <DEDENT> self.search_ingredients = [v.str... | Initialize handler.
Initialize the handler. Loads the recipe data structure.
Args:
recipes: Path to recipes data structure.
food_hash: Hash from food name to tags and to recipes containing that food.
adj: Adjacency matrix for recipes and ingredients.
sortby_methods: Valid sortby methods. | 625941e2b545ff76a89141cb |
def edges(self): <NEW_LINE> <INDENT> edgelist = [] <NEW_LINE> for node, others in self._data.iteritems(): <NEW_LINE> <INDENT> edgelist.append((node, others)) <NEW_LINE> <DEDENT> return edgelist | Return a list of all edges in the graph. Edges are represented by a
tuple, with the first item being the origin node and the second item
being the target. | 625941e2507cdc57c6307099 |
def test_cpickle(self): <NEW_LINE> <INDENT> tr = Trace(data=np.random.randn(1441)) <NEW_LINE> st = Stream([tr]) <NEW_LINE> st.verify() <NEW_LINE> temp = pickle.dumps(st, protocol=0) <NEW_LINE> st2 = pickle.loads(temp) <NEW_LINE> np.testing.assert_array_equal(st[0].data, st2[0].data) <NEW_LINE> self.assertEqual(st[0].st... | Testing pickling of Stream objects.. | 625941e25510c4643540f791 |
def __call__(self, io, record=None): <NEW_LINE> <INDENT> loc_fmt = self.fmt <NEW_LINE> time_now = datetime.now() <NEW_LINE> date = time_now.strftime(self.fmt_date) <NEW_LINE> time = time_now.strftime(self.fmt_time) <NEW_LINE> format_record = {'date': date, 'time': time} <NEW_LINE> if self.base_record: <NEW_LINE> <INDEN... | Call the location provider to get a new location.
Args:
io (io manager): where we intend to put the new DataSet.
record (dict, optional): information to insert in the format string
Any key provided here will override the default record | 625941e291f36d47f21ac8ac |
def __init__(self, client): <NEW_LINE> <INDENT> self.running = True <NEW_LINE> self.state = 'start' <NEW_LINE> self.screen = pygame.display.set_mode((WIDTH, HEIGHT)) <NEW_LINE> self.clock = pygame.time.Clock() <NEW_LINE> self.background = pygame.image.load('maze.png') <NEW_LINE> self.cell_width = MAZE_WIDTH // COLUMNS ... | Constructor of the Pac-Man Game, with
the game parameters. | 625941e276d4e153a657eee8 |
def addAscendingOrderByColumn(self, name): <NEW_LINE> <INDENT> self.__orderByColumns.append("%s %s" % (name, SQLConstants.ASC)) <NEW_LINE> return self | Add order by column name, explicitly specifying ascending.
@param name The name of the column to order by.
@return A modified Criteria object. | 625941e2a4f1c619b28b03e7 |
def __init__(self, pulp_connection): <NEW_LINE> <INDENT> super(RepositoryActionsAPI, self).__init__(pulp_connection) <NEW_LINE> self.base_path = "/v2/repositories/%s/actions/" | @type: pulp_connection: pulp.bindings.server.PulpConnection | 625941e2711fe17d82542719 |
@cache <NEW_LINE> def _get_sunlight_coverage(area_def, start_time, sza_threshold=90, overpass=None): <NEW_LINE> <INDENT> if area_def.ndim == 1: <NEW_LINE> <INDENT> logger.debug("Source data is 1 dimensional, will not filter based on sunlight coverage.") <NEW_LINE> return False <NEW_LINE> <DEDENT> adp = polygon_for_area... | Get the sunlight coverage of *area_def* at *start_time* as a value between 0 and 1. | 625941e215baa723493c432e |
def count_word(loclow, lochigh): <NEW_LINE> <INDENT> cwkt = 0 <NEW_LINE> ka = loclow <NEW_LINE> while ka < lochigh: <NEW_LINE> <INDENT> if ParseList[ka] == '(NE': <NEW_LINE> <INDENT> ka += 2 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if ParseList[ka][0] != '(' and ParseList[ka][ 0] != '~' and ParseList[ka][0].isalph... | Returns the number of words in ParseList between loclow and lochigh - 1 | 625941e2f8510a7c17cf9ab5 |
def create_title(): <NEW_LINE> <INDENT> title = "\n{:<25s} | {:s} | {:s} | {:s}\n".format("Donor Name", "Total Given", "Num Gifts", "Average Gift") <NEW_LINE> title += ((len(title) - 1) * "-") <NEW_LINE> return title | Create a title for report.
Returns:
title (string): format string with title header for table | 625941e24f88993c3716c41a |
def test_OPTIONS_category_list_with_valid_permissions(self): <NEW_LINE> <INDENT> method = 'options' <NEW_LINE> uri = reverse('category-list') <NEW_LINE> self._test_users_with_valid_permissions(uri, method) <NEW_LINE> self._test_project_users_with_valid_permissions(uri, method) | Test that the method OPTIONS brings back the correct data. | 625941e27c178a314d6ef81b |
def test_flat_levels(self): <NEW_LINE> <INDENT> self.assertEqual(len(self.flat_st.levels), 2) | Checks the levels of the flat tree. | 625941e28c0ade5d55d3ed74 |
def _extract_interface_from_cudf(df, is_info): <NEW_LINE> <INDENT> if not _use_columnar_initializer(df): <NEW_LINE> <INDENT> raise ValueError('Only cudf is supported for initializing as json ' + 'columnar format. For other libraries please ' + 'refer to specific API.') <NEW_LINE> <DEDENT> def get_interface(obj): <NEW_... | This function should be upstreamed to cudf. | 625941e250812a4eaa59c6d4 |
def decode_measurement_campaign(xml, nsmap): <NEW_LINE> <INDENT> decodings = [ ('funding_sources', True, 'str', 'child::cim:fundingSource/text()'), ('projects', True, 'str', 'child::cim:project/@value'), ('rationales', True, 'str', 'child::cim:rationale/text()'), ('responsible_parties', True, decode_responsible_party, ... | Decodes a measurement campaign instance from xml.
Keyword arguments:
xml -- etree xml element from which entity is to be decoded.
nsmap -- set of xml namespace mappings. | 625941e25f7d997b87174e52 |
def process_card_legalities( self, staged_card: StagedCard, existing_card: Optional[Card] = None ) -> None: <NEW_LINE> <INDENT> existing_legalities = ( list(existing_card.legalities.all()) if existing_card else [] ) <NEW_LINE> for format_str, restriction in staged_card.legalities.items(): <NEW_LINE> <INDENT> if not any... | Find CardLegalities for a card to update, create or delete
:param existing_card:
:param staged_card: The StagedCard to find legalities for | 625941e2435de62698dfe004 |
def __init__(self, sis_graph, job_engine, link_outputs=True, clear_errors_once=False, clear_interrupts_once=False, ignore_once=False, start_computations=False, auto_print_stat_overview=True, interative=False, ui=None): <NEW_LINE> <INDENT> threading.Thread.__init__(self) <NEW_LINE> self.start_computations = start_comput... | :param sisyphus.graph.SISGraph sis_graph:
:param sisyphus.engine.EngineBase job_engine:
:param bool link_outputs:
:param bool clear_errors_once:
:param bool start_computations:
:param bool auto_print_stat_overview:
:param JobCleaner|None job_cleaner: | 625941e2d268445f265b5225 |
def test_filter_by_type_post(self): <NEW_LINE> <INDENT> for i in range(3): <NEW_LINE> <INDENT> Item.objects.create( name='Test%s' % i, fabrics=5, item_type='2', stocked=30) <NEW_LINE> <DEDENT> resp = self.client.post(reverse('item-selector'), {'name': 'test form', 'item_type': '1', 'item_class': 'S', 'size': '12', 'fab... | Test the correct by type filter. | 625941e26e29344779a629c6 |
def make_phepos_dict(POS_fh, CHROM): <NEW_LINE> <INDENT> pos_dict = {} <NEW_LINE> with open_file(POS_fh) as POS: <NEW_LINE> <INDENT> POS.readline() <NEW_LINE> for line in POS: <NEW_LINE> <INDENT> line = line.rstrip().split() <NEW_LINE> if line[1] == CHROM: <NEW_LINE> <INDENT> pos_array = np.array(line[2:4]) <NEW_LINE> ... | Function to read in phenotypes (probes, genes, peaks) with their start and end positions and make a dict.
Keys are phenotype IDs; values are start and end positions.
Only stores the information of the phenotypes from the given chromosome. | 625941e27047854f462a17bc |
def is_between(x, y, z): <NEW_LINE> <INDENT> return x<=y and y<=z | Check if y is between x and z | 625941e28da39b475bd6532e |
@App.path(model=model.Tag, path="/tag/{id_}", variables=lambda obj: dict(id_=obj.id)) <NEW_LINE> def get_tag(id_): <NEW_LINE> <INDENT> return model.Tag.get(id=id_) | "Acceso a un tag por su id | 625941e21b99ca400220ae69 |
def hexacode_random(): <NEW_LINE> <INDENT> a = [0]*6 <NEW_LINE> for i in range(3): <NEW_LINE> <INDENT> a = add4(a,hexacode_basis(i,randint(0,3))) <NEW_LINE> <DEDENT> return a | returns a random hexacode vector | 625941e2e64d504609d74bf6 |
def pred_logprob_full(self): <NEW_LINE> <INDENT> full_var_x = self.full_local_update() <NEW_LINE> K = self.K <NEW_LINE> obs = self.obs_full <NEW_LINE> mask = self.mask <NEW_LINE> nmiss = np.sum(mask) <NEW_LINE> if nmiss == 0: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> logprob = np.zeros((nmiss,K)) <NEW_LINE> f... | Compute predictive log-probability of all missing data.
Requires a full forwards-backwards pass.
We may want to do this at some point. | 625941e271ff763f4b549a49 |
def delete_periodic_tasks(): <NEW_LINE> <INDENT> qs = TaskQueue.objects.filter(is_periodic=True) <NEW_LINE> if qs.count(): <NEW_LINE> <INDENT> qs.delete() | Tasks are persistent in the db. Periodic tasks are read in at
process start and will not expire. So they should get deleted
here. | 625941e276e4537e8c351a2c |
def clearData(self): <NEW_LINE> <INDENT> self.typetags = "," <NEW_LINE> self.message = "" | Clear any arguments appended so far
| 625941e20c0af96317bb859e |
def test_errback_reject_no_args(): <NEW_LINE> <INDENT> f = txaio.create_future() <NEW_LINE> exception = RuntimeError("it failed") <NEW_LINE> errors = [] <NEW_LINE> def err(f): <NEW_LINE> <INDENT> errors.append(f) <NEW_LINE> <DEDENT> txaio.add_callbacks(f, None, err) <NEW_LINE> try: <NEW_LINE> <INDENT> raise exception <... | txaio.reject() with no args | 625941e26aa9bd52df03715c |
def is_community_post_valid(community, comment_op: dict) -> str: <NEW_LINE> <INDENT> if not community: <NEW_LINE> <INDENT> raise Exception("no community specified") <NEW_LINE> <DEDENT> author = comment_op['author'] <NEW_LINE> if author == community: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> sql = "SELECT * FR... | Given a new Steem post/comment, check if valid as per community rules
For a comment to be valid, these conditions apply:
- Post must be new (edits don't count)
- Author is allowed to post in this community (membership & privacy)
- Author is not muted in this community
Args:
community (str): Community... | 625941e215baa723493c432f |
def flagTest(*args, **kwargs): <NEW_LINE> <INDENT> pass | Flags:
- floatRange : fr (floatRange) []
- indexRange : ir (indexRange) []
- multiUse : mu (float, int, unicode) []
- noReport : nr (bool) []
- optionalQueryArgsFlag : oqa (float, int, unicode) []
- pythonOptionalQueryArgsFlag : poq ... | 625941e29b70327d1c4e118d |
def testRevertMissing(self): <NEW_LINE> <INDENT> self._change_to_pkg('simple') <NEW_LINE> p = osc.core.Package('.') <NEW_LINE> p.revert('missing') <NEW_LINE> self.__check_file('missing') <NEW_LINE> self._check_status(p, 'missing', ' ') | revert a missing (state == '!') file | 625941e267a9b606de4a826e |
def remove_collection_layout(self, slug): <NEW_LINE> <INDENT> queries = self.log_ls('collection_layout', slug) <NEW_LINE> matching_keys = [ self.make_key('collection_layout', slug, self.query_to_key(q)) for q in queries ] <NEW_LINE> if not matching_keys: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> self.r.delet... | Remove all instances of this collection layout from the cache | 625941e2287bf620b61d3e18 |
def wait_for_db(max_attempts=15, seconds_between_attempts=1): <NEW_LINE> <INDENT> from copy import deepcopy <NEW_LINE> from django.conf import settings <NEW_LINE> from django.db import DEFAULT_DB_ALIAS, ConnectionHandler <NEW_LINE> from django.db.utils import OperationalError <NEW_LINE> default_db_copy = deepcopy(setti... | Some manage.py commands interact with the database, and we want
them to be directly callable from `docker-compose run`. However,
because docker may start the database container at the same time
as it runs `manage.py`, we potentially face a race condition, and
the manage.py command may attempt to connect to a database t... | 625941e294891a1f4081be62 |
def test_start_date_bad_value(self): <NEW_LINE> <INDENT> for val in self.bad_values: <NEW_LINE> <INDENT> self.assertRaises(line_format_errors.FieldParseError, lambda: self.line._parse_start_date(val)) | Raise FieldParseError if value can't be parsed to a date | 625941e2dc8b845886cb58ed |
def process_prompt(self, prompt): <NEW_LINE> <INDENT> out_prompt = '' <NEW_LINE> l = len(prompt) <NEW_LINE> pos = 0 <NEW_LINE> while True: <NEW_LINE> <INDENT> s = prompt.find('\x01', pos) <NEW_LINE> if s == -1: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> e = prompt.find('\x02', s) <NEW_LINE> if e == -1: <NEW_LINE> <I... | Process the prompt.
This means calculate the length of the prompt. The character
and are used to bracket ANSI control sequences and need to be
excluded from the length calculation. So also a copy of the prompt
is returned with these control characters removed. | 625941e24428ac0f6e5babac |
def update_aliens(ai_settings, screen, stats, score_board, ship, aliens, bullets): <NEW_LINE> <INDENT> check_fleet_edges(ai_settings, aliens) <NEW_LINE> aliens.update() <NEW_LINE> if pygame.sprite.spritecollideany(ship, aliens): <NEW_LINE> <INDENT> ship_hit(ai_settings, screen, stats, score_board, ship, aliens, bullets... | Check if the fleet is at an edge,
and then update the positions of all aliens in the fleet. | 625941e28c0ade5d55d3ed75 |
def _experience_replay(self, long_memory, n_epochs=5): <NEW_LINE> <INDENT> replay = long_memory <NEW_LINE> targets = np.zeros((len(long_memory), self.num_actions)) <NEW_LINE> inputs = np.zeros((len(long_memory), self.state_size)) <NEW_LINE> train_data = [] <NEW_LINE> for j in range(len(long_memory)): <NEW_LINE> <INDENT... | :param long_memory: Set of transitions
:param n_epochs: Number of epochs.
:return: | 625941e23617ad0b5ed682ad |
def as_protein(structure, filter_residues=True): <NEW_LINE> <INDENT> from ssbio.biopython.Bio.Struct.Protein import Protein <NEW_LINE> return Protein.from_structure(structure, filter_residues) | Exposes methods in the Bio.Struct.Protein module.
Parameters:
- filter_residues boolean; removes non-aa residues through Bio.PDB.Polypeptide is_aa function
[Default: True]
Returns a new structure object. | 625941e2cc0a2c11143dd248 |
def t_IDENTIFIER(self, t): <NEW_LINE> <INDENT> t.type = self.ids_map.get(t.value, 'IDENTIFIER') <NEW_LINE> if t.value.lower() in self.reserved: <NEW_LINE> <INDENT> self._error('Line %s, "%s" is a reserved word' % (t.lineno, t.value)) <NEW_LINE> <DEDENT> return t | [a-zA-Z_]{1}[a-zA-Z0-9_]* | 625941e2004d5f362079a6e8 |
def set_skill_level(self, level): <NEW_LINE> <INDENT> self.__skill_level = int(level) | Make sure the skill level can be converted to an integer.
| 625941e2ad47b63b2c50a335 |
def auto_find(self): <NEW_LINE> <INDENT> self.sock.send(f'|/search {self.gamemode}') | auto joins selected gamemode | 625941e2a17c0f6771cbe406 |
def kick(self): <NEW_LINE> <INDENT> self.write(self.kicker, 2) | The kicker kicks and retracts the kicker by itself. | 625941e2bde94217f36831a4 |
def reduce_max(var, axis=None, keep_dims=False, name=None): <NEW_LINE> <INDENT> return be.ops.reduce_max(var, axis=axis, keep_dims=keep_dims, name=name) | Compute max across the given axis
Parameters
----------
axis : int, list or None
The dimensions to compute max. If None (the default),
reduces all dimensions.
keep_dims: bool
If true, retains reduced dimensions with length 1.
name: str
A name for the operation.
Returns
-------
Tensor
The resulting... | 625941e21b99ca400220ae6a |
def GetType(self): <NEW_LINE> <INDENT> return self._NodeType | Get the GvNode Type.
:return: Int (a Cinema 4D Node look at https://developers.maxon.net/docs/Cinema4DPythonSDK/html/types/gvnodes.html) or a Redshift Node member loot at :class:`MetaclassName`
:rtype: Int or Str | 625941e25510c4643540f792 |
def init_velocity_field(self): <NEW_LINE> <INDENT> self.vel_info.init_func() <NEW_LINE> if "perturbations" in self.vel_info: <NEW_LINE> <INDENT> self.perturb_velocity_field() | Process velocity field | 625941e231939e2706e4d21c |
def hangDetector(self): <NEW_LINE> <INDENT> logger = logging.getLogger('http_hangDetector') <NEW_LINE> try: <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> if not self.rfile.read(): <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> except: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> finally: <NEW_LIN... | Detect client disconnection while in the middle of something
or just normal connection close. | 625941e2956e5f7376d71223 |
def getRefractiveIndex(self, wavelength): <NEW_LINE> <INDENT> raise NotImplementedError('Different for functionally and experimentally defined materials') | :param wavelength:
:raise NotImplementedError: | 625941e2a79ad161976cc4fc |
def Judge_score(me, enemy): <NEW_LINE> <INDENT> if not Score_Counter: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> sigma = SIGMA <NEW_LINE> return storage['score']['me'] - storage['score']['enemy'] >= sigma | 判断当前面积比地方大, 可以选择直接返回False, 并去掉Decision中的count_score, 以提高效率 | 625941e2099cdd3c635f1011 |
def get_missing_column_dict(brick_name_list, brick_column_details, column_list): <NEW_LINE> <INDENT> missing_column_dict = {} <NEW_LINE> for brick_name in brick_name_list: <NEW_LINE> <INDENT> if brick_name not in brick_column_details.keys(): <NEW_LINE> <INDENT> missing_column_dict[brick_name] = column_list <NEW_LINE> <... | Return dict of lists showing missing columns for each key. | 625941e29c8ee82313fbbb2d |
def prev_obj_cb(self, *args): <NEW_LINE> <INDENT> if self.current_obj > 0: <NEW_LINE> <INDENT> self.current_obj -= 1 <NEW_LINE> self.zoom_in_on_current_obj() <NEW_LINE> self.mark_current_obj() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.step1_cb() | Respond to back button in step 2 by going back to the last object | 625941e2379a373c97cfaefe |
def bestow_treasures(data, prev_start): <NEW_LINE> <INDENT> if not prev_start: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> not_given = [cat for cat in data["cats"].itervalues() if cat["total_time_in_yard"] > 0 and not cat["given_treasure"]] <NEW_LINE> if len(not_given) is 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DE... | Randomly decide whether or not to give the user a treasure. | 625941e223849d37ff7b3444 |
def _findall_with_attr(self, entity, **kwargs): <NEW_LINE> <INDENT> func = getattr(self.client(), entity) <NEW_LINE> filters = {'filters': kwargs} <NEW_LINE> return func.list(**filters) | Find all items for entity with attributes matching ``**kwargs``. | 625941e22eb69b55b151cc6b |
def getArticleContent(query): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> article = Article(url=query.strip(' '), language='en') <NEW_LINE> article.download() <NEW_LINE> article.parse() <NEW_LINE> return article.text <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> article = '' <NEW_LINE> r = requests.get(que... | Parses out the text content of the article by first
trying to use the Newspaper API, but if that fails
due to restrictions on the website itself, then uses
BeautifulSoup to grab the <p> content
:return: string of article text | 625941e201c39578d7e751f3 |
def toirc(self, bot): <NEW_LINE> <INDENT> self.cmnd = 'Iq' <NEW_LINE> self.conn = bot.connection <NEW_LINE> self.prefix = "" <NEW_LINE> self.postfix = "" <NEW_LINE> self.target = "" <NEW_LINE> self.arguments = [] <NEW_LINE> self.nick = "" <NEW_LINE> self.user = "" <NEW_LINE> self.jid = "" <NEW_LINE> self.ruserhost = se... | set ircevent compatible attributes. | 625941e2ff9c53063f47c5a9 |
def _write_files(s3, app, static_url_loc, static_folder, files, bucket, ex_keys=None, hashes=None): <NEW_LINE> <INDENT> should_gzip = app.config.get('FLASKS3_GZIP') <NEW_LINE> add_mime = app.config.get('FLASKS3_FORCE_MIMETYPE') <NEW_LINE> gzip_include_only = app.config.get('FLASKS3_GZIP_ONLY_EXTS') <NEW_LINE> new_hashe... | Writes all the files inside a static folder to S3. | 625941e2287bf620b61d3e19 |
def prefer_table(old_entry, new_entry): <NEW_LINE> <INDENT> old_func = old_entry['function_name'] <NEW_LINE> new_func = new_entry['function_name'] <NEW_LINE> if ((old_func == "onMakeItemCatch") and (new_func == "onItemPickup")): <NEW_LINE> <INDENT> return new_entry <NEW_LINE> <DEDENT> if ((new_func == "onMakeItemCatch"... | In some situations, functions are also duplicated across these tables.
The "function" of the functions in these tables must be internally related
enough for them to be re-used in certain cases. This probably indicates
that there are a better set of names for these tables/functions. | 625941e263b5f9789fde749e |
def charge(self,price): <NEW_LINE> <INDENT> self.count_charge+=1 <NEW_LINE> success = super().charge(price) <NEW_LINE> if not success: <NEW_LINE> <INDENT> self._balance+=5 <NEW_LINE> <DEDENT> if (self.count_charge>10): <NEW_LINE> <INDENT> self.additional_charge() <NEW_LINE> <DEDENT> return success | Charge given price to the card, assuming sufficient credit limit.
Return True if charge was processed.
Return False and assess 5 fee if charge is denied. | 625941e2be8e80087fb20ff5 |
def get_user_using_get_with_http_info(self, user_uuid, **kwargs): <NEW_LINE> <INDENT> local_var_params = locals() <NEW_LINE> all_params = [ 'user_uuid', 'x_yapily_api_version' ] <NEW_LINE> all_params.extend( [ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout' ] ) <NEW_LINE> for key, val in s... | Get an application user # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_user_using_get_with_http_info(user_uuid, async_req=True)
>>> result = thread.get()
:param async_req bool: execute request asynchronously
... | 625941e273bcbd0ca4b2c42d |
def _compute_bundles(self, components): <NEW_LINE> <INDENT> _logger.critical(">>>>>>>>> _compute_bundles") <NEW_LINE> bundles = {} <NEW_LINE> not_found = set() <NEW_LINE> for component in components: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> bundles[component] = self._finder.normalize(component) <NEW_LINE> <DEDENT> ... | Normalizes the component beans by looking for their implementation
bundle.
:param components: A set of components (beans modified in-place)
:return: A Component bean -> Bundle bean dictionary
:raise FactoriesMissing: Some factories are missing | 625941e207d97122c4178c4b |
def __getitem__(self, name): <NEW_LINE> <INDENT> return deepcopy(self.context.attrs[name]) | return an item value
| 625941e207f4c71912b1183c |
def load_DTR(self, cr, uid, commitment, context=None): <NEW_LINE> <INDENT> context = context or {} <NEW_LINE> commitment_DTR_line_model = self.pool['account.vat.communication.dtr.line'] <NEW_LINE> sum_amounts = self.load_DTE_DTR( cr, uid, commitment, commitment_DTR_line_model, 'DTR', context) <NEW_LINE> return sum_amou... | Read all purchase invoices in periods | 625941e299cbb53fe6792f9d |
def fix_long_ipv6_netmask(netmask: str): <NEW_LINE> <INDENT> return IPV6_NETMASKS.get(netmask, netmask) | :param netmask: String netmask, long or short, IPv4 or IPv6
:return: If the string matches one of the valid but non-standard
long IPv6 netmask, return the number of leading bits. Otherwise
return the string unchanged. | 625941e2e76e3b2f99f3abbd |
def grelha_elemento(g, l, c): <NEW_LINE> <INDENT> if (0 <= l <= (grelha_nr_linhas(g) - 1)) and (0 <= c <= (grelha_nr_colunas(g) - 1)): <NEW_LINE> <INDENT> return g[l][c] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise ValueError('grelha_elemento: argumentos invalidos') | grelha_elemento: grelha x No x No -> caracter
grelha_elemento(g, l, c) devolve o caracter que esta na
posicao (l , c) da grelha g. | 625941e238b623060ff0b1a5 |
def __init__(self, action = '__init__', args = None, project = None, modulePath = None, symbol=None, version='0.0', graph=None): <NEW_LINE> <INDENT> self.genDummy = True <NEW_LINE> Interface.__init__(self,action,args,project,modulePath,symbol,version,graph,kind='enum') <NEW_LINE> return | bocca <verb> enum [options] SIDL_SYMBOL
<verb> is one of create, change, remove, rename, display. For documentation on
specific verbs, use 'bocca help <verb> enum' | 625941e24e696a04525c9804 |
def process(self, raw, identifiers, frame_meta): <NEW_LINE> <INDENT> predictions = self._extract_predictions(raw, frame_meta)[self.output_blob] <NEW_LINE> result = [] <NEW_LINE> box_size = self.classes + self.coords + 1 <NEW_LINE> for identifier, prediction in zip(identifiers, predictions): <NEW_LINE> <INDENT> if len(p... | Args:
identifiers: list of input data identifiers
raw: output of model
Returns:
list of DetectionPrediction objects | 625941e2293b9510aa2c364a |
def tag_form( self, mach, tagname, tokens, attributes, content ): <NEW_LINE> <INDENT> for tok in tokens : <NEW_LINE> <INDENT> attr = self.form2attr.get( tok, None ) <NEW_LINE> attributes += attr if attr else (' action=%s' % tok) <NEW_LINE> <DEDENT> return '<form %s>%s</form>' % (attributes, content) | <form> tag handler. Supported tokens,
* ``on`` token translates to ``autocomplete="on"``.
* ``off`` token translates to ``autocomplete="off"``.
* ``application/x-www-form-urlencoded`` token translates to
``enctype="application/x-www-form-urlencoded"``.
* ``multipart/form-data`` token translates to
``enctype="mult... | 625941e256ac1b37e6264580 |
def to_png(data, size, level=6, output=None): <NEW_LINE> <INDENT> pack = struct.pack <NEW_LINE> crc32 = zlib.crc32 <NEW_LINE> width, height = size <NEW_LINE> line = width * 3 <NEW_LINE> png_filter = pack(">B", 0) <NEW_LINE> scanlines = b"".join( [png_filter + data[y * line : y * line + line] for y in range(height)] ) <... | Dump data to a PNG file. If `output` is `None`, create no file but return
the whole PNG data.
:param bytes data: RGBRGB...RGB data.
:param tuple size: The (width, height) pair.
:param int level: PNG compression level.
:param str output: Output file name. | 625941e256b00c62f0f14a13 |
def _fetch_screenshots(self, cpt): <NEW_LINE> <INDENT> if cpt.screenshots: <NEW_LINE> <INDENT> success = True <NEW_LINE> shots = list() <NEW_LINE> cnt = 1 <NEW_LINE> for shot in cpt.screenshots: <NEW_LINE> <INDENT> origin_url = shot['source-image']['url'] <NEW_LINE> try: <NEW_LINE> <INDENT> image = urllib.urlopen(origi... | Fetches screenshots from the given url and
stores it in png format. | 625941e2d99f1b3c44c67940 |
def __init__(self, config_map=None, downward_api=None, secret=None): <NEW_LINE> <INDENT> self._config_map = None <NEW_LINE> self._downward_api = None <NEW_LINE> self._secret = None <NEW_LINE> self.discriminator = None <NEW_LINE> if config_map is not None: <NEW_LINE> <INDENT> self.config_map = config_map <NEW_LINE> <DED... | IoK8sApiCoreV1VolumeProjection - a model defined in Swagger | 625941e260cbc95b062c68fb |
def write(self, app): <NEW_LINE> <INDENT> if self.info is None: <NEW_LINE> <INDENT> self.collect(app) <NEW_LINE> <DEDENT> parameters = self.info["application"] <NEW_LINE> self._createPath(self.filename) <NEW_LINE> with open(self.filename, "w") as fout: <NEW_LINE> <INDENT> from .CollectVersionInfo import CollectVersionI... | Write parameters to ASCII file. | 625941e266673b3332b92449 |
def get_records_geogrid(precision, keyword=None, bounds=None): <NEW_LINE> <INDENT> query = { "aggregations" : { "geogrid" : { "geohash_grid" : { "field" : "geolocation", "precision" : precision } } } } <NEW_LINE> return es.search(query) | Return geohash grids containing records
| 625941e2ac7a0e7691ed447d |
def gap_AlGaAs(x): <NEW_LINE> <INDENT> if type(x)==np.ndarray: <NEW_LINE> <INDENT> Eg = 1.424 + 1.247*x <NEW_LINE> Eg[x>=0.45] = 1.9+0.125*x+0.143*x**2 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if (x<=0.45): <NEW_LINE> <INDENT> Eg = 1.424 + 1.247*x <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> Eg = 1.9+0.125*x+0.14... | return the AlGaAs energy gap (eV) as a function of the concentration x | 625941e23eb6a72ae02ec89e |
def _get_remote_file(filename, prefix): <NEW_LINE> <INDENT> socket.setdefaulttimeout(5) <NEW_LINE> fileContents = "" <NEW_LINE> gotContents = False <NEW_LINE> for host in _sponsor_servers: <NEW_LINE> <INDENT> url = host + filename <NEW_LINE> try: <NEW_LINE> <INDENT> fileHandle = urllib.urlopen(url) <NEW_LINE> fileConte... | Get file I{filename} from the sponsor server.
@param filename: the name of the file to get
@type filename: string
@param prefix: a short string that is expected at the beginning of the file
for the retrieval to be denoted as successful
@type prefix: string
@return: gotContents, fileContent... | 625941e2d99f1b3c44c67941 |
def maxEnvelopes(self, envelopes): <NEW_LINE> <INDENT> if not envelopes: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> envelopes=sorted(envelopes,lambda x,y:x[0]-y[0] if x[0]!=y[0] else y[1]-x[1]) <NEW_LINE> height=[] <NEW_LINE> for i in xrange(len(envelopes)): <NEW_LINE> <INDENT> height.append(envelopes[i][1]) <NEW... | :type envelopes: List[List[int]]
:rtype: int | 625941e2de87d2750b86014e |
def upload_dir(hosts, dirname, branch, auth, compress=False): <NEW_LINE> <INDENT> log.info("Open directory for files ...") <NEW_LINE> files = [f for f in os.listdir(dirname) if os.path.isfile(os.path.join(dirname, f)) and not os.path.islink(os.path.join(dirname, f))] <NEW_LINE> log.debug("Go through all files in direct... | Sequentially call uploading subroutine for each file in the dir | 625941e2656771135c3ebc2b |
def __init__(self, parent_node, id, collapsed_icon, x, y, parent_widget=None, expanded_icon=None, label=None, expandable_flag=0): <NEW_LINE> <INDENT> self.parent_node=parent_node <NEW_LINE> self.id=id <NEW_LINE> self.expanded_icon=expanded_icon <NEW_LINE> self.collapsed_icon=collapsed_icon <NEW_LINE> if parent_widget: ... | Create node and initialize it. This also displays the node at the
given position on the canvas, and binds mouseclicks. | 625941e2442bda511e8be7cb |
def parse(self): <NEW_LINE> <INDENT> self.stream = FileStack(self.filename) <NEW_LINE> tree = defaultdict(list) <NEW_LINE> for phrase in self.stream: <NEW_LINE> <INDENT> cmd, _sep, args = phrase.partition(' ') <NEW_LINE> k, v = self.parsenode(cmd)(args) <NEW_LINE> tree[k].append(v) <NEW_LINE> <DEDENT> return tree | Returns a dict of elements that have been parsed out of the file | 625941e215fb5d323cde0ecd |
def testCreateSprintCommand(self): <NEW_LINE> <INDENT> sprint_start = normalize_date(now(tz=utc)) <NEW_LINE> cmd_create = SprintController.CreateSprintCommand(self.env, name='AnotherTestSprint', milestone='MyRelease', team=self.team.name, start=sprint_start, duration=15) <NEW_LINE> sprint = self.controller.process_comm... | Tests the creation of a Sprint like a View would do | 625941e2cdde0d52a9e533ed |
def Setup(options): <NEW_LINE> <INDENT> def TestRunnerFactory(_unused_device, _unused_shard_index): <NEW_LINE> <INDENT> return test_runner.JavaTestRunner(options) <NEW_LINE> <DEDENT> return (TestRunnerFactory, ['JUnit tests']) | Creates a test runner factory for junit tests.
Return:
A (runner_factory, tests) tuple. | 625941e226068e7796caf09c |
def zero_grad(self): <NEW_LINE> <INDENT> for group in self.param_groups: <NEW_LINE> <INDENT> for p in group['params']: <NEW_LINE> <INDENT> if p.grad is not None: <NEW_LINE> <INDENT> p.grad.fill(0) | Clears the gradients of all optimized :class:`Variable` s. | 625941e2ac7a0e7691ed447e |
def get_testpattern(self): <NEW_LINE> <INDENT> return self.sc.send_cmd('IMGU?') | IMGU?
:return: | 625941e2aad79263cf390dff |
def ops(self, input): <NEW_LINE> <INDENT> pool = fluid.layers.sequence_pool( input=input, pool_type=self.pool_type) <NEW_LINE> return pool | operation | 625941e221bff66bcd684d07 |
def test_desk(self): <NEW_LINE> <INDENT> test_desk = Desk() <NEW_LINE> test_desk.list_of_pieces = [] <NEW_LINE> for piece in self.list_of_pieces: <NEW_LINE> <INDENT> test_desk.list_of_pieces.append( self._dict_of_pieces[piece.reduction](piece.x, piece.y, piece.colour, test_desk)) <NEW_LINE> <DEDENT> for piece in test_d... | Копирует фигуры на тестовую доску и возвращает её | 625941e2377c676e9127255f |
def unquote_pairs(text): <NEW_LINE> <INDENT> return | Unquotes pairs | 625941e22c8b7c6e89b35b76 |
def add_strong_R_cons(ais, ajs, avs, b_ub, n, include_main_diag): <NEW_LINE> <INDENT> if include_main_diag: <NEW_LINE> <INDENT> n_tri = n * (n+1) // 2 <NEW_LINE> k = 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> n_tri = n * (n-1) // 2 <NEW_LINE> k = -1 <NEW_LINE> <DEDENT> (i_tril, j_tril) = np.tril_indices(n, k=k, m=... | Generate strong R constraints before calling LP solver | 625941e2cc40096d61595d07 |
def get_labs_list(): <NEW_LINE> <INDENT> yaml_files = [] <NEW_LINE> files = glob.glob("./virl_data/*") <NEW_LINE> for file in files: <NEW_LINE> <INDENT> yaml_files.append(os.path.split(file)[1].replace(".yaml", "")) <NEW_LINE> <DEDENT> return yaml_files | A function that lists the names of lab configuration yaml files stored in
virl_data.
Returns
-------
list
List of names of yaml files that define the lab configuration. | 625941e256b00c62f0f14a14 |
def __init__(self, previous_exceptions): <NEW_LINE> <INDENT> Error.__init__(self) <NEW_LINE> self._previous_exceptions = previous_exceptions | Init exception.
Args:
# previous_exceptions: A sequence of Error objects that were raised.
previous_exceptions: [Error] | 625941e28c3a873295158777 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.