code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def get_program_uuid(self, obj): <NEW_LINE> <INDENT> return retrieve_offer(obj).condition.program_uuid | Get the Program UUID attached to the coupon. | 625941c2d53ae8145f87a218 |
def verify_state(self, resp, state_data, state): <NEW_LINE> <INDENT> if not ("state" in resp and "state" in state_data and resp["state"] == state_data["state"]): <NEW_LINE> <INDENT> tmp_state = "" <NEW_LINE> if "state" in resp: <NEW_LINE> <INDENT> tmp_state = resp["state"] <NEW_LINE> <DEDENT> satosa_logging(LOGGER, log... | Will verify the state and throw and error if the state is invalid.
:type resp: AuthorizationResponse
:type state_data: dict[str, str]
:type state: satosa.state.State
:param resp: The authorization response from the OP, created by pyoidc.
:param state_data: The state data for this backend.
:param state: The current sta... | 625941c2f548e778e58cd522 |
def notify_trommons(task_dir_name, project_backlink, json_filename, trommons_dir): <NEW_LINE> <INDENT> temp_dir = mkdtemp() <NEW_LINE> temp_proj_dir = os.path.join(temp_dir, task_dir_name) <NEW_LINE> os.mkdir(temp_proj_dir) <NEW_LINE> temp_file_name = os.path.join(temp_proj_dir, json_filename) <NEW_LINE> output_json_fi... | Write the 'meta.json' and translated file so Trommons can get it. | 625941c24f88993c3716c00e |
def train_model_oe_pe(): <NEW_LINE> <INDENT> print('load data') <NEW_LINE> import data_utils, training_utils <NEW_LINE> conf = data_utils.TrainConfigure() <NEW_LINE> data_dict = data_utils.pickle_load(conf.char_file) <NEW_LINE> print('loading embed ...') <NEW_LINE> vocab_dict = data_utils.pickle_load(conf.char_dict) <N... | 使用自己训练的Embedding,使用Position embedding
:return: | 625941c244b2445a3393203c |
def normalizeEmail(emailaddr, domainmap, domainrules, ignorePlus=True): <NEW_LINE> <INDENT> emailaddr = emailaddr.lower() <NEW_LINE> localpart, domain = extractEmailAddress(emailaddr) <NEW_LINE> canonical = canonicalizeEmailDomain(domain, domainmap) <NEW_LINE> if ignorePlus: <NEW_LINE> <INDENT> idx = localpart.find('+'... | Normalise an email address according to the processing rules for its
canonical originating domain.
The email address, **emailaddr**, will be parsed and validated, and then
checked that it originated from one of the domains allowed to email
requests for bridges to the
:class:`~bridgedb.distributors.email.distributor.Em... | 625941c2711fe17d82542315 |
def _check_pillar_exact_minions(self, expr, delimiter, greedy): <NEW_LINE> <INDENT> return self._check_cache_minions(expr, greedy, delimiter, 'pillar', exact_match=True) | Return the minions found by looking via pillar | 625941c27cff6e4e8111792b |
def divisible_by_three(number_list): <NEW_LINE> <INDENT> return [x for x in number_list if not x % 3] | Given a list of numbers, return a list of the numbers which are divisible by three. | 625941c2be8e80087fb20beb |
def is_developer_certificate_getter(self): <NEW_LINE> <INDENT> return self._device_execution_mode.value == 1 | Return whether this certificate is a developer certificate or not.
:param self: Instance of the entity for which this is a custom method.
:type self: mbed_cloud.foundation.TrustedCertificate
:return: True if a developer certificate, False otherwise.
:rtype: bool | 625941c2167d2b6e31218b3c |
def set_tf_cuda_version(environ_cp): <NEW_LINE> <INDENT> ask_cuda_version = ( 'Please specify the CUDA SDK version you want to use. ' '[Leave empty to default to CUDA %s]: ') % _DEFAULT_CUDA_VERSION <NEW_LINE> for _ in range(_DEFAULT_PROMPT_ASK_ATTEMPTS): <NEW_LINE> <INDENT> tf_cuda_version = get_from_env_or_user_or_de... | Set CUDA_TOOLKIT_PATH and TF_CUDA_VERSION. | 625941c2d486a94d0b98e0eb |
def pop(self, value): <NEW_LINE> <INDENT> return self.delete(value) | Remove value in the set if it is present. | 625941c28e71fb1e9831d750 |
def _comparison(self, op, value): <NEW_LINE> <INDENT> value = self._validate(value) <NEW_LINE> return query.FilterNode(self._code_name, op, value) | get called when standard Python binary operator is used on a property to
return a query.FilterNode. | 625941c26fb2d068a760f041 |
def clear_db(func): <NEW_LINE> <INDENT> def test_wrapper(*args): <NEW_LINE> <INDENT> global DB <NEW_LINE> DB = {} <NEW_LINE> return func(*args) <NEW_LINE> <DEDENT> return test_wrapper | A decorator to clear out the in-memory database prior to a test. | 625941c27c178a314d6ef402 |
def auth_password_change(request): <NEW_LINE> <INDENT> data = parse_auth_password_change_data(request.data) <NEW_LINE> return data | params: request
return: data | 625941c27047854f462a13b2 |
def adx_pos(high, low, close, n=14, fillna=False): <NEW_LINE> <INDENT> cs = close.shift(1) <NEW_LINE> tr = high.combine(cs, max) - low.combine(cs, min) <NEW_LINE> trs = tr.rolling(n).sum() <NEW_LINE> up = high - high.shift(1) <NEW_LINE> dn = low.shift(1) - low <NEW_LINE> pos = ((up > dn) & (up > 0)) * up <NEW_LINE> neg... | Average Directional Movement Index Positive (ADX)
The Plus Directional Indicator (+DI) and Minus Directional Indicator (-DI)
are derived from smoothed averages of these differences, and measure trend
direction over time. These two indicators are often referred to collectively
as the Directional Movement Indicator (DMI... | 625941c2bde94217f3682d98 |
def _decode_preferred_encoding(s): <NEW_LINE> <INDENT> if six.PY3 and isinstance(s, bytes): <NEW_LINE> <INDENT> enc = locale.getpreferredencoding() <NEW_LINE> try: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return s.decode(enc) <NEW_LINE> <DEDENT> except LookupError: <NEW_LINE> <INDENT> enc = 'utf-8' <NEW_LINE> <DEDE... | Decode the supplied byte string using the preferred encoding for
the locale (`locale.getpreferredencoding`) or, if the default
encoding is invalid, fall back first on utf-8, then on latin-1 if
the message cannot be decoded with utf-8. | 625941c25f7d997b87174a3c |
def send_invitation_email(from_addr, to_addr, signed_invitation): <NEW_LINE> <INDENT> subject = "Invitation by %s to %s" % (from_addr, settings.HOST) <NEW_LINE> text_content = loader.get_template('emails/profiles/invite.txt') <NEW_LINE> html_content = loader.get_template('emails/profiles/invite.html') <NEW_LINE> log.de... | Send the invitation to join | 625941c2097d151d1a222e01 |
def minWindow(self, S, T): <NEW_LINE> <INDENT> lookup = [[None for _ in xrange(26)] for _ in xrange(len(S)+1)] <NEW_LINE> find_char_next_pos = [None]*26 <NEW_LINE> for i in reversed(xrange(len(S))): <NEW_LINE> <INDENT> find_char_next_pos[ord(S[i])-ord('a')] = i+1 <NEW_LINE> lookup[i] = list(find_char_next_pos) <NEW_LIN... | :type S: str
:type T: str
:rtype: str | 625941c230c21e258bdfa442 |
def test_bad_R_spec(self): <NEW_LINE> <INDENT> from plugins.R import RCheckInstallSection <NEW_LINE> class ChecksMockup(object): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> class ApplicableRCheckInstallSection(RCheckInstallSection): <NEW_LINE> <INDENT> def is_applicable(self): <NEW_LINE> <INDENT> return True <NEW_LINE... | test R spec, expected to fail. | 625941c2d7e4931a7ee9dec3 |
def ex8_cpv_hist(bot_year=2008, top_year=2020, country_list=countries, cpv='50'): <NEW_LINE> <INDENT> pipeline = [] <NEW_LINE> list_documents = [] <NEW_LINE> return list_documents | Produce an histogram where each bucket has the contract counts of a particular cpv
in a given range of values (bucket) according to 'VALUE_EURO'
Choose 10 buckets of any partition
Buckets Example:
0 to 100000
100000 to 200000
200000 to 300000
300000 to 400000
400000 to 500000
500000 to 600000
600000 to 700000... | 625941c2283ffb24f3c558a9 |
def setConfig(self, config): <NEW_LINE> <INDENT> self._previousIdentifier = config['identifier'] <NEW_LINE> self._previousGFLoc = config['GF Filename'] <NEW_LINE> self._previousEnsLoc = config['ensemble filename'] <NEW_LINE> self._previousMeshLoc = config['mesh filename'] <NEW_LINE> self._previousPathLoc = config['path... | Set the current value of the configuration for the dialog. Also
set the _previousIdentifier value so that we can check uniqueness of the
identifier over the whole of the workflow. | 625941c24f6381625f1149e1 |
def _dump_image_info(self, local_images, pvc_images): <NEW_LINE> <INDENT> LOG.debug(_('Local hosting OS image dict: %s'), str(local_images)) <NEW_LINE> LOG.debug(_('PowerVC image dict: %s'), str(pvc_images)) <NEW_LINE> LOG.debug(_('Image ids dict: %s'), str(self.ids_dict)) <NEW_LINE> LOG.debug(_('Local hosting OS updat... | Dump out the current image information
:param: local_images A dict of the local hostingOS images
:param: pvc_images A dict of the PowerVC images | 625941c2ec188e330fd5a749 |
def behind(self, point): <NEW_LINE> <INDENT> if np.dot(self.direction, np.array(point)) - np.dot(self.direction, self.position) < 0: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False | Returns True is if 'point' is behind the ray location.
Used in Scene.sort()
:param point: A cartesian point
:return: boolean
Discussion:
The equation of a plane is ax + by + cz + d = 0.
Let point O, lie on the plane.
The normal of the plane is, n = [a, b, c], thus
d = -n dot O
If n.p + d < 0, the point is behind the... | 625941c291f36d47f21ac496 |
def _place_node(self, node_id, x, min_y): <NEW_LINE> <INDENT> self.processed.append(node_id) <NEW_LINE> try: <NEW_LINE> <INDENT> y_occupied = self.occupied[x] <NEW_LINE> <DEDENT> except IndexError: <NEW_LINE> <INDENT> self.occupied.append(-1) <NEW_LINE> y_occupied = -1 <NEW_LINE> <DEDENT> y = max(min_y, y_occupied + 1)... | Determine x, y position for a node.
node_id: id of the node to be positioned
x: x position (depth) of the node
min_y: minimal y position of the node
(can't be above parent nodes)
returns: y offset relative to min_y | 625941c2d164cc6175782cf4 |
def select_task(conn, sql,params): <NEW_LINE> <INDENT> cur = conn.cursor() <NEW_LINE> cur.execute(sql, params) <NEW_LINE> rows = cur.fetchall() <NEW_LINE> return rows | Query tasks by priority
:param conn: the Connection object
:param priority:
:return: | 625941c291f36d47f21ac497 |
def depthFirstSearch(problem): <NEW_LINE> <INDENT> return GeneralSearch(problem, util.Stack()) | Search the deepest nodes in the search tree first
Your search algorithm needs to return a list of actions that reaches
the goal. Make sure to implement a graph search algorithm
To get started, you might want to try some of these simple commands to
understand the search problem that is being passed in:
print "Start:... | 625941c27cff6e4e8111792c |
def make_256color(self, colortype, val): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> ival = int(val) <NEW_LINE> <DEDENT> except (TypeError, ValueError) as ex: <NEW_LINE> <INDENT> raise self.make_256error(colortype, val) from ex <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if (ival < 0) or (ival > 255): <NEW_LINE> <IN... | Create a 256 color code based on type ('fore' or 'back')
out of a number (can be string).
Raises ColorCodes.Invalid256Color() on error.
Returns the raw color code on success. | 625941c24527f215b584c3ff |
def read_installation_log(fname): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open(fname) as f: <NEW_LINE> <INDENT> file_contents = list(f.readlines()) <NEW_LINE> <DEDENT> <DEDENT> except IOError: <NEW_LINE> <INDENT> log.d('Log not found: ' + fname) <NEW_LINE> return [] <NEW_LINE> <DEDENT> mods_list = [] <NEW_LIN... | Read an 'installed_raws.txt' and return the mods. | 625941c21f5feb6acb0c4af9 |
def echo_add_to_file(echo_string, out_file): <NEW_LINE> <INDENT> check_cmd = 'echo "%s" >> %s' % (echo_string, out_file) <NEW_LINE> output = subprocess.getoutput(check_cmd) <NEW_LINE> error = False <NEW_LINE> if output: <NEW_LINE> <INDENT> error = True <NEW_LINE> <DEDENT> assert not error, "echo is complaining:\n%s\n%s... | Add a string to file, using echo command. | 625941c23eb6a72ae02ec47e |
def read_nodes(path): <NEW_LINE> <INDENT> arr = np.genfromtxt(path, delimiter = "'", dtype = np.int32) <NEW_LINE> return arr | Read data example and save it
>>> read_nodes("examples/nodes1.csv")
array([1, 2, 3, 1, 2, 3, 1, 2]) | 625941c273bcbd0ca4b2c01d |
def save_revision(self, user=None, submitted_for_moderation=False, approved_go_live_at=None, changed=True, log_action=False, previous_revision=None, clean=True): <NEW_LINE> <INDENT> if self.alias_of_id: <NEW_LINE> <INDENT> raise RuntimeError( "save_revision() was called on an alias page. " "Revisions are not required f... | Creates and saves a page revision.
:param user: the user performing the action
:param submitted_for_moderation: indicates whether the page was submitted for moderation
:param approved_go_live_at: the date and time the revision is approved to go live
:param changed: indicates whether there were any content changes
:para... | 625941c2090684286d50ec8a |
def runfilter(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.rtn_filename() <NEW_LINE> <DEDENT> except getopt.GetoptError as err: <NEW_LINE> <INDENT> print(err) <NEW_LINE> self.usage() <NEW_LINE> sys.exit(2) <NEW_LINE> <DEDENT> if (not self.attr['Interactive']): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> se... | Run configured job submission filter. After queue classes, illegal
command and attribute rules have been specified, runfilter method will
ensure submitted jobs do not violate any set rules. | 625941c221a7993f00bc7c93 |
def dbsApiImplUpdateProcDSDesc(self, dataset, desc): <NEW_LINE> <INDENT> funcInfo = inspect.getframeinfo(inspect.currentframe()) <NEW_LINE> data = self._server._call ({ 'api' : 'updateProcDSDesc', 'path' : get_path(dataset), 'desc' : str(desc), }, 'POST') | Updates the description of a processed dataset
dataset: Dataset to be updated
desc : the description | 625941c22eb69b55b151c853 |
def create_user(self, email, password=None, **extra_fields): <NEW_LINE> <INDENT> if not email: <NEW_LINE> <INDENT> raise ValueError('Users must have a valid email address') <NEW_LINE> <DEDENT> user = self.model(email=self.normalize_email(email), **extra_fields) <NEW_LINE> user.set_password(password) <NEW_LINE> user.sav... | Create and save a new user | 625941c24a966d76dd550fb4 |
def formatDict(self, results): <NEW_LINE> <INDENT> formattedResults = DBFormatter.formatDict(self, results) <NEW_LINE> for formattedResult in formattedResults: <NEW_LINE> <INDENT> formattedResult["id"] = int(formattedResult["id"]) <NEW_LINE> <DEDENT> return formattedResults | _formatDict_
Cast the id column to an integer since formatDict() turns everything
into strings. | 625941c2cdde0d52a9e52fd7 |
def create_html_table_from_data(table_headings, table_data, table_name): <NEW_LINE> <INDENT> table_head = '<tr>' + '<th>%s</th>' * len(table_headings) + '</tr>\n' <NEW_LINE> table_body = '' <NEW_LINE> for item in table_data: <NEW_LINE> <INDENT> table_line = '<tr>' + '<td>%s</td>' * len(item) + '</tr>\n' <NEW_LINE> tabl... | Takes in a list of tuples as data for the table, returns the data as an html table | 625941c230dc7b766590190f |
def _locality(self, executors): <NEW_LINE> <INDENT> if self.src: <NEW_LINE> <INDENT> if isinstance(self.src, Iterable): <NEW_LINE> <INDENT> localities = defaultdict(int) <NEW_LINE> forbidden = set() <NEW_LINE> for src in self.src: <NEW_LINE> <INDENT> if src.dset.sync_required: <NEW_LINE> <INDENT> continue <NEW_LINE> <D... | Determine locality of computing this partition. Cache locality is dealt
with when this method is invoked by Partition.locality(executors).
Typically source partition implementations which inherit from Partition
indicate here whether computing on a executor shows locality. This allows
dealing with caching and preferenc... | 625941c2b830903b967e98b3 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, PagedResourceListOfCutLabelDefinition): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.to_dict() == other.to_dict() | Returns true if both objects are equal | 625941c20383005118ecf58a |
def get_advise_python_with_http_info(self, analysis_id, **kwargs): <NEW_LINE> <INDENT> all_params = ['analysis_id'] <NEW_LINE> all_params.append('async_req') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE> all_params.append('_request_timeout') <NEW_LINE... | Get computed adviser result based on its identifier # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_advise_python_with_http_info(analysis_id, async_req=True)
>>> result = thread.get()
:param async_req bool
:pa... | 625941c2f548e778e58cd523 |
def is_live(): <NEW_LINE> <INDENT> return self.stem.find('Live')!=-1 | True if the file belongs to a Live image, False otherwise | 625941c2627d3e7fe0d68df5 |
def normalize_cols(pair_count): <NEW_LINE> <INDENT> max_margin_error = 0.0 <NEW_LINE> for letter in alphabet: <NEW_LINE> <INDENT> total = 0.0 <NEW_LINE> for encrypted_letter in alphabet: <NEW_LINE> <INDENT> pair_key = (encrypted_letter, letter) <NEW_LINE> count = pair_count[pair_key] <NEW_LINE> total += count <NEW_LINE... | :param pair_count: a pair count object, a Counter with tuples for keys
like ('a','b') for each pair of letters
:return: normalized along the col direction | 625941c2d8ef3951e32434e4 |
def get(self, request, format=None): <NEW_LINE> <INDENT> parameters = { 'query': request.REQUEST.get('query', ''), 'started': int(request.REQUEST.get('started', 0)), 'hasTA': int(request.REQUEST.get('hasTA', 0)), } <NEW_LINE> if not parameters['started']: <NEW_LINE> <INDENT> parameters['started'] = 'false' <NEW_LINE> <... | Search | 625941c20fa83653e4656f62 |
def readGenos(self,genofile,referencefile=None): <NEW_LINE> <INDENT> if referencefile: <NEW_LINE> <INDENT> self.gen = np.zeros((len(self.ped),len(self.mark))) <NEW_LINE> self.gen1 = np.zeros((len(self.ped),len(self.mark))) <NEW_LINE> self.gen1[:] = np.nan <NEW_LINE> <DEDENT> else: self.gen = np.zeros((len(self.ped),len... | Reads the genotype file and converts the genotypes into a numpy array as 0/1/2
The -a parameter will specify if the alleles are given as:
0/1/2 (-a 1),
11/13/33 (-a 2),
1 1/1 3/3 3 (-a 3) | 625941c2a934411ee375163a |
def adam_updates(params, cost_or_grads, lr=0.001, mom1=0.9, mom2=0.999): <NEW_LINE> <INDENT> updates = [] <NEW_LINE> if not isinstance(cost_or_grads, list): <NEW_LINE> <INDENT> grads = tf.gradients(cost_or_grads, params) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> grads = cost_or_grads <NEW_LINE> <DEDENT> t = tf.Vari... | Builds an adam optimizer. | 625941c2e64d504609d747e6 |
def GetGenerateScalesOutput(self): <NEW_LINE> <INDENT> return _itkMultiScaleHessianBasedMeasureImageFilterPython.itkMultiScaleHessianBasedMeasureImageFilterID3ISSRTD33ID3_GetGenerateScalesOutput(self) | GetGenerateScalesOutput(self) -> bool | 625941c29b70327d1c4e0d7b |
def unmute(self): <NEW_LINE> <INDENT> ret = lib.dc_set_chat_mute_duration(self.account._dc_context, self.id, 0) <NEW_LINE> if not bool(ret): <NEW_LINE> <INDENT> raise ValueError("Failed to unmute chat") | unmutes the chat
:returns: None | 625941c23d592f4c4ed1d019 |
def test_ignore_empty(self): <NEW_LINE> <INDENT> doc_1 = get_xml_declaration('1.0', 'utf-8') + get_xml_doctype('foo', 'SYSTEM', 'test.dtd') + '<foo></foo>' <NEW_LINE> doc_2 = get_xml_declaration('1.0', 'utf-8') + get_xml_doctype('foo', 'SYSTEM', 'test.dtd') + '<foo><bar /></foo>' <NEW_LINE> f1 = file_obj_from_string(do... | Ensure that empty tags are ignored if ignore_empty_tags is set to True. | 625941c2cb5e8a47e48b7a53 |
def radius(G, e=None): <NEW_LINE> <INDENT> if e is None: <NEW_LINE> <INDENT> e=eccentricity(G) <NEW_LINE> <DEDENT> return min(e.values()) | Return the radius of the graph G.
The radius is the minimum eccentricity.
Parameters
----------
G : NetworkX graph
A graph
e : eccentricity dictionary, optional
A precomputed dictionary of eccentricities.
Returns
-------
r : integer
Radius of graph | 625941c2fb3f5b602dac3638 |
def add_time(time): <NEW_LINE> <INDENT> return time * 0.9 + time * 0.2 * random.random() | Make some random for next iteration | 625941c2fff4ab517eb2f3e1 |
@task.task() <NEW_LINE> def run_downsampling(): <NEW_LINE> <INDENT> datastream.downsample_streams() | Executes the `downsample_streams` API method on the datastream backend
as some backends need this to be executed periodically. | 625941c2a8370b7717052847 |
def plot_volume(nifti_file,v_color=(.98,.63,.48),v_opacity=.1, fliplr=False, newfig=False): <NEW_LINE> <INDENT> import nibabel as nib <NEW_LINE> if newfig: <NEW_LINE> <INDENT> mlab.figure(bgcolor=(1, 1, 1), size=(400, 400)) <NEW_LINE> <DEDENT> input = nib.load(nifti_file) <NEW_LINE> input_d = input.get_data() <NEW_LINE... | Render a volume from a .nii file
Use fliplr option if scan has radiological orientation | 625941c260cbc95b062c64e9 |
def start(self): <NEW_LINE> <INDENT> def _check_list(list_object): <NEW_LINE> <INDENT> if list_object: <NEW_LINE> <INDENT> return list_object <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None, None, None <NEW_LINE> <DEDENT> <DEDENT> def _list(l_payload, go, l_last_obj): <NEW_LINE> <INDENT> return _check_list( l... | Return a list of objects from the API for a container. | 625941c24d74a7450ccd416a |
def _do_complete_added_revision(self, **kwargs): <NEW_LINE> <INDENT> pass | Hook for indiividual revisions to process additional parameters
necessary to create a new revision representing an added record.
By default no additional processing is done, so subclasses are
free to override this method without calling it on the parent class. | 625941c2a79ad161976cc0ec |
def normalize_args_sync(self, args): <NEW_LINE> <INDENT> if not self.infer_value: <NEW_LINE> <INDENT> args = tuple(_broaden(a) for a in args) <NEW_LINE> <DEDENT> return args | If infer_value is False, return broadened arguments. | 625941c2d10714528d5ffc88 |
def test_default(): <NEW_LINE> <INDENT> assert MINIMAL_STOP.wheelchair_boarding == 0 <NEW_LINE> assert MINIMAL_STOP.location_type == 0 | test_default: check for correct default values (wheelchair_boarding and location_type) | 625941c27d43ff24873a2c46 |
def createMov(self, shotCutList, marker): <NEW_LINE> <INDENT> fontColor = self.mode['[burnInTopFontColor]'] <NEW_LINE> fontSize = self.mode['[burnInTopFontSize]'] <NEW_LINE> prerendered = self.getPrerenderedString(shotCutList) <NEW_LINE> version = shotCutList.version <NEW_LINE> nukeFolder = self.mode['[localFolder]'] <... | Composite the slate information onto a ShotCutList
Args:
shotCutList: The ShotCutList to composite
marker: The Marker corresponding to shotCutList
Returns:
The path to the composited movie | 625941c250485f2cf553cd40 |
def remote_type_mode(self): <NEW_LINE> <INDENT> for widget, mode in self.widget_display_mode(): <NEW_LINE> <INDENT> widget.hide() | In this mode, the user selects either an existing remote or the
type of the new remote (directory or web). | 625941c24c3428357757c2d1 |
def fitstars(uknstars, refstars, verbose=True): <NEW_LINE> <INDENT> assert len(uknstars) == len(refstars) <NEW_LINE> if len(uknstars) < 2: <NEW_LINE> <INDENT> logger.debug("Sorry I cannot fit a transform on less than 2 stars.") <NEW_LINE> return None <NEW_LINE> <DEDENT> ref = np.hstack(listtoarray(refstars)) <NEW_LINE>... | I return the transform that puts the unknown stars (uknstars) onto the refstars.
If you supply only two stars, this is using linalg.solve() -- perfect solution.
If you supply more stars, we use linear least squares, i.e. minimize the 2D error.
Formalism inspired by :
http://math.stackexchange.com/questions/77462/ | 625941c294891a1f4081ba4f |
def get_tfidf(docs, dictionary): <NEW_LINE> <INDENT> bow_corpus = [dictionary.doc2bow(doc) for doc in docs] <NEW_LINE> tfidf = gensim.models.TfidfModel(bow_corpus) <NEW_LINE> corpus_tfidf = tfidf[bow_corpus] <NEW_LINE> return corpus_tfidf | Get the TF-IDF transformed data
:param docs: given descriptor
:param dictionary: Mapping of words to #
:return: tfidf model | 625941c23eb6a72ae02ec47f |
def gen_stmt(self, stmt, func): <NEW_LINE> <INDENT> if stmt.kind == TN.COMP_STMT: <NEW_LINE> <INDENT> if stmt.stmt_list is not None: <NEW_LINE> <INDENT> for body_stmt in stmt.stmt_list: <NEW_LINE> <INDENT> self.gen_stmt(body_stmt, func) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> elif stmt.kind in (TN.WRITE_STMT, TN.WRITELN_... | Generate code for a statement tree node :stmt:. :func: is the
function that :stmt: belongs to. | 625941c2f9cc0f698b1405a4 |
def add_site(self, site): <NEW_LINE> <INDENT> obj, created = GallerySites.objects.get_or_create( gallery=self, site=site ) <NEW_LINE> return obj | Associates a :class:`django.contrib.sites.models.Site` object with this gallery. | 625941c226068e7796caec83 |
def preprocess(self, image): <NEW_LINE> <INDENT> return image | Preprocess Image, e.g., resizing
| 625941c24e4d5625662d4381 |
def assign_daily_distances(plan, form_data): <NEW_LINE> <INDENT> for week in plan.weeks: <NEW_LINE> <INDENT> for day in week.days: <NEW_LINE> <INDENT> day.distance = min(day.distance, determine_max_long_run(form_data)) <NEW_LINE> diff = week._target_distance - week.distance <NEW_LINE> if diff > 5: <NEW_LINE> <INDENT> s... | Now that weeks are set, customize individual daily distances. | 625941c2fbf16365ca6f6167 |
def test_02_supressing_mulitple_errors_should_prevent_any_of_them_throwing(self): <NEW_LINE> <INDENT> with suppress.suppress(IOError, KeyError): <NEW_LINE> <INDENT> with open('blahblah'): <NEW_LINE> <INDENT> raise Exception("FAIL: Somehow opened blahblah, why on earth does it exist!") <NEW_LINE> <DEDENT> d = {} <NEW_LI... | Suppressing multiple error types should prevent them being raised | 625941c229b78933be1e5656 |
def get_version(rel_path): <NEW_LINE> <INDENT> for line in read(rel_path).splitlines(): <NEW_LINE> <INDENT> if line.startswith('__version__'): <NEW_LINE> <INDENT> delim = '"' if '"' in line else "'" <NEW_LINE> return line.split(delim)[1] <NEW_LINE> <DEDENT> <DEDENT> raise RuntimeError("Unable to find version string.") | Gets the version number declared in the `__version__` constant of
the Python file at `rel_path`. | 625941c2c4546d3d9de729d9 |
def attachEventListener(name, callback): <NEW_LINE> <INDENT> global eventpool <NEW_LINE> eventpool.attachEventListener(name, callback) | Attach a new event listener to the event pool | 625941c2287bf620b61d3a0c |
def encode_scene_primitives(scenes, export_settings): <NEW_LINE> <INDENT> dll = cdll.LoadLibrary(str(dll_path().resolve())) <NEW_LINE> dll.encoderCreate.restype = c_void_p <NEW_LINE> dll.encoderCreate.argtypes = [c_uint32] <NEW_LINE> dll.encoderRelease.restype = None <NEW_LINE> dll.encoderRelease.argtypes = [c_void_p] ... | Handles draco compression.
Moves position, normal and texture coordinate attributes into a Draco encoded buffer. | 625941c2046cf37aa974ccf1 |
def __init__(self, name, age): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.age = age <NEW_LINE> self.sex = 0 | 初始化属性name和age __init__类似与php中的__construct | 625941c2091ae35668666f09 |
def test_disabled(self): <NEW_LINE> <INDENT> dropped_packet_indexes = set( index for (index, frags_400, _, _) in self.pkt_infos if len(frags_400) > 1) <NEW_LINE> self.vapi.ip_reassembly_set(timeout_ms=1000, max_reassemblies=0, expire_walk_interval_ms=10000) <NEW_LINE> self.pg_enable_capture() <NEW_LINE> self.src_if.add... | reassembly disabled | 625941c27c178a314d6ef403 |
def addResources(self, resourceIds): <NEW_LINE> <INDENT> if not isinstance(resourceIds, list): <NEW_LINE> <INDENT> resourceIds = [resourceIds] <NEW_LINE> <DEDENT> templist = [] <NEW_LINE> self._resourceIds = [] <NEW_LINE> for res in resourceIds: <NEW_LINE> <INDENT> toAdd = res <NEW_LINE> if not isinstance(res, External... | Add a new external reference with the given uris. If you're looking
to add ExternalResource objects, append() or extend() them instead.
Args:
resourceIds: a list of uris as strings | 625941c2b57a9660fec33829 |
def print_vd_discovery(self): <NEW_LINE> <INDENT> for volume in self._qsan._VDs: <NEW_LINE> <INDENT> element = {'{#VOLUME}': self._qsan._get_VD_name_by_id(volume)} <NEW_LINE> self._DATA['data'].append(element) <NEW_LINE> <DEDENT> print(json.dumps(self._DATA, indent=2)) | Returns:
{"data": [{"{#VOLUME}": "volname"}, ... ]} | 625941c28da39b475bd64f19 |
def on_load_async(self, view): <NEW_LINE> <INDENT> filetype = lang(view) <NEW_LINE> if filetype is '' or view.is_scratch(): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> filepath = get_file_path() <NEW_LINE> content = view.substr(sublime.Region(0, view.size())) <NEW_LINE> t = Thread(None, notify_func, 'NotifyAsync', [... | Called when the file is finished loading | 625941c2cc40096d615958f8 |
def checkSimpleCombDecoding(self, l): <NEW_LINE> <INDENT> class DecodingRecorder: <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.decodedList = [] <NEW_LINE> <DEDENT> def notifyPacketDecoded(self, packetId): <NEW_LINE> <INDENT> self.decodedList.append(packetId) <NEW_LINE> <DEDENT> <DEDENT> n = 1<<(1<<l... | Test if the packet_set code can correctly decode the set:
{ c1. P1 + c2. P2 ,
c3. P0 + c4. P2 ,
c5. P0 + c6. P1 + c7. P2 }
with all permutations of coefficient positions | 625941c2627d3e7fe0d68df6 |
def set_shot(self, shot_coords): <NEW_LINE> <INDENT> new_board_val = self.new_board_value(shot_coords) <NEW_LINE> self.update_field(shot_coords, new_board_val) | Updates the Board with the new Shot. | 625941c2090684286d50ec8b |
def hashcode(self, video_filepath): <NEW_LINE> <INDENT> hash_code = None <NEW_LINE> try: <NEW_LINE> <INDENT> struct_format = 'q' <NEW_LINE> struct_size = struct.calcsize(struct_format) <NEW_LINE> with open(video_filepath, "rb") as movie_file: <NEW_LINE> <INDENT> filesize = os.path.getsize(video_filepath) <NEW_LINE> mov... | Generates Video Hash code. | 625941c2eab8aa0e5d26daff |
def __init__(self, client=None): <NEW_LINE> <INDENT> self.client = client or boto3.client('ses') | Constructs a new Simple Email Service with a boto3 SES client
:param client: Client that will be used to interface with AWS SES.
It is unlikely that you will ever need to pass another client to this constructor. | 625941c2cc0a2c11143dce37 |
def __init__(self, **kwargs: Any) -> None: <NEW_LINE> <INDENT> self.tag = kwargs.get('tag', None) <NEW_LINE> self.ids = kwargs.get('ids', []) <NEW_LINE> self.classes = kwargs.get('classes', []) <NEW_LINE> self.attributes = kwargs.get('attributes', []) <NEW_LINE> self.nth = kwargs.get('nth', []) <NEW_LINE> self.selector... | Initialize. | 625941c28c3a873295158360 |
def mask_images(images: Iterable[SpatialImage], mask: np.ndarray, image_type: type = None) -> Iterable[np.ndarray]: <NEW_LINE> <INDENT> for images in multimask_images(images, (mask,), image_type): <NEW_LINE> <INDENT> yield images[0] | Mask images.
Parameters
----------
images:
Images to mask.
mask:
Mask to apply.
image_type:
Type to cast images to.
Yields
------
np.ndarray
Masked image. | 625941c21f037a2d8b9461a6 |
def cast(*args): <NEW_LINE> <INDENT> return _itkBinaryThresholdImageFilterPython.itkBinaryThresholdImageFilterIUL2IUC2_Superclass_cast(*args) | cast(itkLightObject obj) -> itkBinaryThresholdImageFilterIUL2IUC2_Superclass | 625941c2167d2b6e31218b3d |
def improve_markdown(markdown: str) -> str: <NEW_LINE> <INDENT> md_text = html.unescape(markdown) <NEW_LINE> md_text = convert_code_block_style(md_text) <NEW_LINE> fixed_md, _ = blacken_docs.format_str( md_text, black.FileMode(target_versions="3.6", line_length=79) ) <NEW_LINE> return fixed_md | Improve markdown. | 625941c2ac7a0e7691ed4077 |
def load_data_source(data_path, subreddit, page_samples, seed=None, relative=True): <NEW_LINE> <INDENT> pages_dir = os.path.join(data_path, 'pages') <NEW_LINE> subreddits_dir = os.path.join(data_path, 'subreddits') <NEW_LINE> sr_path = os.path.join(subreddits_dir, subreddit) <NEW_LINE> random.seed(seed) <NEW_LINE> data... | Generates a dictionary of labeled and unlabelled pages from a Reddit
Data Source as specified by the specification on the github Wiki.
:param data_path: path to a Reddit Data Source.
:param subreddit: labeled subreddit which is to be targeted.
:param page_samples: number of random unlabelled page samples to use.
:param... | 625941c2a8ecb033257d3075 |
def test_product_uninstalled(self): <NEW_LINE> <INDENT> self.assertFalse(self.installer.isProductInstalled( 'redturtle.drawio')) | Test if redturtle.drawio is cleanly uninstalled. | 625941c2be7bc26dc91cd5ab |
def voter_verify_secret_code_doc_template_values(url_root): <NEW_LINE> <INDENT> required_query_parameter_list = [ { 'name': 'api_key', 'value': 'string (from post, cookie, or get (in that order))', 'description': 'The unique key provided to any organization using the WeVoteServer APIs', }, { 'name': 'vo... | Show documentation about voterVerifySecretCode | 625941c2167d2b6e31218b3e |
def point_positive_int_test(): <NEW_LINE> <INDENT> block.save_sga(mock.Mock(method="POST", body=json.dumps({ "display_name": "Test Block", "points": '-10', "weight": 11}))) <NEW_LINE> self.assertEqual(block.points, orig_score) <NEW_LINE> block.save_sga(mock.Mock(method="POST", body=json.dumps({ "display_name": "Test Bl... | Tests point is positive number. | 625941c23cc13d1c6d3c7323 |
def set_preferences(prefs): <NEW_LINE> <INDENT> for name, value in prefs.items(): <NEW_LINE> <INDENT> session[name] = value | Store multiple key/value pairs in the session. | 625941c23617ad0b5ed67ea0 |
def upd_feat(c, f, w, v): <NEW_LINE> <INDENT> param = (f, c) <NEW_LINE> self._totals[param] += (self.i - self._tstamps[param]) * w <NEW_LINE> self._tstamps[param] = self.i <NEW_LINE> self.weights[f][c] = w + v | :params c:词性
:params f:特征
:params w:当前权重
:params v:权重更新值 | 625941c2b7558d58953c4ebf |
def GraphSpi2(d): <NEW_LINE> <INDENT> main=Tk() <NEW_LINE> main.geometry('1000x1000+200+200') <NEW_LINE> main.title("Spirale DE TOTO") <NEW_LINE> def clavier(event): <NEW_LINE> <INDENT> touche=event.keysym <NEW_LINE> if touche=="Return": <NEW_LINE> <INDENT> canvas.create_text(500,30,text='On voit clairement que les nom... | d est le nombre de tours, lors de l'utilisation du programme , pour percevoir le phenomène de Euler, veuillez mettre un nombre de tours de l'ordre de 150, au delà le programme est très complexe ( pour 200 cela dure 20s) , et en dessous on ne voit pas bien le phenomène, veullez appuyer sur enter(ou return) | 625941c26fb2d068a760f043 |
def doStart(self): <NEW_LINE> <INDENT> pass | void Akonadi.UnlinkJob.doStart() | 625941c27047854f462a13b3 |
def predict(self, inputs, turnoff_noise=False, continuing=True): <NEW_LINE> <INDENT> if turnoff_noise: <NEW_LINE> <INDENT> self.noise_level = 0 <NEW_LINE> <DEDENT> if not continuing: <NEW_LINE> <INDENT> self._last_input = np.zeros((self.ninput, 1)) <NEW_LINE> self._last_state = np.zeros((self.ninternal, 1)) <NEW_LINE> ... | inputs: ninput x ntime
continuing: 最後の訓練したstateでつづけるか
turnoff_noise: ノイズを消すかどうか
Return: outputs: noutput x ntime | 625941c2aad79263cf3909e6 |
def resnet34(num_classes=1000): <NEW_LINE> <INDENT> model = ResNet(BasicBlock, [3, 4, 6, 3], num_classes) <NEW_LINE> return model | Constructs a ResNet-34 model.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet | 625941c2bde94217f3682d9a |
def compareMagnitudes(mags1,mags2,unc=None,unc2=None,ignore=[],verbose=True): <NEW_LINE> <INDENT> chi = 0. <NEW_LINE> dm,em = [],[] <NEW_LINE> for f in list(mags1.keys()): <NEW_LINE> <INDENT> if f in list(mags2.keys()) and f in list(unc.keys()) and f not in ignore: <NEW_LINE> <INDENT> dm.append(mags1[f]-mags2[f]) <NEW_... | this code compares a set of magnitudes using one of several statistics | 625941c2a79ad161976cc0ed |
def remove_OMC(self): <NEW_LINE> <INDENT> self.kat.removeBlock('OMCpath') <NEW_LINE> self.kat.removeBlock('OMC') <NEW_LINE> self.kat.nodes.replaceNode(self.kat.sOut,self.kat.sOut.nodes[0],self.kat.components['SRAR'].nodes[1].name) | Method for removing the OMC and OMCpath blocks. The SR mirror
is reconnected to the sOut space, so that nB1 remains a valid
output node. | 625941c292d797404e304131 |
def test_check_known_host_exists(self): <NEW_LINE> <INDENT> shutil.copyfile( os.path.join(integration.FILES, 'ssh', 'known_hosts'), KNOWN_HOSTS) <NEW_LINE> arg = ['root', 'github.com'] <NEW_LINE> kwargs = {'config': KNOWN_HOSTS} <NEW_LINE> ret = self.run_function('ssh.check_known_host', arg, **dict(kwargs, fingerprint=... | Verify check_known_host_exists | 625941c266673b3332b92039 |
def _calc_check_digits(number): <NEW_LINE> <INDENT> check = int(number) % 97 <NEW_LINE> return '%02d' % (check or 97) | Calculate the check digits over the provided part of the number. | 625941c2f7d966606f6a9faa |
def _setup_os_metadatas(metadata_session): <NEW_LINE> <INDENT> logging.info('setup os metadata table') <NEW_LINE> from compass.db.api import metadata <NEW_LINE> metadata.add_os_metadata_internal(metadata_session) | Initialize os metadata table. | 625941c23346ee7daa2b2d13 |
def report(self, simulation, state, accept_move=True): <NEW_LINE> <INDENT> if accept_move: <NEW_LINE> <INDENT> super(MCReporter, self).report(simulation, state) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> return | Generate a report.
Parameters
----------
simulation : simtk.openmm.app.Simulation
The Simulation to generate a report for
state : simtk.openmm.State
The current state of the simulation
accept_move : bool
Whether or not the MC move is valid | 625941c2004d5f362079a2dd |
def remove(self, valor): <NEW_LINE> <INDENT> inicio = self.head <NEW_LINE> anterior = None <NEW_LINE> while inicio.proximo is not None: <NEW_LINE> <INDENT> anterior = inicio <NEW_LINE> inicio = inicio.proximo <NEW_LINE> if inicio.dado == valor: <NEW_LINE> <INDENT> anterior.proximo = inicio.proximo <NEW_LINE> inicio = a... | Remove todos os elementos que forem igual ao valor informado. | 625941c230dc7b7665901910 |
def teleport(self, x, y): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> locations[self.x][self.y].playerLeaves(self.id) <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> locations[x][y].playerEnters(self.id) <NEW_LINE> self.x = x <NEW_LINE> self.y = y | Locations use different methods when a player moves then when a NPC does. | 625941c267a9b606de4a7e63 |
def process_bounds(self, zoom=None): <NEW_LINE> <INDENT> warnings.warn( DeprecationWarning("Method renamed to self.bounds_at_zoom(zoom).") ) <NEW_LINE> return self.bounds_at_zoom(zoom) | Deprecated. | 625941c2e76e3b2f99f3a7b7 |
def _parse_text(path): <NEW_LINE> <INDENT> split_path = path.split(".") <NEW_LINE> if split_path[-1] == "gz": <NEW_LINE> <INDENT> lang = split_path[-2] <NEW_LINE> with open(path, "rb") as f, gzip.GzipFile(fileobj=f) as g: <NEW_LINE> <INDENT> return g.read().decode("utf-8").split("\n"), lang <NEW_LINE> <DEDENT> <DEDENT>... | Returns the sentences from a single text file, which may be gzipped. | 625941c2d164cc6175782cf6 |
def delete_affinity_group(kwargs=None, conn=None, call=None): <NEW_LINE> <INDENT> if call != 'function': <NEW_LINE> <INDENT> raise SaltCloudSystemExit( 'The delete_affinity_group function must be called with -f or --function.' ) <NEW_LINE> <DEDENT> if kwargs is None: <NEW_LINE> <INDENT> kwargs = {} <NEW_LINE> <DEDENT> ... | .. versionadded:: 2015.8.0
Delete a specific affinity group associated with the account
CLI Examples:
.. code-block:: bash
salt-cloud -f delete_affinity_group my-azure name=my_affinity_group | 625941c255399d3f0558865b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.