code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def to_dict(self): <NEW_LINE> <INDENT> return HalPlan(data={ 'id': self.id, 'name': self.name, 'created': self.created.strftime('%Y-%m-%dT%H:%M:%s'), 'executors_count': self.executors_count, 'next_execution': self.next_execution, 'executed': self.executed }).to_dict() | Returns a :meth:`chaosmonkey.api.hal.document` representation for the Executor
:return: :meth:`chaosmonkey.dal.plan_model.HalPlan` | 625941c6d8ef3951e324356d |
def __init__(self, style='wxTAB_TRAVERSAL'): <NEW_LINE> <INDENT> self._logger = logging.getLogger(self.__class__.__name__) <NEW_LINE> EditStylesMixin.__init__(self, 'wxPanel') <NEW_LINE> self.top_sizer = None <NEW_LINE> self.no_custom_class = np.CheckBoxProperty(False, default_value=False) <NEW_LINE> self.scrollable ... | Class to handle wxPanel objects | 625941c6eab8aa0e5d26db88 |
def test_dict_output_77(self): <NEW_LINE> <INDENT> result = '77' <NEW_LINE> assert self.get_dict_output(result) == int(result) | make sure correct value is returned | 625941c6baa26c4b54cb1150 |
def format_ein(ein): <NEW_LINE> <INDENT> formatted_ein = ein[:2] + '-' + ein[2:] <NEW_LINE> return formatted_ein | Convert an unformatted EIN number (in string format) to the hyphenated format.
e.g.
Input: 751107227
Output: 75-1107227 | 625941c6498bea3a759b9adf |
def _print_format_variables(self, tw, code_lines): <NEW_LINE> <INDENT> def read_formatted_vars(lines): <NEW_LINE> <INDENT> formatted_var_regex = "(?P<format_var>{.*?})" <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> for match in re.finditer(formatted_var_regex, line): <NEW_LINE> <INDENT> yield match.group("format_va... | Print a list of the format variables and their value at this stage
If the format variable is not defined, print it in red as '???'
Args:
tw (TerminalWriter): Pytest TW instance
code_lines (list(str)): Source lines for this stage
Returns:
list(str): List of all missing format variables | 625941c6d6c5a1020814407a |
@cli.command( name="context", ) <NEW_LINE> @pass_config <NEW_LINE> def use_remote_context(client: RemoteDockerClient): <NEW_LINE> <INDENT> client.use_remote_context() | Creates and switches to the remote-docker context | 625941c6adb09d7d5db6c7c0 |
def __init__(self, a, regionResults=None): <NEW_LINE> <INDENT> self.area = a <NEW_LINE> if regionResults==None: <NEW_LINE> <INDENT> regionResults = eResults <NEW_LINE> <DEDENT> self._accumulateRegions(regionResults) | @param a [Aggregation]
@param regionResults [dict of str:EResult] to get regional
results from. For aggregates of 2009 results, this will be
our global variable (eResults) which is what it defaults to. | 625941c692d797404e3041ba |
@templatekeyword("activebookmark") <NEW_LINE> def showactivebookmark(**args): <NEW_LINE> <INDENT> active = args[r"repo"]._activebookmark <NEW_LINE> if active and active in args[r"ctx"].bookmarks(): <NEW_LINE> <INDENT> return active <NEW_LINE> <DEDENT> return "" | String. The active bookmark, if it is associated with the changeset. | 625941c6b5575c28eb68e02f |
def delete_resources(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> rescs = self.status(RSC) <NEW_LINE> rescs = [r['id'] for r in rescs] <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> rescs = [] <NEW_LINE> <DEDENT> if len(rescs) > 0: <NEW_LINE> <INDENT> self.manager(MGR_CMD_DELETE, RSC, id=rescs) | Delete all resources | 625941c6283ffb24f3c55932 |
def spoencode(self, val): <NEW_LINE> <INDENT> if val is None: <NEW_LINE> <INDENT> return '*' <NEW_LINE> <DEDENT> elif "'" in val: <NEW_LINE> <INDENT> return val <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return '<%s>' % (val,) | Encode search terms for an SPO query.
:param val: string to be encoded
:rtype: string | 625941c6f548e778e58cd5ad |
def convert(self, s, numRows): <NEW_LINE> <INDENT> if s is None or numRows < 2 or len(s) <= numRows: <NEW_LINE> <INDENT> return s <NEW_LINE> <DEDENT> per = ["" for x in range(numRows)] <NEW_LINE> init = 0 <NEW_LINE> direct = 1 <NEW_LINE> for i in range(len(s)): <NEW_LINE> <INDENT> per[init] += s[i] <NEW_LINE> init += d... | :type s: str
:type numRows: int
:rtype: str | 625941c6b57a9660fec338b3 |
@pytest.fixture(scope="function") <NEW_LINE> def atac_pipe_name(): <NEW_LINE> <INDENT> return "ATACSeq.py" | Oft-used as filename for pipeline module and PipelineInterface key. | 625941c6d4950a0f3b08c380 |
def __init__(self, attribute): <NEW_LINE> <INDENT> self.attribute = attribute | Initialize the attribute detector with the attribute to detect | 625941c65f7d997b87174ac7 |
def next_boards_connectfour(board) : <NEW_LINE> <INDENT> answer = [] <NEW_LINE> if is_game_over_connectfour(board): <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> for i in range(board.num_cols): <NEW_LINE> <INDENT> if board.is_column_full(i): <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT>... | Returns a list of ConnectFourBoard objects that could result from the
next move, or an empty list if no moves can be made. | 625941c6fbf16365ca6f61f2 |
def get(self): <NEW_LINE> <INDENT> code = self.get_argument('code', '000001') <NEW_LINE> market = self.get_argument('market', MARKET_TYPE.STOCK_CN) <NEW_LINE> end = self.get_argument('end', str(datetime.date.today)) <NEW_LINE> gap = self.get_argument('gap', 50) <NEW_LINE> frequence = self.get_argument('frequence', FREQ... | [summary]
/fetcher
http://localhost:8010/marketdata/fetcher?code=RB1905&market=future_cn&end=2018-12-01&gap=20&frequence=15min
http://localhost:8010/marketdata/fetcher?code=000001&market=stock_cn&end=2018-12-01&gap=20&frequence=15min
http://localhost:8010/marketdata/fetcher?code=000001,000002&market=stock_cn&end=201... | 625941c6baa26c4b54cb1151 |
def canMouseWin(self, grid: List[str], catJump: int, mouseJump: int) -> bool: <NEW_LINE> <INDENT> MOUSE, CAT = 0, 1 <NEW_LINE> ROWS, COLS = len(grid), len(grid[0]) <NEW_LINE> POSITION = {} <NEW_LINE> for row in range(ROWS): <NEW_LINE> <INDENT> for col in range(COLS): <NEW_LINE> <INDENT> if grid[row][col] in ['M', 'C', ... | Alex Wice copied Lerry's Solution | 625941c6377c676e912721d9 |
@then('the following scenarios are selected with cmdline') <NEW_LINE> def step_then_scenarios_are_selected_with_cmdline(context): <NEW_LINE> <INDENT> assert context.beehive_model, "REQUIRE: context attribute" <NEW_LINE> assert context.table, "REQUIRE: context.table" <NEW_LINE> context.table.require_columns(["cmdline", ... | .. code-block:: Gherkin
Then the following scenarios are selected with cmdline:
| cmdline | selected? | Logic comment |
| --tags=@foo | A1, A3, B2 | @foo | | 625941c63eb6a72ae02ec50a |
def align_ladder_peaks_xxx( ladders, peaks, indels_penalty = (0,0) ): <NEW_LINE> <INDENT> ladders = reversed( sorted(ladders) ) <NEW_LINE> peaks = reversed( sorted( peaks, key = lambda x: x.peak ) ) <NEW_LINE> norm_ladders = [ (x/ladders[0], x) for x in ladders ] <NEW_LINE> norm_peaks = [ (x.peak/peaks[0].peak, x) for ... | align ladders & peaks
return: [ (ladder_size, peak), ... ] | 625941c6498bea3a759b9ae0 |
@nox.session(python=PYTHON_VERSIONS) <NEW_LINE> def unit(session): <NEW_LINE> <INDENT> install_myself(session) <NEW_LINE> session.install(*REQUIREMENTS_TEST) <NEW_LINE> args = ['--cov=b2sdk', '--cov-branch', '--cov-report=xml', '--doctest-modules'] <NEW_LINE> session.run('pytest', '--api=v1', *args, *session.posargs, '... | Run unit tests. | 625941c655399d3f055886e4 |
def _on_resized(self, event): <NEW_LINE> <INDENT> if self._is_shown: <NEW_LINE> <INDENT> self._update_geometries() | The event handler for the EVT_SIZE event.
This triggers a geometry update for the decendant children. | 625941c6956e5f7376d70e9e |
def calculate_checksum(self, cs_type): <NEW_LINE> <INDENT> return types.calculate_checksum(self._value, cs_type) | returns the checksum for the data of this Value-object
*cs_type* is the checksum mechanism (e.g. 'crc32' or 'md5') | 625941c6d486a94d0b98e176 |
def build_allele_assignments(self, qtl_file, num_alleles=None): <NEW_LINE> <INDENT> num_alleles = num_alleles if num_alleles else self.len <NEW_LINE> allele_assigns = {} <NEW_LINE> for r in self._file_iter(qtl_file): <NEW_LINE> <INDENT> id,l = r[0],r[1:(num_alleles * 2) + 1] <NEW_LINE> allele_assigns[id] = [(l[i],l[i +... | Method that builds assignment of allele assignments to individuals
in the provided pedigree. See constructor for parameter descriptions.
Returns
-------
allele_assigns : {literal: [(literal,literal)]}
Dictionary that maps IDs of individuals in pedigree to their allele
assignments. Loci are represented as 2-tup... | 625941c6d268445f265b4e9f |
def test_pluralize(self): <NEW_LINE> <INDENT> self.assertEqual(util.pluralize('family'), 'families') <NEW_LINE> self.assertEqual(util.pluralize('stud'), 'studs') | Confirm converting singulars into plurals | 625941c6aad79263cf390a70 |
def extract(self, butler, data, **kwargs): <NEW_LINE> <INDENT> self.safe_update(**kwargs) <NEW_LINE> if butler is not None: <NEW_LINE> <INDENT> self.log.warn("Ignoring butler") <NEW_LINE> <DEDENT> hdu_out = merge_fp(data, self) <NEW_LINE> output_file = self.tablefile_name() + '.fits' <NEW_LINE> makedir_safe(output_file... | Make a camera level mosaic
Parameters
----------
butler : `Butler`
The data butler
data : `dict`
Dictionary (or other structure) contain the input data
kwargs
Used to override default configuration
Returns
-------
dtables : `TableDict`
The resulting data | 625941c6046cf37aa974cd79 |
def __str__(self): <NEW_LINE> <INDENT> return "{result}: {response_message}" .format( result=self._result, response_message=self.response_message) | Represents the SendResponse as a str.
:return the string
:rtype str | 625941c68a43f66fc4b54097 |
def _get_config(self, file_path, default_vals, over_vals, file_tobe_created): <NEW_LINE> <INDENT> config_parser = SafeConfigParser(default_vals) <NEW_LINE> if not file_tobe_created: <NEW_LINE> <INDENT> config_parser.read(file_path) <NEW_LINE> <DEDENT> for p in over_vals: <NEW_LINE> <INDENT> config_parser.set('DEFAULT',... | - open existing config
- overwrite default dict with overriding values | 625941c67c178a314d6ef48e |
def __init__(self, idc=None, idcName=None, deviceId=None, deviceNo=None, snNo=None, cabinetNo=None, rackUIndex=None, uNum=None, brand=None, model=None, deviceType=None, assetBelong=None, assetStatus=None, deviceOpenTime=None): <NEW_LINE> <INDENT> self.idc = idc <NEW_LINE> self.idcName = idcName <NEW_LINE> self.deviceId... | :param idc: (Optional) 机房英文标识
:param idcName: (Optional) 机房名称
:param deviceId: (Optional) 设备Id
:param deviceNo: (Optional) 设备编码
:param snNo: (Optional) 设备SN号
:param cabinetNo: (Optional) 机柜编码
:param rackUIndex: (Optional) 所在U位
:param uNum: (Optional) U数(U)
:param brand: (Optional) 品牌
:param model: (Optional) 型号
:param ... | 625941c671ff763f4b5496ba |
def test_train_with_one_dim_labels_and_weights(self): <NEW_LINE> <INDENT> head = head_lib._binary_logistic_head_with_sigmoid_cross_entropy_loss( weight_column='label_weights') <NEW_LINE> logits = np.array(((45,), (-41,), (44,)), dtype=np.float32) <NEW_LINE> labels_rank_1 = np.array((1., 1., 0.,)) <NEW_LINE> weights_ran... | 3 examples, 1 batch. | 625941c68a349b6b435e81a4 |
def get_reduced_chi_squareds(self, p=None): <NEW_LINE> <INDENT> if len(self._xdatas_given)==0 or len(self._ydatas_given)==0: return None <NEW_LINE> r = self.get_studentized_residuals(p) <NEW_LINE> if r is None: return <NEW_LINE> N = 0 <NEW_LINE> for i in range(len(r)): N += len(r[i]) <NEW_LINE> dof_per_point = self.get... | Returns the reduced chi squared for each processed data set.
p=None means use the fit results (if defined) then guess values. | 625941c632920d7e50b28200 |
def get_skill_by_stat(self, stat_name): <NEW_LINE> <INDENT> logger.debug(f'Getting skills: {stat_name}') <NEW_LINE> if stat_name == 'all': <NEW_LINE> <INDENT> skills = [] <NEW_LINE> for s in self.stats: <NEW_LINE> <INDENT> skills.append(s.skills) <NEW_LINE> <DEDENT> return skills <NEW_LINE> <DEDENT> elif self.get_stat_... | Gets a list of all skills from given stat
@param stat_name: String name of stat or all if you want all skills
@return:List | 625941c68c3a8732951583ea |
def charge(self, price): <NEW_LINE> <INDENT> if price + self._balance > self._limit: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._set_balance(self._balance+price) <NEW_LINE> return True | Charge given price to the card, assuming sufficient credit limit.
Return True if charge was processed, False if denied. | 625941c699fddb7c1c9de3c2 |
def factor_number(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return self.__factor_number <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDENT> self.__factor_number = self.__f.number() <NEW_LINE> return self.__factor_number | Return factor number.
OUTPUT:
int
EXAMPLES::
sage: from sage_modabvar import AbelianVariety
sage: A = AbelianVariety('43b')
sage: A.factor_number()
1 | 625941c621a7993f00bc7d1e |
def trace(value=None): <NEW_LINE> <INDENT> if value is not None: <NEW_LINE> <INDENT> self._default_env._trace = value <NEW_LINE> <DEDENT> return _default_env._trace | trace status of the default environment
Parameters
----------
value : bool
new trace status |n|
if omitted, no change
Returns
-------
trace status : bool
Note
----
If you want to test the status, always include parentheses, like |n|
if sim.trace(): | 625941c6046cf37aa974cd7a |
def main(): <NEW_LINE> <INDENT> streamer = managers.StreamThread("Streamer", STREAM_HANDLER, ACCOUNT_HANDLER, url, functions.reply_with_shortened_url) <NEW_LINE> account_manager = managers.AccountThread(ACCOUNT_HANDLER, UPLOAD_HANDLER, url, args.rate, args.fav, args.retweet, args.follow, args.follow_limit, args.scrape)... | Main function to handle different activites of the account. | 625941c6be8e80087fb20c75 |
def __init__(self, **services: typing.Any) -> None: <NEW_LINE> <INDENT> super().__init__( "strip_license_files", help_string="Strip away license files.", file=__file__, **services ) | Constructor. | 625941c63539df3088e2e37b |
def __init__(self, rolling_update=None, type=None, local_vars_configuration=None): <NEW_LINE> <INDENT> if local_vars_configuration is None: <NEW_LINE> <INDENT> local_vars_configuration = Configuration() <NEW_LINE> <DEDENT> self.local_vars_configuration = local_vars_configuration <NEW_LINE> self._rolling_update = None <... | V1beta2StatefulSetUpdateStrategy - a model defined in OpenAPI | 625941c60a366e3fb873e84a |
def test_instance_extra(self): <NEW_LINE> <INDENT> ret_str = self.run_cloud( "-p gce-test-extra {}".format(self.instance_name), timeout=TIMEOUT ) <NEW_LINE> self.assertInstanceExists(ret_str) <NEW_LINE> self.assertDestroyInstance() | Tests creating and deleting an instance on GCE | 625941c62eb69b55b151c8de |
def __init__(self,movie_title,movie_storyline,poster_image,trailer_youtube): <NEW_LINE> <INDENT> self.title = movie_title <NEW_LINE> self.storyline = movie_storyline <NEW_LINE> self.poster_image_url = poster_image <NEW_LINE> self.trailer_youtube_url = trailer_youtube | This docstring explains the constructor method, it's inputs and outputs if any | 625941c6be7bc26dc91cd633 |
def delete(self, session_id): <NEW_LINE> <INDENT> self._get_connection().delete((KEY_PREFIX + 'sess') % session_id) | Delete a session
In:
- ``session_id`` -- id of the session to delete | 625941c6e8904600ed9f1f5c |
@app.route('/routes') <NEW_LINE> def get_routes(): <NEW_LINE> <INDENT> return controller.get_routes() | Returns a list of api endpoints | 625941c62c8b7c6e89b357f2 |
def _get_description(li): <NEW_LINE> <INDENT> sdiv = li.find("div", attrs={"class": "s"}) <NEW_LINE> if sdiv: <NEW_LINE> <INDENT> stspan = sdiv.find("span", attrs={"class": "st"}) <NEW_LINE> return stspan.text.encode("utf-8").strip() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None | Return the description of a google search.
TODO: There are some text encoding problems to resovle. | 625941c666656f66f7cbc1db |
def fail (self,message='',from_child=False): <NEW_LINE> <INDENT> if not self._fail_logged: <NEW_LINE> <INDENT> if not from_child or self.persist <= 0: <NEW_LINE> <INDENT> if isinstance(message,Exception): <NEW_LINE> <INDENT> message = message.__class__.__name__; <NEW_LINE> <DEDENT> self.log(message,"FAIL",level=-999999... | Reports a fail with given message, fails parent. Message can be a string,
or an exception object | 625941c65fcc89381b1e16ef |
def test_select_slide_and_show_cursor(self): <NEW_LINE> <INDENT> self.app.build_base() <NEW_LINE> l = self.app.load_slides_from_wiki(['Society is intrinsically<\/li>']) <NEW_LINE> self.assertEqual(1, len(l), "list is not as expected: %s" % l) <NEW_LINE> self.app.SLIDES[0]._select(None) <NEW_LINE> self.gui.svg.rect.asse... | Seleciona um slide e mostra o cursor | 625941c650812a4eaa59c354 |
def left(i): <NEW_LINE> <INDENT> return i * 2 + 1 | get left child index of item i | 625941c61f037a2d8b94622f |
def make_factor(self, name, substitute=False, option=None): <NEW_LINE> <INDENT> if not (substitute or option): <NEW_LINE> <INDENT> raise ValueError <NEW_LINE> <DEDENT> factor = {'factor_name': name} <NEW_LINE> if substitute: <NEW_LINE> <INDENT> factor['substitute'] = True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> f... | Given name, and type of factor make factor dict.
:param name: factor_name
:param substitute: True if template factor.
:param option: Option name
:return: factor-dict | 625941c65510c4643540f418 |
def shared_dir_on(): <NEW_LINE> <INDENT> return config.directory.shared_dir | :returns: True if a shared_dir has been set in openquake.cfg, else False | 625941c6dc8b845886cb5566 |
def optimize_rotation_center(self, guess = 0, subscale = 8, center_of_mass = True, full_search = False): <NEW_LINE> <INDENT> if center_of_mass: <NEW_LINE> <INDENT> guess = self._parent.analyse.center_of_mass()[1] - self._parent.data.shape[2] // 2 <NEW_LINE> <DEDENT> self._parent.message('Searching for the center of rot... | Find the rotation center using a subscaling factor.
Make sure that if you dont use center_of_mass or the initial guess, use subscale that is large enough. | 625941c6ff9c53063f47c225 |
def differByOne(self, dict: List[str]) -> bool: <NEW_LINE> <INDENT> seen = set() <NEW_LINE> for word in dict: <NEW_LINE> <INDENT> for i in range(len(word)): <NEW_LINE> <INDENT> pattern = word[:i] + "*" + word[i+1:] <NEW_LINE> if pattern in seen: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> seen.add(pattern) <NEW... | Brute Force:
For each string, compare it with every other string. If differ by 1, return.
Time O(n^2 * len(string))
Space O(1) | 625941c676d4e153a657eb62 |
def _get_vb_class(self, a_feats, a_toks1, a_toks2): <NEW_LINE> <INDENT> vb_classes = Counter() <NEW_LINE> vb_cls1 = vb_cls2 = None <NEW_LINE> for w1, p1 in a_toks1: <NEW_LINE> <INDENT> if w1 not in LCSI or p1 not in VB_TAGS: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> vb_cls1 = LCSI[w1] <NEW_LINE> for w2, p2 in a_... | Obtain verb classes for the given relation.
Args:
a_feats (dict):
target feature dictionary
a_toks1 (list(str)):
list of tokens from the 1-st argument
a_toks2 (list(str)):
list of tokens from the 2-nd argument
Returns:
void:
Note:
updates ``a_feats`` dictionary in place | 625941c631939e2706e4ce9d |
def ensureMinimal(minVersion, optionsRequired=False): <NEW_LINE> <INDENT> assert type(minVersion) == str <NEW_LINE> if 'wx' in sys.modules or 'wxPython' in sys.modules: <NEW_LINE> <INDENT> raise AlreadyImportedError("wxversion.ensureMinimal() must be called before wxPython is imported") <NEW_LINE> <DEDENT> bestMatch =... | Checks to see if the default version of wxPython is greater-than
or equal to `minVersion`. If not then it will try to find an
installed version that is >= minVersion. If none are available
then a message is displayed that will inform the user and will
offer to open their web browser to the wxPython downloads page,
an... | 625941c6d10714528d5ffd13 |
def propagate(w, b, X, Y): <NEW_LINE> <INDENT> m = X.shape[1] <NEW_LINE> A = None <NEW_LINE> cost = None <NEW_LINE> A= sigmoid((np.dot(w.T,X)+b)) <NEW_LINE> cost=-1/m*(np.sum((Y*(np.log(A)))+((1-Y)*(np.log(1-A))))) <NEW_LINE> dw = None <NEW_LINE> db = None <NEW_LINE> dw=1/m*(np.dot(X,(A-Y).T)) <NEW_LINE> db=1/m*(np.sum... | Implement the cost function and its gradient for the propagation explained above
Arguments:
w -- weights, a numpy array of size (num_px * num_px * 3, 1)
b -- bias, a scalar
X -- data of size (num_px * num_px * 3, number of examples)
Y -- true "label" vector (containing 0 if non-cat, 1 if cat) of size (1, number of exa... | 625941c6a8370b77170528d1 |
def read_msg(self): <NEW_LINE> <INDENT> hdr = self._read_all(self.HDR_LEN) <NEW_LINE> payload_len, signature = int(hdr[:10]), hdr[10:] <NEW_LINE> if payload_len > 2 ** 28: <NEW_LINE> <INDENT> raise IOError("Payload len too large %d" % payload_len) <NEW_LINE> <DEDENT> payload = self._read_all(payload_len) <NEW_LINE> if ... | Read the header, then the payload, validate the payload, parse
:return: The Request or Response. | 625941c6711fe17d8254239f |
def sample_metric(self, X, Y): <NEW_LINE> <INDENT> I = X.round().astype(int) - self.i0 <NEW_LINE> J = Y.round().astype(int) - self.j0 <NEW_LINE> A = self.dx[J, I] <NEW_LINE> return A, A | Sample the metric coefficients
Changes slowly, so using nearest neighbour | 625941c67b180e01f3dc4831 |
def EnableBasemapMode(self, bYesNo): <NEW_LINE> <INDENT> return super(IScreenDisplayBasemap, self).EnableBasemapMode(bYesNo) | Method IScreenDisplayBasemap.EnableBasemapMode
INPUT
bYesNo : VARIANT_BOOL | 625941c63c8af77a43ae37d1 |
def create_annotation(self, text, raw_annotatable_url, fragment, before_html=None, after_html=None, canonical_url=None, og_url=None, title=None, text_format=None): <NEW_LINE> <INDENT> msg = "Must supply `canonical_url`, `og_url`, or `title`." <NEW_LINE> assert any([canonical_url, og_url, title]), msg <NEW_LINE> endpoin... | Creates an annotation for a web page.
Requires scope: :obj:`create_annotation`.
Args:
text (:obj:`str`): Annotation text in Markdown format.
raw_annotatable_url (:obj:`str`): The original URL of the page.
fragment (:obj:`str`): The highlighted fragment (the referent).
before_html (:obj:`str`, optional... | 625941c6a8370b77170528d2 |
def open_cover(self, **kwargs): <NEW_LINE> <INDENT> self._module.open(self._channel) | Open the cover. | 625941c60fa83653e4656fed |
def remove_clicked_annotation(self,event): <NEW_LINE> <INDENT> if self.ax != event.inaxes: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> toDelete = None <NEW_LINE> annotationObjects = self.parent.getAnnotationTextObjs(self.ax) <NEW_LINE> annotationBbox = self.parent.getAnnotationBbox(self.ax) <NEW_LINE> xyE = (event.x... | Removes annotations upon click from dicts and figure
does not redraw canvas | 625941c6a79ad161976cc177 |
def arrayPairSum(self, nums): <NEW_LINE> <INDENT> s = 0 <NEW_LINE> nums.sort() <NEW_LINE> for i in xrange(0, len(nums), 2): <NEW_LINE> <INDENT> s += min(nums[i], nums[i + 1]) <NEW_LINE> <DEDENT> return s | :type nums: List[int]
:rtype: int | 625941c69c8ee82313fbb7a6 |
def link_examples_to_features(infra_node_embeddings, all_cross_link, binary_operator): <NEW_LINE> <INDENT> return [ binary_operator(infra_node_embeddings[each[0] - 1][str(each[1]+1)].reshape((128,)), infra_node_embeddings[each[3] - 1][str(each[2]+1)].reshape((128,))) for each in all_cross_link ] | binary operator on source and target nodes
start_layer = each[0]
end_layer = each[3]
start_node = each[1]+1 # 0-index --> node nummber is i+1
end_node = each[2]+1 # 0-index --> node nummber is i+1 | 625941c67d847024c06be2ec |
def lookup_manpage_section(name: str) -> int: <NEW_LINE> <INDENT> protected = "&#?!@;'- |<>" <NEW_LINE> if any(x in name for x in protected): <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> result = subprocess.run(["man", "-w", name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) <NEW_LINE> pattern = re.compile(look... | uses `man -w <name>` to look up the path of the man page,
then from that parses the path to get the section
number.
If not found, defaults to 1.
>>> lookup_manpage_section("ping")
8
>>> lookup_manpage_section("aaaaaaa")
1
>>> lookup_manpage_section("invalid")
1
>>> lookup_manpage_section("very invalid")
1
>>> lookup_m... | 625941c6187af65679ca5150 |
def do_NLP_to_stuff(jobs_df, user_input, numberofhits): <NEW_LINE> <INDENT> job_vectors = unpack_vectors(df['packed_jobvectors']) <NEW_LINE> cosine_scores = process_vector_comparison(job_vectors, user_input) <NEW_LINE> results_df = serve_user_recs(cosine_scores, jobs_df, numberofhits) <NEW_LINE> return results_df | Input:
jobs_df (dataframe): dataframe of job post data from Indeed.com in which
job descriptions already vectorized and serialized for
storage in a df column.
user_input (string): text string of user input describing a job
numberofhits (int): number of results to return
Unpacks vectors from original datafra... | 625941c682261d6c526ab4cf |
def rfp_name(self, val=None): <NEW_LINE> <INDENT> return self._textbox("#rfpName", val) | Get or set the field 'Name this RFP'. | 625941c65fc7496912cc39b0 |
def __init__(self, innerRadius=1.0, outerRadius=2.0 , epsilonR=1): <NEW_LINE> <INDENT> self.a = innerRadius <NEW_LINE> self.b = outerRadius <NEW_LINE> self.epsR = epsilonR | innerRadius: radius of the vacuum area of the cylindrical waveguide
outerRadius: radius at interface between dielectric and perfect conductor
epsilonR: relative permittivity of dielectric | 625941c61f5feb6acb0c4b83 |
def __init__(self, username, password, remember_me=False, host=None): <NEW_LINE> <INDENT> self._identifier = username <NEW_LINE> self._credentials = password <NEW_LINE> self.host = host <NEW_LINE> self.is_remember_me = remember_me <NEW_LINE> self._token_info = {'tier': 1, 'cred_type': 'password'} | :param username: the username submitted for authentication
:type username: str
:param password: the credentials submitted for authentication
:type password: bytearray or string
:param remember_me: if the user wishes their identity to be
remembered across sessions
:type remember_me: bool
:param h... | 625941c65f7d997b87174ac8 |
def get_handedness(self): <NEW_LINE> <INDENT> if self.postdict['handedness'] == 'right': <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> elif self.postdict['handedness'] == 'left': <NEW_LINE> <INDENT> return False | Return True if handedness == 'right'. | 625941c626068e7796caed0f |
def __call__(self, inputs, state, scope=None): <NEW_LINE> <INDENT> print('QRNN pooling inputs shape: ', inputs.get_shape()) <NEW_LINE> print('QRNN pooling state shape: ', state.get_shape()) <NEW_LINE> with tf.variable_scope(scope or "QRNN-fo-pooling"): <NEW_LINE> <INDENT> Z, F, O = tf.split(inputs, 3, 1) <NEW_LINE> pri... | inputs: 2-D tensor of shape [batch_size, Zfeats + [gates]] | 625941c6fff4ab517eb2f46d |
def update_comment(working_file, comment): <NEW_LINE> <INDENT> working_file = normalize_model_parameter(working_file) <NEW_LINE> return client.put( "/actions/working-files/%s/comment" % working_file['id'], {"comment": comment} ) | Update the file comment in database for given working file.
Args:
working_file (str / dict): The working file dict or ID.
Returns:
dict: Modified working file | 625941c67047854f462a143d |
def user_has_perm_thread(thread, profile): <NEW_LINE> <INDENT> user_post = CommunicationNote.objects.filter( author=profile, thread=thread) <NEW_LINE> user_cc = CommunicationThreadCC.objects.filter( user=profile, thread=thread) <NEW_LINE> if user_post.exists() or user_cc.exists(): <NEW_LINE> <INDENT> return True <NEW_L... | Check if the user has read/write permissions on the given thread.
Developers of the add-on used in the thread, users in the CC list,
and users who post to the thread are allowed to access the object.
Moreover, other object permissions are also checked against the ACLs
of the user. | 625941c62ae34c7f2600d163 |
def daily_ranges(): <NEW_LINE> <INDENT> app.logger.debug("Entering daily_ranges") <NEW_LINE> begin_date = arrow.get(flask.session['begin_date']) <NEW_LINE> end_date = arrow.get(flask.session['end_date']) <NEW_LINE> begin_time = flask.session['begin_time'] <NEW_LINE> end_time = flask.session['end_time'] <NEW_LINE> resul... | Returns a sequence of date and time ranges as a list of tuples
based on the contents of the session variables for use in determining
busy times. | 625941c68e05c05ec3eea3a5 |
def MCPWM_ConfigChannel(MCPWMx, channelNum, channelSetup): <NEW_LINE> <INDENT> return robocaller("MCPWM_ConfigChannel", "void", MCPWMx, channelNum, channelSetup) | Configures each channel in MCPWM peripheral according to the specified
parameters in the MCPWM_CHANNEL_CFG_Type.
MCPWMx: Motor Control PWM peripheral selected. Should be: LPC_MCPWM
channelNum: Channel number, should be: 0..2.
channelSetup: Pointer to a MCPWM_CHANNEL_CFG_Type structure that contains the
c... | 625941c60a366e3fb873e84b |
def __init__(self, max_size, window_length): <NEW_LINE> <INDENT> self._max_size = max_size <NEW_LINE> self._window_length = window_length <NEW_LINE> self.clear() | Set up the replay memory | 625941c6f9cc0f698b14062e |
def __init__( self, *, value: Optional[List["OperationDetail"]] = None, next_link: Optional[str] = None, **kwargs ): <NEW_LINE> <INDENT> super(AvailableOperations, self).__init__(**kwargs) <NEW_LINE> self.value = value <NEW_LINE> self.next_link = next_link | :keyword value: Collection of available operation details.
:paramtype value: list[~azure.mgmt.appplatform.v2020_07_01.models.OperationDetail]
:keyword next_link: URL client should use to fetch the next page (per server side paging).
It's null for now, added for future use.
:paramtype next_link: str | 625941c671ff763f4b5496bb |
def health_check(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.conn.ping() <NEW_LINE> <DEDENT> except redis.exceptions.ConnectionError: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True | Verifies the store health | 625941c60a50d4780f666ec3 |
def on_batch_begin(self, last_input, last_target, train, **kwargs): <NEW_LINE> <INDENT> if not train or self.beta == 0: return <NEW_LINE> I_x, I_y = last_input.size()[2:] <NEW_LINE> w = int(np.round(I_x * np.random.beta(self.beta, self.beta))) <NEW_LINE> h = int(np.round(I_y * np.random.beta(self.beta, self.beta))) <NE... | Applies ricap to `last_input` and `last_target` if `train`. | 625941c607d97122c41788bb |
def _mzt(self, mz): <NEW_LINE> <INDENT> if (not self._tolerance) and (not self._tolerance_ppm): <NEW_LINE> <INDENT> return mz <NEW_LINE> <DEDENT> elif self._tolerance: <NEW_LINE> <INDENT> t = int(mz/self._tolerance)*self._tolerance <NEW_LINE> return round(t, ceil(abs(log10(self._tolerance))) + 1) <NEW_LINE> <DEDENT> el... | Rounds mz according to tolerance or tolerance_ppm passed to finish | 625941c6a219f33f3462899d |
def test_expand_entity_ids_recursive(self): <NEW_LINE> <INDENT> self.hass.states.set('light.Bowl', STATE_ON) <NEW_LINE> self.hass.states.set('light.Ceiling', STATE_OFF) <NEW_LINE> test_group = group.Group.create_group( self.hass, 'init_group', ['light.Bowl', 'light.Ceiling', 'group.init_group'], False) <NEW_LINE> self.... | Test expand_entity_ids method with a group that contains itself. | 625941c63346ee7daa2b2d9d |
def reverse_on_array(self, coords): <NEW_LINE> <INDENT> coords = self.__inv_translate_array__(coords) <NEW_LINE> coords = self.__inv_magnify__array__(coords) <NEW_LINE> return coords | internal use: applies reverse transformation to a numpy array | 625941c68e71fb1e9831d7dc |
def clean_url(url): <NEW_LINE> <INDENT> if not url: <NEW_LINE> <INDENT> return url <NEW_LINE> <DEDENT> utm_params = set(('utm_campaign', 'utm_content', 'utm_medium', 'utm_source', 'utm_term')) <NEW_LINE> try: <NEW_LINE> <INDENT> parts = list(urlparse(url)) <NEW_LINE> <DEDENT> except (AttributeError, TypeError, ValueErr... | Removes transient query params (e.g. utm_*) from a URL.
The utm_* (Urchin Tracking Metrics?) params come from Google Analytics.
https://support.google.com/analytics/answer/1033867
The source=rss-... params are on all links in Medium's RSS feeds.
Args:
url: string
Returns:
string, the cleaned url, or None if it ... | 625941c630c21e258bdfa4ce |
def calc_size_backend(size, kernel_size, padding, stride): <NEW_LINE> <INDENT> return int(np.ceil((size - kernel_size + padding + 1) / stride)) | Calculate the size of one image dimension. | 625941c6d99f1b3c44c675c2 |
def renderText(self, x, y, str, font = QFont(), listBase = 2000): <NEW_LINE> <INDENT> pass | void QGLWidget.renderText(int x, int y, QString str, QFont font = QFont(), int listBase = 2000) | 625941c6f548e778e58cd5af |
def cleaner() -> None: <NEW_LINE> <INDENT> PyFunceble.facility.ConfigLoader.start() <NEW_LINE> colorama.init(autoreset=True) <NEW_LINE> description = ( f"{colorama.Style.BRIGHT}{colorama.Fore.GREEN}PyFunceble Cleaner" f"{colorama.Style.RESET_ALL} - " "The cleaner of PyFunceble." ) <NEW_LINE> parser = argparse.ArgumentP... | Provides the CLI for the public file generation. | 625941c6b57a9660fec338b5 |
def test_connect_with_key(self): <NEW_LINE> <INDENT> from twisted.internet import reactor <NEW_LINE> file_path = self.makeFile("content") <NEW_LINE> mock_reactor = self.mocker.patch(reactor) <NEW_LINE> mock_reactor.spawnProcess(ARGS, KWARGS) <NEW_LINE> saved = [] <NEW_LINE> self.mocker.call(lambda *args, **kwargs: save... | A private key path can optionally be specified as an argument
to connect in which case its passed to the ssh command line. | 625941c63d592f4c4ed1d0a3 |
def recv(self, timeout=None): <NEW_LINE> <INDENT> arb_id = ctypes.c_long(0) <NEW_LINE> data = ctypes.create_string_buffer(8) <NEW_LINE> dlc = ctypes.c_uint(0) <NEW_LINE> flags = ctypes.c_uint(0) <NEW_LINE> timestamp = ctypes.c_ulong(0) <NEW_LINE> if timeout is None: <NEW_LINE> <INDENT> timeout = 0xFFFFFFFF <NEW_LINE> <... | Read a message from kvaser device. | 625941c65f7d997b87174ac9 |
def blank_count(string, default=1): <NEW_LINE> <INDENT> pass | Counts the number of replacement fields in a string. | 625941c6627d3e7fe0d68e81 |
def __init__(self, OutputDir=".", TimeOut=60, CaptureScreenOnError=False) : <NEW_LINE> <INDENT> Counter.Counter.__init__(self) <NEW_LINE> self._AutoIt = win32com.client.Dispatch("AutoItX3.Control") <NEW_LINE> self._OutputDir = OutputDir <NEW_LINE> self._TimeOut = int(TimeOut) <NEW_LINE> self._CaptureScreenOnError =... | | OutputDir=<path> | Output directory for captured screenshots. Should set to _${OUTPUTDIR}_ |
| Timeout=<seconds> | Default TimeOut value in seconds. |
| | This is used in other methods when their TimeOut parameter is not used. |
| Captur... | 625941c67d43ff24873a2cd2 |
def mergesort_helper(arr: List[int], left: int, right: int) -> None: <NEW_LINE> <INDENT> if left < right: <NEW_LINE> <INDENT> mid = left + (right - left) // 2 <NEW_LINE> mergesort_helper(arr, left, mid) <NEW_LINE> mergesort_helper(arr, mid + 1, right) <NEW_LINE> merge(arr, left, mid, right) | Sort an array using mergesort, recursive helper function. | 625941c6a219f33f3462899e |
def snull_init(stot): <NEW_LINE> <INDENT> sigma = np.sqrt(stot) <NEW_LINE> return [sigma] | Compute the 'best guess' initialisation values for sigma
when fitting snull to the empirical power spectrum.
Args
--------------
stot: float
Total power in the power spectrum.
Return
-----------------
list of floats:
List containing the initialisation parameters [sigma].
| 625941c64f88993c3716c09a |
def modify_attributes(self, params): <NEW_LINE> <INDENT> self.logger.debug('Modifying %s with parameters: %s' % (self.type_name, params)) <NEW_LINE> res = self.client.modify_load_balancer_attributes(**params) <NEW_LINE> self.logger.debug('Response: %s' % res) <NEW_LINE> return res | Modify a AWS ELB classic load balancer attributes.
.. note:
See http://bit.ly/2pwMHtb for config details. | 625941c64e4d5625662d440b |
def _build_permstring(perm, model): <NEW_LINE> <INDENT> return f"{model._meta.app_label}.{perm}_{model._meta.model_name}" | Return the full permission string for a given permission and model
The perm strings follow the format <app_label>.<permission>_<model_name> | 625941c6baa26c4b54cb1153 |
def aStarSearch(problem, heuristic=nullHeuristic): <NEW_LINE> <INDENT> start = problem.getStartState() <NEW_LINE> path = [] <NEW_LINE> cost = 0 <NEW_LINE> visit = util.PriorityQueue() <NEW_LINE> visit.push((start, path, cost), 0) <NEW_LINE> visited = list() <NEW_LINE> while visit: <NEW_LINE> <INDENT> curr = visit.pop()... | Search the node that has the lowest combined cost and heuristic first. | 625941c6377c676e912721db |
def __init__(self, sta_ssid: str = "", sta_password: str = ""): <NEW_LINE> <INDENT> self.sta_handler = None <NEW_LINE> self.sta_ssid = sta_ssid <NEW_LINE> self.sta_password = sta_password <NEW_LINE> self.ap_handler = None | Constructor of WirelessConnectionController class.
:param sta_ssid: Wifi ssid.
:param sta_password: Wifi password. | 625941c6e64d504609d74872 |
def __init__(self, pubkey): <NEW_LINE> <INDENT> super(MemoryMessageRepository, self).__init__() <NEW_LINE> try: <NEW_LINE> <INDENT> int(pubkey, 16) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> raise ValueError("Encoded public key must be hexadecimal") <NEW_LINE> <DEDENT> self.pubkey = pubkey <NEW_LINE> se... | :param pubkey: Hex encoded version of the public key of this node
:type pubkey: str | 625941c6a4f1c619b28b006e |
def doCreateObject(self, array): <NEW_LINE> <INDENT> document = Document(array) <NEW_LINE> try: <NEW_LINE> <INDENT> if array.get('attributes') and array.get('attributeValues'): <NEW_LINE> <INDENT> document.attributes = [] <NEW_LINE> mapper = AttributesMapper() <NEW_LINE> for attribute in array.get('attributes').items()... | :param dict array:
:return Document: | 625941c630bbd722463cbdf7 |
def is_passive(self, verb): <NEW_LINE> <INDENT> if len(list(item for item in verb.rights if item.dep_ in self.SUBJECT)) == 0: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return True | Checks if sentence or part-sentence is in passive form by looking for a subject right from the verb. | 625941c63617ad0b5ed67f2b |
def inspect(self, service: str) -> None: <NEW_LINE> <INDENT> index = 1 <NEW_LINE> all_containers_processed = False <NEW_LINE> result_list = [] <NEW_LINE> need_build = False <NEW_LINE> while not all_containers_processed: <NEW_LINE> <INDENT> container_name = self._get_container_name(service, index) <NEW_LINE> inspect_dat... | Inspect docker container.
:param service: service name as defined in docker-compose yml.
:return: None | 625941c6d58c6744b4257c93 |
def _validate(self, serializer, data): <NEW_LINE> <INDENT> serializer_instance = serializer(data=data) <NEW_LINE> serializer_instance.is_valid(raise_exception=True) <NEW_LINE> return serializer_instance.data | :param serializer: serializer against which data to ve validated
:param data: data to ve validated
:return: validated data. | 625941c6d486a94d0b98e178 |
def test_release_profiles(prof_plugin): <NEW_LINE> <INDENT> prof_plugin.used_profiles = {'fp1': 'tests3', 'fp2': 'tests3', 'fp3': 'tests2'} <NEW_LINE> prof_plugin.release_profiles('tests3', ['fp1', 'fp2', 'fp3']) <NEW_LINE> assert 'fp1' not in prof_plugin.used_profiles <NEW_LINE> assert 'fp2' not in prof_plugin.used_pr... | Test releasing a previously acquired profile.
| 625941c6ad47b63b2c509fb2 |
def _define_graph(self, data): <NEW_LINE> <INDENT> for shard_id, shard in enumerate(data): <NEW_LINE> <INDENT> self._num_examples = array_ops.shape(shard)[0] <NEW_LINE> shard = array_ops.expand_dims(shard, 0) <NEW_LINE> self._define_log_prob_operation(shard_id, shard) <NEW_LINE> self._define_prior_log_prob_operation(sh... | Define graph for a single iteration.
Args:
data: a list of Tensors defining the training data. | 625941c6090684286d50ed17 |
def test_str(self): <NEW_LINE> <INDENT> with self.assertRaises(NotImplementedError): <NEW_LINE> <INDENT> str(PackageOrder()) | Validate __str__ is not implemented | 625941c699fddb7c1c9de3c4 |
def weibo_all(request): <NEW_LINE> <INDENT> weibos = Weibo.all_to_dict() <NEW_LINE> for weibo in weibos: <NEW_LINE> <INDENT> comments = Comment.all(weibo_id=int(weibo['id'])) <NEW_LINE> comments_dict = [comment.to_dict() for comment in comments] <NEW_LINE> weibo['comments'] = comments_dict <NEW_LINE> <DEDENT> return js... | 返回 json 格式的所有 weibo 数据 | 625941c6d99f1b3c44c675c3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.