code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def get_init(self): <NEW_LINE> <INDENT> return self.graph.get_graph_parameter("init") | Getter.
:return: The initialized global variables of the graph. | 625941bc21bff66bcd684825 |
def delete_zcs_image(session, zcs_image_id, return_type=None, **kwargs): <NEW_LINE> <INDENT> verify_zcs_image_id(zcs_image_id) <NEW_LINE> path = '/api/images/{0}.json'.format(zcs_image_id) <NEW_LINE> return session.delete_api(path=path, return_type=return_type, **kwargs) | Deletes a Zadara Container Services (ZCS) image. There must not be any
spawned containers using this image. This action is irreversible.
:type session: zadarapy.session.Session
:param session: A valid zadarapy.session.Session object. Required.
:type zcs_image_id: str
:param zcs_image_id: The ZCS image 'name' value... | 625941bc10dbd63aa1bd2a7c |
def get_name(self, number, text=""): <NEW_LINE> <INDENT> content = super().get_content(number) <NEW_LINE> return content.name | Get the name to represent the content, here name of the content | 625941bcbd1bec0571d90508 |
def ColorShade(hexcode, factor=0.6): <NEW_LINE> <INDENT> r, g, b = tuple(int(hexcode.lstrip("#")[i:i+2], 16)*factor for i in (0, 2 ,4)) <NEW_LINE> newhex = "#{0:02x}{1:02x}{2:02x}".format(int(r), int(g), int(b)).upper() <NEW_LINE> return newhex | Creates a shade as determined by <factor> | 625941bc8e7ae83300e4ae9c |
@plugin.interval(24 * 60 * 60) <NEW_LINE> def _clean_cache(bot): <NEW_LINE> <INDENT> if bot.memory['safety_cache_lock'].acquire(False): <NEW_LINE> <INDENT> LOGGER.info('Starting safety cache cleanup...') <NEW_LINE> try: <NEW_LINE> <INDENT> cutoff = time.time() - (7 * 24 * 60 * 60) <NEW_LINE> old_keys = [] <NEW_LINE> fo... | Cleans up old entries in URL safety cache. | 625941bc3346ee7daa2b2c3a |
def populate_hostid_cache(self): <NEW_LINE> <INDENT> temp_dict = {} <NEW_LINE> data = self.zapi.host.get(output=['hostid', 'host']) <NEW_LINE> for host in data: <NEW_LINE> <INDENT> temp_dict[host['hostid']] = host['host'] <NEW_LINE> <DEDENT> return temp_dict | DESCRIPTION:
Populate hostid cache | 625941bcaad79263cf39090d |
def _set_topleft(el, pos): <NEW_LINE> <INDENT> left, top = pos <NEW_LINE> x_shift = 0 <NEW_LINE> y_shift = 0 <NEW_LINE> if left is not None: <NEW_LINE> <INDENT> x_shift = left - el.get_storer_rect().left <NEW_LINE> <DEDENT> if top is not None: <NEW_LINE> <INDENT> y_shift = top - el.get_storer_rect().top <NEW_LINE> <DED... | Set element <el>'s topleft using its storer_rect as reference. | 625941bc4428ac0f6e5ba6c2 |
def close(self): <NEW_LINE> <INDENT> if not self.is_closed: <NEW_LINE> <INDENT> while not self.is_closed: <NEW_LINE> <INDENT> for window in self._windows: <NEW_LINE> <INDENT> self._terminate(window.handle) | Closes SAP GUI windows.
:return: None | 625941bc91f36d47f21ac3c0 |
def deploy(): <NEW_LINE> <INDENT> clone_repo_if_needed() <NEW_LINE> with cd(env.project_root): <NEW_LINE> <INDENT> run_with_failure('git pull --all', 'Updating all repos failed.') <NEW_LINE> run_with_failure('git checkout %s' % env.branch, 'Updating %s branch failed.' % env.branch) <NEW_LINE> run_with_failure('git pull... | Updates the server and restarts it | 625941bc3eb6a72ae02ec3a5 |
def synch(self): <NEW_LINE> <INDENT> self.logger('INFO', 'Begin synching ' + str(self.localdir) + ' <=> ' + self.bucketname) <NEW_LINE> self.validate_local_folder() <NEW_LINE> if not self.TEMP_DB_DIR.exists(): <NEW_LINE> <INDENT> self.logger('DEBUG', 'Create temporary folder') <NEW_LINE> self.TEMP_DB_DIR.mkdir() <NEW_L... | This overrides the original synch() and rebuilds an *online* version of the code
:return: | 625941bc9b70327d1c4e0ca4 |
def StartInterrogationHunt(self): <NEW_LINE> <INDENT> flow_name = compatibility.GetName(flows_discovery.Interrogate) <NEW_LINE> flow_args = flows_discovery.InterrogateArgs(lightweight=False) <NEW_LINE> description = "Interrogate run by cron to keep host info fresh." <NEW_LINE> hunt_id = hunt.CreateAndStartHunt( flow_na... | Starts an interrogation hunt on all available clients. | 625941bc3c8af77a43ae366e |
def shift_fields(expr, shift): <NEW_LINE> <INDENT> return Shifter()(expr, shift=shift) | Returns an expression with all :class:`Field`\ s shifted by ``shift``--i.e.,
with ``shift`` added elementwise to each :class:`Field`'s ``offset`` attribute.
:arg expr: The expression(s) to be mapped.
:arg shift: A :class:`tuple`.
.. versionadded:: 2020.1 | 625941bc7d43ff24873a2b6e |
def reaction_stats_strs(self, ): <NEW_LINE> <INDENT> reaction_stats_strs = [] <NEW_LINE> for reactant_pair_str, c_j, reactant_pair in sorted((sorted([repr(d) for d in k]), v, k) for k, v in self.possible_hybridization_reactions.items()): <NEW_LINE> <INDENT> d1, d2 = tuple(reactant_pair) <NEW_LINE> domain1, d... | Generate a string with reaction stats. | 625941bc85dfad0860c3ad2a |
def dev_parsed(**kwargs): <NEW_LINE> <INDENT> result = {} <NEW_LINE> for line in _dev(**kwargs).split('\n'): <NEW_LINE> <INDENT> match = _PHY_RE.match(line) <NEW_LINE> if match: <NEW_LINE> <INDENT> phy = match.group('phy').replace('#', '') <NEW_LINE> result[phy] = {'interfaces': []} <NEW_LINE> <DEDENT> else: <NEW_LINE>... | Parse the results of 'iw dev'.
Args:
**kwargs: Passed to the underlying subprocess call.
Returns:
A dict of the the form: {'phyX': 'interfaces': ['interfaceN', ...]} | 625941bcd7e4931a7ee9dded |
def test_viewing_a_single_question(self): <NEW_LINE> <INDENT> response = self.client.get( '/api/v1/questions/1', data=json.dumps(self.questions), content_type='application/json') <NEW_LINE> self.assertEqual(response.status_code, 200) | Test user can view a single question. | 625941bc24f1403a92600a3a |
def show_table(table): <NEW_LINE> <INDENT> labels = [ 'ID', 'Full ID', 'Item name', 'Manufacturer', 'Purchase date', 'Durbility', ] <NEW_LINE> ui.print_table(table, labels) | Display a table
Args:
table: list of lists to be displayed.
Returns:
None | 625941bcd486a94d0b98e016 |
def __setitem__(self, index, value): <NEW_LINE> <INDENT> list.__setitem__(self, index, protocol.base_rep[value]) | Replaces a single Token of the Message with another Token.
>>> m = NOT(GOF)
>>> m[2] = DRW; print m
NOT ( DRW )
>>> m[-1] = 42; print m
NOT ( DRW 42
>>> m[3]
IntegerToken(42)
>>> m[-2] = [YES, KET] #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
TypeError: list objects are unhashable | 625941bc9c8ee82313fbb645 |
def Build(sess, document_source, FLAGS): <NEW_LINE> <INDENT> task_context = FLAGS["task_context"] <NEW_LINE> arg_prefix = FLAGS["arg_prefix"] <NEW_LINE> num_actions = FLAGS["num_actions"] <NEW_LINE> feature_sizes = FLAGS["feature_sizes"] <NEW_LINE> domain_sizes = FLAGS["domain_sizes"] <NEW_LINE> embedding_dims = FLAGS[... | Builds a sub-network, which will be either the tagger or the parser
Args:
sess: tensorflow session to use
document_source: the input of serialized document objects to process
Flags: (taken from FLAGS argument)
num_actions: number of possible golden actions
feature_sizes: size of each feature vector
domain_s... | 625941bc1f037a2d8b9460d0 |
def _expected_blocks(self, block_types=None, get_parent=False): <NEW_LINE> <INDENT> blocks = {} <NEW_LINE> def add_block(xblock): <NEW_LINE> <INDENT> children = xblock.get_children() <NEW_LINE> if block_types is None or xblock.category in block_types: <NEW_LINE> <INDENT> parent = None <NEW_LINE> if get_parent: <NEW_LIN... | Construct expected blocks.
Arguments:
block_types (list): List of required block types. Possible values include sequential,
vertical, html, problem, video, and discussion. The type can also be
the name of a custom type of block used for the course.
get_parent (boo... | 625941bcd58c6744b4257b31 |
def has_constraint_violation(A, vr, epsilon=1E-8): <NEW_LINE> <INDENT> lhs = 1 - A[0, 1:].sum() <NEW_LINE> rhs = dot(vr[:, 1:], A[1:, 0]) <NEW_LINE> rhs = -1 * rhs.min() <NEW_LINE> if abs(lhs - rhs) > epsilon: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | Check for constraint violations in transformation matrix.
Parameters
----------
A : ndarray
The transformation matrix.
vr : ndarray
The right eigenvectors.
epsilon : float, optional
Tolerance of constraint violation.
Returns
-------
truth : bool
Whether or not the violation exists
Notes
-------
... | 625941bc63f4b57ef0000ff1 |
def _default_platform(): <NEW_LINE> <INDENT> if os.environ.get('PIGLIT_PLATFORM'): <NEW_LINE> <INDENT> return os.environ.get('PIGLIT_PLATFORM') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> plat = core.PIGLIT_CONFIG.get('core', 'platform') <NEW_LINE> if plat not in core.PLATFORMS: <NEW_LINE> <I... | Logic to determine the default platform to use
This assumes that the platform can only be set on Linux, it probably works
on BSD. This is only relevant if piglit is built with waffle support. When
waffle support lands for Windows and if it ever happens for OSX, this will
need to be extended.
On Linux this will try in... | 625941bc1f5feb6acb0c4a25 |
def has_uncommitted_files(): <NEW_LINE> <INDENT> uncommitted_files = subprocess.check_output(GIT_IS_DIRTY_CMD.split(' ')) <NEW_LINE> return bool(len(uncommitted_files)) | Returns true if the repo contains modified files that are uncommitted.
Ignores untracked files. | 625941bc94891a1f4081b979 |
def check_connectivity( self, resource_group_name, network_watcher_name, source, destination, custom_headers=None, raw=False, polling=True, **operation_config): <NEW_LINE> <INDENT> raw_result = self._check_connectivity_initial( resource_group_name=resource_group_name, network_watcher_name=network_watcher_name, source=s... | Verifies the possibility of establishing a direct TCP connection from a
virtual machine to a given endpoint including another VM or an
arbitrary remote server.
:param resource_group_name: The name of the network watcher resource
group.
:type resource_group_name: str
:param network_watcher_name: The name of the networ... | 625941bc76d4e153a657ea01 |
def throttle(self, last_io=None): <NEW_LINE> <INDENT> if last_io is not None: <NEW_LINE> <INDENT> self._last_io_datetime = last_io <NEW_LINE> <DEDENT> reference = datetime.now() <NEW_LINE> if self._last_io_datetime is None: <NEW_LINE> <INDENT> self._last_io_datetime = reference <NEW_LINE> return <NEW_LINE> <DEDENT> if ... | A common throttle control | 625941bc5166f23b2e1a502a |
def _delete_file(file_name: str): <NEW_LINE> <INDENT> os.remove(file_name) | Removes the image from the local file system. | 625941bc91af0d3eaac9b8e6 |
def set_source_colorvalue(self, color, lighten=0): <NEW_LINE> <INDENT> self.set_source_rgba( color.red / 255. + lighten, color.green / 255. + lighten, color.blue / 255. + lighten, color.alpha) | Set the source pattern from a ``cssutils.ColorValue`` object. | 625941bccad5886f8bd26eb3 |
def shortenLine(self, content, max_length, **kwargs): <NEW_LINE> <INDENT> return shorten_line(content, max_length, **kwargs) | Return the supplied *line* shortened to the number to *max_length*.
The *\*\*kwargs* are keyword arguments passed the `shorten_line` function. | 625941bc67a9b606de4a7d8d |
def check_self_colision(snake): <NEW_LINE> <INDENT> head = snake[0] <NEW_LINE> if snake.count(head) > 1: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | Intersection check | 625941bc5fcc89381b1e158e |
def load_json(filename): <NEW_LINE> <INDENT> with open(filename, 'r') as fhnd: <NEW_LINE> <INDENT> return json.load(fhnd) | Load contents of given JSON file and return them as data structures. | 625941bc38b623060ff0acc0 |
def get_normalized_args(): <NEW_LINE> <INDENT> normalized_args = {} <NEW_LINE> args = request.args <NEW_LINE> for key, value in list(args.items()): <NEW_LINE> <INDENT> normalized_args[key.lower()] = value <NEW_LINE> <DEDENT> return normalized_args | Function converting parameter names to lowercase strings
:param serv: Service object
:param args: parameters of the TJS request
:return: request response | 625941bc45492302aab5e191 |
def main(): <NEW_LINE> <INDENT> cd_to_script_path() <NEW_LINE> output_folder = get_output_folder() <NEW_LINE> clear_the_cache = process_command_line_params() <NEW_LINE> if clear_the_cache: <NEW_LINE> <INDENT> clear_cache() <NEW_LINE> <DEDENT> load_cache() <NEW_LINE> module_initialisations() <NEW_LINE> copy_resources(ou... | What it says: the main function | 625941bc7047854f462a12dd |
def create_imageDB(filenamestr, saveURI, echo=False): <NEW_LINE> <INDENT> imagedb.connect2db(saveURI, echo) <NEW_LINE> files = glob.glob(filenamestr) <NEW_LINE> images = [] <NEW_LINE> for filepath in files: <NEW_LINE> <INDENT> run, camcol, filter, field = filepath2frameId(filepath) <NEW_LINE> images.append(imagedb.Imag... | Finds all paths to matching files given by filenamestr, extracts their
frame identifiers and stores them in a database given by saveURI.
Examples
--------
Filenamestr can contain wildcards, f.e.:
>>> create_imageDB("/path/to/dir_containing_subdirs/*/*.png",
"sqlite:///foo.db")
will find all /path/to/dir/subdirs/... | 625941bc0fa83653e4656e8d |
def prepare_csv_read(data, field_names, *args, **kwargs): <NEW_LINE> <INDENT> if hasattr(data, "readlines") or isinstance(data, list): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> elif isinstance(data, basestring): <NEW_LINE> <INDENT> data = open(data) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise TypeError("Unab... | Prepare various input types for CSV parsing
>>> list(prepare_csv_read(open("real_file.csv"),
... ("type", "bool", "string")))
[{'bool': 'true', 'type': 'file', 'string': 'test'}]
>>> test_list = ['James,Rowe', 'ell,caro']
>>> list(prepare_csv_read(test_list, ("first", "last")))
[{'last': 'Rowe', ... | 625941bc9f2886367277a761 |
def read_all(self, connection): <NEW_LINE> <INDENT> connection.setblocking(0) <NEW_LINE> data = self._read(connection, self.rec_buf_size) <NEW_LINE> while len(data) > 0: <NEW_LINE> <INDENT> self._read_buffer += data <NEW_LINE> data = self._read(connection, self.rec_buf_size) <NEW_LINE> <DEDENT> self._flush_read() <NEW_... | Read from a connection until the bytestream dries up.
Sets the connection to non-blocking mode, and then repeatedly reads from it until a socket.error is raised,
which happens when the buffer is empty.
this is a bit fragile, in the sense that part of a message might be delayed, in which case it'll return
immediately w... | 625941bc287bf620b61d393e |
def __smbpasswd(self, username, password): <NEW_LINE> <INDENT> if domaincontroller_enabled(): <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> command = '/usr/local/bin/smbpasswd -D 0 -s -a "%s"' % (username) <NEW_LINE> smbpasswd = self._pipeopen(command) <NEW_LINE> smbpasswd.communicate("%s\n%s\n" % (password, passwor... | Add the user ``username'' to samba using ``password'' as
the current password
Returns:
True whether the user has been successfully added and False otherwise | 625941bcd53ae8145f87a146 |
def correct_offset_in_file(file_path, lat_field, lng_field, out_fields): <NEW_LINE> <INDENT> temp_file = tempfile.NamedTemporaryFile(delete=False) <NEW_LINE> with open(file_path, 'rb') as csv_file: <NEW_LINE> <INDENT> csv_reader = csv.DictReader(remove_bom_from_first(csv_file)) <NEW_LINE> csv_reader.next() <NEW_LINE> c... | Generates a temp file with corrected coordinates for the given file_path.
Params:
:file_path: Path to the file whose coordinates should be corrected.
:lat_field: Name of the field in which latitude coordinates are found.
:lng_field: Name of the field in which longitude coordinates are found.
:out_field... | 625941bc4e696a04525c931d |
def london(): <NEW_LINE> <INDENT> print("\nYou made it to London, and you've almost completed your bucketlist.") <NEW_LINE> print("You are still being chased by the police and have to leave Europe.") <NEW_LINE> print("Luckily the last item of your bucketlist is to stay at a beach bungalow in Thailand.") <NEW_LINE> prin... | Sixth room of the game.
The player is now in London.
Still being chased by the police for what the player has done in Berlin, the
player now has to come up with a plan to flee Europe and still complete his/
her bucketlist. | 625941bcff9c53063f47c0c6 |
def call_at_to(start_datetime, end_datetime, f, *args, **kwargs): <NEW_LINE> <INDENT> delta = start_datetime - datetime.datetime.now() <NEW_LINE> seconds_ahead = delta.days * SECONDS_IN_DAY + delta.seconds + delta.microseconds / US_IN_SECOND <NEW_LINE> delta = end_datetime - datetime.datetime.now() <NEW_LINE> seconds_b... | Run f(*args, **kwargs) at datetime. | 625941bc50812a4eaa59c1f6 |
def filter_counter(self, counter, min=2, max=100000000): <NEW_LINE> <INDENT> records_filterd = {} <NEW_LINE> counter_all_records = 0 <NEW_LINE> for item in counter: <NEW_LINE> <INDENT> counter_all_records += 1 <NEW_LINE> if max > counter[item] >= min: <NEW_LINE> <INDENT> records_filterd[item] = counter[item] <NEW_LINE>... | Filter the counted records.
Returns: List with record numbers. | 625941bcfff4ab517eb2f30b |
def exercise_complex(show_result=True): <NEW_LINE> <INDENT> if show_result is False: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> c_abs = 1.2 <NEW_LINE> c_angle = 20 <NEW_LINE> c_angle_rad = np.deg2rad(c_angle) <NEW_LINE> a = c_abs * np.cos(c_angle_rad) <NEW_LINE> b = c_abs * np.sin(c_angle_rad) <NEW_LINE> c = a + b*... | Exercise 1: Rotate Complex Number
Notebook: PCP_06_complex.ipynb
Args:
show_result: Show result (Default value = True) | 625941bc55399d3f05588584 |
def draw_module_names(ax, vertical=False, color='white'): <NEW_LINE> <INDENT> if cfg.geometry == '9M': <NEW_LINE> <INDENT> if vertical is True: <NEW_LINE> <INDENT> y = 952 <NEW_LINE> for j in range(3): <NEW_LINE> <INDENT> x = 256 <NEW_LINE> for i in range(6): <NEW_LINE> <INDENT> t_str = 'T#{:02d}'.format(cfg.Eiger9M.T[... | Write out the names of the modules in the 9M image.
Names are fetched from sls_detector.config.Eiger9M
Parameters
----------
ax: mpl.axes
axes to draw the names on
vertical: bool, optional
Defaults to False, set to True if the image is rotated
color: str
Textcolor | 625941bc711fe17d82542243 |
def get_tracking_work_size(self): <NEW_LINE> <INDENT> return sum([len(ca) - 1 if len(ca) > 0 else 0 for ca in self.channel_accumulator.values()]) | :return: | 625941bc046cf37aa974cc1b |
def test_case(self, instance, node): <NEW_LINE> <INDENT> if 'end' in node.attribute.values: <NEW_LINE> <INDENT> return node.attribute.name <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> example_value = instance.get_value(node.attribute) <NEW_LINE> for child in node.children: <NEW_LINE> <INDENT> if example_value == child... | Recursively pass a given instance through the decision tree and return the answer
:param instance: (Example) the information to classify
:param node: (Node) current node
:return:
(str) the trained classification for the given decision tree | 625941bc9b70327d1c4e0ca5 |
def get_average_pln_for_day(self, currency: Currency, date: datetime.date) -> Optional[Decimal]: <NEW_LINE> <INDENT> url = QuotatorNBP._make_url(currency.value, date) <NEW_LINE> return self._read_average_pln(url) | Implements QuotesProviderProtocol | 625941bc7b180e01f3dc46d6 |
@login_required(login_url='login') <NEW_LINE> def my_likes(request): <NEW_LINE> <INDENT> posts = TablePost.objects.filter(table_like_set__like_from=request.user, table_like_set__like=True) <NEW_LINE> for post in posts: <NEW_LINE> <INDENT> post.is_liked = True <NEW_LINE> <DEDENT> context = { 'posts': posts, } <NEW_LINE>... | The 'my_likes' view displays all posts we liked on the website. | 625941bca4f1c619b28aff11 |
def git_check_no_modified_files(): <NEW_LINE> <INDENT> command = [ 'git', 'submodule', 'foreach', '--recursive', 'git', 'diff', '--quiet', 'HEAD'] <NEW_LINE> subprocess.check_call(command) <NEW_LINE> command = [ 'git', 'diff', '--quiet', 'HEAD'] <NEW_LINE> subprocess.check_call(command) | Make sure that there are no modified files.
| 625941bc009cb60464c63285 |
def get_all(context, session): <NEW_LINE> <INDENT> query = session.query(models.MetadefResourceType) <NEW_LINE> resource_types = query.all() <NEW_LINE> resource_types_list = [] <NEW_LINE> for rt in resource_types: <NEW_LINE> <INDENT> resource_types_list.append(rt.as_dict()) <NEW_LINE> <DEDENT> return resource_types_lis... | Get a list of all resource types | 625941bc796e427e537b0494 |
def process_compare_data(params): <NEW_LINE> <INDENT> for cur_date in rrule(MONTHLY, dtstart=params['ini_date'], until=params['end_date']): <NEW_LINE> <INDENT> next_date = cur_date + relativedelta( months=1) - relativedelta(minutes=1) <NEW_LINE> logging.info('Querying: cur_date: %s; next_date: %s', cur_date.date().isof... | Processa dados para comparacao entre DESSEM e SAGIC | 625941bccc40096d61595823 |
def shape_mask_shift(shape_mask, mean_shift): <NEW_LINE> <INDENT> vshift = int(np.ceil(mean_shift[0])) <NEW_LINE> hshift = int(np.ceil(mean_shift[1])) <NEW_LINE> if vshift > 0: <NEW_LINE> <INDENT> shape_mask = np.delete(shape_mask, np.s_[-abs(vshift):], axis = 0) <NEW_LINE> shape_mask = np.insert(shape_mask, np.s_[0:ab... | Shifts the before-and-after images so that old particles will be masked and not counted in
the new image | 625941bcf548e778e58cd44e |
def to_dict(self): <NEW_LINE> <INDENT> if self.failure: <NEW_LINE> <INDENT> failure = self.failure.to_dict() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> failure = None <NEW_LINE> <DEDENT> return { 'failure': failure, 'meta': self.meta, 'name': self.name, 'results': self.results, 'state': self.state, 'version': self.v... | Translates the internal state of this object to a ``dict``.
:returns: this atom detail in ``dict`` form | 625941bc15fb5d323cde09dd |
def remove_comments(self): <NEW_LINE> <INDENT> result = [] <NEW_LINE> for token in self.lexems: <NEW_LINE> <INDENT> if token.tag == 'COMMENT': <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> result.append(token) <NEW_LINE> <DEDENT> <DEDENT> return result | Removes the comments from the token list
---
Args: None
Return : None | 625941bc50485f2cf553cc6a |
def densenet121(expandSize, pretrained=False, **kwargs): <NEW_LINE> <INDENT> model = DenseNet(expandSize, num_init_features=64, growth_rate=32, block_config=(6, 12, 24, 16), **kwargs) <NEW_LINE> if pretrained: <NEW_LINE> <INDENT> model.load_state_dict(model_zoo.load_url(model_urls['densenet121'])) <NEW_LINE> <DEDENT> r... | Densenet-121 model from
`"Densely Connected Convolutional Networks" <https://arxiv.org/pdf/1608.06993.pdf>`
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet | 625941bc63d6d428bbe443c1 |
def getSystem(self, block="AUTO"): <NEW_LINE> <INDENT> if block is True: <NEW_LINE> <INDENT> self.wait() <NEW_LINE> <DEDENT> elif block == "AUTO" and self._is_blocked: <NEW_LINE> <INDENT> self.wait() <NEW_LINE> <DEDENT> if self.isError(): <NEW_LINE> <INDENT> _warnings.warn("The process exited with an error!") <NEW_LINE... | Get the latest molecular system.
Parameters
----------
block : bool
Whether to block until the process has finished running.
Returns
-------
system : :class:`System <BioSimSpace._SireWrappers.System>`
The latest molecular system. | 625941bc91af0d3eaac9b8e7 |
def next(self): <NEW_LINE> <INDENT> self.current_position += self.current_batch_size <NEW_LINE> if self.no_batch_left(): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if self.current_position + self.minibatch_size <= self.total(): <NEW_LINE> <INDENT> self.current_batch_size = self.minibatch_size <NEW_LINE> <DEDEN... | Move to the next batch. | 625941bc97e22403b379ce6a |
def truez(p,t,w): <NEW_LINE> <INDENT> r0m = 287.04 <NEW_LINE> g = 9.80616 <NEW_LINE> ratio = 0.621971 <NEW_LINE> arg = (r0m/g)*(t/p)*(1.0+(1.0/ratio-1.0)*w/1000.0) <NEW_LINE> deltap = num.diff(p) <NEW_LINE> deltap = num.append(deltap,num.zeros(1)) <NEW_LINE> arg = arg*deltap <NEW_LINE> z = -arg.cumsum() <NEW_LINE> retu... | z = truez(p,t,w)
compute true citation altitudes using the hydrostatic equation
inputs:
p pressure in mbar
t air temperature in K
w water vapor mixing ratio in g/kg
| 625941bc851cf427c661a3e4 |
def _setup_annotation_colors(params): <NEW_LINE> <INDENT> raw = params['raw'] <NEW_LINE> segment_colors = params.get('segment_colors', dict()) <NEW_LINE> if raw.annotations is not None: <NEW_LINE> <INDENT> ann_order = raw.annotations.onset.argsort(axis=0) <NEW_LINE> descriptions = raw.annotations.description[ann_order]... | Set up colors for annotations. | 625941bcd8ef3951e324340f |
def set_vibration(self, left=0, right=0, vibration_time=1): <NEW_LINE> <INDENT> self.left_vibration, self.right_vibration = min(int(left), 255), min(int(right), 255) <NEW_LINE> self.vibration_time = min(int(vibration_time), 200) | Set the level of vibration on the corresponding oculus touch for the specified number of iterations/time.
The level of vibration of each controller is between 0 and 255. | 625941bc7d43ff24873a2b6f |
def list_upcoming_birthdays(self): <NEW_LINE> <INDENT> status = True <NEW_LINE> query = 'select INDI, NAME, BIRT from indi where DEAT == "NA"' <NEW_LINE> thirty_days = relativedelta(days=30) <NEW_LINE> people = self.tool.query_info(query) <NEW_LINE> for person in people: <NEW_LINE> <INDENT> if self.tool.dates_within(st... | Author Youhao
US38 List all living people in a GEDCOM file whose birthdays occur in the next 30 days
:return:bool | 625941bc45492302aab5e192 |
def compare_password(self, password): <NEW_LINE> <INDENT> encodedpassword = password.encode('utf-8') <NEW_LINE> return bcrypt.hashpw(encodedpassword, self.get('password')) == self.get('password') | ' PURPOSE
' Given a password, compare it to the saved password.
' PARAMETERS
' <str password>
' RETURNS
' <bool is_same> True if passwords match, False if not. | 625941bcd4950a0f3b08c223 |
def build_latex(): <NEW_LINE> <INDENT> global args <NEW_LINE> latex = args.build_type+'latex' if args.build_type!='dvi' else 'latex' <NEW_LINE> if in_path(latex): <NEW_LINE> <INDENT> aux_fname = '%s.aux' % args.base_name <NEW_LINE> aux_hash = hash_file(aux_fname) <NEW_LINE> for i in range(5): <NEW_LINE> <INDENT> if sys... | Run *latex/bibtex until .aux file no longer changes (max 5 times). | 625941bc16aa5153ce36234a |
def permute(listPerm): <NEW_LINE> <INDENT> np = [] <NEW_LINE> for i in range(0,len(listPerm)): <NEW_LINE> <INDENT> for p in range (i, len(listPerm)): <NEW_LINE> <INDENT> if i != p: <NEW_LINE> <INDENT> np.append((listPerm[i], listPerm[p])) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return np | Return all possible and different permutations of a list | 625941bc92d797404e30405b |
def __init__(self, pooling_type, n_dim, *args, **kwargs): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> pool_cls = getattr(torch.nn, "%sPool%dd" % (pooling_type, n_dim)) <NEW_LINE> self.pool = pool_cls(*args, **kwargs) | Parameters
----------
pooling_type : str
Type of Pooling, case sensitive.
Supported values are
* ``Max``
* ``Avg``
* ``AdaptiveAvg``
* ``AdaptiveMax``
n_dim : int
number of dimensions
*args :
positional arguments of the chosen pooling class
**kwargs :
keyword argu... | 625941bcf8510a7c17cf95cc |
@csrf_exempt <NEW_LINE> @api_view(['GET']) <NEW_LINE> @authentication_classes((TokenAuthentication, BasicAuthentication, SessionAuthentication)) <NEW_LINE> @permission_classes((IsAuthenticated,)) <NEW_LINE> def do_working_dir_dir_json(request, uid): <NEW_LINE> <INDENT> return directory_json(request, "work", uid) | get: List directory content as JSON (working area)
List directory content as JSON | 625941bc66656f66f7cbc07c |
def get_num_outputs(self): <NEW_LINE> <INDENT> if self.hide_acc_from_interface: <NEW_LINE> <INDENT> return 2 * self.n_task_dims <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return 3 * self.n_task_dims | Get number of environment outputs.
Returns
----------
n : int
number of environment outputs | 625941bc07d97122c4178757 |
def create_formatter(axis_naming, axis_title, column_list): <NEW_LINE> <INDENT> return html.Details( id='{}-formatting'.format(axis_naming), children=[ html.Summary( '{} Formatting'.format(axis_title), style={ 'font-size': '14px', 'color': '#444', 'padding': '0px 0px 0px 5px' } ), html.Div( [ html.Div( Dropdown( placeh... | Return collapsable formatting div | 625941bc4d74a7450ccd4094 |
def do_health_checks(self, list_of_ips): <NEW_LINE> <INDENT> threads = [] <NEW_LINE> results = [] <NEW_LINE> for count, ip in enumerate(list_of_ips): <NEW_LINE> <INDENT> thread = threading.Thread( target = self._do_tcp_check, name = "%s:%s" % (self.thread_name, ip), args = (ip, results)) <NEW_LINE> thread.start() <... | Perform a health check on a list of IP addresses.
Each check (we use a TCP connection attempt) is run in its own thread.
Gather up the results and return the list of those addresses that
failed the test and the list of questionable IPs.
TODO: Currently, this starts a thread for every single address we want
to check.... | 625941bccc40096d61595824 |
def _set_color(self, ida_color=None, qt_color=None): <NEW_LINE> <INDENT> if ida_color is not None: <NEW_LINE> <INDENT> r = ida_color & 255 <NEW_LINE> g = (ida_color >> 8) & 255 <NEW_LINE> b = (ida_color >> 16) & 255 <NEW_LINE> <DEDENT> if qt_color is not None: <NEW_LINE> <INDENT> r = (qt_color >> 16) & 255 <NEW_LINE> g... | Sets the color of the user color button. | 625941bc596a89723608999c |
def remove_percona_repository(host, repo_file): <NEW_LINE> <INDENT> with host.sudo("root"): <NEW_LINE> <INDENT> cmd = "sudo rm -f {}".format(repo_file) <NEW_LINE> result = host.run(cmd) <NEW_LINE> assert result.rc == 0, result.stderr | Delete repository file
| 625941bc9f2886367277a762 |
def get_ids_and_tickers(conn): <NEW_LINE> <INDENT> cur = conn.cursor() <NEW_LINE> cur.execute('SELECT id, ticker FROM symbol') <NEW_LINE> rows = cur.fetchall() <NEW_LINE> cur.close() <NEW_LINE> return [(row[0], row[1]) for row in rows] | Retrieves list of ids and corresponding ticker for all symbols in the
symbol table.
Returns:
list: [(id, ticker) for every ticker found in the database] | 625941bc187af65679ca4fef |
def run(self): <NEW_LINE> <INDENT> def wrapper(): <NEW_LINE> <INDENT> self.logger.info('Waiting for messages...') <NEW_LINE> self._channel.start_consuming() <NEW_LINE> <DEDENT> return wrapper | Start the AMQP consumer. | 625941bcc4546d3d9de72903 |
def generate_sql_verification_data(sql_results_instance): <NEW_LINE> <INDENT> results_string = "" <NEW_LINE> all_rows = sql_results_instance["ResultSet"]["Rows"] <NEW_LINE> for row_index in range(1, len(all_rows)): <NEW_LINE> <INDENT> results_string += f"{generate_sql_verification_data_row(all_rows[row_index])}" <NEW_L... | Generates the verification text for a given result sql.
Keyword arguments:
sql_results_instance -- the sql results returned from athena
show_columns -- boolean for whether to show column names or not in the results | 625941bc293b9510aa2c316a |
def __init__(self, text="", elements=None, normal_params=None, press_params=None, value=False, namestyle=None, type_="checkbox", check_img=None): <NEW_LINE> <INDENT> namestyle=style.STYLE_INSERTER_NAME if namestyle is None else namestyle <NEW_LINE> super(Checker, self).__init__("", elements, normal_params, press_params... | Checkable check or radio box.
<text>: text before the box.
<value>: True for checked, False for not checked.
<type_>: can be either 'checkbox' or 'radio'.
<check_img>: if not None, define the image used for the box. | 625941bc56ac1b37e62640a7 |
def getTagName(self): <NEW_LINE> <INDENT> return self._tagName | Return the tag name for this Element.
Parameters:
self: This object.
Return value:
String containing the tag name for this Element.
Description:
Return the tag name for this Element as a string. | 625941bc56b00c62f0f14529 |
def get_dateformat(self): <NEW_LINE> <INDENT> return _DATE_FORMAT_RE | Returns the dateformat. | 625941bc4f6381625f11490f |
def test_remove_cart(): <NEW_LINE> <INDENT> cafe.cart = {'pop-tarts': 1} <NEW_LINE> cafe.remove_cart('pop-tarts') <NEW_LINE> assert 'pop-tarts' not in cafe.cart | Tests that if one of an item is in the cart, it is completely removed | 625941bc1f5feb6acb0c4a26 |
def _passes_reverse_restriction(): <NEW_LINE> <INDENT> if test.get_function_object() in ParallelProcessor.__REVERSE_PARALLEL_RESTRICTIONS: <NEW_LINE> <INDENT> reverse_tests = ParallelProcessor.__REVERSE_PARALLEL_RESTRICTIONS[test.get_function_object()] <NEW_LINE> for class_object, suite_mapping in list(ParallelProcesso... | If current suite is part of parallel restriction in another suite which is currently active, can't run it.
:return: BOOLEAN | 625941bc8a349b6b435e8045 |
def setup_model(**config): <NEW_LINE> <INDENT> engine = engine_from_config(config) <NEW_LINE> session = scoped_session(sessionmaker(bind=engine, extension=ZopeTransactionExtension())) <NEW_LINE> init_model(session) <NEW_LINE> create_tables() | sets up collection model according to configuration | 625941bccc0a2c11143dcd62 |
def rgetLambda(self): <NEW_LINE> <INDENT> return _core.CGPSumCache_rgetLambda(self) | rgetLambda(CGPSumCache self) -> MatrixXd &
Parameters:
self: limix::CGPSumCache * | 625941bc627d3e7fe0d68d20 |
def addPlot(self,tag,_type,colum,_db = None): <NEW_LINE> <INDENT> if colum not in self.to_draw : <NEW_LINE> <INDENT> self.to_draw[colum]=defaultdict(list) <NEW_LINE> <DEDENT> if _db : <NEW_LINE> <INDENT> self.to_draw[colum][tag].append([_db, _type, _db.getX(self.plotint), _db.getRecord(tag,_type,self.plotint)]) <NEW_LI... | tag = Reptag , _type = incell|outcell|other , _db = instance of DataManager | 625941bc4527f215b584c32d |
def _build_children(self): <NEW_LINE> <INDENT> if self._page: <NEW_LINE> <INDENT> children = {'page': self._page} <NEW_LINE> children.update(self._build_menus()) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> children = {} <NEW_LINE> <DEDENT> return children | Build the children for the layout based on the users permissions | 625941bc4f6381625f114910 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, PowerFormFormDataRecipient): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.to_dict() == other.to_dict() | Returns true if both objects are equal | 625941bc97e22403b379ce6b |
def connect(self, db): <NEW_LINE> <INDENT> counter = 0 <NEW_LINE> while not self.connected and not counter>20: <NEW_LINE> <INDENT> self.connected = False <NEW_LINE> try: <NEW_LINE> <INDENT> self.dbase = self.pool[db] <NEW_LINE> self.connected = True <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> l.log_exception('MyMon... | connect to mongodb | 625941bc10dbd63aa1bd2a7e |
def getIcon(self): <NEW_LINE> <INDENT> return ":/icons/Draft_Array" | Set the icon in the tree view. | 625941bcd99f1b3c44c67468 |
def rename(self, old_name, new_name, add_postfix_if_exists=True): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self._conn.rename(old_name, new_name) <NEW_LINE> <DEDENT> except ftplib.error_perm as e: <NEW_LINE> <INDENT> if 'existant' in e.message: <NEW_LINE> <INDENT> new_name = new_name.split('.') <NEW_LINE> new_name =... | rename / move a file | 625941bc8a43f66fc4b53f3b |
def max_stock_profit(trading_info): <NEW_LINE> <INDENT> best_profit = None <NEW_LINE> for price in range(len(trading_info)-1): <NEW_LINE> <INDENT> potential = - trading_info[price] + max(trading_info[price+1:]) <NEW_LINE> if best_profit == None or potential > best_profit: <NEW_LINE> <INDENT> best_profit = potential <NE... | given list of trading values where indices are minutes
past opening time and values is stock price, determine
when best time is to buy and sell. Must sell after buy. | 625941bc3317a56b86939b3b |
def mergeKLists(self, lists): <NEW_LINE> <INDENT> if len(lists) == 0 or (lists[0] is None and len(lists) <= 1): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> n = len(lists) <NEW_LINE> dummy = ListNode() <NEW_LINE> tuplelist = [(lists[i].val, lists[i]) for i in range(n) if lists[i]] <NEW_LINE> print(tuplelist) <NE... | :type lists: List[ListNode]
:rtype: ListNode
合并 k 个排序链表,返回合并后的排序链表。请分析和描述算法的复杂度。
[ 1->4->5,
1->3->4,
2->6 ] | 625941bc925a0f43d2549d46 |
def usart_set_parity(): <NEW_LINE> <INDENT> pass | __NATIVE__
PmReturn_t retval = PM_RET_OK;
pPmObj_t p0, p1;
uint32_t usart;
uint32_t parity;
/* If wrong number of args, raise TypeError */
if (NATIVE_GET_NUM_ARGS() != 2)
{
PM_RAISE_WITH_INFO(retval, PM_RET_EX_TYPE, "incorrect number of arguments");
return retval;
}
p0 = NATIVE_GET_LOCAL(0);
/* If arg is not... | 625941bcd6c5a10208143f1a |
def warning(self, message): <NEW_LINE> <INDENT> self.messageLevel = WARNING <NEW_LINE> self.logger.warning(message) | Log a message with level warning. | 625941bc3346ee7daa2b2c3c |
def __add_encryptednumber(self, other: '__class__') -> '__class__': <NEW_LINE> <INDENT> if self.public_key != other.public_key: <NEW_LINE> <INDENT> raise ValueError("add two numbers have different public key!") <NEW_LINE> <DEDENT> x, y = self.__align_exponent(self, other) <NEW_LINE> encryptednumber = self.__raw_add(x.c... | return PaillierEncryptedNumber: z = E(x) + E(y)
| 625941bc66656f66f7cbc07d |
def is_legal(self, x, y): <NEW_LINE> <INDENT> return (0 <= x < self.xsize) and (0 <= y < self.ysize) | Returns true if the x,y coordinates are legal for this board. | 625941bc7d847024c06be18c |
def restart_server(): <NEW_LINE> <INDENT> run('cd %(path)s/releases/current; %(path)s/releases/current/site-restart' % env) <NEW_LINE> sudo('/etc/init.d/nginx restart') | Restart the web server | 625941bc21a7993f00bc7bbe |
def lookup1(required, provided, name=u'', default=None): <NEW_LINE> <INDENT> pass | Lookup a value using a single required interface
A value is looked up based on a single required
specifications, a provided interface, and a name, which must be
text. | 625941bcd7e4931a7ee9ddef |
def _get_root_dn(self): <NEW_LINE> <INDENT> return desktop.conf.LDAP.BASE_DN.get() | Returns the configured base DN (DC=desktop,DC=local). | 625941bc656771135c3eb73f |
@task(publish_linux) <NEW_LINE> def install_linux(c): <NEW_LINE> <INDENT> c.run('cp bin/Release/net6.0/linux-x64/publish/jpackages /home/itang/.local/bin/jpackages') | install for linux | 625941bc379a373c97cfaa1d |
def get_text_field_value(self): <NEW_LINE> <INDENT> return self.text_field_web_element.get_attribute("value") | Returns the value of the text field. | 625941bc2eb69b55b151c77e |
def newton_method(x_train, y_train, max_epoch=10000, epsilon=1e-4, _lambda=0.0): <NEW_LINE> <INDENT> order = np.shape(x_train)[1] - 1 <NEW_LINE> w = np.random.normal(0, 0.01, size=order + 1) <NEW_LINE> w = np.mat(w).T <NEW_LINE> for epoch in range(max_epoch): <NEW_LINE> <INDENT> loss0 = get_loss(w, x_train, y_train, _l... | 牛顿法求解
:param x_train: 训练集的x, 矩阵, 每行形如 [1, x, x^2, ... x^n]
:param y_train: 训练集的y, 列向量
:param max_epoch: 最大迭代轮数,若到达该轮还未到达min_loss, 返回
:param epsilon: 精度阈值
:param _lambda: 正则项的lambda系数, 默认不含正则项
:return: 返回求解得带的参数w, 列向量 | 625941bc1f037a2d8b9460d2 |
def detect(self, img, degree=DEFAULT_DEGREE, debug=False, min_size=150): <NEW_LINE> <INDENT> image_list = self.rotate_image(img, degree) <NEW_LINE> detected_pols = [] <NEW_LINE> for image, rotation_matrix in image_list: <NEW_LINE> <INDENT> detected_rectangles, w = self.hog.detectMultiScale(image, winStride=(8, 8), padd... | Detect people in the image.
:param debug: show each rotated image and press to continue
:param img: source image
:param degree: delta angle for rotations.
:param min_size: minimum height in pixels for a person | 625941bcd58c6744b4257b33 |
def handleKey(self, key): <NEW_LINE> <INDENT> return False | Handler for user input. This returns true if the key press was consumed,
false otherwise.
Arguments:
key - keycode for the key pressed | 625941bc6e29344779a624e8 |
def verifyStatistic(statistic): <NEW_LINE> <INDENT> return statistic | if statistic is a statistic object, return same. else get statistic | 625941bcb5575c28eb68ded1 |
def set_option(self, name, value): <NEW_LINE> <INDENT> if name not in self.settable: <NEW_LINE> <INDENT> raise SCons.Errors.UserError("This option is not settable from a SConscript file: %s"%name) <NEW_LINE> <DEDENT> if name == 'num_jobs': <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> value = int(value) <NEW_LINE> if va... | Sets an option from an SConscript file. | 625941bcd4950a0f3b08c224 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.