code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def find_task(self, name: str) -> Optional['Task']: <NEW_LINE> <INDENT> return next((p for p in self._tasks if p.name == name), None) | find task with given name. | 625941bcf8510a7c17cf95d7 |
def fullJustify(self, words, maxWidth): <NEW_LINE> <INDENT> res = [] <NEW_LINE> row = [] <NEW_LINE> cur_len = 0 <NEW_LINE> n = len(words) <NEW_LINE> for wi in xrange(n): <NEW_LINE> <INDENT> word = words[wi] <NEW_LINE> if len(word)>maxWidth: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> cur_len += (0 if cur_len == 0 els... | :type words: List[str]
:type maxWidth: int
:rtype: List[str] | 625941bccb5e8a47e48b798a |
def make_link(cfgdict, nodea, nodeb): <NEW_LINE> <INDENT> stdlink = { "delay": "43ms", "capacity": "1Gb", "weight": 10 } <NEW_LINE> sourceidx = get_nodeindex(cfgdict, nodea) <NEW_LINE> targetidx = get_nodeindex(cfgdict, nodeb) <NEW_LINE> stdlink["source"] = sourceidx <NEW_LINE> stdlink["target"] = targetidx <NEW_LINE> ... | Make a new link from nodea to nodeb and add it to configuration | 625941bc0c0af96317bb80c5 |
def test_LeafBondSelector_constructor(self): <NEW_LINE> <INDENT> leafBndSel = LeafBondSelector() <NEW_LINE> self.assertEqual( leafBndSel.__class__, LeafBondSelector) | test LeafBond constructor | 625941bc10dbd63aa1bd2a83 |
def GetReplicationControllers(self, namespace=None): <NEW_LINE> <INDENT> if namespace: <NEW_LINE> <INDENT> url = ('%(base_url)s/namespaces/%(ns)s/replicationcontrollers' % {"base_url":self.base_url, "ns":namespace}) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> url = '%s/replicationcontrollers' % self.base_url <NEW_LIN... | List all replicationcontrollers on this cluster | 625941bc56b00c62f0f14534 |
def check_interrupt(self): <NEW_LINE> <INDENT> if not self._interrupted: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self.before_interrupt() <NEW_LINE> raise TaskInterruption | Checks if this task was marked interrupted. If yes, raise an Exception
to terminate the thread.
A good task should call this function frequently to avoid infinite
loop. | 625941bc4f88993c3716bf47 |
def cal_snr_weight(used_misfit_window, value1, value2): <NEW_LINE> <INDENT> value = used_misfit_window.snr_energy <NEW_LINE> weight = cal_cos_weight(value, value1, value2) <NEW_LINE> return weight | cal_snr_weight: use snr_energy to get a weight. | 625941bc5fc7496912cc385a |
def test_tags_can_be_added_to_photos(self): <NEW_LINE> <INDENT> user = User.objects.all()[0] <NEW_LINE> self.client.force_login(user) <NEW_LINE> photo_id = Photo.objects.all()[0].id <NEW_LINE> response = self.client.get(reverse( 'photo_edit', kwargs={'photo_id': photo_id}) ) <NEW_LINE> html = soup(response.rendered_con... | Test tags can be added to photos. | 625941bcfff4ab517eb2f316 |
def delete_inner_session(self): <NEW_LINE> <INDENT> self.token = None <NEW_LINE> return True | #====================================================================================
# @Method: 删除带内Session
# @Param:
# @Return:
# @author:
#==================================================================================== | 625941bc3346ee7daa2b2c46 |
def cb_alternative(self): <NEW_LINE> <INDENT> self.cb.action_getbufferlist() | Called when the detach button is clicked. | 625941bcd10714528d5ffbbd |
def hidden_layer(pooled, input_size, output_size): <NEW_LINE> <INDENT> with tf.name_scope("hidden"): <NEW_LINE> <INDENT> weights = tf.Variable( tf.truncated_normal( [input_size, output_size], stddev=1.0 / math.sqrt(input_size) ), name='weights' ) <NEW_LINE> init = tf.truncated_normal([output_size,], stddev=math.sqrt(2.... | Create a hidden feedforward layer. | 625941bc71ff763f4b549563 |
def test_list_ints(self): <NEW_LINE> <INDENT> assert duck.list_ints(1) == [1] <NEW_LINE> assert duck.list_ints([1]) == [1] <NEW_LINE> assert duck.list_ints([1, 2, 3]) == [1, 2, 3] | Testing list_ints. | 625941bc3eb6a72ae02ec3b1 |
def stop(self,req): <NEW_LINE> <INDENT> self.log_play() <NEW_LINE> self._stop() <NEW_LINE> req.auto=False <NEW_LINE> return self.redirect(req,"") | stop and clear the list | 625941bc26068e7796caebb6 |
def test_simple(self): <NEW_LINE> <INDENT> tbl = TextTable("%one") <NEW_LINE> tbl.append({'one': 'foo'}) <NEW_LINE> self.assertEqual(str(tbl), "ONE\n---\nfoo") | simple row | 625941bcadb09d7d5db6c66e |
def Size(self): <NEW_LINE> <INDENT> return _itkSamplePython.itkSampleVF3_Size(self) | Size(self) -> size_t | 625941bc85dfad0860c3ad36 |
def bootstrap_steady_perf(steady_segments_all_pexecs, confidence_level=CONFIDENCE_LEVEL, quality='HIGH'): <NEW_LINE> <INDENT> if quality.lower() == "high": <NEW_LINE> <INDENT> means = _bootstrap_means_highq(steady_segments_all_pexecs) <NEW_LINE> <DEDENT> elif quality.lower() == "low": <NEW_LINE> <INDENT> means = _boots... | This is not a general bootstrapping function.
Input is a list containing a list for each pexec, containing a list of
segments with iteration times. | 625941bcc4546d3d9de7290e |
def enable_internal_db(self, region=0, key_address=None, db_password=None, ssh_password=None, log_callback=None): <NEW_LINE> <INDENT> (log_callback or self.log.info)( 'Enabling internal DB (region {}) on {}.'.format(region, self.address)) <NEW_LINE> self.db_address = self.address <NEW_LINE> del(self.db) <NEW_LINE> clie... | Enables internal database
Args:
region: Region number of the CFME appliance.
key_address: Address of CFME appliance where key can be fetched.
Note:
If key_address is None, a new encryption key is generated for the appliance. | 625941bc26238365f5f0ed47 |
def rerank(self, hypotheses: Dict[str, Any], reference: str) -> Dict[str, Any]: <NEW_LINE> <INDENT> scores = [self.scoring_function(hypothesis, reference).score for hypothesis in hypotheses['translations']] <NEW_LINE> ranking = list(np.argsort(scores, kind='mergesort')[::-1]) <NEW_LINE> reranked_hypotheses = self._sort... | Reranks a set of hypotheses that belong to one single reference
translation. Uses stable sorting.
:param hypotheses: Nbest translations.
:param reference: A single string with the actual reference translation.
:return: Nbest translations sorted by reranking scores. | 625941bccdde0d52a9e52f0c |
def context_before(string, index, contextnum): <NEW_LINE> <INDENT> if contextnum < 0: <NEW_LINE> <INDENT> raise ValueError("Context amount cannot be negative") <NEW_LINE> <DEDENT> bound = index - contextnum <NEW_LINE> if bound < 0: <NEW_LINE> <INDENT> bound = 0 <NEW_LINE> <DEDENT> return string[bound:index] | gets the specified number of characters before the given index,
or until the beginning of the string. | 625941bca934411ee3751577 |
def _run_length_encoding(x): <NEW_LINE> <INDENT> x = np.asarray(x) <NEW_LINE> assert x.ndim == 1, "run_length_encoding currently only supports 1D arrays" <NEW_LINE> changes = x[:-1] != x[1:] <NEW_LINE> changes_ix = np.where(changes)[0] + 1 <NEW_LINE> changes_from = np.concatenate(([int(not x[0])], x[changes_ix])) <NEW_... | from https://github.com/ornithos/pyalexutil/manipulate.py
For 1D array x, turn [0,0,0,0,1,1,1,1,0,1,1,1] into [0, 3, 7, 8],
[3, 4, 1, 4], [0, 1, 0, 1]
:param x:
:return: (indices of changes, length of runs, new number (assuming boolean). | 625941bc01c39578d7e74d18 |
def echange_banque(player_id=Player.current_player,liste_carte=[0,0,0,0,0]): <NEW_LINE> <INDENT> if (isinstance(liste_carte,list) and len(liste_carte) == 5): <NEW_LINE> <INDENT> if (min(liste_carte) == -4 and max(liste_carte) == 1 and sum(liste_carte) == -3): <NEW_LINE> <INDENT> for i, carte in enumerate(['wood','clay'... | Permet d'échanger ses cartes avec la banque
['wood','clay','sheep','wheat','stone']
Par exemple, si le joueur souhaite donner 4 bois et
recevoir 1 argile à la banque : [-4,1,0,0,0] | 625941bcd6c5a10208143f25 |
def getColumns(self, query): <NEW_LINE> <INDENT> return query.find('columns').text | Get columns | 625941bc1f037a2d8b9460db |
def test_pyquest_interactive_density_matrix(): <NEW_LINE> <INDENT> circuit = Circuit() <NEW_LINE> circuit += ops.DefinitionBit(name='out', length=2, is_output=True) <NEW_LINE> circuit += ops.DefinitionBit(name='out2', length=2, is_output=True) <NEW_LINE> circuit += ops.DefinitionBit(name='notout', length=2, is_output=... | Test with PyQuEST density matrix | 625941bc1b99ca400220a98d |
def getMarkerIcon(): <NEW_LINE> <INDENT> pass | Returns name of marker icon. Allowed values are defined
in maps_properties/map_markers property.
Method should return 'Red Marker' for example. | 625941bc4a966d76dd550ee9 |
def _next_character(self): <NEW_LINE> <INDENT> return self._file_stream.pop(0) | Get the next character in the file stream. | 625941bc4e4d5625662d42b9 |
def store(self): <NEW_LINE> <INDENT> tt = self.t%self.STIME <NEW_LINE> self.data[self.l_inp][:,tt] = self.inp <NEW_LINE> self.data[self.l_out][:,tt] = self.out <NEW_LINE> out = self.out_raw*2 <NEW_LINE> datax = self.data[self.l_out_raw] <NEW_LINE> win = self.idx | storage | 625941bc6fb2d068a760ef77 |
def setUp(self): <NEW_LINE> <INDENT> self.user = User("Fellow1", "[email protected]", "bootcampertofellow") <NEW_LINE> self.event1 = Event("Bootcamp", "Learning", "Uganda", "Andela", "Learning event for aspiring Andelans") <NEW_LINE> self.event2 = Event("Blaze", "Entrepreneurial", "Kenya", "Safariom", "This is is a gr... | Instantiating reusable variables | 625941bc1f037a2d8b9460dc |
def button_2_click(self, **event_args): <NEW_LINE> <INDENT> anvil.users.logout() <NEW_LINE> pagestack.clear() <NEW_LINE> app_tables.order_tmp2.delete_all_rows() <NEW_LINE> self.repeating_panel_1.items = app_tables.order_tmp2.search() <NEW_LINE> open_form('Query') | This method is called when the button is clicked | 625941bc6e29344779a624f1 |
def get_config(self): <NEW_LINE> <INDENT> return MCVirtConfig().get_config()[Factory.GROUP_CONFIG_KEY] | Return the configs for storage backends. | 625941bc2c8b7c6e89b3569f |
def test(self): <NEW_LINE> <INDENT> if self.__class__ is HarnessCase: <NEW_LINE> <INDENT> logger.warning('Skip this harness itself') <NEW_LINE> return <NEW_LINE> <DEDENT> logger.info('Testing role[%d] case[%s]', self.role, self.case) <NEW_LINE> try: <NEW_LINE> <INDENT> self._init_browser() <NEW_LINE> while True: <NEW_L... | This method will only start test case in child class | 625941bc23849d37ff7b2f6e |
def isValid(self, s): <NEW_LINE> <INDENT> if not s: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> stack = [] <NEW_LINE> com_dict = {'(':')', '[':']', '{':'}'} <NEW_LINE> for str_index in range(len(s)): <NEW_LINE> <INDENT> if s[str_index] in ['(', '[', '{']: <NEW_LINE> <INDENT> stack.append(s[str_index]) <NEW_LINE... | :type s: str
:rtype: bool | 625941bc3617ad0b5ed67dd5 |
def test_sentence(): <NEW_LINE> <INDENT> _sentence = None <NEW_LINE> for sentence in CoNLL.iter_string(CONLL_SENTENCE): <NEW_LINE> <INDENT> _sentence = sentence <NEW_LINE> <DEDENT> sentence_obj = Sentence(_sentence) <NEW_LINE> assert sentence_obj.meta_present("text") is True <NEW_LINE> assert sentence_obj.meta_value("t... | Test case | 625941bc462c4b4f79d1d5ad |
def update(version=None): <NEW_LINE> <INDENT> ret = {} <NEW_LINE> if not HAS_ESKY: <NEW_LINE> <INDENT> ret["_error"] = "Esky not available as import" <NEW_LINE> return ret <NEW_LINE> <DEDENT> if not getattr(sys, "frozen", False): <NEW_LINE> <INDENT> ret["_error"] = "Minion is not running an Esky build" <NEW_LINE> retur... | Update the salt minion from the URL defined in opts['update_url']
SaltStack, Inc provides the latest builds here:
update_url: https://repo.saltproject.io/windows/
Be aware that as of 2014-8-11 there's a bug in esky such that only the
latest version available in the update_url can be downloaded and installed.
This fea... | 625941bccad5886f8bd26ebf |
def _process_layer_uuid(self, uuid): <NEW_LINE> <INDENT> self._validate_uuid(uuid) <NEW_LINE> layer = None <NEW_LINE> try: <NEW_LINE> <INDENT> layer = Layer.retrieve(uuid) <NEW_LINE> <DEDENT> except InvalidRequestError: <NEW_LINE> <INDENT> raise ValueError( "UUID '{}' is not a Layer.".format(uuid)) <NEW_LINE> <DEDENT> ... | Validates uuid as a Layer UUID, and adds ELTs for that UUID to
self._elt_loss_sets | 625941bc50812a4eaa59c201 |
def transfer(self, from_acct: Account, b58_to_address: str, value: int, payer_acct: Account, gas_limit: int, gas_price: int) -> str: <NEW_LINE> <INDENT> func = self.__abi_info.get_function('transfer') <NEW_LINE> if not isinstance(value, int): <NEW_LINE> <INDENT> raise SDKException(ErrorCode.param_err('the data type of ... | This interface is used to call the Transfer method in ope4
that transfer an amount of tokens from one account to another account.
:param from_acct: an Account class that send the oep4 token.
:param b58_to_address: a base58 encode address that receive the oep4 token.
:param value: an int value that indicate the amount ... | 625941bcbe8e80087fb20b24 |
def __init__(self, k): <NEW_LINE> <INDENT> self.k = k | Class to manage all the evaluation methods and operation
:param data: dataset object
:param k: top-k evaluation | 625941bc8c0ade5d55d3e89c |
def infer(self, features, *args, **kwargs): <NEW_LINE> <INDENT> del args, kwargs <NEW_LINE> if "targets" not in features: <NEW_LINE> <INDENT> if "infer_targets" in features: <NEW_LINE> <INDENT> targets_shape = common_layers.shape_list(features["infer_targets"]) <NEW_LINE> <DEDENT> elif "inputs" in features: <NEW_LINE> ... | Produce predictions from the model by running it. | 625941bc3617ad0b5ed67dd6 |
def conv_gauss(img, kernel): <NEW_LINE> <INDENT> n_channels, _, kw, kh = kernel.shape <NEW_LINE> img = fnn.pad(img, (kw//2, kh//2, kw//2, kh//2), mode='replicate') <NEW_LINE> return fnn.conv2d(img, kernel, groups=n_channels) | convolve img with a gaussian kernel that has been built with build_gauss_kernel | 625941bc30dc7b7665901847 |
def _get_province(self): <NEW_LINE> <INDENT> province = self.address.province <NEW_LINE> if province: <NEW_LINE> <INDENT> return province <NEW_LINE> <DEDENT> return "" | Return province of main address | 625941bc090684286d50ebbf |
def delete_data_source(self, data_source, ignore_missing=True): <NEW_LINE> <INDENT> return self._delete(_ds.DataSource, data_source, ignore_missing=ignore_missing) | Delete a data_source
:param data_source: value can be the ID of a data_source or an instance
of :class:`~openstack.map_reduce.v1.data_source.DataSource`
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be raised when
the data_source does not exist.
... | 625941bca17c0f6771cbdf30 |
def __ne__(self, other) : <NEW_LINE> <INDENT> return not self.__eq__(other) | Rend le P1 != P2 fonctionnel | 625941bcad47b63b2c509e5e |
def __init__(self): <NEW_LINE> <INDENT> self.platformName = "Issuu" <NEW_LINE> self.tags = ["tools"] <NEW_LINE> self.isValidMode = {} <NEW_LINE> self.isValidMode["phonefy"] = False <NEW_LINE> self.isValidMode["usufy"] = True <NEW_LINE> self.isValidMode["searchfy"] = False <NEW_LINE> self.url = {} <NEW_LINE> self.url["u... | Constructor... | 625941bc283ffb24f3c557e9 |
def test_makefastqs_standard_protocol_bcl2fastq_2_17(self): <NEW_LINE> <INDENT> illumina_run = MockIlluminaRun( "171020_M00879_00002_AHGXXXX", "miseq", top_dir=self.wd) <NEW_LINE> illumina_run.create() <NEW_LINE> run_dir = illumina_run.dirn <NEW_LINE> sample_sheet = os.path.join(self.wd,"SampleSheet.csv") <NEW_LINE> wi... | MakeFastqs: standard protocol/bcl2fastq: use v2.17 | 625941bc01c39578d7e74d19 |
def say( self, verbosity, msg, channel = 1 ): <NEW_LINE> <INDENT> if self._verbosity >= verbosity: <NEW_LINE> <INDENT> self.write( self._preamble.format( **self.about ) + msg + '\n', channel ).flush() <NEW_LINE> <DEDENT> return self | if verbosity level met, write and flush message string msg to system channel {1,2} => (stdout, stderr).
Returns self. | 625941bc56ac1b37e62640b2 |
def to_python(self, value): <NEW_LINE> <INDENT> if not value: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if isinstance(value, list): <NEW_LINE> <INDENT> for index, position_val in enumerate(value): <NEW_LINE> <INDENT> val = super(MultipleDecimalField, self).to_python(position_val) <NEW_LINE> value[index] = val... | Validates that the input can be converted to a list of decimals. | 625941bc31939e2706e4cd4c |
def run_command(container, command): <NEW_LINE> <INDENT> return container.exec_run( cmd="bash -c \"" + command + "\"", tty=True, privileged=True) | Function that executes a command inside a container. | 625941bc2c8b7c6e89b356a0 |
def fetch(self, filter, **kwargs): <NEW_LINE> <INDENT> pass | To be implemented in final models
:param item:
:return: list with data
:raises: DataModelFetchError | 625941bce64d504609d7471e |
def start(self): <NEW_LINE> <INDENT> pygame.display.init() <NEW_LINE> self.screen = pygame.display.set_mode((640,400),0,8) <NEW_LINE> pygame.display.set_caption('Simple CPU Simulator framebuffer') <NEW_LINE> self.vga = vgaconsole.VGAConsole(self.screen) <NEW_LINE> self.cpu.mem.add_map(0xc, Framebuffer(self.vga.vgabuf))... | This will initialize the actual framebuffer device. | 625941bc7b180e01f3dc46e2 |
def __sub__(self, other): <NEW_LINE> <INDENT> if isinstance(other, Point): <NEW_LINE> <INDENT> return Point(self.x - other.x, self.y - other.y) <NEW_LINE> <DEDENT> return Point(self.x - other, self.y - other) | getter: (point1 , point2) substract 2 points and return the result | 625941bc4428ac0f6e5ba6cf |
def optionsStringWasSet(option, text, default=None): <NEW_LINE> <INDENT> if default is None: <NEW_LINE> <INDENT> return _to_tuple(PISM.cpp.OptionString(option, text, ""), False) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return _to_tuple(PISM.cpp.OptionString(option, text, default), True) | Determines if a string-valued command line option was set.
:param option: Name of command line option.
:param text: Description of option.
:param default: Default value if option was not set.
:returns: Tuple ``(value, wasSet)`` where ``value`` is the value that was set (or the ``default`` value if it was not)
... | 625941bc0a50d4780f666d6d |
def create_attention_mask_from_input_mask(from_tensor, to_mask): <NEW_LINE> <INDENT> from_shape = get_shape_list(from_tensor, expected_rank=[2, 3],name='') <NEW_LINE> batch_size = from_shape[0] <NEW_LINE> from_seq_length = from_shape[1] <NEW_LINE> to_shape = get_shape_list(to_mask, expected_rank=2,name='') <NEW_LINE> t... | Create 3D attention mask from a 2D tensor mask.
Args:
from_tensor: 2D or 3D Tensor of shape [batch_size, from_seq_length, ...].
to_mask: int32 Tensor of shape [batch_size, to_seq_length].
Returns:
float Tensor of shape [batch_size, from_seq_length, to_seq_length]. | 625941bc97e22403b379ce76 |
def get_current_moon_phase(): <NEW_LINE> <INDENT> moon_observer.date = datetime.now() <NEW_LINE> phase_end = ephem.next_new_moon(moon_observer.date) <NEW_LINE> phase_start = ephem.previous_new_moon(moon_observer.date) <NEW_LINE> phase = (moon_observer.date - phase_start) / (phase_end - phase_start) <NEW_LINE> phase *= ... | Get the current moon phase | 625941bc851cf427c661a3f0 |
def validate_layout(self, layout, expected_widgets, optional_widgets = set()): <NEW_LINE> <INDENT> next_visits = deque([layout]) <NEW_LINE> widget_seen = set() <NEW_LINE> while next_visits: <NEW_LINE> <INDENT> w_desc = next_visits.popleft() <NEW_LINE> if type(w_desc) is str: <NEW_LINE> <INDENT> if w_desc not in expecte... | Validate layout: check whether the layout of widgets built from the config string is valid.
Args:
layout (`dict`): the json-parsed config string
expected_widgets (`set`): strings with the names of widgets that have to be used in this layout
optional_widgets (`set`): strings with the names of widgets that ma... | 625941bcd4950a0f3b08c22f |
def create_schema(config=None, engine=None): <NEW_LINE> <INDENT> if engine is None: <NEW_LINE> <INDENT> engine = sqla_api.get_engine() <NEW_LINE> <DEDENT> if version(engine=engine) is not None: <NEW_LINE> <INDENT> raise db_exc.DBMigrationError( _("Watcher database schema is already under version control; " "use upgrade... | Create database schema from models description.
Can be used for initial installation instead of upgrade('head'). | 625941bc091ae35668666e42 |
def _get_journal(self, cr, uid, context=None): <NEW_LINE> <INDENT> journal_id = False <NEW_LINE> journal_pool = self.pool.get('account.journal') <NEW_LINE> if context.get('journal_type', False): <NEW_LINE> <INDENT> jids = journal_pool.search(cr, uid, [('type','=', context.get('journal_type'))]) <NEW_LINE> if not jids: ... | Return journal based on the journal type | 625941bcf7d966606f6a9edf |
def get_config_query_kwargs(self, **kwargs): <NEW_LINE> <INDENT> return {} | Return query arguments for fetching an integration configuration.
This can be subclassed to return additional arguments used when
fetching configurations, based on the needs of the application. For
example, limiting it by user or organization.
By default, this doesn't return any additional query arguments.
Args:
... | 625941bc097d151d1a222d3a |
def removeLeaves(self, accessibles): <NEW_LINE> <INDENT> nonleaves = [] <NEW_LINE> for acc in accessibles: <NEW_LINE> <INDENT> if acc.childCount > 0: <NEW_LINE> <INDENT> nonleaves.append(acc) <NEW_LINE> <DEDENT> <DEDENT> return nonleaves | Removes accessibles with no children (leaves) from a list
of accessibles.
@param accessibles: List of accessibles to be examined
@type accessibles: list
@return: The accessibles list without leaves
@rtype: list | 625941bc462c4b4f79d1d5ae |
def cmdCallback(self, cmd): <NEW_LINE> <INDENT> if not cmd.isDone: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> log.info("%s %s" % (self, cmd)) <NEW_LINE> msgCode, msgStr = cmd.getKeyValMsg() <NEW_LINE> self.writeToUsers(msgCode, msgStr, cmd=cmd) | !Called when a user command changes state; report completion or failure
| 625941bca8370b771705277f |
def make_random_path(): <NEW_LINE> <INDENT> return "%s" % (User.objects.make_random_password(20)) | this functions creates a random path for storing
JS file | 625941bca79ad161976cc023 |
def get_node(num): <NEW_LINE> <INDENT> this_node, tmp = root, num <NEW_LINE> for i in xrange(depth-1): <NEW_LINE> <INDENT> if tmp&self.filter: <NEW_LINE> <INDENT> this_node = this_node.right <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> this_node = this_node.left <NEW_LINE> <DEDENT> tmp = tmp<<1 <NEW_LINE> <DEDENT> ret... | Given the node's index, return the node | 625941bc63b5f9789fde6fc3 |
def __getitem__(self, remaining): <NEW_LINE> <INDENT> if not remaining: <NEW_LINE> <INDENT> return self <NEW_LINE> <DEDENT> elif self.children is None: <NEW_LINE> <INDENT> raise KeyError("%r is not a container" % self.name) <NEW_LINE> <DEDENT> for child in self.children: <NEW_LINE> <INDENT> if child.name == remaining[0... | Look up a child atom, potentially recursively.
e.g. atom['udta', 'meta'] => <Atom name='meta' ...> | 625941bc56b00c62f0f14535 |
def enable(self): <NEW_LINE> <INDENT> self.write("MO") | Enables motion for the axis. | 625941bc5fdd1c0f98dc0110 |
def log_ec2_limit_error(exception): <NEW_LINE> <INDENT> if isinstance(exception, BotoServerError) and "RequestLimitExceeded" in utils.safe_stringify(exception): <NEW_LINE> <INDENT> stack_str = traceback.format_exc() <NEW_LINE> if "add_tag" in stack_str: <NEW_LINE> <INDENT> op_name = "CreateTag" <NEW_LINE> <DEDENT> elif... | Logs more details if the exception is RequestLimitExceeded. Not implemented in the best way/right place but
should work just fine
:param exception:
:return: | 625941bc23849d37ff7b2f6f |
def test_generate_freeway_routes_flow(self): <NEW_LINE> <INDENT> routes_file = os.path.join(self._output_dir, 'freeway_routes_demands.xml') <NEW_LINE> token = '<routes>\n' <NEW_LINE> file_util.append_line_to_file(routes_file, token) <NEW_LINE> token = (' <vType id="Car" accel="0.8" decel="4.5" sigma="0.5" ' 'length=... | Test for the freeway demands generation workflow.
All the unit tests have been done above, and there is no calculation in this
test. So this one just verifies nothing is block in the workflow. | 625941bcd10714528d5ffbbe |
def kill_cursors(self, cursor_ids): <NEW_LINE> <INDENT> if not isinstance(cursor_ids, list): <NEW_LINE> <INDENT> raise TypeError("cursor_ids must be a list") <NEW_LINE> <DEDENT> return self._send_message(message.kill_cursors(cursor_ids)) | Send a kill cursors message with the given ids.
Raises :class:`TypeError` if `cursor_ids` is not an instance of
``list``.
:Parameters:
- `cursor_ids`: list of cursor ids to kill | 625941bcd99f1b3c44c67473 |
def test_set_output_volume(): <NEW_LINE> <INDENT> mock = MagicMock(return_value={"retcode": 0}) <NEW_LINE> with patch.dict(mac_desktop.__salt__, {"cmd.run_all": mock}), patch( "salt.modules.mac_desktop.get_output_volume", MagicMock(return_value="25") ): <NEW_LINE> <INDENT> assert mac_desktop.set_output_volume("25") | Test if it set the volume of sound (range 0 to 100) | 625941bc50485f2cf553cc77 |
def get_similarities(tags=None): <NEW_LINE> <INDENT> tags = tags or _get_tags() | Should return a list of similar tag pairs (tuples) | 625941bc1d351010ab8559fb |
def setup_platform(hass, config, add_devices, discovery_info=None): <NEW_LINE> <INDENT> from pysabnzbd import SabnzbdApi, SabnzbdApiException <NEW_LINE> host = config.get(CONF_HOST) <NEW_LINE> port = config.get(CONF_PORT) <NEW_LINE> name = config.get(CONF_NAME) <NEW_LINE> api_key = config.get(CONF_API_KEY) <NEW_LINE> m... | Setup the SABnzbd sensors. | 625941bc4c3428357757c208 |
def parse_coaches(self): <NEW_LINE> <INDENT> lx_doc = self.html_doc() <NEW_LINE> tr = lx_doc.xpath('//tr[@id="HeadCoaches"]')[0] <NEW_LINE> for i, td in enumerate(tr): <NEW_LINE> <INDENT> txt = td.xpath('.//text()') <NEW_LINE> txt = ex_junk(txt, ['\n','\r']) <NEW_LINE> team = 'away' if i == 0 else 'home' <NEW_LINE> sel... | Parse the home and away coaches
:returns: ``self`` on success, ``None`` otherwise | 625941bc3346ee7daa2b2c48 |
def testResourcesGroupAccount(self): <NEW_LINE> <INDENT> pass | Test ResourcesGroupAccount | 625941bc925a0f43d2549d52 |
def SetText(self, *args, **kw): <NEW_LINE> <INDENT> self.setText(self.text) | set the text of the Label | 625941bc71ff763f4b549565 |
def setup_interrupt( self, pin: PinType, edge: InterruptEdge, in_conf: ConfigType, ) -> None: <NEW_LINE> <INDENT> pass | Configure a pin as an interrupt.
This is used on modules which don't supply software callbacks, but use some other
way of representing interrupts, such as connecting a dedicated interrupt output
pin to another module that does supply software callbacks. | 625941bc66673b3332b91f6f |
def get_template_id(kwargs=None, call=None): <NEW_LINE> <INDENT> if call == 'action': <NEW_LINE> <INDENT> raise SaltCloudSystemExit( 'The list_nodes_full function must be called with -f or --function.' ) <NEW_LINE> <DEDENT> if kwargs is None: <NEW_LINE> <INDENT> kwargs = {} <NEW_LINE> <DEDENT> name = kwargs.get('name',... | Returns a template's ID from the given template name.
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt-cloud -f get_template_id opennebula name=my-template-name | 625941bc090684286d50ebc0 |
def pdf(self, X, y): <NEW_LINE> <INDENT> return np.exp(self.logpdf(X, y)) | GMLR probability density function. | 625941bc3eb6a72ae02ec3b3 |
def take_screenshot(filename='screenshot.png', add_timestamp=True): <NEW_LINE> <INDENT> logger.debug('Capturing Screenshot') <NEW_LINE> _make_results_dir() <NEW_LINE> if add_timestamp: <NEW_LINE> <INDENT> filename = _add_time_stamp(filename) <NEW_LINE> <DEDENT> screenshot_file = os.path.join(config.results_directory, f... | Take a screenshot of the browser window. Called automatically on failures
when running in `-s` mode.
Return the path to the saved screenshot. | 625941bc26068e7796caebb8 |
def single_loop(self, inlet_mass_flow=None, update_channels=True): <NEW_LINE> <INDENT> if inlet_mass_flow is not None: <NEW_LINE> <INDENT> self.mass_flow_in = inlet_mass_flow <NEW_LINE> <DEDENT> if update_channels: <NEW_LINE> <INDENT> self.update_channels() <NEW_LINE> self.dp_channel[:] = np.array([chann... | Update the flow circuit | 625941bc460517430c39406b |
def get_user_menu(auths): <NEW_LINE> <INDENT> menus = SysMenuDao.get_all_menu() <NEW_LINE> self_menus = [] <NEW_LINE> [self_menus.append(m) for m in menus if not m["authority"] or m["authority"] in auths] <NEW_LINE> ids = [] <NEW_LINE> [ids.append(menu["parent_id"]) for menu in self_menus if menu["parent_id"] not in id... | 根据权限获取主菜单
:param auths:
:return: | 625941bcdc8b845886cb5412 |
def __init__(self) -> None: <NEW_LINE> <INDENT> self.coqtop: Optional[CoqtopProcess] = None <NEW_LINE> self.xml: Optional[XMLInterfaceBase] = None <NEW_LINE> self.states: List[int] = [] <NEW_LINE> self.state_id = -1 <NEW_LINE> self.root_state = -1 <NEW_LINE> self.out_q: BytesQueue = Queue() <NEW_LINE> self.err_q: Bytes... | Initialize Coqtop state.
coqtop - The Coqtop process
states - A stack of previous state_ids (grows to the right)
state_id - The current (tip) state_id
root_state - The starting state_id
out_q - A thread-safe queue of data read from Coqtop
err_q - A thread-safe queue of error messages read from Coqtop
xml - The XML int... | 625941bc01c39578d7e74d1a |
def CalcScore(): <NEW_LINE> <INDENT> Correctness = eval(input("Out of ten points, enter the score for correctness of code depending on the specifications met: ")) <NEW_LINE> Elegence = eval(input("Out of ten points, enter the score for the elegence of the code: ")) <NEW_LINE> Hygiene = eval(input("Out of ten points, en... | This function calculates the total score of the assigment depending on whether the assignment was submitted on time | 625941bc4c3428357757c209 |
def to_file(self, filename, mode='P'): <NEW_LINE> <INDENT> format = os.path.splitext(filename)[1][1:].upper() <NEW_LINE> if format == 'LMP': writefile(filename, self.data) <NEW_LINE> elif format == 'RAW': writefile(filename, self.to_raw()) <NEW_LINE> else: <NEW_LINE> <INDENT> im = self.to_Image(mode) <NEW_LINE> if fo... | Save the graphic to an image file.
The output format is selected based on the filename extension.
For example, "file.jpg" saves to JPEG format. If the file has
no extension, PNG format is used.
Special cases: ".lmp" saves the raw lump data, and ".raw" saves
the raw pixel data.
`mode` may be be 'P', 'RGB', or 'RGBA' ... | 625941bc2eb69b55b151c78a |
def test_json_conversion(self): <NEW_LINE> <INDENT> metric1 = BaseMetrics() <NEW_LINE> jsobj = metric1.to_json_object() <NEW_LINE> metric2 = BaseMetrics.from_json_object(json.loads(json.dumps(jsobj))) <NEW_LINE> assert metric1 == metric2 | Test json conversion | 625941bcd486a94d0b98e024 |
def __init__(self): <NEW_LINE> <INDENT> pass | Initialize FEMOutput object | 625941bc1f037a2d8b9460dd |
def commit_item(): <NEW_LINE> <INDENT> return s3_rest_controller() | REST Controller | 625941bc4e4d5625662d42bb |
def set_athena_lambda_enable(self): <NEW_LINE> <INDENT> if 'athena_partition_refresh_config' not in self.config['lambda']: <NEW_LINE> <INDENT> LOGGER_CLI.error('No configuration found for Athena Partition Refresh. ' 'Please run: $ python manage.py athena init') <NEW_LINE> return <NEW_LINE> <DEDENT> self.config['lambda'... | Enable athena partition refreshes | 625941bcb57a9660fec3375f |
def pmtu_discovery(self): <NEW_LINE> <INDENT> assert self.automatic_pmtu <NEW_LINE> if self.pmtu_probe_size is not None and self.pmtu_probe_size <= self.pmtu_probe_acked_mtu: <NEW_LINE> <INDENT> self.pmtu_probe_iteration = 0 <NEW_LINE> self.pmtu_probe_size = None <NEW_LINE> self.pmtu_probe_acked_mtu = 0 <NEW_LINE> self... | Handle periodic PMTU discovery. | 625941bc1f037a2d8b9460de |
def test_search_find_one_result_by_ref(self): <NEW_LINE> <INDENT> make_recipe( "legalaid.case", personal_details__full_name="abc", personal_details__postcode="123", **self.get_extra_search_make_recipe_kwargs() ) <NEW_LINE> response = self.client.get( self.list_url, data={"search": self.resource.reference}, HTTP_AUTHORI... | GET search by name should work | 625941bccc0a2c11143dcd6f |
def regulartype(prompt_template="default"): <NEW_LINE> <INDENT> echo_prompt(prompt_template) <NEW_LINE> command_string = "" <NEW_LINE> cursor_position = 0 <NEW_LINE> with raw_mode(): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> in_char = getchar() <NEW_LINE> if in_char in {ESC, CTRLC}: <NEW_LINE> <INDENT> echo(c... | Echo each character typed. Unlike magictype, this echos the characters the
user is pressing.
Returns: command_string | The command to be passed to the shell to run. This is
| typed by the user. | 625941bc76d4e153a657ea0f |
def tofile(f,txt): <NEW_LINE> <INDENT> f.write(txt + "\n") | write text to file with trailing line break | 625941bc38b623060ff0accd |
def setup(bot): <NEW_LINE> <INDENT> bot.add_cog(CoreCommands()) | DecoraterBot's Core Commands Plugin. | 625941bc67a9b606de4a7d9b |
def _subwidget_names(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> x = self.tk.call(self._w, 'subwidgets', '-all') <NEW_LINE> return self.tk.split(x) <NEW_LINE> <DEDENT> except TclError: <NEW_LINE> <INDENT> return None | Return the name of all subwidgets. | 625941bc3617ad0b5ed67dd7 |
def bounds_scale(X, bounds, scale=(-1., 1.)): <NEW_LINE> <INDENT> if X.ndim == 1: X = X.reshape(1, -1) <NEW_LINE> _X = (X - bounds[:,0]) * (scale[1] - scale[0]) <NEW_LINE> _X = _X / (bounds[:,1] - bounds[:,0]) + scale[0] <NEW_LINE> if X.ndim == 1: return _X.ravel() <NEW_LINE> return _X | Scale the features X with range in bounds into range in scale
| 625941bc851cf427c661a3f1 |
def optimize_costs(self): <NEW_LINE> <INDENT> while self.cost_occurence != 1500: <NEW_LINE> <INDENT> new_solution = deepcopy(self.solution) <NEW_LINE> new_grid = new_solution.grid <NEW_LINE> netlist = new_grid.netlist <NEW_LINE> net = choice(netlist) <NEW_LINE> new_grid.delete_net(net, -1) <NEW_LINE> new_astar_solution... | Optimize a given solution on base of the total costs. Remove a randomly chosen net and let
the A* algorithm plot it again. If the costs of the new solution are lower than or equal to
the old costs, remember the new solution. Else, continue with the loop. | 625941bc7b25080760e39339 |
def get_arc_cost_sav( arc ): <NEW_LINE> <INDENT> __moveData["arc_stat"] = get_arc_status( arc ); <NEW_LINE> if __moveData["arc_stat"] == __BASIC: return( 0.0 ) <NEW_LINE> in_arc = __int( arc ) <NEW_LINE> apex = __int(0) <NEW_LINE> out_arc = __int( 0 ) <NEW_LINE> flow_chg = __int( 0 ) <NEW_LINE> i_path = __int(0) <NEW_L... | Compute and return the cost savings that can be achieved by
introducing the arc "arc" into the basis. | 625941bca79ad161976cc024 |
def assert_body(self, body, body_msg, expected_msg): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> msg = body[body_msg] <NEW_LINE> assert msg == expected_msg <NEW_LINE> self.logger.info( "Response body msg == expected_msg, expected_msg is %s, body_msg is %s" % (expected_msg, body[body_msg])) <NEW_LINE> <DEDENT> except: ... | 验证response body中任意属性的值
:param body:
:param body_msg:
:param expected_msg:
:return: | 625941bc45492302aab5e19f |
def history(d): <NEW_LINE> <INDENT> if not hasattr(d, 'cut_history'): <NEW_LINE> <INDENT> raise ValueError("Cut history for this data not available.") <NEW_LINE> <DEDENT> hist = pd.DataFrame(d.cut_history, columns=['selection_desc', 'n_before', 'n_after']) <NEW_LINE> hist['n_removed'] = hist.n_before - hist.n_after <NE... | Return pandas dataframe describing cuts history on dataframe. | 625941bcd53ae8145f87a154 |
def main(): <NEW_LINE> <INDENT> parser = argparse.ArgumentParser(description='Renders an occupancy grid (BINVOX file).') <NEW_LINE> parser.add_argument('--binvox', type=str, help='Path to OFF file.') <NEW_LINE> parser.add_argument('--output', type=str, default='output.png', help='Path to output PNG image.') <NEW_LINE> ... | Main function for rendering a specific binvox file. | 625941bc9f2886367277a76f |
def __rollback(self): <NEW_LINE> <INDENT> for tile_contents in self.tile_create_list: <NEW_LINE> <INDENT> tile_contents.remove() <NEW_LINE> <DEDENT> self.db.rollback() | Roll back the transaction while handling tile files. | 625941bcd8ef3951e324341c |
def fibonacci(n): <NEW_LINE> <INDENT> if n==0 or n==1: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return fibonacci(n-1) + fibonacci(n-2) | Regresa el termino $a_n$ de la sucesion
de Fibonacci. | 625941bcbe8e80087fb20b26 |
def __init__(self, url: str, user: str, password: str, *, verify: bool = True, timeout: Optional[float] = None, retry: Optional[dict] = None, auth_update_callback: Optional[Callable[[], Tuple[str, str]]] = None ): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.host, self.version = self._get_host_and_api_version... | Swarm client class.
* url: ``str``
Url of Swarm server, must include API version.
* user: ``str``
User name, login.
* password: ``str``
Password for user.
* verify: ``bool`` (optional)
Verify SSL (default: true).
* timeout: ``float`` (optional)
HTTP request timeout.
* retry: ``dict`` (optional)
Retry ... | 625941bc3539df3088e2e22a |
def save_clustering_results(_output_file, _centers, _scores, _feature_names): <NEW_LINE> <INDENT> with open(_output_file, 'w') as f: <NEW_LINE> <INDENT> writer = csv.writer(f) <NEW_LINE> writer.writerow(['k'] + ['score'] + list(_feature_names)) <NEW_LINE> for k, v in _centers.items(): <NEW_LINE> <INDENT> centers_list =... | Save the cluster centers and Silhuette scores for the different k.
These data will be use to choose the optimal k.
Input:
- output file name where the data are saved. It will be overwritten if it exists.
- dictionary containing the cluster centers with k as key.
- dictionary containing the Silhuette scores with l as... | 625941bc8e71fb1e9831d68c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.