code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def shuffle(self) -> "Route": <NEW_LINE> <INDENT> points = list(range(len(self))) <NEW_LINE> random.shuffle(points) <NEW_LINE> new_route = self.__class__() <NEW_LINE> for p in points: <NEW_LINE> <INDENT> new_route.add(self[p]) <NEW_LINE> <DEDENT> return new_route | Shuffle a route.
This is done by creating a list of the indexes and shuffling that. rather
than manipulating Point's. when the order has been determined, a new Route
is created.
Returns:
Route - A shuffled route | 625941be7c178a314d6ef36c |
def _find_remove_targets(name=None, version=None, pkgs=None, **kwargs): <NEW_LINE> <INDENT> cur_pkgs = __salt__['pkg.list_pkgs'](versions_as_list=True, **kwargs) <NEW_LINE> if pkgs: <NEW_LINE> <INDENT> to_remove = _repack_pkgs(pkgs) <NEW_LINE> if not to_remove: <NEW_LINE> <INDENT> return {'name': name, 'changes': {}, '... | Inspect the arguments to pkg.removed and discover what packages need to
be removed. Return a dict of packages to remove. | 625941be67a9b606de4a7dcd |
def _populate_user_quota_usage(user): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> user.space_usage = seafile_api.get_user_self_usage(user.email) <NEW_LINE> user.space_quota = seafile_api.get_user_quota(user.email) <NEW_LINE> <DEDENT> except SearpcError as e: <NEW_LINE> <INDENT> logger.error(e) <NEW_LINE> user.space_us... | Populate space/share quota to user.
Arguments:
- `user`: | 625941be50812a4eaa59c235 |
def getCard(self): <NEW_LINE> <INDENT> self.random_number = np.random.choice(self.number_list, 1, p=self.p_number)[0] <NEW_LINE> self.random_direction = np.random.choice(self.directions, 1)[0] <NEW_LINE> self.card = Card(self.side, self.random_direction, self.random_number) | Pick random number and direction, assign them to a variable and create a Card instance with those
variables as arguments. | 625941bef7d966606f6a9f12 |
def matrix_divided(matrix, div): <NEW_LINE> <INDENT> if div == 0: <NEW_LINE> <INDENT> raise ZeroDivisionError('division by zero') <NEW_LINE> <DEDENT> if type(div) is not int and type(div) is not float: <NEW_LINE> <INDENT> raise TypeError('div must be a number') <NEW_LINE> <DEDENT> new_matrix = [] <NEW_LINE> for i in ra... | Function divides all elements of a matrix(list of lists)
by second parameter passed (div)
Parameters:
matrix -- a list of lists to be divided
div -- number to divide matrix by
Return: new matrix containing the quotients of aforementioned division | 625941be21bff66bcd684866 |
def sign_ssh_data(self, data, algorithm=None): <NEW_LINE> <INDENT> return bytes() | Sign a blob of data with this private key, and return a `.Message`
representing an SSH signature message.
:param str data:
the data to sign.
:param str algorithm:
the signature algorithm to use, if different from the key's
internal name. Default: ``None``.
:return: an SSH signature `message <.Message>`.
.... | 625941be29b78933be1e55c2 |
def test_module_promotion_preserves_contents(self): <NEW_LINE> <INDENT> create_dummy_file('foo.py', 'print "Hello, world"') <NEW_LINE> sha1 = file_sha('foo.py') <NEW_LINE> self.assertFileTree(['foo.py']) <NEW_LINE> Module('foo').promote() <NEW_LINE> self.assertFileTree(['foo/__init__.py']) <NEW_LINE> sha2 = file_sha('f... | Promotion preserves file content. | 625941bee8904600ed9f1e3b |
@main.route('/home/comment/<int:post_id>',methods = ['GET','POST']) <NEW_LINE> @login_required <NEW_LINE> def comment(post_id): <NEW_LINE> <INDENT> form = CommentForm() <NEW_LINE> post = Post.query.get_or_404(post_id) <NEW_LINE> if form.validate_on_submit(): <NEW_LINE> <INDENT> comment = form.comment.data <NEW_LINE> co... | View root page function that returns the comments and its data | 625941be45492302aab5e1d2 |
def save_file(shares): <NEW_LINE> <INDENT> nome_file=input('\n\tNome del file da utilizzare per salvare i dati (senza estensione) : ') <NEW_LINE> xls_file=path+nome_file+'.xls' <NEW_LINE> csv_file=path+nome_file+'.csv' <NEW_LINE> txt_file=path+nome_file+'.txt' <NEW_LINE> print ('\n\tSalvo il DataFrame "Shares" delle az... | Salva il DataFrame delle azioni nei formati Excel File, CSV, TXT.
Il DataFrame Shares dei titoli viene salvato come file XLS nella directory di lavoro definita nella variabile path | 625941be4a966d76dd550f1e |
def display_peek( self, dataset ): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return dataset.peek <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return "HMMER3 database (multiple files)" | Create HTML content, used for displaying peek. | 625941be1f5feb6acb0c4a65 |
def initialize_connection_fc(self, volume, connector): <NEW_LINE> <INDENT> initiators = [fczm_utils.get_formatted_wwn(wwpn) for wwpn in connector['wwpns']] <NEW_LINE> eseries_vol = self._get_volume(volume['name_id']) <NEW_LINE> mapping = self.map_volume_to_host(volume, eseries_vol, initiators) <NEW_LINE> lun_id = mappi... | Initializes the connection and returns connection info.
Assigns the specified volume to a compute node/host so that it can be
used from that host.
The driver returns a driver_volume_type of 'fibre_channel'.
The target_wwn can be a single entry or a list of wwns that
correspond to the list of remote wwn(s) that will e... | 625941becad5886f8bd26eeb |
def do_render(self, gpsmap): <NEW_LINE> <INDENT> dummy_map = gpsmap | render the layer | 625941bea05bb46b383ec735 |
def get_updated_definition( func: Callable, traces: Iterable[CallTrace], max_typed_dict_size: int, rewriter: Optional[TypeRewriter] = None, existing_annotation_strategy: ExistingAnnotationStrategy = ExistingAnnotationStrategy.REPLICATE, ) -> FunctionDefinition: <NEW_LINE> <INDENT> if rewriter is None: <NEW_LINE> <INDEN... | Update the definition for func using the types collected in traces. | 625941be9f2886367277a7a1 |
def on_stop(self, func): <NEW_LINE> <INDENT> self._on_stop_funcs.append(func) | Register a cleanup function to be executed when the server stops | 625941be63d6d428bbe44401 |
def _get_clone_spec(self, datastore, disk_move_type, snapshot, backing, disk_type, host=None, resource_pool=None, extra_config=None, disks_to_clone=None): <NEW_LINE> <INDENT> if disk_type is not None: <NEW_LINE> <INDENT> disk_device = self._get_disk_device(backing) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> disk_dev... | Get the clone spec.
:param datastore: Reference to datastore
:param disk_move_type: Disk move type
:param snapshot: Reference to snapshot
:param backing: Source backing VM
:param disk_type: Disk type of clone
:param host: Target host
:param resource_pool: Target resource pool
:param extra_config: Key-value pairs to be... | 625941bea219f33f3462887e |
def set_create_time(self, *args, **kwargs): <NEW_LINE> <INDENT> if kwargs.get("start", None) and kwargs.get("end", None): <NEW_LINE> <INDENT> if kwargs.get("range", None): <NEW_LINE> <INDENT> raise ApiError("cannot specify range= in addition to start= and end=") <NEW_LINE> <DEDENT> stime = kwargs["start"] <NEW_LINE> if... | Restricts the alerts that this query is performed on to the specified
creation time (either specified as a start and end point or as a
range).
:return: This instance | 625941be1d351010ab855a2e |
def submissions(): <NEW_LINE> <INDENT> custom = False <NEW_LINE> atable = db.auth_user <NEW_LINE> cftable = db.custom_friend <NEW_LINE> handle = None <NEW_LINE> duplicates = [] <NEW_LINE> row = None <NEW_LINE> if len(request.args) < 1: <NEW_LINE> <INDENT> if auth.is_logged_in(): <NEW_LINE> <INDENT> user_id = session.us... | Retrieve submissions of a specific user | 625941be82261d6c526ab3ad |
@pytest.mark.parametrize( "text, expected", [ ( "Let's have URL http://janlipovsky.cz and a second URL https://example.com/@eon01/asdsd-dummy it's over.", [ ("http://janlipovsky.cz", (15, 36)), ("https://example.com/@eon01/asdsd-dummy", (54, 92)), ], ), ( "Some text www.company.com", [ ("www.company.com", (10, 25)), ],... | Testing find_urls returning only unique URLs
:param fixture urlextract: fixture holding URLExtract object
:param str text: text in which we should find links
:param list(str) expected: list of URLs that has to be found in text | 625941be0383005118ecf4f6 |
def _valueToPos(self, value): <NEW_LINE> <INDENT> if self.vertical: <NEW_LINE> <INDENT> return scale(value, (self.min(), self.max()), (0, self.height() - self._splitter.handleWidth() * 2)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return scale(value, (self.min(), self.max()), (0, self.width() - self._splitter.handl... | converts slider value to local pixel x coord | 625941beff9c53063f47c106 |
def update_metric(self, eval_metric, labels): <NEW_LINE> <INDENT> raise NotImplementedError() | Evaluates and accumulates evaluation metric on outputs of the last forward
computation.
Parameters
----------
eval_metric : EvalMetric
Evaluation metric to use.
labels : list of NDArray
Typically `data_batch.label`.
Examples
--------
An example of updating evaluation metric::
>>> mod.forward(data_batch)
... | 625941be046cf37aa974cc5b |
def fit_transform(self, raw_documents, y=None): <NEW_LINE> <INDENT> if not self.fit_vocabulary: <NEW_LINE> <INDENT> return self.transform(raw_documents) <NEW_LINE> <DEDENT> term_counts_per_doc = [] <NEW_LINE> term_counts = Counter() <NEW_LINE> document_counts = Counter() <NEW_LINE> max_df = self.max_df <NEW_LINE> max_f... | Learn the vocabulary dictionary and return the count vectors
This is more efficient than calling fit followed by transform.
Parameters
----------
raw_documents: iterable
an iterable which yields either str, unicode or file objects
Returns
-------
vectors: array, [n_samples, n_features] | 625941be099cdd3c635f0b6e |
def create_fake_import(module_name): <NEW_LINE> <INDENT> def fake_import(name, *args, **kwargs): <NEW_LINE> <INDENT> if name == module_name: <NEW_LINE> <INDENT> raise ImportError('mocked import Error for module %s' % name) <NEW_LINE> <DEDENT> return real_import(name, *args, **kwargs) <NEW_LINE> <DEDENT> return fake_imp... | Create a fake import function.
It raises ImportErorr for a given module name. | 625941be2ae34c7f2600d043 |
def tr(self, message): <NEW_LINE> <INDENT> return QCoreApplication.translate('AttributeTransfer', message) | Get the translation for a string using Qt translation API.
We implement this ourselves since we do not inherit QObject.
:param message: String for translation.
:type message: str, QString
:returns: Translated version of message.
:rtype: QString | 625941be009cb60464c632c5 |
def convertToIntArr(self): <NEW_LINE> <INDENT> return _MEDCoupling.DataArrayDouble_convertToIntArr(self) | convertToIntArr(self) -> DataArrayInt
1 | 625941be57b8e32f524833ab |
def draw_line(event): <NEW_LINE> <INDENT> end_point = find_closest_midpoint(event) <NEW_LINE> print ("end") <NEW_LINE> if end_point == start_point_list[0]: <NEW_LINE> <INDENT> raise ValueError("Start point and end point are equal.") <NEW_LINE> <DEDENT> end_point_list[0] = end_point <NEW_LINE> edges.append( tuple((start... | uses the starting point and the second point - which is indicated by
another click - to draw a line between those points | 625941be596a8972360899d5 |
def object_hook(self, obj): <NEW_LINE> <INDENT> if "__type__" in obj: <NEW_LINE> <INDENT> if obj["__type__"] == "complex": <NEW_LINE> <INDENT> val = obj["__value__"] <NEW_LINE> return val[0] + 1j * val[1] <NEW_LINE> <DEDENT> if obj["__type__"] == "array": <NEW_LINE> <INDENT> return np.array(obj["__value__"]) <NEW_LINE>... | Object hook. | 625941be99cbb53fe6792af9 |
def printpos(s, start, end, fill = 0): <NEW_LINE> <INDENT> fs = 10 <NEW_LINE> return "%s %s%s %s" % (s[start - fs:start], s[start:end], '-' * fill, s[end:end + fs]) | For debugging purposes. | 625941bed4950a0f3b08c262 |
def exists(url): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> resp = requests.get(url.geturl()) <NEW_LINE> <DEDENT> except InvalidSchema as e: <NEW_LINE> <INDENT> raise URLError(e) <NEW_LINE> <DEDENT> return resp.status_code < 400 | Check the existence of a resource.
Args:
url: (urlparse.SplitResult) Resource locator
Returns:
(Bool): True if resource is accessible | 625941be3eb6a72ae02ec3e7 |
def zone_sm_reconfig_schedule(db_session, zone_sm, zone_sm_event=None, randomize=False, master_reconfig=False, **kwargs): <NEW_LINE> <INDENT> master_sm = get_master_sm(db_session) <NEW_LINE> coalesce_time = timedelta(seconds=3*float(settings['sleep_time'])) <NEW_LINE> delay_secs = 6*float(settings['sleep_time']) <NEW_L... | Schedule MasterSM zone creation/update events
Zone SM helper function | 625941bed164cc6175782c5f |
def _check_ur(self): <NEW_LINE> <INDENT> return self.turn == self.board[0][2] == self.board[1][1] == self.board[2][0] | Assures all values in upper-right diagonal are winning or not | 625941be92d797404e30409b |
def getPathForOID(self, oid, create=False): <NEW_LINE> <INDENT> if isinstance(oid, int): <NEW_LINE> <INDENT> oid = utils.p64(oid) <NEW_LINE> <DEDENT> path = self.layout.oid_to_path(oid) <NEW_LINE> path = os.path.join(self.base_dir, path) <NEW_LINE> if create and not os.path.exists(path): <NEW_LINE> <INDENT> try: <NEW_L... | Given an OID, return the path on the filesystem where
the blob data relating to that OID is stored.
If the create flag is given, the path is also created if it didn't
exist already. | 625941bebaa26c4b54cb1034 |
def frequencySort2(self, s: str) -> str: <NEW_LINE> <INDENT> return ''.join(c * f for c, f in Counter(s).most_common()) | Pure python function. | 625941be8e7ae83300e4aede |
def get_report_file(x, amazon_report_id): <NEW_LINE> <INDENT> report = try_or_sleep(x.get_report)(report_id=bytes(str(amazon_report_id), CODING)) <NEW_LINE> text = report.response.text <NEW_LINE> return text_to_df(text, report.response.encoding) | Get report and convert it to DF. | 625941be5f7d997b871749a6 |
def allocate(self, host_type): <NEW_LINE> <INDENT> server_number = 1 <NEW_LINE> if host_type in self.hosts: <NEW_LINE> <INDENT> server_number = self._next_server_number(self.hosts[host_type]) <NEW_LINE> self.hosts[host_type].append(server_number) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.hosts[host_type] = [se... | Reserve and return the next available hostname | 625941be3346ee7daa2b2c7b |
def pause(start_time, action_period): <NEW_LINE> <INDENT> tsleep = start_time + action_period - time() <NEW_LINE> if tsleep > 0: <NEW_LINE> <INDENT> sleep(tsleep) | Sleep untill next action period | 625941bed4950a0f3b08c263 |
def load_h5(fname): <NEW_LINE> <INDENT> f = h5py.File(fname) <NEW_LINE> data = dict() <NEW_LINE> for k in f.keys(): <NEW_LINE> <INDENT> data[k] = f[k][:] <NEW_LINE> <DEDENT> return data | load .h5 file and return a dict | 625941bea05bb46b383ec736 |
@register.simple_tag(takes_context=True) <NEW_LINE> def url_replace(context, **kwargs): <NEW_LINE> <INDENT> query = context['request'].GET.dict() <NEW_LINE> query.update(kwargs) <NEW_LINE> return urlencode(query) | will append kwargs to the existing url
ie: assuming the current url is '/home/?foo=bar'
<a href="?{% url_replace page=1 %}">Next</a>
rendered html:
<a href="/home/?foo=bar&page=1">Next</a> | 625941be6fb2d068a760efac |
@tf_export('cos') <NEW_LINE> def cos(x, name=None): <NEW_LINE> <INDENT> _ctx = _context.context() <NEW_LINE> if not _ctx.executing_eagerly(): <NEW_LINE> <INDENT> _, _, _op = _op_def_lib._apply_op_helper( "Cos", x=x, name=name) <NEW_LINE> _result = _op.outputs[:] <NEW_LINE> _inputs_flat = _op.inputs <NEW_LINE> _attrs = ... | Computes cos of x element-wise.
Args:
x: A `Tensor`. Must be one of the following types: `half`, `bfloat16`, `float32`, `float64`, `complex64`, `complex128`.
name: A name for the operation (optional).
Returns:
A `Tensor`. Has the same type as `x`. | 625941bec4546d3d9de72943 |
def load_jpeg(self): <NEW_LINE> <INDENT> return self.video._video_zip.open(self.video._frame_name[self.index]).read() | Loads and returns the frame as compressed jpeg data. | 625941be167d2b6e31218aa8 |
def CheckForCopyright(filename, lines, error): <NEW_LINE> <INDENT> for line in xrange(1, min(len(lines), 11)): <NEW_LINE> <INDENT> if re.search(r'Copyright', lines[line], re.I): break <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> error(filename, 1, 'legal/copyright', 5, 'No copyright, suggest: "Copyright (c) %d, The To... | Logs an error if no Copyright message appears at the top of the file. | 625941beaad79263cf39094f |
def __init__(self, entry, feed=None): <NEW_LINE> <INDENT> self.feed = feed <NEW_LINE> self.post = entry | Entry is expected to be the dictionary object from a FeedSync
After wrangling, it will become a models.Post object. | 625941be0a366e3fb873e729 |
def test_04a_validate_optional_description_missing(self): <NEW_LINE> <INDENT> info, _ = self._load_feed_file() <NEW_LINE> del info['reports'][0]['description'] <NEW_LINE> cr = CbReport(**info['reports'][0]) <NEW_LINE> assert 'description' not in cr.data | Verify that description is optional and not required. | 625941be4e696a04525c935e |
def __init__(self, path): <NEW_LINE> <INDENT> self._properties = {} <NEW_LINE> if not os.path.isfile(path): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> for line in open(path): <NEW_LINE> <INDENT> matchobj = re.match(r'(\w+)=(.*)', line.strip()) <NEW_LINE> if matchobj: <NEW_LINE> <INDENT> var = matchobj.group(1) <NEW... | Parses a version definition file.
Args:
path: A filename which has the version definition.
If the file is not existent, empty properties are prepared instead. | 625941be0c0af96317bb80fa |
def pythonify(filelist: List[str], arguments: List[str] = []) -> None: <NEW_LINE> <INDENT> if not isinstance(filelist, list): <NEW_LINE> <INDENT> raise ValueError("First argument must be a list") <NEW_LINE> <DEDENT> options, args = parse_args(arguments) <NEW_LINE> options.full = True <NEW_LINE> execute(options, filelis... | Convert to python the files included in the list. | 625941be26238365f5f0ed7c |
def extract_email_features(email_task): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> task_input_information = json.loads(email_task.task_input) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> log.error("Could not parse task input as valid json; task input: %s", email_task.task_input) <NEW_LINE> return email_... | From the given task, extract email content information
Expects that the given task has the following attributes:
* task_input (dict containing email_id)
* task_output (optional, dict containing total emails sent)
* requester, the user who executed the task
With this information, gets the corresponding email object fr... | 625941be23849d37ff7b2fa2 |
def GetFannedVRad(): <NEW_LINE> <INDENT> vrad = np.array([ 289.9, 287.2, 271.4, 318.2, 236.6, 258.6]) <NEW_LINE> return vrad | GetFannedVRad:
Returns the radial velocity of the Ophiuchus Stream members identified as
fanned candidates by Sesar et al. (2016).
Args: None
Returns:
vrad (array) | 625941be4d74a7450ccd40d5 |
def clean(self): <NEW_LINE> <INDENT> data = self.data <NEW_LINE> phone = data.get('phone') <NEW_LINE> password = data.get('password') <NEW_LINE> if password not in cache.get(u'pwds_{}'.format(phone), []): <NEW_LINE> <INDENT> raise forms.ValidationError(u'动态密码错误') <NEW_LINE> <DEDENT> return data | Check phone and password | 625941be4e4d5625662d42ed |
def shownChanged(self, boardview, shown): <NEW_LINE> <INDENT> pass | Update the suggestions to match a changed position. | 625941becad5886f8bd26eec |
def maxProfit(self, prices): <NEW_LINE> <INDENT> lowest_price = sys.maxsize <NEW_LINE> largest_return = 0 <NEW_LINE> for i in prices: <NEW_LINE> <INDENT> if i < lowest_price: <NEW_LINE> <INDENT> lowest_price = i <NEW_LINE> <DEDENT> elif (i - lowest_price) > largest_return: <NEW_LINE> <INDENT> largest_return = i - lowes... | One pass. O(n)
:type prices: List[int]
:rtype: int | 625941bea8ecb033257d2fe0 |
def do_memstats(self, args): <NEW_LINE> <INDENT> self._exec_command(args, JERRY_DEBUGGER_MEMSTATS) <NEW_LINE> return | Memory statistics | 625941bea8370b77170527b3 |
def read_origin_destination(filename, separator=','): <NEW_LINE> <INDENT> origin_destination_list = [] <NEW_LINE> Log.add('Reading origin/destination statistics from file ...') <NEW_LINE> with open(filename, 'r') as f: <NEW_LINE> <INDENT> line = f.readline() <NEW_LINE> while line: <NEW_LINE> <INDENT> fields = line.rstr... | Reads origin/destination statistics from a csv file
with the following structure:
origin1,destination1,weight
origin2,destination2,weight
origin3,destination3,weight
Parameters
----------
filename: str
path to the file containing the origin/destination statistics
separator: str
arbitrary separation character ... | 625941be090684286d50ebf4 |
def tstheng(next, qiang): <NEW_LINE> <INDENT> global a, b, c, d <NEW_LINE> if (a - next % a) < c or (b - next // a) < d: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> for k in range(c): <NEW_LINE> <INDENT> if qiang[next + k] != 0: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> for... | 检查下一块砖能不能横着铺 | 625941be7d43ff24873a2bb0 |
def _may_send_newlines(self, con): <NEW_LINE> <INDENT> scnt = 0 <NEW_LINE> netok = True <NEW_LINE> try: <NEW_LINE> <INDENT> ppos = self.get_sent_pos(con) <NEW_LINE> it_lines = self.select_lines_to_send(con, ppos) <NEW_LINE> scnt, pos = self.send_new_lines(con, it_lines) <NEW_LINE> if scnt > 0: <NEW_LINE> <INDENT> self.... | Send new lines if there are ones content with additional conditions.
Note:
Conditions are over last position & no duplicates
Args:
con(DBConnector): DB connection
Returns:
int: Count of sent lines
netok: True if sending causes no network problem. | 625941be046cf37aa974cc5c |
def automaton_copy( s :int, g :Automaton, g_dup :Automaton, pmap_vrelevant :ReadPropertyMap = None, pmap_erelevant :ReadPropertyMap = None, pmap_vertices :ReadWritePropertyMap = None, pmap_edges :ReadWritePropertyMap = None, callback_dup_vertex ... | Copy a sub-graph from an Automaton according to an edge-based filtering
starting from a given source node.
Args:
s: The VertexDescriptor of the source node.
g: An Automaton instance.
pmap_vrelevant: A ReadPropertyMap{VertexDescriptor : bool} which indicates
for each vertex whether if it must be dupe... | 625941be925a0f43d2549d86 |
def get( self, resource_group_name, network_watcher_name, **kwargs ): <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } <NEW_LINE> error_map.update(kwargs.pop('error_map', {})) <NEW_LINE> api_version = "2020-... | Gets the specified network watcher by resource group.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param network_watcher_name: The name of the network watcher.
:type network_watcher_name: str
:keyword callable cls: A custom type or function that will be passed the direct ... | 625941be50485f2cf553ccaa |
def get_data(self): <NEW_LINE> <INDENT> self._init() <NEW_LINE> if not self._measured: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> def abs_file_dict(d): <NEW_LINE> <INDENT> return dict((abs_file(k), v) for k,v in iitems(d)) <NEW_LINE> <DEDENT> self.data.add_lines(abs_file_dict(self.collector.get_line_data())) <NEW_L... | Get the collected data and reset the collector.
Also warn about various problems collecting data.
Returns:
:class:`CoverageData`: the collected coverage data. | 625941be71ff763f4b549599 |
def add_bounds_for_categorical(self, bounds_arr): <NEW_LINE> <INDENT> for param in self.hyperparams: <NEW_LINE> <INDENT> if param.param_type == 'categorical': <NEW_LINE> <INDENT> lower = np.zeros(len(param.possible_values)) <NEW_LINE> upper = np.ones(len(param.possible_values)) <NEW_LINE> bounds_arr = np.concatenate([b... | not used | 625941be711fe17d82542283 |
def select_label_sequentially(self, k_labels, label_scores, label_models): <NEW_LINE> <INDENT> n_topics = label_scores.shape[0] <NEW_LINE> chosen_labels = [] <NEW_LINE> for _ in xrange(n_topics): <NEW_LINE> <INDENT> chosen_labels.append(list()) <NEW_LINE> <DEDENT> for i in xrange(n_topics): <NEW_LINE> <INDENT> for j in... | Return:
------------
list<list<int>>: shape n_topics x k_labels | 625941be7047854f462a131e |
def most_similar_to_given(model, average, given): <NEW_LINE> <INDENT> minimum = (float('inf'), None) <NEW_LINE> distances = model.wv.distances(average, given) <NEW_LINE> for i, w in enumerate(distances): <NEW_LINE> <INDENT> if distances[i] < minimum[0]: <NEW_LINE> <INDENT> minimum = (distances[i], given[i]) <NEW_LINE> ... | Finds the most similar word from the set of words
to the average word
average : a word VECTOR that represents the average of several words
given : a set of words to compare the average word to
Returns the word in given closest to the average word | 625941be50485f2cf553ccab |
def test_decorator(self): <NEW_LINE> <INDENT> class Resource(object): <NEW_LINE> <INDENT> @guard.guard(make_checker(True)) <NEW_LINE> def allowed(self, request): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> @guard.guard(make_checker(False)) <NEW_LINE> def denied(self, request): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDE... | Check the decorator is passing or failing in the correct manner. | 625941bebe383301e01b539e |
def select_filters(filters, level): <NEW_LINE> <INDENT> return [f for f in filters if f.max_debug_level is None or cmp_debug_levels(level, f.max_debug_level) <= 0] | Return from the list in ``filters`` those filters which indicate that
they should run for the given debug level. | 625941beb7558d58953c4e2b |
def run_test(self, redant): <NEW_LINE> <INDENT> vol_option = {'cluster.server-quorum-type': 'server'} <NEW_LINE> redant.set_volume_options(self.vol_name, vol_option, self.server_list[0]) <NEW_LINE> brick_list = redant.get_all_bricks(self.vol_name, self.server_list[0]) <NEW_LINE> redant.stop_glusterd(self.server_list[1:... | Test Brick status when Quorum is not met after glusterd restart.
1. Create a volume and mount it.
2. Set the quorum type to 'server'.
3. Bring some nodes down such that quorum won't be met.
4. Brick status should be offline in the node which is up.
5. Restart glusterd in this node.
6. The brick status still should be o... | 625941be73bcbd0ca4b2bf89 |
def respondToHead(self, trans): <NEW_LINE> <INDENT> res = trans.response() <NEW_LINE> w = res.write <NEW_LINE> res.write = lambda *args: None <NEW_LINE> self.respondToGet(trans) <NEW_LINE> res.write = w | Respond to a HEAD request.
A correct but inefficient implementation. | 625941be7b180e01f3dc4715 |
def test_make_macro(self): <NEW_LINE> <INDENT> macro, body = self.create_random_instance(return_body=True) <NEW_LINE> self.assertEqual(body, macro.body) | Test creating a macro and checking its parameters. The base class
will already do part of this test but will not check parameters. | 625941be796e427e537b04d6 |
def batch_normalization(x, mean, std, beta, gamma, epsilon=0.0001): <NEW_LINE> <INDENT> return tf.nn.batch_normalization(x, mean, std, beta, gamma, epsilon) | Apply batch normalization on x given mean, std, beta and gamma.
| 625941be4a966d76dd550f1f |
def to_openbabel(self): <NEW_LINE> <INDENT> obmol = cclib.bridge.makeopenbabel( self.atomcoords, self.atomnos, self.charge, self.mult ) <NEW_LINE> obmol.SetTitle(self.name) <NEW_LINE> return obmol | Return a OBMol. | 625941be23e79379d52ee479 |
@utils.supported_filters() <NEW_LINE> @check_user_admin_or_owner() <NEW_LINE> @database.run_in_session() <NEW_LINE> @utils.wrap_to_dict(RESP_FIELDS) <NEW_LINE> def get_user( user_id, exception_when_missing=True, user=None, session=None, **kwargs ): <NEW_LINE> <INDENT> return utils.get_db_object( session, models.User, e... | get field dict of a user. | 625941be8e71fb1e9831d6bd |
def get_own_set_attribute(self, node, set_name, attr_name): <NEW_LINE> <INDENT> return self._send({'name': 'getOwnSetAttribute', 'args': [node, set_name, attr_name]}) | Get the value of the attribute entry specifically set for the set at the node.
:param node: the owner of the set.
:type node: dict
:param set_name: the name of the set.
:type set_name: str
:param attr_name: the name of the attribute entry.
:type attr_name: str
:returns: Return the value of the attribute. If it is unde... | 625941be9c8ee82313fbb687 |
def test_toggle_call_recording_neutral(self): <NEW_LINE> <INDENT> estimated_response_json = { 'recording_enabled': 'wildcard', } <NEW_LINE> client = get_client() <NEW_LINE> with patch.object(client, 'get_call', return_value=estimated_response_json) as get_mock: <NEW_LINE> <INDENT> client.toggle_call_recording('callId')... | toggle_call_recording() should call get_call with the id | 625941bed164cc6175782c60 |
def __init__(self): <NEW_LINE> <INDENT> self.InvokerTDid = None | :param InvokerTDid: 凭证did
:type InvokerTDid: str | 625941bed486a94d0b98e057 |
def show_vcs_output_vcs_nodes_vcs_node_info_manufacturer_name(self, **kwargs): <NEW_LINE> <INDENT> config = ET.Element("config") <NEW_LINE> show_vcs = ET.Element("show_vcs") <NEW_LINE> config = show_vcs <NEW_LINE> if kwargs.pop('delete_show_vcs', False) is True: <NEW_LINE> <INDENT> delete_show_vcs = config.find('.//*sh... | Auto Generated Code
| 625941be99fddb7c1c9de2a5 |
def rule_text(self): <NEW_LINE> <INDENT> if self.debug: <NEW_LINE> <INDENT> print('rule_text' + lineno()) <NEW_LINE> <DEDENT> return 'S3 bucket does not have the required tags of Name, ResourceOwner, DeployedBy, Project' | Returns rule text
:return: | 625941be498bea3a759b99c2 |
def __init__(self, decorations=None, time=None, value=None, local_vars_configuration=None): <NEW_LINE> <INDENT> if local_vars_configuration is None: <NEW_LINE> <INDENT> local_vars_configuration = Configuration() <NEW_LINE> <DEDENT> self.local_vars_configuration = local_vars_configuration <NEW_LINE> self._decorations = ... | VehicleStatsAmbientAirTempMilliCWithDecoration - a model defined in OpenAPI | 625941befbf16365ca6f60d1 |
def test_invalid_product(self): <NEW_LINE> <INDENT> self.basket.addProduct("TTT", 2) <NEW_LINE> total = self.basket.getFinalAmount("BOGO50") <NEW_LINE> self.assertRaises(ValueError("Product is not available")) | Test Validation | 625941becdde0d52a9e52f43 |
def test_annotate_default_action_sub_default_group_default_iob_annotation_empty_in_data(self): <NEW_LINE> <INDENT> pattern = 'pos~"NN.?"' <NEW_LINE> annotation = [] <NEW_LINE> data = [ {'raw':'Over', 'pos':'IN'}, {'raw':'a', 'pos':'DT' }, {'raw':'cup', 'pos':'NN' }, {'raw':'of', 'pos':'IN'}, {'raw':'coffee', 'pos':'NN'... | Test annotate method on step with default args namely sub action, zero group and iob False. The annotation is empty. The pattern is present in the data. | 625941be2c8b7c6e89b356d5 |
def RetrieveOrgUnit(self, customer_id, org_unit_path): <NEW_LINE> <INDENT> uri = UNIT_URL % (customer_id, org_unit_path) <NEW_LINE> return self._GetProperties(uri) | Retrieve a Orgunit based on its path.
Args:
customer_id: The ID of the Google Apps customer.
org_unit_path: The organization's full path name.
Note: Each element of the path MUST be URL encoded (example: finance%2Forganization/suborganization)
Returns:
A dict containing the result of the retrie... | 625941be4f6381625f114950 |
def get_call_type_with_literals(self, context, args, kws, literals): <NEW_LINE> <INDENT> return self.get_call_type(context, args, kws) | Simliar to .get_call_type() but with extra argument for literals.
Default implementation ignores literals and forwards to .get_call_type(). | 625941be6fece00bbac2d64f |
def group_install(name=None, groups=None, skip=None, include=None, **kwargs): <NEW_LINE> <INDENT> pkg_groups = [] <NEW_LINE> if groups: <NEW_LINE> <INDENT> pkg_groups = yaml.safe_load(groups) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> pkg_groups.append(name) <NEW_LINE> <DEDENT> skip_pkgs = [] <NEW_LINE> if skip: <NE... | Install the passed package group(s). This is basically a wrapper around
pkg.install, which performs package group resolution for the user. This
function is currently considered "experimental", and should be expected to
undergo changes before it becomes official.
name
The name of a single package group to install. ... | 625941be29b78933be1e55c3 |
def __call__(self): <NEW_LINE> <INDENT> self.page1() <NEW_LINE> grinder.sleep(2117) <NEW_LINE> self.page2() <NEW_LINE> grinder.sleep(1867) <NEW_LINE> self.page3() <NEW_LINE> grinder.sleep(4351) <NEW_LINE> self.page4() <NEW_LINE> grinder.sleep(16341) <NEW_LINE> self.page5() <NEW_LINE> grinder.sleep(1309) <NEW_LINE> self... | Called for every run performed by the worker thread. | 625941bed6c5a10208143f5b |
def test_new_accessions_2(self): <NEW_LINE> <INDENT> os.chdir('test_new_accessions_2') <NEW_LINE> ref_acc = ['E-GEOD-42314'] <NEW_LINE> test_acc = new_accessions() <NEW_LINE> os.chdir('..') <NEW_LINE> self.assertEqual(ref_acc, test_acc) | Is the list of new accessions correctly generated for two json files? | 625941be091ae35668666e76 |
def _find_items(self, bill_lines): <NEW_LINE> <INDENT> items = [] <NEW_LINE> skip_line = False <NEW_LINE> for line_index in range(len(bill_lines)): <NEW_LINE> <INDENT> if skip_line: <NEW_LINE> <INDENT> logger.debug( 'Skipped line %s ' 'Used to build previous item' % bill_lines[line_index]) <NEW_LINE>... | Find items of the bill.
Returns list of items in format:
[
{
'name': 'item-name [string]',
'quantity': 'item-quantity [int]',
'amount': 'item-amount [float]'
}
] | 625941be1b99ca400220a9c3 |
def list_tasks(self, owner=None): <NEW_LINE> <INDENT> if owner is None: <NEW_LINE> <INDENT> all = self._db.task_list.find() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> all = self._db.task_list.find({'owner': owner}) <NEW_LINE> <DEDENT> for task_dict in all: <NEW_LINE> <INDENT> task_dict['id'] = task_dict.pop('_id') <... | Return list of tasks. | 625941be6e29344779a62527 |
def slh(n,s,maxiter = 0): <NEW_LINE> <INDENT> if maxiter == 0: <NEW_LINE> <INDENT> return SymmetricLatinHypercubeDesign(n,s) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return SymmetricLatinHypercubeDesignDecorrelation(n,s,maxiter) | short name of SymmetricLatinHypercubeDesign | 625941be596a8972360899d6 |
def SIRT_CPU(projections, volume, geometry, iterations=10, relaxation=1,options = {'poisson_weight': False, 'l2_update': True, 'preview':False, 'bounds':None}, psf=None): <NEW_LINE> <INDENT> if not isinstance(projections, numpy.memmap): <NEW_LINE> <INDENT> projections = numpy.ascontiguousarray(projections) <NEW_LINE> <... | SIRT on CPU with or without detector PSF | 625941be377c676e912720bc |
def __setitem__(self, xy, item): <NEW_LINE> <INDENT> x, y = xy <NEW_LINE> self.level_map[y][x] = item | x (col) and y (row) position of char to set. (x and y start with 0) | 625941bea934411ee37515a6 |
def addFactionsFromXML(self, factionRoots) -> None: <NEW_LINE> <INDENT> for factionRoot in factionRoots: <NEW_LINE> <INDENT> factionNames = self.__xml.getNamesFromXML(factionRoot) <NEW_LINE> for name in factionNames: <NEW_LINE> <INDENT> newfaction = Faction(name) <NEW_LINE> self.repository.addFaction(newfaction) | Takes a list of Faction GameObject XML roots and adds
them to the repository | 625941be23849d37ff7b2fa3 |
def my_first_name(): <NEW_LINE> <INDENT> return 'Alexandra' | Return your first name as a string.
>>> my_first_name() != 'PUT YOUR FIRST NAME HERE'
True | 625941be656771135c3eb77f |
def bwCmds( self, bw=None, speedup=0, use_hfsc=False, use_tbf=False): <NEW_LINE> <INDENT> cmds, parent = [], ' root ' <NEW_LINE> if bw and ( bw < 0 or bw > 1000 ): <NEW_LINE> <INDENT> error( 'Bandwidth', bw, 'is outside range 0..1000 Mbps\n' ) <NEW_LINE> <DEDENT> elif bw is not None: <NEW_LINE> <INDENT> if ( speedup > ... | Return tc commands to set bandwidth | 625941bef548e778e58cd48f |
def pauseScreen(mode,score,limit,lev,fClick,ybo,p,st,sc,pc): <NEW_LINE> <INDENT> if click==True and pauseMenu.collidepoint(mx,my): <NEW_LINE> <INDENT> restart() <NEW_LINE> return "menu",0,0,1,0,300,0,0,"pending",0 <NEW_LINE> <DEDENT> if click==True and pauseRetry.collidepoint(mx,my): <NEW_LINE> <INDENT> restart() <NEW_... | This function checks activity in the pause screen, if menu is clicked then
the user goes to the menu, if they click restart they restart | 625941be4f88993c3716bf7e |
def __init__(self): <NEW_LINE> <INDENT> self.cnn_filter_num = 128 <NEW_LINE> self.cnn_first_filter_size = 5 <NEW_LINE> self.cnn_filter_size = 3 <NEW_LINE> self.res_layer_num = 7 <NEW_LINE> self.l2_reg = 1e-4 <NEW_LINE> self.value_fc_size = 256 <NEW_LINE> self.distributed = False <NEW_LINE> self.input_depth = 14 | WARNING: DO NOT CHANGE THESE PARAMETERS | 625941be7c178a314d6ef36d |
def get_max_joltage(inputs: list) -> int: <NEW_LINE> <INDENT> return max([int(i) for i in inputs]) | Retrieves max joltage from list of inputs. | 625941be7c178a314d6ef36e |
def _convertList(self, vector): <NEW_LINE> <INDENT> return ravel(vector).tolist() | Converts the incoming vector to a python list. | 625941bef7d966606f6a9f14 |
def _update_on_node(self, node, try_all=False): <NEW_LINE> <INDENT> if try_all is True and hasattr(node, 'update_all'): <NEW_LINE> <INDENT> node.update_all() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> node.update() | Call update/update_all on currently focused node. If try_all is
True update_all will be called if available but update will be used as
a fallback.
Args:
node: urwid.TreeNode to call function on.
try_all (optional): bool to try calling update_all before update. | 625941be3d592f4c4ed1cf88 |
def accidentesSize(analyzer): <NEW_LINE> <INDENT> return lt.size(analyzer['accidentes']) | Número de accidentes leidos | 625941be45492302aab5e1d3 |
def extract_encoder_weights(network, names, saveas): <NEW_LINE> <INDENT> layers = las.layers.get_all_layers(network) <NEW_LINE> d = {} <NEW_LINE> for i, name in enumerate(names): <NEW_LINE> <INDENT> for l in layers: <NEW_LINE> <INDENT> if l.name == name: <NEW_LINE> <INDENT> weight = l.W.container.data <NEW_LINE> bias =... | extract encoder weights of the given model
:param network: trained model
:param names: names of layer weights to extract
:param saveas: names to save to in a list of tuples [(weight name, bias name), ...]
:return: dictionary containing weights and biases of the encoding layers | 625941be21bff66bcd684868 |
def _create_client(self, clt_class, url, public=True): <NEW_LINE> <INDENT> verify_ssl = pyrax.get_setting("verify_ssl") <NEW_LINE> if self.service == "object_store": <NEW_LINE> <INDENT> client = pyrax.connect_to_cloudfiles(region=self.region, public=public, context=self.identity) <NEW_LINE> <DEDENT> elif self.service =... | Creates a client instance for the service. | 625941beec188e330fd5a6b7 |
def _get_patchset_revs(args, srctree, recipe_path): <NEW_LINE> <INDENT> import bb <NEW_LINE> if args.initial_rev: <NEW_LINE> <INDENT> return args.initial_rev, args.initial_rev <NEW_LINE> <DEDENT> commits = [] <NEW_LINE> initial_rev = None <NEW_LINE> with open(recipe_path, 'r') as f: <NEW_LINE> <INDENT> for line in f: <... | Get initial and update rev of a recipe. These are the start point of the
whole patchset and start point for the patches to be re-generated/updated. | 625941bee64d504609d74753 |
def create_preset_images(self): <NEW_LINE> <INDENT> for f in self.get_files_from_data(): <NEW_LINE> <INDENT> photoInstances = {} <NEW_LINE> for preset in self.generator.settings["GALLERY_PRESETS"]: <NEW_LINE> <INDENT> preset_dir = "%s%s%s" % (self.absolute_output_path, os.sep, preset["name"]) <NEW_LINE> photoInstances[... | Creates the image assets for each preset and returns a PhotoSet object | 625941beb545ff76a8913d29 |
def test_selinux_enforcing(selinux_getenforce): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> assert selinux_getenforce == "Enforcing" <NEW_LINE> <DEDENT> except AssertionError: <NEW_LINE> <INDENT> pytest.fail(msg="SELinux is not in Enforcing mode!") | Verifies whether SELinux is in 'Enforcing' state.
:param selinux_getenforce: Current enforcing status
:type selinux_getenforce: ``str``
:raises: pytest.Failed | 625941bee76e3b2f99f3a729 |
def save(self, file_name): <NEW_LINE> <INDENT> print('Saving model to: {0}'.format(file_name)) <NEW_LINE> if self.layer == 1: <NEW_LINE> <INDENT> with open(file_name, 'wb') as f: <NEW_LINE> <INDENT> pickle.dump(self.W, f) <NEW_LINE> pickle.dump(self.W2, f) <NEW_LINE> pickle.dump(self.W3, f) <NEW_LINE> pickle.dump(self.... | Function to save all main parameters | 625941be56b00c62f0f1456b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.