code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def has_angle_limit_alarm_led(self, dynamixel_id): <NEW_LINE> <INDENT> byte_seq = self.read_data(dynamixel_id, pk.ALARM_LED, 1) <NEW_LINE> alarm_led_byte = byte_seq[0] <NEW_LINE> return bool(alarm_led_byte & (1 << 1)) | Return ``True`` if the LED of the specified Dynamixel unit is
configured to blink when an *Angle Limit Error* occurs.
:param int dynamixel_id: the unique ID of a Dynamixel unit. It must be
in range (0, 0xFD). | 625941d2442bda511e8be5d8 |
def getColumns(self): <NEW_LINE> <INDENT> pass | Get the Columns for the table.
Should be overridden in the sub classes | 625941d221a7993f00bc7eb3 |
def _get_links_to_sections_of_genres(): <NEW_LINE> <INDENT> page_text = requests.get("https://en.wikipedia.org/wiki/List_of_music_styles") <NEW_LINE> try: <NEW_LINE> <INDENT> page_text.raise_for_status <NEW_LINE> <DEDENT> except Exception as exc: <NEW_LINE> <INDENT> print("There was a problem") <NEW_LINE> <DEDENT> page... | Returns a list of links to the different sections of genres in wikipedia | 625941d2bf627c535bc13390 |
def _get_generic_items(self, tag): <NEW_LINE> <INDENT> related = [] <NEW_LINE> for generic in TaggedItem.objects.filter(tag__in=[tag]): <NEW_LINE> <INDENT> item = generic.content_object <NEW_LINE> item.related_score = self._get_related_score(item) <NEW_LINE> related.append(item) <NEW_LINE> <DEDENT> return set(related) | Returns a set of unique generic items for specified tag.
:param: tag object.
:rtype: set. | 625941d29b70327d1c4e0f97 |
def api_factory(cluster_id, **kwargs): <NEW_LINE> <INDENT> kwargs['cluster_id'] = cluster_id <NEW_LINE> return dell_storagecenter_blockdevice.create_driver_instance( **kwargs) | Well known entry point for Flocker to load driver instance. | 625941d244b2445a33932257 |
def countBits(num): <NEW_LINE> <INDENT> num += 1 <NEW_LINE> res = [0, 1] <NEW_LINE> while (len(res) < num): <NEW_LINE> <INDENT> res += [i+1 for i in res] <NEW_LINE> print (res) <NEW_LINE> <DEDENT> return res[:num] | :type num: int
:rtype: List[int] | 625941d285dfad0860c3b01d |
def processor_affinity(self): <NEW_LINE> <INDENT> return _iio_swig.fmcomms2_sink_sptr_processor_affinity(self) | processor_affinity(fmcomms2_sink_sptr self) -> std::vector< int,std::allocator< int > > | 625941d2377c676e9127236a |
def connect(self, storage: str = None): <NEW_LINE> <INDENT> if not any([storage, self._storage]): <NEW_LINE> <INDENT> raise ValueError("Storage has not been provided.") <NEW_LINE> <DEDENT> self._storage = storage or self._storage <NEW_LINE> self._meta_fpath = Path(self._storage) / '.meta' <NEW_LINE> if not os.path.isfi... | Connect adapter adapter to a storage. | 625941d2d4950a0f3b08c50f |
def do_command(self, cmd, timeout=TMO, ack=True): <NEW_LINE> <INDENT> self.command = cmd <NEW_LINE> self('submit').click() <NEW_LINE> if ack: <NEW_LINE> <INDENT> NotifierPage.wait(self, timeout, base_id='command') | Execute a command. | 625941d2796e427e537b0789 |
def createClass(name, package, author, resources): <NEW_LINE> <INDENT> with open('%s.java' % name, 'r', encoding='utf-8') as f: <NEW_LINE> <INDENT> return template.format(**({ 'header': '\n'.join(' * %s' % line for line in ('%s.java' % name, 'Contains resources for %s' % package, '', author, strftime('%a %c', localtime... | Docstring goes here | 625941d215baa723493c4138 |
def get(self): <NEW_LINE> <INDENT> return execute_soap(self._client, self._host, self.moid, 'vim.EsxCLI.system.coredump.partition.Get', ) | Get one of the dump partition configured values. This command will print either the active dump partition or the configured dump partition depending on the flags passed.
:returns: vim.EsxCLI.system.coredump.partition.get.KernelDumpParition | 625941d24d74a7450ccd4385 |
def RMSE(groundtruth, prediction, mask=None): <NEW_LINE> <INDENT> groundtruth = np.array(groundtruth, dtype=np.float32) <NEW_LINE> prediction = np.array(prediction, dtype=np.float32) <NEW_LINE> assert groundtruth.shape == prediction.shape <NEW_LINE> if mask: <NEW_LINE> <INDENT> mask = np.array(mask) <NEW_LINE> groundtr... | groundtruth: matrix containing the real samples to be predicted (N samples,
sample dim) prediction: matrix containing the prediction (N samples,
sample dim) mask: optional binary mask to not consider certain samples
(0 in mask) | 625941d2596a897236089c81 |
def get_history(self, obj): <NEW_LINE> <INDENT> return reverse(viewname='wapi:v2:waves-jobs-history', request=self.context['request'], kwargs={'slug': obj.slug}) | Link to job history details wapi:v2 endpoint | 625941d2d6c5a1020814420e |
def getNISTcas(request, inchi): <NEW_LINE> <INDENT> url = "http://webbook.nist.gov/cgi/inchi/{0}".format(urllib.parse.quote(inchi)) <NEW_LINE> searcher = re.compile('<li><a href="/cgi/inchi\?GetInChI=C(\d+)') <NEW_LINE> try: <NEW_LINE> <INDENT> with urllib.request.urlopen(url, timeout=5) as f: <NEW_LINE> <INDENT> for l... | Get the CAS number as used by NIST, from an InChI | 625941d2435de62698dfde0f |
def scheduled_change_permissions_signoffs_delete(sc_id): <NEW_LINE> <INDENT> return PermissionScheduledChangeSignoffsView().delete(sc_id) | DELETE /scheduled_changes/permissions/<int:sc_id>/signoffs | 625941d2b7558d58953c50d4 |
def manual_grow(Crop): <NEW_LINE> <INDENT> valid = False <NEW_LINE> while not valid: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> light = int(input("Enter light value between 1-20")) <NEW_LINE> if 1 <= light <=20: <NEW_LINE> <INDENT> valid = True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print ("Invalid input, plea... | provide specific values to crop in 1 day, testing it accepts appropriate range of values, performs as expcted when receiving a particular pairing of light and water | 625941d2d4950a0f3b08c510 |
def HorizontalWinner(board): <NEW_LINE> <INDENT> rows = [[board[i] for i in range(3)], [board[i] for i in range(3, 6)], [board[i] for i in range(6, 9)]] <NEW_LINE> for row in rows: <NEW_LINE> <INDENT> if all(row[i] != ' ' for i in range(3)): <NEW_LINE> <INDENT> if all(row[0] == row[i] for i in range(3)): <NEW_LINE> <IN... | Return the symbol of 3 in a row. If no winner, return None | 625941d223849d37ff7b3251 |
def construct_gasex_sfgs(self, query): <NEW_LINE> <INDENT> samples = query.all() <NEW_LINE> to_average = [] <NEW_LINE> for sample in samples: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> spec = self.wz.session.query(self.wz.gasex_sfg).filter( self.wz.gasex_sfg.sample_hash == sample.sample_hash).one() <NEW_LINE> spec_ra... | Collects the spectra specified in query and converts them to actual SfgSpectrum objects for averaging | 625941d263d6d428bbe446b1 |
def handle_exists(): <NEW_LINE> <INDENT> _ = recv(protocol.BOOL) <NEW_LINE> key = recv(protocol.STRING) <NEW_LINE> for rbytes in protocol.UINT32.serialize( protocol.RESULT_SUCCESS): <NEW_LINE> <INDENT> yield rbytes <NEW_LINE> <DEDENT> for rbytes in protocol.BOOL.serialize(key in self._values): <NEW_LINE> <INDENT> yield... | Handle an "exists" command | 625941d2cb5e8a47e48b7c6a |
def __call__(self, context): <NEW_LINE> <INDENT> items = [ "Billing", "Clinical", "Practice Management", "Reception", "Quality", "Workflow", ] <NEW_LINE> items = [SimpleTerm(i, i, i) for i in items] <NEW_LINE> return SimpleVocabulary(items) | See IVocabularyFactory interface
| 625941d296565a6dacc8f88d |
def add_host_def(self, host): <NEW_LINE> <INDENT> self.host_config.append(host) | :type host: HostDef | 625941d2c432627299f04e08 |
def __init__(self, machine_name="Driving3"): <NEW_LINE> <INDENT> self.__machine_name = machine_name <NEW_LINE> self.fr = framework.QF.getInstance() <NEW_LINE> self.activeObjects = self.fr.getActiveDict() <NEW_LINE> self.set('InReverse', False) <NEW_LINE> self.set('UnlockBrake', False) | Constructor | 625941d266673b3332b92253 |
def write_header(self, alignments): <NEW_LINE> <INDENT> stream = self.stream <NEW_LINE> stream.write("#NEXUS\n") | Use this to write the file header. | 625941d294891a1f4081bc6c |
def compute_percent_correct(data): <NEW_LINE> <INDENT> correct_edges = 0 <NEW_LINE> for edge in data.edges: <NEW_LINE> <INDENT> if data.get_labels(edge.src) == data.get_labels(edge.tgt): <NEW_LINE> <INDENT> correct_edges = correct_edges + 1 <NEW_LINE> <DEDENT> <DEDENT> total_edges = len(data.edges) <NEW_LINE> return fl... | Compute the ratio of edges connecting two nodes with the same label.
Args:
data: A GraphDataset object.
Returns:
A float representing the ratio of edges among all graph edges that are
connecting nodes with similar labels. | 625941d26fb2d068a760f261 |
def get_attachment(attachment_id): <NEW_LINE> <INDENT> root = M.GetAttachment( M.AttachmentShape( T.IncludeMimeContent("true"), ), M.AttachmentIds( T.AttachmentId(Id=attachment_id) ) ) <NEW_LINE> return root | Prepares an api request for GetAttachment api call
<GetAttachment xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<AttachmentShape/>
<AttachmentIds>
<t:AttachmentId Id="AAAtAEFkbWluaX..."/>
</AttachmentIds>
</GetAttachm... | 625941d24428ac0f6e5ba9b5 |
def format(self, eq_constr, leq_constr, dims, solver): <NEW_LINE> <INDENT> if self.is_sym: <NEW_LINE> <INDENT> eq_constr += self.__format[0] <NEW_LINE> dims[s.EQ_DIM] += (self.size[0]*(self.size[1] - 1))//2 <NEW_LINE> <DEDENT> leq_constr += self.__format[1] <NEW_LINE> dims[s.SDP_DIM].append(self.size[0]) | Formats SDP constraints as inequalities for the solver.
Parameters
----------
eq_constr : list
A list of the equality constraints in the canonical problem.
leq_constr : list
A list of the inequality constraints in the canonical problem.
dims : dict
A dict with the dimensions of the conic constraints.
solve... | 625941d2e76e3b2f99f3a9cb |
def getStandardUnitType(std_unit_system, obs_type, agg_type=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> unit_group = getUnitGroup(obs_type, agg_type) <NEW_LINE> unit_type = StdUnitSystem[std_unit_system][unit_group] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> unit_type = None <NEW_LINE> <DEDENT> r... | Given an observation type and an aggregation type, return the unit type
within a standardized unit system.
std_unit_system: Either weewx.US or weewx.METRIC
obs_type: An observation type ('outTemp', 'rain', etc.)
agg_type: Type of aggregation ('mintime', 'count', etc.)
[Optional. default is no aggregation)
returns t... | 625941d2167d2b6e31218d58 |
def get_notifs(self): <NEW_LINE> <INDENT> url, params = self.url_builder.get_notif_url(self.uid, self.token, self.key) <NEW_LINE> response = json.loads(requests.get(url, params=params).text) <NEW_LINE> if response["success"]: <NEW_LINE> <INDENT> return response["data"] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> retu... | Returns list of unread user notifications. | 625941d25510c4643540f5a4 |
def get_active_states(self): <NEW_LINE> <INDENT> raise NotImplementedError() | Get a description of the current state.
Note that this is specific to container implementation.
@rtype: list of string | 625941d2ff9c53063f47c3b5 |
def find_external_section(self, guru_section): <NEW_LINE> <INDENT> intercom_sections = self.get_all("https://api.intercom.io/help_center/sections") <NEW_LINE> for intercom_section in intercom_sections: <NEW_LINE> <INDENT> if intercom_section["name"].lower() == guru_section.title.lower(): <NEW_LINE> <INDENT> return inte... | This checks if a section already exists in Intercom by checking for one with
the same name. This is a little confusing because both Guru and Intercom call
them "sections". | 625941d27d43ff24873a2e63 |
def correct(self, word, pre1, pre2): <NEW_LINE> <INDENT> candidates_list = self.candidates(word) <NEW_LINE> correction_dict = {} <NEW_LINE> rank_list = [] <NEW_LINE> for candidate in candidates_list: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> p = self.probability(candidate, pre1, pre2) <NEW_LINE> correction_dict[cand... | generate most probable spelling correction for typo 'word' | 625941d20383005118ecf7a4 |
def get_server(self, source, destination=None): <NEW_LINE> <INDENT> used_server = None <NEW_LINE> if destination: <NEW_LINE> <INDENT> new_list = [source, destination] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> new_list = [source] <NEW_LINE> <DEDENT> for item in new_list: <NEW_LINE> <INDENT> parsed = self.parse_url(i... | Get the server address from the provided URLs
Parameters
----------
source: `str`
URL path of the from location
destination: `str`
URL path of the to location
Returns
-------
used_server: `str`
String of the used server
Raises
------
None
Examples
--------
# FileUtils
>>> from ..file... | 625941d2851cf427c661a6d0 |
def _ssm_execution_id(ssm_document_name): <NEW_LINE> <INDENT> response = ssm.describe_automation_executions( Filters=[ { 'Key': 'DocumentNamePrefix', 'Values': [ ssm_document_name, ] }, { 'Key': 'ExecutionStatus', 'Values': ['Pending','InProgress', ] }, ], MaxResults=1 ) <NEW_LINE> return response['AutomationExecutionM... | Determine whether an automation execution exists for a given
document and status.
Keyword arguments:
ssm_document_name -- the name of the SSM document
execution_status -- the SSM execution status | 625941d232920d7e50b28393 |
def list_resources(self, stack_identifier): <NEW_LINE> <INDENT> resp, resources = self.client.list_resources(stack_identifier) <NEW_LINE> self.assertEqual('200', resp['status']) <NEW_LINE> self.assertIsInstance(resources, list) <NEW_LINE> for res in resources: <NEW_LINE> <INDENT> self.assert_fields_in_dict(res, 'logica... | Get a dict mapping of resource names to types. | 625941d2d486a94d0b98e308 |
def _draw_visible_icons(self): <NEW_LINE> <INDENT> for coord in coords.get_all_box_coords(): <NEW_LINE> <INDENT> animation_status = self._animation_statuses.get_status(coord) <NEW_LINE> if animation_status.icon_visible: <NEW_LINE> <INDENT> self._draw_icon_at_coord(coord) | Draw all icons that are visible. | 625941d27047854f462a15cb |
def parse_xml(self, xml): <NEW_LINE> <INDENT> items = list() <NEW_LINE> for item in xml.getchildren(): <NEW_LINE> <INDENT> items.append(xmltodict(item)) <NEW_LINE> <DEDENT> return items | Parse the response from USPS into a dictionary
@param xml: the xml to parse
@return: a dictionary representing the XML response from USPS | 625941d232920d7e50b28394 |
def stop(self): <NEW_LINE> <INDENT> with self._state_cond: <NEW_LINE> <INDENT> if self._executor_obj is not None: <NEW_LINE> <INDENT> self._running = False <NEW_LINE> self._executor_obj.stop() <NEW_LINE> <DEDENT> self._state_cond.notify_all() | Stop handling incoming messages.
Once this method returns, no new incoming messages will be handled by
the server. However, the server may still be in the process of handling
some messages, and underlying driver resources associated to this
server are still in use. See 'wait' for more details. | 625941d216aa5153ce36263a |
def main(): <NEW_LINE> <INDENT> print("windows") <NEW_LINE> print("starbucks coffee") <NEW_LINE> print("google") <NEW_LINE> print("java") <NEW_LINE> print("apple") <NEW_LINE> print("mozilla firefox") <NEW_LINE> print("sublime text") <NEW_LINE> print("google chrome") <NEW_LINE> print("python") <NEW_LINE> print("microsof... | Main function | 625941d2a4f1c619b28b01f9 |
def ui(self): <NEW_LINE> <INDENT> result = comp.AskUser( 'Chose Slices', { 1: { 1: 'Slice Sequence', 2: 'FileBrowse', 'Save': False }, 2: { 1: 'Slice In Width', 2: 'Slider', 'Min': 1, 'Max': 10, 'Default': 5 }, 3: { 1: 'Slice In Height', 2: 'Slider', 'Min': 1, 'Max': 10, 'Default': 5 } } ) <NEW_LINE> self.path = result... | the UI for the script
| 625941d255399d3f05588877 |
def split_network(self): <NEW_LINE> <INDENT> disconnect_nodes(self.nodes[1], 2) <NEW_LINE> disconnect_nodes(self.nodes[2], 1) <NEW_LINE> self.sync_all(self.nodes[:2]) <NEW_LINE> self.sync_all(self.nodes[2:]) | Split the network of four nodes into nodes 0/1 and 2/3. | 625941d266673b3332b92254 |
def get_config(argv, cwd=None): <NEW_LINE> <INDENT> if argv and (argv[-1] in DATABASE): <NEW_LINE> <INDENT> database = argv.pop() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> database = 'galaxy' <NEW_LINE> <DEDENT> database_defaults = DATABASE[database] <NEW_LINE> config_names = database_defaults.get('config_names', D... | Read sys.argv and parse out repository of migrations and database url.
>>> import os
>>> from ConfigParser import SafeConfigParser
>>> from shutil import rmtree
>>> from tempfile import mkdtemp
>>> config_dir = mkdtemp()
>>> os.makedirs(os.path.join(config_dir, 'config'))
>>> def write_ini(path, property, value):
... ... | 625941d2a05bb46b383ec9e4 |
def list_listeners(self, lb_id, params=None): <NEW_LINE> <INDENT> url = self._LISTENERS_URL.format(lb_id=lb_id) <NEW_LINE> if params: <NEW_LINE> <INDENT> url = '{0}?{1}'.format(url, parse.urlencode(params)) <NEW_LINE> <DEDENT> resp, body = self.get(url) <NEW_LINE> body = jsonutils.loads(body) <NEW_LINE> self.expected_s... | List all listeners. | 625941d2bde94217f3682fb3 |
def show_info(args, request, client_info): <NEW_LINE> <INDENT> message = args[0] <NEW_LINE> return({"info": message}, client_info) | Displays an informational notification at the top of the screen. | 625941d2be8e80087fb20e04 |
def get_key_list(self): <NEW_LINE> <INDENT> return self._type2number.keys() | return key list | 625941d266656f66f7cbc36e |
def extractor(url): <NEW_LINE> <INDENT> response = requester(url, main_url, delay, cook, headers, timeout, host, ninja, user_agents, failed, processed) <NEW_LINE> if clone: <NEW_LINE> <INDENT> mirror(url, response) <NEW_LINE> <DEDENT> matches = re.findall(r'<[aA].*(href|HREF)=([^\s>]+)', response) <NEW_LINE> for link i... | Extract details from the response body. | 625941d21f037a2d8b9463c0 |
def test_and_set_connected(self, window_id): <NEW_LINE> <INDENT> if window_id in self.connected: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> self.connected.add(window_id) <NEW_LINE> return False | Test and set window_id in self.connected. | 625941d2f548e778e58cd741 |
def solutions(self): <NEW_LINE> <INDENT> if self.results is None: <NEW_LINE> <INDENT> warning('results') <NEW_LINE> return <NEW_LINE> <DEDENT> if self.is_isoschizomer(): <NEW_LINE> <INDENT> iso = True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> iso = False <NEW_LINE> <DEDENT> if type(self.best) == list: <NEW_LINE> <I... | Prints the solutions obtained for the diagnostic digest | 625941d231939e2706e4d02b |
def insert_entry(self, entry, taxids): <NEW_LINE> <INDENT> entry_dict = dict(entry.attrib) <NEW_LINE> entry_dict['created'] = datetime.strptime(entry_dict['created'], '%Y-%m-%d') <NEW_LINE> entry_dict['modified'] = datetime.strptime(entry_dict['modified'], '%Y-%m-%d') <NEW_LINE> taxid = self.get_taxid(entry) <NEW_LINE>... | insert UniProt entry | 625941d282261d6c526ab663 |
@treeio_login_required <NEW_LINE> @handle_response_format <NEW_LINE> def opportunity_edit(request, opportunity_id, response_format='html'): <NEW_LINE> <INDENT> opportunity = get_object_or_404(Opportunity, pk=opportunity_id) <NEW_LINE> if not request.user.profile.has_permission(opportunity, mode='w') and not ... | Opportunity edit | 625941d299cbb53fe6792da9 |
def flatten(response): <NEW_LINE> <INDENT> includes_users = defaultdict( lambda: {}, { **extract_includes(response, "users", "id"), **extract_includes(response, "users", "username"), }, ) <NEW_LINE> includes_media = extract_includes(response, "media", "media_key") <NEW_LINE> includes_polls = extract_includes(response, ... | Flatten an API response by moving all "included" entities inline with the
tweets they are referenced from. flatten expects an entire page response
from the API (data, includes, meta) and will raise a ValueError if what is
passed in does not appear to be an API response. It will return a list of
dictionaries where each ... | 625941d282261d6c526ab664 |
def post_plone_version(configurator, question, answer): <NEW_LINE> <INDENT> _set_plone_version_variables(configurator, answer) <NEW_LINE> return answer | Find out if it is supposed to be Plone 5. | 625941d2be7bc26dc91cd7c1 |
def getDBSummary(self): <NEW_LINE> <INDENT> retDict = {"Request": {}, "Operation": {}, "File": {}} <NEW_LINE> session = self.DBSession() <NEW_LINE> try: <NEW_LINE> <INDENT> requestQuery = session.query(Request._Status, func.count(Request.RequestID)).group_by(Request._Status).all() <NEW_LINE> for status, count in reques... | get db summary | 625941d2ad47b63b2c50a142 |
def test_find_by_address(self): <NEW_LINE> <INDENT> Customer( first_name="Some", last_name="Dude", email="coys@internet.com", address="House,Street,NotNewYork,GoodChoice", active=True, ).create() <NEW_LINE> Customer( first_name="P", last_name="Sherman", email="dory@findingnemo.com", address="42, Wallaby Way, Sydney, 'S... | Find a Customer by address | 625941d2283ffb24f3c55ac3 |
def terminal(self): <NEW_LINE> <INDENT> a = [x for x in self.moves() if x is not None] <NEW_LINE> if not a: <NEW_LINE> <INDENT> s = ReversiState(self.board, self.fields, self.opponent, self, None) <NEW_LINE> opp_moves = s.moves() <NEW_LINE> return not [y for y in opp_moves if y is not None] <NEW_LINE> <DEDENT> return F... | Determine wheater | 625941d2f7d966606f6aa1c8 |
def GetUserCfgDir(self): <NEW_LINE> <INDENT> cfgDir = '.idlerc' <NEW_LINE> userDir = os.environ.get('SPORKPATH', os.path.expanduser('~')) <NEW_LINE> if userDir != '~': <NEW_LINE> <INDENT> if not os.path.exists(userDir): <NEW_LINE> <INDENT> warn = ('\n Warning: os.path.expanduser("~") points to\n ' + userDir + ',\n but ... | Return a filesystem directory for storing user config files.
Creates it if required. | 625941d27d847024c06be480 |
def node_traces(self,pos,root_trace,node_trace,node_Mcolor='white'): <NEW_LINE> <INDENT> for node in self.G.nodes(): <NEW_LINE> <INDENT> x, y = pos[node] <NEW_LINE> if node == '': <NEW_LINE> <INDENT> root_trace['x'] += tuple([x]) <NEW_LINE> root_trace['y'] += tuple([y]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> nod... | Provides the information of the plotly traces for nodes.
pos: position of nodes
root_trace: the root plotly trace settings
node_trace: the node plotly trace settings
node_Mcolor: assign a color to the node, default white
Adds data to the plotly traces. Traces have to be created prior using plotly. | 625941d2fb3f5b602dac3857 |
def check_update(self, update): <NEW_LINE> <INDENT> if (not isinstance(update, Update) or update.channel_post or self.per_chat and not update.effective_chat or self.per_message and not update.callback_query or update.callback_query and self.per_chat and not update.callback_query.message): <NEW_LINE> <INDENT> return Non... | Determines whether an update should be handled by this conversationhandler, and if so in
which state the conversation currently is.
Args:
update (:class:`telegram.Update`): Incoming telegram update.
Returns:
:obj:`bool` | 625941d2ab23a570cc250346 |
def kick(self, request, queryset): <NEW_LINE> <INDENT> for user in queryset: <NEW_LINE> <INDENT> user.kick() | Logout selected users.
:param request: django request instance.
:type request: django.http.request.HttpRequest.
:param queryset: queryset with selected users.
:type queryset: django.db.models.query.QuerySet. | 625941d26aa9bd52df036f68 |
def select_all_pos(self): <NEW_LINE> <INDENT> self.selection = list() <NEW_LINE> unique_id = list() <NEW_LINE> if self.all_match_id is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> for i in self.all_match_id: <NEW_LINE> <INDENT> if i not in unique_id: <NEW_LINE> <INDENT> unique_id.append(i) <NEW_LINE> self.selec... | attach all match id to selection list | 625941d23346ee7daa2b2f30 |
def next_greater(s): <NEW_LINE> <INDENT> assert s <NEW_LINE> s2 = s.rstrip('\xff') <NEW_LINE> return s2 and (s2[:-1] + chr(ord(s2[-1]) + 1)) | Given a bytestring `s`, return the most compact bytestring that is
greater than any value prefixed with `s`, but lower than any other value.
::
>>> assert next_greater('') == '\x00'
>>> assert next_greater('\x00') == '\x01'
>>> assert next_greater('\xff') == '\xff\x00'
>>> assert next_greater('\x00\x0... | 625941d2f9cc0f698b1407be |
def test_vector(Simulator, nl): <NEW_LINE> <INDENT> N = 40 <NEW_LINE> m = nengo.Model('test_vector', seed=123) <NEW_LINE> input = nengo.Node(output=lambda t: [np.sin(t), np.cos(t), np.arctan(t)]) <NEW_LINE> A = nengo.Ensemble(nl(N * 3), 3, radius=2) <NEW_LINE> nengo.Connection(input, A) <NEW_LINE> in_p = nengo.Probe(in... | A network that represents sin(t), cos(t), arctan(t). | 625941d2167d2b6e31218d59 |
def get_address_from_loc(self, geocode): <NEW_LINE> <INDENT> address = self.gmaps.reverse_geocode(geocode) <NEW_LINE> return address | Get text address from geocode | 625941d23c8af77a43ae3964 |
def get_nonzero_random_bytes(length, rnd=default_crypto_random): <NEW_LINE> <INDENT> result = [] <NEW_LINE> i = 0 <NEW_LINE> while i < length: <NEW_LINE> <INDENT> rnd = rnd.getrandbits(12*length) <NEW_LINE> s = i2osp(rnd, 3*length) <NEW_LINE> s = s.replace('\x00', '') <NEW_LINE> result.append(s) <NEW_LINE> i += len(s) ... | Accumulate random bit string and remove bytes until the needed length
is obtained. | 625941d321bff66bcd684b15 |
def test_admin_can_change_location_of_pending_parcels(self): <NEW_LINE> <INDENT> self.client.post( "api/v2/users/parcels", data=(json.dumps(self.generic_parcel)), content_type="application/json", headers=self.headers) <NEW_LINE> location = {"current_location": "Nairoberry"} <NEW_LINE> res = self.client.put("/api/v2/par... | Admins should not be able to change current location of parcels not in transit | 625941d2236d856c2ad4499f |
def init(dispatcher: Dispatcher): <NEW_LINE> <INDENT> dispatcher.add_handler(CommandHandler('contact', contact, pass_args=True)) | Provide handlers initialization. | 625941d316aa5153ce36263b |
def handle_pong(self, id, pinged_by, status, latency): <NEW_LINE> <INDENT> key = (self._my_hostname, id) <NEW_LINE> assert key in self._pings <NEW_LINE> (target, plugin, local_timestamp, extra) = self._pings[key] <NEW_LINE> assert plugin is not None <NEW_LINE> plugins.Plugin.dispatch_pong_notification(plugin, pinged_by... | Called after any pong or pong_notification in reply of one of
the ping requests *we* made.
:param id: The ID of the ping request
:param pinged_by: The hostname of the host which actually pinged
the host.
:param status: Status of the request, if applicable
:param latency: The delta between the moment the ping was s... | 625941d3851cf427c661a6d1 |
def log_change(self, request, object, message): <NEW_LINE> <INDENT> super(VersionAdmin, self).log_change(request, object, message) <NEW_LINE> reversion.revision.user = request.user <NEW_LINE> reversion.revision.comment = message | Sets the version meta information. | 625941d31d351010ab855cdf |
@reversion.create_revision() <NEW_LINE> def update_virgo_model(inifile, modelname=None, verbose=False): <NEW_LINE> <INDENT> raise NotImplementedError("Parsing Virgo INI files has " "not been implemented yet.") | Update the Virgo channels from the given INI file
Parameters
----------
inifile : `str`, `file`-like
path to INI file on disk, or an open file
modelname : `str`
the name of the front-end model. Only required if `inifile` is
given as an open file | 625941d396565a6dacc8f88e |
def kidsWithCandies(self, candies, extraCandies): <NEW_LINE> <INDENT> maxCandy = max(candies) <NEW_LINE> answer = [] <NEW_LINE> for i in range(len(candies)): <NEW_LINE> <INDENT> if candies[i] + extraCandies >= maxCandy: <NEW_LINE> <INDENT> answer.append(True) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> answer.append(... | :type candies: List[int]
:type extraCandies: int
:rtype: List[bool] | 625941d30a366e3fb873e9de |
def get_list_of_urls_to_scrape(county: str = "Camden") -> list: <NEW_LINE> <INDENT> url_list = [] <NEW_LINE> urlbase = "https://visitsouthjersey.com/page/" <NEW_LINE> urlsuffix = f"/?post_type=member_org&member_org_categories=attractions&features%5Bcounty%5D={county}&features%5Bcity%5D" <NEW_LINE> for page in range(1, ... | function tests if URL with different page number (up to 10) is valid, then adds valid pages to url_list | 625941d3460517430c394346 |
def create_valid_date(date): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> valid_date = parse(six.text_type(date), default=datetime.datetime( year=1990, month=1, day=1)).strftime("%Y-%m-%d") <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> valid_date = '' <NEW_LINE> <DEDENT> return valid_date | Add '01' as a value of missing month and/or day values. | 625941d37c178a314d6ef625 |
def delete_consumer(self, consumer_id): <NEW_LINE> <INDENT> raise exception.NotImplemented() | Delete consumer.
:param consumer_id: id of consumer to get
:type consumer_ref: string
:returns: None. | 625941d367a9b606de4a807c |
def testGetDefaultCVSTagType( self ): <NEW_LINE> <INDENT> assertEquals( 'Default CVS tag type' , self.bif.getDefaultCVSTagType() , 'tag' ) | SuccessfulSetupTestCase::getDefaultCVSTagType() | 625941d3c4546d3d9de72bf8 |
def test_mag2db(self): <NEW_LINE> <INDENT> self.assertEqual( ut.mag2db(np.array([[1000]], dtype='float')), 60) | Test utility.mag2db. | 625941d3090684286d50eeaa |
def _get_target_size(self): <NEW_LINE> <INDENT> return self._target_size | Get this filesystem's target size. | 625941d3d6c5a1020814420f |
def __init__(self, controller): <NEW_LINE> <INDENT> self.c = controller <NEW_LINE> cut = str(get_monitors()[0]).split("(")[1].split("x") <NEW_LINE> self.SCREEN_WIDTH = int(cut[0]) <NEW_LINE> self.SCREEN_HEIGHT = int(cut[1].split("+")[0]) - 40 <NEW_LINE> self.SCREEN_CENTER = (self.SCREEN_WIDTH/2, self.SCREEN_HEIGHT/2) ... | Constructor | 625941d31f5feb6acb0c4d12 |
def _get_level_name(level): <NEW_LINE> <INDENT> if level is 'D': <NEW_LINE> <INDENT> return 'DEBUG' <NEW_LINE> <DEDENT> if level is 'I': <NEW_LINE> <INDENT> return 'INFO' <NEW_LINE> <DEDENT> if level is 'W': <NEW_LINE> <INDENT> return 'WARNING' <NEW_LINE> <DEDENT> if level is 'E': <NEW_LINE> <INDENT> return 'ERROR' <NE... | Convert one chars symbols to level name
| 625941d3bf627c535bc13392 |
@django_view <NEW_LINE> @ajax_request <NEW_LINE> @admin_cm_permission <NEW_LINE> def cma_ajax_get_table_images(request): <NEW_LINE> <INDENT> if request.method == 'GET': <NEW_LINE> <INDENT> rest_data = prep_data({'images_public': ('admin_cm/system_image/get_list/', {'access': image_access['public']}), 'images_private': ... | Ajax view for fetching images list. | 625941d37cff6e4e81117b49 |
def edit_menu_item(request, menu_item_id): <NEW_LINE> <INDENT> menu_item = Menu_item.objects.get(id=menu_item_id) <NEW_LINE> menu = menu_item.menu <NEW_LINE> if request.method != 'POST': <NEW_LINE> <INDENT> form = MenuItemForm(instance=menu_item) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> form = MenuItemForm(instanc... | Edit a menu item | 625941d39b70327d1c4e0f99 |
def __init__(self, complex_optional_roots: List[Location]): <NEW_LINE> <INDENT> self._location_to_children: Dict[Optional[Location], Set[Location]] = { optional_root_location: set() for optional_root_location in complex_optional_roots } <NEW_LINE> self._root_location: Optional[Location] = None <NEW_LINE> self._location... | Initialize empty tree of optional root Locations (elements of complex_optional_roots).
This object constructs a tree of complex optional roots. These are locations preceding an
@optional traverse that expand vertex fields within. Simple @optional traverses i.e.
ones that do not expand vertex fields within them are exc... | 625941d34d74a7450ccd4387 |
def percolator(self, index, name, query): <NEW_LINE> <INDENT> response = self.send_request('PUT', ['_percolator', index, name], query) <NEW_LINE> return response | Register specific definition for percolator query | 625941d3d6c5a10208144210 |
def example_producer(raw_data, batch_size, num_steps, name=None): <NEW_LINE> <INDENT> with tf.name_scope(name, "Producer", [raw_data, batch_size, num_steps]): <NEW_LINE> <INDENT> raw_data = tf.convert_to_tensor(raw_data, name="raw_data", dtype=tf.int32) <NEW_LINE> data_len = tf.size(raw_data) <NEW_LINE> batch_len = dat... | Iterate on the raw token ids.
This chunks up raw_data into batches of examples and returns Tensors that
are drawn from these batches.
Args:
raw_data: a list of integer token ids
batch_size: int, the batch size.
num_steps: int, the number of unrolls.
name: the name of this operation (optional).
Returns:
A p... | 625941d3009cb60464c63574 |
def test(): <NEW_LINE> <INDENT> title, dataset, document = get_title_context() <NEW_LINE> print("%d documents" % len(dataset)) <NEW_LINE> X, vectorizer = transform(dataset, n_features=500) <NEW_LINE> true_ks = [] <NEW_LINE> scores = [] | 测试选择最优参数 | 625941d3498bea3a759b9c72 |
def weight(self): <NEW_LINE> <INDENT> raise NotImplementedError() | Returns the weight matrix. | 625941d3b545ff76a8913fd9 |
def __str__( self ): <NEW_LINE> <INDENT> return '\n'.join( [ str(_d) for _d in self.dist ] ) | string representation | 625941d34a966d76dd5511d4 |
@pytest.fixture <NEW_LINE> def voucher_and_partial_matches_with_coupons(voucher_and_partial_matches): <NEW_LINE> <INDENT> context = voucher_and_partial_matches <NEW_LINE> products = [ ProductFactory(content_object=course_run) for course_run in context.partial_matches ] <NEW_LINE> coupon_eligibility_list = [ CouponEligi... | Returns a voucher with partial matching CourseRuns and valid coupons | 625941d30a366e3fb873e9df |
def get_options_parser(): <NEW_LINE> <INDENT> parser = argparse.ArgumentParser(description='Tool for creating notes in your gists', prog='noteit') <NEW_LINE> parser.add_argument('note', metavar='NOTE', nargs='*', default=_get_from_pipe(), help='new note') <NEW_LINE> parser.add_argument('-u', '--user', help='username') ... | Arguments definition | 625941d3adb09d7d5db6c953 |
def contained_simplex(self, large=True, initial_point=None, point_order=None): <NEW_LINE> <INDENT> self._assert_is_affine() <NEW_LINE> if point_order is None: <NEW_LINE> <INDENT> points = list(self.points()) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> points = list(reversed(point_order)) <NEW_LINE> initial_point = No... | Return a simplex contained in the point configuration.
INPUT:
- ``large`` -- boolean. Whether to attempt to return a large
simplex.
- ``initial_point`` -- a
:class:`~sage.geometry.triangulation.base.Point` or ``None``
(default). A specific point to start with when picking the
simplex vertices.
- ``point_o... | 625941d3d8ef3951e3243701 |
def __init__(self, uniq_id=None): <NEW_LINE> <INDENT> NodeObject.__init__(self) <NEW_LINE> self.uniq_id = uniq_id <NEW_LINE> self.type = "" <NEW_LINE> self.names = [] <NEW_LINE> self.pname = "" <NEW_LINE> self.coord = None | Creates a new Place instance. | 625941d3baa26c4b54cb12e2 |
def itkNarrowBandBNI2UC_cast(*args): <NEW_LINE> <INDENT> return _itkNarrowBandPython.itkNarrowBandBNI2UC_cast(*args) | itkNarrowBandBNI2UC_cast(itkLightObject obj) -> itkNarrowBandBNI2UC | 625941d32ae34c7f2600d2f5 |
def test_authentication(self): <NEW_LINE> <INDENT> connection = smtplib.SMTP(config.smtp_host, config.smtp_port) <NEW_LINE> connection.ehlo() <NEW_LINE> connection.starttls() <NEW_LINE> try: <NEW_LINE> <INDENT> connection.login(config.smtp_username, config.smtp_password) <NEW_LINE> return True <NEW_LINE> <DEDENT> excep... | Check to see whether or not the currently configured SMTP credentials can be used
to authenticate to the remote service.
:return: True if the current configured SMTP credentials can be used to authenticate to
the remote service, False otherwise. | 625941d330dc7b7665901b29 |
def init_hash(self): <NEW_LINE> <INDENT> self.cle_raw = self.cle_depart <NEW_LINE> self.debut = self.taille_bloc <NEW_LINE> self.final = (len(self.plain_txt) - 1) * self.taille_bloc <NEW_LINE> self.position = 0 | Réinitianyle les paramètres de hash | 625941d3cc0a2c11143dd055 |
def calc_gl_position_block(astrometry, trajectory): <NEW_LINE> <INDENT> s2d_list = trajectory['position'].T[:2].T <NEW_LINE> r2d_list = numpy.vstack((astrometry['x'], astrometry['y'])).T <NEW_LINE> mat_1 = numpy.einsum('ni,nj', s2d_list, s2d_list) <NEW_LINE> mat_2 = numpy.einsum('ni,nj', r2d_list, s2d_list) <NEW_LINE> ... | Finds the best linear transformation that
aligns the theoretical trajectory to the proper motion data
:param astrometry: Observational data (proper motion and radial velocity)
:param trajectory: Complete theoretical trajectory
:return: A 2x2 matrix | 625941d3b830903b967e9ace |
def has_intersection(p_a0, p_a1, p_b0, p_b1): <NEW_LINE> <INDENT> da_x, da_y = p_a1[0] - p_a0[0], p_a1[1] - p_a0[1] <NEW_LINE> db_x, db_y = p_b1[0] - p_b0[0], p_b1[1] - p_b0[1] <NEW_LINE> if da_x * db_y == db_x * da_y: <NEW_LINE> <INDENT> return True, False, 0, 0 <NEW_LINE> <DEDENT> a_x, a_y = p_a0 <NEW_LINE> b_x, b_y ... | Returns tuple[is_parallel: bool, has_intersection: bool, x: int, y] | 625941d3956e5f7376d71031 |
def __eq__(self, other): <NEW_LINE> <INDENT> if isinstance(other, Table): <NEW_LINE> <INDENT> return self.name == other.name <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | Checks for equality with another table.
:param other: The object to compare with this. If it is a table,
their names are compared. If not, the comparison returns false.
:return: A boolean representing whether the two objects are equal. | 625941d3d99f1b3c44c67751 |
def get_test_suites(): <NEW_LINE> <INDENT> suite = unittest.TestSuite() <NEW_LINE> suite.addTest(PageGenerateTestCase()) <NEW_LINE> return suite | Return test cases as a suite in this module | 625941d3c4546d3d9de72bf9 |
def test_field_with_custom_receiver_method(self): <NEW_LINE> <INDENT> obj = CustomReceiver.objects.create() <NEW_LINE> refreshed_obj = CustomReceiver.objects.get(pk=obj.pk) <NEW_LINE> self.assertIsNotNone(refreshed_obj.youyouid) <NEW_LINE> self.assertIsInstance(str(refreshed_obj.youyouid), str) <NEW_LINE> self.assertIs... | Should use a different receiver method for generating a custom
base64field. For this test `CustomReceiver` model will be used which
it will use `django_baset64field.tests.receivers:custom_receiver` as a
custom receiver for `Base64field`. | 625941d35f7d997b87174c5d |
def winsFor(self, ox): <NEW_LINE> <INDENT> for row in range(self.__height): <NEW_LINE> <INDENT> hCount = 0 <NEW_LINE> for col in range(self.__width): <NEW_LINE> <INDENT> if self.__board[row][col] == ox: <NEW_LINE> <INDENT> hCount +=1 <NEW_LINE> if hCount >= 4: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT... | Returns True if the checker, X or O in ox has won the calling board, otherwise returns False | 625941d3627d3e7fe0d69014 |
def generate(fevents, format, backends, binary=None, probe_prefix=None): <NEW_LINE> <INDENT> import tracetool <NEW_LINE> format = str(format) <NEW_LINE> if len(format) is 0: <NEW_LINE> <INDENT> raise TracetoolError("format not set") <NEW_LINE> <DEDENT> if not tracetool.format.exists(format): <NEW_LINE> <INDENT> raise T... | Generate the output for the given (format, backends) pair.
Parameters
----------
fevents : file
Event description file.
format : str
Output format name.
backends : list
Output backend names.
binary : str or None
See tracetool.backend.dtrace.BINARY.
probe_prefix : str or None
See tracetool.backend.d... | 625941d3462c4b4f79d1d895 |
def _get_or_allocate_key(self, key, array): <NEW_LINE> <INDENT> buf_arr = self._buffer.get(key, None) <NEW_LINE> if buf_arr is None: <NEW_LINE> <INDENT> buf_arr = np.zeros((self._capacity, array.shape[1]), array.dtype) <NEW_LINE> self._buffer[key] = buf_arr <NEW_LINE> <DEDENT> return buf_arr | Get or allocate key in the buffer.
Args:
key (str): Key in buffer.
array (numpy.ndarray): Array corresponding to key.
Returns:
numpy.ndarray: A NumPy array corresponding to key in the buffer. | 625941d3099cdd3c635f0e1f |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.