code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def split_bezier(bpoints, t): <NEW_LINE> <INDENT> def split_bezier_recursion(bpoints_left_, bpoints_right_, bpoints_, t_): <NEW_LINE> <INDENT> if len(bpoints_) == 1: <NEW_LINE> <INDENT> bpoints_left_.append(bpoints_[0]) <NEW_LINE> bpoints_right_.append(bpoints_[0]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> new_poin... | Uses deCasteljau's recursion to split the Bezier curve at t into two
Bezier curves of the same order. | 625941e471ff763f4b549a90 |
def remove_cached_file(self): <NEW_LINE> <INDENT> def remove_file(file): <NEW_LINE> <INDENT> if not file: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> filepath = join(get_storage_path(), file) <NEW_LINE> if exists(filepath): <NEW_LINE> <INDENT> remove(filepath) <NEW_LINE> return True <NEW_LINE> <DEDENT> return ... | Remove the downloaded cache files. | 625941e4d164cc617578314d |
def _check_vpcs_version(self, working_dir): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> output = subprocess.check_output([self._settings["path"], "-v"], cwd=working_dir) <NEW_LINE> match = re.search("Welcome to Virtual PC Simulator, version ([0-9a-z\.]+)", output.decode("utf-8")) <NEW_LINE> if match: <NEW_LINE> <INDEN... | Checks if the VPCS executable version is >= 0.5b1. | 625941e43d592f4c4ed1d461 |
def create_logger(self): <NEW_LINE> <INDENT> self.logger = logging.getLogger() <NEW_LINE> self.set_log_level() <NEW_LINE> formatter = self.set_log_format() <NEW_LINE> if self.print_to_file: <NEW_LINE> <INDENT> self.create_and_add_file_handler(formatter) <NEW_LINE> <DEDENT> if self.print_to_screen: <NEW_LINE> <INDENT> s... | Create logger handler, according to object properties.
:return: logger handler. | 625941e444b2445a33932491 |
def _check_base_crossover(self, base): <NEW_LINE> <INDENT> if base.down == None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if base.down.h != base.h: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if base.up == None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if base.up.h != base.h: <NEW_LINE> ... | Check if there is a crossover to a different helix at the given base.
Arguments:
base (DnaBase): The base to check for a crossover.
Returns True if there is a crossover at the base. | 625941e4099cdd3c635f1057 |
def unicode_exp(exp): <NEW_LINE> <INDENT> if exp == 1: <NEW_LINE> <INDENT> return chr(0xB9) <NEW_LINE> <DEDENT> if exp == 2 or exp == 3: <NEW_LINE> <INDENT> return chr(0xB0 + exp) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return chr(0x2070 + exp) | Get a exponent number for html format
https://es.stackoverflow.com/questions/316023/imprimir-exponente-en-python | 625941e4ad47b63b2c50a37d |
def turn_on(self): <NEW_LINE> <INDENT> self._player.play() | turn the media player on. | 625941e4d6c5a1020814444c |
def can_edit(self, user): <NEW_LINE> <INDENT> if getattr(user, 'is_admin', False): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> elif self.is_managed: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return self.is_admin(user) | Determine if user can edit group data.
:param user: User to be checked.
:returns: True or False. | 625941e4925a0f43d254a279 |
def search_all(self, sstr=None, columns=None): <NEW_LINE> <INDENT> if sstr is None: <NEW_LINE> <INDENT> print('... add search string') <NEW_LINE> os.exit(1) <NEW_LINE> <DEDENT> if columns is None: <NEW_LINE> <INDENT> columns = ['title', 'abstract', 'author', 'keywords', 'doi', 'local-url'] <NEW_LINE> <DEDENT> if 'keywo... | search searchword for all database | 625941e482261d6c526ab8a4 |
def __init__(self): <NEW_LINE> <INDENT> self.swagger_types = { 'last_heartbeat_time': 'datetime', 'last_transition_time': 'datetime', 'message': 'str', 'reason': 'str', 'status': 'str', 'type': 'str' } <NEW_LINE> self.attribute_map = { 'last_heartbeat_time': 'lastHeartbeatTime', 'last_transition_time': 'lastTransitionT... | V1NodeCondition - 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. | 625941e41f5feb6acb0c4f48 |
def freq(self, width): <NEW_LINE> <INDENT> hfreq.freq_multi(self.region, width, gen='Gen0') | Run the frequency command | 625941e463b5f9789fde74e4 |
def is_git_repo(): <NEW_LINE> <INDENT> sourcepath = os.path.realpath(os.path.join(os.path.dirname(nipype.__file__), os.path.pardir)) <NEW_LINE> gitpathgit = os.path.join(sourcepath, '.git') <NEW_LINE> if os.path.exists(gitpathgit): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return Fal... | Does the current nipype module have a git folder
| 625941e424f1403a92600f61 |
def day_counter(start_day): <NEW_LINE> <INDENT> day = datetime.strptime(start_day, '%m/%d/%Y').date() <NEW_LINE> tomorrow = date.today() + timedelta(days=1) <NEW_LINE> while day != tomorrow: <NEW_LINE> <INDENT> if day.weekday() not in {5, 6}: <NEW_LINE> <INDENT> yield day.strftime('%m/%d/%Y') <NEW_LINE> <DEDENT> day +=... | Function that will print out every work day from certain date
excluding weekend (Saturday and Sunday). | 625941e44e4d5625662d47d1 |
def propNRevsSpheres(mu, s0, beta, spheres, N=10, dT=np.pi, dv0=0.05, retDV=False, **kwargs): <NEW_LINE> <INDENT> pb = None <NEW_LINE> if 'progbar' in kwargs: <NEW_LINE> <INDENT> pb = kwargs.pop('progbar') <NEW_LINE> <DEDENT> v = findVSpheres(mu, s0, 90, spheres, dv0, **kwargs) <NEW_LINE> s1 = s0.copy() <NEW_LINE> s1[3... | Propagate spacecraft in CRTBP for N revolutions near libration point.
Every dT period calculates velocity correction vector at beta angle
(findVPlanes) for bounded motion. Initial beta = 90 degrees and
initial velocity correction vector is velocity itself.
Uses propCrtbp, findVPlanes.
Parameters
-----... | 625941e4379a373c97cfaf45 |
def runPortalMigration(context=None): <NEW_LINE> <INDENT> portal = getSite() <NEW_LINE> pm = getattr( portal, 'portal_migration', getToolByName(portal, 'portal_migration')) <NEW_LINE> if pm.needUpgrading(): <NEW_LINE> <INDENT> pm.upgrade() | Run any migrations that are pending
| 625941e4be8e80087fb2103b |
def generate_base(battery_dest,tasks=None,experiment_repo=None,survey_repo=None,game_repo=None, add_experiments=True,add_surveys=True,add_games=True,battery_repo=None,warning=True): <NEW_LINE> <INDENT> if experiment_repo == None or battery_repo == None or survey_repo == None or game_repo == None: <NEW_LINE> <INDENT> tm... | generate_base returns a folder with downloaded experiments, surveys, and battery, either specified by the user or a temporary directory, to be used by generate_local and generate (for psiturk)
:param battery_dest: [required] is the output folder for your battery. This folder MUST NOT EXIST.
:param battery_repo: locatio... | 625941e40383005118ecf9e0 |
@hook_specification(firstresult=True) <NEW_LINE> def ecl300_config_path(): <NEW_LINE> <INDENT> pass | :return: Path to ecl300 config file
:rtype: PluginResponse with data as str | 625941e4283ffb24f3c55cfb |
def get_queryset(self): <NEW_LINE> <INDENT> return self.request.user.courses.all() | This method is an implicit object-level permission management
This view will only match the ids of existing quizzes that belongs
to the logged in user. | 625941e40fa83653e46573b7 |
def test_auth_anon_user_cant_view_manage_datasets(self): <NEW_LINE> <INDENT> app = self._get_test_app() <NEW_LINE> factories.Dataset(type='showcase', name='my-showcase') <NEW_LINE> app.get('/showcase/manage_datasets/my-showcase', status=302) | An anon (not logged in) user can't access the showcase manage datasets page. | 625941e43346ee7daa2b316d |
def update_language(self, message): <NEW_LINE> <INDENT> for item_p in self.iview.root.GetChildren(): <NEW_LINE> <INDENT> for item_module in item_p.GetChildren(): <NEW_LINE> <INDENT> m_data = item_module.GetData() <NEW_LINE> if isinstance(m_data[0], PackageFile): <NEW_LINE> <INDENT> item_module.SetText(self.iview._packa... | Actualiza nombres de módulos y paquetes del tree principal cuando se
cambia el lenguaje.
:param Message: Mensaje conteniendo el topic. | 625941e421bff66bcd684d4d |
def create_node(self, **kwargs): <NEW_LINE> <INDENT> node = self.ex_create_node_nowait(**kwargs) <NEW_LINE> timeout = 60 * 20 <NEW_LINE> waittime = 0 <NEW_LINE> interval = 2 * 60 <NEW_LINE> while node.id is None and waittime < timeout: <NEW_LINE> <INDENT> nodes = self.list_nodes() <NEW_LINE> for i in nodes: <NEW_LINE> ... | Create a new GoGird node
@inherits: :class:`NodeDriver.create_node`
:keyword ex_description: Description of a Node
:type ex_description: ``str``
:keyword ex_ip: Public IP address to use for a Node. If not
specified, first available IP address will be picked
:type ex_ip: ``str``
:rtype:... | 625941e4cdde0d52a9e53434 |
def getOne(self, table=None, fields='*', where=None, order=None, limit=(0, 1)): <NEW_LINE> <INDENT> cur = self._select(table, fields, where, order, limit) <NEW_LINE> result = cur.fetchone() <NEW_LINE> row = None <NEW_LINE> if result: <NEW_LINE> <INDENT> fields = [f[0] for f in cur.description] <NEW_LINE> row = zip(fiel... | Get a single result
table = (str) table_name
fields = (field1, field2 ...) list of fields to select
where = ("parameterizedstatement", [parameters])
eg: ("id=%s and name=%s", [1, "test"])
order = [field, ASC|DESC]
limit = [from, to] | 625941e4460517430c394579 |
def perseverationsList(l): <NEW_LINE> <INDENT> if len(l) > 0: <NEW_LINE> <INDENT> if isinstance(l[0][0], list): <NEW_LINE> <INDENT> perseveration_items = [perseverationsList(i) for i in l] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> perseveration_items = [list(set([item for item in ls if ls.count(item) > 1])) for ls ... | One line description here.
Detailed description here. Detailed description here. Detailed
description here.
Args:
arg1 (type): Description here.
arg2 (type): Description here.
Returns:
Detailed description here. Detailed description here. Detailed
description here. | 625941e4cc0a2c11143dd290 |
def test_publication_disabled(self): <NEW_LINE> <INDENT> toggle_switch('publish_program_to_marketing_site', active=False) <NEW_LINE> with mock.patch.object(ProgramMarketingSitePublisher, '__init__') as mock_init: <NEW_LINE> <INDENT> self.program.save() <NEW_LINE> self.program.delete() <NEW_LINE> assert mock_init.call_c... | Verify that the publisher is not initialized when publication is disabled. | 625941e4851cf427c661a90a |
def serialize_numpy(self, buff, numpy): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> _x = self <NEW_LINE> buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) <NEW_LINE> _x = self.header.frame_id <NEW_LINE> length = len(_x) <NEW_LINE> if python3 or type(_x) == unicode: <NEW_LINE> <IND... | serialize message with numpy array types into buffer
:param buff: buffer, ``StringIO``
:param numpy: numpy python module | 625941e445492302aab5e6c6 |
def write_csv(self, path, line_delimiter="\n", field_delimiter=',', write_mode=WriteMode.NO_OVERWRITE): <NEW_LINE> <INDENT> child = dict() <NEW_LINE> child[_Fields.IDENTIFIER] = _Identifier.SINK_CSV <NEW_LINE> child[_Fields.PATH] = path <NEW_LINE> child[_Fields.PARENT] = self._info <NEW_LINE> child[_Fields.DELIMITER_FI... | Writes a Tuple DataSet as a CSV file to the specified location.
Note: Only a Tuple DataSet can written as a CSV file.
:param path: The path pointing to the location the CSV file is written to.
:param write_mode: OutputFormat.WriteMode value, indicating whether files should be overwritten | 625941e438b623060ff0b1ec |
def delete_blog(self, name, session_id=1): <NEW_LINE> <INDENT> conn, cursor = self.connect() <NEW_LINE> if session_id == 1: <NEW_LINE> <INDENT> print('Авторизуйтесь, чтобы удалить блог') <NEW_LINE> self.close_connect(conn) <NEW_LINE> return <NEW_LINE> <DEDENT> cursor.execute("SELECT name FROM blogs WHERE user_id = '%s'... | Удалить блог | 625941e4fb3f5b602dac3a96 |
def add_ocr_tokens_recursive(text, tess_outdirs: list, freqlist_forms): <NEW_LINE> <INDENT> if not tess_outdirs: <NEW_LINE> <INDENT> return text <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> new_text = add_ocr_tokens(text, tess_outdirs[0], freqlist_forms) <NEW_LINE> return add_ocr_tokens_recursive(new_text, tess_outdir... | Return text with added tokens from each tesseract-OCR-model (cf. traineddata_labels). | 625941e45166f23b2e1a5558 |
def put(self, request, pk=None): <NEW_LINE> <INDENT> return Response({'method': 'PUT'}) | Handle updating objects, will replace the fields that are not supplied | 625941e456ac1b37e62645c7 |
def fuzz(self): <NEW_LINE> <INDENT> self.mreq.request_targets(self.fuzzy_targets) <NEW_LINE> results = [] <NEW_LINE> for target, response in self.mreq.results: <NEW_LINE> <INDENT> logger.debug("target type: %s", type(target)) <NEW_LINE> try: <NEW_LINE> <INDENT> result = self.analyze_response(target, response) <NEW_LINE... | Fuzz all the targets and return the results.
returns list of Result objects. | 625941e4ec188e330fd5ab96 |
def btn_delete_clicked(self): <NEW_LINE> <INDENT> buttonReply = QtWidgets.QMessageBox.question(self.temp_window, "Message", 'Delete the product "{}" ?'.format(self.selected_product), QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No) <NEW_LINE> if buttonReply == QtWidgets.QMessageBox.Yes: <... | Call a function delete_product_byId to delete the selected product | 625941e47b25080760e39856 |
def get_filename(self): <NEW_LINE> <INDENT> if self._msg is None: <NEW_LINE> <INDENT> raise NotmuchError(STATUS.NOT_INITIALIZED) <NEW_LINE> <DEDENT> return Message._get_filename(self._msg) | Returns the file path of the message file
:returns: Absolute file path & name of the message file
:exception: :exc:`NotmuchError` STATUS.NOT_INITIALIZED if the message
is not initialized. | 625941e460cbc95b062c6942 |
def retain_layer_output(dest, layer, name): <NEW_LINE> <INDENT> dest[name] = None <NEW_LINE> def hook_fn(m, i, output): <NEW_LINE> <INDENT> dest[name] = output.detach() <NEW_LINE> <DEDENT> layer.register_forward_hook(hook_fn) | Callback function to keep a reference to a layer's output in a dict. | 625941e463b5f9789fde74e5 |
def register_invokation_syntax(server): <NEW_LINE> <INDENT> invk_syn = invokation_syntax() <NEW_LINE> invk_syn.element_name = "serialize" <NEW_LINE> invk_syn.allowed_parent_components = ["pipeline", "match", "when", "otherwise"] <NEW_LINE> invk_syn.required_attribs = ["type"] <NEW_LINE> invk_syn.required_attrib_values ... | Allows the component to register the required XML element syntax for it's invokation
in sitemap files with the sitemap_config_parse class. | 625941e47047854f462a1804 |
def findNodeSentinel(self,delim,lines,n): <NEW_LINE> <INDENT> offset = 0 <NEW_LINE> nodeSentinelLine = -1 <NEW_LINE> line = n - 1 <NEW_LINE> while len(lines) > line >= 0 and nodeSentinelLine == -1: <NEW_LINE> <INDENT> progress = line <NEW_LINE> s = lines[line] <NEW_LINE> i = g.skip_ws(s,0) <NEW_LINE> if g.match(s,i,del... | Scan backwards from the line n, looking for an @-body line. When found,
get the VNode's name from that line and set p to the indicated VNode. This
will fail if VNode names have been changed, and that can't be helped.
We compute the offset of the requested line **within the found node**. | 625941e4287bf620b61d3e60 |
def testerPresent(self, active=True, reqId=None, interval=250): <NEW_LINE> <INDENT> reqId = reqId or self.currentReqId <NEW_LINE> if active is True: <NEW_LINE> <INDENT> self.sendCtrlSeq(["p 6 8 " + str(interval) + " 0", "p 6 6 $" + reqId + " 0"] , False) <NEW_LINE> logging.info("Tester Present On") <NEW_LINE> <DEDENT> ... | This function enables/disables sending the tester present message in the background.
:param active: Sets if the periodic tester present message should be send or not
:type active: bool
:param reqId: The RequestID you want to send to. If left blank, the reqId configured in the configureCAN function is used
:type reqId:... | 625941e4f548e778e58cd97e |
def edges_to_single(list_of_edges): <NEW_LINE> <INDENT> output = [0] * (len(list_of_edges) + 1) <NEW_LINE> for edge in list_of_edges: <NEW_LINE> <INDENT> output[edge[1]] = edge[0] <NEW_LINE> <DEDENT> return output | converts the get_edmonds output (a list of edges) to the format used in the paper | 625941e42c8b7c6e89b35bbd |
def generate_repo_file_name(repo_uuid): <NEW_LINE> <INDENT> if repo_uuid is not None: <NEW_LINE> <INDENT> return check_uuid(repo_uuid) + '.tar' | Work out file name for repo_uuid (or None if repo_uuid is None) | 625941e463f4b57ef000150d |
def mask_data(self, rms=None, nsig=None, **kwargs): <NEW_LINE> <INDENT> if rms is None: <NEW_LINE> <INDENT> rms = self.rms <NEW_LINE> <DEDENT> if nsig is None: <NEW_LINE> <INDENT> nsig = self.nsig <NEW_LINE> <DEDENT> maskval = kwargs.get('maskval', 0.0) <NEW_LINE> return np.where(self.data >= nsig * rms, self.data, mas... | Mask the data by some RMS value. | 625941e4ff9c53063f47c5f1 |
def _select_by_id(self): <NEW_LINE> <INDENT> if self._connection is not None and self.category_id is not None: <NEW_LINE> <INDENT> _cursor = self._connection.cursor(buffered=True) <NEW_LINE> _cursor.execute(self._select_query_by_id, (self.category_id,)) <NEW_LINE> for (category_id, pattern, prefix, suffix, ref_that, re... | select row from db if exists and populate respective fields
Returns:
status (bool): return true if record loaded in respective vars else false | 625941e4a17c0f6771cbe44e |
def iso_attr_diff(g0, g1): <NEW_LINE> <INDENT> assert type(g0) == type(g1) <NEW_LINE> node_diff = {} <NEW_LINE> edge_diff = {} <NEW_LINE> if isinstance(g0, nx.MultiDiGraph): <NEW_LINE> <INDENT> matcher = nx.isomorphism.MultiDiGraphMatcher(g0, g1) <NEW_LINE> if not matcher.is_isomorphic(): <NEW_LINE> <INDENT> raise Valu... | Find differences in node/edge attributes of structurally isomorphic graphs.
Parameters
----------
g0, g1 : networkx.Graph
NetworkX graphs. Graphs must be of the same type.
Returns
-------
node_diff : dict
Each key is a tuple containing the isomorphic node IDs in `g0` and `g1`,
respectively; the value cont... | 625941e4a79ad161976cc545 |
def add_paths(self, addition, metadata): <NEW_LINE> <INDENT> expect_type(addition, list) <NEW_LINE> for path in addition: <NEW_LINE> <INDENT> expect_type(path, str) <NEW_LINE> f = File(template={'remote_path': path}) <NEW_LINE> f.update(metadata) <NEW_LINE> self.add(f) | Add multiple files to this file collection.
TODO: This has some issues. Do you always want to assume the added
paths are local paths? Is this whole schema a bit heavy-handed?
Example:
>>> cond_a_pairs = ['file/path/one_a.fq', 'file/path/two_a.fq']
>>> reads_a = FileCollection().add_multi(cond_a_pairs,
...... | 625941e430dc7b7665901d61 |
def get_model_classes(self): <NEW_LINE> <INDENT> pass | Returns the Classes for the models representing the tables | 625941e4f7d966606f6aa408 |
def apply(self, name, evaluation): <NEW_LINE> <INDENT> py_name = name.to_python() <NEW_LINE> if not (isinstance(py_name, str) and py_name[0] == py_name[-1] == '"'): <NEW_LINE> <INDENT> evaluation.message("AbsoluteFileName", "fstr", name) <NEW_LINE> return <NEW_LINE> <DEDENT> py_name = py_name[1:-1] <NEW_LINE> result = ... | AbsoluteFileName[name_] | 625941e4a219f33f34628d64 |
def __get_nested_config(self, path_list, value): <NEW_LINE> <INDENT> config_part = {} <NEW_LINE> if len(path_list) == 1: <NEW_LINE> <INDENT> config_part[path_list[0]] = value <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> config_part[path_list[0]] = self.__get_nested_config(path_list[1:], value) <NEW_LINE> <DEDENT> retu... | Recursively builds a dict path from a list of strings, and sets the value
Args:
- path_list: list of strings to build a path from
- value: value to set at the path specified
Returns:
dictionary | 625941e482261d6c526ab8a5 |
def load(fp, encoding=None, cls=None, object_hook=None, **kw): <NEW_LINE> <INDENT> return loads(fp.read()) | Deserialize the contents of a file containing a JSON object to a Python
object.
@type fp: file
@param fp: The file to read
@rtype: object
@return: the deserialized Python object
NOTE: The various keywords arguments are ignored; they only exist
for calling compatibility with C{simplejson}. | 625941e4d18da76e235328da |
def factorial(n): <NEW_LINE> <INDENT> n=n <NEW_LINE> total = product(n, identity) <NEW_LINE> return total | Return n factorial for n >= 0 by calling product.
>>> factorial(4)
24
>>> factorial(6)
720
>>> from construct_check import check
>>> check(HW_SOURCE_FILE, 'factorial', ['Recursion', 'For', 'While'])
True | 625941e45510c4643540f7d9 |
def test_post_with_conflict(self): <NEW_LINE> <INDENT> self._login_user(admin=True) <NEW_LINE> group = self.create_review_group() <NEW_LINE> rsp = self.apiPost( get_review_group_list_url(), { 'name': group.name, 'display_name': 'My Group', }, expected_status=409) <NEW_LINE> self.assertEqual(rsp['stat'], 'fail') <NEW_LI... | Testing the POST groups/ API with Group Already Exists error | 625941e426068e7796caf0e4 |
def test_get_namespaced_serviceaccount(self): <NEW_LINE> <INDENT> pass | Test case for get_namespaced_serviceaccount
read the specified ServiceAccount | 625941e4de87d2750b860196 |
def process_request_using_patch1(self, body, request_headers, routing_key, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('async_req'): <NEW_LINE> <INDENT> return self.process_request_using_patch1_with_http_info(body, request_headers, routing_key, **kwargs) <NEW_LINE> <D... | processRequest # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.process_request_using_patch1(body, request_headers, routing_key, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str body: msg ... | 625941e48e7ae83300e4b3cd |
def guild_ranks(self): <NEW_LINE> <INDENT> r = requests.get(self._url + self._extension_rank + self._key, auth=('user', 'pass')) <NEW_LINE> if r.status_code != 200: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> return r.json() | Call GW2-API and get guild ranks or else None | 625941e497e22403b379d39b |
def testRealpath(self): <NEW_LINE> <INDENT> self.setUpLinks() <NEW_LINE> self.path = filepath.FilePath(self.path.path) <NEW_LINE> self.assertEquals(self.path.child("sub1.link").realpath(), self.path.child("sub1")) <NEW_LINE> self.assertEquals(self.path.child("sub1").realpath(), self.path.child("sub1")) | Verify that a symlink is correctly normalized | 625941e431939e2706e4d264 |
def update(self,screen_rect): <NEW_LINE> <INDENT> self.adjust_images() <NEW_LINE> if self.direction_stack: <NEW_LINE> <INDENT> direction_vector = DIRECT_DICT[self.direction_stack[-1]] <NEW_LINE> self.rect.x += self.speed*direction_vector[0] <NEW_LINE> self.rect.y += self.speed*direction_vector[1] <NEW_LINE> self.rect.c... | Updates our player appropriately every frame. | 625941e4b545ff76a8914215 |
@commandWrap <NEW_LINE> def SetMeshSprayTool(*args, **kwargs): <NEW_LINE> <INDENT> return cmds.SetMeshSprayTool(*args, **kwargs) | :rtype: list|str|DagNode|AttrObject|ArrayAttrObject|Components1Base | 625941e4fbf16365ca6f65cb |
def ghk_current(x,cr,c_0=1.0): <NEW_LINE> <INDENT> c_in = c_0 <NEW_LINE> c_out = cr*c_0 <NEW_LINE> ex = p.exp(-x) <NEW_LINE> return x*(c_in - c_out*ex)/(1. - ex) | the Goldman-Hodgkin-Katz current equation
x: the normalized voltage
cr: the concentration ratio
c_0: the reference (inside) concentration | 625941e44c3428357757c725 |
def forward(self, img, index, alpha): <NEW_LINE> <INDENT> averaged = self.fromRGB[index-1](self.avgpool(img)) <NEW_LINE> x = self.fromRGB[index](img) <NEW_LINE> for i in reversed(range(index+1)): <NEW_LINE> <INDENT> if i == 0: <NEW_LINE> <INDENT> minibatch_std = img.std(dim=0) <NEW_LINE> averaged_std = minibatch_std.me... | Args:
img:
index:
alpha:
Returns: | 625941e4097d151d1a223257 |
@contextlib.contextmanager <NEW_LINE> def extract_time_series(data_path, cleanup_archive=True, cleanup_files=False, extract_dir=None): <NEW_LINE> <INDENT> if extract_dir is None: <NEW_LINE> <INDENT> extract_dir = tempfile.mkdtemp() <NEW_LINE> <DEDENT> if tarfile.is_tarfile(data_path): <NEW_LINE> <INDENT> archive = tarf... | Extract zip- or tarfile of time series file and return file paths.
If the given file is not a tar- or zipfile then it is treated as a single
time series filepath.
Parameters
----------
data_path : str
Path to data archive or single data file.
cleanup_archive : bool, optional
Boolean specifying whether to del... | 625941e4498bea3a759b9eae |
def __init__(self): <NEW_LINE> <INDENT> self.BATCH_SIZE = self.IMAGES_PER_GPU * self.GPU_COUNT <NEW_LINE> self.IMAGE_SHAPE = np.array( [self.IMAGE_MIN_DIM, self.IMAGE_MIN_DIM, 3]) <NEW_LINE> self.TEXTURE_SHAPE = np.array( [self.TEXTURE_SIZE, self.TEXTURE_SIZE, 3]) | Set values of computed attributes. | 625941e430dc7b7665901d62 |
def affine_backward(dout, cache): <NEW_LINE> <INDENT> x, theta, theta_0 = cache <NEW_LINE> dx, dtheta, dtheta_0 = None, None, None <NEW_LINE> x1 = x.reshape(x.shape[0],-1) <NEW_LINE> dx1 = np.dot(dout, theta.T) <NEW_LINE> dx = dx1.reshape(x.shape) <NEW_LINE> dtheta = np.dot(x1.T, dout) <NEW_LINE> dtheta_0 = np.sum(dout... | Computes the backward pass for an affine layer.
Inputs:
- dout: Upstream derivative, of shape (m, h)
- cache: Tuple of:
- x: Input data, of shape (m, d_1, ... d_k)
- theta: Weights, of shape (d, h)
Returns a tuple of:
- dx: Gradient with respect to x, of shape (m, d1, ..., d_k)
- dtheta: Gradient with respect to ... | 625941e45fc7496912cc3d7d |
def getSubscription(self,jid): <NEW_LINE> <INDENT> return self._getItemData(jid,'subscription') | Returns 'subscription' value of contact 'jid'. | 625941e4d486a94d0b98e546 |
def __init__(self): <NEW_LINE> <INDENT> self.obj = {} | Initialize your data structure here. | 625941e4bd1bec0571d90a2e |
def expect_lsas(router, area, lsas, wait=5, extra_params=""): <NEW_LINE> <INDENT> tgen = get_topogen() <NEW_LINE> command = "show ipv6 ospf6 database {} json".format(extra_params) <NEW_LINE> logger.info("waiting OSPFv3 router '{}' LSA".format(router)) <NEW_LINE> test_func = partial( topotest.router_json_cmp, tgen.gears... | Run the OSPFv3 show LSA database command and expect the supplied LSAs.
Optional parameters:
* `wait`: amount of seconds to wait.
* `extra_params`: extra LSA database parameters.
* `inverse`: assert the inverse of the expected. | 625941e4236d856c2ad44bdf |
def variant( self, document_id=None, gene_panels=None, case_id=None, simple_id=None, variant_type="clinical", ): <NEW_LINE> <INDENT> query = {} <NEW_LINE> if case_id and document_id: <NEW_LINE> <INDENT> query["case_id"] = case_id <NEW_LINE> query["variant_id"] = document_id <NEW_LINE> <DEDENT> elif case_id and simple_i... | Returns the specified variant.
Args:
document_id : A md5 key that represents the variant or "variant_id"
gene_panels(List[GenePanel])
case_id (str): case id (will search with "variant_id")
simple_id (str): a variant simple_id (example: 1_161184089_G_GTA)
variant_type(str): 'research' or 'clinical' ... | 625941e430bbd722463cc1c8 |
def register_class(cls): <NEW_LINE> <INDENT> REGISTRY[cls.__name__] = cls | Register a class' existence in the registry.
:param cls: Class to register
:return: None | 625941e407f4c71912b11884 |
def test_journeys(self): <NEW_LINE> <INDENT> response = self.query("/v1/{q}".format(q=journey_basic_query)) <NEW_LINE> self.is_valid_journey_response(response, journey_basic_query) <NEW_LINE> assert len(response['feed_publishers']) == 1 <NEW_LINE> assert response['feed_publishers'][0]['name'] == u'routing api data' <NE... | journey query with 2 overlapping coverage.
main_routing_test is free
empty_routing_test is not free but without data (and with the same bounding shape than main_routing_test)
the empty region should be chosen first and after having returned no journey the real region should be called
==> ie we must have a journey in t... | 625941e4cc40096d61595d4f |
def __put_setting(self, setting_name, setting_value): <NEW_LINE> <INDENT> self.__settings.beginGroup("settings") <NEW_LINE> value = self.__settings.setValue(setting_name, setting_value) <NEW_LINE> self.__settings.endGroup() | writes a new value to a specified setting | 625941e4fbf16365ca6f65cc |
def recv(self): <NEW_LINE> <INDENT> assert self.open <NEW_LINE> while self.open: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> fin, opcode, data = self.read_frame() <NEW_LINE> <DEDENT> except NoDataException: <NEW_LINE> <INDENT> return "" <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> LOGGER.debug("Failed to... | Receive data from the websocket.
This is slightly different from 'websockets' in that it doesn't
fire off a routine to process frames and put the data in a queue.
If you don't call recv() sufficiently often you won't process control
frames. | 625941e4f8510a7c17cf9aff |
def deserialise_options(option_s, translations): <NEW_LINE> <INDENT> pairs = option_s.split(",") <NEW_LINE> options = {} <NEW_LINE> for pair in pairs: <NEW_LINE> <INDENT> k, v = [s.strip() for s in pair.split("=")] <NEW_LINE> translation = translations.get(k, None) <NEW_LINE> if translation: <NEW_LINE> <INDENT> for mat... | Take a serialised dictionary on the form key=value,key=value... and
return an actual dictionary.
translations is a dictionary of keys to key/value pairs of replacements. | 625941e450485f2cf553d19b |
def all_txs(self, att): <NEW_LINE> <INDENT> return self.cmp_txs(att) + self.pl_txs(att) | returns the list of treatments currently associated with an attribute.
eg all_txs("ul8") may return ["O", "B,CO"] | 625941e40383005118ecf9e1 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, ReportInProductSentByDetails): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.to_dict() == other.to_dict() | Returns true if both objects are equal | 625941e4e76e3b2f99f3ac05 |
def test_peak_summer_on_peak(): <NEW_LINE> <INDENT> usage_time = "2020-07-24T15:00:00" <NEW_LINE> rate, is_on_peak = get_rate(usage_time) <NEW_LINE> assert rate == 0.2409 <NEW_LINE> assert is_on_peak is True | Test peak summer on peak price. | 625941e410dbd63aa1bd2fa2 |
def run_cmd_no_fail(cmd, input_str=None, from_dir=None, verbose=None, dry_run=False, arg_stdout=subprocess.PIPE, arg_stderr=subprocess.PIPE, env=None, combine_output=False, exc_type=SystemExit): <NEW_LINE> <INDENT> stat, output, errput = run_cmd(cmd, input_str=input_str, from_dir=from_dir, verbose=verbose, dry_run=dry_... | Wrapper around subprocess to make it much more convenient to run shell commands.
Expects command to work. Just returns output string.
>>> run_cmd_no_fail('echo foo') == 'foo'
True
>>> run_cmd_no_fail('echo THE ERROR >&2; false') # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SystemExit: ERROR: Command:... | 625941e491f36d47f21ac8f7 |
def mouse_contains(self, pos): <NEW_LINE> <INDENT> if sum([o.x for o in self.parents()]) < pos[0] - self.x < sum([o.x for o in self.parents()]) + self.width: <NEW_LINE> <INDENT> if sum([o.y for o in self.parents()]) + self.y + self.shift < pos[1] < sum([o.y for o in self.parents()]) + self.y + self.s... | Checks whether or not the position is within the scroll-bar, in its current scroll state. | 625941e4d268445f265b526f |
def set_JobID(self, value): <NEW_LINE> <INDENT> super(DeleteJobBookmarkInputSet, self)._set_input('JobID', value) | Set the value of the JobID input for this Choreo. ((required, integer) Enter a LinkedIn job ID.) | 625941e4009cb60464c637af |
def add_to_segment(self, entry: str, error: bool) -> None: <NEW_LINE> <INDENT> self.entries.append(entry) <NEW_LINE> if error is True: <NEW_LINE> <INDENT> self.error_present = True | Adds an entry to the current segment. | 625941e40a366e3fb873ec1e |
def notify_settings(self, host, dbloc, instance): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> url_loc = "http://" + host + ":8008/file_operation?arg0=list_user_storage_file&arg1=&arg2=" + instance + "&arg3=20&arg4=true&arg5=true&arg6=true&arg7=all&arg8=name_asc&arg9=false&arg10=false" <NEW_LINE> req = urllib2.Request(... | Retrieves the NMJv2 database location from Popcorn hour
host: The hostname/IP of the Popcorn Hour server
dbloc: 'local' for PCH internal harddrive. 'network' for PCH network shares
instance: Allows for selection of different DB in case of multiple databases
Returns: True if the settings were retrieved successfully, F... | 625941e4fff4ab517eb2f83e |
def stored_name(self, name): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> path = super().stored_name(name) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> parsed_name = urlsplit(unquote(name)) <NEW_LINE> path = parsed_name.path.strip() <NEW_LINE> <DEDENT> return path | Prevent ManifestStaticFilesStorage from raising a ValueError when a
file is not found in the manifest.json, or the manifest.json was
never created (i.e. collectstatic was never run). This will prevent
an incorrectly referenced static file in a template from causing
a 500 error. | 625941e4f9cc0f698b1409f8 |
def how_many(aDict): <NEW_LINE> <INDENT> values = 0 <NEW_LINE> for i in aDict: <NEW_LINE> <INDENT> values += len(aDict[i]) <NEW_LINE> <DEDENT> return values | aDict: A dictionary, where all the values are lists.
returns: int, how many values are in the dictionary. | 625941e4eab8aa0e5d26df5a |
def recevoir(self, depot): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.depot.pull(depot) <NEW_LINE> <DEDENT> except f.GitError as err: <NEW_LINE> <INDENT> f.traiter_erreur(err) <NEW_LINE> return self.afficher(self._conflit(err)) <NEW_LINE> <DEDENT> b.redirect(self.url) | Réception des modifications distantes | 625941e432920d7e50b285d4 |
def image_reader(filename): <NEW_LINE> <INDENT> image = CCDData.read(filename, unit = 'adu') <NEW_LINE> return image | Takes in a filename/directory string, and then reads the data using
astropy's CCDData attribute, where the file is in .fits file format. | 625941e46fb2d068a760f4a4 |
def train_nn(sess, epochs, batch_size, get_batches_fn, train_op, cross_entropy_loss, input_image, correct_label, keep_prob, learning_rate): <NEW_LINE> <INDENT> sess.run(tf.global_variables_initializer()) <NEW_LINE> print("Training...") <NEW_LINE> print() <NEW_LINE> for epoch_index in range(epochs): <NEW_LINE> <INDENT> ... | Train neural network and print out the loss during training.
:param sess: TF Session
:param epochs: Number of epochs
:param batch_size: Batch size
:param get_batches_fn: Function to get batches of training data. Call using get_batches_fn(batch_size)
:param train_op: TF Operation to train the neural network
:param cros... | 625941e4ff9c53063f47c5f2 |
def GetChar(self): <NEW_LINE> <INDENT> c = self.stream.read(1) or 'R_EOF' <NEW_LINE> if c != 'R_EOF': <NEW_LINE> <INDENT> if c == '\n': <NEW_LINE> <INDENT> self.line += 1 <NEW_LINE> self.last_col, self.col = self.col, 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.col += 1 <NEW_LINE> <DEDENT> <DEDENT> self.last_g... | Read the next character, updating the current line and column. | 625941e41f5feb6acb0c4f4a |
def is_writable_directory(dir_path): <NEW_LINE> <INDENT> if not os.path.exists(dir_path): <NEW_LINE> <INDENT> raise ValueError("Directory does not exist: %s", dir_path) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> testfile = tempfile.TemporaryFile(dir=dir_path) <NEW_LINE> testfile.close() <NEW_LINE> <DEDENT> except OSE... | Returns True if dir_path is writable, False otherwise
Arguments:
dir_path - A directory path | 625941e466673b3332b92492 |
def get_name(self): <NEW_LINE> <INDENT> name = random.choice(self.get_queryset()) <NEW_LINE> return name | Return a random unused name. | 625941e48a349b6b435e8573 |
@asyncio.coroutine <NEW_LINE> def async_setup(hass, config): <NEW_LINE> <INDENT> hass.http.register_view(DialogflowIntentsView) <NEW_LINE> return True | Set up Dialogflow component. | 625941e482261d6c526ab8a6 |
def host_maintenance_mode(self, host, mode): <NEW_LINE> <INDENT> if not mode: <NEW_LINE> <INDENT> return 'off_maintenance' <NEW_LINE> <DEDENT> host_list = [host_ref for host_ref in self._session.call_xenapi('host.get_all') if host_ref != self._session.get_xenapi_host()] <NEW_LINE> migrations_counter = vm_counter = 0 <N... | Start/Stop host maintenance window. On start, it triggers
guest VMs evacuation. | 625941e424f1403a92600f63 |
def testBody(self): <NEW_LINE> <INDENT> model = swagger_client.models.body.Body() | Test Body | 625941e4236d856c2ad44be0 |
def execute_with_bar( command_line: List[str], prefix: str, end="\r{prefix}: " + Color.GREEN + "Done" + Color.RESET + "\n") -> List[str]: <NEW_LINE> <INDENT> process: subprocess.Popen = subprocess.Popen( command_line, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ) <NEW_LINE> duration = "Unknown" <NEW_LINE> li... | Executes the command line and displays a progress bar for it.
:return: The output value of the process
:except: CalledProcessError if the exit code is non-zero | 625941e491af0d3eaac9be1d |
def update_format_nick(self): <NEW_LINE> <INDENT> for row in self._model: <NEW_LINE> <INDENT> if isinstance(row[1], e3.Group): <NEW_LINE> <INDENT> for contact_row in row.iterchildren(): <NEW_LINE> <INDENT> contact_row[2] = self.format_nick(contact_row[1]) <NEW_LINE> <DEDENT> <DEDENT> elif isinstance(row[1], e3.Contact)... | update the format of contact nick name | 625941e416aa5153ce362878 |
def eval(self, code, **vars): <NEW_LINE> <INDENT> f_locals = self.f_locals.copy() <NEW_LINE> f_locals.update(vars) <NEW_LINE> return eval(code, self.f_globals, f_locals) | Evaluate 'code' in the frame.
'vars' are optional additional local variables.
Returns the result of the evaluation. | 625941e4d18da76e235328db |
def test_index_view_with_two_past_questions(self): <NEW_LINE> <INDENT> create_question_with_choice(question_text="Past question 1.", days=-30) <NEW_LINE> create_question_with_choice(question_text="Past question 2.", days=-5) <NEW_LINE> response = self.client.get(reverse('polls:index')) <NEW_LINE> self.assertQuerysetEqu... | The questions index page may display multiple questions. | 625941e4be8e80087fb2103d |
def __init__(self, directory): <NEW_LINE> <INDENT> self.directory = directory <NEW_LINE> self.mt = MyTools() <NEW_LINE> self.DOC = intro | directory = dossier racine de recherche des scripts | 625941e43cc13d1c6d3c7779 |
def find(self, k): <NEW_LINE> <INDENT> secondary = self._map[k] <NEW_LINE> return (k, secondary[0]) | Return arbitrary (k,v) pair with given key(or raise KeyError). | 625941e40fa83653e46573b9 |
def __score(self): <NEW_LINE> <INDENT> total = sum(len(set(self.__recommendation.for_one(user, self.__test.hold_out)).intersection(items)) for user, items in self.__test.data.items()) <NEW_LINE> return total / self.__test.number_of_cases | Returns the average number of correctly predicted buys per user. | 625941e4627d3e7fe0d69252 |
def get_list_value(self): <NEW_LINE> <INDENT> return self.list_value | Retrieves the list value.
:rtype: List
:return: The list value. | 625941e4cdde0d52a9e53436 |
def find_all_adverbs(self): <NEW_LINE> <INDENT> words = self.ds[Text._element_types[1]] <NEW_LINE> adverbs = [] <NEW_LINE> for word in words: <NEW_LINE> <INDENT> if word.is_adverb(): <NEW_LINE> <INDENT> adverbs.append(word) <NEW_LINE> <DEDENT> <DEDENT> return adverbs | Finds all the adverbs in the text. | 625941e467a9b606de4a82b8 |
def supports_vault_lookup(self): <NEW_LINE> <INDENT> return 'supports_vault_lookup' in profile.SUPPORTS | Tests if a vault lookup service is supported.
A vault lookup service defines methods to access authorization
vaults.
return: (boolean) - ``true`` if function lookup is supported,
``false`` otherwise
*compliance: mandatory -- This method must be implemented.* | 625941e466656f66f7cbc5ad |
def test_align(self): <NEW_LINE> <INDENT> shape = SpectralShape(100, 900, 5) <NEW_LINE> self.assertEqual(self.__spd.clone().align(shape).shape, shape) <NEW_LINE> shape = SpectralShape(600, 650, 1) <NEW_LINE> self.assertEqual(self.__spd.clone().align(shape).shape, shape) | Tests
:func:`colour.colorimetry.spectrum.SpectralPowerDistribution.align`
method. | 625941e4cc0a2c11143dd293 |
def test_last_contribution_date(self): <NEW_LINE> <INDENT> u = user(username='satdav', save=True) <NEW_LINE> p = profile(user=u) <NEW_LINE> self.refresh() <NEW_LINE> data = UserMappingType.search().query( username__match='satdav').values_dict()[0] <NEW_LINE> assert not data['last_contribution_date'] <NEW_LINE> d = date... | Verify the last_contribution_date field works properly. | 625941e4004d5f362079a731 |
def _make_cuda(self): <NEW_LINE> <INDENT> self.papemb = self.papemb.cuda() <NEW_LINE> self.papemb_mask = self.papemb_mask.cuda() <NEW_LINE> self.autemb = self.autemb.cuda() <NEW_LINE> self.autemb_mask = self.autemb_mask.cuda() <NEW_LINE> self.features = self.features.cuda() <NEW_LINE> if self.target is not None: <NEW_L... | Move the batch to GPU
:return: | 625941e438b623060ff0b1ee |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.