code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def getScheduleJobs(self): <NEW_LINE> <INDENT> return self.schedule.jobs
Get method for client's active jobs
625941e450812a4eaa59c72b
def __init__(self, params): <NEW_LINE> <INDENT> Agent.__init__(self, params) <NEW_LINE> self.q = np.random.rand(self.num_states, self.num_actions) <NEW_LINE> self.returns = {(state, action):[] for state in range(self.num_states) for action in range(self.num_actions)} <NEW_LINE> self.epsilon = 1 <NEW_LINE> self.tuple_st...
See documentation in the base class
625941e456b00c62f0f14a69
def printIpNetwork(self, net): <NEW_LINE> <INDENT> self._printIpNetworkLine(net) <NEW_LINE> self._printTree(net)
Print out the IpNetwork and IpAddress hierarchy under net.
625941e47047854f462a1812
def merge( self, symbol): <NEW_LINE> <INDENT> raise NotImplementedError()
extracts and merges information from the symbol to the declarations tree. This method should be overridden in the derived classes.
625941e44e696a04525c985a
def list_transactions(self): <NEW_LINE> <INDENT> msg = f'{self.__class__.__name__}.{sys._getframe().f_code.co_name}' <NEW_LINE> logging.info(msg) <NEW_LINE> result_list = TinkModelResultList(msg='') <NEW_LINE> return result_list
Initiates the retrieval of a list of all transactions in the Tink platform. :return: TinkModelResult
625941e4a17c0f6771cbe45d
def convert_img_to_json(input_file): <NEW_LINE> <INDENT> request_list = [] <NEW_LINE> for line in input_file: <NEW_LINE> <INDENT> image_filename, features = line.lstrip().split(' ', 1) <NEW_LINE> with open(image_filename, 'rb') as image_file: <NEW_LINE> <INDENT> content_json_obj = { 'content': base64.b64encode(image_fi...
Translates the input file into a json output file. Args: input_file: a file object, containing lines of input to convert. output_filename: the name of the file to output the json to.
625941e42eb69b55b151ccc2
def test_search_entry(self): <NEW_LINE> <INDENT> pass
Test case for search_entry student info # noqa: E501
625941e4b545ff76a8914222
def _get_valid_units(): <NEW_LINE> <INDENT> valid_prefix_names = ['yocto', 'zepto', 'atto', 'femto', 'pico', 'nano', 'micro', 'milli', 'centi', 'deci', 'deca', 'hecto', 'kilo', 'mega', 'giga', 'tera', 'peta', 'exa', 'zetta', 'yotta'] <NEW_LINE> valid_prefix_symbols = ['y', 'z', 'a', 'f', 'p', 'n', u'µ', 'm', 'c', 'd', ...
Get valid units according to the International System of Units (SI). The International System of Units (SI, [1]_) is the default system for describing units in the Brain Imaging Data Structure (BIDS). For more information, see the BIDS specification [2]_ and the appendix "Units" therein. References ---------- [1] .. ...
625941e4796e427e537b09d6
def multiply_unoptimized(first_operand: int, second_operand: int)->(int, int): <NEW_LINE> <INDENT> big_a, big_b = abs(first_operand), abs(second_operand) <NEW_LINE> result = 0 <NEW_LINE> for _ in range(big_a): <NEW_LINE> <INDENT> result = result + big_b <NEW_LINE> <DEDENT> answer = calculate_sign(first_operand, second_...
for any numbers a and b, just use a for loop for abs(a) iterations were we keep adding abs(b) to result @a:32-bit integer @b:32-bit integer
625941e4796e427e537b09d7
def tail(n, iterable): <NEW_LINE> <INDENT> return iter(collections.deque(iterable, maxlen=n))
"Return an iterator over the last n items Example:: >>> list(tail(3, 'ABCDEFG')) ['E', 'F', 'G']
625941e4d10714528d6000f5
def get_downloader(self): <NEW_LINE> <INDENT> return GYAODownloader(self.url, self.session)
Return a :class: of the Downloader
625941e4fb3f5b602dac3aa5
def exec_command( command, execute_in='', use_shell=None, use_tee = None, _with_python = 1, **env ): <NEW_LINE> <INDENT> log.debug('exec_command(%r,%s)' % (command, ','.join(['%s=%r'%kv for kv in env.items()]))) <NEW_LINE> if use_tee is None: <NEW_LINE> <INDENT> use_tee = os.name=='posix' <NEW_LINE> <DEDENT> if...
Return (status,output) of executed command. command is a concatenated string of executable and arguments. The output contains both stdout and stderr messages. The following special keyword arguments can be used: use_shell - execute `sh -c command` use_tee - pipe the output of command through tee execute_in - b...
625941e40c0af96317bb85f5
def _update_positions(current_positions, bounding_box_dimensions, simplices, initial_positions, descent_rate, momentum=None, apply_delaunay=True): <NEW_LINE> <INDENT> updated_positions = current_positions.copy() <NEW_LINE> bbd = bounding_box_dimensions <NEW_LINE> num_particles = current_positions.shape[0] <NEW_LINE> fo...
Performs a single iteration of force directed displacement for every word
625941e4d8ef3951e324394b
def source_file(file_to_source): <NEW_LINE> <INDENT> os.environ.update(env_after_source(file_to_source))
Updates the environment with the environment created by sourcing the file in bash
625941e421a7993f00bc8104
def slow_request_processor(task): <NEW_LINE> <INDENT> log.warning('Long request processing detected.\n' 'Request was %s\nYou have to process request in %ss\n' 'request was automatically responded with `ERROR_RESPONSE_KEY`', request, RESPONSE_TIMEOUT) <NEW_LINE> dispatcher = self.get_dispatcher() <NEW_LINE> loop = dispa...
Handle response after 2.7 sec (RESPONSE_TIMEOUT) :param task: :return:
625941e47d43ff24873a30b1
def test(testing=False): <NEW_LINE> <INDENT> ising_graphs(100, 100, 50, 50, (1, 4), testing)
Runs a quick test to see that e_t is working
625941e48c0ade5d55d3edcb
@app.cli.command() <NEW_LINE> def initdb(): <NEW_LINE> <INDENT> db.create_all() <NEW_LINE> click.echo('Init db') <NEW_LINE> admin_role = model.Role(name='admin') <NEW_LINE> db.session.add(admin_role) <NEW_LINE> user_datastore.create_user( name='admin', email='admin', password=encrypt_password('admin'), roles=[admin_rol...
Initialize the database.
625941e4de87d2750b8601a4
def Peek(self): <NEW_LINE> <INDENT> pass
Peek(self: Stack) -> object Returns the object at the top of the System.Collections.Stack without removing it. Returns: The System.Object at the top of the System.Collections.Stack.
625941e426068e7796caf0f3
def read_input(fname): <NEW_LINE> <INDENT> ignore = set() <NEW_LINE> with open(fname, 'r', encoding='utf-8') as f: <NEW_LINE> <INDENT> for line in f: <NEW_LINE> <INDENT> line = line.strip() <NEW_LINE> lemma, word, tag = line.split("\t") <NEW_LINE> if word != u"": <NEW_LINE> <INDENT> ignore.add((lemma, tag)) <NEW_LINE> ...
read in the uncovered file to ignore paradigm slots
625941e44e696a04525c985b
def _findLinksInCurrentFile(self) -> set: <NEW_LINE> <INDENT> file = self._openFile() <NEW_LINE> fStream = file.read() <NEW_LINE> file.close() <NEW_LINE> return set(re.findall(self._regexFindLinks, fStream))
Return the set of all links in the Current File (fileNames)
625941e4ad47b63b2c50a38c
def fleeAggression(self,destination_patch,constraints): <NEW_LINE> <INDENT> constraints.append(self.cur_patch) <NEW_LINE> destination_patch.attackTile(constraints,self)
attack tile on destination_patch
625941e4507cdc57c63070f1
@app.route('/edit_nginx/validate_nginx', methods=['GET', 'POST']) <NEW_LINE> def validate_nginx(): <NEW_LINE> <INDENT> result = subprocess.Popen(nginx_head_path + '/sbin/nginx -t -c ' + nginx_file_path ,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT) <NEW_LINE> result.wait() <NEW_LINE> return str(result.st...
检查nginx配置文件语法
625941e44428ac0f6e5bac03
def get_sessions_by_speaker_in_wishlist(self, user): <NEW_LINE> <INDENT> sessions = self.wishlist_sessions(user) <NEW_LINE> speaker_keys = [] <NEW_LINE> for s in sessions: <NEW_LINE> <INDENT> sk = getattr(s, 'speakerKeys', []) <NEW_LINE> speaker_keys += sk <NEW_LINE> <DEDENT> if not speaker_keys: <NEW_LINE> <INDENT> re...
Gets a list of sessions by speakers referenced in user's wishlist. Args: user (endpoints.user) Returns: ConferenceSessionForms
625941e4b7558d58953c5319
def perform(self, cmd, *args): <NEW_LINE> <INDENT> trace(cmd, args) <NEW_LINE> cc = self.cc <NEW_LINE> buf = self.buf <NEW_LINE> if 'copy' == cmd: <NEW_LINE> <INDENT> if _text_select_present(buf): <NEW_LINE> <INDENT> text = buf.get(SEL_FIRST, SEL_LAST) <NEW_LINE> cc.set_clipboard_text(text) <NEW_LINE> <DEDENT> return '...
メニュー選択により動作する機能
625941e4b830903b967e9d14
def file_delete(self): <NEW_LINE> <INDENT> if os.path.exists(self.file_location): <NEW_LINE> <INDENT> os.remove(self.file_location) <NEW_LINE> return 1 <NEW_LINE> <DEDENT> return 0
() -> int If file exsists deletes the file and returns 1 If file does not exist returns 0
625941e445492302aab5e6d5
def test_02_basics(self): <NEW_LINE> <INDENT> self.pkg("install pkg://test1/foo") <NEW_LINE> self.pkg("list foo") <NEW_LINE> self.pkg("list pkg://test1/foo") <NEW_LINE> self.pkg("uninstall foo")
Test install from an explicit preferred publisher
625941e4656771135c3ebc81
def testAdvancedOpcodeUpdateINAllow(self): <NEW_LINE> <INDENT> name = 'opcodeupdate.advanced.tests.powerdns.com.' <NEW_LINE> query = dns.message.make_query(name, 'A', 'IN') <NEW_LINE> query.set_opcode(dns.opcode.UPDATE) <NEW_LINE> response = dns.message.make_response(query) <NEW_LINE> rrset = dns.rrset.from_text(name, ...
Advanced: Allow Opcode UPDATE
625941e438b623060ff0b1fb
def convert2gray(img): <NEW_LINE> <INDENT> if len(img.shape)>2: <NEW_LINE> <INDENT> gray = np.mean(img, -1) <NEW_LINE> return gray <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return img
图片转黑白 即3维转1维 把彩色图像转为灰度图像(色彩对识别验证码没有什么用) :param img: :return:
625941e4b545ff76a8914223
def get_bot_sum(self): <NEW_LINE> <INDENT> sum = 0 <NEW_LINE> for card in self.bot_cards: <NEW_LINE> <INDENT> if card.rank == 1: <NEW_LINE> <INDENT> sum += 11 <NEW_LINE> continue <NEW_LINE> <DEDENT> if card.rank >= 10: <NEW_LINE> <INDENT> sum += 10 <NEW_LINE> continue <NEW_LINE> <DEDENT> sum += card.rank <NEW_LINE> <DE...
1はまず11として数えて、それで21を超えていれば1としてカウントします。
625941e43c8af77a43ae3bb2
def seed(self, seed): <NEW_LINE> <INDENT> self.np_random = np.random.RandomState() <NEW_LINE> self.np_random.seed(seed) <NEW_LINE> self.seed = random.seed(seed)
Seed the environment
625941e4627d3e7fe0d6925f
def fit_MSD(array_MSD): <NEW_LINE> <INDENT> N = array_MSD.shape[1] <NEW_LINE> if N <= 100: <NEW_LINE> <INDENT> n = 10 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> n = N/10 <NEW_LINE> <DEDENT> t = array_MSD[0,:n] <NEW_LINE> MSD = array_MSD[1,:n] <NEW_LINE> x0 = ([1,1]) <NEW_LINE> fit_par, fit_cov = optimize.curve_fit(M...
Given a MSD array of a trace, fits the MSD with the function MSD_func and obtains the diffusion coefficient D (and the positional accuracy s, which I don't use here). Usually only the first 10% of the points is used for the MSD fit, because for large time delays the contribute of the noise in the diffusion dominates o...
625941e49f2886367277ac98
def allowRootAccess(self): <NEW_LINE> <INDENT> return Proxy.send(self,"allowRootAccess")
Indicates whether you or your application has access to the root frame of the Teleplace. Defaults to True
625941e432920d7e50b285e1
def srcrev_internal_helper(ud, d, name): <NEW_LINE> <INDENT> if 'rev' in ud.parm: <NEW_LINE> <INDENT> return ud.parm['rev'] <NEW_LINE> <DEDENT> if 'tag' in ud.parm: <NEW_LINE> <INDENT> return ud.parm['tag'] <NEW_LINE> <DEDENT> rev = None <NEW_LINE> pn = d.getVar("PN", True) <NEW_LINE> if name != '': <NEW_LINE> <INDENT>...
Return: a) a source revision if specified b) latest revision if SRCREV="AUTOINC" c) None if not specified
625941e4adb09d7d5db6cb9b
def add_role(self, role, sort_rules=False, use_rbac_role=True): <NEW_LINE> <INDENT> if not isinstance(role, RbacRole): <NEW_LINE> <INDENT> if isinstance(role, basestring): <NEW_LINE> <INDENT> if role in self.roles: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if not use_rbac_role: <NEW_LINE> <INDENT> self.roles....
Adds the role and role rules to the user roles and rules lists. If the role is already added we don't do anything. This method don't check if a Role rules definition has changed. :param role: RbacRole Model or role name string to append to the user rules. :param sort_rules: will sort all the rules at the end. ...
625941e40a50d4780f6672a3
def get_mapview_config(): <NEW_LINE> <INDENT> namespace = 'ckanext.spatial.common_map.' <NEW_LINE> return {k.replace(namespace, ''): v for k, v in six.iteritems(config) if k.startswith(namespace)}
Extracts and returns map view configuration of the reclineview extension.
625941e4a934411ee3751aa2
def get(self): <NEW_LINE> <INDENT> return self._invoke('get', None)
Get load health. :rtype: :class:`Load.HealthLevel` :return: Load health. :raise: :class:`com.vmware.vapi.std.errors_client.Error` Generic error
625941e423849d37ff7b349a
def add_handler(self, handler, channels): <NEW_LINE> <INDENT> if isinstance(channels, str): <NEW_LINE> <INDENT> channels = {channels} <NEW_LINE> <DEDENT> invalid_channels = channels - self.handler_channels <NEW_LINE> if invalid_channels: <NEW_LINE> <INDENT> raise ValueError("Invalid channel names: %s" % invalid_channel...
Add a callback for received messages on one or more channels. Parameters ---------- handler : function Will be called for each message received with the message dictionary as a single argument. channels : set or str Channel names: 'shell', 'iopub', 'stdin' or 'control'
625941e4d486a94d0b98e555
def degrees_to_radians(deg): <NEW_LINE> <INDENT> return deg / 180.0 * pi
:type deg: float or int
625941e4e64d504609d74c4e
def dma_name(key): <NEW_LINE> <INDENT> if not have_DMAMUX: <NEW_LINE> <INDENT> return "DMA" <NEW_LINE> <DEDENT> for p in DMAMUX2_peripherals: <NEW_LINE> <INDENT> if key.find(p) != -1: <NEW_LINE> <INDENT> return 'BDMA' <NEW_LINE> <DEDENT> <DEDENT> return 'DMA'
return 'DMA' or 'BDMA' based on peripheral name
625941e4956e5f7376d7127a
def predict(self, X): <NEW_LINE> <INDENT> W1, b1 = self.params['W1'], self.params['b1'] <NEW_LINE> W2, b2 = self.params['W2'], self.params['b2'] <NEW_LINE> hidden_layer = np.maximum(0, np.dot(X, W1) + b1) <NEW_LINE> scores = np.dot(hidden_layer, W2) + b2 <NEW_LINE> y_pred = np.argmax(scores, axis=1) <NEW_LINE> return y...
Use the trained weights of this two-layer network to predict labels for data points. For each data point we predict scores for each of the C classes, and assign each data point to the class with the highest score. Inputs: - X: A numpy array of shape (N, D) giving N D-dimensional data points to classify. Returns: - ...
625941e4ec188e330fd5aba5
def get_tone(self, character, ignore_unknown=True): <NEW_LINE> <INDENT> if self.__codes is None: <NEW_LINE> <INDENT> self.generate_tones() <NEW_LINE> <DEDENT> character = character.upper() <NEW_LINE> char_int = ord(character) <NEW_LINE> if (48 <= char_int <= 57) or (65 <= char_int <= 90): <NEW_LINE> <INDENT> return sel...
Return the Morse Code NumPy Array for a character :param character: (str) alphabetic character, in the range A-Z, a-z and 0-9 :param ignore_unknown: (bool) Return a blank character if the character is not found, or raise an CharacterNotFound exception :raise TypeError: If a single character is not passed :raise Ch...
625941e43d592f4c4ed1d470
@raises(SystemExit) <NEW_LINE> def test_main_noargs(): <NEW_LINE> <INDENT> startdir = os.getcwd() <NEW_LINE> d = tempfile.mkdtemp() <NEW_LINE> os.chdir(d) <NEW_LINE> parser = argparse.ArgumentParser() <NEW_LINE> parser.add_argument('--glob', default=os.path.join(os.getcwd(),"backup*.gz.gpg")) <NEW_LINE> args=parser.par...
calling main, passing no arguments.
625941e48a43f66fc4b5446f
def wiggleMaxLength2(self, nums): <NEW_LINE> <INDENT> length = len(nums) <NEW_LINE> if length <= 1: <NEW_LINE> <INDENT> return length <NEW_LINE> <DEDENT> big = (nums[1] - nums[0] > 0) <NEW_LINE> count = 1 <NEW_LINE> for i in range(1, length): <NEW_LINE> <INDENT> if (big and nums[i] - nums[i-1] > 0) or (not big and nums...
Greedy solution according to current stage(bigger or smaller), anticipate next stage. Then check if this anticipate meets. :param nums: :return:
625941e4566aa707497f4971
def scale(self): <NEW_LINE> <INDENT> return self._value
Return a rational number `r` such that ``self`` is equal to `r e^{2 \pi i q}` for some `q \in (-1/2, 1/2]`. In other words, just return self as a rational number. EXAMPLES:: sage: QQbar(-3)._descr.scale() -3
625941e46e29344779a62a1e
def get_repomd_iso_publish_path(self, export_dir, distributor): <NEW_LINE> <INDENT> return os.path.join( export_dir, self.repo['id'], 'repodata', 'repomd.xml' )
Provide the repomd.xml publish path within an exported ISO.
625941e4293b9510aa2c36a0
def check_connection(self, url): <NEW_LINE> <INDENT> self.messagebox("Checking Server Status...") <NEW_LINE> conn = CommonUtil.check_connection(url) <NEW_LINE> if conn: <NEW_LINE> <INDENT> self.statusinfo[0][1] = "OK" <NEW_LINE> self.statusinfo[0][2] = "GREEN" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.statusin...
Check connection status to the server currently selected by user and show a status box indicating current operation. :param url: The link of the server chose by user.This string could be a domain name or the IP address of a server. .. seealso:: :attr:`link` in :meth:`~util.common.CommonUtil.check_con...
625941e47b180e01f3dc4c03
def test_get_resource_access_state(self): <NEW_LINE> <INDENT> request = self.make_request() <NEW_LINE> with mock.patch(self.get_page_method, return_value=request.feincms_page): <NEW_LINE> <INDENT> access_state = self.middleware._get_resource_access_state(request) <NEW_LINE> <DEDENT> expected_state = self.CUSTOM_STATE <...
Assert that the correct access_state value comes back from the request.
625941e4009cb60464c637bc
def wordFreq(book, word): <NEW_LINE> <INDENT> freq = Counter(book) <NEW_LINE> return freq[word]
Count the frequency of a word in a book :param book: :param word: :return:
625941e44e4d5625662d47e0
def regions_equal(r1, r2): <NEW_LINE> <INDENT> return r1.begin() == r2.begin() and r1.end() == r2.end()
Region.__eq__ seems to compare by r.a and r.b
625941e46fb2d068a760f4b2
def updateInDB(self): <NEW_LINE> <INDENT> dbHotel = Hotel.query.get([self.name, self.lang]) <NEW_LINE> dbHotel.valuableInfo = self.valuableInfo <NEW_LINE> dbHotel.positives = self.positives <NEW_LINE> dbHotel.negatives = self.negatives <NEW_LINE> db.session.add(dbHotel) <NEW_LINE> db.session.commit()
Actualiza el modelo Hotel de la BD. Actualiza un Hotel almacenando los valores obtenidos del análisis del Lenguaje Natural, servicios del hotel y valoración de los clientes.
625941e48da39b475bd65387
def random_airports_removal(gsc_SC_KM, nodes_statuses_pre_treatment, verbose, method_kwargs): <NEW_LINE> <INDENT> if verbose: <NEW_LINE> <INDENT> print('Perform random vaccination...') <NEW_LINE> <DEDENT> num_nodes_to_remove = int( gsc_SC_KM.number_of_nodes() * method_kwargs['nodes_percenta...
Remove random nodes (airports) of the graph.
625941e455399d3f05588ac5
def setCriterion(portal, folder_name, index, operator, value=None): <NEW_LINE> <INDENT> folder = getattr(portal, folder_name, None) <NEW_LINE> if folder and getattr(folder, "index", False): <NEW_LINE> <INDENT> collection = folder.index <NEW_LINE> if not getattr(collection, "query", False): <NEW_LINE> <INDENT> migrateTo...
Change existing criterion to collection, or add a new one
625941e423e79379d52ee96d
def __str__(self): <NEW_LINE> <INDENT> return "WAMP Call-Result Message (callid = '%s', result = %s)" % (self.callid, self.result)
Returns text representation of this instance. :returns str -- Human readable representation (eg for logging or debugging purposes).
625941e4b830903b967e9d15
def test_403(self): <NEW_LINE> <INDENT> delay = self.proxy.check_for_delay("GET", "/delayed") <NEW_LINE> self.assertEqual((None, None), delay) <NEW_LINE> delay, error = self.proxy.check_for_delay("GET", "/delayed") <NEW_LINE> error = error.strip() <NEW_LINE> expected = ("60.00", ( "403 Forbidden\n\nOnly 1 GET request(s...
Forbidden request test.
625941e4d8ef3951e324394c
def _cleanup_cg_share_snapshot(self, context, share_snapshot, share_server): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.delete_snapshot(context, share_snapshot, share_server) <NEW_LINE> <DEDENT> except exception.ManilaException: <NEW_LINE> <INDENT> msg = _LE('Could not delete CG Snapshot %(snap)s ' 'for share %(...
Deletes the snapshot of a share belonging to a consistency group.
625941e42ae34c7f2600d53f
def export(target, ide, build=None, src=None, macros=None, project_id=None, zip_proj=False, build_profile=None, export_path=None, silent=False, app_config=None): <NEW_LINE> <INDENT> project_dir, name, src, lib = setup_project(ide, target, program=project_id, source_dir=src, build=build, export_path=export_path) <NEW_LI...
Do an export of a project. Positional arguments: target - MCU that the project will compile for ide - the IDE or project structure to export to Keyword arguments: build - to use the compiled mbed libraries or not src - directory or directories that contain the source to export macros - extra macros to add to the proj...
625941e471ff763f4b549aa1
def test_applications_id_apis_post(self): <NEW_LINE> <INDENT> pass
Test case for applications_id_apis_post Create a request for an application to access an API. # noqa: E501
625941e463d6d428bbe448ff
def test_select_destination_placement_connect_fails(self): <NEW_LINE> <INDENT> place_res = None <NEW_LINE> self._test_select_destination(place_res)
Tests that we will raise NoValidHost when the scheduler report client's get_allocation_candidates() returns None, which it would if the connection to Placement failed and the safe_connect decorator returns None.
625941e424f1403a92600f71
def get_users(): <NEW_LINE> <INDENT> out = {} <NEW_LINE> data = get_data() <NEW_LINE> users = get_users_from_xml() <NEW_LINE> for i in data.keys(): <NEW_LINE> <INDENT> user = users.get(str(i)) <NEW_LINE> if user: <NEW_LINE> <INDENT> out[i] = user <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> out[i] = { 'avatar': '/api/...
Comparing lists ID's extracted from xml file and csv. If ID from CSV file is not in XML file adding default values. Structure of dict is below: {'151': {'avatar': '/api/images/users/151', 'name': 'Dawid J.'}, 18: {'avatar': '/api/images/users/00', 'name': 'User 18'}}
625941e4a8ecb033257d34da
def stub_out(stubs, funcs): <NEW_LINE> <INDENT> for func in funcs: <NEW_LINE> <INDENT> func_name = '_'.join(func.__name__.split('_')[1:]) <NEW_LINE> stubs.Set(db, func_name, func) <NEW_LINE> stubs.Set(db.api, func_name, func)
Set the stubs in mapping in the db api.
625941e4435de62698dfe05b
def load_weight(weight_file: str, weight_name: str, weight_file_cache: Dict[str, Dict]) -> mx.nd.NDArray: <NEW_LINE> <INDENT> logger.info('Loading input weight file: %s', weight_file) <NEW_LINE> if weight_file.endswith(".npy"): <NEW_LINE> <INDENT> return np.load(weight_file) <NEW_LINE> <DEDENT> elif weight_file.endswit...
Load wight fron a file or the cache if it was loaded before. :param weight_file: Weight file. :param weight_name: Weight name. :param weight_file_cache: Cache of loaded files. :return: Loaded weight.
625941e4046cf37aa974d152
def findDisappearedNumbers4(self, nums): <NEW_LINE> <INDENT> for num in nums: <NEW_LINE> <INDENT> nums[abs(num) - 1] = - abs(nums[abs(num) - 1]) <NEW_LINE> <DEDENT> return [i for i, num in enumerate(nums, 1) if num > 0]
原地修改,给数组中数字索引取反,然后大于0的索引即答案 :type nums: List[int] :rtype: List[int]
625941e47b25080760e39865
def enable_simulation(self): <NEW_LINE> <INDENT> self.pushButton_chMethod.setEnabled(True) <NEW_LINE> self.pushButton_cancelAnalysis.setEnabled(True)
Method to enable the simulation in the GUI
625941e4eab8aa0e5d26df68
def loadSingleJsonConfig(self): <NEW_LINE> <INDENT> return 0
load single json config file
625941e476e4537e8c351a84
def _get_one_by_id(self, id, requester_user, permission_type, exclude_fields=None, from_model_kwargs=None): <NEW_LINE> <INDENT> instance = self._get_by_id(resource_id=id, exclude_fields=exclude_fields) <NEW_LINE> if permission_type: <NEW_LINE> <INDENT> rbac_utils.assert_user_has_resource_db_permission(user_db=requester...
:param exclude_fields: A list of object fields to exclude. :type exclude_fields: ``list``
625941e43617ad0b5ed68305
def compute_correlations(self): <NEW_LINE> <INDENT> self.means = [0 for i in range(self.vector_size)] <NEW_LINE> self.correlations = [0 for i in range(self.vector_size)] <NEW_LINE> n = len(self.correlation_train_data) <NEW_LINE> for line in self.correlation_train_data: <NEW_LINE> <INDENT> for i in range(self.vector_siz...
Computes the correlations between the values of the vectors and the notes of the reviews from the training set
625941e4596a897236089eca
def values(self): <NEW_LINE> <INDENT> return self._values
Return the values in the row.
625941e4627d3e7fe0d69260
def train(self, X, y): <NEW_LINE> <INDENT> self.X = X <NEW_LINE> self.y = y
Use this function to train
625941e4be7bc26dc91cda07
def test_bootstrap_succeeded(self): <NEW_LINE> <INDENT> cmd = ("openstack-juju stat --format yaml") <NEW_LINE> out = utils.get_command_output(cmd) <NEW_LINE> out = out['output'] <NEW_LINE> assert('environment: local' in out)
Verifies a local bootstrap happened
625941e44f6381625f114e4a
def pay(): <NEW_LINE> <INDENT> payment = 0 <NEW_LINE> q = float(input("How many quarters?: ")) <NEW_LINE> d = float(input("How many dimes?: ")) <NEW_LINE> n = float(input("How many nickels?: ")) <NEW_LINE> p = float(input("How many pennies?: ")) <NEW_LINE> payment += q * QUARTER <NEW_LINE> payment += d * DIME <NEW_LINE...
Calculates payment entered
625941e463b5f9789fde74f4
def scale_poly(c, power=1, eccen=1): <NEW_LINE> <INDENT> return int(((c / 255)**(power * eccen)) * 255)
Reshape a color curve into a different order/eccentricity polynomial.
625941e48c3a8732951587ce
def read_defaults_file(self, settings_file): <NEW_LINE> <INDENT> super().read_defaults_file(settings_file) <NEW_LINE> self.global_contexts = pickle.load(settings_file) <NEW_LINE> self._migrate_contexts(self.global_contexts)
Call the inherited method, then read global context from the pickle.
625941e41d351010ab855f2a
def search(self): <NEW_LINE> <INDENT> if self.ui.tabs.currentIndex() == 0 and self.ui.searchbar_PS.text() != "": <NEW_LINE> <INDENT> self.search_data_PS = util.search_patches(self.ps.get_data_ps(), self.ui.searchbar_PS.text()) <NEW_LINE> self.set_data(True) <NEW_LINE> <DEDENT> elif self.ui...
Initiates a data search for the metadata that is retrieved via the PS API or that is stored locally. The search will then set the table to display the returned query matches. Currently triggered via a button press.
625941e43317a56b8693a05d
def __init__(self, capacity): <NEW_LINE> <INDENT> self.container = OrderedDict() <NEW_LINE> self.capacity = capacity
:type capacity: int
625941e430c21e258bdfa8b0
def chamfer(self: T, length: float, length2: Optional[float] = None) -> T: <NEW_LINE> <INDENT> solid = self.findSolid() <NEW_LINE> edgeList = cast(List[Edge], self.edges().vals()) <NEW_LINE> if len(edgeList) < 1: <NEW_LINE> <INDENT> raise ValueError("Chamfer requires that edges be selected") <NEW_LINE> <DEDENT> s = sol...
Chamfers a solid on the selected edges. The edges on the stack are chamfered. The solid to which the edges belong must be in the parent chain of the selected edges. Optional parameter `length2` can be supplied with a different value than `length` for a chamfer that is shorter on one side longer on the other side. :p...
625941e4460517430c394589
def IndexOf(self,value): <NEW_LINE> <INDENT> pass
IndexOf(self: PerformanceCounterPermissionEntryCollection,value: PerformanceCounterPermissionEntry) -> int Determines the index of a specified permission entry in this collection. value: The permission entry for which to search. Returns: The zero-based index of the specified permission entry,or -1 if the perm...
625941e44f6381625f114e4b
def __eq__(self, other): <NEW_LINE> <INDENT> return int(self.value) == int(other.value)
Needed for sorting the dice
625941e496565a6dacc8fad9
def signal_to_frames(signal, fs, window_size, fs_desired=None): <NEW_LINE> <INDENT> if fs_desired is not None: <NEW_LINE> <INDENT> signal = sig.resample_poly(signal, fs_desired, fs) <NEW_LINE> fs = fs_desired <NEW_LINE> <DEDENT> n_samples = len(signal) <NEW_LINE> n_window_samples = 2 * np.floor(window_size * fs / 2) <N...
From a 1-d sound signal, builds the corresponding frame matrix Y Parameters ---------- signal : array, shape (n_samples, ) Input sound signal fs : float Sampling frequency of fs window_size : float Window size in ms fs_desired: float | None Over/sub-samble the signal.
625941e4004d5f362079a740
def set_generic(self, name, value): <NEW_LINE> <INDENT> self._config.set_generic(name.lower(), value, scope=self._scope)
Set generic for test case
625941e456ac1b37e62645d7
def resize_spectrogram(data, ratio): <NEW_LINE> <INDENT> spec = stft(data) <NEW_LINE> resize_spec = np.apply_along_axis(resize, 1, spec, ratio) <NEW_LINE> return istft(resize_spec)
This function speeds up a WAV file, without changing the pitch, using spectrogram scaling :param data: a 1D ndarray of dtype float64 representing the original samples points :param ratio: a positive float64 representing the rate change of the WAV file :return: a new sample points according to ratio
625941e4711fe17d82542771
def setup_visualizer(self, focus=None, visualiser_mode=None, visualiser_2d_dimension=None, visualiser_raster_seperate=None, visualiser_no_colours=None, visualiser_average_period_tics=None, visualiser_longer_period_tics=None, visualiser_update_screen_in_tics=None, visualiser_reset_counters=None, visualiser_reset_counter...
method that sets the data on how the visualiser is to represent this vertex at runtime if at all
625941e47b25080760e39866
def insert_es_log(es, es_index_prefix, doc_type, doc_id, status, detail): <NEW_LINE> <INDENT> now = datetime.now() <NEW_LINE> doc = { 'accession': doc_id, 'type': doc_type, 'status': status, 'detail': detail, 'last_update': now } <NEW_LINE> insert_into_es(es, es_index_prefix, 'log', doc_id, doc)
insert a log entry for the data record into ES :param es: elasticsearch python library instance :param es_index_prefix: form the string <es_index_prefix>_log, which is the index tge log entry will be written into :param doc_type: the type of the data record :param doc_id: the id of the data record :param status: the st...
625941e4460517430c39458a
def get_secret(setting, secrets): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return secrets[setting] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> error_msg = "Set the {0} environment variable".format(setting) <NEW_LINE> raise ImproperlyConfigured(error_msg)
Get the secret variable or return explicit exception.
625941e431939e2706e4d273
def start(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> for user_config in self.user_config_list: <NEW_LINE> <INDENT> self.initialize_info(user_config) <NEW_LINE> self.get_pages() <NEW_LINE> if self.user_config_file_path: <NEW_LINE> <INDENT> self.update_user_config_file(self.user_config_file_path) <NEW_LINE> <DED...
运行爬虫
625941e450812a4eaa59c72d
def get_weather_station(self): <NEW_LINE> <INDENT> if self.conn: <NEW_LINE> <INDENT> s = select([weather_stations.c.id]).where(weather_stations.c.usaf_id == self.station_id) <NEW_LINE> result = self.conn.execute(s) <NEW_LINE> row = result.fetchone() <NEW_LINE> if row: <NEW_LINE> <INDENT> self.weather_station_pk = row['...
Sets the weather_station_pk attribute using the db connection and self.station_id, if available.
625941e47cff6e4e81117d94
def two_view_reconstruction_rotation_only(p1, p2, camera1, camera2, threshold): <NEW_LINE> <INDENT> b1 = camera1.pixel_bearing_many(p1) <NEW_LINE> b2 = camera2.pixel_bearing_many(p2) <NEW_LINE> R = multiview.relative_pose_ransac_rotation_only( b1, b2, 1 - np.cos(threshold), 1000, 0.999) <NEW_LINE> inliers = _two_view_r...
Find rotation between two views from point correspondences. Args: p1, p2: lists points in the images camera1, camera2: Camera models threshold: reprojection error threshold Returns: rotation and inlier list
625941e456b00c62f0f14a6b
def fit(self, X, y=None): <NEW_LINE> <INDENT> m, n = X.shape <NEW_LINE> self.map_ = [] <NEW_LINE> for j in range(n): <NEW_LINE> <INDENT> counter = Counter(X[:,j]) <NEW_LINE> keys = [k for k, c in counter.items() if c > self.threshold] <NEW_LINE> self.map_.append(self._encode(keys)) <NEW_LINE> <DEDENT> return self
X is an array of shape [n_samples, n_features]
625941e4be8e80087fb2104c
def _update_model_pars(self): <NEW_LINE> <INDENT> for key in self.parinfo.keys(): <NEW_LINE> <INDENT> sl = self.parinfo[key][0] <NEW_LINE> val = self[sl] <NEW_LINE> if len(val) == 1: <NEW_LINE> <INDENT> val = val[0] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> val = val <NEW_LINE> <DEDENT> par = getattr(self.mobj, key...
Update single parameters
625941e48a43f66fc4b54470
def _concat(self, items): <NEW_LINE> <INDENT> if items is None: <NEW_LINE> <INDENT> return '' <NEW_LINE> <DEDENT> if isinstance(items, string_types): <NEW_LINE> <INDENT> items = [items] <NEW_LINE> <DEDENT> return ','.join(i for i in items if i != '_all')
Return a comma-delimited concatenation of the elements of ``items``, with any occurrences of "_all" omitted. If ``items`` is a string, promote it to a 1-item list.
625941e4a17c0f6771cbe45e
def get_cost_policy_formulas_grid_column_names_by_order(self): <NEW_LINE> <INDENT> self.column_name_list = self.get_grid_column_names_by_order(self.cost_policies_formulas_grid_div_id) <NEW_LINE> return self.column_name_list
Implementing get cost policy formulas grid column names by order functionality :return: column_name_list
625941e4cb5e8a47e48b7eb3
def itkMaskNegatedImageFilterIVF22IUC2IVF22_Superclass_cast(*args): <NEW_LINE> <INDENT> return _itkMaskNegatedImageFilterPython.itkMaskNegatedImageFilterIVF22IUC2IVF22_Superclass_cast(*args)
itkMaskNegatedImageFilterIVF22IUC2IVF22_Superclass_cast(itkLightObject obj) -> itkMaskNegatedImageFilterIVF22IUC2IVF22_Superclass
625941e4b545ff76a8914224
def test_ifelse(): <NEW_LINE> <INDENT> res = run(('openalea.python method', 'ifelse'), inputs={'c': True, 'a': 'a', 'b': 'b'}, pm=pm) <NEW_LINE> assert res[0] == 'a' <NEW_LINE> res = run(('openalea.python method', 'ifelse'), inputs={'c': False, 'a': 'a', 'b': 'b'}, pm=pm) <NEW_LINE> assert res[0] == 'b'
Test of node ifelse
625941e4a8370b7717052cac
def analyse(self): <NEW_LINE> <INDENT> gameid = self.game.gameid <NEW_LINE> logging.debug("gameid %d, AnalysisReplayer, analyse", gameid) <NEW_LINE> items = [self.session.query(table) .filter(table.gameid == gameid).all() for table in [GameHistoryBoard, GameHistoryUserRange, GameHistoryActionResult, GameHistoryRangeAct...
Perform all analysis on game that has not been done. If you need to reanalyse the game, delete the existing analysis first.
625941e4099cdd3c635f1068
def set_simple_message(self, message, title=None, color=None, fallback=None): <NEW_LINE> <INDENT> if color is None: <NEW_LINE> <INDENT> color = self.color <NEW_LINE> <DEDENT> if fallback is None: <NEW_LINE> <INDENT> fallback = title or message <NEW_LINE> <DEDENT> self.json_attachments = { "fallback": fallback, "color":...
Sets formatted json to use in sending a Slack notification using only a provided message. Requires: - str(message): The body text of the message Optional: - str(title): The title of the message - str(color): The color of the message - str(fallback): The fallback text. Same as title by default Returns: ...
625941e4baa26c4b54cb152b
def hasNext(self): <NEW_LINE> <INDENT> return self.cur != None or len(self.stack) > 0
:rtype: bool
625941e4f9cc0f698b140a07
def count_dates_from_messages(messages: List[Message]) -> Tuple[Dates, Frequencies]: <NEW_LINE> <INDENT> dates = [] <NEW_LINE> for mes in messages: <NEW_LINE> <INDENT> dates.append(fromtimestamp(mes.get('date'))) <NEW_LINE> <DEDENT> frequencies = Counter(dates) <NEW_LINE> return list(frequencies.keys()), list(frequenci...
Получить список дат и их частот :param messages: список сообщений
625941e4e8904600ed9f2342
def accel(message): <NEW_LINE> <INDENT> global normalShake, shakeTrigger, shakeAmount <NEW_LINE> args = message.getArguments() <NEW_LINE> shake = args[0] <NEW_LINE> shakeAmount = abs(shake - normalShake) <NEW_LINE> if shakeAmount > shakeTrigger: <NEW_LINE> <INDENT> drawCircle()
Sets global variable 'shakeAmount'. If 'shakeAmount' is higher than 'shakeTrigger', we call function drawCircle().
625941e4fb3f5b602dac3aa7
def isValidWord(word, hand, wordList): <NEW_LINE> <INDENT> if word not in wordList: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> frequencies = [] <NEW_LINE> for letter in hand.keys(): <NEW_LINE> <INDENT> frequencies.append(hand[letter]) <NEW_LINE> <DEDENT> newHand = dict(zip(hand.keys(...
Returns True if word is in the wordList and is entirely composed of letters in the hand. Otherwise, returns False. Does not mutate hand or wordList. word: string hand: dictionary (string -> int) wordList: list of lowercase strings
625941e40c0af96317bb85f7
def get_detailtrans_21cn(data_base, type): <NEW_LINE> <INDENT> data21cn = data_base.get("ec21") if type == 'en' else data_base.get("ce_new") <NEW_LINE> if not data21cn: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> detailtrans_dict = {} <NEW_LINE> data21cn = data21cn.get("word")[0] <NEW_LINE> data21cn_trs = data2...
get 21 detail trans dict :param data_base: :param type: :return:
625941e4cdde0d52a9e53445
def mouseDoubleClickEvent(self, event): <NEW_LINE> <INDENT> Qutepart.mouseDoubleClickEvent(self, event) <NEW_LINE> if self.selectedText: <NEW_LINE> <INDENT> selectedPos = self.absSelectedPosition <NEW_LINE> self.onHighlight() <NEW_LINE> self.absSelectedPosition = selectedPos
Highlight the current word keeping the selection
625941e421a7993f00bc8106