code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def zGetFieldTuple(self): <NEW_LINE> <INDENT> fieldCount = self.zGetField(0)[1] <NEW_LINE> fieldDataTuple = [ ] <NEW_LINE> for i in range(fieldCount): <NEW_LINE> <INDENT> reply = self._sendDDEcommand('GetField,'+str(i+1)) <NEW_LINE> rs = reply.split(',') <NEW_LINE> fieldData = tuple([float(elem) for elem in rs]) <NEW_L...
Get all field data in a single N-D tuple. `zGetFieldTuple()->fieldDataTuple` Parameters ---------- None Returns ------- fieldDataTuple: the output field data tuple is also a N-D tuple (0<N<=12) with every dimension representing a single field location. Each dimension has all 8 field p...
625941ca56ac1b37e6264276
def is_front(self): <NEW_LINE> <INDENT> return self.front
Returns if this sector is part of the front
625941ca656771135c3eb914
def collect_files(self): <NEW_LINE> <INDENT> path = os.path.join(self.unconverted_directory, self.file_pattern) <NEW_LINE> return glob.glob(path)
Get a list of all relevant files (based on the file extension) in the local unconverted media file directory.
625941ca38b623060ff0ae94
def lazy_dedupe(seq: Sequence, key: Callable=None) -> Iterable: <NEW_LINE> <INDENT> seen = set() <NEW_LINE> for item in seq: <NEW_LINE> <INDENT> val = item if key is None else key(item) <NEW_LINE> if val not in seen: <NEW_LINE> <INDENT> yield item <NEW_LINE> seen.add(val)
Returns a generator which which yields items in the sequence skipping duplicates.
625941ca3d592f4c4ed1d115
def setup_credentials(arguments): <NEW_LINE> <INDENT> log = get_logger() <NEW_LINE> try: <NEW_LINE> <INDENT> auth_params = init_auth(arguments, quiet=False) <NEW_LINE> <DEDENT> except ValueError as ex: <NEW_LINE> <INDENT> log.info(str(ex)) <NEW_LINE> auth_params = _ask_for_credentials() <NEW_LINE> if not auth_params: <...
Setup action: Guides the user through the process of entering this API KEY Credentials for the Stormpath API.
625941ca596a897236089b67
def on_task_filter(self, task, config): <NEW_LINE> <INDENT> config = self.prepare_config(config) <NEW_LINE> found_series = {} <NEW_LINE> for entry in task.entries: <NEW_LINE> <INDENT> if entry.get('series_name') and entry.get('series_id') is not None and entry.get('series_parser'): <NEW_LINE> <INDENT> found_series.setd...
Filter series
625941ca7b180e01f3dc48a4
def max_noutput_items(self): <NEW_LINE> <INDENT> return _pmt_cpp_swig.Noise_sptr_max_noutput_items(self)
max_noutput_items(Noise_sptr self) -> int
625941cab57a9660fec33929
def _is_forward(self, r, c): <NEW_LINE> <INDENT> if self._player == 'red': <NEW_LINE> <INDENT> if r < self._row: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> if r > self._row: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> return True
True if one point forward, False otherwise :param r: int :param c: int :return: bool
625941caaad79263cf390ae6
@qgsfunction(1, "Expressions +", register=False) <NEW_LINE> def isselected(values, feature, parent): <NEW_LINE> <INDENT> layername=values[0] <NEW_LINE> fid = feature.id() <NEW_LINE> layers = QgsMapLayerRegistry.instance().mapLayers() <NEW_LINE> try: <NEW_LINE> <INDENT> layer = layers[layername] <NEW_LINE> <DEDENT> exce...
Returns a boolean representing the current selection status of a feature. <h4>Syntax</h4> <p>isselected(<i>layername</i>)</p> <h4>Arguments</h4> <p><i> layername</i> &rarr; a string. Must be the either the layer id or the layer name of the layer on which this feature is located.<br/></p> <h4>Example</h4> <p><!-- Sh...
625941cab57a9660fec3392a
def _onFavoritesChanged(self, preference_key: str) -> None: <NEW_LINE> <INDENT> if preference_key != "cura/favorite_materials": <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self._onChanged()
Triggered when any preference changes, but only handles it when the list of favourites is changed.
625941cacad5886f8bd27080
def test_term_parents_BP(self): <NEW_LINE> <INDENT> self.assertEqual(self.graph.getParentTerms("GO:0022403"), ('GO:0044848',))
Test the accessor for term ancestors of GO:0022403 in BP
625941ca07d97122c4178931
def isValid(self, s): <NEW_LINE> <INDENT> d_c = {} <NEW_LINE> d_c[")"] = "(" <NEW_LINE> d_c["}"] = "{" <NEW_LINE> d_c["]"] = "[" <NEW_LINE> st = Stack() <NEW_LINE> for i in s: <NEW_LINE> <INDENT> if i in d_c.keys(): <NEW_LINE> <INDENT> if st.pop() != d_c[i]: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT>...
:type s: str :rtype: bool
625941cae8904600ed9f1fd2
def set_evidence(self, index, value): <NEW_LINE> <INDENT> raise NotImplementedError('abstract method')
Set value for evidence node. :param index: index of evidence node :param value: value of evidence
625941ca5fdd1c0f98dc02d9
def diff(f1, f2): <NEW_LINE> <INDENT> with open(f1) as fin: <NEW_LINE> <INDENT> f1_contents = fin.read() <NEW_LINE> <DEDENT> with open(f2) as fin: <NEW_LINE> <INDENT> f2_contents = fin.read() <NEW_LINE> <DEDENT> return f1_contents != f2_contents
Returns True if the files are different.
625941ca45492302aab5e369
def get_page(url): <NEW_LINE> <INDENT> res = html_xpath(url, 'gbk') <NEW_LINE> res = res.xpath('/html/body/div[4]/div/div[2]/div/div[3]/text()[1]') <NEW_LINE> res = re.compile('\d+').findall(res[0]) <NEW_LINE> res = res[1] <NEW_LINE> return res
获取界面页数 :param url: 三大类url :return: int
625941ca8c0ade5d55d3ea61
def test_delete_topic(self): <NEW_LINE> <INDENT> Topic.objects.get(pk=1).delete() <NEW_LINE> forum = Forum.objects.get(pk=1) <NEW_LINE> self.assertEquals(forum.topics.count(), 2) <NEW_LINE> self.assertEquals(forum.topic_count, 2) <NEW_LINE> user = User.objects.get(pk=1) <NEW_LINE> forum_profile = ForumProfile.objects.g...
Verifies that deleting a Topic has the appropriate effect on denormalised data.
625941ca63d6d428bbe44596
def follow(n, scramble=True): <NEW_LINE> <INDENT> import random <NEW_LINE> make(n) <NEW_LINE> if scramble: <NEW_LINE> <INDENT> agoto('random') <NEW_LINE> acolor('random') <NEW_LINE> aturnto('random') <NEW_LINE> <DEDENT> for n, pyn in enumerate(pynguins): <NEW_LINE> <INDENT> pyn.name = 'P%s' % n <NEW_LINE> pyn._fspeed =...
Create n new pynguins, each one following one of the others. Each pynguin has its own forward speed and turn speed randomly generated. If a pynguin happens to wander off the screen, it will head back to the center before resuming following its chosen other pynguin. if scramble=True all pynguins will be moved to rand...
625941ca92d797404e304230
def getValue(self, p): <NEW_LINE> <INDENT> value = p.geocentric[TableFieldInfo.sidereal]['longitude'] <NEW_LINE> valueStr = "" <NEW_LINE> if value != None: <NEW_LINE> <INDENT> padaSize = 360 / 108.0 <NEW_LINE> pada = (math.floor(value / padaSize) % 4) + 1 <NEW_LINE> valueStr = "{}".format(pada) <NEW_LINE> <DEDENT> retu...
Virtual function that returns a string for the field value. Arguments: p - PlanetaryInfo object for this row.
625941ca56ac1b37e6264277
def handle_response(r, http_method, custom_err): <NEW_LINE> <INDENT> json = {} <NEW_LINE> if r.status_code == requests.codes.ok: <NEW_LINE> <INDENT> if r.text: <NEW_LINE> <INDENT> json = r.json() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print("{0} returned an empty response.".format(http_method)) <NEW_LINE> <DEDEN...
Handles the HTTP response and returns the JSON Parameters ---------- r: requests module's response http_method: string "GET", "POST", "PUT", etc. custom_err: string the custom error message if any Returns ------- json : dict
625941ca63f4b57ef00011c1
def writeTable(simbolo): <NEW_LINE> <INDENT> saida.write(str(simbolo) + '\n')
Função que armazena os símbolos no arquivo de saida, saída de símbolos.
625941cadc8b845886cb55db
def webservice_list(request, detail=None): <NEW_LINE> <INDENT> return iotronicclient(request).webservice.list()
Get web services list.
625941ca23e79379d52ee60b
def main(): <NEW_LINE> <INDENT> if not sys.platform.startswith('linux'): <NEW_LINE> <INDENT> print("Error: this OS is not supported.") <NEW_LINE> sys.exit(1) <NEW_LINE> <DEDENT> parser = argparse.ArgumentParser() <NEW_LINE> parser.add_argument("-m", "--model", help="the name of the model to check") <NEW_LINE> args = pa...
Accepts command-line arguments and passes them to an instance of CheckDependencies.
625941ca3cc13d1c6d3c7421
def boosting_prediction(tree, df,main_df,i): <NEW_LINE> <INDENT> alpha_list = [] <NEW_LINE> for index, rows in train_df.iterrows(): <NEW_LINE> <INDENT> boost_pred = predict(train_df, tree, rows) <NEW_LINE> alpha_list.append(boost_pred) <NEW_LINE> <DEDENT> df['predicted_column'] = alpha_list <NEW_LINE> epsilon = epsilon...
Function used to find the misclassified data points in an individual iteration of the boosting algorithm by predicting on the training data. Using that calculate epsilon, alpha calling the previous 2 functions. Find the weight, normalize it and update the weight for the next iteration for boosting. Core function for bo...
625941ca7047854f462a14b1
def _mergeArgumentsAndConfig(self, cmdline_namespace): <NEW_LINE> <INDENT> cmdline_dict = cmdline_namespace.__dict__ <NEW_LINE> for name, value in cmdline_dict.iteritems(): <NEW_LINE> <INDENT> if name in self.data_namespace.__dict__.keys(): <NEW_LINE> <INDENT> lg.debug("Datum '%s' with value '%s' overridden by '%s'." ...
Merge the cmdline arguments, `cmdline_namespace`, into Kali's global namespace, `data_namespace`, which currently only contains data loaded from the configuration file. Log any conflicts.
625941ca2c8b7c6e89b35868
def __init__(self, data): <NEW_LINE> <INDENT> self._data = data
data example. { 'id': 'F162E0F26861C4D25AB1ED3D82FCA86A', 'total_parts': 30, 'session_endpoints': { 'abort': 'https://upload.box.com/api/2.0/files/upload_sessions/F162E0F26861C4D25AB1ED3D82FCA86A', 'log_event': 'https://upload.box.com/api/2.0/files/upload_sessions/F162E0F26861C4D25AB1ED3D...
625941ca5f7d997b87174b3e
def dessin(xBalle,yBalle,rayonBalle,xRect,yRect,largeurRect,hauteurRect): <NEW_LINE> <INDENT> efface('rect') <NEW_LINE> efface('ball') <NEW_LINE> cercle(xBalle,yBalle,rayonBalle, remplissage='blue',tag='ball') <NEW_LINE> rectangle(xRect,yRect,xRect+largeurRect,yRect+hauteurRect, remplissage='black',tag='r...
dessine tout les elements affiché
625941caa79ad161976cc1ec
def __init__(self, name, filename): <NEW_LINE> <INDENT> super().__init__(name) <NEW_LINE> self.filename = filename <NEW_LINE> self.code_gen = None <NEW_LINE> self.headers = [] <NEW_LINE> self.schema = None <NEW_LINE> extensions = ['.c', '.s'] <NEW_LINE> if any([filename.endswith(ext) for ext in extensions]): <NEW_LINE>...
Create a new `Module` with a given `name`. The `filename` currently must point to a .c file, but this will be expanded in time. `project` is a pointer back to the project in which it exists.
625941caf7d966606f6aa0aa
def test_delete_root_on_right_heavy_left_sub_tree(): <NEW_LINE> <INDENT> b = BST([14, 8, 16, 9, 7, 18, 8.5, 12]) <NEW_LINE> b.delete(8) <NEW_LINE> assert b._root.left.val == 7 <NEW_LINE> assert b._root.left.right.val == 9 <NEW_LINE> assert b.size() == 7
Test deletion of the root when right is heavier.
625941ca3346ee7daa2b2e12
def run_test(): <NEW_LINE> <INDENT> runner = unittest.TextTestRunner() <NEW_LINE> runner.run(unittest.makeSuite(TestClient)) <NEW_LINE> runner.run(unittest.makeSuite(TestCopyObject)) <NEW_LINE> runner.run(unittest.makeSuite(TestGeneratePreSignedUrl)) <NEW_LINE> runner.run(unittest.makeSuite(TestListMultipartsUploads)) ...
start run test
625941ca4d74a7450ccd426b
def strategy(self, score, opp_score): <NEW_LINE> <INDENT> s0 = score if self.who == 0 else opp_score <NEW_LINE> s1 = opp_score if self.who == 0 else score <NEW_LINE> self.s_labels[0].text = s0 <NEW_LINE> self.s_labels[1].text = s1 <NEW_LINE> self.roll_label.text = 'Ходит {0}. Число костей:'.format(name(self.who)) <NEW_...
A strategy with a hook to the GUI. This strategy gets passed into the PLAY function from the HOG module. At its core, the strategy waits until a number of rolls has been verified, then returns that number. Game information is updated as well. score -- player's score opp_score -- opponent's score
625941cabe7bc26dc91cd6a8
def get_dict_count(mapping, k): <NEW_LINE> <INDENT> if k in mapping: <NEW_LINE> <INDENT> return mapping[k] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return 0
Given a dictionary and its key, return the value If key is not in dictionary, return 0
625941caeab8aa0e5d26dbfe
def crypt(self, data, crypt_type): <NEW_LINE> <INDENT> if not data: <NEW_LINE> <INDENT> return '' <NEW_LINE> <DEDENT> if len(data) % self.block_size != 0: <NEW_LINE> <INDENT> if crypt_type == des.DECRYPT: <NEW_LINE> <INDENT> raise ValueError("Invalid data length, data must be a multiple of " + str(self.block_size) + " ...
Crypt the data in blocks, running it through des_crypt()
625941ca5fdd1c0f98dc02da
def minPathSum(self, grid): <NEW_LINE> <INDENT> if not grid: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> elif not grid[0]: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> for i in range(len(grid)): <NEW_LINE> <INDENT> for j in range(len(grid[0])): <NEW_LINE> <INDENT> if i == 0 and j == 0: <NEW_LINE> <INDENT> cont...
:type grid: List[List[int]] :rtype: int
625941ca8e7ae83300e4b073
def blink(self): <NEW_LINE> <INDENT> count = 0 <NEW_LINE> for action in self.scheduler.elapsed(self.clock()): <NEW_LINE> <INDENT> action() <NEW_LINE> count += 1 <NEW_LINE> <DEDENT> return count
Dispatch actions for all ready monitors.
625941caa17c0f6771cbe0f8
def start_experiment(self): <NEW_LINE> <INDENT> self.dataset = Dataset() <NEW_LINE> self.dataset.read_original_data(self.dataset_name) <NEW_LINE> self.preprocess_data() <NEW_LINE> self.extract_features() <NEW_LINE> all_features = self.read_features_train_test() <NEW_LINE> all_features = self.transform_data(all_features...
Starts an experiment with a predefined sequence of procedures.
625941ca3317a56b86939d00
def list_reduce(linked_list): <NEW_LINE> <INDENT> node, _str = linked_list, "" <NEW_LINE> while node: <NEW_LINE> <INDENT> _str += format_zeros(node.value) <NEW_LINE> node = node.next <NEW_LINE> <DEDENT> return _str
list_reduce(LinkedList) -> str Return a string representing the value of reduced Linked List with leading zeros if needed
625941caf548e778e58cd624
def get_info(username): <NEW_LINE> <INDENT> if redis_obj is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> return redis_obj.get('user:%s' % (username))
Get contributor information :param username: String of username :returns: Data stored for that username
625941ca73bcbd0ca4b2c11d
def pysh_execfile(fname, globals=None, locals=None): <NEW_LINE> <INDENT> import tempfile <NEW_LINE> with open(fname) as sourcefile: <NEW_LINE> <INDENT> lines = sourcefile.readlines() <NEW_LINE> <DEDENT> for i, line in enumerate(lines): <NEW_LINE> <INDENT> lines[i] = _rewrite_shell_statement(line) <NEW_LINE> <DEDENT> t...
Re-write pysh-script `fname` as Python and execute it.
625941ca66656f66f7cbc251
def get_version(): <NEW_LINE> <INDENT> f = CURDIR / "interfacea" / "version.py" <NEW_LINE> contents = f.read_text() <NEW_LINE> version = contents.strip().split()[-1] <NEW_LINE> return version[1:-1]
Read the variable version from interfacea/version.py.
625941ca6fece00bbac2d7e5
def do_scan(self, arg): <NEW_LINE> <INDENT> if len(arg.split()) > 0: <NEW_LINE> <INDENT> print("Error: too many parameters.") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if self.current: <NEW_LINE> <INDENT> if isinstance(self.current, world.World): <NEW_LINE> <INDENT> self.current = world.World(self.current.path) <NE...
Scans the current workload.
625941ca6e29344779a626b9
def clean_done(self): <NEW_LINE> <INDENT> ongoing = [] <NEW_LINE> status_file = "/tmp/farm-%d" % (os.getpid()) <NEW_LINE> os.system("qstat > %s 2>/dev/null" % status_file) <NEW_LINE> f = open(status_file) <NEW_LINE> f.readline() <NEW_LINE> f.readline() <NEW_LINE> me = getpass.getuser() <NEW_LINE> for l in f: <NEW_LINE>...
Removes dead processes from the running list.
625941ca30dc7b7665901a0e
def t_MINUSMINUS(t): <NEW_LINE> <INDENT> return t
-\=
625941ca566aa707497f4611
def load_all_magres(dir): <NEW_LINE> <INDENT> atoms = [] <NEW_LINE> for magres_file in find_all_magres(dir): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> atoms.append(MagresAtoms.load_magres(magres_file)) <NEW_LINE> <DEDENT> except BadVersion: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> <DEDENT> return atoms
Find all magres files starting in directory dir and load them into a :py:class:`magres.atoms.MagresAtoms` structure. Returns a list.
625941ca76e4537e8c351719
def global_appendix(context, request): <NEW_LINE> <INDENT> page = get_partial(request, "global/appendix") <NEW_LINE> if page: <NEW_LINE> <INDENT> return format_markdown(context, request, page)
Returns a HTML of global appendix content. This appendix content is the content of ``internal:global/appendix`` page. :param context: A :class:`mako.runtime.Context` object. :param request: A :class:`pyramid.request.Request` object.
625941ca6fb2d068a760f144
def search(self, bucket, query): <NEW_LINE> <INDENT> self._input_mode = 'query' <NEW_LINE> self._inputs = {'module': 'riak_search', 'function': 'mapred_search', 'arg': [bucket, query]} <NEW_LINE> return self
Begin a map/reduce operation using a Search. This command will return an error unless executed against a Riak Search cluster. :param bucket: The bucket over which to perform the search :type bucket: string :param query: The search query :type query: string :rtype: RiakMapReduce
625941ca9f2886367277a935
def start_logger(self, _widget, Terminal): <NEW_LINE> <INDENT> savedialog = gtk.FileChooserDialog(title="Save Log File As", action=self.dialog_action, buttons=self.dialog_buttons) <NEW_LINE> savedialog.set_do_overwrite_confirmation(True) <NEW_LINE> savedialog.set_local_only(True) <NEW_LINE> savedialog.show_all() <NEW_L...
Handle menu item callback by saving text to a file
625941ca24f1403a92600c0e
def init_numericalCore(self, erase=True): <NEW_LINE> <INDENT> self.cpp_path = os.path.join(main_path(self), self.objlabel.lower()) <NEW_LINE> self.work_path = os.getcwd() <NEW_LINE> self.src_path = os.path.join(self.cpp_path, 'src') <NEW_LINE> if os.path.exists(self.cpp_path): <NEW_LINE> <INDENT> shutil.rmtree(self.cpp...
Build the Numeric from the Core. Additionnally, generate the c++ code if config['lang'] == 'c++'. Parameter --------- erase : bool (optional) If True, any existing h5file with same path than data h5file is erased. Else, it is used to initialize the data object. The default is True.
625941caa05bb46b383ec8c9
def ready_to_take(self) -> bool: <NEW_LINE> <INDENT> non_ending = flatten(self.get_path_sections(False)[0:5]) <NEW_LINE> return not any(non_ending)
Zjistí, zda jsou všechny aktivní kameny hráče v závěrečné zóně, a lze je tedy sebrat.
625941ca796e427e537b066d
def plot(self,mo_matrix,symmetry='1',title='All',x_label='index', y_label='MO coefficients',output_format='png', plt_dir='Plots',ylim=None,thresh=0.1,x0=0,grid=True,x_grid=None,**kwargs): <NEW_LINE> <INDENT> import pylab as plt <NEW_LINE> from matplotlib.ticker import MultipleLocator <NEW_LINE> import os <NEW_LINE> dis...
Plots all molecular orbital coefficients of one self.symmetry.
625941ca460517430c39422d
def get_item_list(self) -> List[ProviderDescriptor]: <NEW_LINE> <INDENT> res = [i for i in self.items.values()] <NEW_LINE> res.sort(key=lambda i: i.name) <NEW_LINE> return res
return the list of items in the catalog, sorted by name
625941ca3eb6a72ae02ec583
def quadrado(x): <NEW_LINE> <INDENT> return x * x
Retorna o quadrado de x.
625941cad486a94d0b98e1ec
def __negotiatehttp(self, destaddr, destport): <NEW_LINE> <INDENT> if not self.__proxy[3]: <NEW_LINE> <INDENT> addr = socket.gethostbyname(destaddr) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> addr = destaddr <NEW_LINE> <DEDENT> self.sendall( ("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + des...
__negotiatehttp(self,destaddr,destport) Negotiates a connection through an HTTP server.
625941ca283ffb24f3c559a9
def remove_tags(self, tags): <NEW_LINE> <INDENT> if isinstance(tags, (list, tuple, set)): <NEW_LINE> <INDENT> self.tags.difference_update(tags) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.tags.discard(tags)
Remove tags from the input. Args: tags: A single tag or list/tuple/set of tags
625941ca627d3e7fe0d68ef7
@task <NEW_LINE> def restart_redis(): <NEW_LINE> <INDENT> require('root', provided_by=('staging', 'production')) <NEW_LINE> with settings(user='sudouser'): <NEW_LINE> <INDENT> sudo('supervisorctl restart %(project)s-%(environment)s-redis' % env)
Restart Redis
625941cae5267d203edcdd45
def test_advance2(self, row=2): <NEW_LINE> <INDENT> self.apiname = read_excel(self.sheetNAME, row, 2) <NEW_LINE> self.parameter = Headers(read_excel('publicData', 4, 1), read_excel('Advance', row, 5)) <NEW_LINE> self.requestHandler(reqdata=self.parameter, row=row)
设置邮箱信息
625941cad8ef3951e32435e4
def makeInverseIndex(strlist): <NEW_LINE> <INDENT> D = {} <NEW_LINE> for (x,y) in enumerate(strlist): <NEW_LINE> <INDENT> for z in y.split(): <NEW_LINE> <INDENT> D.setdefault(z,set()).add(x) <NEW_LINE> <DEDENT> <DEDENT> return {x:y for x,y in D.items() if y!=set()}
Input: a list of documents as strings Output: a dictionary that maps each word in any document to the set consisting of the document ids (ie, the index in the strlist) for all documents containing the word. Note that to test your function, you are welcome to use the files stories_small.txt or stories_big.txt...
625941ca7d43ff24873a2d48
def _scroll_to_element(self, form_element, simple=False): <NEW_LINE> <INDENT> coordinates = form_element.location_once_scrolled_into_view <NEW_LINE> if simple: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> x = coordinates.get('x', 0) <NEW_LINE> y = coordinates.get('y', 0) <NEW_LINE> self.driver.execute_script( "window...
Scroll to element.
625941cabde94217f3682e99
def pivotIndex(self, nums): <NEW_LINE> <INDENT> sums = sum(nums) <NEW_LINE> total = 0 <NEW_LINE> for x, n in enumerate(nums): <NEW_LINE> <INDENT> if sums - n == 2 * total: return x <NEW_LINE> total += n <NEW_LINE> <DEDENT> return -1
:type nums: List[int] :rtype: int
625941ca56b00c62f0f14700
def facebook_extra_values(sender, user, response, details, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> birthday = timezone.datetime.strptime( response.get('birthday'), '%m/%d/%Y').date() <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> birthday = None <NEW_LINE> <DEDENT> location = response.get('lo...
Adds extra information retrieved from facebook to the profile.
625941ca925a0f43d2549f1e
def test_lc_fit(): <NEW_LINE> <INDENT> lc_fit(lc, X, y, F, wf)
[Parallel | Blend | Prep] test layer container fit.
625941cab7558d58953c4fbd
def test_batchDeleteOrderLimit(self): <NEW_LINE> <INDENT> options = self.store.querySQL('PRAGMA compile_options;') <NEW_LINE> if ('ENABLE_UPDATE_DELETE_LIMIT',) not in options: <NEW_LINE> <INDENT> raise unittest.SkipTest( 'SQLite compiled without SQLITE_ENABLE_UPDATE_DELETE_LIMIT') <NEW_LINE> <DEDENT> for i in range(10...
C{deleteFromStore} on a query with an order and limit specified does not disregard the order.
625941caff9c53063f47c29b
def fit_from_shape(self, image, initial_shape, gt_shape=None): <NEW_LINE> <INDENT> warnings.warn('Fitting from an initial shape is not supported by ' 'Dlib - therefore we are falling back to the tightest ' 'bounding box from the given initial_shape') <NEW_LINE> tightest_bb = initial_shape.bounding_box() <NEW_LINE> retu...
Fits the model to an image. Note that it is not possible to initialise the fitting process from a shape. Thus, this method raises a warning and calls `fit_from_bb` with the bounding box of the provided `initial_shape`. Parameters ---------- image : `menpo.image.Image` or subclass The image to be fitted. initial_sh...
625941ca460517430c39422e
def getRegion(self): <NEW_LINE> <INDENT> r = [self.lines[0].value(), self.lines[1].value()] <NEW_LINE> return (min(r), max(r))
Return the values at the edges of the region.
625941caac7a0e7691ed4175
def __init__(self, site_url, login_url, chrome_driver_path, sleep_time=2, user_agent=False): <NEW_LINE> <INDENT> self.site_url = site_url <NEW_LINE> self.login_url = login_url <NEW_LINE> self.chrome_options = Options() <NEW_LINE> self.chrome_driver_path = chrome_driver_path <NEW_LINE> if user_agent: <NEW_LINE> <INDENT>...
Creates a new instance of chrome for a WordPress site :type site_url: str :type login_url: str :type chrome_driver_path: str :type sleep_time: int :type user_agent: bool :param site_url: Home address of WordPress site. :param login_url: Login address of WordPress site. :param chrome_driver_path: Path of chrome webdriv...
625941ca3539df3088e2e3f2
def matrix(self): <NEW_LINE> <INDENT> return QMatrix
QPaintEngineState.matrix() -> QMatrix
625941ca167d2b6e31218c3d
def locate_human_centroid(self): <NEW_LINE> <INDENT> human_duis = utils.get_human_mesh(self.dui2dtn) <NEW_LINE> indices = sorted(idx for idx, dui in enumerate(self.duis) if dui in human_duis) <NEW_LINE> return np.mean(self.coordinates[indices, :], axis=0)
Locate the centroid of all human terms
625941ca7b25080760e39501
def record_measurements(step: int, reporters: Dict[str, uv.AbstractReporter], measure_batch_size: int, model, training_data, test_data): <NEW_LINE> <INDENT> train_m = total_metrics(model, training_data, measure_batch_size) <NEW_LINE> reporters["train"].report_all(step, train_m) <NEW_LINE> test_m = total_metrics(model, ...
This function actually records various metrics. NOTE that all of these measurements could have been recorded on the same base reporter! The only reason to break up the measurement like this is for style reasons.
625941ca7047854f462a14b2
def convert_bbox_to_output_tensor(img_dims, n_grids,n_classes,norm_class_vector): <NEW_LINE> <INDENT> label_arr = zeros((n_grids,n_grids,5+n_classes)) <NEW_LINE> boxes = get_bboxes(n_classes,norm_class_vector) <NEW_LINE> locs = get_grid_locations(img_dims,n_grids) <NEW_LINE> for box in boxes: <NEW_LINE> <INDENT> for lo...
this will convert a normal output vector of shape (n_samples, ((x, y, w, h, c) * nboxes) to a yolo label of shape (n_grids,n_grids,n_classes) works on only 1 sample
625941cacc40096d615959f8
def expand_test_files(test_dirs, names): <NEW_LINE> <INDENT> if not isinstance(names, list): <NEW_LINE> <INDENT> raise IpaUtilsException( 'Names must be a list containing test names' ' and/or test descriptions.' ) <NEW_LINE> <DEDENT> tests, descriptions = get_test_files(test_dirs) <NEW_LINE> expanded_names = [] <NEW_LI...
Expand the list of test files and test descriptions. Returns: List of test files and sync points. Raises: IpaUtilsException: If names is not a list.
625941ca71ff763f4b549732
def _level(img, bbox, landmark, cnns, padding): <NEW_LINE> <INDENT> for i in range(5): <NEW_LINE> <INDENT> x, y = landmark[i] <NEW_LINE> patch, patch_bbox = getPatch(img, bbox, (x, y), padding[0]) <NEW_LINE> patch = cv2.resize(patch, (15, 15)).reshape((1, 1, 15, 15)) <NEW_LINE> patch = processImage(patch) <NEW_LINE> d1...
第二阶段,左眼睛、右眼睛、鼻子、左嘴角、右嘴角分别预测 :param img: 灰度图 :param bbox: 人脸框 :param landmark: 第一阶段预测的位置 :param cnns: CNN网络 :param padding: 第一次预测点内间距,取一小块区域 :return: 更精确的结果
625941cae5267d203edcdd46
def peek(self): <NEW_LINE> <INDENT> if not self.hasPeeked: <NEW_LINE> <INDENT> self.hasPeeked = True <NEW_LINE> self.PeekedElement.append(self.iterator.next()) <NEW_LINE> <DEDENT> return self.PeekedElement[-1]
Returns the next element in the iteration without advancing the iterator. :rtype: int
625941ca099cdd3c635f0d02
def test_thing_property_subscribe(exposed_thing, property_fragment): <NEW_LINE> <INDENT> assert property_fragment.observable <NEW_LINE> @tornado.gen.coroutine <NEW_LINE> def test_coroutine(): <NEW_LINE> <INDENT> prop_name = Faker().pystr() <NEW_LINE> exposed_thing.add_property(prop_name, property_fragment) <NEW_LINE> v...
Property updates can be observed on ExposedThings using the map-like interface.
625941caa934411ee375173b
def process(self): <NEW_LINE> <INDENT> histo = self.data['midiIntervalHistogram'] <NEW_LINE> total = sum(histo) <NEW_LINE> if total == 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> targets = [1] <NEW_LINE> total = sum(histo) <NEW_LINE> count = 0 <NEW_LINE> for t in targets: <NEW_LINE> <INDENT> count += histo[t] <NE...
Do processing necessary, storing result in feature.
625941ca379a373c97cfabec
def _must_be_contributor_factory(include_public): <NEW_LINE> <INDENT> def wrapper(func): <NEW_LINE> <INDENT> @functools.wraps(func) <NEW_LINE> def wrapped(*args, **kwargs): <NEW_LINE> <INDENT> response = None <NEW_LINE> _inject_nodes(kwargs) <NEW_LINE> node = kwargs['node'] <NEW_LINE> kwargs['auth'] = Auth.from_kwargs(...
Decorator factory for authorization wrappers. Decorators verify whether the current user is a contributor on the current project, or optionally whether the current project is public. :param bool include_public: Check whether current project is public :return: Authorization decorator
625941ca91af0d3eaac9bac0
def format_queues(queues, indent=0): <NEW_LINE> <INDENT> format = lambda **queue: QUEUE_FORMAT.strip() % queue <NEW_LINE> info = "\n".join(format(name=name, **config) for name, config in queues.items()) <NEW_LINE> return textindent(info, indent=indent)
Format routing table into string for log dumps.
625941ca3c8af77a43ae3848
def _get_proceedings(self): <NEW_LINE> <INDENT> return self.__proceedings
Getter method for proceedings, mapped from YANG variable /inputs/vnfbd/proceedings (container) YANG Description: Proceedings of VNF-BD. The proceedings are utilized by the Manager component to execute a benchmarking Test. It consists of agent(s)/monitor(s) settings, detailing their prober(s)/listener(s) specif...
625941caf548e778e58cd625
def _an_element_(self): <NEW_LINE> <INDENT> return OverconvergentModularFormElement(self, self._gsr.an_element())
Return an element of this space (used by the coercion machinery). EXAMPLES:: sage: OverconvergentModularForms(3, 2, 1/3, prec=4).an_element() # indirect doctest 3-adic overconvergent modular form of weight-character 2 with q-expansion 9*q + 216*q^2 + 2430*q^3 + O(q^4)
625941cad10714528d5ffd8a
def _handle_id_conflict(instance, attachments, process, domain): <NEW_LINE> <INDENT> conflict_id = _extract_id_from_raw_xml(instance) <NEW_LINE> existing_doc = XFormInstance.get_db().get(conflict_id) <NEW_LINE> assert domain <NEW_LINE> if existing_doc.get('domain') != domain or existing_doc.get('doc_type') n...
For id conflicts, we check if the files contain exactly the same content, If they do, we just log this as a dupe. If they don't, we deprecate the previous form and overwrite it with the new form's contents.
625941ca26238365f5f0ef15
def set_dest_dir(self, path): <NEW_LINE> <INDENT> assert isinstance(path, string_types), path <NEW_LINE> self.dlconfig.set('download_defaults', 'saveas', path)
Sets the directory where to save this Download. @param path A path of a directory.
625941ca76e4537e8c35171a
def add_step(self, exposure_ms, lamp, tl_intensity=None, delay_after_ms=0): <NEW_LINE> <INDENT> self._compiled = False <NEW_LINE> if lamp == 'TL': <NEW_LINE> <INDENT> lamp_timing = self._config.sutter_led.TIMING <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if tl_intensity is not None: <NEW_LINE> <INDENT> raise ValueEr...
Add an image acquisition step to the existing sequence. Parameters exposure_ms: exposure time in ms for the image. lamp: 'TL' for transmitted light, or name of a spectra lamp for fluorescence. tl_intensity: intensity of the transmitted lamp, should it be enabled. If None, then do not change intensity setting from ...
625941cafbf16365ca6f626b
def copyright(self, date=True, minimum=1990, maximum=2016): <NEW_LINE> <INDENT> ct = self.company_type(abbr=True) <NEW_LINE> if date: <NEW_LINE> <INDENT> founded = randint(minimum, maximum - 1) <NEW_LINE> return '© %s-%s %s, %s' % (founded, maximum, self.company(), ct) <NEW_LINE> <DEDENT> return '© %s, %s' % (self.comp...
Generate a random copyright. :param date: When True will be returned copyright with date. :param minimum: Minimum of date range. :param maximum: Maximum of date range. :return: Dummy copyright of company. :Example: © 1990-2016 Komercia, Inc.
625941cae64d504609d748e8
def _finished(self, results): <NEW_LINE> <INDENT> self.result = results <NEW_LINE> self.result_set = True
This is a default callback function automatically added for all jobs. It is the first function called when job finishes, and simply sets the result of the job.
625941ca10dbd63aa1bd2c4b
def cmd_playMode(self, mode): <NEW_LINE> <INDENT> self.send_command('(playMode {})'.format(mode))
Schedules the '(playMode mode)' trainer command for the simspark instance. Available play modes can be found at: http://simspark.sourceforge.net/wiki/index.php/Play_Modes
625941ca85dfad0860c3af03
def repository_list(request): <NEW_LINE> <INDENT> repository_list = models.Repository.objects.all() <NEW_LINE> if not request.user.is_authenticated(): <NEW_LINE> <INDENT> repository_list = repository_list.filter(is_private=False) <NEW_LINE> <DEDENT> return shortcuts.render_to_response( 'svnlit/repository_list.html', lo...
A view listing the available repositories.
625941ca30dc7b7665901a0f
def assertProvides(self, obj, interface): <NEW_LINE> <INDENT> from lp.testing.matchers import Provides <NEW_LINE> self.assertThat(obj, Provides(interface))
Assert 'obj' correctly provides 'interface'.
625941ca851cf427c661a5b7
def isMatch(self, s, p): <NEW_LINE> <INDENT> if s == p == '': <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> lastF = [0] * (len(s) + 1) <NEW_LINE> lastF[0] = 1 <NEW_LINE> nowF = None <NEW_LINE> for i, ch in enumerate(p): <NEW_LINE> <INDENT> if i != len(p) - 1 and p[i + 1] == '*': <NEW_LINE> <INDENT> nowF = [0] * (...
:type s: str :type p: str :rtype: bool
625941caff9c53063f47c29c
def disable(): <NEW_LINE> <INDENT> actions.superuser_run('ttrss', ['disable']) <NEW_LINE> frontpage.remove_shortcut('ttrss')
Enable the module.
625941ca5510c4643540f48e
def dense_assem(elements, mats, nodes, neq, DME, uel=None): <NEW_LINE> <INDENT> KG = np.zeros((neq, neq)) <NEW_LINE> MG = np.zeros((neq, neq)) <NEW_LINE> CG = np.zeros((neq, neq)) <NEW_LINE> nels = elements.shape[0] <NEW_LINE> for el in range(nels): <NEW_LINE> <INDENT> kloc , mloc , cloc , ndof , iet = retriever(eleme...
Assembles the global stiffness matrix _KG_ using a dense storing scheme Parameters ---------- elements : ndarray (int) Array with the number for the nodes in each element. mats : ndarray (float) Array with the material profiles. nodes : ndarray (float) Array with the nodal numbers and coordinates. DME : n...
625941ca4428ac0f6e5ba89a
def serialize(self, buff): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> _x = self <NEW_LINE> buff.write(_struct_d5I.pack(_x.packet_timestamp, _x.stage, _x.stage_time_left, _x.command, _x.command_counter, _x.command_timestamp)) <NEW_LINE> _x = self.b_name <NEW_LINE> length = len(_x) <NEW_LINE> if python3 or type(_x) == ...
serialize message into buffer :param buff: buffer, ``StringIO``
625941ca287bf620b61d3b0c
def gen_cre_str_index_o0(orb_list, nelec): <NEW_LINE> <INDENT> cre_strs = make_strings(orb_list, nelec+1) <NEW_LINE> if isinstance(cre_strs, OIndexList): <NEW_LINE> <INDENT> raise NotImplementedError('System with 64 orbitals or more') <NEW_LINE> <DEDENT> credic = dict(zip(cre_strs,range(cre_strs.__len__()))) <NEW_LINE>...
Slow version of gen_cre_str_index function
625941ca0fa83653e4657064
def fire(data): <NEW_LINE> <INDENT> return fire_entity(_TRANSMITTER_TRANSFORMS, _TRANSMITTER_SORT, data)
Returns the given record as a string formatted to the IRS Publication 1220 specification, based on data supplied as parameter. Parameters ---------- data : dict Expects data parameter to have all keys specified in _TRANSMITTER_TRANSFORMS. Returns ---------- str String formatted to meet IRS Publication 122...
625941cab57a9660fec3392c
def __init__(self, func): <NEW_LINE> <INDENT> self.func_ = func <NEW_LINE> BehaviorLoop.__init__(self) <NEW_LINE> self.functionCodeName_ = self.func_.alias()
Save a reference to the function, and configure the function to loop.
625941ca2ae34c7f2600d1d9
def region_obs(rtype, subregion): <NEW_LINE> <INDENT> response = requests.get("http://ebird.org/ws1.1/data/obs/region/recent?rtype=" + rtype + "&r=" + subregion + "&hotspot=true&includeProvisional=true&back=5&fmt=json") <NEW_LINE> if response.status_code == 400: <NEW_LINE> <INDENT> assert response.status_code == 400 <N...
checklists
625941ca82261d6c526ab547
def click_bulk_edit_button(self): <NEW_LINE> <INDENT> is_clicked = None <NEW_LINE> try: <NEW_LINE> <INDENT> self.logger.info('Start: click bulk edit button') <NEW_LINE> self._sell_page.click_bulk_edit_button() <NEW_LINE> is_clicked = True <NEW_LINE> <DEDENT> except WebDriverException as exp: <NEW_LINE> <INDENT> is_clic...
Returning click bulk edit button Implementing logging for click bulk edit button functionality :return: True/False
625941cad268445f265b4f16
def update_active_users(request): <NEW_LINE> <INDENT> if request.is_ajax(): <NEW_LINE> <INDENT> active = Visitor.objects.active() <NEW_LINE> user = getattr(request, 'user', None) <NEW_LINE> info = { 'active': active, 'registered': active.filter(user__isnull=False), 'guests': active.filter(user__isnull=True), 'user': us...
Returns a list of all active users
625941ca236d856c2ad44882
def decsamples(self): <NEW_LINE> <INDENT> return (s for s in self.dec_samples)
Returns an iterator over decision samples.
625941ca8c3a873295158462
def recv(self, buffsize: int, timeout: Optional[float] = 20.0) -> bytes: <NEW_LINE> <INDENT> raise NotImplementedError("Abstract class.")
Receives data on the connection. :param buffsize: how much data at max is received :param timeout: timeout of the receiving call
625941ca15baa723493c401d
def seq_gather(x): <NEW_LINE> <INDENT> seq, idxs = x <NEW_LINE> idxs = K.cast(idxs, 'int32') <NEW_LINE> batch_idxs = K.arange(0, K.shape(seq)[0]) <NEW_LINE> batch_idxs = K.expand_dims(batch_idxs, 1) <NEW_LINE> idxs = K.concatenate([batch_idxs, idxs], 1) <NEW_LINE> return K.tf.gather_nd(seq, idxs)
seq是[None,seq_len,s_size]的格式,idxs是[None,1]的格式 在seq的第i个序列中选出第idxs[i]个向量,最后输出[None,s_size]的向量
625941cad18da76e2353257e
def undo(self, doc): <NEW_LINE> <INDENT> self._apply(doc, inverse=True)
Undo operation.
625941cae8904600ed9f1fd4
def _fe_extract_tld(self, sample): <NEW_LINE> <INDENT> result = OrderedDict() <NEW_LINE> for item in self._tlds: <NEW_LINE> <INDENT> result["tld_{}".format(item)] = 1 if item == sample['tld'] else 0 <NEW_LINE> <DEDENT> return result
Check if TLD is in a list of ~30 TLDs indicative of phishing / not phishing. Originally, this was a categorical feature extended via get_dummies / one hot encoding, but it was adding too many unnecessary features to the feature vector resulting in a large tax performance wise. Args: sample (dictionary): Info about...
625941cae8904600ed9f1fd5