code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def plot_bar(data, fig_prefix): <NEW_LINE> <INDENT> n_row, n_col = np.shape(data) <NEW_LINE> ind = np.arange(n_col/2) <NEW_LINE> w = 0.35 <NEW_LINE> mean_data = np.average(data, axis=0) <NEW_LINE> stdev_data = np.std(data, axis=0) <NEW_LINE> fig = plt.figure(figsize=(4, 4)) <NEW_LINE> left, width = 0.2, 0.7 <NEW_LINE> ... | Plot the data as a grouped bar graph
:param data: input data
:param fig_prefix: output figure prefix
:return: | 625941c77b25080760e394a8 |
def is_enabled(): <NEW_LINE> <INDENT> return _ENABLED | Returns True if covenant functionality is enabled | 625941c79f2886367277a8dc |
def variance(f, contributors, method="Default"): <NEW_LINE> <INDENT> P = f["P"][:] <NEW_LINE> nmodes = P.shape[0] <NEW_LINE> swap = np.arange(nmodes) - 2 <NEW_LINE> swap[0:2] = [nmodes - 2, nmodes - 1] <NEW_LINE> if (method == "Default"): <NEW_LINE> <INDENT> err = f[contributors[0]][:] * 0. <NEW_LINE> for c in contribu... | Return the error variance of specified contributors
params:
f : (h5py.File) : roket hdf5 file opened with h5py
contributors : (list of string) : list of the contributors
method : (optional, default="Default") : if "Independence", the
function returns ths sum of the contributors variances.
... | 625941c7187af65679ca516d |
def check_output(cmd): <NEW_LINE> <INDENT> popen = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) <NEW_LINE> out = popen.communicate()[0].strip() <NEW_LINE> if not isinstance(out, str): <NEW_LINE> <INDENT> out = out.decode(sys.stdout.encoding) <NEW_LINE> <DEDENT> return out | Version of check_output which does not throw error | 625941c77c178a314d6ef4ad |
@pytest.fixture(scope="session") <NEW_LINE> def environment_info(): <NEW_LINE> <INDENT> environment_params = {} <NEW_LINE> for a in os.environ: <NEW_LINE> <INDENT> environment_params.update({a: os.getenv(a)}) <NEW_LINE> <DEDENT> return environment_params | Fixture for environment_info | 625941c74f88993c3716c0b7 |
def filtre(predicat, xs): <NEW_LINE> <INDENT> return 0 | Renvoie la liste des éléments de xs qui vérifient le prédicat
>>> filtre(lambda x : x >= 3, [1, 2, 3, 4])
[3, 4] | 625941c776d4e153a657eb7f |
def remove_payment_line(self, reason, payment_situation): <NEW_LINE> <INDENT> self.payment_line_ids.unlink() <NEW_LINE> self.payment_situation = payment_situation <NEW_LINE> self.cnab_state = "done" <NEW_LINE> self.invoice_id.message_post(body=_(reason)) | Remove a Linha de Pagamento
:param reason:
:param payment_situation:
:return: | 625941c7c4546d3d9de72a82 |
def redirect_filename(project, filename=None): <NEW_LINE> <INDENT> protocol = "http" <NEW_LINE> if filename.startswith(protocol): <NEW_LINE> <INDENT> return filename <NEW_LINE> <DEDENT> version = project.get_default_version() <NEW_LINE> lang = project.language <NEW_LINE> use_subdomain = getattr(settings, 'USE_SUBDOMAIN... | Return a url for a page. Always use http for now,
to avoid content warnings. | 625941c732920d7e50b2821e |
def get_keys_to_reserve(self): <NEW_LINE> <INDENT> return [] | Returns keys with ids in their paths to be reserved.
Returns:
A list of keys used to advance the id sequences associated with
each id to prevent collisions with future ids. | 625941c7e8904600ed9f1f7a |
def product_groups_id_replace_post(self, id, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('callback'): <NEW_LINE> <INDENT> return self.product_groups_id_replace_post_with_http_info(id, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.product_groups... | Replace attributes for a model instance and persist it into the data source.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>... | 625941c73c8af77a43ae37ee |
def takeAsproFull(self, posArena): <NEW_LINE> <INDENT> chipOnPos = self.getTile(posArena).chip <NEW_LINE> if isinstance(chipOnPos, ChipAsproFull): <NEW_LINE> <INDENT> self.zapOnePos(posArena, ZAP_PATH, 1) <NEW_LINE> self.hasTakenAsproFull = True <NEW_LINE> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> retur... | zob | 625941c7d99f1b3c44c675df |
def from_vector(self, vector, order=None, coerce=True): <NEW_LINE> <INDENT> if order is None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> order = sorted(self.basis().keys()) <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDENT> order = range(self.dimension()) <NEW_LINE> <DEDENT> <DEDENT> if not coerce or vect... | Build an element of ``self`` from a vector.
EXAMPLES::
sage: p_mult = matrix([[0,0,0],[0,0,-1],[0,0,0]])
sage: q_mult = matrix([[0,0,1],[0,0,0],[0,0,0]])
sage: A = algebras.FiniteDimensional(QQ, [p_mult, q_mult, matrix(QQ,3,3)],
....: 'p,q,z')
sage: A.from_vector(vec... | 625941c74d74a7450ccd4213 |
def as_text(self, flags=0): <NEW_LINE> <INDENT> buf = BIO.MemoryBuffer() <NEW_LINE> m2.asn1_string_print_ex(buf.bio_ptr(), self.asn1str, flags) <NEW_LINE> return util.py3str(buf.read_all()) | Output an ASN1_STRING structure according to the set flags.
:param flags: determine the format of the output by using
predetermined constants, see ASN1_STRING_print_ex(3)
manpage for their meaning.
:return: output an ASN1_STRING structure. | 625941c776e4537e8c3516c1 |
def delete_cgsnapshot(self, context, cgsnapshot, snapshots): <NEW_LINE> <INDENT> cgsnap_name = self._get_3par_snap_name(cgsnapshot.id) <NEW_LINE> snapshot_model_updates = [] <NEW_LINE> for i, snapshot in enumerate(snapshots): <NEW_LINE> <INDENT> snapshot_update = {'id': snapshot['id']} <NEW_LINE> try: <NEW_LINE> <INDEN... | Deletes a cgsnapshot. | 625941c7046cf37aa974cd98 |
def competing_needs_mutex(self, node_a1: PgNode_a, node_a2: PgNode_a) -> bool: <NEW_LINE> <INDENT> for parent_a1 in node_a1.parents: <NEW_LINE> <INDENT> for parent_a2 in node_a2.parents: <NEW_LINE> <INDENT> if parent_a1.is_mutex(parent_a2): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return Fa... | Test a pair of actions for mutual exclusion, returning True if one of
the precondition of one action is mutex with a precondition of the
other action.
:param node_a1: PgNode_a
:param node_a2: PgNode_a
:return: bool | 625941c7e64d504609d7488f |
def _validate_name(name): <NEW_LINE> <INDENT> if name is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if not all([name[0].isalnum(), name[-1].isalnum()]): <NEW_LINE> <INDENT> raise ValueError("Bucket names must start and end with a number or letter.") <NEW_LINE> <DEDENT> return name | Pre-flight ``Bucket`` name validation.
:type name: str or :data:`NoneType`
:param name: Proposed bucket name.
:rtype: str or :data:`NoneType`
:returns: ``name`` if valid. | 625941c71d351010ab855b6b |
def __init__(self, twitterApi, since_id=None, status_file='state'): <NEW_LINE> <INDENT> self.twitterApi = twitterApi <NEW_LINE> self.since_id = since_id <NEW_LINE> self.status_file = status_file <NEW_LINE> self.status = dict() <NEW_LINE> if self.since_id is None and self.status_file is not None: <NEW_LINE> <INDENT> wit... | Create a new mentions instance, using the specified twitter API.
If since_id is not None, it will only evaluate mentions after that ID.
If status_file is specified, it will retrieve the since_id from it
and update it while progressing. | 625941c7ab23a570cc2501d1 |
def rightSideView(self, root): <NEW_LINE> <INDENT> if not root: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> ans = [] <NEW_LINE> self.bfs(root, ans) <NEW_LINE> return ans | :type root: TreeNode
:rtype: List[int] | 625941c76fece00bbac2d78c |
def p_expr2(p): <NEW_LINE> <INDENT> if p[2] == "." and isinstance(p[3],node.expr) and p[3].op=="parens": <NEW_LINE> <INDENT> p[0] = node.getfield(p[1],p[3].args[0]) <NEW_LINE> <DEDENT> elif p[2] == ":" and isinstance(p[1],node.expr) and p[1].op==":": <NEW_LINE> <INDENT> p[0] = p[1] <NEW_LINE> p[0].args.insert(1,p[3]) <... | expr2 : expr AND expr
| expr ANDAND expr
| expr BACKSLASH expr
| expr COLON expr
| expr DIV expr
| expr DOT expr
| expr DOTDIV expr
| expr DOTEXP expr
| expr DOTMUL expr
| expr EQ expr
| expr EXP expr
| expr GE expr
| expr GT expr
| expr LE expr
| expr LT expr
| expr MINUS expr
| expr MUL expr
| expr NE expr
| expr OR... | 625941c7435de62698dfdc9c |
def save(self, cwd): <NEW_LINE> <INDENT> return _normalize( tkFileDialog.asksaveasfilename( initialdir=cwd, filetypes=[self.FILTER_XLS], defaultextension=self.FILTER_XLS[1] ) ) | Open "save as" dialog with .xls file filter. | 625941c71f037a2d8b94624d |
def test_main(): <NEW_LINE> <INDENT> numbers1 = [6, 15] <NEW_LINE> numbers2 = [7, 17] <NEW_LINE> numbers3 = [0, 16] <NEW_LINE> numbers4 = [7, 100] <NEW_LINE> numbers5 = [30, 80] <NEW_LINE> numbers6 = [1, 5] <NEW_LINE> eq_(main.find_squares(numbers1), 1) <NEW_LINE> eq_(main.find_squares(numbers2), 2) <NEW_LINE> eq_(main... | test for main function | 625941c77b25080760e394a9 |
def remove_projection_from_vector(v: Vector, w: Vector) -> Vector: <NEW_LINE> <INDENT> return subtract(v, project(v, w)) | projects v onto w and subtracts the result from v | 625941c791af0d3eaac9ba67 |
def setType(self, type): <NEW_LINE> <INDENT> self._type = type | Sets type of connection.
The type argument is a string of capitalized letters and should be one of the available types described in the class documentation. | 625941c7cc40096d615959a0 |
def create_ngon(context, n, cx, cy, r, fill="#FFFFFF", width=1, outline="#000000", angle=0): <NEW_LINE> <INDENT> pts = [] <NEW_LINE> circle = 2 * math.PI <NEW_LINE> innerAngle = circle / n <NEW_LINE> angle += math.PI/2 <NEW_LINE> for point in range(n): <NEW_LINE> <INDENT> a = angle + innerAngle * point <NEW_LINE> x, y ... | regular ngon centered at (cx, cy) with radius r | 625941c726068e7796caed2c |
@app.route('/update_downstream', methods=['GET']) <NEW_LINE> def update_downstream(): <NEW_LINE> <INDENT> json_data = request.json <NEW_LINE> updated_source_broker = json_data['update_source_broker'] <NEW_LINE> updated_topic = json_data['source_topic'] <NEW_LINE> shelf = db_handler.get_db('jobs.db') <NEW_LINE> for job ... | Downstream Agents to update their upstream address accordingly | 625941c78c3a873295158409 |
def read(self, group, quantities='all'): <NEW_LINE> <INDENT> self.read_geometry(group['Geometry']) <NEW_LINE> self.read_quantities(group['Quantities'], quantities=quantities) <NEW_LINE> self._check_array_dimensions() | Read the geometry and physical quantities from an AMR grid
Parameters
----------
group : h5py.Group
The HDF5 group to read the grid from. This group should contain
groups named 'Geometry' and 'Quantities'.
quantities : 'all' or list
Which physical quantities to read in. Use 'all' to read in all
quantit... | 625941c7656771135c3eb8bd |
def get_camera_url(self): <NEW_LINE> <INDENT> return self._url + '/camera' | URL of the camera image. | 625941c767a9b606de4a7f0a |
@pytest.fixture <NEW_LINE> def non_mapping_dict_subclass(): <NEW_LINE> <INDENT> class TestNonDictMapping(abc.Mapping): <NEW_LINE> <INDENT> def __init__(self, underlying_dict): <NEW_LINE> <INDENT> self._data = underlying_dict <NEW_LINE> <DEDENT> def __getitem__(self, key): <NEW_LINE> <INDENT> return self._data.__getitem... | Fixture for a non-mapping dictionary subclass. | 625941c794891a1f4081baf8 |
def _preprocess_imgs(self, img_names): <NEW_LINE> <INDENT> images = [] <NEW_LINE> for i, img_name in enumerate(img_names): <NEW_LINE> <INDENT> path = join(self.img_dir, img_name) <NEW_LINE> try: <NEW_LINE> <INDENT> img = imresize(imread(path), (299,299)).astype(np.float32) <NEW_LINE> img = preprocess_input(img) <NEW_LI... | Preprocess images for InceptionV3 | 625941c7293b9510aa2c32e7 |
def parse(self, stream, *args, **kwargs): <NEW_LINE> <INDENT> self._parse(stream, False, None, *args, **kwargs) <NEW_LINE> return self.tree.getDocument() | Parse a HTML document into a well-formed tree
:arg stream: a file-like object or string containing the HTML to be parsed
The optional encoding parameter must be a string that indicates
the encoding. If specified, that encoding will be used,
regardless of any BOM or later declaration (such as in a meta
... | 625941c744b2445a339320e6 |
def getMethodDoc(self, name): <NEW_LINE> <INDENT> return self._client.service.getMethodDoc(name) | Gets online documentation for method. | 625941c756ac1b37e6264220 |
def _symlink_check(name, target, force, user, group): <NEW_LINE> <INDENT> if not os.path.exists(name) and not __salt__['file.is_link'](name): <NEW_LINE> <INDENT> return None, 'Symlink {0} to {1} is set for creation'.format( name, target ) <NEW_LINE> <DEDENT> if __salt__['file.is_link'](name): <NEW_LINE> <INDENT> if __s... | Check the symlink function | 625941c7de87d2750b85fde1 |
def __ensure_resource_is_missing(self, stack_arn, resource): <NEW_LINE> <INDENT> found = True <NEW_LINE> try: <NEW_LINE> <INDENT> resource_arn = self.get_stack_resource_arn(stack_arn, resource) <NEW_LINE> if resource_arn is None: <NEW_LINE> <INDENT> found = False <NEW_LINE> <DEDENT> <DEDENT> except AssertionError: <NEW... | Ensure that no valid resource ARN exists for project | 625941c7d164cc6175782d9d |
def generate_policy_exploitation(my_history, opponent_history, my_form_last_time, opponent_form_last_time): <NEW_LINE> <INDENT> return {"rock": 0.333, "scissor": 0.333, "paper": 0.334} | You must fill here | 625941c7bf627c535bc1321e |
def iterate_regions(self, image): <NEW_LINE> <INDENT> h, w = image.shape <NEW_LINE> for i in range(h - 2): <NEW_LINE> <INDENT> for j in range(w - 2): <NEW_LINE> <INDENT> image_region = image[i:(i + 3), j:(j + 3)] <NEW_LINE> yield image_region, i , j | Generates all possible 3x3 image regions using valid padding
- image is 2d numpy array | 625941c745492302aab5e312 |
def handle_response(response_dict, reply_key): <NEW_LINE> <INDENT> if not response_dict: <NEW_LINE> <INDENT> raise PapiException(-1, 'invalid response received') <NEW_LINE> <DEDENT> status_code = response_dict['s'] <NEW_LINE> if status_code == 0: <NEW_LINE> <INDENT> result_code = response_dict['r'] <NEW_LINE> if result... | Process a response from the Taranos Server.
:param response_dict: Response dict from the server
:param reply_key: Expected reply key
:return: Contents of the response dict indexed by the specified reply key
:raise PapiException: | 625941c7aad79263cf390a8f |
def rr_decoder(counts_rr, epsilon, n, normalization = 0): <NEW_LINE> <INDENT> k = len(counts_rr) <NEW_LINE> p_rr = decode_counts(counts_rr, epsilon, n, k) <NEW_LINE> if normalization == 0: <NEW_LINE> <INDENT> p_rr = probability_normalize(p_rr) <NEW_LINE> <DEDENT> if normalization == 1: <NEW_LINE> <INDENT> p_rr = projec... | Decodes RR encoded samples using a normalized standard decoder.
Args:
counts_rr: A 1-d numpy array containing the counts under RR.
epsilon: The differential privacy level.
n: The number of samples. | 625941c782261d6c526ab4ed |
def dict2file(d, nameoffile='dict.txt', sorted=True): <NEW_LINE> <INDENT> def list2dict(li): <NEW_LINE> <INDENT> x = {} <NEW_LINE> for (i, el) in enumerate(li): <NEW_LINE> <INDENT> x[i] = el <NEW_LINE> <DEDENT> return x <NEW_LINE> <DEDENT> if not isinstance(d, dict): <NEW_LINE> <INDENT> d = list2dict(d) <NEW_LINE> <DED... | Write dictionary (or list or tuple) to a textfile.
Sorted by keys, if sorted=True. | 625941c7a8370b77170528f0 |
def get_noncutters(self, htmldoc): <NEW_LINE> <INDENT> bolds = htmldoc.find_all('b') <NEW_LINE> noncutters = [elem for elem in bolds if "Noncutters:" in elem.text] <NEW_LINE> if noncutters: <NEW_LINE> <INDENT> return [enz.strip() for enz in noncutters[0].text.split(',').replace('Noncutters:', '')] | Return a list of non-cutting enzymes from the htmldoc. | 625941c7167d2b6e31218be5 |
def find_all_alive(self) -> int: <NEW_LINE> <INDENT> alive_cells = 0 <NEW_LINE> for x in range(self._column): <NEW_LINE> <INDENT> for y in range(self._row): <NEW_LINE> <INDENT> if self._grid[x][y].is_alive(): <NEW_LINE> <INDENT> alive_cells += 1 <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return alive_cells | Return all alive cells | 625941c730dc7b76659019b7 |
def forward(self, x): <NEW_LINE> <INDENT> self.node_list = [] <NEW_LINE> self.h = torch.zeros(1, 1, self.embed_size).cuda() <NEW_LINE> self.c = torch.zeros(1, 1, self.embed_size).cuda() <NEW_LINE> root_node = self.walk_tree(x.root) <NEW_LINE> all_nodes = torch.cat(self.node_list) <NEW_LINE> return all_nodes | Forward function accepts input data and returns a Variable of output data | 625941c7097d151d1a222eaa |
def set_sensor_satellite_level(self): <NEW_LINE> <INDENT> self.sensor_altitude = None <NEW_LINE> self.sensor_alt_pres = -1000 | Set the sensor altitude to be satellite level. | 625941c707d97122c41788d9 |
def read_state(workdir: pathlib.Path) -> Dict[str, pathlib.Path]: <NEW_LINE> <INDENT> state_dir = workdir / STATE_DIR <NEW_LINE> files = [pathlib.Path(name).name for name in state_dir.glob("*.state")] <NEW_LINE> state = {} <NEW_LINE> for file in files: <NEW_LINE> <INDENT> state[pathlib.Path(file).with_suffix(".gz").nam... | Generates pairs file.gz : path / to / state_file.state
:param workdir:
:return: | 625941c750485f2cf553cde9 |
def _content_path_to_yaml(path, root_path, split_char="_", add_titles=True): <NEW_LINE> <INDENT> path = path.with_suffix("") <NEW_LINE> if path.name == "index": <NEW_LINE> <INDENT> title = _filename_to_title(path.resolve().parent.name, split_char=split_char) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> title = _filena... | Return a YAML entry for the TOC from a path. | 625941c7167d2b6e31218be6 |
def set_verbose(verbose): <NEW_LINE> <INDENT> Global.verbose_enabled = verbose | Enable or disable verbose messages. Increases the number of INFO messages. | 625941c7a8ecb033257d311d |
def addTwoNumbers(self, l1, l2): <NEW_LINE> <INDENT> re = ListNode(0) <NEW_LINE> r = re <NEW_LINE> carry = 0 <NEW_LINE> while (l1 or l2): <NEW_LINE> <INDENT> x = l1.val if l1 else 0 <NEW_LINE> y = l2.val if l2 else 0 <NEW_LINE> s = carry + x + y <NEW_LINE> carry = int(s / 10) <NEW_LINE> r.next = ListNode(s % 10) <NEW_L... | :type l1: ListNode
:type l2: ListNode
:rtype: ListNode | 625941c723849d37ff7b30df |
def insert_docs(buf, iter, obj, bold_tag): <NEW_LINE> <INDENT> if is_data_object(obj): <NEW_LINE> <INDENT> obj = type(obj) <NEW_LINE> <DEDENT> name = getattr(obj, '__name__', None) <NEW_LINE> document = pydoc.text.document(obj, name) <NEW_LINE> pos = 0 <NEW_LINE> while True: <NEW_LINE> <INDENT> m = BOLD_RE.search(docum... | Insert documentation about obj into a gtk.TextBuffer
@param buf: the buffer to insert the documentation into
@param iter: the location to insert the documentation
@param obj: the object to get documentation about
@param bold_tag: the tag to use for bold text, such as headings | 625941c726238365f5f0eebc |
def compile_pillar(self, ext=True, pillar_dirs=None): <NEW_LINE> <INDENT> top, top_errors = self.get_top() <NEW_LINE> if ext: <NEW_LINE> <INDENT> if self.opts.get('ext_pillar_first', False): <NEW_LINE> <INDENT> self.opts['pillar'], errors = self.ext_pillar({}, pillar_dirs) <NEW_LINE> self.rend = salt.loader.render(self... | Render the pillar data and return | 625941c755399d3f05588703 |
def generate_shard_prune_playbook(migration): <NEW_LINE> <INDENT> full_plan = get_db_allocations(migration.target_couch_config) <NEW_LINE> shard_suffix_by_db = { db_name: shard_allocation_doc.usable_shard_suffix for db_name, shard_allocation_doc in full_plan.items() } <NEW_LINE> _, deletable_files_by_node = figure_out_... | Create a playbook for deleting unused files.
:returns: List of nodes that have files to remove | 625941c7fbf16365ca6f6212 |
def generate_samples(num_samp, num_point): <NEW_LINE> <INDENT> helix = [] <NEW_LINE> t_low = 0 <NEW_LINE> t_up = 2*np.pi <NEW_LINE> t = np.linspace(t_low, t_up, num_point) <NEW_LINE> label = np.random.uniform(low=0.4, high=0.8, size=(num_samp, 1)) <NEW_LINE> for i, a in enumerate(label): <NEW_LINE> <INDENT> x = a*np.co... | This function is used to generate circles with different radius
num_samp: the number of samples
num_point: the dimenson of hyperparameter | 625941c7be8e80087fb20c94 |
def correlation_output_formatter(bt, corr_coefs, pvals, fdr_pvals, bon_pvals, md_key): <NEW_LINE> <INDENT> header = [ 'OTU', 'Correlation Coef', 'pval', 'pval_fdr', 'pval_bon', md_key] <NEW_LINE> num_lines = len(corr_coefs) <NEW_LINE> lines = ['\t'.join(header)] <NEW_LINE> for i in range(num_lines): <NEW_LINE> <INDENT>... | Format the output of the correlations for easy writing.
| 625941c7ff9c53063f47c244 |
def augment_with_pretrained(dictionary, ext_emb_path, chars): <NEW_LINE> <INDENT> print('Loading pretrained embeddings from %s...' % ext_emb_path) <NEW_LINE> assert os.path.isfile(ext_emb_path) <NEW_LINE> pretrained = set([ line.rstrip().split()[0].strip() for line in codecs.open(ext_emb_path, 'r', 'utf-8') if len(ext_... | Augment the dictionary with words that have a pretrained embedding.
If `words` is None, we add every word that has a pretrained
to the dictionary, otherwise, we only add the words that are given by
`words` (typically the words in the development and test sets.) | 625941c72ae34c7f2600d181 |
def description(self): <NEW_LINE> <INDENT> return self._description | Return the description of this transaction
Returns:
str: Description of transaction | 625941c71f5feb6acb0c4ba2 |
def _write_cell(sheet, row_index, col_index, value, field_type): <NEW_LINE> <INDENT> cell = sheet.cell(row=row_index + 1, column=col_index + 1) <NEW_LINE> cell.value = value <NEW_LINE> if field_type is fields.PercentField: <NEW_LINE> <INDENT> cell.number_format = '0.00%' <NEW_LINE> <DEDENT> elif field_type is fields.Da... | Write a cell to the sheet, fixing value/formatting if needed | 625941c71f5feb6acb0c4ba1 |
def isAttributeImage(self, attributeName=None): <NEW_LINE> <INDENT> if None == attributeName: <NEW_LINE> <INDENT> raise FunctionArgumentException("Function isAttributeImage(attributeName) called without correct parameters.") <NEW_LINE> <DEDENT> if "jpegphoto" == attributeName.lower(): <NEW_LINE> <INDENT> return True <N... | Returns a boolean if a given attribute contains image data.
| 625941c7ad47b63b2c509fcf |
def compute_resource_check(self): <NEW_LINE> <INDENT> return | Check available resources (in case limits are set on the target VDC and/or account) to make sure
that this Compute instance can be deployed.
@return: True if enough resources, False otherwise.
@return: Dictionary of remaining resources estimation after the specified Compute instance would
have been deployed. | 625941c796565a6dacc8f71b |
def scatter_plot(prep_dataset): <NEW_LINE> <INDENT> sns.pairplot(prep_dataset, hue="Hogwarts House", markers = ".", size=2) <NEW_LINE> plt.show() | Pair plot on the remaining features of the training set
Input:
-prep_dataset (pd.dataframe) | 625941c71f037a2d8b94624e |
def segments(lst, num): <NEW_LINE> <INDENT> for i in range(0, len(lst), num): <NEW_LINE> <INDENT> yield lst[i:i + num] | Yields lst in segments of size num | 625941c7956e5f7376d70ebe |
def __init__(self, **kwargs): <NEW_LINE> <INDENT> self.dimming_duration = None <NEW_LINE> self.color = None <NEW_LINE> self.color_channels = None <NEW_LINE> super().__init__(**kwargs) | Initialize the mock zwave values. | 625941c723849d37ff7b30e0 |
def to_xml(self, parent): <NEW_LINE> <INDENT> element = et.SubElement(parent, "optimizer") <NEW_LINE> element.set("name", self.name) <NEW_LINE> element.set("learning_rate", fstr(self.learning_rate)) <NEW_LINE> if self.alpha is not None: <NEW_LINE> <INDENT> element.set("alpha", fstr(self.alpha)) <NEW_LINE> <DEDENT> if s... | Output the details of the optimizer as children of the parent node. | 625941c78da39b475bd64fc3 |
def gather_name_input(self, pass1_fname, nametaxa_fname): <NEW_LINE> <INDENT> recno = 0 <NEW_LINE> try: <NEW_LINE> <INDENT> self._log.info('Open initial pre-processed BISON output file {}' .format(pass1_fname)) <NEW_LINE> dreader, inf = get_csv_dict_reader(pass1_fname, BISON_DELIMITER, ENCODING) <NEW_LINE> nametaxa_lut... | Gather list of scientific names, with associated taxon keys to use
for input to GBIF parser to output accepted canonical names.
Args:
pass1_fname,
nametaxa_fname
Note:
Only used if the first processing step (transform_gbif_to_bison)
fails to collect names and taxon keys into a file. | 625941c7377c676e912721f9 |
def interpret(inp): <NEW_LINE> <INDENT> stack = [""] <NEW_LINE> for token in TOKEN_RE.split(inp): <NEW_LINE> <INDENT> if not token: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> func_call = FUNC_RE.match(token) <NEW_LINE> if func_call: <NEW_LINE> <INDENT> func_name = func_call.group(1).lower() <NEW_LINE> if func_nam... | Interpret an expression with SGR functions | 625941c7a05bb46b383ec872 |
def process_direct_payment(self, direct_payment_details=None, **kwargs): <NEW_LINE> <INDENT> if direct_payment_details: <NEW_LINE> <INDENT> payment_xml_root = Element("ewaygateway") <NEW_LINE> for each_field in direct_payment_details: <NEW_LINE> <INDENT> field = Element(each_field) <NEW_LINE> field.text = str(direct_pa... | Eway Direct Payment API Url : http://www.eway.com.au/developers/api/direct-payments#tab-1
Input and Output format: https://gist.github.com/2552fcaa2799045a7884 | 625941c75fcc89381b1e170e |
def do_and_form(expressions, env): <NEW_LINE> <INDENT> if expressions == nil: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> curr = scheme_eval(expressions.first, env) <NEW_LINE> if scheme_truep(curr): <NEW_LINE> <INDENT> if expressions.second == nil: <NEW_LINE> <INDENT> return curr <NEW_... | Evaluate a (short-circuited) and form. | 625941c7283ffb24f3c55952 |
def make_change(cash_as_pennies: int, cash_input: str): <NEW_LINE> <INDENT> values = [] <NEW_LINE> change = cash_as_pennies <NEW_LINE> for val in CHANGE_VALUES: <NEW_LINE> <INDENT> values.append(change // val) <NEW_LINE> change %= val <NEW_LINE> <DEDENT> return ChangeCalculation(cash_input, ''.join(str(v) for v in valu... | Given the total number of pennies that make up the provided value,
calculate the best way to break it into change using the fewest
denominations of coins. This method requires the original input
from the user so it can be stored in the ChangeCalculation DTO
for logging and storage in the database | 625941c731939e2706e4cebc |
def __call__(self, instance): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> handler = self.__type_handlers[type(instance)] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> raise self.UnregisteredTypeError( 'Cannot generate mailing list identifier for {!r}'.format(instance) ) <NEW_LINE> <DEDENT> label = '.'.join(... | Build a list-id string from an instance.
Raises ``UnregisteredTypeError`` if there is no registered handler for
the instance type. Raises ``AssertionError`` if a valid list-id string
cannot be generated from the values returned by the type handler. | 625941c7be383301e01b54d8 |
def init_signal(self): <NEW_LINE> <INDENT> self.signal = Signal() <NEW_LINE> self.signal.set( feeder_exited=False, parser_exited=False, reach_max_num=False) | Init signal
3 signals are added: ``feeder_exited``, ``parser_exited`` and
``reach_max_num``. | 625941c7a934411ee37516e4 |
def path(self, *parts): <NEW_LINE> <INDENT> parts2 = [str(self.cwd)] <NEW_LINE> for p in parts: <NEW_LINE> <INDENT> if isinstance(p, RemotePath): <NEW_LINE> <INDENT> raise TypeError("Cannot construct LocalPath from %r" % (p,)) <NEW_LINE> <DEDENT> parts2.append(self.env.expanduser(str(p))) <NEW_LINE> <DEDENT> return Loc... | A factory for :class:`LocalPaths <plumbum.local_machine.LocalPath>`.
Usage ::
p = local.path("/usr", "lib", "python2.7") | 625941c7460517430c3941d8 |
def float_scientific_positive( self, float_query=1.034E+20, custom_headers=None, raw=False, **operation_config): <NEW_LINE> <INDENT> url = '/queries/float/1.034E+20' <NEW_LINE> query_parameters = {} <NEW_LINE> query_parameters['floatQuery'] = self._serialize.query("float_query", float_query, 'float') <NEW_LINE> header_... | Get '1.034E+20' numeric value
:param float_query: '1.034E+20'numeric value
:type float_query: float
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<m... | 625941c7ec188e330fd5a7f1 |
def create_image_dataproduct(data_product): <NEW_LINE> <INDENT> tmpfile = data_product.create_thumbnail() <NEW_LINE> if tmpfile: <NEW_LINE> <INDENT> dp, _ = DataProduct.objects.get_or_create( product_id="{}_{}".format(data_product.product_id, "jpeg"), target=data_product.target, observation_record=data_product.observat... | Creates and saves a thumbnail image for a ``DataProduct``.
:param data_product: ``DataProduct`` for which to create an image
:type data_product: DataProduct
:returns: True if creation was successful
:rtype: boolean | 625941c721a7993f00bc7d3e |
def weight_exp_pure(history): <NEW_LINE> <INDENT> return _recent(history, lambda w: w*2) | multiplicative | 625941c7b545ff76a8913e67 |
def init_central_widget(self): <NEW_LINE> <INDENT> self.central_widget = QtGui.QWidget() <NEW_LINE> self.buttons_widget = QtGui.QWidget() <NEW_LINE> v_layout = QtGui.QVBoxLayout() <NEW_LINE> h_layout = QtGui.QHBoxLayout() <NEW_LINE> self.function_text = QtGui.QTextEdit() <NEW_LINE> self.function_text.setFontPointSize(2... | Vsebina centralnega okna
| 625941c73eb6a72ae02ec52b |
def build_section_by_section(sxs, part, fr_start_page, previous_label=None): <NEW_LINE> <INDENT> structures = [] <NEW_LINE> while len(sxs): <NEW_LINE> <INDENT> title, text_els, sub_sections, sxs = split_into_ttsr(sxs) <NEW_LINE> page = find_page(title, title.sourceline, fr_start_page) <NEW_LINE> paragraph_xmls = [deepc... | Given a list of xml nodes in the section by section analysis, pull
out hierarchical data into a structure. Previous label is carried along to
merge analyses of the same section. | 625941c7d4950a0f3b08c3a0 |
def _variable_parts(self, line, codeline): <NEW_LINE> <INDENT> var_subs = [] <NEW_LINE> if codeline: <NEW_LINE> <INDENT> var_subs = self._find_variable(codeline.pattern, line) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> line_str = self._strip_datetime(self._strip_counters(line)) <NEW_LINE> var_subs = [line_str.strip(... | Return variable parts of the codeline, given the static parts. | 625941c7d268445f265b4ebe |
def associate_port(self, args): <NEW_LINE> <INDENT> LOG.debug("associate_port() called\n") <NEW_LINE> return self._invoke_inventory(const.UCS_PLUGIN, self._func_name(), args) | Get the portprofile name and the device name for the dynamic vnic | 625941c756b00c62f0f146a9 |
def test_seeking(tmp_path): <NEW_LINE> <INDENT> dur = 33 <NEW_LINE> temp_file = str(tmp_path / "temp.webp") <NEW_LINE> with Image.open("Tests/images/anim_frame1.webp") as frame1: <NEW_LINE> <INDENT> with Image.open("Tests/images/anim_frame2.webp") as frame2: <NEW_LINE> <INDENT> frame1.save( temp_file, save_all=True, ap... | Create an animated WebP file, and then try seeking through frames in reverse-order,
verifying the timestamps and durations are correct. | 625941c7d58c6744b4257cb1 |
def get(self, counter, param): <NEW_LINE> <INDENT> reg = ReconfigRegister(cmd='read',counter=counter,param=param) <NEW_LINE> self.write(reg) <NEW_LINE> return self.read().data | issue a read instruction for one parameter of the given instruction.
Returns: the value of the clock parameter | 625941c7d99f1b3c44c675e0 |
def add_host(self, address, signal): <NEW_LINE> <INDENT> log.info("Now considering host %s for new connections", address) <NEW_LINE> new_host = self.metadata.add_host(address) <NEW_LINE> if new_host and signal: <NEW_LINE> <INDENT> self._prepare_all_queries(new_host) <NEW_LINE> self.control_connection.on_add(new_host) <... | Called when adding initial contact points and when the control
connection subsequently discovers a new node. Intended for internal
use only. | 625941c7236d856c2ad44829 |
def __contains__(self, pt): <NEW_LINE> <INDENT> if abs(self.graph.x+self.x-pt.x) < self.r*2 and abs(self.graph.y+self.y-pt.y) < self.r*2: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | True if pt.x, pt.y is inside the node's absolute position.
| 625941c74f6381625f114a8c |
def hash_entry(self, entry): <NEW_LINE> <INDENT> return hashlib.sha224("{}{}".format(entry.title, entry.link)).hexdigest() | Creates a hash out of the feedparser's Entry. Uses just the title
and the link as that is what we care about in most cases. | 625941c78c3a87329515840a |
def test_check_property_state_example_data(self): <NEW_LINE> <INDENT> ps_data = { 'no_default_data': True, 'custom_id_1': 'abcd', 'pm_property_id': 'PMID', 'site_eui': 525600, } <NEW_LINE> ps = self.property_state_factory.get_property_state(None, **ps_data) <NEW_LINE> dq = DataQualityCheck.retrieve(self.org.id) <NEW_LI... | Trigger 5 rules - 2 default and 3 custom rules - one of each condition type | 625941c7baa26c4b54cb1171 |
@datastore.command() <NEW_LINE> @click.argument(u'resource-id', nargs=1) <NEW_LINE> @click.argument( u'output-file', type=click.File(u'wb'), default=click.get_binary_stream(u'stdout') ) <NEW_LINE> @click.option(u'--format', default=u'csv', type=click.Choice(DUMP_FORMATS)) <NEW_LINE> @click.option(u'--offset', type=clic... | Dump a datastore resource.
| 625941c70a50d4780f666ee2 |
def test_ports(self): <NEW_LINE> <INDENT> self.definition.run( fetch_image=False, ports={'8000/tcp': ('127.0.0.1', '10701')}) <NEW_LINE> self.assertCountEqual(self.definition.ports.items(), [ ('80/tcp', None), ('8000/tcp', [{'HostIp': '127.0.0.1', 'HostPort': '10701'}]), ]) | We can get the ports exposed or published on a container. | 625941c74e4d5625662d442a |
def stop(self): <NEW_LINE> <INDENT> if not self.is_playing(): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self.cpx.stop_tone() <NEW_LINE> self.active_note = None | Stop playing the song. Call play() to start playing the song againg
from the beginning. | 625941c71d351010ab855b6c |
def __init__(self, data_dir: Path, name_pat: str = '%', library_id: int = 1): <NEW_LINE> <INDENT> logger.debug(f'data {format(data_dir)}') <NEW_LINE> self.data_dir = data_dir <NEW_LINE> self.name_pat = name_pat <NEW_LINE> self.library_id = library_id | Initialize
:param data_dir: directory containing the Zotero DB files (sqlite and
collections)
:param name_pat: the SQL pattern to match against subcollection names
:param library_id: the DB ide of the library to export | 625941c7091ae35668666fb0 |
def calculate_freq(ds, freq='5min', buffer='1H'): <NEW_LINE> <INDENT> ds_freq = ds.resample(freq, 'time', how='sum', label='right', keep_attrs=True).fillna(0) <NEW_LINE> buffer = pd.Timedelta(buffer) <NEW_LINE> inter_tip_time = pd.Timedelta(ds.rain_gage.attrs.get('inter_tip_time', 0)) <NEW_LINE> bool_array = ds.time.d... | Calculate frequency given tip dataset.
Parameters
----------
ds: xarray.Dataset object containing one station's worth of tip data
freq: time frequency string as in pandas - default '5min'
buffer: time frequency string by which to increase max allowable time between
tip reports - default '1H'
Returns
-------
d... | 625941c7091ae35668666fb1 |
def cb_defaults(self): <NEW_LINE> <INDENT> pass | defaults callback | 625941c77b25080760e394aa |
@pytest.mark.parametrize("chem", ["SO2", "O3", "H2O2", "CO2", "HNO3", "NH3"]) <NEW_LINE> def test_henry_checker(data, chem, eps = {"SO2": 5e-8, "O3":4e-8, "H2O2": 2e-6, "CO2": 4e-8, "NH3": 4e-7, "HNO3":2e-6}): <NEW_LINE> <INDENT> vol = data.variables["radii_m3"][-1] * 4/3. * math.pi <NEW_LINE> conc_H = data.variable... | Checking if dissolving chemical compounds into cloud droplets follows Henrys law
http://www.henrys-law.org/
libcloudph++ takes into account the effect of temperature and pH on Henry constant
and the effects of mass transfer into droplets
Due o the latter effect, to compare with the teoretical values there is first th... | 625941c73539df3088e2e39b |
def capitalize(a): <NEW_LINE> <INDENT> a_arr = numpy.asarray(a) <NEW_LINE> return _vec_string(a_arr, a_arr.dtype, 'capitalize') | Return a copy of `a` with only the first character of each element
capitalized.
Calls `str.capitalize` element-wise.
For 8-bit strings, this method is locale-dependent.
Parameters
----------
a : array_like of str or unicode
Returns
-------
out : ndarray
Output array of str or unicode, depending on input
typ... | 625941c7097d151d1a222eab |
def query_and_wait(self, d, maxresults=20): <NEW_LINE> <INDENT> self.query(d, maxresults) <NEW_LINE> while self.is_alive(): <NEW_LINE> <INDENT> self.join(0.2) <NEW_LINE> <DEDENT> return self.ans | Performs a query and waits until the job is done. Returns the answer. | 625941c715fb5d323cde0b5f |
def check_group_is_friend(self, group): <NEW_LINE> <INDENT> return True | if all elements are in friendship with each other, return true. else, false.
:return: if all elements are in friendship with each other, return true. else, false. | 625941c78c0ade5d55d3ea0b |
def test_avltree(): <NEW_LINE> <INDENT> tree = AVLTree() <NEW_LINE> assert 0 not in tree <NEW_LINE> assert list(tree) == list(tree.keys()) == list(tree.values()) == list(tree.items()) == [] <NEW_LINE> size = 7 <NEW_LINE> for permutation in permutations(range(size)): <NEW_LINE> <INDENT> tree = AVLTree() <NEW_LINE> for e... | Test AVLTree. | 625941c72ae34c7f2600d182 |
def fetch(self, minion_id, pillar, *args, **kwargs): <NEW_LINE> <INDENT> db_name = self._db_name() <NEW_LINE> log.info('Querying {0} for information for {1}'.format(db_name, minion_id)) <NEW_LINE> qbuffer = self.extract_queries(args, kwargs) <NEW_LINE> with self._get_cursor() as cursor: <NEW_LINE> <INDENT> for root, de... | Execute queries, merge and return as a dict. | 625941c7925a0f43d2549ec7 |
def childNames( self ): <NEW_LINE> <INDENT> if ( self._domObject ): <NEW_LINE> <INDENT> return [ child.nodeName for child in self._domObject.childNodes if isinstance( child, PyXmlElement ) ] <NEW_LINE> <DEDENT> return [] | emarks returns a list of the element names for the children
of this xml element
eturn <list> [ <str>, .. ] | 625941c7b7558d58953c4f67 |
def __init__(self, elf_class=64, endianness='little', architecture='x86_64', entry=None, phoff=None, shoff=None, flags=None, ehsize=None, phentsize=None, phnum=None, shentsize=None, shnum=None, shstrndx=None): <NEW_LINE> <INDENT> if elf_class == 64: <NEW_LINE> <INDENT> self.elf_class = self.ELFCLASS.ELFCLASS64 <NEW_LIN... | Constructs the ELFHeader object required to generate ELF binaries.
Args:
elf_class: The elf file class. Must be one of 32 or 64 for ELF32 and
ELF64 respectively.
endianness: The endianness can be either little or big.
architecture: The CPU architecture we are building this ELF binary for.
Others: Look at... | 625941c7cc0a2c11143dcee1 |
def name(self): <NEW_LINE> <INDENT> return _blocks_swig4.peak_detector_fb_sptr_name(self) | name(peak_detector_fb_sptr self) -> std::string | 625941c723e79379d52ee5b6 |
def multi_panel_brain_figure(panels): <NEW_LINE> <INDENT> plot_panels = [] <NEW_LINE> for img in panels: <NEW_LINE> <INDENT> if (img.shape[1] < img.shape[0]): <NEW_LINE> <INDENT> img = np.rot90(img) <NEW_LINE> <DEDENT> plot_panels.append(img) <NEW_LINE> <DEDENT> shots_per_hemi = int(len(panels) / 2) <NEW_LINE> sizes = ... | Make a matplotlib figure with the brain screenshots.
Parameters
----------
panels : list of arrays
Assumes the list has screenshots from the left hemisphere and then
screenshots of the same views from the right hemisphere. The
screenshots should be "cropped" for best results.
Returns
-------
f: matplotlib... | 625941c745492302aab5e313 |
def test_delete_fulfillment_process_log_tag(self): <NEW_LINE> <INDENT> pass | Test case for delete_fulfillment_process_log_tag
Delete a tag for a fulfillmentProcessLog. # noqa: E501 | 625941c75e10d32532c5ef78 |
def get_edge_count(self, pin, reset_counter): <NEW_LINE> <INDENT> self.check_validity() <NEW_LINE> pin = int(pin) <NEW_LINE> reset_counter = bool(reset_counter) <NEW_LINE> return self.ipcon.send_request(self, BrickletIO4.FUNCTION_GET_EDGE_COUNT, (pin, reset_counter), 'B !', 12, 'I') | Returns the current value of the edge counter for the selected pin. You can
configure the edges that are counted with :func:`Set Edge Count Config`.
If you set the reset counter to *true*, the count is set back to 0
directly after it is read.
.. versionadded:: 2.0.1$nbsp;(Plugin) | 625941c78a43f66fc4b540b7 |
def QZONE_HOMR_URL(QQ): <NEW_LINE> <INDENT> return '%(QZONE_DOMAIN)s%(QQ)s' % { 'QZONE_DOMAIN' : QZONE_DOMAIN, 'QQ' : QQ } | 获取QQ空间首页地址
:param QQ: QQ号
:return: | 625941c797e22403b379cfeb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.