code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def insert(self, key, item): <NEW_LINE> <INDENT> return lib.zhashx_insert(self._as_parameter_, key, item)
Insert item into hash table with specified key and item. If key is already present returns -1 and leaves existing item unchanged Returns 0 on success.
625941f2293b9510aa2c385d
def isgreeting(microgear, line_bot_api, event, txtmsg, replyToken, userId): <NEW_LINE> <INDENT> for word in txtmsg.split(" "): <NEW_LINE> <INDENT> if word.lower() in GREETING_KEYWORDS: <NEW_LINE> <INDENT> replymsg = random.choice(GREETING_RESPONSES) <NEW_LINE> line_bot_api.reply_message( replyToken, TextSendMessage(tex...
If any of the words in the user's input was a greeting, return True
625941f263d6d428bbe44abe
def get_hourly_exits(grp): <NEW_LINE> <INDENT> grp['EXITSn_hourly'] = (grp.EXITSn-grp.EXITSn.shift(1)).fillna(0) <NEW_LINE> return grp
The data in the MTA Subway Turnstile data reports on the cumulative number of entries and exits per row. Assume that you have a dataframe called grp that contains only the rows for a particular turnstile machine (i.e., unique SCP, C/A, and UNIT). This function should change these cumulative exit numbers to a count of...
625941f2d8ef3951e3243b0b
@com.run_with_connection <NEW_LINE> def get_trap_metadata(cur, trap_id): <NEW_LINE> <INDENT> sql = ('SELECT p.prefix, p.obfuscate FROM traps as t, providers as p ' 'WHERE t.prefix = p.prefix AND t.trap_id = %s') <NEW_LINE> cur.execute(sql, (trap_id,)) <NEW_LINE> row = cur.fetchone() <NEW_LINE> if not row: <NEW_LINE> <I...
Get metadata for the trapset containing the given trap. trap_id -- A string representing a BG-Counter trap ID. Note: Omit the 'cur' argument when calling and provide other arguments as keyword args.
625941f23c8af77a43ae3d75
def test_invalid(self): <NEW_LINE> <INDENT> invalid = [ "m1gZHpD1AzEixLgcnncod5df6CntYK4Jpi", "121tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX", "n3SjFgAhHAv8PcTuq5x2e9sugcXDpMTzX7", "m4dT2rG2nms1yEWP75C1oc65our7jRp4bj", "m5ifG3WbdPsVWHWP7JEQzkz2GNhRzhDKjP", "2REFC168wX4h1", "AH5FpvXbhaAYyM194A", "C6Vix8wPoc7cemv9Nk16Y2J4PiKQXjFHWy...
Test invalid addresses are rejected
625941f29c8ee82313fbbd45
def test_digits(self): <NEW_LINE> <INDENT> expected_output = { -(10 ** 5): 6, -1000: 4, -100: 3, -10: 2, -9: 1, -math.pi: 1, -1: 1, -0.5555: 1, 0: 1, 0.5555: 1, 0.999999: 1, 10: 2, math.pi: 1, 15: 2, 20: 2, 49: 2, 80: 2, 99: 2, 100: 3, 101.40409: 3, 999: 3, 1000: 4, 10 ** 5: 6, (10 ** 5) + 10: 6 } <NEW_LINE> for digit ...
Tests digits functions from minesweeper.utils
625941f221a7993f00bc82c8
def read_message_vital_signs(self) -> "XeThru::VitalSignsData": <NEW_LINE> <INDENT> return _moduleconnectorwrapper.PyX4M200_read_message_vital_signs(self)
read_message_vital_signs(PyX4M200 self) -> VitalSignsData Get one vital signs data message from subscription queue. Returns ------- : A data object holding the resulting vital signs data
625941f2187af65679ca56ed
def value(self, card): <NEW_LINE> <INDENT> return self.valores[self.deck.index(card)]
Get the value of a single card
625941f230dc7b7665901f2d
def is_pingable(ip_addr): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> logger.info('Pinging address: %s', ip_addr) <NEW_LINE> status = os.system(f"ping -c1 -w2 {ip_addr} >/dev/null") <NEW_LINE> if status == 0: <NEW_LINE> <INDENT> logger.info('IP: %s is RESPONDING !', ip_addr) <NEW_LINE> return True <NEW_LINE> <DEDENT> ...
verifies the specified ip_address is reachable or not. Args: ip_addr: ip_address to verify the PING. returns: return True is ip_address is pinging else returns False.
625941f25510c4643540f9a2
def calc_hyp_correct_posterior_mass(n_runs, n_contexts, n_utterances, multi_run_log_posterior_matrix, correct_hyp_indices): <NEW_LINE> <INDENT> posterior_correct_mass_accumulator = np.zeros((n_runs, ((n_contexts*n_utterances)+1))) <NEW_LINE> for r in range(len(multi_run_log_posterior_matrix)): <NEW_LINE> <INDENT> log_p...
:param multi_run_log_posterior_matrix: A 3D multi_run_log_posterior_matrix with shape (n_runs, n_contexts, n_hypotheses) :param correct_hyp_indices: A 1D numpy array with all the indices of the correct hypotheses in the learner's full hypothesis_space :return:
625941f23617ad0b5ed684c4
def load_precompiled_filters(filterpackage, precompiled_modules): <NEW_LINE> <INDENT> global _filter_precompiled_cache <NEW_LINE> logger.debug("Loading precompiled filter list for '%s': %r", filterpackage, precompiled_modules) <NEW_LINE> _filter_precompiled_cache[filterpackage] = precompiled_modules
`filterpackage`: name of the filter package under which to scope the given precompiled filter modules. `precompiled_modules`: a dictionary of `'filter_name': filter_module` of precompiled filter modules, along with their name.
625941f2b830903b967e9ed2
def get(self, endpoint, params=None): <NEW_LINE> <INDENT> res = requests.get("https://api.github.com/" + endpoint, auth=requests.auth.HTTPBasicAuth(self.credentials['username'], self.credentials['token']), params=params) <NEW_LINE> return res.json()
returns info about the requested endpoint from github
625941f26fb2d068a760f674
def is_unit_installed(self): <NEW_LINE> <INDENT> if self.get_systemd_unit() is not None: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return "sshtunnel@.service" in SystemDCache.get()
Check if this tunnel has a corresponding systemd unit :return: True if the tunnel's systemd unit is installed, false otherwise :rtype: bool
625941f2099cdd3c635f1225
@jax.jit <NEW_LINE> def deep_linear_model_loss(w, x, y): <NEW_LINE> <INDENT> z = x <NEW_LINE> for i in range(len(w)): <NEW_LINE> <INDENT> z = w[i].T @ z <NEW_LINE> <DEDENT> loss = nn.softplus(-y * z).mean() <NEW_LINE> return loss
Returns the loss given an input and its ground-truth label.
625941f271ff763f4b549c64
def set(self, key, value): <NEW_LINE> <INDENT> if not self.enabled: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if self.redis: <NEW_LINE> <INDENT> if value is not None: <NEW_LINE> <INDENT> self.redis.set(key, self.serializer.dumps(value)) <NEW_LINE> self.cache[key] = value <NEW_LINE> <DEDENT> <DEDENT> elif self.cach...
Add an item to the cache.
625941f2e76e3b2f99f3adcf
def GetFieldValuesTuple(self, trip_id): <NEW_LINE> <INDENT> result = [] <NEW_LINE> for fn in self._FIELD_NAMES: <NEW_LINE> <INDENT> if fn == 'trip_id': <NEW_LINE> <INDENT> result.append(trip_id) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> result.append(getattr(self, fn) or '' ) <NEW_LINE> <DEDENT> <DEDENT> return tup...
Return a tuple that outputs a row of _FIELD_NAMES to be written to a GTFS file. Arguments: trip_id: The trip_id of the trip to which this StopTime corresponds. It must be provided, as it is not stored in StopTime.
625941f22ae34c7f2600d6fe
def pad_number(num: str, sign_flag: int): <NEW_LINE> <INDENT> padding = str(sign_flag) <NEW_LINE> while len(num) % 4 != 0: <NEW_LINE> <INDENT> num = padding + num <NEW_LINE> <DEDENT> return num
Applies padding to passed binary string so that # of bits are a multiple of 4 :param num: binary string :param sign_flag: 1 for negative, 0 for positive. Used for padding :return: binary string
625941f23eb6a72ae02ecabb
def print_messages(self): <NEW_LINE> <INDENT> bold_on = False <NEW_LINE> if not self.messages.empty(): <NEW_LINE> <INDENT> no_exception = sys.exc_info()[0] is None <NEW_LINE> bold_on = sys.stdout.isatty() <NEW_LINE> if not self.config.quiet: <NEW_LINE> <INDENT> if bold_on: <NEW_LINE> <INDENT> print(util.ANSI_SGR_BOLD) ...
Prints messages to the user and clears the message queue. If there is an unhandled exception, only messages for which ``on_crash`` is ``True`` are printed.
625941f2460517430c394742
def new_status(self) -> FeatureStatus: <NEW_LINE> <INDENT> return TemperaturesStatus(0,0)
See base class.
625941f2956e5f7376d71439
def test_wtree_basic_include(self): <NEW_LINE> <INDENT> wd = 'foobar0' <NEW_LINE> self.make_branch_and_tree(wd) <NEW_LINE> os.chdir(wd) <NEW_LINE> self._mk_versioned_file('file0.aa') <NEW_LINE> self._mk_versioned_file('file0.bb') <NEW_LINE> self._mk_versioned_file('file0.cc') <NEW_LINE> out, err = self.run_bzr(['grep',...
(wtree) Ensure that --include flag is respected.
625941f23eb6a72ae02ecabc
def get_cert_serial(cert_file): <NEW_LINE> <INDENT> cmd = "certutil.exe -verify {0}".format(cert_file) <NEW_LINE> out = __salt__['cmd.run'](cmd) <NEW_LINE> matches = re.search(r"Serial: (.*)", out) <NEW_LINE> if matches is not None: <NEW_LINE> <INDENT> return matches.groups()[0].strip() <NEW_LINE> <DEDENT> else: <NEW_L...
Get the serial number of a certificate file cert_file The certificate file to find the serial for
625941f25fc7496912cc3f4b
def load_settings(config_path: str) -> ArkUrlSettings: <NEW_LINE> <INDENT> app.config.config_path = config_path <NEW_LINE> environment_vars = { "ArkExternalHost": os.environ.get("ARK_EXTERNAL_HOST", "ark.example.org"), "ArkInternalHost": os.environ.get("ARK_INTERNAL_HOST", "0.0.0.0"), "ArkInternalPort": os.environ.get(...
Loads configuration from given path and returns an ArkUrlSettings.
625941f2d4950a0f3b08c914
def add_current_phase(filtered_event_stream): <NEW_LINE> <INDENT> prev_period = None <NEW_LINE> def current_p(e): <NEW_LINE> <INDENT> nonlocal prev_period <NEW_LINE> e['current_phase'] = current_phase(e['timestamp']) <NEW_LINE> e['phase_start'] = True if prev_period is not None and prev_period != e['current_phase'] els...
Append current phase :param filtered_event_stream: filtered event stream (full events)
625941f226068e7796caf2b6
def len(self, s): <NEW_LINE> <INDENT> len_conv_this = len(s) <NEW_LINE> if len_conv_this > 3: <NEW_LINE> <INDENT> len_conv_this = 3 <NEW_LINE> <DEDENT> return len_conv_this
If greater than three, reduce as the maximum length for Kana conversions is 3 to improve speed :-)
625941f21b99ca400220b082
def average_pressure(self): <NEW_LINE> <INDENT> return self._average(self._purge_none_samples( self.pressure_series()))
Returns the average value in the pressure series :returns: a float :raises: ValueError when the measurement series is empty
625941f282261d6c526aba76
def named_modules(self, memo=None, prefix=''): <NEW_LINE> <INDENT> if memo is None: <NEW_LINE> <INDENT> memo = set() <NEW_LINE> <DEDENT> if self not in memo: <NEW_LINE> <INDENT> memo.add(self) <NEW_LINE> yield prefix, self <NEW_LINE> for name, module in self._modules.items(): <NEW_LINE> <INDENT> if module is None: <NEW...
Returns an iterator over all modules in the network, yielding both the name of the module as well as the module itself. Yields: (string, Module): Tuple of name and module Note: Duplicate modules are returned only once. In the following example, ``l`` will be returned only once. >>> l = nn.Linear(2, 2...
625941f2187af65679ca56ee
def add_header(self, name, value): <NEW_LINE> <INDENT> assert not self.headers_sent, 'headers have been sent already' <NEW_LINE> assert isinstance(name, str), 'Header name should be a string, got {!r}'.format(name) <NEW_LINE> assert set(name).issubset(aiohttp.protocol.ASCIISET), 'Header name shoul...
Analyze headers. Calculate content length, removes hop headers, etc.
625941f26aa9bd52df037376
def test_img_get_img_model(make_test_image): <NEW_LINE> <INDENT> img = make_test_image <NEW_LINE> ival, mval = img.get_img(image_callable) <NEW_LINE> shape = (20, 30) <NEW_LINE> expected1 = np.ones(shape) <NEW_LINE> expected2 = np.ones(shape) * 3 <NEW_LINE> assert ival.shape == shape <NEW_LINE> assert ival == pytest.ap...
What happens when we give a callable function to get_img? The idea is that it will be a model, but all we need is a callable.
625941f2cc0a2c11143dd460
def setType(self, val): <NEW_LINE> <INDENT> if val not in ['label', 'input', 'choice', 'button', 'checkbox', 'toggle', 'file', 'progress', 'spin']: <NEW_LINE> <INDENT> raise ValueError("Not a valid property type!") <NEW_LINE> <DEDENT> self.type = val
Set property type. Allowed values are 'label', 'input', 'choice', 'button', 'checkbox', 'toggle', 'file', 'progress', and 'spin'.
625941f2baa26c4b54cb16e7
def eventing_functions(self): <NEW_LINE> <INDENT> from couchbase.management.eventing import EventingFunctionManager <NEW_LINE> self._check_for_shutdown() <NEW_LINE> return EventingFunctionManager(self._admin)
Get the EventingFunctionManager. :return: A :class:`~.management.EventingFunctionManager` with which you can create or modify eventing functions on the cluster.
625941f25fdd1c0f98dc0803
def __init__(self, path, lang=None, keep_last=False): <NEW_LINE> <INDENT> lang = lang or get_language() <NEW_LINE> path = _path = fix_slashes(path) <NEW_LINE> if not path_regex.match(path): <NEW_LINE> <INDENT> raise InvalidPageError(u'Invalid path: {}'.format(path)) <NEW_LINE> <DEDENT> rootdir = os.path.realpath(defaul...
Returns the page on ``path`` recursively expanding all redirects. If ``keep_last`` is True, the last path component is not expanded and returned as is even if it is a redirect. Usefull if we want to get the redirect object itself. The path in an absolute path but does not have to start or end with a slash, the slashes ...
625941f2bd1bec0571d90bfd
def _tile_ragged_values(rt_input, multiples, const_multiples=None): <NEW_LINE> <INDENT> ragged_rank = rt_input.ragged_rank <NEW_LINE> nested_splits = rt_input.nested_row_splits <NEW_LINE> inner_value_ids = math_ops.range(nested_splits[-1][-1]) <NEW_LINE> prev_splits = None <NEW_LINE> for axis in range(ragged_rank, 0, -...
Builds flat_values tensor for a tiled `RaggedTensor`. Returns a tensor that repeats the values in `rt_input.flat_values` in the appropriate pattern to construct a `RaggedTensor` that tiles `rt_input` as specified by `multiples`. Args: rt_input: The `RaggedTensor` whose values should be repeated. multiples: A 1-D ...
625941f2eab8aa0e5d26e128
def forward_backward_prop(data, labels, params, dimensions): <NEW_LINE> <INDENT> ofs = 0 <NEW_LINE> Dx, H, Dy = (dimensions[0], dimensions[1], dimensions[2]) <NEW_LINE> W1 = np.reshape(params[ofs:ofs+ Dx * H], (Dx, H)) <NEW_LINE> ofs += Dx * H <NEW_LINE> b1 = np.reshape(params[ofs:ofs + H], (1, H)) <NEW_LINE> ofs += H ...
Forward and backward propagation for a two-layer sigmoidal network Compute the forward propagation and for the cross entropy cost, and backward propagation for the gradients for all parameters. Arguments: data -- M x Dx matrix, where each row is a training example. labels -- M x Dy matrix, where each row is a one-hot...
625941f28e05c05ec3eea948
def resize_image(image, save_locaton): <NEW_LINE> <INDENT> im = Image.open(image) <NEW_LINE> maxsize = (512, 512) <NEW_LINE> if (im.width and im.height) < 512: <NEW_LINE> <INDENT> size1 = im.width <NEW_LINE> size2 = im.height <NEW_LINE> if im.width > im.height: <NEW_LINE> <INDENT> scale = 512 / size1 <NEW_LINE> size1ne...
Copyright Rhyse Simpson: https://github.com/skittles9823/SkittBot/blob/master/tg_bot/modules/stickers.py
625941f20a366e3fb873edee
def calcComputeWFIMMVM(self): <NEW_LINE> <INDENT> print("INFORMATION:(**HWR/MVM**): Calculating WFIM, using MVM (wavefront-interaction matrix)") <NEW_LINE> for actNo,thisIp in enumerate(self.spmx): <NEW_LINE> <INDENT> if type(thisIp)!=numpy.ndarray: <NEW_LINE> <INDENT> thisIp=numpy.array(thisIp.todense()).ravel() <NEW_...
Compute the WFIM based on spmx using MVM
625941f2f8510a7c17cf9ccf
def duplicate_sandhi_one_final_cons(base): <NEW_LINE> <INDENT> ans = None <NEW_LINE> n0 = len(base) <NEW_LINE> n = n0 <NEW_LINE> more = (1 < n) <NEW_LINE> n2 = None <NEW_LINE> while more: <NEW_LINE> <INDENT> n = n - 1 <NEW_LINE> x = base[n] <NEW_LINE> if x in init.consonant_set: <NEW_LINE> <INDENT> if not n2: <NEW_LINE...
Antoine 72-1. No Sanskrit word can end with more than one consonant. A final compound consonant must be reduced to its first member. In particular, this applies to Nominative Singular ending 's' joined to nouns ending in consonants. Routine returns None unless some change is made in tokar.
625941f2dd821e528d63b772
def has_dataset(name): <NEW_LINE> <INDENT> endswith = {'sample': 'MNE-sample-data', 'spm': 'MNE-spm-face', 'somato': 'MNE-somato-data', 'testing': 'MNE-testing-data', 'fake': 'foo', }[name] <NEW_LINE> dp = _data_path(download=False, name=name, check_version=False) <NEW_LINE> return dp.endswith(endswith)
Helper for dataset presence
625941f29f2886367277ae56
def Mathf_FMod(*args): <NEW_LINE> <INDENT> return _fife.Mathf_FMod(*args)
Mathf_FMod(float _x, float _y) -> float
625941f2be383301e01b5a48
def flags_from_text_set(texts_set): <NEW_LINE> <INDENT> flags = 0 <NEW_LINE> for text in texts_set: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> flags += _flag_by_text[text] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> raise NotImplementedError( "DNSKEY flag '%s' is not supported" % text) <NEW_LINE> <DEDENT...
Convert set of DNSKEY flag mnemonic texts to DNSKEY flag value @rtype: int
625941f2009cb60464c6397b
def PressStampButton(buttonName): <NEW_LINE> <INDENT> uiView = _wx.GetApp().UIRepositoryView <NEW_LINE> for block in _Block.Block.iterItems(uiView): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> blockName = block.blockName <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> if blo...
Press a Stamp button in the markup bar, by firing its event
625941f2507cdc57c63072b8
def get_bug_info_uncached(self, repository, bug_id): <NEW_LINE> <INDENT> bug_id = str(bug_id) <NEW_LINE> result = { 'summary': '', 'description': '', 'status': '', } <NEW_LINE> try: <NEW_LINE> <INDENT> url = '%s/rest/bug/%s' % ( repository.extra_data['bug_tracker-bugzilla_url'], bug_id) <NEW_LINE> rsp, headers = self.c...
Get the bug info from the server.
625941f276d4e153a657f101
def serialize(self, serializer): <NEW_LINE> <INDENT> serializer.serializeAttribute(self, common.NAME) <NEW_LINE> serializer.serializeProperty(self, common.DISPLAY_NAME) <NEW_LINE> serializer.serializeProperty(self, common.DESCRIPTION) <NEW_LINE> serializer.serializeProperty(self, common.FUNCTION_CATEGORY) <NEW_LINE> se...
Load/unload class state to/from serializer object.
625941f2cb5e8a47e48b806e
def check_PM3(line,Funcanno_flgs,Allels_flgs): <NEW_LINE> <INDENT> PM3=0 <NEW_LINE> return(PM3)
For recessive disorders, detected in trans with a pathogenic variant
625941f2596a89723608a086
def shifted_correlation(): <NEW_LINE> <INDENT> tickers = ['^IXIC', '^NYA', '^DJI', '^GSPC', '^STOXX50E', '000001.SS'] <NEW_LINE> dic = {} <NEW_LINE> index_ticker = {} <NEW_LINE> for ticker in tickers: <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> dic[ticker] = web.DataReader(ticker, 'yaho...
Part 7 of the assignment This below block of code will fix the stock ticker input by the user and will shift the index ticker ( 5 places up and 5 places down), then calculating the maximum correlation with each combination. Then we will compare this maximum correlation with the correlation calculated earlier. :return:
625941f2287bf620b61d402e
def get_user_timeline_tweets(screen_name): <NEW_LINE> <INDENT> interns_logger.info( 'Making twitter timeline request for user: %s', screen_name ) <NEW_LINE> twitterClient = get_twitter_client() <NEW_LINE> last_entry_id = eleanor_twitter.get_username_last_tweet_id(screen_name) <NEW_LINE> timeline_tweets = [] <NEW_LINE> ...
Pull as many tweets as possible for a newly added user
625941f2e76e3b2f99f3add0
def __repr__(self): <NEW_LINE> <INDENT> return("AVR(0x%x, %d" % (self._i2c_address, self._i2c_bus_num))
String representation of self
625941f23317a56b8693a218
def test_get_message_create(self): <NEW_LINE> <INDENT> with self.login(self.brosner): <NEW_LINE> <INDENT> response = self.get("pinax_messages:message_create") <NEW_LINE> self.assertEqual(response.status_code, 200)
Ensure user can get page to create a message.
625941f28e71fb1e9831dd75
def enter(self, player): <NEW_LINE> <INDENT> player.stage += 1 <NEW_LINE> self.say("Just another trashy RPG game") <NEW_LINE> self.say("Don't expect much, mkay?") <NEW_LINE> return "End Stage"
Start the event.
625941f2bde94217f36833ba
def _activation_summary(x): <NEW_LINE> <INDENT> tensor_name = re.sub('%s_[0-9]*/' % TOWER_NAME, '', x.op.name) <NEW_LINE> tf.summary.histogram(tensor_name + '/activations', x) <NEW_LINE> tf.summary.scalar(tensor_name + '/sparsity', tf.nn.zero_fraction(x))
Helper to create summaries for activations. Creates a summary that provides a histogram of activations. Creates a summary that measures the sparsity of activations. Args: x: Tensor Returns: nothing
625941f21f037a2d8b9467ca
def delete_role(self, r_name): <NEW_LINE> <INDENT> if self.get_role(r_name): <NEW_LINE> <INDENT> for user in self['user_storage'].get_elements( query={'crecord_type': 'user'} ): <NEW_LINE> <INDENT> if user and 'role' in user and r_name == user['role']: <NEW_LINE> <INDENT> user.pop('role', None) <NEW_LINE> self['user_st...
Args: r_name: id of the role to be deleted Returns: ``True`` if the role was deleted ``False`` otherwise
625941f23d592f4c4ed1d62c
def __getitem__(self, key): <NEW_LINE> <INDENT> if key == 'name': <NEW_LINE> <INDENT> return self.name <NEW_LINE> <DEDENT> elif key == 'type': <NEW_LINE> <INDENT> return self.type <NEW_LINE> <DEDENT> elif key == 'tab_id': <NEW_LINE> <INDENT> return self.tab_id <NEW_LINE> <DEDENT> elif key == 'is_hidden': <NEW_LINE> <IN...
This method allows callers to access CourseTab members with the d[key] syntax as is done with Python dictionary objects.
625941f2d4950a0f3b08c915
def test_3_non_exist_cert_key(self): <NEW_LINE> <INDENT> non_exist_cert = os.path.join(self.test_root, "idonot_exist_cert") <NEW_LINE> non_exist_key = os.path.join(self.test_root, "idonot_exist_key") <NEW_LINE> exist_cert = os.path.join(self.test_root, "tmp", "ido_exist_cert") <NEW_LINE> exist_key = os.path.join(self.t...
We return an error given an non-exist cert or key.
625941f2f7d966606f6aa5da
def registerPresenceHandler(self, template, handler): <NEW_LINE> <INDENT> self._presenceHandlers[handler] = template
DEPRECATED register a handler that will manage all incoming presence notifications matching the given presence template
625941f2377c676e91272775
def send_report_mm(plain_text, settings): <NEW_LINE> <INDENT> report_text = "```\n" <NEW_LINE> report_text += plain_text <NEW_LINE> report_text += "\n```" <NEW_LINE> payload = dict() <NEW_LINE> payload['text'] = report_text <NEW_LINE> payload['channel'] = settings['channel'] <NEW_LINE> payload['icon_url'] = settings['i...
Send anomalies report by email Arguments: plain_text {string} -- Report body in plain text settings (dict) -- Settings from the class Config.MatterMost Returns: bool -- True/False depending the request result
625941f2956e5f7376d7143a
def create_routes_dict(): <NEW_LINE> <INDENT> buffer = BytesIO() <NEW_LINE> handle = pycurl.Curl() <NEW_LINE> handle.setopt(pycurl.URL, 'http://www.lpp.si/sites/default/files/lpp_vozniredi/iskalnik/index.php?stop=0&line=212') <NEW_LINE> handle.setopt(pycurl.HTTPHEADER, ['Accept: application/json']) <NEW_LINE> handle.se...
This method creates the 'out/routes_dict.json' file needed for create_bus_routes() :return: /
625941f230c21e258bdfaa73
def apply(self, **kwargs): <NEW_LINE> <INDENT> kwargs_upper = dict( (key.upper(), value) for key, value in kwargs.items() ) <NEW_LINE> kept = ( (key, value) for key, value in self.__isupport.items() if ('-%s' % key) not in kwargs_upper ) <NEW_LINE> updated = dict(itertools.chain(kept, kwargs_upper.items())) <NEW_LINE> ...
Build a new instance of :class:`ISupport`. :return: a new instance, updated with the latest advertised features :rtype: :class:`ISupport` This method applies the latest advertised features from the server: the result contains the new and updated parameters, and doesn't contain the removed parameters (marked by ``-{PA...
625941f29c8ee82313fbbd46
def __init__(self): <NEW_LINE> <INDENT> super(CandidateModel, self).__init__()
Init Model
625941f2435de62698dfe21c
def gen_signature(data): <NEW_LINE> <INDENT> h = hmac.new(GIT_SECRET.encode("utf-8"), data.encode("utf-8"), hashlib.sha1) <NEW_LINE> s = "sha1=" + h.hexdigest() <NEW_LINE> return s.encode("utf-8")
Generate the signature for the data. :param data: Data to generate signature for :return: "sha1=<hexdigest>"
625941f260cbc95b062c6b12
def add_links(self, parent, children): <NEW_LINE> <INDENT> new_sensors = [] <NEW_LINE> if parent not in self: <NEW_LINE> <INDENT> self._add_sensor(parent) <NEW_LINE> new_sensors.append(parent) <NEW_LINE> <DEDENT> for child in children: <NEW_LINE> <INDENT> if child not in self: <NEW_LINE> <INDENT> self._add_sensor(child...
Create dependency links from parent to child. Any sensors not in the tree are added. After all dependency links have been created, the parent is recalculated and the tree attaches to any sensors it was not yet attached to. Links that already exist are ignored. Parameters ---------- parent : :class:`katcp.Sensor` obje...
625941f201c39578d7e7540a
def hangman(secret_word): <NEW_LINE> <INDENT> print("Welcome to the game, Hangman!") <NEW_LINE> print("I am thinking of a word that is " + str(len(secret_word)) + " letters long.") <NEW_LINE> wrong_guess_count = 8 <NEW_LINE> entered_string_by_user = "" <NEW_LINE> print(secret_word) <NEW_LINE> list_1 = [] <NEW_LINE> whi...
secretWord: string, the secret word to guess. Starts up an interactive game of Hangman. * At the start of the game, let the user know how many letters the secretWord contains. * Ask the user to supply one guess (i.e. letter) per round. * The user should receive feedback immediately after each guess about whether th...
625941f245492302aab5e898
def set_thread_priority(self, *args, **kwargs): <NEW_LINE> <INDENT> return _blocks_swig4.not_ii_sptr_set_thread_priority(self, *args, **kwargs)
set_thread_priority(not_ii_sptr self, int priority) -> int
625941f27cff6e4e81117f54
def dict_rules(enforcer_rules): <NEW_LINE> <INDENT> return jsonutils.loads(str(enforcer_rules))
Converts enforcer rules to dictionary. :param enforcer_rules: enforcer rules represented as a class Rules :return: enforcer rules represented as a dictionary
625941f2498bea3a759ba07c
def evaluate(self): <NEW_LINE> <INDENT> if(self.token == "+"): <NEW_LINE> <INDENT> return (self.left.evaluate() + self.right.evaluate()) <NEW_LINE> <DEDENT> elif(self.token == "*"): <NEW_LINE> <INDENT> return (self.left.evaluate() * self.right.evaluate()) <NEW_LINE> <DEDENT> elif(self.token == "//"): <NEW_LINE> <INDENT...
Evaluates the math expression and returns the result. :exception: raises a runtime_error.RuntimeError if division by zero is attempted, with the message, 'Division by zero error' :return: The result of performing the math operation (int)
625941f292d797404e30475c
def history_graphics(self, data_list)->str: <NEW_LINE> <INDENT> title = "USER HISTORY" <NEW_LINE> history = self.IFmethods.list_interface(data_list, title) <NEW_LINE> return self.defaultheader+self.history_view_default+history
Is to be triggered every time history menu is requested
625941f25166f23b2e1a5728
def topKFrequent(nums, k): <NEW_LINE> <INDENT> tempDict = {} <NEW_LINE> for i in range(len(nums)): <NEW_LINE> <INDENT> if nums[i] in tempDict: <NEW_LINE> <INDENT> tempDict[nums[i]] = tempDict[nums[i]] + 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> tempDict[nums[i]] = 1 <NEW_LINE> <DEDENT> <DEDENT> result = list(sort...
:type nums: List[int] :type k: int :rtype: List[int]
625941f263b5f9789fde76b5
def __init__(self, scenario, args): <NEW_LINE> <INDENT> super(ImposeRelPronAgr, self).__init__(scenario, args)
Constructor, checking the argument values
625941f245492302aab5e899
def test_limiter_offset_zero(self): <NEW_LINE> <INDENT> req = webob.Request.blank('/?offset=0') <NEW_LINE> self.assertEqual(common.limited(self.tiny, req), self.tiny) <NEW_LINE> self.assertEqual(common.limited(self.small, req), self.small) <NEW_LINE> self.assertEqual(common.limited(self.medium, req), self.medium) <NEW_...
Test offset key works with 0.
625941f23617ad0b5ed684c5
def __enter__(self): <NEW_LINE> <INDENT> self._revert_stack.append([]) <NEW_LINE> for key, value in self._parameters: <NEW_LINE> <INDENT> old_value = self._update_value(key, value) <NEW_LINE> self._debug_print('Set {key} to {value}, was {old_value}.', key=key, value=value, old_value=old_value) <NEW_LINE> if old_value i...
Store current and set requested parameter values.
625941f2d6c5a1020814461f
def _restart_animation ( self ): <NEW_LINE> <INDENT> if self.animate: <NEW_LINE> <INDENT> self.animate = False <NEW_LINE> self.animate = True
Restart the animation if it is running.
625941f26fece00bbac2dd15
def init_model(self, latent_dim , n_feature, network_architecture, lambda_reconstruct, lambda_kl, device, batch_shape ): <NEW_LINE> <INDENT> self.model = CVAE(latent_dim = latent_dim, n_feature = n_feature, network_architecture= network_architecture, lambda_reconstruct = lambda_reconstruct, lambda_kl = lambda_kl, batch...
Initialize the model.
625941f215baa723493c4549
def find_element_by_any(self, search_term): <NEW_LINE> <INDENT> return self.find_element_by_id(search_term) or self.find_element_by_name(search_term)
Find an element by a search term Try ID, then fallback to Name
625941f2bf627c535bc1379f
def _wrap_get_client(self, target, version_cap=None, serializer=None): <NEW_LINE> <INDENT> serializer = CheatingSerializer(serializer) <NEW_LINE> return messaging.RPCClient(rpc.TRANSPORT, target, version_cap=version_cap, serializer=serializer)
Mirror rpc.get_client() but with our special sauce.
625941f21b99ca400220b083
def _theme_get_upstream(self): <NEW_LINE> <INDENT> self.ensure_one() <NEW_LINE> return self.upstream_dependencies(exclude_states=('',)).filtered(lambda x: x.name.startswith('theme_'))
Return installed upstream themes. :return: recordset of themes ``ir.module.module``
625941f230dc7b7665901f2f
def create_exchange_space(self, exchange_space=None, org_id=''): <NEW_LINE> <INDENT> log.debug("create_exchange_space(%s, org_id=%s)" % (exchange_space, org_id)) <NEW_LINE> self.assert_condition(exchange_space and org_id, "Arguments not set") <NEW_LINE> org = self.container.resource_registry.read(org_id) <NEW_LINE> if ...
Creates an Exchange Space distributed resource from the parameter exchange_space object. @param exchange_space ExchangeSpace @param org_id str @retval exchange_space_id str @throws BadRequest if object passed has _id or _rev attribute
625941f23c8af77a43ae3d77
def _init_options(self, argv): <NEW_LINE> <INDENT> opts = Extract._load_options(argv) <NEW_LINE> for opt, arg in opts: <NEW_LINE> <INDENT> if opt in ("-h", "--help"): <NEW_LINE> <INDENT> raise C_Exceptions.DisplayHelpError <NEW_LINE> <DEDENT> elif opt == "--inputlayer": <NEW_LINE> <INDENT> self._input_layer_path = arg ...
Verify and set up values from options/arguments
625941f2d486a94d0b98e716
def main(seq_length, seq_count): <NEW_LINE> <INDENT> gt = dict() <NEW_LINE> funcs = [0] * 5 <NEW_LINE> for i in range(seq_count): <NEW_LINE> <INDENT> seq = set() <NEW_LINE> while len(seq) < seq_length: <NEW_LINE> <INDENT> val = random.randint(1, 100) <NEW_LINE> if not val in seq: <NEW_LINE> <INDENT> seq.add(val) <NEW_L...
Generate seq_count random sequences of seq_length values (containing values between 1 and 100) together with ground truth generated using one of the five functions. Output sequences and ground truth. Parameters ---------- seq_length: int seq_count: int
625941f294891a1f4081c07c
def __grant_certificate(self, client_id, client_public_key, network): <NEW_LINE> <INDENT> current = datetime.datetime.now() <NEW_LINE> validity = (current, current + datetime.timedelta(days=5)) <NEW_LINE> self.__database.get(client_id).validity = validity <NEW_LINE> serialized_cert = pickle.dumps((client_id, client_pub...
Creates a certificate and sends it back to the client :param client_id: str; client's id :param client_public_key: bytes; client's public key :param network: Wrapper :return: None
625941f229b78933be1e5c74
def delete(self, request, pk, *args, **kwargs): <NEW_LINE> <INDENT> Interface.objects.filter(id=pk).delete() <NEW_LINE> return common.response_success()
删除单个接口 :param request: :param pk: :param args: :param kwargs: :return:
625941f23cc13d1c6d3c7946
def p_repeatable_selector_sequence(p): <NEW_LINE> <INDENT> if len(p) == 2: <NEW_LINE> <INDENT> p[0] = [p[1]] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> p[0] = [p[1]] + p[2]
repeatable_selector_sequence : repeatable_selector | repeatable_selector repeatable_selector_sequence
625941f2a79ad161976cc715
def test_verify_reject_id_with_ctrl_char(self): <NEW_LINE> <INDENT> conf_path = "../setUpClass/test-router-ctrl-char.conf" <NEW_LINE> with open(conf_path, 'w') as router_conf: <NEW_LINE> <INDENT> router_conf.write("router { \n") <NEW_LINE> router_conf.write(" id: abc\\bdef \n") <NEW_LINE> router_conf.write("}") <NEW...
Writes illegal config, runs router, examines console output
625941f20fa83653e4657587
def children(self): <NEW_LINE> <INDENT> return self._children
Return all nested nodes.
625941f22ae34c7f2600d700
def to_tree( self, max_level: QueryLevel = QueryLevel.IMAGE, level_fmts: Optional[Dict[Optional[QueryLevel], str]] = None, sep: str = " | ", missing: str = "NA", ) -> str: <NEW_LINE> <INDENT> formatter = partial( self.to_line, level_fmts=level_fmts, sep=sep, missing=missing ) <NEW_LINE> child_getter = self._make_sorted...
Produce a formatted text tree representation
625941f291af0d3eaac9bfee
def weeks_splitting(time1,asrm,qids): <NEW_LINE> <INDENT> length=len(time1) <NEW_LINE> years=np.array([mdates.num2date(time1[i]).isocalendar()[0] for i in range(length)]) <NEW_LINE> weeks=np.array([mdates.num2date(time1[i]).isocalendar()[1] for i in range(length)]) <NEW_LINE> unique_years,[weeks_per_year,times_per_year...
Input: time1: 1d numpy array, machine time since 1970 asrm,qids: 1d numpy array Output: unique_weeks_per_year: [[unique weeks for year1],..[unique weeks for year n],...] times_per_week_per_year: [[times per week for year 1],...,[times per week for year n],..] where [times per week for year 1...
625941f2851cf427c661aad9
def stack_single_bands(images, outfile, bands=None, of='GTiff', co=None, no_data=0, band_names=None, overwrite=False): <NEW_LINE> <INDENT> if os.path.exists(outfile) and overwrite is True: <NEW_LINE> <INDENT> delete_ds(outfile) <NEW_LINE> <DEDENT> elif os.path.exists(outfile) and overwrite is False: <NEW_LINE> <INDENT>...
Create a layerstack from the given images. They have to share the same spatial reference system, data type and dimensions. :param images: Input images. Will be stacked in the given order. :param outfile: Output image. :param bands: The desired band numbers of the input images which shall be used for stacking. By ...
625941f273bcbd0ca4b2c645
def AsymmetricSign(self, request, global_params=None): <NEW_LINE> <INDENT> config = self.GetMethodConfig('AsymmetricSign') <NEW_LINE> return self._RunMethod( config, request, global_params=global_params)
Signs data using a CryptoKeyVersion with CryptoKey.purpose. ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from GetPublicKey. Args: request: (CloudkmsProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsAsymmetricSignRequest) input message global_params: ...
625941f28a349b6b435e8742
def pick_num_neighbors(): <NEW_LINE> <INDENT> klist = list(range(1,20)) <NEW_LINE> scoresTR = [] <NEW_LINE> scoresTE = [] <NEW_LINE> for i in klist: <NEW_LINE> <INDENT> knn = KNeighborsClassifier(n_neighbors=i) <NEW_LINE> knn.fit(cv_data_train, cv_target_train) <NEW_LINE> scoresTR.append(knn.score(cv_data_train, cv_tar...
function when run, plots training and testing scores. It is easy to see from the graph which k to use.
625941f2a4f1c619b28b05fa
def test_retrieve_ingredients_list(self): <NEW_LINE> <INDENT> Ingredient.objects.create(user=self.user, name='Kale') <NEW_LINE> Ingredient.objects.create(user=self.user, name='Salt') <NEW_LINE> res = self.client.get(INGREDIENTS_URL) <NEW_LINE> ingredients = Ingredient.objects.all().order_by('-name') <NEW_LINE> serializ...
Test receiving a list of ingredients
625941f263b5f9789fde76b6
def get_name(self): <NEW_LINE> <INDENT> return self._name
Retorna el nombre de la partícula
625941f207d97122c4178e6a
def cEDU_to_labels(cEDU, labels): <NEW_LINE> <INDENT> start = min(cEDU) <NEW_LINE> end = max(cEDU) <NEW_LINE> for i, l in enumerate(labels): <NEW_LINE> <INDENT> if i < start: <NEW_LINE> <INDENT> labels[i] = _BEFORE <NEW_LINE> <DEDENT> elif i > end: <NEW_LINE> <INDENT> labels[i] = _AFTER <NEW_LINE> <DEDENT> elif i in cE...
label a segment sequence by connective positions only
625941f226068e7796caf2b8
def field_from_native(self, data, files, field_name, into): <NEW_LINE> <INDENT> if self.read_only: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> value = data[field_name] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> if self.default is not None and not self.partial: <NEW_LINE> <INDEN...
Override default so that the serializer can be used as a writable nested field across relationships.
625941f2004d5f362079a8fe
def merge_dicts(x, y): <NEW_LINE> <INDENT> z = x.copy() <NEW_LINE> z.update(y) <NEW_LINE> return z
Merge two dictionaries. Values from y will be retaining where keys match. :param x: <dict> first dictionary :param y: <dict> second dictionary :return: <dict>
625941f2d18da76e23532aae
def read_handshake(): <NEW_LINE> <INDENT> global _topology_name, _component_name, _task_id, _conf, _context, _debug <NEW_LINE> msg = read_message() <NEW_LINE> pid_dir, _conf, _context = msg['pidDir'], msg['conf'], msg['context'] <NEW_LINE> open('{}/{}'.format(pid_dir, str(_pid)), 'w').close() <NEW_LINE> send_message({'...
Read and process an initial handshake message from Storm.
625941f2442bda511e8be9df
def move(self, **kwargs): <NEW_LINE> <INDENT> if kwargs: <NEW_LINE> <INDENT> self.set_params(**kwargs) <NEW_LINE> <DEDENT> self.com.write(self.to_command())
Sends the proper commands to the SCC32 using com
625941f20a366e3fb873edf0
def ts_to_date(request_data): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> request_data['timestamp'] = datetime.fromtimestamp(request_data['timestamp']) <NEW_LINE> request_data['error_code'] = 0 <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> request_data['error_code'] = 1 <NEW_LINE> <DEDENT> return request_da...
Переводит юникс таймстамп в джангоугодный формат времени
625941f24527f215b584ca21
def getProductPath(product): <NEW_LINE> <INDENT> if product in PRODUCTS.keys(): <NEW_LINE> <INDENT> return PRODUCTS[product]['path'] <NEW_LINE> <DEDENT> if product in PRODUCTNAMES: <NEW_LINE> <INDENT> for abbr in PRODUCTS.keys(): <NEW_LINE> <INDENT> if PRODUCTS[abbr]['name'] == product: <NEW_LINE> <INDENT> return PRODU...
Returns the product path for a known abbreviation.
625941f2f8510a7c17cf9cd1
def calc_manual_numbers(n): <NEW_LINE> <INDENT> return (BASE * pow(FACTOR, n - 1, MOD)) % MOD
>>> calc_manual_numbers(1) 20151125 >>> calc_manual_numbers(2) 31916031 >>> calc_manual_numbers(3) 18749137 >>> calc_manual_numbers(21) 33511524
625941f26fece00bbac2dd16
def send_empty_dir(sock_conn, file_abs_path, dest_file_parent_path): <NEW_LINE> <INDENT> file_name = file_abs_path[len(dest_file_parent_path):] <NEW_LINE> if file_name[0] == '\\' or file_name[0] == '/': <NEW_LINE> <INDENT> file_name = file_name[1:] <NEW_LINE> <DEDENT> file_size = -1 <NEW_LINE> file_md5 = ' ' * 32 <NEW_...
函数功能:将目标文件夹中所含的空文件夹发送给客户端 参数描述: sock_conn 套接字对象 dir_abs_path 空文件夹文件的绝对路径 dest_file_parent_path 待发送文件的文件目录的相对路径(相对于发送的文件夹)
625941f299cbb53fe67931b4
def map_to_md_dir(associative_list): <NEW_LINE> <INDENT> equiv_dict = create_equiv_classes(associative_list) <NEW_LINE> for k,v in equiv_dict.items(): <NEW_LINE> <INDENT> equiv_dict[k] = v + k <NEW_LINE> <DEDENT> return equiv_dict
map from (instrument, API) associative list to {instrument -> md_directory} mapping. :param associative_list: :return:
625941f299cbb53fe67931b5
def _start_acquisition(self, cbuf): <NEW_LINE> <INDENT> assert cbuf <NEW_LINE> if self._late_events: <NEW_LINE> <INDENT> event_time = self._late_events.pop() <NEW_LINE> logging.warning("starting acquisition late by %g s", time.time() - event_time) <NEW_LINE> self.pvcam.pl_exp_start_seq(self._handle, cbuf) <NEW_LINE> re...
Triggers the start of the acquisition on the camera.ini. If the DataFlow is synchronized, wait for the Event to be triggered. cbuf (ctype): buffer to contain the data raises CancelledError if the acquisition must stop
625941f29f2886367277ae58
def match_fixture_not_found_file_location(line): <NEW_LINE> <INDENT> return match_pattern( r'file (?P<file_path>.*), line (?P<line_no>.*)$', line, )
Extract filename path and line number from 'fixture not found' error report. :param line: A string to pattern match against. :returns: A dictionary where the key `file_path` holds the file path and the key `line_no` the line number. If not matched, the dictionary is empty.
625941f292d797404e30475d