code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, BTMassPropResponse): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941c9a4f1c619b28b00b7 |
def __call__(self, outputs): <NEW_LINE> <INDENT> output = outputs[self.output_name] <NEW_LINE> eps = 1e-8 <NEW_LINE> t = TT.clip(self.target, eps, 1 - eps) <NEW_LINE> kl = t * TT.log(t / TT.clip(output, eps, 1 - eps)) <NEW_LINE> if self.weight is not None: <NEW_LINE> <INDENT> return abs(self.weight * kl).sum() / self.w... | Construct the computation graph for this loss function.
Parameters
----------
outputs : dict of Theano expressions
A dictionary mapping network output names to Theano expressions
representing the outputs of a computation graph.
Returns
-------
loss : Theano expression
The values of the loss given the netw... | 625941c9287bf620b61d3ae0 |
def is_dynamic(self): <NEW_LINE> <INDENT> return all(not isinstance(v, Literal) for v in self.container) | Check if a set contains only dynamic values. | 625941c90fa83653e4657038 |
def __generator(d): <NEW_LINE> <INDENT> path = [[x for x in range(16)], [3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12], [15 - x for x in range(16)], [0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15]] <NEW_LINE> for x in path[d]: <NEW_LINE> <INDENT> yield x // 4, x % 4 | Used for looping. When a direction is set, blocks should be
handled in a specific order. | 625941c9a934411ee3751710 |
def _add_dlhist(self, f): <NEW_LINE> <INDENT> self.dlhist[f].append(os.stat(f).st_size) | ダウンロード中のファイルサイズを記録する | 625941c93617ad0b5ed67f74 |
def __call__(self,key,default = None): <NEW_LINE> <INDENT> return self.get(key,default) | Dict("key") | 625941c9d7e4931a7ee9df99 |
def remove_selected_indicator(self, _): <NEW_LINE> <INDENT> current_row = self.current_indicator_list.currentRow() <NEW_LINE> item = self.current_indicator_list.takeItem(current_row) <NEW_LINE> del item | 删除已选的指标 | 625941c9d10714528d5ffd5e |
def parseHtpasswdFile(): <NEW_LINE> <INDENT> lines = [l.rstrip().split(':', 1) for l in file(dissomniag.config.htpasswd.htpasswd_file).readlines()] <NEW_LINE> session = Session() <NEW_LINE> usernamesInHtpasswd = [] <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> username = line[0] <NEW_LINE> usernamesInHtpasswd.appen... | Test parseHtPasswdFile() | 625941c982261d6c526ab51a |
def SetOutsideValue(self, *args): <NEW_LINE> <INDENT> return _itkMaskNegatedImageFilterPython.itkMaskNegatedImageFilterIVF33IUL3IVF33_SetOutsideValue(self, *args) | SetOutsideValue(self, itkVectorF3 outsideValue) | 625941c9236d856c2ad44855 |
def test_has_edge_operator(): <NEW_LINE> <INDENT> assert calc.has_edge_operator("+9") <NEW_LINE> assert calc.has_edge_operator("9+") <NEW_LINE> assert calc.has_edge_operator("+9+") <NEW_LINE> assert calc.has_edge_operator("+9+6") <NEW_LINE> assert calc.has_edge_operator("8+9+") <NEW_LINE> assert not calc.has_edge_opera... | test for unwanted characters at the edges | 625941c9aad79263cf390abc |
def d_head(self, feats, anchors, num_classes, input_shape, training = True): <NEW_LINE> <INDENT> num_anchors = len(anchors) <NEW_LINE> anchors_tensor = tf.reshape(tf.constant(anchors, dtype = tf.float32), [1, 1, 1, num_anchors, 2]) <NEW_LINE> grid_size = tf.shape(feats)[1:3] <NEW_LINE> predictions = tf.reshape(feats, [... | Introduction
------------
根据不同大小的feature map做多尺度的检测,三种feature map大小分别为13x13x1024, 26x26x512, 52x52x256
Parameters
----------
feats: 输入的特征feature map
anchors: 针对不同大小的feature map的anchor
num_classes: 类别的数量
input_shape: 图像的输入大小,一般为416
trainging: 是否训练,用来控制返回不同的值
Returns
------- | 625941c90a366e3fb873e896 |
def picoKPE(KibbleBit, bodies): <NEW_LINE> <INDENT> if 'picoapi' in KibbleBit.config: <NEW_LINE> <INDENT> headers = { 'Content-Type': 'application/json', 'PicoAPI-Key': KibbleBit.config['picoapi']['key'] } <NEW_LINE> js = { "texts": [] } <NEW_LINE> a = 0 <NEW_LINE> KPEs = [] <NEW_LINE> for body in bodies: <NEW_LINE> <I... | KPE using picoAPI Text Analysis | 625941c955399d3f05588730 |
def addTwoNumbers(self, l1, l2): <NEW_LINE> <INDENT> sum = 0 <NEW_LINE> i = 0 <NEW_LINE> A = [] <NEW_LINE> while l1 != None or l2 != None: <NEW_LINE> <INDENT> if l1 == None: <NEW_LINE> <INDENT> sum += (l2.val) * (10**i) <NEW_LINE> l2 = l2.next <NEW_LINE> <DEDENT> elif l2 == None: <NEW_LINE> <INDENT> sum += (l1.val) * (... | :type l1: ListNode
:type l2: ListNode
:rtype: ListNode | 625941c94d74a7450ccd4240 |
def selection_sort(array): <NEW_LINE> <INDENT> for i in xrange(len(array)): <NEW_LINE> <INDENT> min_index = i <NEW_LINE> for j in xrange(i+1, len(array)): <NEW_LINE> <INDENT> if array[j] < array[min_index]: <NEW_LINE> <INDENT> min_index = j <NEW_LINE> <DEDENT> <DEDENT> array[i], array[min_index] = array[min_index], arr... | Divides the array in 2 sublist, sorted and unsorted. Left sublist contains
list of sorted elements, right sublist contains list of unsorted elements.
Find the least element and put in sorted sublist. | 625941c9283ffb24f3c5597e |
def add_rows(self, rows): <NEW_LINE> <INDENT> self.resize(rows=self.rows + rows, cols=self.cols) | Adds rows to worksheet.
:param rows: Rows number to add. | 625941c97cff6e4e81117a02 |
@utils.arg('name', metavar='<name>', help='Name of the backup.') <NEW_LINE> @utils.arg('instance', metavar='<instance>', help='UUID of the instance.') <NEW_LINE> @utils.arg('--description', metavar='<description>', default=None, help='An optional description for the backup.') <NEW_LINE> @utils.arg('--parent', metavar='... | Creates a backup. | 625941c93317a56b86939cd6 |
def invalidate_support_access_with_http_info(self, **kwargs): <NEW_LINE> <INDENT> local_var_params = locals() <NEW_LINE> all_params = [ ] <NEW_LINE> all_params.extend( [ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout', '_request_auth', '_headers' ] ) <NEW_LINE> for key, val in six.iteritem... | [EARLY ACCESS] InvalidateSupportAccess: Revoke any FINBOURNE support access to your account # noqa: E501
This will result in a loss of access to your data for all FINBOURNE support agents # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req... | 625941c98e7ae83300e4b049 |
def pytest_runtest_setup(item): <NEW_LINE> <INDENT> if item.config.getoption('--all'): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if item.config.getoption('--integration'): <NEW_LINE> <INDENT> if 'integration' not in item.keywords: <NEW_LINE> <INDENT> pytest.skip('skipping non integration te... | Filter tests
'' (no option): Run all non integration tests
'--integration' Run integration tests only
'--fast': Run fast tests only
'--all': Run all tests | 625941c921bff66bcd6849d0 |
def mjd_toiso(mjd=0.0): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return Time(mjd+2400000.5, format='jd', precision=3).iso <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> return '' | return ISO or '' | 625941c94f88993c3716c0e4 |
def get_userByid(self, user_id: object) -> object: <NEW_LINE> <INDENT> cur.execute("SELECT firstname,lastname,othername,PhoneNumber,passportUrl FROM tbl_users where id = %s", (user_id,)) <NEW_LINE> row = cur.fetchall() <NEW_LINE> size = len(row) <NEW_LINE> if size > 0: <NEW_LINE> <INDENT> return make_response(jsonify({... | This method returns a specific user by id | 625941c963d6d428bbe4456c |
def add(key, value): <NEW_LINE> <INDENT> pass | Add role/roles to a principal(key). It will keep the previous roles.
| 625941c9fff4ab517eb2f4b8 |
def ts_train_test_normalize(all_data, time_steps, for_periods): <NEW_LINE> <INDENT> ts_train = all_data[:'2019'].iloc[:, 0:1].values <NEW_LINE> ts_test = all_data[f'{endYear}':].iloc[:, 0:1].values <NEW_LINE> ts_train_len = len(ts_train) <NEW_LINE> ts_test_len = len(ts_test) <NEW_LINE> from sklearn.preprocessing import... | input:
data: dataframe with dates and price data
output:
X_train, y_train: data from 2013/1/1-2018/12/31
X_test: data from 2019 -
sc: insantiated MinMaxScaler object fit to the training data | 625941c924f1403a92600be4 |
def script_user_exists(): <NEW_LINE> <INDENT> script_users = User.objects.filter(username=SCRIPT_USER) <NEW_LINE> assert script_users.count() <= 1, Errors.MULTIPLE_USERS_EXIST <NEW_LINE> return script_users.count() == 1 | Has the script user been created? | 625941c9460517430c394203 |
def __init__(self, device): <NEW_LINE> <INDENT> self.device = device <NEW_LINE> self.api = device.apis.loadables | Creates a new M0 coprocessor control object. | 625941c9a17c0f6771cbe0cd |
@fix_biclass_wrapper <NEW_LINE> def gather(ary, indexes): <NEW_LINE> <INDENT> ary = array_manipulation.flatten(array_create.array(ary)) <NEW_LINE> if is_scalar(indexes): <NEW_LINE> <INDENT> indexes = [indexes] <NEW_LINE> <DEDENT> indexes = array_create.array(indexes, dtype=numpy.uint64, bohrium=True) <NEW_LINE> ret = a... | gather(ary, indexes)
Gather elements from 'ary' selected by 'indexes'.
The values of 'indexes' are absolute indexed into a flatten 'ary'
The shape of the returned array equals indexes.shape.
Parameters
----------
ary : array_like
The array to gather elements from.
indexes : array_like, interpreted as integers
... | 625941c90c0af96317bb8264 |
def writeTimeTestCode(self,buff): <NEW_LINE> <INDENT> buff.writeIndented("if t>=%(startTime)s and %(name)s.playing!=visual.FINISHED:\n" %(self.params)) | Write the code for each frame that tests whether the component is being
drawn/used. | 625941c90383005118ecf65f |
def create_optimization_pass(self, parameters_and_grads, loss, startup_program=None): <NEW_LINE> <INDENT> program = loss.block.program <NEW_LINE> self._dtype = loss.dtype <NEW_LINE> with program_guard(program, startup_program): <NEW_LINE> <INDENT> global_block = framework.default_main_program().global_block() <NEW_LINE... | Add optimization operators to update gradients to variables.
Args:
loss(Variable): the target that this optimization is for.
parameters_and_grads(list(tuple(Variable, Variable))):
a list of (variable, gradient) pair to update.
Returns:
return_op_list: a list of operators that will complete one step of
optim... | 625941c97d43ff24873a2d1d |
def visit_list (self,aList): <NEW_LINE> <INDENT> assert isinstance(aList,(list,tuple)),repr(aList) <NEW_LINE> for z in aList: <NEW_LINE> <INDENT> self.visit(z) <NEW_LINE> <DEDENT> return None | Visit all ast nodes in aList. | 625941c9a05bb46b383ec89f |
def createReaction(mod): <NEW_LINE> <INDENT> CBQt4.createReaction(mod) | Load the QT4 reaction creator widget
- *mod* a PySCeS CBMPy model instance | 625941c9ac7a0e7691ed414a |
def _get_time_diff(data): <NEW_LINE> <INDENT> return data.index[1] - data.index[0] | Generates the time difference used to determine granularity and
to generate the period
data : pandas DataFrame
composed of input data | 625941c915baa723493c3ff1 |
def pushBack(self, new_element): <NEW_LINE> <INDENT> if self.tail: <NEW_LINE> <INDENT> self.tail.next = new_element <NEW_LINE> self.tail = new_element <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.head = self.tail = new_element | add to back,also known as append
Arguments:
- new_element: an object that reference to new element to be added | 625941c9cc40096d615959cd |
def correlation(self, other, use_binning=False, assert_is_similar_symmetry=True): <NEW_LINE> <INDENT> if (assert_is_similar_symmetry): <NEW_LINE> <INDENT> assert self.is_similar_symmetry(other) <NEW_LINE> <DEDENT> assert self.is_real_array() <NEW_LINE> assert other.is_real_array() <NEW_LINE> assert not use_binning or s... | Calculate correlation coefficient between two arrays (either globally or
binned).
:param other: another array of real numbers
:param use_binning: calculate CC in resolution bins (default = calculate
a single global value)
:param assert_is_similar_symmetry: check that arrays have compatible
... | 625941c9c4546d3d9de72ab0 |
def getDbRecord(self): <NEW_LINE> <INDENT> return self.__dbRecord | Return the DbRecord for this version. | 625941c9004d5f362079a3b0 |
def combinationSum(self, candidates, target): <NEW_LINE> <INDENT> self.res = [] <NEW_LINE> tmp = [] <NEW_LINE> self.helper(sorted(candidates),target,tmp,0) <NEW_LINE> return self.res | :type candidates: List[int]
:type target: int
:rtype: List[List[int]] | 625941c95fdd1c0f98dc02b0 |
def __init__(self, diameter, xPos, yPos, colour, app): <NEW_LINE> <INDENT> super(Circle, self).__init__(xPos, yPos, colour, app) <NEW_LINE> self.diameter = diameter | Inicialização.
Parâmetros:
diameter (int): Diâmetro do círculo (em pixels).
xPos (int): distância horizontal (em pixels) entre borda esquerda da janela e
a forma geométrica.
yPos (int): distância vertical (em pixels) entre borda superior da janela e
a forma geométrica.
colour (str): designa a ... | 625941c98c3a873295158437 |
def remote_run(remote, cmd, logfile=None, ms_timeout=-1): <NEW_LINE> <INDENT> reactor = Reactor() <NEW_LINE> proc = RemoteRun(reactor=reactor, remote=remote, cmd=cmd, logfile=logfile) <NEW_LINE> with proc: <NEW_LINE> <INDENT> while reactor.run(ms_timeout) > 0: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> <DEDENT> retur... | Run `cmd` on remote.host as remote.username
Log execution output into `logfile` if not None.
Wait `ms_timeout` for execution to complete.
:param RemoteConfiguration remote: The connection parameters
:param str cmd: str A binary or bash-compatible expression
:param file logfile: A file object used to log shell executi... | 625941c90383005118ecf660 |
def enable_input(self): <NEW_LINE> <INDENT> self.is_likes = False <NEW_LINE> self.is_playlist = False <NEW_LINE> self.artist.setDisabled(False) <NEW_LINE> self.name.setDisabled(False) | Enable artist, and name after a playlist | 625941c9656771135c3eb8eb |
def monster_weakness_save(row): <NEW_LINE> <INDENT> if row[0] == '_id': <NEW_LINE> <INDENT> print('header') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> monster_num = Monster.objects.get(key=row[1]) <NEW_LINE> fire = lo_to_hi(row[3]) <NEW_LINE> water = lo_to_hi(row[4]) <NEW_LINE> thunder = lo_to_hi(row[5]) <NEW_LINE> ... | Create Weakness Object. | 625941c9d58c6744b4257cdd |
def connect(self): <NEW_LINE> <INDENT> self.db = MySQLdb.connect(self.host, self.user, self.passw, self.dbname, cursorclass=MySQLdb.cursors.DictCursor, use_unicode=True, charset='utf8', init_command='SET NAMES UTF8') | Connect to db | 625941c9bd1bec0571d906ac |
def __call__(self, y_pred, y_true, dim=1, threshold=None): <NEW_LINE> <INDENT> if threshold: <NEW_LINE> <INDENT> y_pred = _binarize(y_pred, threshold) <NEW_LINE> <DEDENT> return torch.mean((y_pred - y_true) ** 2) | args:
y_true : 4-d ndarray in [batch_size, channels, img_rows, img_cols]
y_pred : 4-d ndarray in [batch_size, channels, img_rows, img_cols]
threshold : [0.0, 1.0]
return mean_squared_error, smaller the better | 625941c9ac7a0e7691ed414b |
def load_data_person(pickle_filename) -> dict: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open(pickle_filename, "rb") as f: <NEW_LINE> <INDENT> visage_connu = pickle.load(f) <NEW_LINE> <DEDENT> <DEDENT> except: <NEW_LINE> <INDENT> print("error when loading pickle") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> p... | Charge le fichier .pkl contenant les features des visages déjà vu.
Args:
pickle_filename (.pkl): fichier contenant les features des visages enregistrés.
return:
visage_connu (dict): le noms en clefs et
en valeurs les caractéristiques des visages des personnes déjà connnus | 625941c9adb09d7d5db6c80d |
@bot.message_handler(commands=['create']) <NEW_LINE> def create(message): <NEW_LINE> <INDENT> bot.send_message(message.chat.id, str(random.choice(ccreate)), reply_markup=markup_help) <NEW_LINE> periphrase_step[message.chat.id] = WILL_YOU_HELP_CREATE | При выборе команды create пользователь получает рандомный перифраз. | 625941c9462c4b4f79d1d74d |
def is_impacted(self): <NEW_LINE> <INDENT> coords_obus = self.get_coords(self.obus_img, self.obus) <NEW_LINE> coords_cible = self.get_coords(self.cible_img, self.cible) <NEW_LINE> if (coords_cible[0] <= coords_obus[0] <= coords_cible[2]) and (coords_cible[1] <= coords_obus[1] <= coords_cible[3]): <NEW_LINE> <INDENT> re... | Si une collision est repérée | 625941c95fc7496912cc39fb |
def show_check_subproject(request, name, project, subproject): <NEW_LINE> <INDENT> subprj = get_object_or_404( SubProject, slug=subproject, project__slug=project ) <NEW_LINE> subprj.check_acl(request) <NEW_LINE> try: <NEW_LINE> <INDENT> check = CHECKS[name] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> raise... | Show checks failing in a subproject. | 625941c9fbf16365ca6f6240 |
def _add_bookmark_item(self): <NEW_LINE> <INDENT> item = self._make_menu_item('Bookmark This Page', 'bookmark-new-symbolic', show_icon=True) <NEW_LINE> item.connect('activate', lambda itm: self.bookmark_page()) <NEW_LINE> self.append(item) <NEW_LINE> self.append(Gtk.SeparatorMenuItem()) | Put a bookmark page at top of main menu. | 625941c932920d7e50b2824c |
def sort_values(self, return_indexer=False, ascending=True): <NEW_LINE> <INDENT> _as = self.argsort() <NEW_LINE> if not ascending: <NEW_LINE> <INDENT> _as = _as[::-1] <NEW_LINE> <DEDENT> sorted_index = self.take(_as) <NEW_LINE> if return_indexer: <NEW_LINE> <INDENT> return sorted_index, _as <NEW_LINE> <DEDENT> else: <N... | Return a sorted copy of the index.
Return a sorted copy of the index, and optionally return the indices
that sorted the index itself.
Parameters
----------
return_indexer : bool, default False
Should the indices that would sort the index be returned.
ascending : bool, default True
Should the index values be s... | 625941c9d8ef3951e32435ba |
def computeValue(self, capture): <NEW_LINE> <INDENT> prePosition = [0,0,0] <NEW_LINE> obj_array = capture.getObjectArray() <NEW_LINE> self.value = [] <NEW_LINE> for i in range(len(obj_array)) : <NEW_LINE> <INDENT> obj_data = obj_array[i] <NEW_LINE> obj_position = obj_data.position <NEW_LINE> distance = math.sqrt((obj_p... | Computes the distances between each detected person and the previous detected person (first person compared to 0,0,0). | 625941c9cb5e8a47e48b7b28 |
def angle(x1: float, x2: float, y1: float, y2: float) -> float: <NEW_LINE> <INDENT> dx, dy = x2 - x1, y2 - y1 <NEW_LINE> h = (dy ** 2 + dx ** 2) ** 0.5 <NEW_LINE> theta = math.degrees(math.acos(dx / h)) <NEW_LINE> if dy < 0: <NEW_LINE> <INDENT> theta = math.degrees(math.acos(-dx / h)) <NEW_LINE> theta += 180 <NEW_LINE>... | Calcs angle (0-360) between 2 points (relative to the first point)
with both points' x and y coordinates. | 625941c94f88993c3716c0e5 |
def FeeReport(self, request, context): <NEW_LINE> <INDENT> context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) | * lncli: `feereport`
FeeReport allows the caller to obtain a report detailing the current fee
schedule enforced by the node globally for each channel. | 625941c9cc40096d615959ce |
def get_extract(self, chars=500): <NEW_LINE> <INDENT> return self.body[:chars-3]+"..." | Return an extract of given size from this article.
Use this method to retrieve the body as it can be overriden by
subclasses to give the expected result for each type of article.
Keywords arguments:
chars -- Length of extract in number of characters (default 100) | 625941c98a349b6b435e81f0 |
def conv_forward_naive(x, w, b, conv_param): <NEW_LINE> <INDENT> out = None <NEW_LINE> pad = conv_param['pad'] <NEW_LINE> stride = conv_param['stride'] <NEW_LINE> N=x.shape[0] <NEW_LINE> F=w.shape[0] <NEW_LINE> Houtx=int(((x.shape[2]+2*pad-w.shape[2])/stride)+1) <NEW_LINE> Houty=int(((x.shape[3]+2*pad-w.shape[3])/strid... | A naive implementation of the forward pass for a convolutional layer.
The input consists of N data points, each with C channels, height H and width
W. We convolve each input with F different filters, where each filter spans
all C channels and has height HH and width HH.
Input:
- x: Input data of shape (N, C, H, W)
- ... | 625941c999cbb53fe6792c64 |
def read_data(): <NEW_LINE> <INDENT> with h5.File(os.path.join(DATADIR, DATAFILE), 'r') as datafile: <NEW_LINE> <INDENT> ca = {str(key): np.asarray(value, dtype=np.float64) for key, value in datafile['Ca'].items()} <NEW_LINE> Vm = {str(key): np.asarray(value, dtype=np.float64) for key, value in datafile['Vm'].items()} ... | Read the file contents in custom format. This format has the following groups:
/Ca : Group containing [Ca2+] in mM of a fraction of the
cells. Each dataset is named after the cell it is recorded
from.
/Vm : Group containing Vm in Volt.
/bias_current : Group containing bias currents for each
... | 625941c9e1aae11d1e749d33 |
def invisible_visit(self, node): <NEW_LINE> <INDENT> raise nodes.SkipNode | Invisible nodes should be ignored. | 625941c960cbc95b062c65c0 |
def modify_width(self, delta): <NEW_LINE> <INDENT> self._width = self._width + delta <NEW_LINE> if self._width > 0: <NEW_LINE> <INDENT> self._width = self._width + delta <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise ValueError('Unable to modify width. Enter another value.') | This method modifies the width of a given rectangle | 625941c9b7558d58953c4f93 |
def test_a_small_file(self): <NEW_LINE> <INDENT> filename = 'E:\\az.rar' <NEW_LINE> size = os.stat(filename).st_size <NEW_LINE> channel = SwiftUploadChannel.SwiftUploadChannel(size , server_url="https://eu01-auth.webzilla.com:5000/v2.0" , username="3186" , tennant_name="2344" , password = "icafLFsmAOswwISn", ... | test1 desctiption | 625941c967a9b606de4a7f37 |
def playHand(hand, wordList, n): <NEW_LINE> <INDENT> total = 0 <NEW_LINE> while calculateHandlen(hand) > 0: <NEW_LINE> <INDENT> print("Current hand: ", end='') <NEW_LINE> displayHand(hand) <NEW_LINE> word = input('Enter word, or a "." to indicate that you are finished: ') <NEW_LINE> if word != '.': <NEW_LINE> <INDENT> ... | Allows the user to play the given hand, as follows:
* The hand is displayed.
* The user may input a word or a single period (the string ".")
to indicate they're done playing
* Invalid words are rejected, and a message is displayed asking
the user to choose another word until they enter a valid word or "."
* When ... | 625941c9b545ff76a8913e94 |
def superimposearr(QMpixarray, allregs=True, crop=True): <NEW_LINE> <INDENT> fullpath= filedialog.askopenfilename(title='Select SE image', filetypes=[("JPG","*.jpg")]) <NEW_LINE> (directory, filename)=os.path.split(fullpath) <NEW_LINE> jpgimage=Image.open(filename) <NEW_LINE> draw=ImageDraw.Draw(jpgimage) <NEW_LINE> if... | Superimpose pix arrays (boundaries or all boxes) on SE image
| 625941c944b2445a33932113 |
def post(self, request, *args, **kwargs): <NEW_LINE> <INDENT> body = utils.body_to_dict(request.body, self.POST_BODY_SCHEMA) <NEW_LINE> if not body: <NEW_LINE> <INDENT> return HttpResponseBadRequest("Body required") <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> result = Stubs.request_user_deletion(request, body, ) <NEW_... | :param self: A RequestUserDeletion instance
:param request: An HttpRequest | 625941c93346ee7daa2b2de8 |
def nextSteps(level): <NEW_LINE> <INDENT> nextStep = input('Go to next quiz or exit? (next / exit): ').lower() <NEW_LINE> if nextStep == 'next': <NEW_LINE> <INDENT> if level == 'easy': <NEW_LINE> <INDENT> initQuiz('medium') <NEW_LINE> <DEDENT> elif level == 'medium': <NEW_LINE> <INDENT> initQuiz('hard') <NEW_LINE> <DED... | We have completed the quiz, now it's time for the student to figure out what
they want to do next. They can exit or select the next level.
If they are at the end, they can choose to start over. | 625941c950485f2cf553ce17 |
def is_valid(self): <NEW_LINE> <INDENT> return all([ self._check(self.edges[0], self.edges[1], self.edges[2]), self._check(self.edges[0], self.edges[2], self.edges[1]), self._check(self.edges[1], self.edges[2], self.edges[0]) ]) | combinations
e1 e2 > e3
e1 e3 > e2
e2 e3 > e1 | 625941c973bcbd0ca4b2c0f4 |
def execute_proxy(self, action: ActionProxy) -> AddonExecutionResponse: <NEW_LINE> <INDENT> operation_result = self.send_request( "POST", urljoin(self._remote_address, Endpoint.AddonExecution.value), self._create_action_proxy_payload(action), ) <NEW_LINE> if operation_result.status_code == HTTPStatus.NOT_FOUND: <NEW_LI... | Sends a custom action to the Agent
Args:
action (ActionProxy): The custom action to be executed
Returns:
AddonExecutionResponse: object containing the result of the action execution | 625941c910dbd63aa1bd2c21 |
def norm_fn(data): <NEW_LINE> <INDENT> norm = data - data.min() <NEW_LINE> norm = norm / norm.max() <NEW_LINE> if mode == '-1,1': <NEW_LINE> <INDENT> norm = norm - 0.5 <NEW_LINE> norm = norm * 2 <NEW_LINE> <DEDENT> elif mode == '0,1': <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise ValueErr... | Returns the input data normalized to the range
Parameters
----------
data : np.ndarray
data which should be normalized
Returns
-------
np.ndarary
normalized data | 625941c91d351010ab855b99 |
def name(self): <NEW_LINE> <INDENT> return _gsm.gsm_receiver_cf_sptr_name(self) | name(self) -> string | 625941c9377c676e91272226 |
def test_context_qa_init(self): <NEW_LINE> <INDENT> qas: List[QuestionAnswer] = [ QuestionAnswer( "qa_%d" % i, "question %d" % i, [Answer("c%d" % i, 3 * i, self.tokenizer, self.processor)], self.tokenizer, self.processor, ) for i in range(2) ] <NEW_LINE> context_text = "c0 c1 c2" <NEW_LINE> context_tokens = self.tokeni... | Tests that ContextQuestionAnswer objects are initialized properly | 625941c9099cdd3c635f0cd8 |
def _procure_exception_message_line(self): <NEW_LINE> <INDENT> message_line = self.exception_message <NEW_LINE> message_line = message_line.replace(":", ";") <NEW_LINE> message_line = message_line.replace("\n", " ") <NEW_LINE> return message_line | This method creates the string version of the exception message, that can be put as a line in the body of
the form. The Commanding protocol works by separating items of the body by new lines and separating the key
from the value with a ':' character, thus this method removes those character from the message string and
... | 625941c9d6c5a102081440c8 |
def mean_not_trainable(self): <NEW_LINE> <INDENT> self.mean.requires_grad = False | Makes the mean a non-trainable variable.
:return: None | 625941c994891a1f4081bb26 |
def test_read0(self): <NEW_LINE> <INDENT> with zipfile_aes.AESZipFile(TESTFN, mode="w") as zipf: <NEW_LINE> <INDENT> zipf.writestr("foo.txt", "O, for a Muse of Fire!") <NEW_LINE> with zipf.open("foo.txt") as f: <NEW_LINE> <INDENT> for i in range(FIXEDTEST_SIZE): <NEW_LINE> <INDENT> self.assertEqual(f.read(0), b'') <NEW... | Check that calling read(0) on a ZipExtFile object returns an empty
string and doesn't advance file pointer. | 625941c9a8370b771705291e |
def test_tasks_are_correctly_scheduled(self): <NEW_LINE> <INDENT> tjp_sched = TaskJugglerScheduler(compute_resources=True) <NEW_LINE> from stalker import Studio <NEW_LINE> test_studio = Studio( name='Test Studio', now=datetime.datetime(2013, 4, 16, 0, 0, tzinfo=pytz.utc) ) <NEW_LINE> test_studio.start = date... | testing if the tasks are correctly scheduled
| 625941c98a43f66fc4b540e4 |
def pc_noutput_items(self): <NEW_LINE> <INDENT> return _filter_swig.interp_fir_filter_fff_sptr_pc_noutput_items(self) | pc_noutput_items(interp_fir_filter_fff_sptr self) -> float | 625941c930bbd722463cbe43 |
def _find_names_in_stmt(stmt: AST) -> List[str]: <NEW_LINE> <INDENT> if isinstance(stmt, ns.SimpleStmt): <NEW_LINE> <INDENT> return _find_names_in_stmt(stmt.stmt) <NEW_LINE> <DEDENT> elif isinstance(stmt, ns.FuncDef): <NEW_LINE> <INDENT> return [stmt.name.text] <NEW_LINE> <DEDENT> elif isinstance(stmt, ns.ClassDef): <N... | Determines whether a statement is of the kind that will bind a name (or names) and binds all returns all such names
declared by the statement. Returns an empty list if the statement would not bind any names.
:param stmt: the statement to try to extract names from
:return: a list of extracted names | 625941c930dc7b76659019e5 |
def find_backedges(graph, block=None, seen=None, seeing=None): <NEW_LINE> <INDENT> backedges = [] <NEW_LINE> if block is None: <NEW_LINE> <INDENT> block = graph.startblock <NEW_LINE> <DEDENT> if seen is None: <NEW_LINE> <INDENT> seen = {block: None} <NEW_LINE> <DEDENT> if seeing is None: <NEW_LINE> <INDENT> seeing = {}... | finds the backedges in the flow graph | 625941c9a934411ee3751711 |
def stations_list(request): <NEW_LINE> <INDENT> stations = Station.objects.all() <NEW_LINE> form = StationForm() <NEW_LINE> antennas = Antenna.objects.all() <NEW_LINE> return render(request, 'base/stations.html', {'stations': stations, 'form': form, 'antennas': antennas}) | View to render Stations page. | 625941c96e29344779a62690 |
def nitems_written(self, *args, **kwargs): <NEW_LINE> <INDENT> return _digital_swig.digital_descrambler_bb_sptr_nitems_written(self, *args, **kwargs) | nitems_written(self, unsigned int which_output) -> uint64_t | 625941c9e5267d203edcdd1c |
def _declare_queue_binding(self): <NEW_LINE> <INDENT> queue_expiration = self._pika_engine.rpc_queue_expiration <NEW_LINE> exchange = self._pika_engine.get_rpc_exchange_name( self._target.exchange ) <NEW_LINE> queues_to_consume = [] <NEW_LINE> for no_ack in [True, False]: <NEW_LINE> <INDENT> queue = self._pika_engine.g... | Overrides base method and perform declaration of RabbitMQ exchanges
and queues which correspond to oslo.messaging RPC target
:return Dictionary, declared_queue_name -> no_ack_mode | 625941c9379a373c97cfabc2 |
def _register_main_startup_script(self, qualified_name): <NEW_LINE> <INDENT> desc = self._get_or_create_script('odoo_starter', name=qualified_name)[1] <NEW_LINE> arguments = '%s, %s, version=%r, gevent_script_path=%s' % ( self._relativitize(self._get_server_command()), self._relativitize(self.config_path), self.major_v... | Register main startup script, usually ``start_odoo`` for install.
| 625941c929b78933be1e572b |
def focus_wrapper(tdbp, list_rows): <NEW_LINE> <INDENT> return tdbp.focus_multiprocessing(list_rows) | Wrapper of TDBP.focus() method to be used in parallel multiprocessing TDBP focus.
Wrapper needs to be at top level of module and use an instance of TDBP class to call instance method.
Parameters
----------
tdbp: object (TDBP instance).
TDBP instance to focus image.
list_rows: list of ints.
List containing rows of ... | 625941c960cbc95b062c65c1 |
def event_m20_21_5030(): <NEW_LINE> <INDENT> assert event_m20_21_x31(z198=20213100, z199=40, flag23=221000015, z200=40) <NEW_LINE> EndMachine() <NEW_LINE> Quit() | Elevator_initialization | 625941c92ae34c7f2600d1af |
def user_behavior_statistics(): <NEW_LINE> <INDENT> user_behavior = pd.read_csv(base_path + "buy.csv", sep='\t', header=None, names=['user_id', 'item_id','behavior', 'time']) <NEW_LINE> temp = user_behavior.drop_duplicates(subset=['item_id'], keep='first') <NEW_LINE> print(len(temp['item_id'])) | user_behavior总数量:
clk:176558058
buy:6038697
cart:18621881
collect:5458289
item总数量: 10786748
user:987791 | 625941c9956e5f7376d70eec |
def _createDefault(self, addtorank=True): <NEW_LINE> <INDENT> owner = self.getOwner() <NEW_LINE> default = self.getDefault() <NEW_LINE> a_payload = (self.payloads or [None])[0] <NEW_LINE> if isinstance(a_payload, Fiber): <NEW_LINE> <INDENT> next_default = a_payload.getDefault() <NEW_LINE> <DEDENT> else: <NEW_LINE> <IND... | _createDefault
Obtain the default payload for a fiber. This method goes one
step further than getDefault() because if the default payload
is itself a fiber it creates a Fiber().
Finally, if the current fiber is part of a a non-leaf rank
it (optionally) adds the new fiber into the **next** rank.
TBD: Fold this into a... | 625941c938b623060ff0ae6c |
def get_new_state(current, defs): <NEW_LINE> <INDENT> new_state = current.copy() <NEW_LINE> if defs.get('attrs', []): <NEW_LINE> <INDENT> if "attrs"in new_state: <NEW_LINE> <INDENT> new_state["attrs"] = new_state.get("attrs", [])[:] <NEW_LINE> <DEDENT> for a in defs["attrs"]: <NEW_LINE> <INDENT> ia = invert_attr_label(... | Return new state by applying new specs on to current state
>>> from pprint import pprint as pp
>>> get_new_state({'fg': 'red'}, {'fg': 'blue'})
{'fg': 'blue'}
>>> pp(get_new_state({'fg': 'red'}, {'bg': 'blue'}))
{'bg': 'blue', 'fg': 'red'}
>>> pp(get_new_state({'attrs': ['bold', ]}, {'attrs': ['unbold',]}))
{'attrs'... | 625941c957b8e32f52483518 |
def start_response(*args): <NEW_LINE> <INDENT> outbuf.writelines(args) | Sends args to outbuf | 625941c956ac1b37e626424f |
@pytest.fixture(scope="session", name="hardgame") <NEW_LINE> def fix_hardgame(): <NEW_LINE> <INDENT> with open(path.join("example_games", "hard_nash.json")) as fil: <NEW_LINE> <INDENT> return gamereader.load(fil) | Hard nash game | 625941c97b180e01f3dc487d |
def equal_objects(d1, d2): <NEW_LINE> <INDENT> d1 = dict((k, d1[k]) for k in d1.keys() if k not in NON_COMPARABLE_PROPERTIES and d1[k]) <NEW_LINE> d2 = dict((k, d2[k]) for k in d2.keys() if k not in NON_COMPARABLE_PROPERTIES and d2[k]) <NEW_LINE> return equal_dicts(d1, d2, compare_by_reference=False) | Checks whether two objects are equal. Ignores special object properties (e.g. 'id', 'version') and
properties with None and empty values. In case properties contains a reference to the other object,
only object identities (ids and types) are checked.
:type d1: dict
:type d2: dict
:return: True if passed objects and th... | 625941c95fcc89381b1e173c |
def clean(self): <NEW_LINE> <INDENT> self.number = re.sub(r'\D', '', self.number) | Strip sall non-numeric characters from the phone number. | 625941c931939e2706e4cee9 |
def onTicks(self, ticks): <NEW_LINE> <INDENT> pass | 由子类重载来更新实时持仓和账户信息 | 625941c93c8af77a43ae381e |
@web.route('/book/search') <NEW_LINE> def search(): <NEW_LINE> <INDENT> form = SearchForm(request.args) <NEW_LINE> books = BookCollection() <NEW_LINE> if form.validate(): <NEW_LINE> <INDENT> q = form.q.data.strip() <NEW_LINE> page = form.page.data <NEW_LINE> isbn_or_key = is_isbn_or_key(q) <NEW_LINE> yushu_book = YuShu... | 书籍检索
不缓存,缓存的意义很小,反而会占用内存 | 625941c982261d6c526ab51c |
def noop(dummy, value): <NEW_LINE> <INDENT> return value | Do nothing... | 625941c931939e2706e4ceea |
def _state(self, s): <NEW_LINE> <INDENT> l = len(self.Q) <NEW_LINE> if isinstance(s, (int, long, float)): <NEW_LINE> <INDENT> if s >= l or s < 0 or s != int(s): <NEW_LINE> <INDENT> raise ValueError('State (%s) must be an integer in {0, ..., %s}.' % (s, l-1)) <NEW_LINE> <DEDENT> s = [int(i == s) for i in range(l)] <NEW_... | Convert a pure state (as an integer) to its corresponding characteristic array if passed as a scalar. | 625941c9f9cc0f698b14067a |
@memo <NEW_LINE> def tightest_subscript(): <NEW_LINE> <INDENT> def f(acc): <NEW_LINE> <INDENT> (_,(_,t,_))=acc <NEW_LINE> return Etok(name='apply_sub',etoks=t,raw=acc) <NEW_LINE> <DEDENT> return (c.next_type('APPLYSUB') + c.paren(tightest_term().plus())).treat(f,'tightest_subscript') | Parser for subscript
APPLYSUB handles subscripts coming from a TeX file.
The braces have been converted to ()
In brief,
x_1 is an identifier.
x APPLYSUB (1) is equivalent to x 1 and is the de-TeXed form of x_{1}.
x APPLYSUB (i j) is equivalent to x i j. (This is perhaps a surprise.)
x APPLYSUB ((f j)) is equivalen... | 625941c976e4537e8c3516f0 |
def variable_in_groupping(snv, group_kind, groups, in_union=True, in_all_groups=True, reference_free=True, maf=None, min_num_reads=None, min_reads_per_allele=None): <NEW_LINE> <INDENT> alleles = _get_alleles_for_group(snv.qualifiers['alleles'], groups, group_kind, snv.qualifiers['read_groups'], min_reads_per_allele=min... | It looks if the given snv is variable for the given groups | 625941c98c3a873295158438 |
@app.before_request <NEW_LINE> def before_request(): <NEW_LINE> <INDENT> g.db = models.DATABASE <NEW_LINE> g.db.connect() <NEW_LINE> g.user = current_user | Connect to the db before each request | 625941c9e64d504609d748be |
def ws_100(self, ws, gen_dataset=False): <NEW_LINE> <INDENT> secondary_counts = OrderedDict() <NEW_LINE> overall_column = grand_total_column = ws.dim_colmax <NEW_LINE> for _, models in SHEET_MEDIA_GROUPS: <NEW_LINE> <INDENT> for media_type, model in models.items(): <NEW_LINE> <INDENT> counts = Counter() <NEW_LINE> rows... | Cols: Medium
Rows: Major topic | 625941c9711fe17d825423ec |
def ptc_func(pars, mean): <NEW_LINE> <INDENT> alpha, gain = pars <NEW_LINE> return mean*(1./gain - mean*alpha) | Model for variance vs mean.
See http://adsabs.harvard.edu/abs/2015A%26A...575A..41G. | 625941c924f1403a92600be5 |
def _authenticate(self, user, item, permission, distroseries=None): <NEW_LINE> <INDENT> permissions = self.getPermissions( user, item, permission, distroseries=distroseries) <NEW_LINE> return bool(permissions) | Private helper method to check permissions. | 625941c924f1403a92600be6 |
def get_edges_data(self, key): <NEW_LINE> <INDENT> data_list = [edge[2][key] for edge in self.edges] <NEW_LINE> return data_list | return a list of edges data 'key' | 625941c93346ee7daa2b2de9 |
def close(self): <NEW_LINE> <INDENT> self.keep_running = False | our websock are running in a thread
we use keep_running flg to shutdown the connection | 625941c915fb5d323cde0b8d |
def __init__(self): <NEW_LINE> <INDENT> self.Data = None <NEW_LINE> self.RequestId = None | :param Data: 大Key类型分布详细信息
:type Data: list of BigKeyTypeInfo
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str | 625941c94f6381625f114aba |
@array_function_dispatch(_unary_op_dispatcher) <NEW_LINE> def isalnum(a): <NEW_LINE> <INDENT> return _vec_string(a, bool_, 'isalnum') | Returns true for each element if all characters in the string are
alphanumeric and there is at least one character, false otherwise.
Calls `str.isalnum` element-wise.
For 8-bit strings, this method is locale-dependent.
Parameters
----------
a : array_like of str or unicode
Returns
-------
out : ndarray
Output a... | 625941c957b8e32f52483519 |
def rot_mat(theta) : <NEW_LINE> <INDENT> R_x,R_y,R_z = elementary_rot_mat(theta) <NEW_LINE> R = R_z @ R_y @ R_x <NEW_LINE> return R | Returns the Rotation matrix for the rotation parametrized with theta
Convention rotation around X then around Y then around Z | 625941c9e76e3b2f99f3a88b |
def make_freq_dict(text): <NEW_LINE> <INDENT> dict_ = {} <NEW_LINE> for b in text: <NEW_LINE> <INDENT> if b not in dict_: <NEW_LINE> <INDENT> dict_[b] = 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> dict_[b] += 1 <NEW_LINE> <DEDENT> <DEDENT> return dict_ | Return a dictionary that maps each byte in text to its frequency.
@param bytes text: a bytes object
@rtype: dict{int,int}
>>> d = make_freq_dict(bytes([65, 66, 67, 66]))
>>> d == {65: 1, 66: 2, 67: 1}
True | 625941c9ac7a0e7691ed414c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.