code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def isColumnEditingEnabled(self, column): <NEW_LINE> <INDENT> return self._columnEditing.get(column, True) | Sets whether or not the given column for this item should be editable.
:param column | <int>
:return <bool> | 625941de167d2b6e31218ec4 |
def create_user(self, username, password): <NEW_LINE> <INDENT> user = self.create(username=username) <NEW_LINE> user.set_password(password) <NEW_LINE> user.save(using=self._db) <NEW_LINE> return user | Creates and saves a User with the given username and password. | 625941de45492302aab5e5f6 |
def __eq__(self, other): <NEW_LINE> <INDENT> if hasattr(other, "element_info"): <NEW_LINE> <INDENT> return self.element_info == other.element_info <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return self.element_info == other | Returns true if 2 BaseWrapper's describe 1 actual element | 625941de8c3a8732951586ed |
def __init__(self): <NEW_LINE> <INDENT> self.matrix = [['●' for x in range(7)] for y in range(6)] | Initializer for the Board class
It contains a pseudo-matrix which memories the state of the board | 625941ded8ef3951e324386d |
def has_anagram(counter_dict, word): <NEW_LINE> <INDENT> for w in counter_dict: <NEW_LINE> <INDENT> if sorted(w) == sorted(word): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> return False | Return True if the word has an anagram in the dictionnary else False | 625941de07d97122c4178bc2 |
def main(): <NEW_LINE> <INDENT> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'authentification.settings') <NEW_LINE> try: <NEW_LINE> <INDENT> from django.core.management import execute_from_command_line <NEW_LINE> <DEDENT> except ImportError as exc: <NEW_LINE> <INDENT> raise ImportError( "Couldn't import Django. Are... | Run administrative tasks. | 625941debe383301e01b57b0 |
def ctrl_v(self): <NEW_LINE> <INDENT> self.tag_keys(self._search_bar,'CONTROL','v') <NEW_LINE> return self | 粘贴 | 625941de627d3e7fe0d69181 |
def remove_cluster_file(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> os.remove(self.cluster_file) <NEW_LINE> <DEDENT> except FileNotFoundError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.log.debug(f"Removed cluster file: {self.cluster_file}") | Remove my cluster file. | 625941de3eb6a72ae02ec815 |
def get_function_pars(fn): <NEW_LINE> <INDENT> pars = [] <NEW_LINE> par_names = pyLike.StringVector() <NEW_LINE> fn.getParamNames(par_names) <NEW_LINE> for pname in par_names: <NEW_LINE> <INDENT> par = fn.getParam(pname) <NEW_LINE> bounds = par.getBounds() <NEW_LINE> perr = par.error() if par.isFree() else np.nan <NEW_... | Extract the parameters of a pyLikelihood function object
(value, scale, bounds).
Parameters
----------
fn : pyLikelihood.Function
Returns
-------
pars : list | 625941de566aa707497f4895 |
def __init__(self, id=None, name=None, description=None, available_from=None, available_until=None, decimal_price=None, trips=None, courses=None, accommodations=None): <NEW_LINE> <INDENT> self.swagger_types = { 'id': 'int', 'name': 'str', 'description': 'str', 'available_from': 'date', 'available_until': 'date', 'decim... | Package - a model defined in Swagger
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
:param dict attributeMap: The key is attribute name
and the value is json key in definition. | 625941de293b9510aa2c35c2 |
def __set_name__(self, owner, name): <NEW_LINE> <INDENT> self.owner = owner <NEW_LINE> self.name = name | Inherit ownership pointer and name. | 625941de21a7993f00bc8025 |
def describe_task_execution(self, task_execution_arn): <NEW_LINE> <INDENT> return self.get_conn().describe_task_execution(TaskExecutionArn=task_execution_arn) | Get description for the specified ``task_execution_arn``.
:param str task_execution_arn: TaskExecutionArn
:return: AWS metadata about a task execution.
:rtype: dict
:raises AirflowBadRequest: If ``task_execution_arn`` is empty. | 625941decdde0d52a9e53365 |
@pvm_retry.retry() <NEW_LINE> def list_bridges(adapter, host_uuid): <NEW_LINE> <INDENT> net_bridges = pvm_net.NetBridge.get(adapter, parent_type=pvm_ms.System, parent_uuid=host_uuid) <NEW_LINE> if len(net_bridges) == 0: <NEW_LINE> <INDENT> LOG.warning('No NetworkBridges detected on the host.') <NEW_LINE> <DEDENT> retur... | Lists NetBridge wrappers on the system.
:param adapter: The pypowervm adapter.
:param host_uuid: The UUID for the host system. | 625941dec4546d3d9de72d66 |
def random_name(size): <NEW_LINE> <INDENT> return ''.join(next(_random_letter_generator) for _ in xrange(size)).capitalize() | Return random name of given size.
It rotates between consonants and vowels.
Rotation is global first letter depends on prev calls. | 625941dee8904600ed9f2261 |
def open_qasm(self): <NEW_LINE> <INDENT> res = q1tsimffi.unpack_result(self.__sim.circuit_open_qasm(self.__ptr)) <NEW_LINE> return res | Export to OpenQasm
Export this circuit to a program in OpenQasm format. On a successful
conversion, returns a string with the program text. | 625941de293b9510aa2c35c3 |
def bldTree(self): <NEW_LINE> <INDENT> dic_loc = {} <NEW_LINE> dep = 1 <NEW_LINE> tag = [0] <NEW_LINE> for label in self.dic_data.keys(): <NEW_LINE> <INDENT> dic_loc[label] = list(range(len(self.dic_data[label]))) <NEW_LINE> <DEDENT> self.split_fun(dic_loc, dep, tag) | build decision tree | 625941de66673b3332b923c2 |
def p2(rho, graph): <NEW_LINE> <INDENT> mu = np.zeros(len(rho)) <NEW_LINE> for i in range(2**graph.N): <NEW_LINE> <INDENT> j = i & (_mask_a((1 << len(graph.a)) - 1, graph)) <NEW_LINE> for k in range(2 ** len(graph.a)): <NEW_LINE> <INDENT> m = _mask_a(k, graph) <NEW_LINE> mu[i] += rho[(i ^ j) ^ m] * rho[i ^ m] <NEW_LINE... | Perform protocol P2 of the ADB protocol for two-colorable graph states.
Implements equation (19) of Phys. Rev. A 71, 012319 (2005)
Preprint: https://arxiv.org/abs/quant-ph/0405045
See docstring of p1 for comment on the iterations and bit strings.
Parameters
----------
rho : np.ndarray
Diagonal entries of a densi... | 625941ded4950a0f3b08c67b |
def play_hand(hand, word_list): <NEW_LINE> <INDENT> score = 0; <NEW_LINE> while calculate_handlen(hand) > 0: <NEW_LINE> <INDENT> print("Current Hand:"); <NEW_LINE> display_hand(hand); <NEW_LINE> answer = input("Enter word, or '!!' to indicate that you are finished: "); <NEW_LINE> if answer == "!!": <NEW_LINE> <INDENT> ... | Allows the user to play the given hand, as follows:
* The hand is displayed.
* The user may input a word.
* When any word is entered (valid or invalid), it uses up letters
from the hand.
* An invalid word is rejected, and a message is displayed asking
the user to choose another word.
* After every valid word: ... | 625941de0a50d4780f6671c5 |
def rebin(self): <NEW_LINE> <INDENT> log.info("Rebinning all images to the pixel grid of the observed image with the lowest resolution ...") <NEW_LINE> target_wcs = None <NEW_LINE> for key in self.observed: <NEW_LINE> <INDENT> if target_wcs is None or self.observed[key].wcs.average_pixelscale > target_wcs.average_pixel... | This function ...
:return: | 625941de2ae34c7f2600d461 |
def estimate_conditional_tag_probability(morph, corpus_filename): <NEW_LINE> <INDENT> import nltk <NEW_LINE> import opencorpora <NEW_LINE> class _ConditionalProbDist(nltk.ConditionalProbDist): <NEW_LINE> <INDENT> def __init__(self, cfdist, probdist_factory): <NEW_LINE> <INDENT> self._probdist_factory = probdist_factory... | Estimate P(t|w) based on OpenCorpora xml dump.
Probability is estimated based on counts of disambiguated
ambiguous words, using simple Laplace smoothing. | 625941de26068e7796caf013 |
def test02_Version(self): <NEW_LINE> <INDENT> expected = vtSite.VERSION <NEW_LINE> self.assert_(vtconfig.getVersion() == expected, 'Bad version number') | Check the version number.
| 625941de6fece00bbac2da72 |
def gridData(context, main=None, add=None, filterinfo=None, session=None, elementId=None, sortColumnList=None, firstrecord=None, pagesize=None): <NEW_LINE> <INDENT> permissions = customPermsCursor(context) <NEW_LINE> if sortColumnList: <NEW_LINE> <INDENT> sortName = toHexForXml(sortColumnList[0].id) <NEW_LINE> sortType... | Функция получения данных для грида. | 625941de23849d37ff7b33bd |
def setCurrentWidget(self, w): <NEW_LINE> <INDENT> tw, tidx = self._tab_widget(w) <NEW_LINE> if tw is not None: <NEW_LINE> <INDENT> self._set_current_tab(tw, tidx) | Make the given widget current. | 625941de7d847024c06be5ef |
def deleteDuplicates(self, head): <NEW_LINE> <INDENT> node = head <NEW_LINE> while node!=None: <NEW_LINE> <INDENT> if node.next == None: <NEW_LINE> <INDENT> return head <NEW_LINE> <DEDENT> while node.val == node.next.val: <NEW_LINE> <INDENT> node.next = node.next.next <NEW_LINE> if node.next == None: <NEW_LINE> <INDENT... | :type head: ListNode
:rtype: ListNode | 625941de596a897236089ded |
def test_accept(self): <NEW_LINE> <INDENT> ddns.isc.util.cio.socketsession.SocketSessionReceiver = FakeSessionReceiver <NEW_LINE> self.assertEqual({}, self.ddns_server._socksession_receivers) <NEW_LINE> self.ddns_server.accept() <NEW_LINE> self.assertEqual([3], list(self.ddns_server._socksession_receivers.ke... | Test that we can accept a new connection. | 625941de3cc13d1c6d3c76a9 |
def t_SPACE(self, t): <NEW_LINE> <INDENT> t.value = ' ' <NEW_LINE> return t | [^\S\r\n]+ | 625941de596a897236089dee |
def validate_cusip(cusip): <NEW_LINE> <INDENT> if len(cusip) == 9 and cusip_checksum(cusip[:8]) == cusip[8]: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | Validate a CUSIP | 625941de82261d6c526ab7d4 |
def setPolicyPremium(self,amt): <NEW_LINE> <INDENT> self._policyPremium = amt | assigns the formal parameter to the policy's monthly premium | 625941dedc8b845886cb5867 |
def CheckValidity(self) -> None: <NEW_LINE> <INDENT> self._quantity.CheckValue(self._value) | :raises ValueError: when current value is wrong somehow (out of limits, for example). | 625941de7b25080760e39788 |
def enter(self, prev_mode): <NEW_LINE> <INDENT> if self.prev_mode is None: <NEW_LINE> <INDENT> self.prev_mode = prev_mode <NEW_LINE> if self.inherit_pause_from_prev_mode and prev_mode is not None: <NEW_LINE> <INDENT> self.paused = prev_mode.paused <NEW_LINE> <DEDENT> <DEDENT> pygame.mouse.set_visible(self.mouse_visible... | Enter the mode. | 625941de5fc7496912cc3cae |
def rebinHist(rebin,h): <NEW_LINE> <INDENT> h_binValues=[h.GetBinContent(ii) for ii in range(1,h.GetNbinsX())] <NEW_LINE> h_binWidths=[h.GetBinWidth(ii) for ii in range(1,h.GetNbinsX())] <NEW_LINE> n=len(h_binValues) <NEW_LINE> newSize=len(rebin) <NEW_LINE> rebinVector=np.zeros(newSize) <NEW_LINE> for i,js in rebin: <N... | This takes a histogram and returns a vector of bin values after rebinning, taking the bin width into account. The rebin argument is a list of maps: [ (newbin , [ oldbinstocombine ]) ]. It is provided to match the rebinCov procedure | 625941de76d4e153a657ee63 |
def testTwoInsertionsAndOneDeletionInReference(self): <NEW_LINE> <INDENT> template = ( 'CA-CGT-G', ' AA-G', ' ??-?', ' TAG', ' ???', ) <NEW_LINE> with makeBAM(template) as (fastaFilename, bamFilename): <NEW_LINE> <INDENT> self.assertEqual( 'CAAxGTAG', consensusFromBAM(bamFilename, quiet=True, referenceFasta=fas... | Two insertions and one deletion in the reference must be handled
correctly, with the deletion marked with 'x' as requested. | 625941de3317a56b86939f82 |
def finder_dict(arr1, arr2): <NEW_LINE> <INDENT> numbers = defaultdict(int) <NEW_LINE> for i in arr2: <NEW_LINE> <INDENT> numbers[i] += 1 <NEW_LINE> <DEDENT> for i in arr1: <NEW_LINE> <INDENT> if i in numbers: <NEW_LINE> <INDENT> numbers[i] -= 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return i | This function finds the missing element using default dict from
collections module. We can also use an empty dictionary to use
it for finding the missing element. | 625941de76e4537e8c3519a5 |
def is_tremor(f, Pxx_den): <NEW_LINE> <INDENT> isTremor = False <NEW_LINE> DF, mag = get_DF(f, Pxx_den) <NEW_LINE> if DF >= 2.95 and DF <= 12 and mag > 0.01: <NEW_LINE> <INDENT> isTremor = True <NEW_LINE> <DEDENT> return isTremor, DF | Identify a tremor based on the PSD
:param f: frequency (output from psd_welch)
:param Pxx_den: Power spectal density (output from psd_welch)
:return: boolean classifying whether a tremor occurred and
the frequency of the tremor **TO DO: amplitude of tremor** | 625941de4c3428357757c657 |
def stop_generating_20(strings): <NEW_LINE> <INDENT> return len(strings) >= 20 | Returns true if the length of the list is greater than 20 | 625941de462c4b4f79d1da01 |
def get_asset_from_db(db): <NEW_LINE> <INDENT> return db.split('_')[0] | Get asset from database. | 625941de31939e2706e4d196 |
def get_version(*file_paths): <NEW_LINE> <INDENT> filename = os.path.join(os.path.dirname(__file__), *file_paths) <NEW_LINE> version_file = open(filename).read() <NEW_LINE> version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) <NEW_LINE> if version_match: <NEW_LINE> <INDENT> return versio... | Retrieves the version from tigerleaflet/__init__.py | 625941de442bda511e8be745 |
def _pprint(params, offset=0, printer=repr): <NEW_LINE> <INDENT> options = np.get_printoptions() <NEW_LINE> np.set_printoptions(precision=5, threshold=64, edgeitems=2) <NEW_LINE> params_list = list() <NEW_LINE> this_line_length = offset <NEW_LINE> line_sep = ',\n' + (1 + offset // 2) * ' ' <NEW_LINE> for i, (k, v) in e... | Pretty print the dictionary 'params'
Parameters
----------
params: dict
The dictionary to pretty print
offset: int
The offset in characters to add at the begin of each line.
printer:
The function to convert entries to strings, typically
the builtin str or repr | 625941def548e778e58cd8b0 |
def _printSortedDateUrlDict (dateURLDict): <NEW_LINE> <INDENT> for i in sorted(dateURLDict.items()): <NEW_LINE> <INDENT> print(i[0]) <NEW_LINE> sorted_urls_count = sorted(i[1].items(), key=itemgetter(1), reverse=True) <NEW_LINE> for url in sorted_urls_count: <NEW_LINE> <INDENT> print (url[0], url[1]) | Prints the sorted dictionary
:param dateURLDict: the 2D dictionary storing the data from the input files
:return: | 625941de1f037a2d8b94652e |
def map_relation(relation, locale='en'): <NEW_LINE> <INDENT> rel_type = relation['type-id'] <NEW_LINE> if rel_type in _mbz_reltype_map: <NEW_LINE> <INDENT> artist = get_artist_primary_alias(relation['artist'], locale) <NEW_LINE> return Relation(_mbz_reltype_map[rel_type], artist.name, artist.sortname) <NEW_LINE> <DEDEN... | Map a musicbrainz artist relation to a tag name. The result is a Relation named tuple. | 625941ded10714528d600017 |
def timeout_session(session): <NEW_LINE> <INDENT> kill_session(session, kill_dtach=True) | Attached to Gate One's 'timeout_callbacks'; kills the given session.
If 'dtach' support is enabled the dtach processes associated with the
session will also be killed. | 625941de0383005118ecf912 |
def one_check(self, sharename, repair_uri, mode): <NEW_LINE> <INDENT> result = repair_share(sharename, repair_uri, mode, self.verbosity) <NEW_LINE> if re.match(r'^HTTP\ Error\ 410:\ Gone$', result.decode('utf8')): <NEW_LINE> <INDENT> status = 'not retrievable' <NEW_LINE> self.unhealthy += 1 <NEW_LINE> <DEDENT> elif jso... | Performs a shallow repair on 'repair_uri' | 625941de30bbd722463cc0fa |
def sagars(self, subjects, site): <NEW_LINE> <INDENT> keywords = [ 'ロマサガRS', 'ロマンシングサガ', 'リ・ユニバース', ] <NEW_LINE> keywords_ignore = ignore_base <NEW_LINE> return _base_search(subjects, site, keywords, keywords_ignore) | ロマサガ
:param subjects: list[Subject]
:param site: dict{id: Subject} | 625941de26238365f5f0f1a3 |
def dump(u, *args, **kwargs): <NEW_LINE> <INDENT> return dict( id=u.id, email=u.email, password=u.password, password_salt=u.password_salt, note=u.note, full_name=u.full_name if hasattr(u, 'full_name') else '{0} {1}'.format( u.given_names, u.family_name), settings=u.settings, nickname=u.nickname, last_login=dt2iso_or_em... | Dump the users as a list of dictionaries.
:param u: User to be dumped.
:type u: `invenio.modules.accounts.models.User [Invenio2.x]` or namedtuple.
:returns: User serialized to dictionary.
:rtype: dict | 625941ded18da76e2353280a |
def get_gid(path): <NEW_LINE> <INDENT> if not os.path.exists(path): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> secdesc = win32security.GetFileSecurity (path, win32security.OWNER_SECURITY_INFORMATION) <NEW_LINE> owner_sid = secdesc.GetSecurityDescriptorOwner() <NEW_LINE> return win32security.ConvertSidToString... | Return the id of the group that owns a given file
CLI Example::
salt '*' file.get_gid c:\temp\test.txt | 625941de44b2445a339323c5 |
def QueryConfigTarget(self, host=None): <NEW_LINE> <INDENT> return self.delegate("QueryConfigTarget")(host) | Queries for information about a specific target, a "physical" device that can
be used to back virtual devices. The ConfigTarget that is returned specifies
the set of values that can be used in the device backings to connect the
virtual machine to physical (or logical) host devices.Queries for information
about a specif... | 625941de5fcc89381b1e19f1 |
def write_file(self, name, template, context, relative_urls=False, paginated=None, override_output=False, url=None, **kwargs): <NEW_LINE> <INDENT> if name is False or name == "" or not is_selected_for_writing(self.settings, os.path.join(self.output_path, name)): <NEW_LINE> <INDENT> return <NEW_LINE>... | Render the template and write the file.
:param name: name of the file to output
:param template: template to use to generate the content
:param context: dict to pass to the templates.
:param relative_urls: use relative urls or absolutes ones
:param paginated: dict of article list to paginate - must have the
same l... | 625941de091ae3566866728a |
def fix_dictionaries(reference, dic2): <NEW_LINE> <INDENT> fixed_dic2 = {} <NEW_LINE> fixed_reference = {} <NEW_LINE> common_entries = set(reference.keys()).intersection(set(dic2.keys())) <NEW_LINE> for a in common_entries: <NEW_LINE> <INDENT> fixed_reference[a] = reference[a] <NEW_LINE> fixed_dic2[a] = dic2[a] <NEW_LI... | "check if dicitonaries have the same keys. If not, delete entries to make them.
:param dictionary reference: true dictionary
:param dictionary dic2: dictionary to edit | 625941de507cdc57c6307012 |
def query_summary(self, **query): <NEW_LINE> <INDENT> res = self._get_resource(_statistic.ConsumptionSummary, None) <NEW_LINE> return res.query(self._session, **query) | Queries summary information of data type and domains in the interval
:param \*\*query: The query parameters. Available parameters include:
* start_time: The timestamp marking the start of the query.
Optional.
* end_time: The timestamp marking the end of the query. Optional.
* domain_name: A domain... | 625941de0a50d4780f6671c6 |
def return_first_and_last_items(shopping): <NEW_LINE> <INDENT> new_list = [shopping[0], shopping[len(shopping) - 1]] <NEW_LINE> print(new_list) | Create a function that takes a list as a parameter
and returns a list containing the first and the last
element of the list.
:param shopping:
:return: | 625941ded99f1b3c44c678bb |
@app.on_message(Filters.command(GROUP_COMMANDS) & Filters.private) <NEW_LINE> def on_wrong_chat_command(client, message): <NEW_LINE> <INDENT> message.reply(ONLY_GROUP_COMMAND_MSG) | Sends a message to the user that invokes a command in private
chat that should only be invoked in groups | 625941de7b25080760e39789 |
def parse_wp_config(location: "Location", config_file_name: Text = "wp-config.php"): <NEW_LINE> <INDENT> config_location = location.child(config_file_name) <NEW_LINE> config = config_location.get_content() <NEW_LINE> const = extract_php_constants(config) <NEW_LINE> try: <NEW_LINE> <INDENT> return { "db_host": const["DB... | Parses the WordPress configuration to get the DB configuration | 625941de7c178a314d6ef795 |
def p_arg_list(p): <NEW_LINE> <INDENT> if len(p) == 4: <NEW_LINE> <INDENT> p[0] = ('arglist', p[1], p[3]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> p[0] = ('arglist', p[1],'empty') | arglist : arglist COMA NAME
| NAME | 625941de851cf427c661a83d |
def get_help_topic(self): <NEW_LINE> <INDENT> return self.topic | Return the help topic this can be found under. | 625941de1f5feb6acb0c4e7c |
def isValidBST(self, root): <NEW_LINE> <INDENT> last = [-sys.maxsize] <NEW_LINE> def helper(node): <NEW_LINE> <INDENT> if node == None: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> left = helper(node.left) <NEW_LINE> mid = node.val > last[0] <NEW_LINE> last[0] = node.val <NEW_LINE> right = helper(node.right) <NE... | :type root: TreeNode
:rtype: bool | 625941decad5886f8bd2730a |
def fulfill(self, values): <NEW_LINE> <INDENT> if 'password' in values: <NEW_LINE> <INDENT> values['password'] = saslprep(values['password']) <NEW_LINE> <DEDENT> self.values.update(values) | Provide requested values to the mechanism.
:param values: A dictionary of requested values. | 625941de3539df3088e2e67c |
def delete(self, req, id, **kwargs): <NEW_LINE> <INDENT> LOG.info(req.environ['hotzenplotz.context']) <NEW_LINE> context = req.environ['hotzenplotz.context'] <NEW_LINE> zmq_args = { 'method': self.METHOD_MAP['update'], 'args': { 'user_id': context.user_id, 'project_id': context.project_id, 'is_admin': context.is_admin,... | Delete the specified entity | 625941de0383005118ecf913 |
def add_connection_entry(self,client_id, display_name,session_id,host,conn,addr): <NEW_LINE> <INDENT> self.connections[client_id] = { "display_name" : display_name, "session_id" : session_id, "host" : host, "CONN" : conn, "ADDR" : addr, "connected" : True } | creates an entry in the connections dictionary for a new connection
Parameters : client_id (str) -> Represents the client id key to be added to the connections dictionary
: display_name (str) -> Represents the client's display name
: session_id (str) -> Represents the ... | 625941de6fece00bbac2da73 |
def partition(arr,l,r): <NEW_LINE> <INDENT> print("run partition") <NEW_LINE> x = arr[r] <NEW_LINE> i = l <NEW_LINE> for j in range(l,r): <NEW_LINE> <INDENT> if arr[j] <= x: <NEW_LINE> <INDENT> arr[i], arr[j] = arr[j], arr[i] <NEW_LINE> i += 1 <NEW_LINE> <DEDENT> <DEDENT> arr[i], arr[r] = arr[r], arr[i] <NEW_LINE> retu... | move the pivot point to a point where all elements smaller than it
come before and all elements larger come after | 625941de60cbc95b062c6875 |
def get_location_nd(right_bottom, left_bottom, left_top, right_top): <NEW_LINE> <INDENT> right_bottom_list = right_bottom.split('&') <NEW_LINE> left_bottom_list = left_bottom.split('&') <NEW_LINE> left_top_list = left_top.split('&') <NEW_LINE> right_top_list = right_top.split('&') <NEW_LINE> return np.float32([left_bot... | 输入位置,例如154&383,返回位置的ndarray
:param location:位置,str类型
:return:位置,list类型 | 625941de4527f215b584c785 |
def selected_indices(total_number_of_indices, desired_number_of_indices=None): <NEW_LINE> <INDENT> if ( desired_number_of_indices is None or desired_number_of_indices >= total_number_of_indices or desired_number_of_indices < 0 ): <NEW_LINE> <INDENT> return range(total_number_of_indices) <NEW_LINE> <DEDENT> increase = f... | Returns a list of indices that will contain exactly the number of desired indices (or the number of total items in the list, if this is smaller).
These indices are selected such that they are evenly spread over the whole sequence. | 625941de8da39b475bd652a8 |
def gradient(self): <NEW_LINE> <INDENT> firstColorList = self.stringToList(self.mainColor) <NEW_LINE> secondColorList = self.stringToList(self.secundairColor) <NEW_LINE> setNegZero = lambda a: int((abs(a)+a)/2) <NEW_LINE> b = math.ceil((firstColorList[0] - secondColorList[0] ) / (self.leds - 1)) <NEW_LINE> g = math.cei... | Lets color fade to second color trough out ledstrip
@return Nothing | 625941def9cc0f698b14092a |
def spawn_self_player(self): <NEW_LINE> <INDENT> player_copy = copy(self) <NEW_LINE> player_copy.history = [] <NEW_LINE> return player_copy | Returns an agent with the same methods that can be used for self-play.
Args:
[none]
Returns:
agent: an agent that can be used for self-play (must be respawned after calling `agent.endgame()`)
Note: as is clear in the code, the only thing that changes in the returned agent is `agent.history`,
which is a new l... | 625941de92d797404e3044bc |
def cmnWords(parameter): <NEW_LINE> <INDENT> lyrics = "" <NEW_LINE> words = [] <NEW_LINE> i = 0 <NEW_LINE> word = "" <NEW_LINE> send = [] <NEW_LINE> occurrences = {} <NEW_LINE> for song in database: <NEW_LINE> <INDENT> lyrics += song[3] <NEW_LINE> <DEDENT> for char in lyrics: <NEW_LINE> <INDENT> if not char == "\n" and... | This function returns the 50 most common words in pink floyd lyrics
:param parameter: empty parameter
:type parameter: str
:return: the list of the most common words
:rtype: str | 625941dee64d504609d74b71 |
def get(self): <NEW_LINE> <INDENT> self.render( 'links/add_link.html', original_url='' ) | Define get method. | 625941de63f4b57ef0001442 |
def test_no_attr(self): <NEW_LINE> <INDENT> self.assertFalse(hasattr(self.object, 'foo')) <NEW_LINE> self.assertIdentical(None, util.get_callable_target(self.object, 'foo')) | Should return C{None} if no attribute exists | 625941de236d856c2ad44b10 |
def get_file(id): <NEW_LINE> <INDENT> r = requests.get(URL_files + '/{id}'.format(id=id), auth=(fileuser, filepwd), timeout=TIMEOUT, verify=False) <NEW_LINE> return r.status_code | get a file from MetaX. | 625941de851cf427c661a83e |
def generate_source_library(package, context): <NEW_LINE> <INDENT> lib_name = package['package']['name'] <NEW_LINE> data = SourceLibrary(lib_name) <NEW_LINE> for name, path in package.get('includes', {}).iteritems(): <NEW_LINE> <INDENT> (file, folder) = extract_file(name, path, context) <NEW_LINE> data.includes[name] =... | Generates the build glue for a library whose sources are provided. | 625941ded58c6744b4257f90 |
def _post(self, path, params=None): <NEW_LINE> <INDENT> url = self.ROOT_URL + path <NEW_LINE> json = params or {} <NEW_LINE> json.update(self._body()) <NEW_LINE> json = dict([(k, v) for (k, v) in json.items() if v is not None]) <NEW_LINE> try: <NEW_LINE> <INDENT> r = self.requests.post(url=url, json=json, headers=self.... | POST request.
:param path:
:param params: | 625941de090684286d50f01a |
def send_mail_simple(subject, text, addr_from, addr_to): <NEW_LINE> <INDENT> addr_to = addr_to if type(addr_to) == list else [addr_to] <NEW_LINE> send_mail(subject, text, addr_from, addr_to) | Send simple email | 625941de460517430c3944af |
def set_period(self, value): <NEW_LINE> <INDENT> self.period = value | Set the period of the resource
Parameters:
*value*
The new period of the resoruce | 625941de92d797404e3044bd |
def end(): <NEW_LINE> <INDENT> if not AsPi.hasEnded(): <NEW_LINE> <INDENT> AsPi._ended = True <NEW_LINE> print("Forcing termination in " + str(SHUTDOWN_TIMEOUT_IN_SECS) + " secs") <NEW_LINE> AsPi.shutdowntimer = Timer( SHUTDOWN_TIMEOUT_IN_SECS , AsPi.terminate ) <NEW_LINE> AsPi.shutdowntimer.start() | Call to gracefully end of the program. A termination timer is also started.
If the program cleanup actions are not done in SHUTDOWN_TIMEOUT_IN_SECS seconds,
self termination is issued. | 625941de38b623060ff0b11f |
def getDepthInSection(self, node): <NEW_LINE> <INDENT> sections = 0 <NEW_LINE> while node.parentNode: <NEW_LINE> <INDENT> if node.nodeName == "section": <NEW_LINE> <INDENT> sections += 1 <NEW_LINE> <DEDENT> node = node.parentNode <NEW_LINE> <DEDENT> return sections | Returns the number of parent sections of the given node. | 625941de8c3a8732951586ef |
def GetOrphanedPages(self): <NEW_LINE> <INDENT> pages_to_check = deque(self._root_pages.union(self._always_detached)) <NEW_LINE> found = set(self._root_pages) | self._always_detached <NEW_LINE> while pages_to_check: <NEW_LINE> <INDENT> item = pages_to_check.popleft() <NEW_LINE> target_page = self._pages[item] <NEW_LINE... | Crawls the server find all pages that are connected to the pages at
|seed_url|s. Return the links that are valid on the server but are not in
part of the connected component containing the |root_pages|. These pages
are orphans and cannot be reached simply by clicking through the server. | 625941ded8ef3951e324386f |
def __getSiteForCEs(self, ces): <NEW_LINE> <INDENT> res = getQueues(community = self.vo) <NEW_LINE> if not res['OK']: <NEW_LINE> <INDENT> return S_ERROR("Could not get site for CE") <NEW_LINE> <DEDENT> sitedict = res['Value'] <NEW_LINE> final_sdict = {} <NEW_LINE> for site, s_ces in sitedict.items(): <NEW_LINE> <INDENT... | We want to get the site for a given CE because that's what the job expects
| 625941de82261d6c526ab7d5 |
def test_sign_rsa_sha512_with_client(self): <NEW_LINE> <INDENT> self.assertEqual( self.expected_signature_rsa_sha512, sign_rsa_sha512_with_client(self.eg_signature_base_string, self.rsa_private_client)) <NEW_LINE> self.assertTrue(verify_rsa_sha512( MockRequest('POST', 'http://example.com/request', self.eg_params, self.... | Test sign and verify with RSA-SHA512. | 625941de7b180e01f3dc4b29 |
def ajouter_porte(self, clef=None): <NEW_LINE> <INDENT> if self.porte: <NEW_LINE> <INDENT> raise AttributeError("la sortie {} possède déjà une porte".format( self)) <NEW_LINE> <DEDENT> porte = Porte(clef) <NEW_LINE> self.porte = porte <NEW_LINE> if self.sortie_opposee: <NEW_LINE> <INDENT> self.sortie_opposee.porte = po... | Ajoute une porte sur la sortie et sa sortie opposée.
Si une porte est déjà définie sur la sortie, lève une exception. | 625941de07f4c71912b117b6 |
def ring_cliques_benchmark(n, r): <NEW_LINE> <INDENT> graph = nx.disjoint_union_all([nx.complete_graph(n) for i in range(0, r)]) <NEW_LINE> graph.add_edges_from([(u, u + n + 1) for u in range(0, r * (n), n)]) <NEW_LINE> graph.remove_node(n * r + 1) <NEW_LINE> graph.add_edge(n - 1, n * r - 1) <NEW_LINE> return graph | Returns a networkx graph of ring of cliques with r cliques of n nodes
n number of nodes in every clique
r number of connected cliques | 625941deff9c53063f47c524 |
def test_saml2_pki_dir(host): <NEW_LINE> <INDENT> saml2 = host.file('/etc/ckan/saml2/pki') <NEW_LINE> assert saml2.exists <NEW_LINE> assert saml2.is_directory <NEW_LINE> assert saml2.user == 'root' <NEW_LINE> assert saml2.group == 'www-data' <NEW_LINE> assert saml2.mode == 0o750 | saml2 pki configuration directory is installed. | 625941dea219f33f34628c97 |
def bfs_visited(ugraph, start_node): <NEW_LINE> <INDENT> queue=deque([start_node]) <NEW_LINE> visited=set([start_node]) <NEW_LINE> while queue: <NEW_LINE> <INDENT> jay_node=queue.popleft() <NEW_LINE> for neighbor in ugraph[jay_node]: <NEW_LINE> <INDENT> if neighbor not in visited: <NEW_LINE> <INDENT> visited.add(neighb... | Takes the undirected graph ugraph
and the node start_node and returns the set consisting of all nodes
that are visited by a breadth-first search that starts at start_node
| 625941de925a0f43d254a1ab |
def get( ip, community, oid, port=161, timeout=DEFAULT_TIMEOUT, version=Version.V2C ): <NEW_LINE> <INDENT> result = multiget( ip, community, [oid], port, timeout=timeout, version=version ) <NEW_LINE> return result[0] | Executes a simple SNMP GET request and returns a pure Python data
structure.
Example::
>>> get('192.168.1.1', 'private', '1.2.3.4')
'non-functional example' | 625941decc40096d61595c81 |
def test_find_credential_by_account(self): <NEW_LINE> <INDENT> self.new_credential.save_credential() <NEW_LINE> test_credential = Credential("Test","testAccount","testPass") <NEW_LINE> test_credential.save_credential() <NEW_LINE> found_credential = Credential.find_by_account("testAccount") <NEW_LINE> self.assertEqual(f... | Test if we can find a credential by account | 625941ded164cc6175783080 |
def get(self, x_RT: np.array, geom: Geometry) -> dict: <NEW_LINE> <INDENT> point = np.zeros((self.n_point,)) <NEW_LINE> for point_ind, name in enumerate(self.lut_grid_config): <NEW_LINE> <INDENT> if name in self.statevector_names: <NEW_LINE> <INDENT> ix = self.statevector_names.index(name) <NEW_LINE> point[point_ind] =... | Get interpolated MODTRAN results at a particular location
Args:
x_RT: radiative-transfer portion of the statevector
geom: local geometry conditions for lookup
Returns:
interpolated modtran result | 625941de3c8af77a43ae3ad5 |
def add_stream(self, func, *args, **kwargs): <NEW_LINE> <INDENT> if self._stream_connection is None: <NEW_LINE> <INDENT> raise StreamError('Not connected to stream server') <NEW_LINE> <DEDENT> if func == setattr: <NEW_LINE> <INDENT> raise StreamError('Cannot stream a property setter') <NEW_LINE> <DEDENT> return_type = ... | Add a stream to the server | 625941ded164cc6175783081 |
def query_keys(self, **kwargs): <NEW_LINE> <INDENT> for key, value in self._store.items(): <NEW_LINE> <INDENT> metadata = value[1] <NEW_LINE> if all(metadata.get(arg) == value for arg, value in kwargs.items()): <NEW_LINE> <INDENT> yield key | Query for keys matching metadata provided as keyword arguments
This provides a very simple querying interface that returns precise
matches with the metadata. If no arguments are supplied, the query
will return the complete set of keys for the key-value store.
This is equivalent to ``self.query(**kwargs).keys()``, bu... | 625941de498bea3a759b9de0 |
def __init__(self, items={}): <NEW_LINE> <INDENT> self.items = items | Initialize ProjectList. | 625941de3346ee7daa2b309f |
def apply(self, layer_path, layer_dict): <NEW_LINE> <INDENT> if not self.regExpPattern: <NEW_LINE> <INDENT> self.regExpPattern = self._getRegExpPattern() <NEW_LINE> <DEDENT> baseName = os.path.basename(layer_path) <NEW_LINE> layerBaseName = os.path.splitext(baseName)[0] <NEW_LINE> if '|layername=' in baseName and not b... | Apply an alphanumeric filter | 625941de9f2886367277abbd |
def debug(self, msg): <NEW_LINE> <INDENT> self.__logger.debug(msg) | Logs a 'msg % args' message with level 'DEBUG' on this logger.
Args:
msg (str): Log message. | 625941de85dfad0860c3b18e |
def test_update_with_invalid_jabber(self): <NEW_LINE> <INDENT> self.new_data['jabber'] = 'bla-bla-bla' <NEW_LINE> resp = self.client.post(self.UPDATE_URL, self.new_data) <NEW_LINE> self.assertEqual(resp.status_code, 200) <NEW_LINE> self.assertTrue('jabber' in resp.context['form'].errors) | If entered jabber is invalid,
user should see update page again
with error message. | 625941de97e22403b379d2cd |
def find_a_path(self, start, end): <NEW_LINE> <INDENT> self.visited.add(start) <NEW_LINE> if (end in self.dictionary[start]): <NEW_LINE> <INDENT> return start + " " + end <NEW_LINE> <DEDENT> elif (self.dictionary[start] <= self.visited): <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> elif max(map(lambda x: Solution(... | :rtype | 625941ded8ef3951e3243870 |
def left_motion(self, event): <NEW_LINE> <INDENT> self.set_current() <NEW_LINE> results = self.canvas.find_withtag(tk.CURRENT) <NEW_LINE> if len(results) is 0: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> item = results[0] <NEW_LINE> rectangle = self.items[item] <NEW_LINE> self.config(cursor="exchange") <NEW_LINE> se... | Callback for the B1-Motion event, or the dragging of an item.
Moves the item to the desired location, but limits its movement to a
place on the actual Canvas. The item cannot be moved outside of the Canvas.
:param event: Tkinter event | 625941de0c0af96317bb851a |
def post(self, user_id=None): <NEW_LINE> <INDENT> if user_id is None: <NEW_LINE> <INDENT> return UserController.create_user() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> abort(405) | POST /users --> Create new user. | 625941de4e696a04525c977e |
def _repr_compact(self): <NEW_LINE> <INDENT> if not self: <NEW_LINE> <INDENT> return '-' <NEW_LINE> <DEDENT> def str_rep(x): <NEW_LINE> <INDENT> return '%s' % x if x is not None else '.' <NEW_LINE> <DEDENT> return '/'.join(','.join(str_rep(r) for r in row) for row in self) | Return a compact string representation of ``self``.
EXAMPLES::
sage: SkewTableau([[None,None,3],[4,5]])._repr_compact()
'.,.,3/4,5'
sage: Tableau([])._repr_compact()
'-' | 625941de1f037a2d8b94652f |
def add(self, comp): <NEW_LINE> <INDENT> self._sprite_comps.append(comp) <NEW_LINE> self._layer.add(comp.sprite, z=comp.z) | Add a sprite component. | 625941de57b8e32f524837cf |
def _get_server(self, attr_name): <NEW_LINE> <INDENT> key_filename = pkg_resources.resource_filename( 'yardstick.resources', h_join('files/yardstick_key', get_short_key_uuid(self.key_uuid))) <NEW_LINE> if isinstance(attr_name, collections.Mapping): <NEW_LINE> <INDENT> node_name, cname = self.split_name(attr_name['name'... | lookup server info by name from context
attr_name: either a name for a server created by yardstick or a dict
with attribute name mapping when using external heat templates | 625941de66673b3332b923c3 |
def get_info(self): <NEW_LINE> <INDENT> path = '/api/v1/info' <NEW_LINE> return self._get(path) | Get Concourse version information | 625941dec4546d3d9de72d69 |
def set_option(self, name, value): <NEW_LINE> <INDENT> encoded = json.dumps(value) <NEW_LINE> self.options[name] = value <NEW_LINE> with db.ensure_transaction() as session: <NEW_LINE> <INDENT> db.model_query(db.Option, session=session).filter_by( uuid=self.uuid, name=name).delete() <NEW_LINE> db.Option(uuid=self.uuid, ... | Set an option for a node. | 625941de5e10d32532c5f258 |
def people_generator(self): <NEW_LINE> <INDENT> for generation in range(self.generations): <NEW_LINE> <INDENT> for data in self.gen2people[generation]: <NEW_LINE> <INDENT> yield (data[0], data[6]) <NEW_LINE> <DEDENT> <DEDENT> for generation in range(self.generations): <NEW_LINE> <INDENT> for data in self.gen2fam[genera... | a generator over all people outside of the core person | 625941dead47b63b2c50a2b1 |
@app.route('/position/<string:device>/', methods = ["POST"]) <NEW_LINE> def position_post(device): <NEW_LINE> <INDENT> print(u"Called : POST /position/{0} | data = {1}".format(device, request.form)) <NEW_LINE> try: <NEW_LINE> <INDENT> found = False <NEW_LINE> for a_device in g.devices: <NEW_LINE> <INDENT> if device == ... | Used for POST on /position/<device>/
Sample for Android app Trip Tracker :
data = ImmutableMultiDict([('locations[1][longitude]', u'-1.3015050539275859'), ('locations[0][time]', u'1414950119346'), ('locations[1][speed]', u'1.5556983'), ('locations[1][time]', u'1414958966722'), ('locations[1][latitude]', u'47.089564705... | 625941dea8ecb033257d33fe |
def build_shared_network(X, add_summaries=False): <NEW_LINE> <INDENT> conv1 = tf.contrib.layers.conv2d( X, 16, 8, 4, activation_fn = tf.nn.relu, scope="conv1") <NEW_LINE> conv2 = tf.contrib.layers.conv2d( conv1, 32, 4, 2, activation_fn = tf.nn.relu, scope="conv2") <NEW_LINE> fc1 = tf.contrib.layers.fully_connected( inp... | Builds a 3-layer network conv -> conv -> fc as described
in the A3C paper. This network is shared by both the policy and value net.
:param X: Inputs
:param add_summaries: If true, add layer summaries to Tensorboard.
:return: Final layer activations. | 625941de30dc7b7665901c96 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.