code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def proxy_factory(format, filename=None): <NEW_LINE> <INDENT> if filename: <NEW_LINE> <INDENT> return get_processor(format, _INDEXER_MAP)(filename, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return format in _INDEXER_MAP
Given a filename returns proxy object, else boolean if format OK.
625941e857b8e32f52483936
def arg(*args, **kwargs): <NEW_LINE> <INDENT> kwargs = {k: v for k, v in kwargs.items() if not k.startswith("__")} <NEW_LINE> ret = { "args": args, "kwargs": kwargs, } <NEW_LINE> return ret
Output the given args and kwargs Kwargs will be filtered for 'private' keynames.
625941e8b830903b967e9d9e
def test_formats_dict(self): <NEW_LINE> <INDENT> formatter = PositionalArgumentsFormatter() <NEW_LINE> event_dict = formatter(None, None, {'event': '%(foo)s bar', 'positional_args': ( {'foo': 'bar'},)}) <NEW_LINE> assert 'bar bar' == event_dict['event'] <NEW_LINE> assert 'positional_args' not in event_dict
Positional arguments as dict are rendered.
625941e8cc40096d61595de6
def execute_athena_query(output_location, query): <NEW_LINE> <INDENT> console_printer.print_info( f"Executing query and sending output results to '{output_location}'" ) <NEW_LINE> athena_client = get_client(service_name="athena") <NEW_LINE> query_start_resp = athena_client.start_query_execution( QueryString=query, Resu...
Executes the given individual query against athena and return the result. Keyword arguments: output_location -- the s3 location to output the results of the execution to query -- the query to execute
625941e8e64d504609d74cd8
@cli.command(name="generate-import-list") <NEW_LINE> @click.option("--list-path", "list_path", help="Specify the list output file.") <NEW_LINE> @click.pass_context <NEW_LINE> @sceptre_cli.environment_options <NEW_LINE> @sceptre_cli.catch_exceptions <NEW_LINE> def generate_import_list(ctx, environment, list_path): <NEW_...
Generate import a list of Sceptre stack from AWS Cloudformation.
625941e8167d2b6e3121902d
def Login(access_token): <NEW_LINE> <INDENT> url = "https://api.bunjang.co.kr/login_with_token" <NEW_LINE> loginPayload: dict = { "token": access_token } <NEW_LINE> headers = { "Host": "api.bunjang.co.kr", "User-Agent": "Mozilla/5.0 (Linux; Android 10.0.0; SM-F700NZPAKOO) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/7...
```http Host: api.bunjang.co.kr User-Agent: Mozilla/5.0 (Linux; Android 10.0.0; SM-F700NZPAKOO) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.101 Mobile Safari/537.36 Content-Type: application/json;charset=utf-8 Origin: https://m.bunjang.co.kr Connection: keep-alive Referer: https://m.bunjang.co.kr/ TE: Trail...
625941e8236d856c2ad44c78
def initFromSimulation(KF, measFile, nUnderSamp=1, tRange=None, colMap=None, timeCol='Time_[s]', dataDict=None): <NEW_LINE> <INDENT> import welib.fast.fastlib as fastlib <NEW_LINE> import welib.weio as weio <NEW_LINE> df=weio.read(measFile).toDataFrame() <NEW_LINE> df=df.iloc[::nUnderSamp,:] <NEW_LINE> if tRange is not...
" - Open a simulation result file - Use dt to discretize the KF - Define clean values of measurements and states based on simulation - Define sigmas from the std of the clean signals dataDict: additional data provided for ColMap
625941e85fc7496912cc3e15
def fixBackslashes( fileName ): <NEW_LINE> <INDENT> return re.sub( r'\\', '/', fileName, 0 )
Convert backslashes to slashes in file name
625941e856ac1b37e626465e
def setUp(self): <NEW_LINE> <INDENT> super(VideoBatchUnarchiveTests, self).setUp() <NEW_LINE> self.project = milkman.deliver(Project) <NEW_LINE> self.project.set_owner(self.admin) <NEW_LINE> self.project.add_assigned(self.user, pending=False) <NEW_LINE> self.video = self.create_video( project=self.project, user=self.us...
Bootstrap test data
625941e87d43ff24873a313c
def declare_sample_delay(self, *args): <NEW_LINE> <INDENT> return _blocks_swig2.add_const_ss_sptr_declare_sample_delay(self, *args)
declare_sample_delay(add_const_ss_sptr self, int which, int delay) declare_sample_delay(add_const_ss_sptr self, unsigned int delay)
625941e81b99ca400220af4b
def __compare(self, VMInstruction): <NEW_LINE> <INDENT> self.__writeLine("@CHECK" + str(self.__conCounter)) <NEW_LINE> self.__writeLine("0;JMP") <NEW_LINE> self.__writeLine("(TRUE" + str(self.__conCounter) + ")") <NEW_LINE> self.__writeLine("@SP") <NEW_LINE> self.__writeLine("A=M-1") <NEW_LINE> self.__writeLine("M=-1")...
writes the stack equal instructions in hack assembly to output file
625941e838b623060ff0b285
def _fan_native(method): <NEW_LINE> <INDENT> setattr(method, _FAN_NATIVE, True) <NEW_LINE> return method
Native fan method not overridden.
625941e8287bf620b61d3ef9
def __calcInstanceScore(self, labels): <NEW_LINE> <INDENT> uniqueLabels = np.unique(labels) <NEW_LINE> numSamples = labels.size <NEW_LINE> klDivergence = 0 <NEW_LINE> uniform = 1 / uniqueLabels.size <NEW_LINE> for cluster in uniqueLabels: <NEW_LINE> <INDENT> currentSize = labels[labels == cluster].size <NEW_LINE> curre...
Calculates a goodness of clustering depending on how many games are in the different categories. A good clustering is a clustering with clusters with more than 1 game but not too many games Args: categories (g numpy-Array): [For each game in the original data the corresponding label] Returns: [float]: [Insta...
625941e891f36d47f21ac98f
def cancel_builds_for_org(self, orgid, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('callback'): <NEW_LINE> <INDENT> return self.cancel_builds_for_org_with_http_info(orgid, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.cancel_builds_for_org_with...
Cancel builds for org Cancel all in progress builds for an organization. Canceling an already finished build will do nothing and respond successfully. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the resp...
625941e86aa9bd52df03723f
@pytest.fixture(params=[True, False]) <NEW_LINE> def skipna(request): <NEW_LINE> <INDENT> return request.param
Fixture to pass skipna to nanops functions.
625941e830dc7b7665901df9
def create_puzzle(self): <NEW_LINE> <INDENT> self.rho_horizontal, self.rho_vertical = get_line_positions(self.img_gray, 150) <NEW_LINE> puzzle = Container((len(self.rho_horizontal) - 1, len(self.rho_vertical) - 1)) <NEW_LINE> for i in range(len(self.rho_horizontal) - 1): <NEW_LINE> <INDENT> for j in range(len(self.rho_...
Creates new puzzle. Detects lines on image, cuts image along them and passes smaller images to container. :return: puzzle
625941e8498bea3a759b9f46
def __init__(self, relations): <NEW_LINE> <INDENT> self.relations = relations
Initialize a new Window object. Args: links: 1d list [link1, link2, ... ] each link consist of two args
625941e8d4950a0f3b08c7e1
def fromDict(self, objDict, checkForClassData = True): <NEW_LINE> <INDENT> if isinstance(objDict, list): <NEW_LINE> <INDENT> ret = objDict[:] <NEW_LINE> for idx, value in enumerate(ret): <NEW_LINE> <INDENT> ret[idx] = self.fromDict(value, checkForClassData) <NEW_LINE> <DEDENT> <DEDENT> elif isinstance(objDict, dict): <...
Inverse of toDict, takes a dict and finds members with module & class names, and builds their instances.
625941e85510c4643540f871
def farthest_point_sampling(pts, k, initial_idx=None, metrics=l2_norm, skip_initial=False, indices_dtype=np.int32, distances_dtype=np.float32): <NEW_LINE> <INDENT> if pts.ndim == 2: <NEW_LINE> <INDENT> pts = pts[None, ...] <NEW_LINE> <DEDENT> assert pts.ndim == 3 <NEW_LINE> batch_size, num_point, coord_dim = pts.shape ...
Batch operation of farthest point sampling Code referenced from below link by @Graipher https://codereview.stackexchange.com/questions/179561/farthest-point-algorithm-in-python Args: pts (numpy.ndarray or cupy.ndarray): 2-dim array (num_point, coord_dim) or 3-dim array (batch_size, num_point, coord_dim) ...
625941e816aa5153ce362910
def get_page_tags(self): <NEW_LINE> <INDENT> meta_keywords = self.html['head'].cssselect('meta[name="keywords"]') <NEW_LINE> if not meta_keywords: <NEW_LINE> <INDENT> return '' <NEW_LINE> <DEDENT> return meta_keywords[0].get('content')
Return the tags for the page.
625941e8eab8aa0e5d26dff2
def ap_title(s): <NEW_LINE> <INDENT> ARTS = ['a', 'an', 'the'] <NEW_LINE> PREPS = ['about', 'above', 'across', 'after', 'against', 'along', 'amid', 'amidst', 'among', 'around', 'at', 'before', 'behind', 'below', 'beneath', 'beside', 'besides', 'between', 'beyond', 'during', 'except', 'for', 'from', 'in', 'into', 'of',...
Return properly title-cased version of input string according to AP style guide rules. The AP stylebook says: - capitalize the principal words, including prepositions and conjunctions of four or more letters. - capitalize an article – the, a, an – or words of fewer than four letters if it is the first or last word...
625941e876e4537e8c351b0e
def __init__(self): <NEW_LINE> <INDENT> CONF = "profile/adam/conf.yml" <NEW_LINE> self.HOME = os.environ['HOME'] <NEW_LINE> yf = open(self.getPath(CONF)) <NEW_LINE> self.conf = yaml.load(yf) <NEW_LINE> self.o = self.par(self.conf) <NEW_LINE> self.sshfile = self.getPath(self.conf["ODB_FILE"]) <NEW_LINE> self.kfile = sel...
初始化
625941e863f4b57ef00015a4
def test_is_host(self): <NEW_LINE> <INDENT> rendered = self.TEMPLATE2.render(Context({'user':self.user, 'event':self.event1.title})) <NEW_LINE> self.assertIn("False", rendered) <NEW_LINE> rendered = self.TEMPLATE2.render(Context({'user': self.host, 'event': self.event1.title})) <NEW_LINE> self.assertIn("True", rendered...
Tests the events that you make and if you're allowed to reserve them
625941e8cc0a2c11143dd32a
def sub(self, plane, insert_after = None): <NEW_LINE> <INDENT> if plane.parent is not None: <NEW_LINE> <INDENT> plane.parent.remove(plane.name) <NEW_LINE> <DEDENT> if plane.name in self.subplanes_list: <NEW_LINE> <INDENT> del self.subplanes_list[self.subplanes_list.index(plane.name)] <NEW_LINE> <DEDENT> if insert_after...
Remove the Plane given from its current parent and add it as a subplane of this Plane. If insert_after is given, the new subplane will be inserted immediately after the subplane with that name in Plane.subplanes_list, else it will simply be appended. If a subplane with the same name already exists, it is silently rep...
625941e87cff6e4e81117e1e
def test_wrong_type(self): <NEW_LINE> <INDENT> self.assertInvalidCandidate([ ['', 'C_A', 'C_B', 'C_C'], ['R_1', 'a', 'b', 'c'], ])
Test when data is apparent but has the wrong type.
625941e8cdde0d52a9e534cf
def __isub__(self, other): <NEW_LINE> <INDENT> for elem, count in other.items(): <NEW_LINE> <INDENT> self[elem] -= count <NEW_LINE> <DEDENT> return self._keep_positive()
Inplace subtract counter, but keep only results with positive counts. >>> c = Counter('abbbc') >>> c -= Counter('bccd') >>> c Counter({'b': 2, 'a': 1})
625941e86aa9bd52df037240
def leadimage(self, item): <NEW_LINE> <INDENT> if self._has_leadimage(item) and self._field_is_visible('image'): <NEW_LINE> <INDENT> tile_conf = self.get_tile_configuration() <NEW_LINE> image_conf = tile_conf.get('image', None) <NEW_LINE> if image_conf: <NEW_LINE> <INDENT> scaleconf = image_conf['imgsize'] <NEW_LINE> i...
return lead image
625941e824f1403a92600ffb
def post_process_graphml(self, file_path): <NEW_LINE> <INDENT> if file_path: <NEW_LINE> <INDENT> path = Path(file_path) <NEW_LINE> if path.is_file(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.xml_doc = ET.parse(file_path) <NEW_LINE> attributes = ['designName', 'serie', 'target_market', 'drive_wheels', 'battery_...
Main procedure for postprocessing generated .graphml (convert from .graphml to .xml) :param file_path: generated .graphml file to be post-processed :return:None.
625941e8596a897236089f53
def clear_graphs(self): <NEW_LINE> <INDENT> self.__container.clear_data() <NEW_LINE> self.redraw({}, True)
Clears the graphs in the logging display
625941e866673b3332b9252a
def test_auth_sharable_cannot_share(self): <NEW_LINE> <INDENT> self.do_sharable(False, 'pattieblack', _fake_membership(False), tenant='froggy')
Tests that an authenticated context (with is_admin set to False) cannot share an image it does not own even if it is shared with it, but with can_share = False.
625941e84428ac0f6e5bac8f
def resolution(self, **kw): <NEW_LINE> <INDENT> self._translate_Q_to_theta(kw) <NEW_LINE> if 'T' not in kw: <NEW_LINE> <INDENT> raise TypeError("resolution requires slits and either T or Q") <NEW_LINE> <DEDENT> L = kw.get('L',kw.get('wavelength',self.wavelength)) <NEW_LINE> if 'dL' in kw: <NEW_LINE> <INDENT> dL = kw['d...
Calculate resolution at each angle. :Return: *T*, *dT* : [float] | |deg| Angles and angular divergence. *L*, *dL* : [float] | |Ang| Wavelengths and wavelength dispersion.
625941e84527f215b584c8eb
def __mul__(self, val): <NEW_LINE> <INDENT> t = TokenSeries(self) <NEW_LINE> if isinstance(val, int): <NEW_LINE> <INDENT> t.min = t.max = val <NEW_LINE> <DEDENT> elif isinstance(val, tuple): <NEW_LINE> <INDENT> if len(val) == 2: <NEW_LINE> <INDENT> t.min, t.max = val <NEW_LINE> <DEDENT> elif len(val) == 1: <NEW_LINE> <...
Allows you to construct L{TokenSeries} with the * operator. Operand can be: - int (a series of exactly this many) - (int, ) (a series of at least this many) - (x:int, y:int) a series of x to y The constant Inf can be used in some of these -- * Inf yields a 0--infinity series, and * (x, Inf) yields an x--i...
625941e807f4c71912b1191d
def test_empty_data_put(self): <NEW_LINE> <INDENT> data = {} <NEW_LINE> url = reverse('suggested_topic', args=[101]) <NEW_LINE> response = self.client.put(url, json.dumps(data), content_type='application/json') <NEW_LINE> self.assertEqual(response.status_code, 400)
Method that tests unsuccess put request for the updating the certain suggested topic.
625941e8de87d2750b860230
def next_turn(): <NEW_LINE> <INDENT> if turn == X: <NEW_LINE> <INDENT> return O <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return X
Zmień wykonawcę ruchu
625941e855399d3f05588b50
def _negativeInt(val): <NEW_LINE> <INDENT> val = _int(val) <NEW_LINE> if val>0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return val
same as _int(), but returns 0 when you give a positive int.
625941e83d592f4c4ed1d4fa
def get_bootstrap(configurator): <NEW_LINE> <INDENT> url = 'http://downloads.buildout.org/2/bootstrap.py' <NEW_LINE> req = request.urlopen(url) <NEW_LINE> with open(os.path.join(configurator.target_directory, 'bootstrap.py'), 'w') as bootstrap: <NEW_LINE> <INDENT> bootstrap.write(str(req.read()))
Get the last version of bootstrap.py
625941e80383005118ecfa7a
def save(self): <NEW_LINE> <INDENT> _logger.debug('Saving {}'.format(self)) <NEW_LINE> if self.nosave: <NEW_LINE> <INDENT> _logger.info('Fit results are not saved (saving is disabled)') <NEW_LINE> return <NEW_LINE> <DEDENT> elif not (self.tif or self.edf or self.csv or self.dat or self.h5): <NEW_LINE> <INDENT> _logger....
Save result of XRF batch fitting. Preferrable use saveContext instead. HDF5 NXprocess will be updated, not overwritten.
625941e816aa5153ce362911
def test(self, data, labels): <NEW_LINE> <INDENT> n = len(labels) <NEW_LINE> correct = 0 <NEW_LINE> for i in range(n): <NEW_LINE> <INDENT> print('predicting:' + str(i)) <NEW_LINE> x = data[i] <NEW_LINE> y = labels[i] <NEW_LINE> if self.pred(x) == y: <NEW_LINE> <INDENT> correct += 1 <NEW_LINE> <DEDENT> <DEDENT> return c...
:param data: 测试集数据 :param labels: 测试集标签 :return: 模型对测试集数据的预测准确率
625941e8656771135c3ebd0d
def naked_twins(values): <NEW_LINE> <INDENT> for unit in unitlist: <NEW_LINE> <INDENT> found_twin = False <NEW_LINE> temp_pairs = {} <NEW_LINE> for box in unit: <NEW_LINE> <INDENT> twins = [] <NEW_LINE> if(len(values[box]) == 2): <NEW_LINE> <INDENT> temp_pairs[box] = values[box] <NEW_LINE> <DEDENT> <DEDENT> for i in te...
Eliminate values using the naked twins strategy. Args: values(dict): a dictionary of the form {'box_name': '123456789', ...} Returns: the values dictionary with the naked twins eliminated from peers.
625941e8627d3e7fe0d692eb
def _split_generators(self, dl_manager): <NEW_LINE> <INDENT> urls_to_download = {"train": _TRAIN_FILE, "dev": _DEV_FILE, "test": _TEST_FILE} <NEW_LINE> downloaded_files = dl_manager.download_and_extract(urls_to_download) <NEW_LINE> return [ nlp.SplitGenerator(name=nlp.Split.TRAIN, gen_kwargs={"filepath": downloaded_fil...
Returns SplitGenerators.
625941e8a8370b7717052d36
def is_out_of_space(job): <NEW_LINE> <INDENT> stderr = os.path.join(job.workdir, config.Payload.payloadstderr) <NEW_LINE> error_messages = ["No space left on device"] <NEW_LINE> return scan_file(stderr, error_messages, warning_message="identified a \'%s\' message in %s" % (error_messages[0], os.path.basename(stderr)))
Did the disk run out of space? :param job: job object. :return: Boolean. (note: True means the error was found)
625941e850812a4eaa59c7b6
def get_element_ids_of_type(self, seqid, element_type, start = None, end = None): <NEW_LINE> <INDENT> added = set() <NEW_LINE> iterator = self.bucketmaps[seqid].iteritems(start=start,end=end) <NEW_LINE> for theRange, element_id in iterator: <NEW_LINE> <INDENT> if element_id in added: <NEW_LINE> <INDENT> continue <NEW_L...
Gets element ids of some type along a coordinate system Parameters ---------- seqid : str The name of the coordinate system to check element_type : str The type of the elements you want (e.g. 'gene' or 'mRNA') start : int, optional The start point for getting the elements (inclusive, 1-based) end : int, op...
625941e8a79ad161976cc5df
def parser(self, page_url, html_cont): <NEW_LINE> <INDENT> if page_url is None or html_cont is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> soup = BeautifulSoup(html_cont, 'html.parser') <NEW_LINE> new_urls = self._get_new_urls(page_url, soup) <NEW_LINE> new_data = self._get_new_data(page_url, soup) <NEW_LINE> ...
parse a given html page :param page_url: the url path :param html_cont: the content of this url :return: a turple about new urls and the dictionary of this url
625941e8cb5e8a47e48b7f3c
def binarize(img_array): <NEW_LINE> <INDENT> if len(img_array.shape) < 3: <NEW_LINE> <INDENT> return img_array <NEW_LINE> <DEDENT> assert(img_array.shape[2] == 3) <NEW_LINE> img_bin_array = np.zeros((img_array.shape[0], img_array.shape[1]), dtype=np.float32) <NEW_LINE> rchan = img_array[:, :, 0] <NEW_LINE> gchan = img_...
Given an RGB image, create a 2D binary image from it using Otsu's method in each color channel to adaptively compute thresholds.
625941e84f88993c3716c4fc
def main(): <NEW_LINE> <INDENT> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'learn_vue_django.settings') <NEW_LINE> try: <NEW_LINE> <INDENT> from django.core.management import execute_from_command_line <NEW_LINE> <DEDENT> except ImportError as exc: <NEW_LINE> <INDENT> raise ImportError( "Couldn't import Django. Are...
Run administrative tasks.
625941e821bff66bcd684de7
def rssh(bot, update): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open('/tmp/rssh-pid', 'r') as pid_file: <NEW_LINE> <INDENT> pid = pid_file.readline() <NEW_LINE> if (run(['kill', '%s' % pid]).returncode == 0): <NEW_LINE> <INDENT> bot.send_message(chat_id=update.effective_user.id, text="RSSH closed.") <NEW_LINE>...
Disables RSSH access
625941e8bde94217f3683286
def sumRange(self, i, j): <NEW_LINE> <INDENT> return SegmentTree.query(self.root, i, j)
:type i: int :type j: int :rtype: int
625941e86e29344779a62aa9
def _get_documents(self, agenda_or_minutes): <NEW_LINE> <INDENT> if agenda_or_minutes == "agenda": <NEW_LINE> <INDENT> url = self.site.url + "epj_asil.htm" <NEW_LINE> <DEDENT> elif agenda_or_minutes == "minutes": <NEW_LINE> <INDENT> url = self.site.url + "pk_asil.htm" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise...
Returns a list of documents related to a meeting. url should be "epj_asil.htm" or Every paragraph has an own document. A paragraph can have multiple attachments. These are treated as independent documents
625941e88a43f66fc4b544fa
def time_shade(self): <NEW_LINE> <INDENT> op_time = {} <NEW_LINE> max_time = 0 <NEW_LINE> for op, es in self.exec_summ_map.items(): <NEW_LINE> <INDENT> time = str_to_us(es.avg_time) <NEW_LINE> op_time[op] = time <NEW_LINE> max_time = time if time > max_time else max_time <NEW_LINE> <DEDENT> max_time += 1 <NEW_LINE> for...
Color Impala plan nodes with red shades according to its execution time. Slowest plan in the query will be colored dark red.
625941e8f9cc0f698b140a91
def test_insert_select(self): <NEW_LINE> <INDENT> dropall_and_create() <NEW_LINE> ins_doc_title = str(random.random()) <NEW_LINE> ins_doc = Document(title=ins_doc_title, type='article') <NEW_LINE> insert(ins_doc) <NEW_LINE> ins_doc_id = ins_doc.doc_id <NEW_LINE> sel_doc_title = select(Document.title, Document.doc_id ==...
insert and check insert result
625941e821a7993f00bc8191
def filter(self, p): <NEW_LINE> <INDENT> meanI = box_filter(I=self.I, r=self.radius) <NEW_LINE> meanp = box_filter(I=p, r=self.radius) <NEW_LINE> corrI = box_filter(I=self.I * self.I, r=self.radius) <NEW_LINE> corrIp = box_filter(I=self.I * p, r=self.radius) <NEW_LINE> varI = corrI - meanI * meanI <NEW_LINE> covIp...
Parameters ---------- p: NDArray Filtering input of 2D Returns ------- q: NDArray Filtering output of 2D
625941e84e4d5625662d486b
def eqNodes(N, a=0, b=1, extrIncl=True): <NEW_LINE> <INDENT> if extrIncl: <NEW_LINE> <INDENT> return np.linspace(a,b,N) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> out = np.linspace(a,b,N+2) <NEW_LINE> return list(np.array_split(out,[1,len(out)-1])[1])
return a list of N equispaced nodes in [a,b]. If extrIncl is True, a,b are included, otherwise not.
625941e863f4b57ef00015a5
def diff_by_dir(dir_path1, dir_path2, dcmp=None, column_size=80): <NEW_LINE> <INDENT> if dcmp is None: <NEW_LINE> <INDENT> logcm.print_info("diff_by_dir dir1[%s] vs dir2[%s]" % (dir_path1, dir_path2)) <NEW_LINE> dcmp = dircmp(dir_path1, dir_path2) <NEW_LINE> diff_by_dir(dir_path1, dir_path2, dcmp, column_size) <NEW_LIN...
比较两个目录。 @param dir_path1: 文件目录1 @param dir_path2: 文件目录2 @param dcmp: 目录比较结果对象,为空则执行首层目录比较 @param column_size: 打印列宽度,用于补空对齐 @return: None
625941e8b545ff76a89142af
def drawColorScale(palet,minval,maxval,medval,maxexp,minexp,ncolors,dec,scale,ngrid,linewidth,nlabel,lefttext,font,x,y,w,h): <NEW_LINE> <INDENT> CS = ColorScale(palet,minval,maxval,midval=medval,exp=maxexp,exp2=minexp) <NEW_LINE> CL = ColorLegend(CS,ncolors) <NEW_LINE> CLA = decors.ColorLegend(CL,x,y,w,h,ngrid=ngrid,li...
Draw a color scale with the specified parameters
625941e8cdde0d52a9e534d0
def __init__(self, ControlArea=None, *args, **kw_args): <NEW_LINE> <INDENT> self._ControlArea = None <NEW_LINE> self.ControlArea = ControlArea <NEW_LINE> super(EnergyArea, self).__init__(*args, **kw_args)
Initialises a new 'EnergyArea' instance. @param ControlArea: The control area specification that is used for the load forecast.
625941e83c8af77a43ae3c3f
def refresh(self): <NEW_LINE> <INDENT> self.__init__(self.url, token=self.token)
Refreshes the service properties.
625941e8aad79263cf390ee1
def test_EmptyArrays(self): <NEW_LINE> <INDENT> source = Vt.IntArray([1,2,3]) <NEW_LINE> target = Vt.IntArray([4,5,6]) <NEW_LINE> mapper = MakeMapper("ABC", "") <NEW_LINE> assert not mapper.IsIdentity() <NEW_LINE> assert mapper.IsNull() <NEW_LINE> self.assertEqual(mapper.Remap(source), Vt.IntArray()) <NEW_LINE> self.as...
Test mapping when either the source or dest order is empty.
625941e897e22403b379d435
def get(self): <NEW_LINE> <INDENT> args = self.reqparse.parse_args() <NEW_LINE> parts = args['Authorization'].split() <NEW_LINE> info = DBHelper.get_info(parts[1]) <NEW_LINE> if info: <NEW_LINE> <INDENT> return info <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise CustomError('Invalid ext_id', status_code=400)
get a specific user's information :return: Json
625941e8baa26c4b54cb15b4
def singleNumber(self, nums): <NEW_LINE> <INDENT> result = 0 <NEW_LINE> negatives = 0 <NEW_LINE> for i in range(32): <NEW_LINE> <INDENT> mask = 1<<i <NEW_LINE> temp = 0 <NEW_LINE> for num in nums: <NEW_LINE> <INDENT> if num<0: <NEW_LINE> <INDENT> negatives += 1 <NEW_LINE> num = -num <NEW_LINE> <DEDENT> temp += 1 if num...
:type nums: List[int] :rtype: int
625941e87cff6e4e81117e1f
def get_printer_handler(self): <NEW_LINE> <INDENT> return self.printer_handler
Retrieves the printer handler. :rtype: Tuple :return: The printer handler.
625941e88c3a87329515885a
def add_class(self, *args): <NEW_LINE> <INDENT> return _sphinxbase.NGramModel_add_class(self, *args)
add_class(NGramModel self, char const * c, float32 w, size_t n, float32 const * weights) -> int32
625941e89f2886367277ad23
def mark_fixture(*register_uri_args, **register_uri_kwargs): <NEW_LINE> <INDENT> def mark_fixture_decorator(fn): <NEW_LINE> <INDENT> return mark_fixture_function(fn, *register_uri_args, **register_uri_kwargs) <NEW_LINE> <DEDENT> return mark_fixture_decorator
Decorator wrapper for `mark_fixture_function` :param *args register_uri_args: Arguments to pass through to `httpretty.register_uri` :param **kwargs register_uri_kwargs: Keyword arguments to pass through to `httpretty.register_uri`
625941e8fbf16365ca6f6667
def identify_task_type(task_data): <NEW_LINE> <INDENT> if 'choice' in task_data: <NEW_LINE> <INDENT> return 'survey_task' <NEW_LINE> <DEDENT> elif 'value' in task_data: <NEW_LINE> <INDENT> values = task_data['value'] <NEW_LINE> if isinstance(values, list): <NEW_LINE> <INDENT> if any(['choice' in x for x in values]): <N...
Identify task type - survey or question task
625941e826238365f5f0f30e
def readConfig(config): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> tokenConfig = configparser.ConfigParser() <NEW_LINE> tokenConfig.read(config) <NEW_LINE> token = tokenConfig["github"]["token"] <NEW_LINE> username = tokenConfig["github"]["username"] <NEW_LINE> return token, username <NEW_LINE> <DEDENT> except KeyErr...
This function reads auth configuration file and returns token and username. :param string config: Path of the auth configuration file. :return: Pair of strings with token and username.
625941e8091ae356686673f0
def restore_ceph_config(self, after_storage_enabled=False): <NEW_LINE> <INDENT> if not self.ceph_manager_sees_cluster_up(): <NEW_LINE> <INDENT> LOG.info('Aborting crushmap restore.The cluster has yet to be ' 'recognized as operational.') <NEW_LINE> return False <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> backup = os.p...
Restore Ceph configuration during Backup and Restore process. :returns: return True if restore is successful or no need to restore
625941e8d6c5a102081444e8
def vdf(self, r): <NEW_LINE> <INDENT> volume = 4/3. * sp.pi * r**3 <NEW_LINE> return volume * self.__call__(r, der=0)
Evaluate the spline and scale by volume
625941e83317a56b8693a0e7
def call(self, inputs, training=None, mask=None): <NEW_LINE> <INDENT> route_1 = self.backbone_model1(inputs) <NEW_LINE> route_2 = self.backbone_model2(route_1) <NEW_LINE> route_3 = self.backbone_model3(route_2) <NEW_LINE> """需要主义的是,这里 smaller_bbox 是小物体在大分辨率下小物体的预测框,而不是小分辨率下的检测结果""" <NEW_LINE> smaller_bbox, medium_bbox,...
前向传播
625941e8a934411ee3751b2e
def isHappy(self, n): <NEW_LINE> <INDENT> def digit_sqart(num): <NEW_LINE> <INDENT> sum = 0 <NEW_LINE> while num: <NEW_LINE> <INDENT> val = num % 10 <NEW_LINE> sum += val * val <NEW_LINE> num /= 10 <NEW_LINE> <DEDENT> return sum <NEW_LINE> <DEDENT> slow = digit_sqart(n) <NEW_LINE> fast = digit_sqart(n) <NEW_LINE> fast ...
:type n: int :rtype: bool
625941e8d8ef3951e32439d7
def check_guess(title, remaining_titles): <NEW_LINE> <INDENT> if title in remaining_titles: <NEW_LINE> <INDENT> print_box(["{} ({}) is Correct!".format(remaining_titles[title][2],remaining_titles[title][0])],'-') <NEW_LINE> remaining_titles.pop(title) <NEW_LINE> return True <NEW_LINE> <DEDENT> for correct_title in rema...
checks if guessed title is in actor's known for films, returns bool Parameters ---------- title : string input guessed title to be compared to those in remaining_titles. remaining_titles : set set of strings of actors remaining ungessed known4 titles. Returns ------- bool true if title found in remaining ...
625941e87b25080760e398f0
def getRtLMLgradDataTerm(self): <NEW_LINE> <INDENT> return _core.CGPkronSum_getRtLMLgradDataTerm(self)
getRtLMLgradDataTerm(CGPkronSum self) -> limix::mfloat_t Parameters: self: limix::CGPkronSum *
625941e8435de62698dfe0e7
def determine_db_dir(): <NEW_LINE> <INDENT> if platform.system() == "Darwin": <NEW_LINE> <INDENT> return os.path.expanduser("~/Library/Application Support/EACoinCore/") <NEW_LINE> <DEDENT> elif platform.system() == "Windows": <NEW_LINE> <INDENT> return os.path.join(os.environ['APPDATA'], "EACoinCore") <NEW_LINE> <DEDEN...
Return the default location of the EACoin Core data directory
625941e80c0af96317bb8681
def getMonthIndex(my_str): <NEW_LINE> <INDENT> my_str = my_str.upper() <NEW_LINE> mon_list = ['JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY', 'JUNE', 'JULY', 'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 'DECEMBER'] <NEW_LINE> if my_str in mon_list: <NEW_LINE> <INDENT> return [mon_list.index(my_str) + 1] <NEW_LINE> <DE...
Given a string representing a month or a season (common abrev) Returns the ordered indices of the month. Author: Krishna Achutarao Date: April 2001 :param my_str: string reperesenting month or season :type my_str: str :returns: The ordered indices of the month :rtype: list
625941e87d847024c06be75a
def answer_by_ean(db, ean, flds): <NEW_LINE> <INDENT> if ean[:3] == '977': <NEW_LINE> <INDENT> return db(db.answer.ean.startswith(ean[:10])).select(*flds).first() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return db(db.answer.ean == ean).select(*flds).first()
return: row or None
625941e876d4e153a657efcc
def set_value(self, val): <NEW_LINE> <INDENT> self.values.append(val) <NEW_LINE> self.times.append(time.time()) <NEW_LINE> self.mi.set_value(self.eid, val)
Set Value for devices, record time and value
625941e84527f215b584c8ec
def parse_pair(self): <NEW_LINE> <INDENT> name = self.consume(ID).text <NEW_LINE> self.consume(EQUAL) <NEW_LINE> value = self.parse_value() <NEW_LINE> return name, value
Parse a `name = value` pair.
625941e810dbd63aa1bd303c
def request(self, request, has_response=True): <NEW_LINE> <INDENT> future = None <NEW_LINE> if has_response: <NEW_LINE> <INDENT> future = ResponseFuture(self.handler) <NEW_LINE> <DEDENT> task = self.Task(request, future) <NEW_LINE> self._requests.put(task) <NEW_LINE> return future
Construct a new request :type request: :class:`pykafka.protocol.Request` :param has_response: Whether this request will return a response :returns: :class:`pykafka.handlers.ResponseFuture`
625941e8167d2b6e3121902f
def rerun_filters(filters=None, do_update=True, datapush_id=None): <NEW_LINE> <INDENT> with MatchEngine( plugin_dir='./filters_config/plugins', protocol_nos=filters, match_on_closed=False, config='./filters_config/filters_config.json', db_name=settings.MONGO_DBNAME, match_document_creator_class="DFCIFilterMatchDocument...
Update all filters, or individual filters accepted as an array of ids :param filters: Array of filter IDs or None to run all filters :param do_update: When finding matches for temporary filters do not update db :param datapush_id: When all filters are rerun as part of the oncopanel datapush, flag new matches as 'new' a...
625941e8fb3f5b602dac3b32
def anim10(svg): <NEW_LINE> <INDENT> H, W = svg.get_size() <NEW_LINE> cx, cy = W // 2, H // 2 <NEW_LINE> g = svg.draw(draw_tag('g')) <NEW_LINE> svg.set_node(g, 'opacity', '1.0') <NEW_LINE> wall_line = [2, -1.8, 1] <NEW_LINE> pts = draw_line_param_abc(wall_line, 0, W, 0, H) <NEW_LINE> drawlinePoints(svg, pts, g, color='...
moving ball bounce with a line
625941e9046cf37aa974d1dd
def get_form(self, form_class): <NEW_LINE> <INDENT> if form_class: <NEW_LINE> <INDENT> return form_class(**self.get_form_kwargs()) <NEW_LINE> <DEDENT> return None
Returns an instance of the form to be used in this view.
625941e92ae34c7f2600d5ca
def grab_remove_next_unit_ids(rcv_text) -> (str, list): <NEW_LINE> <INDENT> regex = data_groups['unit_id_group'] <NEW_LINE> resultblock = regex.search(rcv_text).group(0) <NEW_LINE> result_list = str(resultblock).splitlines(keepends=False) <NEW_LINE> result_list = [result for result in result_list if result is not ""] <...
grabs the first set of unit IDs that can be found on the arg 'text' and then removes it from the text ie. grabs : ---------- COMP1000 COMP2000 ISAD3000 ---------- as a single block and then splits it to lines :param rcv_text: the report text from which the unit IDs are to be fetched :return str: the modified report te...
625941e8f8510a7c17cf9b99
def format_table_central_analysis(table,tags): <NEW_LINE> <INDENT> table = separate_table(table, tags[2]) <NEW_LINE> keys = separate_line(table[1], tags[3])[1:] <NEW_LINE> keys.insert(0, table[0].split(tags[3])[1].strip()) <NEW_LINE> value = separate_multi_line(table[2]) <NEW_LINE> tmp = [keys] <NEW_LINE> for y in valu...
Get the data from the ring analysis table
625941e9d18da76e23532976
def test_research_research_id_put(self): <NEW_LINE> <INDENT> pass
Test case for research_research_id_put Edit Research Project details
625941e9d8ef3951e32439d8
def update_plots(self): <NEW_LINE> <INDENT> assert( self.numPlots <= len(self.dataHandler.channels) ) <NEW_LINE> for i in range(0,self.numPlots): <NEW_LINE> <INDENT> channel = self.dataHandler.channels[i] <NEW_LINE> data = list(channel.data) <NEW_LINE> num_points = len(data) <NEW_LINE> axes = self.axes[i] <NEW_LINE> ax...
For live-updating of plots
625941e932920d7e50b2866e
@receiver(post_save, sender=CourseEnrollment, dispatch_uid='create_schedule_for_enrollment') <NEW_LINE> def create_schedule(sender, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> enrollment = kwargs.get('instance') <NEW_LINE> enrollment_created = kwargs.get('created') <NEW_LINE> schedule_details = _create_sche...
When a CourseEnrollment is created, create a Schedule if configured.
625941e9a219f33f34628dfd
def AbelTransformIntensity(self): <NEW_LINE> <INDENT> self.distribution = [] <NEW_LINE> if self.isFromImage: <NEW_LINE> <INDENT> self.abelIntensityFromImage() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.abelIntensityFromFile()
called when Intensity button is clicked
625941e982261d6c526ab941
def pline(sample='▃', style='standard'): <NEW_LINE> <INDENT> pl(sample * 43, style)
输出一条横线
625941e95510c4643540f872
@lru_cache() <NEW_LINE> def s(time): <NEW_LINE> <INDENT> return sofa.vectorized_s06(time)
CIO locator
625941e9009cb60464c63848
def test_commit(self): <NEW_LINE> <INDENT> storage = TreeRevisionStorage() <NEW_LINE> self.assertEqual(storage.revision, 1) <NEW_LINE> storage.set(PARENT, CHILD_ONE, 1) <NEW_LINE> storage.set(PARENT, CHILD_ONE, 2) <NEW_LINE> storage.set(PARENT, CHILD_ONE, 3) <NEW_LINE> self.assertEqual(storage.revision, 3) <NEW_LINE> s...
Test committing.
625941e999cbb53fe679307f
def psi_Mg_MgOH_HSO4_HMW84(T, P): <NEW_LINE> <INDENT> psi = 0.0 <NEW_LINE> valid = np.isclose(T, 298.15, **temperature_tol) <NEW_LINE> return psi, valid
c-c'-a: magnesium magnesium-hydroxide bisulfate [HMW84].
625941e945492302aab5e762
def __init__(self, init_x=0, init_y=0, bat=100, reg_data_rec=0, local_data_rec=0): <NEW_LINE> <INDENT> self.bat = bat <NEW_LINE> self.reg_data_rec = reg_data_rec <NEW_LINE> self.local_data_rec = local_data_rec <NEW_LINE> self.visited = 0 <NEW_LINE> self.loc = [init_x, init_y] <NEW_LINE> self.detection_radius = 1
Create a vehicle which navigates out grid world :param bat: percentage of battery for the UAV :param reg_data_rec: data recorded within the entire region :param local_data_rec: data recorded within a local cell
625941e9a8ecb033257d3565
def render_vis(model, objective_f, param_f=None, optimizer=None, transforms=None, thresholds=(512,), print_objectives=None, verbose=True, relu_gradient_override=True, use_fixed_seed=False): <NEW_LINE> <INDENT> with tf.Graph().as_default() as graph, tf.Session() as sess: <NEW_LINE> <INDENT> if use_fixed_seed: <NEW_LINE>...
Flexible optimization-base feature vis. There's a lot of ways one might wish to customize otpimization-based feature visualization. It's hard to create an abstraction that stands up to all the things one might wish to try. This function probably can't do *everything* you want, but it's much more flexible than a naive...
625941e9a8ecb033257d3566
def clean(self): <NEW_LINE> <INDENT> super().clean() <NEW_LINE> overlaped_fields = [] <NEW_LINE> if self.kw.get('meta_change_fields'): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if self.kw.get('meta_overlap_fields'): <NEW_LINE> <INDENT> if self.kw.get('meta_overlap_fields') =='__all__': <NEW_LINE> <INDENT> return <...
数据过期检查 overlaped_fields 用于排除掉不需要检查的字段。 meta_key_fields 用于设定只检查哪些字段 meta_change_fields 在__init__函数中,不在meta_change_fields中的字段会被还原,只剩下变化的,所以这里不需要检测了。
625941e9c4546d3d9de72ed2
def get_filepaths(directory): <NEW_LINE> <INDENT> file_paths = [] <NEW_LINE> for root, _, files in os.walk(directory): <NEW_LINE> <INDENT> for filename in files: <NEW_LINE> <INDENT> filepath = os.path.join(root, filename) <NEW_LINE> rel_path = os.path.relpath(filepath, directory) <NEW_LINE> file_paths.append(rel_path) ...
This function will generate the file names in a directory tree by walking the tree either top-down or bottom-up. For each directory in the tree rooted at directory top (including top itself), it yields a 3-tuple (dirpath, dirnames, filenames).
625941e94e696a04525c98e8
def find_cacheinfo(dirs): <NEW_LINE> <INDENT> viceetcdir = dirs.get('viceetcdir') <NEW_LINE> if not viceetcdir: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> ci = os.path.join(viceetcdir, 'cacheinfo') <NEW_LINE> if not os.path.exists(ci): <NEW_LINE> <INDENT> log.warning('cacheinfo file not found: %s', ci) <NEW_LI...
Find the cache manager configuration parameters.
625941e9eab8aa0e5d26dff4
def parse(self, stream, media_type=None, parser_context=None): <NEW_LINE> <INDENT> parser_context = parser_context or {} <NEW_LINE> encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET) <NEW_LINE> try: <NEW_LINE> <INDENT> data = stream.read().decode(encoding) <NEW_LINE> return json.loads(data, object_pair...
Parses the incoming bytestream as JSON and returns the resulting data.
625941e96fece00bbac2dbdf
def gradient_nD(stack): <NEW_LINE> <INDENT> stack = np.copy(stack) <NEW_LINE> stack = stack.astype(np.float64) <NEW_LINE> sumsq = ndi.filters.sobel(stack, axis=0) ** 2 <NEW_LINE> for d in range(1, stack.ndim): <NEW_LINE> <INDENT> sumsq = sumsq + (ndi.filters.sobel(stack, axis=d) ** 2) <NEW_LINE> <DEDENT> gradient = np....
Find the gradient of an n-dimensional image. Approximates an nD (typically: 3D) gradient by applying a gradient filter separately on each axis and taking the root of the sum of their squares. Args: stack: ndarray Image stack in [z, x, y] or [x, y] Returns: gradient: ndarray Gradient t...
625941e9ad47b63b2c50a419
def add_user(self, name, email, books=None): <NEW_LINE> <INDENT> user = self.users.get(email) <NEW_LINE> if user: <NEW_LINE> <INDENT> print("{email} address already exists for user {name}. Please use a different email address.".format(email=email, name=user.get_name())) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> se...
Adds user
625941e9c432627299f050e4
def help(self, command:str=None): <NEW_LINE> <INDENT> if not command: <NEW_LINE> <INDENT> max_length = max([len(command[0].__name__ + " " + command[1]) for command in self.commands]) <NEW_LINE> for command in self.commands: <NEW_LINE> <INDENT> name = command[0].__name__ <NEW_LINE> signature = name + " " + command[1] <...
Display this message
625941e907d97122c4178d31
def set_source_subsystem(self, source_subsystem: str): <NEW_LINE> <INDENT> self.source_subsystem = source_subsystem
Set source subsystem.
625941e971ff763f4b549b2e
def flatten(items, symbols=None, level=0, split_strings_on=None, as_string=False): <NEW_LINE> <INDENT> if symbols is None: <NEW_LINE> <INDENT> symbols = {} <NEW_LINE> <DEDENT> for item in items: <NEW_LINE> <INDENT> if item is not None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> test_string = item + '' <NEW_LINE> if s...
Flatten and yield level/item pairs from a potentially nested list. If split_strings_on is specified splits all strings on it. If vars has dictionary entries, formats all strings with it. If as_string is True converts items to strings.
625941e924f1403a92600ffd