code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def __init__(self): <NEW_LINE> <INDENT> self.Status = None | :param Status: 0-未发送 1-发送中 2-发送结束 3-发送取消
:type Status: int | 625941e966656f66f7cbc652 |
def thumbnail_attachment(request, bookid, attachment, version=None): <NEW_LINE> <INDENT> from django.views import static <NEW_LINE> try: <NEW_LINE> <INDENT> book = models.Book.objects.get(url_title__iexact=bookid) <NEW_LINE> <DEDENT> except models.Book.DoesNotExist: <NEW_LINE> <INDENT> return views.ErrorPage(request, "... | Returns image thumbnail for book attachment.
@param request: Django Request
@param bookid: Book ID
@param attachment: Attachment name | 625941e9a05bb46b383eccc2 |
def _PGMultiButton_AddButton(self, label, id=-2): <NEW_LINE> <INDENT> self.Add(label, id) | A simple wrapper around the PGMultiButton.Add method, for backwards compatibility. | 625941e9a79ad161976cc5ea |
def create_client(self, version=None, service_type=None): <NEW_LINE> <INDENT> from zaqarclient.queues import client as zaqar <NEW_LINE> tenant_id = self.keystone.auth_ref.project_id <NEW_LINE> conf = {"auth_opts": {"backend": "keystone", "options": { "os_username": self.credential.username, "os_password": self.credenti... | Return Zaqar client. | 625941e93d592f4c4ed1d506 |
def validate(self, msg: Message) -> bool: <NEW_LINE> <INDENT> if self.msg_validator: <NEW_LINE> <INDENT> return self.msg_validator.validate_function(msg) <NEW_LINE> <DEDENT> return True | function to validate inputted message | 625941e9dc8b845886cb59dc |
def all_combinations (string): <NEW_LINE> <INDENT> if 'q' in string: <NEW_LINE> <INDENT> flag = True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> flag = False <NEW_LINE> <DEDENT> combi = [] <NEW_LINE> for i in range(3, len(string)+1): <NEW_LINE> <INDENT> combi.extend(itertools.combinations(string, i)) <NEW_LINE> combi... | 文字列 string を与えられると、string に含まれる文字の全ての3文字以上の組み合わせを考える。
string に q が含まれているならば、u も追加しておく。
(なぜなら、q を含む単語は、必ず qu という形で出現するから。) | 625941e9a17c0f6771cbe4f4 |
def has_at_most(self, *args, **kwargs): <NEW_LINE> <INDENT> N, link = args <NEW_LINE> self.constraints.append(Constraint([link], [1], '<=', N, **kwargs)) | A constraint that forces at most N of the variable's (indicator)
links to be active, regardless of its own value. | 625941e907f4c71912b1192a |
def combine_rck(self): <NEW_LINE> <INDENT> pg_pattern_rhythm = [[1 if t0 != 0 else 0 for t0 in t1] for t1 in self.common_pg_patterns[1:]] <NEW_LINE> pg_rhythm_number = len(self.pg_rhythm_data.rhythm_pattern_count) - 1 <NEW_LINE> pg_rhythm_match = np.zeros([2 * pg_rhythm_number, COMMON_PIANO_GUITAR_PATTERN_NUMBER]) <NEW... | 对节奏 根音和和弦进行整合
:return: | 625941e98e05c05ec3eea81e |
def add_values(self, entity, key, parent=None): <NEW_LINE> <INDENT> if isinstance(entity, list): <NEW_LINE> <INDENT> ved = self._get_value_entity_dict(entity, key); <NEW_LINE> sorted_values = sorted(ved, key=lambda value: self._get_number_str(ved[value], parent)) <NEW_LINE> for value in sorted_values: <NEW_LINE> <INDEN... | Add TagLines built from tag values for a given key stored in a TagStore entity or list of
TagStore entities. If 'entity' is a list, all items should be of the same type. | 625941e94e4d5625662d4876 |
def load(self, mapping): <NEW_LINE> <INDENT> self._data = dict(GenericRecipeFormat.default) <NEW_LINE> self._data.update(mapping) <NEW_LINE> return self.verify() | Load the metadata from @mapping. | 625941e9293b9510aa2c3736 |
def _generate_auth_string(user, token): <NEW_LINE> <INDENT> return 'user=%s\1auth=Bearer %s\1\1' % (user, token) | Generates the string to use when authenticating within IMAP | 625941e9cb5e8a47e48b7f48 |
def totalHammingDistance(self, nums): <NEW_LINE> <INDENT> bits = [[0, 0] for _ in xrange(32)] <NEW_LINE> for num in nums: <NEW_LINE> <INDENT> stringNum = format(num, 'b').zfill(32) <NEW_LINE> for i in xrange(32): <NEW_LINE> <INDENT> if stringNum[i] == '0': <NEW_LINE> <INDENT> bits[i][0] += 1 <NEW_LINE> <DEDENT> else: <... | :type nums: List[int]
:rtype: int | 625941e950485f2cf553d241 |
def _small_Helmert_transform_for_OSGB(direction, xa, ya, za): <NEW_LINE> <INDENT> tx = direction * -446.448 <NEW_LINE> ty = direction * +125.157 <NEW_LINE> tz = direction * -542.060 <NEW_LINE> sp = direction * 0.0000204894 + 1 <NEW_LINE> rx = (direction * -0.1502/3600) / 57.29577951308232087679815481410517 <NEW_LINE> r... | Transform 3d planar coordinates to approximate OSGB36 to WGS84.
Formulae as supplied by the OSGB. Designed for +/- 5m accuracy in
most of OSGB area.
`direction` indicates the desired transformation: -1 -> WGS84, +1 -> OSGB36 | 625941e98da39b475bd6541f |
@ensure(lambda result: not result.endswith('\n')) <NEW_LINE> def _serialize_graph(graph: mapry.Graph, go: mapry.Go) -> str: <NEW_LINE> <INDENT> auto_id = mapry.go.generate.AutoID() <NEW_LINE> property_serializations = [ _serialize_property( target_expr="target[{}]".format( mapry.go.generate.escaped_str(prop.json)), val... | Generate the function that serializes the object graph.
:param graph: mapry definition of the object graph
:param go: Go settings
:return: generated code | 625941e96e29344779a62ab5 |
def _copyright(self): <NEW_LINE> <INDENT> return self.copyright | Return the contents of the copyright file. | 625941e9b545ff76a89142bb |
def simulate(self): <NEW_LINE> <INDENT> pass | Simulate a lightcurve from period, Fourier coefficients, pole orientation | 625941e93eb6a72ae02ec98f |
def get_by_key(self, config_key, default=None): <NEW_LINE> <INDENT> if not config_key or not isinstance(config_key, str): <NEW_LINE> <INDENT> return False, default <NEW_LINE> <DEDENT> value = copy.deepcopy(self._config.get(config_key, default)) <NEW_LINE> if not self._prev_config: <NEW_LINE> <INDENT> return True, value... | get the latest sub config by config_key and whether it has changed | 625941e93cc13d1c6d3c781d |
def get_tags (self, user): <NEW_LINE> <INDENT> return self.tags.filter(user=user) | Returns a QuerySet of SiteTags associated with this site
and belonging to `user`.
:param user: user profile
:type user: `UserProfile` | 625941e931939e2706e4d309 |
def reducing(self, workers): <NEW_LINE> <INDENT> result = None <NEW_LINE> isCreated = False <NEW_LINE> for worker in workers: <NEW_LINE> <INDENT> data_file = worker.data_file_name <NEW_LINE> index_file = worker.index_file_name <NEW_LINE> if os.path.isfile(data_file) and os.path.isfile(index_file): <NEW_LINE> <INDENT> f... | master process running reducer function | 625941e9f9cc0f698b140a9d |
def mkdir_p(path): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if not os.path.isdir(path): <NEW_LINE> <INDENT> os.makedirs(path) <NEW_LINE> <DEDENT> <DEDENT> except OSError as exc: <NEW_LINE> <INDENT> if exc.errno == errno.EEXIST and os.path.isdir(path): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <I... | 'mkdir -p' in Python
Original Code came from :
stackoverflow.com/questions/600268/mkdir-p-functionality-in-python
:param path: | 625941e95166f23b2e1a55fe |
def generator_of(size): <NEW_LINE> <INDENT> def make_chunks(enum): <NEW_LINE> <INDENT> for n in xrange(1 + len(enum) / size): <NEW_LINE> <INDENT> yield enum[n*size:(n+1)*size] <NEW_LINE> <DEDENT> <DEDENT> def generator(fn): <NEW_LINE> <INDENT> @wraps(fn) <NEW_LINE> def _fn(data, *args, **kwargs): <NEW_LINE> <INDENT> ch... | this decorator factory turns the input into a generator (if it's not
already so), then process each chunk and yields it as function output. | 625941e9fbf16365ca6f6673 |
def fit(X,y): <NEW_LINE> <INDENT> global margin_scale <NEW_LINE> d_mat = margin_scale*pdist_func(X) <NEW_LINE> p = Pool(cpu_count()) <NEW_LINE> row_range = list(range(len(d_mat))) <NEW_LINE> args = list(zip(d_mat,row_range,[y for i in row_range])) <NEW_LINE> with timer("...getting weibulls"): <NEW_LINE> <INDENT> weibul... | Analogous to scikit-learn's fit method. | 625941e9e76e3b2f99f3acaa |
def volumes(self, codim): <NEW_LINE> <INDENT> return self._volumes(codim) | `retval[e]` is the (dim-`codim`)-dimensional volume of the codim-`codim` entity with global index `e`. | 625941e92c8b7c6e89b35c63 |
def py2_earth_hours_left(start_date=BITE_CREATED_DT): <NEW_LINE> <INDENT> return _remaining(start_date) | Return how many hours, rounded to 2 decimals, Python 2 has
left on Planet Earth (calculated from start_date) | 625941e98e7ae83300e4b474 |
def get_line_ABC_y(line, x): <NEW_LINE> <INDENT> a, b, c = line[0], line[1], line[2] <NEW_LINE> if b == 0: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> return (-c - a * x) / b | line: a*x + b*y + c = 0, line=[a, b, c] | 625941e98c3a873295158866 |
def text_coverage_over_views(ax, ts, end_ct=5): <NEW_LINE> <INDENT> song_to_lyrics, song_to_ann_lyrics = make_song_to_lyrics(annotation_info) <NEW_LINE> song_to_score = compute_song_to_score(song_to_lyrics) <NEW_LINE> song_to_views = {s['url_name']:s['views'] for s in song_info_gen()} <NEW_LINE> ret = collections.defau... | song coverage against views, split by lyric originality
| 625941e99b70327d1c4e127d |
def delete(self, key): <NEW_LINE> <INDENT> bucket, itemlink = self._finditem(key) <NEW_LINE> if itemlink is not None: <NEW_LINE> <INDENT> self._array[bucket].remove(itemlink._value) <NEW_LINE> if len(self._array[bucket]) == 0: <NEW_LINE> <INDENT> self._array[bucket] = None <NEW_LINE> <DEDENT> self._size -= 1 <NEW_LINE>... | Deletes the (key, value) tuple pair in a hashmap instance. If no such
key exists in the hashmap, then raises a KeyError exception. | 625941e99f2886367277ad2f |
def SafeName(filename): <NEW_LINE> <INDENT> return "".join([c for c in filename if c.isalpha() or c.isdigit() or c in [' ', '_'] ]).rstrip() | Sanitize a filename if it contains illegal characters. | 625941e9460517430c39461e |
def testObjective(self): <NEW_LINE> <INDENT> pass | Test Objective | 625941e97cff6e4e81117e2b |
def to_representation(self, instance): <NEW_LINE> <INDENT> ret = super(PostSerializer, self).to_representation(instance) <NEW_LINE> content_type = ret.pop('content_type') <NEW_LINE> ret['content-type'] = content_type <NEW_LINE> return ret | Object instance -> Dict of primitive datatypes. | 625941e956b00c62f0f14b02 |
def _test_evaluation_weights(self, n_classes): <NEW_LINE> <INDENT> label = [1, 0] <NEW_LINE> age = [17., 18.] <NEW_LINE> weights = [1., 2.] <NEW_LINE> bias = [-1.0] if n_classes == 2 else [-1.0] * n_classes <NEW_LINE> initial_global_step = 100 <NEW_LINE> with ops.Graph().as_default(): <NEW_LINE> <INDENT> variables.Vari... | Tests evaluation with weights. | 625941e9ab23a570cc25062c |
def get_transformer_rgb_image(input_shape, mean_bgr_value): <NEW_LINE> <INDENT> transformer = caffe.io.Transformer({'data': input_shape}) <NEW_LINE> transformer.set_transpose('data', (2,0,1)) <NEW_LINE> transformer.set_mean('data', mean_bgr_value) <NEW_LINE> transformer.set_raw_scale('data', 255) <NEW_LINE> transformer... | Return a caffe.Transformer class that modify an array to preprocess the
input of a network.
Parameters
----------
input_shape: array-like of 2 int
input shape of the network
mean_bgr_value: :class:`numpy.ndarray` of 3 int
Set the mean to subtract for centering the data.
Must be in BGR order and in [0, 255]... | 625941e926238365f5f0f31b |
def is_valid_degree_sequence_erdos_gallai(deg_sequence): <NEW_LINE> <INDENT> if deg_sequence==[]: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if not nx.utils.is_list_of_ints(deg_sequence): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if min(deg_sequence)<0: <NEW_LINE> <INDENT> return False <NEW_LINE> <D... | Returns `True` if `deg_sequence` is a valid degree sequence.
A degree sequence is valid if some graph can realize it.
Validation proceeds via the Erdős-Gallai algorithm.
Worst-case run time is: O( n**2 )
Parameters
----------
deg_sequence : list
A list of integers where each element specifies the degree of a no... | 625941e97d43ff24873a3149 |
def write(self, tf_idf_file): <NEW_LINE> <INDENT> print ("<TFIDF>", file=tf_idf_file) <NEW_LINE> for tup, value in self.tf_idf.iteritems(): <NEW_LINE> <INDENT> term, doc = tup <NEW_LINE> print("{order} {term} {doc} {tfidf}".format( order=len(term), term=" ".join(term), doc=doc, tfidf=value), file=tf_idf_file) <NEW_LINE... | Writes TFIDF object to file. | 625941e93317a56b8693a0f3 |
def test_load_from_file(test_data, class_testsuite, platforms_list, all_testcases_dict, caplog, tmpdir_factory): <NEW_LINE> <INDENT> with pytest.raises(SystemExit): <NEW_LINE> <INDENT> class_testsuite.load_from_file(test_data +"twister_test.csv") <NEW_LINE> <DEDENT> assert "Couldn't find input file with list of tests."... | Testing load_from_file function of TestSuite class in Twister | 625941e94c3428357757c7cb |
def find_fan(self, fan_name): <NEW_LINE> <INDENT> raise NotImplementedError | Get a specific fan from its name. | 625941e9187af65679ca55c6 |
def __init__(self, rng, input, n_in, n_out, W=None, b=None, activation=T.tanh): <NEW_LINE> <INDENT> self.input = input <NEW_LINE> if W is None: <NEW_LINE> <INDENT> W_values = numpy.asarray( rng.uniform( low=-numpy.sqrt(6. / (n_in + n_out)), high=numpy.sqrt(6. / (n_in + n_out)), size=(n_in, n_out) ), dtype=theano.config... | Typical hidden layer of a MLP: units are fully-connected and have
sigmoidal activation function. Weight matrix W is of shape (n_in,n_out)
and the bias vector b is of shape (n_out,).
NOTE : The nonlinearity used here is tanh
Hidden unit activation is given by: tanh(dot(input,W) + b)
:type rng: numpy.random.RandomStat... | 625941e9e1aae11d1e74a162 |
def process_main_playlist(url_to_m3u8): <NEW_LINE> <INDENT> DESCRIPTION["origin_url"] = url_to_m3u8 <NEW_LINE> main_list_filename = process_playlist_by_uri(url_to_m3u8) <NEW_LINE> downloaded_files = DOWNLOADER.downloaded_files_by_url() <NEW_LINE> for u in downloaded_files: <NEW_LINE> <INDENT> downloaded_files[u] = os.p... | Process main playlist and save it to main.m3u8
Additional information to description.json
:type url_to_m3u8: Text
:rtype: None | 625941e92ae34c7f2600d5d6 |
def add(self, other, alpha, beta, cutoff=1.e-15): <NEW_LINE> <INDENT> L = self.L <NEW_LINE> assert (other.L == L and L >= 2) <NEW_LINE> assert self.finite <NEW_LINE> assert self.bc == other.bc <NEW_LINE> self._gauge_compatible_vL_vR(other) <NEW_LINE> legs = ['vL', 'vR'] + self._p_label <NEW_LINE> alpha = alpha * self.n... | Return an MPS which represents ``alpha|self> + beta |others>``.
Works only for 'finite', 'segment' boundary conditions.
For 'segment' boundary conditions, the virtual legs on the very left/right are
assumed to correspond to each other (i.e. self and other have the same state outside of
the considered segment).
Takes i... | 625941e9236d856c2ad44c87 |
def getType(self): <NEW_LINE> <INDENT> return _AriaPy.ArSocket_getType(self) | getType(self) -> Type | 625941e9004d5f362079a7d6 |
def is_clipped(sig): <NEW_LINE> <INDENT> bool = False <NEW_LINE> sig = np.abs(sig) <NEW_LINE> max = np.max(np.round(sig, decimals=2)) <NEW_LINE> sig = sig[np.where(sig==max)] <NEW_LINE> if len(sig)>1: <NEW_LINE> <INDENT> bool=True <NEW_LINE> <DEDENT> return bool | Determines if a signal is clipped
sig: AE signal (N*1 array-like)
return: bool (boolean) | 625941e9167d2b6e3121903b |
def encode(self, data, encryptAlgorithm): <NEW_LINE> <INDENT> enc = data <NEW_LINE> if encryptAlgorithm == ENC_ALG_NOT: <NEW_LINE> <INDENT> enc = ''.join([chr(~ord(b) & 0xff) for b in data]) <NEW_LINE> <DEDENT> return enc | encode data based on algorithm, return a string encoded
@param data: original data string
@param encryptAlgorithm: algorithm id
@return: encoded content, string | 625941e924f1403a92601008 |
def test_feature_names_1(): <NEW_LINE> <INDENT> for model in list_of_models: <NEW_LINE> <INDENT> features = model.feature_names() <NEW_LINE> assert isinstance(features, list), ( "Feature names must be in a list") <NEW_LINE> <DEDENT> return | Tests that the feature_names function returns a list | 625941e915baa723493c441f |
def __monkeypatch_gradient_machine__(): <NEW_LINE> <INDENT> swig_paddle.GradientMachine.loadFromConfigFile = staticmethod(loadGradientMachine) <NEW_LINE> def __matrix_to_numpy__(m): <NEW_LINE> <INDENT> if isinstance(m, swig_paddle.Matrix): <NEW_LINE> <INDENT> return m.copyToNumpyMat() <NEW_LINE> <DEDENT> elif is... | Add some class methods to GradientMachine.
This method should be only used internally. | 625941e985dfad0860c3b302 |
def get_filename(filename: str, suffix: str): <NEW_LINE> <INDENT> if not suffix: <NEW_LINE> <INDENT> return filename <NEW_LINE> <DEDENT> split = os.path.splitext(filename) <NEW_LINE> suffix = suffix.strip() <NEW_LINE> suffix = '.' + suffix if suffix[0] != '.' else suffix <NEW_LINE> if split[-1] == suffix: <NEW_LINE> <I... | return the right name of a file. If the given filename already finishes with
the given suffix, then it is readily used; otherwise, the given suffix is
added | 625941e97c178a314d6ef90d |
def _check_swap ( self, direction ): <NEW_LINE> <INDENT> item = self.active_item <NEW_LINE> dy = item.size[1] <NEW_LINE> y = item.draw_position[1] <NEW_LINE> items = self.items <NEW_LINE> i = items.index( item ) <NEW_LINE> if direction > 0: <NEW_LINE> <INDENT> if (i + 1) < len( items ): <NEW_LINE> <INDENT> ... | Checks to see if the moved item needs to be swapped with one of its
neighbors. | 625941e9cc40096d61595df4 |
def x_img_command(self, count): <NEW_LINE> <INDENT> mac_address = self.get_hex_mac_address() <NEW_LINE> command_string = 'ximg {cine:-1, start:0, cnt' + ':{count_}, dest:{mac}, fmt:{format}'.format( count_=count, mac=mac_address, format=self.img_format ) + '}' <NEW_LINE> return command_string | Returns the command string for requesting a
CHANGELOG
Added 23.02.2019
Changed 14.07.2019
Instead of using string formatting with the "%" operator, the .format method is being used now
Added the fmt: parameter to the command string, which will contain the string identifier for the transfer
format the images are to b... | 625941e9956e5f7376d71312 |
def getCL(self): <NEW_LINE> <INDENT> return self.Close-self.Low | Returns Close-Low | 625941e9596a897236089f60 |
def click_origin_set_upload_button(self): <NEW_LINE> <INDENT> origin_set_upload_button_element = self.wait().until(EC.element_to_be_clickable(self.origin_set_upload_button_locator), 'origin set upload button locator not found before specified time out') <NEW_LINE> origin_set_upload_button_element.click() <NEW_LINE> sel... | Implementing click origin set upload button functionality
:return: | 625941e9377c676e9127264d |
def node_communication_error_permission_denied( node, command, reason, severity=ReportItemSeverity.ERROR, forceable=None ): <NEW_LINE> <INDENT> return ReportItem( report_codes.NODE_COMMUNICATION_ERROR_PERMISSION_DENIED, severity, info={ "node": node, "command": command, "reason": reason, }, forceable=forceable ) | node rejected a request as we do not have permissions to run the request
node string node address / name
reason string decription of the error | 625941e95fdd1c0f98dc06db |
def set_groups(name, context, groups_to_set=()): <NEW_LINE> <INDENT> name = unicode(name) <NEW_LINE> from kotti.resources import LocalGroup <NEW_LINE> DBSession.query(LocalGroup).filter( LocalGroup.node_id == context.id).filter( LocalGroup.principal_name == name).delete() <NEW_LINE> for group_name in groups_to_set: <NE... | Set the list of groups for principal with given ``name`` and in
given ``context``. | 625941e999cbb53fe679308b |
def getMaxValue1(matrix): <NEW_LINE> <INDENT> if (not isinstance(matrix, list) or len(matrix) == 0 or not isinstance(matrix[0], list) or len(matrix[0]) == 0): <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> rows = len(matrix) <NEW_LINE> cols = len(matrix[0]) <NEW_LINE> maxValue = [[0]*cols for i in range(rows)] <NEW_L... | 思路:这题是一个动态规划题,假设函数f(i,j)表示到达坐标(i,j)时能拿到
礼物的最大值,因此f(i,j) = max(f(i-1, j), f(i, j-1)) + gift(i, j)
当到达右下角终点是也就获得了全局的礼物最大值。
时间效率O(n^2),空间效率O(n^2) | 625941e98a349b6b435e8619 |
def now_sec(self): <NEW_LINE> <INDENT> return self.time_now().second | 返回当前秒数,类型为int | 625941e95f7d997b87174f42 |
def __init__(self, kbxParamName, kbxParamIsRequired=True, kbxParamMinLength=None, kbxParamMaxLength=None, **kbxParamProps): <NEW_LINE> <INDENT> pass | Parameter that accepts only string value.
Params:
kbxParamName:String - [Required] Name of this parameter.
kbxParamIsRequired:Boolean - [Optional] True if a value for this parameter is required. True by default.
kbxParamMinLength:Integer - [Optional] Minimum length of the value of this parameter is required.
kbxParamM... | 625941e95510c4643540f87e |
@add_arg_scope <NEW_LINE> def same_padding(inputs, ksize, ratios): <NEW_LINE> <INDENT> pad_array = [[0, 0]] <NEW_LINE> for idx, k in enumerate(ksize): <NEW_LINE> <INDENT> k_effective = k + (k - 1) * (ratios[idx] - 1) <NEW_LINE> pad_total = k_effective - 1 <NEW_LINE> pad_beg = pad_total // 2 <NEW_LINE> pad_end = pad_tot... | Pads the input along the spatial dimensions independently of input size.
Args:
inputs: A tensor of size [batch, height_in, width_in, channels].
ksize: The kernel to be used in the conv2d or max_pool2d operation.
Should be a positive integer.
ratios: An integer, rate for atrous convolution.
Return... | 625941e926068e7796caf18d |
def uris(self): <NEW_LINE> <INDENT> return self.keys() | Extract list of all resource URIs in the order added. | 625941e9009cb60464c63854 |
def get_leader_peer(self, group_id=None, is_complain_to_rs=False, is_peer=True): <NEW_LINE> <INDENT> search_group = conf.ALL_GROUP_ID <NEW_LINE> try: <NEW_LINE> <INDENT> leader_peer_id = self.peer_order_list[search_group][self.peer_leader[search_group]] <NEW_LINE> leader_peer = self.get_peer(leader_peer_id, search_grou... | 현재는 sub leader 에 대한 처리는 하지 않는다.
:param group_id:
:return: | 625941e9cdde0d52a9e534dd |
def index(self, req, image_id): <NEW_LINE> <INDENT> self._enforce(req, 'get_members') <NEW_LINE> self._raise_404_if_image_deleted(req, image_id) <NEW_LINE> try: <NEW_LINE> <INDENT> members = registry.get_image_members(req.context, image_id) <NEW_LINE> <DEDENT> except exception.NotFound: <NEW_LINE> <INDENT> msg = "Image... | Return a list of dictionaries indicating the members of the
image, i.e., those tenants the image is shared with.
:param req: the Request object coming from the wsgi layer
:param image_id: The opaque image identifier
:retval The response body is a mapping of the following form::
{'members': [
{'member_id':... | 625941e966673b3332b92538 |
def updateStores(self): <NEW_LINE> <INDENT> if len(self.channels)>0 : <NEW_LINE> <INDENT> for c in self.channels: <NEW_LINE> <INDENT> s = self.getStoresByChannelId(c) <NEW_LINE> if s is not None: <NEW_LINE> <INDENT> st_lst = [(x['_id'] if '_id' in x else '', x['siteName'] if 'siteName' in x else '', x['reference'] if '... | function to update stores table using channels id set
:return: | 625941e930dc7b7665901e08 |
@panel_config('tag_editor', renderer='../templates/panels/tag_editor.pt') <NEW_LINE> def tag_editor(context, request, tags=None, leftcol_width=4, rightcol_width=8, show_name_tag=True): <NEW_LINE> <INDENT> tags = tags or {} <NEW_LINE> controller_options_json = BaseView.escape_json(json.dumps({ 'tags': tags, 'show_name_t... | Tag editor panel.
Usage example (in Chameleon template): ${panel('tag_editor', tags=security_group.tags)} | 625941e997e22403b379d442 |
def delete_case(self, case_id=None, institute_id=None, display_name=None): <NEW_LINE> <INDENT> query = {} <NEW_LINE> if case_id: <NEW_LINE> <INDENT> query["_id"] = case_id <NEW_LINE> LOG.info("Deleting case %s", case_id) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if not (institute_id and display_name): <NEW_LINE> <I... | Delete a single case from database
Args:
institute_id(str)
case_id(str)
Returns:
case_obj(dict): The case that was deleted | 625941e91f037a2d8b9466a3 |
def delete(self, key): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> del self._objects[key] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> raise self.not_exist_error(key) from None | remove an item from key | 625941e9c4546d3d9de72edf |
def select_directory(): <NEW_LINE> <INDENT> root = Tk() <NEW_LINE> root.withdraw() <NEW_LINE> root.wm_attributes('-topmost', 1) <NEW_LINE> directory = askdirectory(parent=root) <NEW_LINE> return directory | Opens a select directory dialog and returns the path selected | 625941e90a50d4780f66733c |
def __init__(self, address, size, mnemonic, operands): <NEW_LINE> <INDENT> self.address = address <NEW_LINE> self.size = size <NEW_LINE> self.mnemonic = mnemonic <NEW_LINE> self.operands = operands | Set up all the relevant data. | 625941e9de87d2750b86023e |
def generate_random(self, number_of_bytes=None): <NEW_LINE> <INDENT> params = {} <NEW_LINE> if number_of_bytes is not None: <NEW_LINE> <INDENT> params['NumberOfBytes'] = number_of_bytes <NEW_LINE> <DEDENT> response = self.make_request(action='GenerateRandom', body=json.dumps(params)) <NEW_LINE> if response.get('Plainte... | Generates an unpredictable byte string.
:type number_of_bytes: integer
:param number_of_bytes: Integer that contains the number of bytes to
generate. Common values are 128, 256, 512, 1024 and so on. The
current limit is 1024 bytes. | 625941e923849d37ff7b3532 |
def OnLoseFocus(self, event): <NEW_LINE> <INDENT> self._hasFocus = False <NEW_LINE> self.Refresh() <NEW_LINE> self.Update() | Handles the wx.EVT_KILL_FOCUS event for L{GradientButton}. | 625941e9596a897236089f61 |
def _continuity_condition_head( self, m_flow_borehole, cp_f, nSegments, segment_ratios=None): <NEW_LINE> <INDENT> self._check_model_variables( m_flow_borehole, cp_f, nSegments, segment_ratios) <NEW_LINE> a_in = np.array([[1.0], [0.0]]) <NEW_LINE> a_out = np.array([[0.0], [1.0]]) <NEW_LINE> a_b = np.zeros((2, nSegments)... | Build coefficient matrices to evaluate fluid temperatures at depth
(z = 0). These coefficients take into account connections between
U-tube pipes.
Returns coefficients for the relation:
.. math::
\mathbf{T_f}(z=0) = \mathbf{a_{in}} \mathbf{T_{f,in}}
+ \mathbf{a_{out}} \mathbf{T_{f,out}}
+... | 625941e976e4537e8c351b1d |
def compare_where(cond, x, y): <NEW_LINE> <INDENT> return torch.where(cond, x, y) | Return item by condition. | 625941e956b00c62f0f14b03 |
def cheap_grover(n_bits, answers, qi_backend): <NEW_LINE> <INDENT> limit = 2 ** n_bits / 2 <NEW_LINE> if len(answers) >= limit: <NEW_LINE> <INDENT> answers = np.array_split(answers, 2) <NEW_LINE> for an in answers: <NEW_LINE> <INDENT> bits = all_bits(n_bits) <NEW_LINE> q = QuantumRegister(n_bits) <NEW_LINE> b = Classic... | This algorithm checks whether the number of search elements isn't over the limit of what one circuit can find.
If this is true, the circuit is split into two. | 625941e945492302aab5e76f |
def changecart(request,flag): <NEW_LINE> <INDENT> token = request.session.get("token") <NEW_LINE> print(token) <NEW_LINE> if token == None: <NEW_LINE> <INDENT> print("当前没有用户登录") <NEW_LINE> return JsonResponse({"data":-1,"status":"error"}) <NEW_LINE> <DEDENT> productid = request.POST.get("productid") <NEW_LINE> product ... | 修改购物车
:param request:
:param flag:
:return: | 625941e9925a0f43d254a322 |
def pw_crack(hashes, current, min_size, max_size): <NEW_LINE> <INDENT> num_of_hashes = len(hashes) - 1 <NEW_LINE> threads = [] <NEW_LINE> thread_not_full_size = thread_crack_pw( "Thread 1", min_size, max_size - 1, hashes, num_of_hashes, False) <NEW_LINE> thread_not_full_size.start() <NEW_LINE> threads.append(thread_not... | Gets an arbitrary number of hashes and checks all possible passwords of size
min_size to max_size (characters) until all pairs (password, hash) are found
or all possible passwords are tested | 625941e95f7d997b87174f43 |
def update_interrupt_table(self): <NEW_LINE> <INDENT> for row_index, row_address in enumerate(range(_INT_TABLE_FIRST_ROW, _INT_TABLE_LAST_ROW + 1)): <NEW_LINE> <INDENT> row_reg = self.read_byte(row_address) <NEW_LINE> for col_index in range(8): <NEW_LINE> <INDENT> self._last_interrupt_table[row_index][col_index] = bool... | Updates the interrupt table. The int. table is an 8*8 matrix of booleans
where if table[row][col] is True -> The pixel row col generated an interrupt. | 625941e94428ac0f6e5bac9d |
def on_connected(self, headers, body): <NEW_LINE> <INDENT> print('on_connected %s %s' % (headers, body)) | :param dict headers:
:param body: | 625941e94f88993c3716c509 |
def __init__ (self): <NEW_LINE> <INDENT> self.ser_num = BusyTask.t_num <NEW_LINE> BusyTask.t_num += 1 | Initialize a busy task by creating its serial number. | 625941e9d10714528d60018f |
def GetViewdir(self): <NEW_LINE> <INDENT> Debug.msg(3, "Nviz::GetViewdir()") <NEW_LINE> dir = (c_float * 3)() <NEW_LINE> GS_get_viewdir(byref(dir)) <NEW_LINE> return dir[0], dir[1], dir[2] | Get viewdir | 625941e9f548e778e58cda26 |
def get_hdfs_binary(self): <NEW_LINE> <INDENT> return get_hdfs_binary("hadoop-hdfs-datanode") | Get the name or path to the hdfs binary depending on the component name. | 625941e9851cf427c661a9b1 |
def __lt__(self, other): <NEW_LINE> <INDENT> assert(isinstance(other, PTNode)) <NEW_LINE> return (self.pdb_resid_dict[(self.chainid, self.start_res_seq)] < self.pdb_resid_dict[(other.chainid,other.start_res_seq)]) | Compare based on chainid and start residue sequence number | 625941e930c21e258bdfa949 |
def GetGenerateHessianOutput(self): <NEW_LINE> <INDENT> return _itkMultiScaleHessianBasedMeasureImageFilterPython.itkMultiScaleHessianBasedMeasureImageFilterIUL2ISSRTD22IUL2_GetGenerateHessianOutput(self) | GetGenerateHessianOutput(self) -> bool | 625941e90a366e3fb873ecc5 |
@dispatch_rna <NEW_LINE> def add_element(collection: T.bpy_prop_collection, proxy: Proxy, index: int, context: Context): <NEW_LINE> <INDENT> if hasattr(collection, "add"): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> collection.add() <NEW_LINE> return <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> logge... | Add an element to a bpy_prop_collection using the collection specific API.s | 625941e91f037a2d8b9466a4 |
def test_open_ended_display(self): <NEW_LINE> <INDENT> test_module = OpenEndedModule(self.test_system, self.location, self.definition, self.descriptor, self.static_data, self.metadata) <NEW_LINE> saved_response = "Saved response." <NEW_LINE> submitted_response = "Submitted response." <NEW_LINE> self.assertEqual(test_mo... | Test storing answer with the open ended module. | 625941e9627d3e7fe0d692f8 |
def mark_scan_scheduled(self): <NEW_LINE> <INDENT> self.uploaded_on = now() <NEW_LINE> return self._update_status(UPLOAD_STATUSES.virus_scanning_scheduled) | Marks document scan has been scheduled. | 625941e907f4c71912b1192b |
def get_model(self): <NEW_LINE> <INDENT> return self.fru.get_board_part_number() | Retrieves the part number of the FAN
Returns:
String: Part number of FAN | 625941e9851cf427c661a9b2 |
def test_harmonic(self): <NEW_LINE> <INDENT> hf = lambda p: np.round(1.0 / (1.0 + self.reindex(p)), 2) <NEW_LINE> case = R.Reference(np.arange(0,24,1, dtype='float'), 24., 0., function=hf) <NEW_LINE> for i,value in enumerate(case.__values__): <NEW_LINE> <INDENT> self.assertEqual(np.round(1./(i+1.0), 2), value) | It should test against a descending harmonic series. | 625941e994891a1f4081bf52 |
def encodeValue(self, value): <NEW_LINE> <INDENT> raise NotImplementedError | Return raw data string encoded from a ``value``.
Note: this is an internal method. | 625941e9a05bb46b383eccc4 |
def setEnvironmentList(self, PassedEnvironmentList): <NEW_LINE> <INDENT> self._environmentList = PassedEnvironmentList | This is a typical accessor method. | 625941e9f548e778e58cda27 |
def function_wrapper(func, args, kwargs, result_queue): <NEW_LINE> <INDENT> start = time.process_time() <NEW_LINE> try: <NEW_LINE> <INDENT> result = func(*args, **kwargs) <NEW_LINE> <DEDENT> except MemoryError as e: <NEW_LINE> <INDENT> result_queue.put(e) <NEW_LINE> return <NEW_LINE> <DEDENT> runtime = time.process_tim... | Runs the given function and measures its runtime.
:param func: The function to run.
:param args: The function arguments as tuple.
:param kwargs: The function kwargs as dict.
:param result_queue: The inter-process queue to communicate with the parent.
:return: A tuple: The function return value, and its runtime. | 625941e90383005118ecfa88 |
def test_package_stime(self): <NEW_LINE> <INDENT> self.assertIsInstance(self.package.stime, arrow.arrow.Arrow) <NEW_LINE> self.assertEqual(self.package.stime, arrow.get(client.example_package_dict['stime'])) | Test that stime is cast to an arrow object | 625941e9d99f1b3c44c67a2d |
def create_matrix_inface(W,delta,df): <NEW_LINE> <INDENT> k1,k0 = np.shape(W) <NEW_LINE> w = mat2vec(W) <NEW_LINE> w_is_zero = w==0 <NEW_LINE> num_zero = sum(w_is_zero) <NEW_LINE> zero_indices = [i for i,x in enumerate(w) if x==0] <NEW_LINE> A_ub,b_ub,A_eq,b_eq,c = create_matrix_fw(k0,k1,delta,df) <NEW_LINE> inface_A_e... | creates matrix to have the following LP problem:
max df * x
s.t. x in feasible region
x in minimal face containing W | 625941e9a17c0f6771cbe4f6 |
def _virtualenv(executor, *commands, **kwargs): <NEW_LINE> <INDENT> env.command = ' && '.join(commands) <NEW_LINE> with prefix('. %(virtualenv_path)s/bin/activate' % env): <NEW_LINE> <INDENT> executor('%(command)s' % env, **kwargs) | source the virtualenv before executing this command | 625941e9a4f1c619b28b04d5 |
def _step_decorator(step_type, step_name, converters=None, target_fixture=None): <NEW_LINE> <INDENT> def decorator(func): <NEW_LINE> <INDENT> step_func = func <NEW_LINE> parser_instance = get_parser(step_name) <NEW_LINE> parsed_step_name = parser_instance.name <NEW_LINE> step_func.__name__ = force_encode(parsed_step_na... | Step decorator for the type and the name.
:param str step_type: Step type (GIVEN, WHEN or THEN).
:param str step_name: Step name as in the feature file.
:param dict converters: Optional step arguments converters mapping
:param target_fixture: Optional fixture name to replace by step definition
:return: Decorator func... | 625941e950812a4eaa59c7c4 |
def __init__(self, device): <NEW_LINE> <INDENT> self.device = device <NEW_LINE> self.coordinator = DataUpdateCoordinator( device.hass, _LOGGER, name=f"{device.name} ({device.api.model} at {device.api.host[0]})", update_method=self.async_update, update_interval=self.SCAN_INTERVAL, ) <NEW_LINE> self.available = None <NEW... | Initialize the update manager. | 625941e9099cdd3c635f1100 |
def test_b_GLMB028(self): <NEW_LINE> <INDENT> self.driver.get('http://10.1.63.125:8080/gmp/admin#/smstemplate') <NEW_LINE> self.searpage.click_time(self.searpage.bianji_3,1) <NEW_LINE> self.driver.find_element_by_id('st') <NEW_LINE> self.driver.find_element_by_id('st0').click() <NEW_LINE> self.bianji_shen = (By.XPATH,'... | 编辑时账号ID,模板内容,状态信息是否回显 | 625941e9cb5e8a47e48b7f4a |
def __enter__(self): <NEW_LINE> <INDENT> super(Impl, self).__enter__() <NEW_LINE> if not self._bin_found: <NEW_LINE> <INDENT> raise ImplError('{0} not found...'.format(self.binary)) <NEW_LINE> <DEDENT> return self.impl() | Check binary existence and perform command
| 625941e9e1aae11d1e74a163 |
def ptb_iterator(raw_data, batch_size, num_steps, epoch_size_override=None): <NEW_LINE> <INDENT> raw_data = np.array(raw_data, dtype=np.int32) <NEW_LINE> data_len = len(raw_data) <NEW_LINE> batch_len = data_len // batch_size <NEW_LINE> data = np.full([batch_size, batch_len], EOS_INDEX, dtype=np.int32) <NEW_LINE> for i ... | Iterate on the raw PTB data.
This generates batch_size pointers into the raw PTB data, and allows
minibatch iteration along these pointers.
Args:
raw_data: one of the raw data outputs from ptb_raw_data.
batch_size: int, the batch size.
num_steps: int, the number of unrolls.
Yields:
Pairs of the batched data,... | 625941e9dd821e528d63b64c |
def my_reverse(): <NEW_LINE> <INDENT> s=input().split(' ') <NEW_LINE> my_list = list(s) <NEW_LINE> my_list.reverse() <NEW_LINE> for i in my_list: <NEW_LINE> <INDENT> print(i,end=' ') | 输入10个整数,要求按输入时的逆序把这10个数打印出来。逆序输出,
就是按照输入相反的顺序打印这10个数。 | 625941e9cdde0d52a9e534de |
def add_mode(path: Path, mode: int): <NEW_LINE> <INDENT> os.chmod(str(path), os.stat(str(path)).st_mode | mode) | Do chmod and add a mode. | 625941e9b545ff76a89142bc |
def search(self, nums, target): <NEW_LINE> <INDENT> if not nums: <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> return self.searchHelper(nums,0,len(nums)-1,target) | :type nums: List[int]
:type target: int
:rtype: int | 625941e9a17c0f6771cbe4f7 |
def setup(self) -> None: <NEW_LINE> <INDENT> self._create_input_widgets() <NEW_LINE> self._create_search_widgets() <NEW_LINE> self._create_route_widgets() | Create the widgets and display the GUI.
This is typically done on instantiation, but this method
if for more advanced uses. | 625941e960cbc95b062c69eb |
def set_style(self, bold=False, italic=False): <NEW_LINE> <INDENT> self._bold = bold <NEW_LINE> self._italic = italic | Setting font style
Kwargs:
bold: Bold font
italic: Italic font | 625941e97d847024c06be767 |
def confirmChoice(level): <NEW_LINE> <INDENT> if level =="1": <NEW_LINE> <INDENT> gameLevel = "Beginner" <NEW_LINE> <DEDENT> elif level=="2": <NEW_LINE> <INDENT> gameLevel = "Medium" <NEW_LINE> <DEDENT> elif level=="3": <NEW_LINE> <INDENT> gameLevel = "Expert" <NEW_LINE> <DEDENT> print("\nYour choice is "+level+", the ... | Ask user to confirm his or her choice on game level | 625941e97c178a314d6ef90e |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.