code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def update_info_attribute(self, s_ini_path, s_info_title, a_info_attr): <NEW_LINE> <INDENT> if a_info_attr is None: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> int_index = self.index_info(s_ini_path, s_info_title) <NEW_LINE> if int_index == -1: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> a_current_info_attr =...
update info attribute
625941c4460517430c39417a
def add_order_to_request(request, order): <NEW_LINE> <INDENT> if request.user and not isinstance(request.user, AnonymousUser): <NEW_LINE> <INDENT> if order.user != request.user: <NEW_LINE> <INDENT> order.user = request.user <NEW_LINE> order.save() <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> request.session['...
Checks that the order is linked to the current user or adds the order to the session should there be no logged in user.
625941c40383005118ecf5d4
def add_document(video_id, title, description, text): <NEW_LINE> <INDENT> index = open_index() <NEW_LINE> writer = AsyncWriter(index) <NEW_LINE> writer.add_document(text=text, title=title, id=video_id, description=description) <NEW_LINE> writer.commit()
Adds single document to index
625941c431939e2706e4ce5d
def add_item(self, itemID, item): <NEW_LINE> <INDENT> self.pdict[itemID] = item
Adds an item to the products dictionary products.add_item(str, Item) -> None
625941c4a79ad161976cc136
def update_limits(self, limits=None): <NEW_LINE> <INDENT> if not limits: <NEW_LINE> <INDENT> limits = self.get_limits() <NEW_LINE> <DEDENT> self._nominal_limits = limits <NEW_LINE> self.emit("limitsChanged", (limits,))
Check if the limits have changed. Emits signal limitsChanged. Args: limits (tuple): two integers tuple (low limit, high limit).
625941c401c39578d7e74e2c
def create_lv_snapshot(self, name, source_lv_name, lv_type='default'): <NEW_LINE> <INDENT> source_lvref = self.get_volume(source_lv_name) <NEW_LINE> if source_lvref is None: <NEW_LINE> <INDENT> LOG.error(_("Unable to find LV: %s") % source_lv_name) <NEW_LINE> return False <NEW_LINE> <DEDENT> cmd = ['lvcreate', '--name'...
Creates a snapshot of a logical volume. :param name: Name to assign to new snapshot :param source_lv_name: Name of Logical Volume to snapshot :param lv_type: Type of LV (default or thin)
625941c47d43ff24873a2c90
def stopped(self): <NEW_LINE> <INDENT> return self._stop_event.is_set()
Returns True if stop() has been called.
625941c445492302aab5e2b3
def writeoutput(self, idout: dict): <NEW_LINE> <INDENT> if Flags.debug: <NEW_LINE> <INDENT> print("{}{}".format(DEBUG, idout)) <NEW_LINE> <DEDENT> json_file = os.path.join(self.root_path, 'props.json') <NEW_LINE> json_fh = open(json_file, "w") <NEW_LINE> json.dump(idout, json_fh) <NEW_LINE> json_fh.close()
write the build props to the json file
625941c423e79379d52ee556
def get_device_info(machine_room_id): <NEW_LINE> <INDENT> device_info = Device.query.filter_by(machine_room_id=machine_room_id).all() <NEW_LINE> logger.debug('device list: {} '.format(device_info)) <NEW_LINE> return device_info if device_info else False
:param machine_room_id: :return:
625941c45166f23b2e1a514a
def nvi(data): <NEW_LINE> <INDENT> return _tup(getattr(tulipy, 'nvi'), data)
Negative Volume Index: tries to show what smart investors are doing by staying flat on up-volume days and only changing on down-volume days. https://tulipindicators.org/nvi :param pd.DataFrame data: a DataFrame instance with data columns (open, high, low, close, volume). :return pd.Series: indicator resu...
625941c41f5feb6acb0c4b43
def _check_if_validation_is_needed(self, run_specs_set): <NEW_LINE> <INDENT> validation_is_needed = False <NEW_LINE> for run_specs in run_specs_set: <NEW_LINE> <INDENT> validation_is_needed = validation_is_needed or not run_specs['train_specs']['no_validation'] <NEW_LINE> <DEDENT> retu...
This method is not finished yet. Fuses, random and replicas should also be taken in account
625941c41f037a2d8b9461ef
def get_object(self, queryset=None): <NEW_LINE> <INDENT> if queryset is None: <NEW_LINE> <INDENT> queryset = self.get_queryset() <NEW_LINE> slug = self.kwargs.get('slug', None) <NEW_LINE> project_slug = self.kwargs.get('project_slug', None) <NEW_LINE> if slug and project_slug: <NEW_LINE> <INDENT> project = Project.obje...
Get the object for this view. Because Sponsor slugs are unique within a Project, we need to make sure that we fetch the correct Sponsor from the correct Project :param queryset: A query set :type queryset: QuerySet :returns: Queryset which is filtered to only show a project :rtype: QuerySet :raises: Http404
625941c494891a1f4081ba9a
def __str__(self): <NEW_LINE> <INDENT> return str(self.Company_name)
Return a string representation of the model.
625941c497e22403b379cf8b
def __init__(self, *args, **kwds): <NEW_LINE> <INDENT> if args or kwds: <NEW_LINE> <INDENT> super(VirtualRCDataControlResponse, self).__init__(*args, **kwds) <NEW_LINE> if self.result is None: <NEW_LINE> <INDENT> self.result = False <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> self.result = False
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix in-order arguments and keyword arguments. The available fields are: result :param args: complete set ...
625941c4956e5f7376d70e5f
def shape_vectors(some_vector): <NEW_LINE> <INDENT> return shape(some_vector)
shape should take a vector or matrix and return a tuple with the number of rows (for a vector) or the number of rows and columns (for a matrix.)
625941c40c0af96317bb81d9
def get_post_by_id(self, post_id, for_listing_only=False): <NEW_LINE> <INDENT> raise NotImplementedError("This method needs to be implemented by the " "inheriting class")
Fetch the blog post given by ``post_id`` :param post_id: The post identifier for the blog post :type post_id: int :param for_listing_only: Flag to indicate fetch only post not their next/last post info :type for_listing_only: bool :return: If the ``post_id`` is valid, the post data is retrieved, else returns ``None``.
625941c47047854f462a13fd
def write(self, bytes): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> wx.CallAfter(self.text_ctrl.AppendText, bytes) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> pass
Writes bytes (into wx.TextArea buffer).
625941c46e29344779a62605
@policy.command() <NEW_LINE> @click.argument('app-id', type=click.INT, metavar='<APP_ID>') <NEW_LINE> @click.argument('type', type=click.Choice(['group', 'instance']), metavar='<POLICY_TYPE>') <NEW_LINE> @click.argument('id', type=click.INT, metavar='<POLICY_ID>') <NEW_LINE> @click.argument('file', type=click.File('r')...
Update an application policy.
625941c45e10d32532c5ef18
def get_discord_invite(self) -> str: <NEW_LINE> <INDENT> return self.http.get_discord_invite()
Gets an invite for the gold discord channel on the monstercat discord guild. The client needs gold subscription in order to get the invite for that channel. Raises ------ NotFound "I need to buy monstercat gold again in order to finish this library" ~ Library Author
625941c4de87d2750b85fd83
def __parseString( self , string ): <NEW_LINE> <INDENT> results = {} <NEW_LINE> word = string.split(' ')[0] <NEW_LINE> items = word.split('-' , 1) <NEW_LINE> tokens = items[0].split('.') <NEW_LINE> if len(tokens) > 3: <NEW_LINE> <INDENT> raise VersionException( 'Too many version numbers supplied: %s' % ...
__parseString(s) --> hash Parses the string s into the proper components of the version. Enforces all required formats here.
625941c4498bea3a759b9aa1
def do(self): <NEW_LINE> <INDENT> component_manager = self.target <NEW_LINE> component_manager.end_scan() <NEW_LINE> message = "EndScan command completed OK" <NEW_LINE> self.logger.info(message) <NEW_LINE> return (ResultCode.OK, message)
Stateless hook for EndScan() command functionality. :return: A tuple containing a return code and a string message indicating status. The message is for information purpose only. :rtype: (ResultCode, str)
625941c4e8904600ed9f1f1c
def reposition(): <NEW_LINE> <INDENT> tt.up() <NEW_LINE> tt.right(90) <NEW_LINE> tt.fd(30) <NEW_LINE> tt.left(90) <NEW_LINE> tt.down()
Repositions the turtle to draw another line of text. :return: None
625941c4e8904600ed9f1f1d
def is_matched(expression): <NEW_LINE> <INDENT> brackets = [] <NEW_LINE> oppening_bracket = ['(', '{', '['] <NEW_LINE> matching_bracket = {'(': ')', '{': '}', '[': ']'} <NEW_LINE> for bracket in expression: <NEW_LINE> <INDENT> if bracket in oppening_bracket: <NEW_LINE> <INDENT> brackets.append(bracket) <NEW_LINE> <DEDE...
Finds if expression is valid in terms of opened/closed brackets
625941c4d18da76e235324c6
def test_fail_search_move(self): <NEW_LINE> <INDENT> self.vimiv["library"].reload(".") <NEW_LINE> self.vimiv["commandline"].search_move(forward=True) <NEW_LINE> self.check_statusbar("ERROR: No search results to navigate")
Fail moving in search as there is no search.
625941c4a05bb46b383ec814
def filter_indices_by_size(self, indices, max_sizes): <NEW_LINE> <INDENT> sizes = self.sizes <NEW_LINE> tgt_sizes = sizes[:, 1] if len(sizes.shape) > 0 and sizes.shape[1] > 1 else None <NEW_LINE> src_sizes = ( sizes[:, 0] if len(sizes.shape) > 0 and sizes.shape[1] > 1 else sizes ) <NEW_LINE> return data_utils.filter_pa...
Filter a list of sample indices. Remove those that are longer than specified in max_sizes. Args: indices (np.array): original array of sample indices max_sizes (int or list[int] or tuple[int]): max sample size, can be defined separately for src and tgt (then list or tuple) Returns: np.array: f...
625941c4a8ecb033257d30bf
def get_wiki_content(self): <NEW_LINE> <INDENT> doc = self._request("album.getInfo", True) <NEW_LINE> if len(doc.getElementsByTagName("wiki")) == 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> node = doc.getElementsByTagName("wiki")[0] <NEW_LINE> return _extract(node, "content")
Returns the content of the wiki.
625941c4462c4b4f79d1d6c2
def setup(self, window): <NEW_LINE> <INDENT> self.main_window = window <NEW_LINE> title1 = QtWidgets.QLabel('Load variability') <NEW_LINE> title1.setFont(QtGui.QFont('arial', weight=QtGui.QFont.Bold)) <NEW_LINE> label1 = QtWidgets.QLabel('Summer Dispersion:') <NEW_LINE> label1.setFixedWidth(100) <NEW_LINE> self.edit_si...
Set up and initialise loads tab
625941c4a17c0f6771cbe044
def find_gt(a, x): <NEW_LINE> <INDENT> i = bisect.bisect(a, x) <NEW_LINE> if i != len(a): <NEW_LINE> <INDENT> return a[i] <NEW_LINE> <DEDENT> return None
Find smallest value strictly greater than x
625941c421bff66bcd684946
def network_publicip_delete(publicip_name, rg_name, params=None, options='', **kwargs): <NEW_LINE> <INDENT> cmd = "azure network public-ip delete %s %s --quiet" % (rg_name, publicip_name) <NEW_LINE> if params: <NEW_LINE> <INDENT> cmd += add_option("--subscription", params.get("Subscription", None)) <NEW_LINE> <DEDENT> ...
help to delete public-ip :param publicip_name: :param rg_name: :param params: :param options: :return:
625941c421a7993f00bc7cdf
def isGraphic(graphics): <NEW_LINE> <INDENT> if graphics.lower() == "y": <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> elif graphics.lower() == "n": <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise IndexError
asks user to confirm graphics
625941c45166f23b2e1a514b
def get_build_path(current_working_path, directory_name): <NEW_LINE> <INDENT> return current_working_path + os.sep + directory_name
get_build_path_(current_working_path, directory_name) Use case-1: current_working_path = "/CerebellumModels" directory_name = "model-predictions" Use case-2: current_working_path = "/CerebellumModels/model-predictions" directory_name = "cells" Use case-3: current_working_path = "/CerebellumModels/model-predictions/cell...
625941c41d351010ab855b0e
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, Paths): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__
Returns true if both objects are equal
625941c43eb6a72ae02ec4cb
def build_dfa_shifts(rules, terminal_tokens): <NEW_LINE> <INDENT> initial_node = build_initial_node(rules, terminal_tokens) <NEW_LINE> nodes = [initial_node] <NEW_LINE> pending_nodes = [initial_node] <NEW_LINE> nodes_dict_by_closure = {} <NEW_LINE> while pending_nodes: <NEW_LINE> <INDENT> node = pending_nodes.pop(0) <N...
:param rules: parsed rules :param terminal_tokens: list of terminal tokens (string) :return: initial node and dict of node keyed by closure
625941c430bbd722463cbdb6
@pytest.mark.parametrize("time,expect", [ param(0, dt.datetime(1970, 1, 1, tzinfo=UTC), id="Unix time zero"), param(1611918983182, dt.datetime(2021, 1, 29, 11, 16, 23, 182000, tzinfo=UTC), id="JS Date.now() miliseconds"), param(1611918983, dt.datetime(2021, 1, 29, 11, 16, 23, tzinfo=UTC), id="JS Date.now() seconds"), p...
learn how Pydantic handles datetime coercion from int .. note: watershed for detection of ms/s is +/-2e10 so dates earlier than 2001 are ambiguous
625941c40a366e3fb873e80b
def make_app(global_conf, full_stack=True, **app_conf): <NEW_LINE> <INDENT> app = make_base_app(global_conf, full_stack=True, **app_conf) <NEW_LINE> return app
Set test-tg2-freeze up with the settings found in the PasteDeploy configuration file used. :param global_conf: The global settings for test-tg2-freeze (those defined under the ``[DEFAULT]`` section). :type global_conf: dict :param full_stack: Should the whole TG2 stack be set up? :type full_stack: str or bool :ret...
625941c4ac7a0e7691ed40c1
def info_command(update, context): <NEW_LINE> <INDENT> update.message.reply_text('Source code: https://www.github.com/heylouiz/myinstantsbot\n' 'Developer: @heylouiz')
Info command
625941c44f6381625f114a2e
def request(self, *args, **kwargs): <NEW_LINE> <INDENT> retries = 4 <NEW_LINE> tries = 0 <NEW_LINE> while tries < (retries - 1): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return super(GoogleBaseConnection, self).request( *args, **kwargs) <NEW_LINE> <DEDENT> except socket.error: <NEW_LINE> <INDENT> e = sys.exc_info()...
@inherits: L{Connection.request}
625941c4b5575c28eb68dff1
def test_str_(self): <NEW_LINE> <INDENT> b1 = User() <NEW_LINE> b1_str = b1.__str__() <NEW_LINE> self.assertEqual(b1_str, "[User] ({}) {}".format(b1.id, b1.__dict__))
tests str method
625941c47cff6e4e81117978
def pop(self): <NEW_LINE> <INDENT> return _CsoundAC.IntVector_pop(self)
pop(IntVector self) -> std::vector< int >::value_type
625941c476e4537e8c351663
def get_credentials(cwd=os.getcwd()): <NEW_LINE> <INDENT> credential_path = os.path.join(cwd, myconfig['gmailApiSetup']['credentialsJsonFilename']) <NEW_LINE> logging.info('get_credentials(): %s %s %s ' % (credential_path, cwd, myconfig['gmailApiSetup']['credentialsJsonFilename'])) <NEW_LINE> store = oauth2client.file....
Gets valid user credentials from storage. Critical error when no credentials available. Returns: Credentials, the obtained credential.
625941c4b830903b967e98fe
def model_fn_query(features, labels, mode, params): <NEW_LINE> <INDENT> del labels, params <NEW_LINE> encoder_module = hub.Module(FLAGS.retriever_module_path) <NEW_LINE> block_emb = encoder_module( inputs=dict( input_ids=features["block_ids"], input_mask=features["block_mask"], segment_ids=features["block_segment_ids"]...
Model function.
625941c4851cf427c661a502
def optimize(self): <NEW_LINE> <INDENT> gen_vars = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope="Generator") <NEW_LINE> disc_vars = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope="Discriminator") <NEW_LINE> out_model = self.model() <NEW_LINE> global_feature = out_model['global_feature'] <NEW_LINE> gbl...
Train
625941c4377c676e9127219b
def adam(x, dx, config=None): <NEW_LINE> <INDENT> if config is None: config = {} <NEW_LINE> config.setdefault('learning_rate', 1e-3) <NEW_LINE> config.setdefault('beta1', 0.9) <NEW_LINE> config.setdefault('beta2', 0.999) <NEW_LINE> config.setdefault('epsilon', 1e-8) <NEW_LINE> config.setdefault('m', np.zeros_like(x)) <...
Uses the Adam update rule, which incorporates moving averages of both the gradient and its square and a bias correction term. config format: - learning_rate: Scalar learning rate. - beta1: Decay rate for moving average of first moment of gradient. - beta2: Decay rate for moving average of second moment of gradient. - ...
625941c4be7bc26dc91cd5f5
def update(self, instance, validated_data): <NEW_LINE> <INDENT> password = validated_data.pop('password', None) <NEW_LINE> user = super().update(instance, validated_data) <NEW_LINE> if password: <NEW_LINE> <INDENT> user.set_password(password) <NEW_LINE> user.save() <NEW_LINE> <DEDENT> return user
Update a user, setting the password correctly and return in
625941c491f36d47f21ac4e3
def main(useruid: str, targe_id: str): <NEW_LINE> <INDENT> user = User(useruid) <NEW_LINE> if not targe_id: <NEW_LINE> <INDENT> targe_id = user.userid <NEW_LINE> <DEDENT> target = User(targe_id + user.course) <NEW_LINE> if not target.userid: <NEW_LINE> <INDENT> target.userid = targe_id <NEW_LINE> <DEDENT> return render...
個資畫面
625941c44a966d76dd551000
def testNewFileObject(self): <NEW_LINE> <INDENT> test_lvm_path_spec = path_spec_factory.Factory.NewPathSpec( definitions.TYPE_INDICATOR_LVM, location='/', parent=self._raw_path_spec) <NEW_LINE> resolver_helper_object = lvm_resolver_helper.LVMResolverHelper() <NEW_LINE> self._TestNewFileObject(resolver_helper_object, te...
Tests the NewFileObject function.
625941c47d847024c06be2ac
def count_positives_sum_negatives(arr): <NEW_LINE> <INDENT> if not len(arr): <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return [len([num for num in arr if num > 0]), sum([num for num in arr if num <= 0])]
Return list of count of positives numbers & sum of negative numbers.
625941c455399d3f055886a5
def test_show_str(self): <NEW_LINE> <INDENT> show = sample_show() <NEW_LINE> self.assertEqual( str(show), f"{show.name}:[{show.num_seasons}][{show.num_eps}]")
Test the show string representation
625941c48a43f66fc4b54059
def __init__(self, word_embedding_path: str): <NEW_LINE> <INDENT> self.pos2index = {'PAD': 0, 'TO': 1, 'VBN': 2, "''": 3, 'WP': 4, 'UH': 5, 'VBG': 6, 'JJ': 7, 'VBZ': 8, '--': 9, 'VBP': 10, 'NN': 11, 'DT': 12, 'PRP': 13, ':': 14, 'WP$': 15, 'NNPS': 16, 'PRP$': 17, 'WDT': 18, '(': 19, ')': 20, '.': 21, ',': 22, '``': 23,...
:param word_embedding_path: path to gensim embedding file
625941c4d486a94d0b98e137
def flipside(s): <NEW_LINE> <INDENT> x = len(s)//2 <NEW_LINE> return s[x:] + s[:x]
flipside swaps s's sides Argument s: a string
625941c430dc7b766590195a
def __init__(self, file_path, password, data_format, sensitive_keys=None): <NEW_LINE> <INDENT> self.file_path = file_path <NEW_LINE> self.data_format = data_format <NEW_LINE> self.sensitive_keys = sensitive_keys if sensitive_keys is not None else [] <NEW_LINE> self.crypto = Crypto(password) <NEW_LINE> self.write_lock =...
:param file_path: path to data file :param password: password to encrypt data with :param data_format: a dictionary of allowed keys and allowed value types (None will be set to new instance of allowed type when writing) :param sensitive_keys: a list of data_format keys that should have their values encrypted on top of ...
625941c4d99f1b3c44c67583
def update_directory_services_with_http_info(self, directory_service, **kwargs): <NEW_LINE> <INDENT> all_params = ['directory_service', 'ids', 'names'] <NEW_LINE> all_params.append('callback') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE> all_params.a...
Update directory services. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response) >>> >>> thread = api.update_directory_services_with_http_...
625941c46aa9bd52df036d95
def setupColors(self): <NEW_LINE> <INDENT> self.letter_normal_color = "Black" <NEW_LINE> self.letter_error_color = self.letter_error.GetValue() <NEW_LINE> self.letter_checked_color = self.letter_checked.GetValue() <NEW_LINE> self.letter_cheat_color = self.letter_cheat.GetValue() <NEW_LINE> self.graphic_error_color = se...
Setup colors for drawing.
625941c4b7558d58953c4f09
@app.route("/consumption", methods=["GET", "POST"]) <NEW_LINE> @login_required <NEW_LINE> def consumption(): <NEW_LINE> <INDENT> if request.method == "POST": <NEW_LINE> <INDENT> if not request.form.get("consumption"): <NEW_LINE> <INDENT> return apology("Must provide part_code") <NEW_LINE> <DEDENT> elif not request.form...
Consumption of parts - Расход деталей
625941c48a349b6b435e8166
def me(self, **kwargs): <NEW_LINE> <INDENT> return self._get(API.ME.value, **kwargs)
Get detailed profile information about the current user. An alias for the 'current_user' method.
625941c473bcbd0ca4b2c069
def precision(y_hat, y, cls): <NEW_LINE> <INDENT> pass
Function to calculate the precision Inputs: > y_hat: pd.Series of predictions > y: pd.Series of ground truth > cls: The class chosen Output: > Returns the precision as float
625941c4bf627c535bc131c1
@commands('tell', 'ask') <NEW_LINE> @nickname_commands('tell', 'ask') <NEW_LINE> @example('lpbot, tell Nevermind7 he broke something again.') <NEW_LINE> def f_remind(bot, trigger): <NEW_LINE> <INDENT> teller = trigger.nick <NEW_LINE> verb = trigger.group(1) <NEW_LINE> if not trigger.group(3): <NEW_LINE> <INDENT> bot.re...
Give someone a message the next time they're seen
625941c44f88993c3716c05b
@api_view(['GET']) <NEW_LINE> @permission_classes((permissions.SelfOnly,)) <NEW_LINE> def user_calendar(_, nickname): <NEW_LINE> <INDENT> cache_key = f'user_{nickname}_calendar' <NEW_LINE> user_calendar = cache.get(cache_key) <NEW_LINE> if user_calendar is not None: <NEW_LINE> <INDENT> Response(user_calendar) <NEW_LINE...
Exposes every event that is related to a user, both periodic and spontaneous ("once") :param nickname: User nickname :return: Response with the events that compose the user calendar.
625941c4851cf427c661a503
def test_request_for_known_app_uses_cache(self): <NEW_LINE> <INDENT> ticket = dict(app_name="Some App", app_uuid=self.app_uuid, public_key_str=self.public_key, created_at=datetime.datetime.now()) <NEW_LINE> cacher = SecurityTokenCacher() <NEW_LINE> with mock.patch("flask_mauth.cacher.security_token_cacher.requests.get"...
A previously downloaded token is returned
625941c4925a0f43d2549e68
def get_someday_before(n,fmt=DEFAULE_DATE_FORMAT): <NEW_LINE> <INDENT> yes = datetime.date.today()-datetime.timedelta(days=n) <NEW_LINE> return yes.strftime(fmt)
获取n天前日期,返回的fmt日期格式
625941c445492302aab5e2b4
def resnet101(pretrained=False, **kwargs): <NEW_LINE> <INDENT> model = ResNet(Bottleneck, [3, 4, 23, 3], net_type='resnet101', **kwargs) <NEW_LINE> if pretrained: <NEW_LINE> <INDENT> model.load_state_dict(model_zoo.load_url(model_urls['resnet101']), strict=False) <NEW_LINE> <DEDENT> return model
Constructs a ResNet-101 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
625941c4711fe17d82542361
def upload_qncloud(filename, filepath): <NEW_LINE> <INDENT> qn_auth = Auth(config.QN_ACCESS_KEY, config.QN_SECRET_KEY) <NEW_LINE> token = qn_auth.upload_token(config.QN_BUCKET, filename, 3600) <NEW_LINE> ret, info = put_file(token, filename, filepath) <NEW_LINE> return ret, info
上传文件到七牛云
625941c45fc7496912cc3970
@login_required <NEW_LINE> def return_form(request): <NEW_LINE> <INDENT> actu_id = request.POST.get('object_id') <NEW_LINE> if actu_id == 'add': <NEW_LINE> <INDENT> form = ActuForm() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> actu = Actu.objects.get(pk=int(actu_id)) <NEW_LINE> form = ActuForm(instance=actu) <NEW_LIN...
select the add or modify form for actu and return response for ajax js
625941c407f4c71912b11474
def _get_input_pixels_celestial(wcs_in, wcs_out, shape_out): <NEW_LINE> <INDENT> xp_out, yp_out = np.indices(shape_out, dtype=float)[::-1] <NEW_LINE> xw_out, yw_out = wcs_out.wcs_pix2world(xp_out, yp_out, 0) <NEW_LINE> xw_in, yw_in = convert_world_coordinates(xw_out, yw_out, wcs_out, wcs_in) <NEW_LINE> xp_in, yp_in = w...
Get the pixel coordinates of the pixels in an array of shape ``shape_out`` in the input WCS.
625941c4460517430c39417b
def doStartCDS(input_type, input_value): <NEW_LINE> <INDENT> x = getLocationCDS(input_value, input_value) <NEW_LINE> coordinate_start = re.findall(r'(\d+)\-', x) <NEW_LINE> return coordinate_start
Process CDS from the getLocationCDS Input: input type and value in config Output:CDS start Coordinate
625941c4a8ecb033257d30c0
def fibonacci(n, m): <NEW_LINE> <INDENT> a1, a2 = 1, 1 <NEW_LINE> f = a1 + a2 <NEW_LINE> while f <= m: <NEW_LINE> <INDENT> if f >= n: <NEW_LINE> <INDENT> print(f) <NEW_LINE> <DEDENT> a1 = a2 <NEW_LINE> a2 = f <NEW_LINE> f = a1 + a2
функция возвращает ряд Фибоначчи с n-элемента до m-элемента.
625941c46aa9bd52df036d96
def backup_crasher(): <NEW_LINE> <INDENT> dir_to_create = datetime.now().strftime("%Y-%m-%d-%H-%M-%S-%f") <NEW_LINE> script_dir = os.path.dirname(os.path.realpath(__file__)) <NEW_LINE> dir_to_create_full_path = os.path.join(script_dir, 'crash', dir_to_create) <NEW_LINE> try: <NEW_LINE> <INDENT> if os.path.exists(dir_to...
Back-up the generated codes responsible for the crash
625941c415baa723493c3f67
def proxy_auth_header(user, password): <NEW_LINE> <INDENT> return 'Basic ' + base64.encodestring('%s:%s' % (user, password))
Args: user (str): proxy server username. password (str): user password. Returns: str: proxy authentication header.
625941c4b545ff76a8913e09
def defaultUrlScheme(self): <NEW_LINE> <INDENT> return QString()
QString KUriFilterData.defaultUrlScheme()
625941c4aad79263cf390a31
def add_char(self, char): <NEW_LINE> <INDENT> self.token += char <NEW_LINE> return
Add a character
625941c4d268445f265b4e61
def plot_story_evaluation( test_y, predictions, report, precision, f1, accuracy, in_training_data_fraction, out_directory, disable_plotting, ): <NEW_LINE> <INDENT> from sklearn.metrics import confusion_matrix <NEW_LINE> from sklearn.utils.multiclass import unique_labels <NEW_LINE> import matplotlib.pyplot as plt <NEW_L...
Plot the results of story evaluation
625941c4627d3e7fe0d68e41
def forecast_move(self, move: Location) -> 'Board': <NEW_LINE> <INDENT> new_board = self.copy() <NEW_LINE> new_board.apply_move(move) <NEW_LINE> return new_board
Make a deep copy of the current game with an input move applied to advance the game one ply. Parameters ---------- move : A coordinate pair (row, column) indicating the next position for the active player on the board. Returns ---------- A deep copy of the board with the input move applied.
625941c4796e427e537b05b7
def get_test_dataloader_prefix(self, dataloader_idx: int = 0) -> str: <NEW_LINE> <INDENT> return self._test_names[dataloader_idx]
Get the name of one or more data loaders, which will be prepended to all logs. Args: dataloader_idx: Index of the data loader. Returns: str name of the data loader at index provided.
625941c44d74a7450ccd41b6
def get_methods_map(self): <NEW_LINE> <INDENT> methods_map = {} <NEW_LINE> for method_idx, m in self.method_ids: <NEW_LINE> <INDENT> class_name = parse_type_signature( self.bytes[self.type_ids[m.class_idx][1].descriptor_idx] ) <NEW_LINE> if not class_name: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> try: <NEW_LINE...
Returns a dictionary with all methods in the Dex file
625941c4d18da76e235324c7
def game_starter(self,master): <NEW_LINE> <INDENT> self.data.acquire() <NEW_LINE> participants = self.data.nodes_at_game_start <NEW_LINE> self.data.release() <NEW_LINE> if master: <NEW_LINE> <INDENT> self.tcp_obj.start_the_game(participants.copy(), master=True) <NEW_LINE> self.data.acquire() <NEW_LINE> print('nodes at ...
add a new function here named master_game_starter The function would be able to use participants from the shared squarcle_data This thread should be called from the GUI start button click It is simulated below as input() It can be used as a master an slave with the right parameters !
625941c4046cf37aa974cd3c
def DB(path, bloom_filter_size=10, create_if_missing=False, error_if_exists=False, paranoid_checks=False, write_buffer_size=(4 * 1024 * 1024), max_open_files=1000, block_cache_size=(8 * 1024 * 1024), block_size=(4 * 1024), default_sync=False, default_verify_checksums=False, default_fill_cache=True): <NEW_LINE> <INDENT>...
This is the expected way to open a database. Returns a DBInterface.
625941c4f8510a7c17cf96ee
def detect_imagename(os_url): <NEW_LINE> <INDENT> for updirs in (4, 3): <NEW_LINE> <INDENT> comp_id_path = updirs * '../' + 'COMPOSE_ID' <NEW_LINE> comp_id = run('wget -q -O- {}'.format(urljoin(os_url, comp_id_path)), quiet=True) <NEW_LINE> if comp_id.succeeded: <NEW_LINE> <INDENT> match_comp = search(r'(\w+)-([\d\.]+)...
Task to detect image name by OS URL :param str os_url: URL of OS media to detect
625941c4596a897236089ab5
def env_no(): <NEW_LINE> <INDENT> no = os.environ.get("LOCUST_NO") <NEW_LINE> if no is None: <NEW_LINE> <INDENT> print("Warning: env LOCUST_NO is not found") <NEW_LINE> return 1 <NEW_LINE> <DEDENT> return int(no)
環境変数からこのスレッドの通し番号を取得する。 ※ Locust起動時にシェルスクリプトなどで環境変数 LOCUST_NO が指定されている必要あり。
625941c401c39578d7e74e2e
def get_kafka_manager_api(args=None, logger=None, stats=None): <NEW_LINE> <INDENT> if not args: <NEW_LINE> <INDENT> parser = get_parser(description=NAME) <NEW_LINE> add_kafka_manager_api_cli_arguments(parser) <NEW_LINE> args = parser.parse_args() <NEW_LINE> <DEDENT> if not logger: <NEW_LINE> <INDENT> logger = get_logge...
Return a usable Kafka Manager object without creating a class around it. In the context of a krux.cli (or similar) interface the 'args', 'logger' and 'stats' objects should already be present. If they are not inputted, we will provide usable ones.
625941c416aa5153ce36246b
def _handle_simple_function_len(self, node, function, pos_args): <NEW_LINE> <INDENT> if len(pos_args) != 1: <NEW_LINE> <INDENT> self._error_wrong_arg_count('len', node, pos_args, 1) <NEW_LINE> return node <NEW_LINE> <DEDENT> arg = pos_args[0] <NEW_LINE> if isinstance(arg, ExprNodes.CoerceToPyTypeNode): <NEW_LINE> <INDE...
Replace len(char*) by the equivalent call to strlen(), len(Py_UNICODE) by the equivalent Py_UNICODE_strlen() and len(known_builtin_type) by an equivalent C-API call.
625941c47d847024c06be2ad
def characterReplacement(self, s, k): <NEW_LINE> <INDENT> left=0 <NEW_LINE> right=-1 <NEW_LINE> num = [0] * 26 <NEW_LINE> max_cnt = 0 <NEW_LINE> while(right<len(s)-1): <NEW_LINE> <INDENT> right += 1 <NEW_LINE> num[ord(s[right])-ord("A")] += 1 <NEW_LINE> max_cnt = max(num[ord(s[right])-ord("A")], max_cnt) <NEW_LINE> if ...
:type s: str :type k: int :rtype: int
625941c48c3a8732951583ac
def ustr(what): <NEW_LINE> <INDENT> if type(what) == type(''): return what <NEW_LINE> try: r=what.__str__() <NEW_LINE> except AttributeError: r=str(what) <NEW_LINE> if type(r)!=type(''): return str(r,ENCODING) <NEW_LINE> return r
Converts object "what" to unicode string using it's own __str__ method if accessible or unicode method otherwise.
625941c476d4e153a657eb23
def registerPlayer(name): <NEW_LINE> <INDENT> db, cursor = connect() <NEW_LINE> params = (name,) <NEW_LINE> cursor.execute("insert into players (name) values (%s)", params) <NEW_LINE> db.commit() <NEW_LINE> db.close()
Adds a player to the tournament database. The database assigns a unique serial id number for the player. (This should be handled by your SQL database schema, not in your Python code.) Args: name: the player's full name (need not be unique).
625941c43539df3088e2e33d
def get_all_actor_velocities(self, actor_id, first_frame=None, last_frame=None): <NEW_LINE> <INDENT> return self._get_all_actor_states(actor_id, "velocity", first_frame, last_frame)
Returns a list with all the velocities of the actor at the frame interval.
625941c43317a56b86939c4f
def get_play_again(): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> u_input = input("Play again (YES/NO): ") <NEW_LINE> l_input = u_input.lower() <NEW_LINE> if l_input == "no": <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> elif l_input == "yes": <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NE...
Check if the user wants to play again.
625941c424f1403a92600b5b
def get_region(self, view=None, can_select_entire_buffer=False): <NEW_LINE> <INDENT> value = '' <NEW_LINE> view, window = self.get_view_and_window(view) <NEW_LINE> if view is not None: <NEW_LINE> <INDENT> selection = view.sel() <NEW_LINE> if can_select_entire_buffer is True: <NEW_LINE> <INDENT> if len(selection) == 1 a...
Get the value under the cursor, or cursors.
625941c491f36d47f21ac4e4
def test_keyword_diff(self): <NEW_LINE> <INDENT> diff = (b"Index: Makefile\n" b"===========================================================" b"========\n" b"--- Makefile (revision 4)\n" b"+++ Makefile (working copy)\n" b"@@ -1,6 +1,7 @@\n" b" # $Id$\n" b" # $Rev$\n" b" # $Revision:: $\n" b"+# foo\n" b" includ...
Testing parsing SVN diff with keywords
625941c4ec188e330fd5a795
def test_access_mass_mailing_user(self): <NEW_LINE> <INDENT> self.blacklist_entry.sudo(self.user_mm_user).read() <NEW_LINE> self.blacklist_entry.sudo(self.user_mm_user).write({'email': '[email protected]'}) <NEW_LINE> self.env['mail.blacklist'].sudo(self.user_mm_user).create({ 'email': '[email protected]', }) <NEW_LINE>...
Test Mass Mailing user's access rights
625941c43eb6a72ae02ec4cc
def filter_docker_compose_files_list(list, version): <NEW_LINE> <INDENT> assert version in ["git", "docker"] <NEW_LINE> def _is_known_yml_file(entry): <NEW_LINE> <INDENT> return ( entry.startswith("git-versions") and entry.endswith(".yml") or entry == "other-components.yml" or entry == "other-components-docker.yml" or ...
Returns a filtered list of known docker-compose files version shall be one of "git", "docker".
625941c4a219f33f3462895f
def get(self, key, default=None): <NEW_LINE> <INDENT> return getattr(self, key, default)
Get the value of a setting.
625941c43c8af77a43ae3792
def get_consumption(self): <NEW_LINE> <INDENT> return [pzh.get_consumption() for pzh in self.hour_data]
get sum consumption for PriceZone
625941c4956e5f7376d70e61
def rotate(self, nums, k): <NEW_LINE> <INDENT> for i in range(k): <NEW_LINE> <INDENT> val=nums.pop() <NEW_LINE> nums.insert(0,val)
:type nums: List[int] :type k: int :rtype: void Do not return anything, modify nums in-place instead.
625941c4adb09d7d5db6c784
def before_run_epoch(self, estimator, epoch, data, batch_n, tot_res): <NEW_LINE> <INDENT> pass
This function is called before run a new epoch. Args: estimator: A reference to the estimator epoch: The index of the current epoch data: The current data passed to the epoch batch_n: The number of batches tot_res: An object with keys the current mode operations and values and array of results Retu...
625941c42ae34c7f2600d125
def get_background_items(self, window, item): <NEW_LINE> <INDENT> return []
Return empty list. Do not react on background clicks.
625941c4187af65679ca5111
def clarifai_check_img_for( self, tags: list = None, tags_skip: list = None, comment: bool = False, comments: list = None, ): <NEW_LINE> <INDENT> if self.aborting: <NEW_LINE> <INDENT> return self <NEW_LINE> <DEDENT> if tags is None and not self.clarifai_img_tags: <NEW_LINE> <INDENT> self.use_clarifai = False <NEW_LINE>...
Defines the tags the images should be checked for
625941c4099cdd3c635f0c4f
def test_existing(self): <NEW_LINE> <INDENT> existing = GalleryFactory(title='Existing') <NEW_LINE> with open(SAMPLE_ZIP_PATH, mode='rb') as f: <NEW_LINE> <INDENT> test_file = File(f) <NEW_LINE> GalleryUpload.objects.create(zip_file=test_file, gallery=existing) <NEW_LINE> <DEDENT> self.assertQuerysetEqual(Gallery.objec...
Add the photos in the zip to an existing gallery.
625941c444b2445a3393208a
def test_init(self): <NEW_LINE> <INDENT> stat = unity_collectors.UnityStat(self.unity) <NEW_LINE> self.assertTrue(isinstance(stat, unity_collectors.UnityStat))
``UnityStat`` the __init__ params have not changed
625941c4287bf620b61d3a58
def twoSum(self, numbers, target): <NEW_LINE> <INDENT> dic = {} <NEW_LINE> for i, num in enumerate(numbers): <NEW_LINE> <INDENT> if target - num in dic: <NEW_LINE> <INDENT> return [dic[target - num] + 1, i + 1] <NEW_LINE> <DEDENT> dic[num] = i <NEW_LINE> <DEDENT> return []
:type numbers: List[int] :type target: int :rtype: List[int]
625941c46fece00bbac2d730
def _getRegionDict(self, env): <NEW_LINE> <INDENT> region = {} <NEW_LINE> parsedRegion = env["GRASS_REGION"].split(';') <NEW_LINE> for r in parsedRegion: <NEW_LINE> <INDENT> r = r.split(':') <NEW_LINE> r[0] = r[0].strip() <NEW_LINE> if len(r) < 2: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT...
Parse string from GRASS_REGION env variable into dict.
625941c4711fe17d82542362
def test_simplex_data_transferring(): <NEW_LINE> <INDENT> host = "cpu" <NEW_LINE> target_host = "llvm" <NEW_LINE> host_ctx = tvm.context(host) <NEW_LINE> if not tvm.module.enabled(target_host): <NEW_LINE> <INDENT> print("Skip test because llvm is not enabled.") <NEW_LINE> return <NEW_LINE> <DEDENT> def check_device(dev...
Test the heterogeneous execution of a simple network where data transferring is from the target device to the host processor at runtime. The host processor is always assumed to be cpu, and the device varies.
625941c4d18da76e235324c8