code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def local_time(time): <NEW_LINE> <INDENT> return time.time()%(24*3600) | Calculation of local time of particular day | 625941c6046cf37aa974cd60 |
def get(self, request): <NEW_LINE> <INDENT> django_logout(request) <NEW_LINE> return redirect('login') | Hace logout de un usuario y le redirige al login
:param request: objeto HttpRequest
:return: objeto HttpResponse de redirección al login | 625941c615fb5d323cde0b24 |
def format_str_lower_case(item): <NEW_LINE> <INDENT> return item.lower() | Format the given string to lower case.
Examples
--------
>>> format_str_lower_case("this is a string")
"this is a string"
>>> format_str_lower_case("string with an ABRV")
"string with an abrv"
>>> format_str_lower_case("string_with %_£+")
"string_with %_£+"
>>> format_str_lower_case("it's an example-with punctuat... | 625941c6fbf16365ca6f61d8 |
def _get_retention_policy_value(self, intrinsics_resolver): <NEW_LINE> <INDENT> if isinstance(self.RetentionPolicy, dict): <NEW_LINE> <INDENT> self.RetentionPolicy = intrinsics_resolver.resolve_parameter_refs(self.RetentionPolicy) <NEW_LINE> if not isinstance(self.RetentionPolicy, string_types): <NEW_LINE> <INDENT> rai... | Sets the deletion policy on this resource. The default is 'Retain'.
:return: value for the DeletionPolicy attribute. | 625941c6d10714528d5ffcf8 |
def lpushx_list(self): <NEW_LINE> <INDENT> result = self.r.lpushx('class', 'sergio2') <NEW_LINE> return result | lpushx/rpushx:与lpush/rpush类似,只不过这个当键存在的时候才插入数据,不存在就不做任何处理
rpushx一样用法 | 625941c6462c4b4f79d1d6e7 |
def report_func(epoch, batch, num_batches, start_time, lr, report_stats, multimodal_model_type): <NEW_LINE> <INDENT> if batch % opt.report_every == -1 % opt.report_every: <NEW_LINE> <INDENT> report_stats.output(epoch, batch + 1, num_batches, start_time) <NEW_LINE> if opt.exp_host: <NEW_LINE> <INDENT> report_stats.log("... | This is the user-defined batch-level traing progress
report function.
Args:
epoch(int): current epoch count.
batch(int): current batch count.
num_batches(int): total number of batches.
start_time(float): last report time.
lr(float): current learning rate.
report_stats(VIStatistics): old VIStati... | 625941c6e76e3b2f99f3a825 |
def go_to(target): <NEW_LINE> <INDENT> for link in _links: <NEW_LINE> <INDENT> if link.tag.target == target: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> raise ValueError(f"No menu link matching target: {target}") <NEW_LINE> <DEDENT> link.raise_event("click") | Emulate clicking a menu link | 625941c671ff763f4b5496a0 |
def computePosterior(ltl, X, vocab, params, memory = None, cache = None, conjoin = False): <NEW_LINE> <INDENT> log_prior = computePrior(ltl, params['lambda'], conjoin) <NEW_LINE> log_likelihood, cscore, memory = computeLikelihood(ltl, X, vocab, params, memory, cache) <NEW_LINE> log_posterior = log_prior + log_likelihoo... | Returns the log-posterior and the current ltl's validity score on X
INPUTS:
ltl - ltl dict
X - evidence (cluster1, cluster2) where each trace in cluster is a trace dict
vocab - vocab of propositions
params - params dict
memory - memory for checking LTL based on ltl['str_friendly']
c... | 625941c67d43ff24873a2cb7 |
def continuer(self, statement, yesResult, noResult): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> yesno = input(statement) <NEW_LINE> if yesno.lower() == "yes": <NEW_LINE> <INDENT> print(yesResult, "\n") <NEW_LINE> return True <NEW_LINE> break <NEW_LINE> <DEDENT> elif yesno.lower() == "no": <NEW_LINE> <INDENT> p... | Helper function. Accepts [Yes] or [No] input from the player and returns either True or False.
Parameters:
statement : str
statement to be answered by player
yesResult : str
statement to be displayed if player answers [Yes]
noResult : str
statement to be displayes if player answers ... | 625941c6925a0f43d2549e8d |
def ranking_nodes_image(self, ranking=None): <NEW_LINE> <INDENT> self.ranking_image = True <NEW_LINE> self.communities_image = False <NEW_LINE> self.path_image = False <NEW_LINE> if ranking is not None: <NEW_LINE> <INDENT> self.ranking = ranking <NEW_LINE> <DEDENT> pos = self.get_node_pos() <NEW_LINE> if self.ranking.t... | Creates a simple image of graph visualization defining size and color of
nodes according to their values in a measure (closeness centrality,
clustering coefficient, etc.)
:param ranking True if it is an image with a ranking of nodes, false
otherwise. | 625941c699fddb7c1c9de3a8 |
def get_book_info(): <NEW_LINE> <INDENT> book_title = str(input("Enter book title: ")) <NEW_LINE> book_isbn = str(input("Enter book ISBN: ")) <NEW_LINE> book_author_last_name = str(input("Enter author last name: ")) <NEW_LINE> year_published = int(input("Enter year published: ")) <NEW_LINE> book_price = float(input("En... | function get_book_info(), the function asks the user to enter the following information:
book title
book ISBN
book author last name
book publisher
year published
book price
The function will eliminate leading and trailing spaces from
title, ISBN, author name and publi... | 625941c657b8e32f524834b1 |
def post(self, request): <NEW_LINE> <INDENT> source_user_id = request.data['source_user'] <NEW_LINE> target_user_id = request.data['target_user'] <NEW_LINE> amount = request.data['transfer_amount'] <NEW_LINE> try: <NEW_LINE> <INDENT> source_uuid = uuid.UUID(source_user_id) <NEW_LINE> target_uuid = uuid.UUID(target_user... | Creates a new transfer between two users.
Returns if the transaction was succesful. | 625941c6cc0a2c11143dcea7 |
def kill_playback(): <NEW_LINE> <INDENT> pidfile = PIDFILE <NEW_LINE> try: <NEW_LINE> <INDENT> with open(pidfile, 'r') as f: <NEW_LINE> <INDENT> pid = int(f.readline()) <NEW_LINE> os.killpg(pid, signal.SIGTERM) <NEW_LINE> <DEDENT> <DEDENT> except IOError as e: <NEW_LINE> <INDENT> logger.debug( ('Could not open pid file... | Kill playback
:returns: nothing | 625941c6091ae35668666f77 |
def sellistrm (self, listname, catnum='1'): <NEW_LINE> <INDENT> self.VistA.wait('Problem List Mgt Menu') <NEW_LINE> self.VistA.write('Create Problem Selection Lists') <NEW_LINE> self.VistA.wait('Create Problem Selection Lists') <NEW_LINE> self.VistA.write('Build') <NEW_LINE> self.VistA.wait('Select LIST NAME:') <NEW_LI... | Remove Category from a Selection List | 625941c6cdde0d52a9e53049 |
def groups(self, merge_groups=None): <NEW_LINE> <INDENT> if merge_groups is None: <NEW_LINE> <INDENT> return self._groups <NEW_LINE> <DEDENT> me = self._copy() <NEW_LINE> me._groups.extend(merge_groups) <NEW_LINE> return me | Get/add groups. | 625941c699fddb7c1c9de3a9 |
def crawl(self, source): <NEW_LINE> <INDENT> sourceIsDir = True if os.path.isdir(source) else False <NEW_LINE> sourceIsFile = True if os.path.isfile(source) else False <NEW_LINE> if not sourceIsFile and not sourceIsDir: <NEW_LINE> <INDENT> raise AttributeError("'{}' is neither a file nor a directory," " attempting to ... | Crawls all directories under the supplied path and stores files
matching a certain filename criteria for further processing
:param str source: Path which should be crawled
:return: Indicator if the crawling of the source was successfull
:rtype: bool | 625941c67b180e01f3dc4817 |
def _make_generic_mconcat(monoid, known_mconcats=_generic_mconcats, **kwargs): <NEW_LINE> <INDENT> generic = _get_generic_type(monoid) <NEW_LINE> if generic and generic in known_mconcats: <NEW_LINE> <INDENT> return known_mconcats[generic] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return partial(reduce, get_generic_... | Attempts to return a generic mconcat method by checking if the generic
type has a known mconcat implementation already or by deriving a generic
mappend implementation and building a generic mconcat with the mappend and
reduce.
If the mappend path is taken and a generic mappend can't be determined,
then a TypeError is ... | 625941c676e4537e8c351688 |
def __init__(self, state_size, action_size, seed): <NEW_LINE> <INDENT> super(QNetwork, self).__init__() <NEW_LINE> self.seed = torch.manual_seed(seed) <NEW_LINE> self.fc1 = nn.Linear(state_size, 64) <NEW_LINE> self.fc2 = nn.Linear(64, 32) <NEW_LINE> self.fc3 = nn.Linear(32, action_size) | Initialize parameters and build model.
Params
======
state_size (int): Dimension of each state
action_size (int): Dimension of each action
seed (int): Random seed | 625941c663f4b57ef0001134 |
def k_shortest_paths(self, start, end, k=10): <NEW_LINE> <INDENT> kshortestpaths = [] <NEW_LINE> orderedX = [] <NEW_LINE> orderedX.append((0, start, 0)) <NEW_LINE> paths = {} <NEW_LINE> paths[(0, start, 0)] = [start] <NEW_LINE> visited = {} <NEW_LINE> visited[start] = 0 <NEW_LINE> sentence_container = {} <NEW_LINE> whi... | Simple implementation of a k-shortest paths algorithms. Takes three
parameters: the starting node, the ending node and the number of
shortest paths desired. Returns a list of k tuples (path, weight). | 625941c697e22403b379cfb0 |
def reportpriority(self, **kwargs): <NEW_LINE> <INDENT> opcode = next(get_opcode(self.device.opcodes, 'A3')) <NEW_LINE> cmd = ReportPriority(opcode=opcode, **kwargs) <NEW_LINE> self.execute(cmd) <NEW_LINE> cmd.unmarshall() <NEW_LINE> return cmd | Return a ReportPriority Instance
:param kwargs: a dict with key/value pairs
priority=0, specifies information to be returned in data_in buffer
alloclen=16384, size of requested datain
:return: a ReportLuns instance | 625941c6dc8b845886cb554b |
def location_autosuggest(self, **params): <NEW_LINE> <INDENT> service_url = "{url}/{market}/{currency}/{locale}/{query}".format( url=self.LOCATION_AUTOSUGGEST_URL, market=params['market'], currency=params['currency'], locale=params['locale'], query=params['query'] ) <NEW_LINE> return self.make_request(service_url, **pa... | {API_HOST}/apiservices/hotels/autosuggest/v2/{market}/{currency}/{locale}/{query}?apikey={apikey} | 625941c60383005118ecf5fb |
def delay_print(s): <NEW_LINE> <INDENT> for c in s: <NEW_LINE> <INDENT> sys.stdout.write("%s" % c) <NEW_LINE> sys.stdout.flush() <NEW_LINE> time.sleep(0.004) | Delays printing. | 625941c69b70327d1c4e0dec |
def rospack_depends(pkg): <NEW_LINE> <INDENT> return rospackexec(['deps', pkg]).split() | @param pkg: package name
@type pkg: str
@return: A list of the names of the packages which pkg depends on
@rtype: list | 625941c630dc7b766590197f |
def reference(name=None): <NEW_LINE> <INDENT> with open(assets + '/references/main.yml', 'r') as file: <NEW_LINE> <INDENT> ref = yaml.safe_load(file) <NEW_LINE> <DEDENT> if name: <NEW_LINE> <INDENT> if 'without' in conf[name]: <NEW_LINE> <INDENT> for key in conf[name]['without']: <NEW_LINE> <INDENT> for entry in ref: <... | Set the expected reference data for a given manager.
Some password managers do not store a lot off data (no group...).
Therefore, we need to remove these entries from the reference data
when testing these managers. | 625941c62ae34c7f2600d149 |
def test_Array_missMatch(self): <NEW_LINE> <INDENT> input = Program([VarDecl('a',ArrayType(5,IntType())),FuncDecl(Id('main'),[],VoidType(),Block([ArrayCell(Id('a'),Id('a'))]))]) <NEW_LINE> expect = "Type Mismatch In Expression: ArrayCell(Id(a),Id(a))" <NEW_LINE> self.assertTrue(TestChecker.test(input,expect,418)) | int a[5];
void main(){
a[a];
} | 625941c656b00c62f0f14670 |
def rth_roots(delta, r, Fq): <NEW_LINE> <INDENT> delta = Fq(delta) <NEW_LINE> q = Fq.order() <NEW_LINE> assert (q - 1) % r == 0, "r should divide q - 1" <NEW_LINE> p = Fq(1) <NEW_LINE> while p ** ((q - 1) // r) == 1: <NEW_LINE> <INDENT> p = Fq.random_element() <NEW_LINE> <DEDENT> t = 0 <NEW_LINE> s = q - 1 <NEW_LINE> w... | Uses the Adleman-Manders-Miller algorithm to extract rth roots in Fq, with r | q - 1.
More information: Cao Z. et al., "Adleman-Manders-Miller Root Extraction Method Revisited" (Section 5)
:param delta: the rth residue delta
:param r: the r
:param Fq: the field Fq
:return: a generator generating the rth roots | 625941c6099cdd3c635f0c73 |
def module_js(self): <NEW_LINE> <INDENT> return make_response( render_template( "foreign_key/js/foreign_key.js", _=_ ), 200, {'Content-Type': 'application/x-javascript'} ) | This property defines (if javascript) exists for this node.
Override this property for your own logic. | 625941c6287bf620b61d3a7c |
def _get_apex_manipulation_data(self, apex_data, form_data) -> dict: <NEW_LINE> <INDENT> form_data = { **form_data, **(apex_data._asdict()), } <NEW_LINE> del form_data['cookie'] <NEW_LINE> return form_data | Prepares form data for a request that will manipulate the Apex worksheet. | 625941c676e4537e8c351689 |
def extract_props(self, settings): <NEW_LINE> <INDENT> props = {} <NEW_LINE> for param in self.call_parameters: <NEW_LINE> <INDENT> if param in settings: <NEW_LINE> <INDENT> props[param] = settings[param] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> props[param] = None <NEW_LINE> <DEDENT> <DEDENT> return props | Extract all valuable properties to be displayed | 625941c66e29344779a6262b |
def send_notification(self, fcm_list, payload): <NEW_LINE> <INDENT> data = self.create_payload(fcm_list=fcm_list, payload=payload) <NEW_LINE> response = requests.post(self.FCM_URL, data=data, headers=self.HEADERS) <NEW_LINE> if 'Error 401' in response.content: <NEW_LINE> <INDENT> logger.error(response.content) <NEW_LIN... | sends notification ands logs
:param fcm_list: fcm_id to which the notification has to be sent
:param payload: data to be sent
:return: None | 625941c64e696a04525c9463 |
def OnLoadButton(self, event): <NEW_LINE> <INDENT> dlg = wx.FileDialog(self, wildcard="*.pdf") <NEW_LINE> if dlg.ShowModal() == wx.ID_OK: <NEW_LINE> <INDENT> wx.BeginBusyCursor() <NEW_LINE> self.viewer.LoadFile(dlg.GetPath()) <NEW_LINE> wx.EndBusyCursor() <NEW_LINE> <DEDENT> dlg.Destroy() | ... | 625941c64527f215b584c470 |
def open(self): <NEW_LINE> <INDENT> if self.comm is None: <NEW_LINE> <INDENT> args = dict(target_name='ipython.widget', data={ 'model_name': self._model_name }) <NEW_LINE> if self._model_id is not None: <NEW_LINE> <INDENT> args['comm_id'] = self._model_id <NEW_LINE> <DEDENT> self.comm = Comm(**args) <NEW_LINE> self._mo... | Open a comm to the frontend if one isn't already open. | 625941c6adb09d7d5db6c7a8 |
def __post_create(self, request, format=None): <NEW_LINE> <INDENT> def validate(request_json): <NEW_LINE> <INDENT> if not (request_json.get('name')): <NEW_LINE> <INDENT> raise ValidationError('Company name is required.') <NEW_LINE> <DEDENT> return request_json <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> user = check_a... | Expected request body:
{
'name': [required] [str],
'segment': [str],
'sector': [str],
'location': [str],
'logoUrl': [str],
'website': [str]
} | 625941c6d10714528d5ffcf9 |
def test_add_translation_to_db_when_page_lang_group_none(): <NEW_LINE> <INDENT> request = _mock_request(matchdict={'public_group_id': '12345', 'language': 'test', 'page_url': 'http://www.annotran_test.com/'}) <NEW_LINE> result = views.add_translation(request) <NEW_LINE> assert not request.db.add.called <NEW_LINE> asser... | This should not add a new translation to the database session.
If page, group or language is None, then it should return immediatelly. | 625941c65e10d32532c5ef3f |
def remove_context(self): <NEW_LINE> <INDENT> del self._label <NEW_LINE> del self._pts | Remove the context for this Secret. | 625941c638b623060ff0ae05 |
def try_utf8_decode(value): <NEW_LINE> <INDENT> if not value or not is_string(value): <NEW_LINE> <INDENT> return value <NEW_LINE> <DEDENT> elif PYTHON3 and not isinstance(value, bytes): <NEW_LINE> <INDENT> return value <NEW_LINE> <DEDENT> elif not PYTHON3 and not isinstance(value, unicode): <NEW_LINE> <INDENT> return v... | Try to decode an object.
:param value:
:return: | 625941c68e7ae83300e4afe4 |
def configureWhere(self, where): <NEW_LINE> <INDENT> return nose.config.Config.configureWhere( self, our_path ) | Configure the working directory or directories for the test run.
We override `nose.config.Config.configureWhere` to avoid adding
together the locations from all the `setup.cfg` files, because Nose
doesn't handle that well. So we use this script's path, which doesn't
have any tests on it, as the official 'where' direct... | 625941c650812a4eaa59c33b |
def set_trace(self, key, value): <NEW_LINE> <INDENT> if key is None or value is None: <NEW_LINE> <INDENT> raise Exception('Invalid trace key/value') <NEW_LINE> <DEDENT> self.trace[key] = value | sets a trace item, overwriting it if it is already set | 625941c6090684286d50ecfc |
def show_trailer(self): <NEW_LINE> <INDENT> webbrowser.open(self.tariler_youtube_url) | the show_trailer mothod to playing movie trailer | 625941c6a219f33f34628983 |
def single_position_coverage(coverage_info, start): <NEW_LINE> <INDENT> coverage = {} <NEW_LINE> for m in coverage_info: <NEW_LINE> <INDENT> if m[0] == ':': <NEW_LINE> <INDENT> new_cov = {i: 1 for i in range(start, start+int(m[1:]))} <NEW_LINE> coverage = {**coverage, **new_cov} <NEW_LINE> start = start + int(m[1:]) <N... | Determine if positions in a subsequence are
covered based on information in the cs field
in a PAF file created by minimpa2.
Parameters
----------
coverage_info : list
List with subsequent operations extracted
from the cd field in a PAF file created by
minimap2.
start : int
Subsequence start position in... | 625941c616aa5153ce362490 |
def reverseList(self, head): <NEW_LINE> <INDENT> if head is None: <NEW_LINE> <INDENT> return head <NEW_LINE> <DEDENT> prev = None <NEW_LINE> while head is not None: <NEW_LINE> <INDENT> temp = head.next <NEW_LINE> head.next = prev <NEW_LINE> prev = head <NEW_LINE> head = temp <NEW_LINE> <DEDENT> return prev | :type head: ListNode
:rtype: ListNode | 625941c6bf627c535bc131e6 |
def subarraySum(self, nums, k): <NEW_LINE> <INDENT> res = [0] <NEW_LINE> count = 0 <NEW_LINE> for i in range(len(nums)): <NEW_LINE> <INDENT> res.append(res[-1] + nums[i]) <NEW_LINE> <DEDENT> for i in range(len(res)): <NEW_LINE> <INDENT> count += res[i + 1:].count(k + res[i]) <NEW_LINE> <DEDENT> return count | :type nums: List[int]
:type k: int
:rtype: int | 625941c650485f2cf553cdb1 |
def _loadTypes(self, fname): <NEW_LINE> <INDENT> if not fname.exists(): <NEW_LINE> <INDENT> getLogger(__name__).info("File to load evolvers from does not exist: %s", fname) <NEW_LINE> return [] <NEW_LINE> <DEDENT> with h5.File(fname, "r") as h5f: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> grp = h5f[self.evolverTypeLo... | !
Load all types of evolvers and transforms in file `fname`. | 625941c6507cdc57c6306cf0 |
def read_bed(bed): <NEW_LINE> <INDENT> fh = open(bed, 'r') <NEW_LINE> dict = {} <NEW_LINE> for line in fh: <NEW_LINE> <INDENT> line = line.rstrip() <NEW_LINE> fields = line.split('\t') <NEW_LINE> for pos in xrange(int(fields[1])+1, int(fields[2])+1, 1): <NEW_LINE> <INDENT> dict[fields[0], str(pos)] = 1 <NEW_LINE> <DEDE... | Read rmsk file and return dictionary of positions to filter
only keep positions that matches chromosome being analyzed | 625941c6283ffb24f3c5591a |
def pair(dice): <NEW_LINE> <INDENT> counts = dice_counts(dice) <NEW_LINE> for i in [6, 5, 4, 3, 2, 1]: <NEW_LINE> <INDENT> if counts[i] >= 2: <NEW_LINE> <INDENT> return 2 * i <NEW_LINE> <DEDENT> <DEDENT> return 0 | Score the given roll in the 'Pair' category
>>> pair([1,2,3,4,4])
8
>>> pair([1,2,3,4,5])
0
It uses the highest scoring pair if there is more than one pair
>>> pair([1,3,3,4,4])
8
>>> pair([3,3,3,4,4])
8 | 625941c65166f23b2e1a5171 |
def __init__(self, parent=None): <NEW_LINE> <INDENT> log_info.output("ui_main_init") <NEW_LINE> self.main = laser_main(); <NEW_LINE> self.operator_id = 999999; <NEW_LINE> self.custom_id = 999999; <NEW_LINE> self.type_id = 999999; <NEW_LINE> self.print_num = 0; <NEW_LINE> self.current_index = 0; <NE... | Constructor
@param parent reference to the parent widget
@type QWidget | 625941c6a934411ee37516ab |
def test_fold_fwd_let_fail(): <NEW_LINE> <INDENT> def before(x, conv_weight, in_bias, in_scale, channels): <NEW_LINE> <INDENT> args = [x, conv_weight, in_bias] <NEW_LINE> x = relay.multiply(x, in_scale) <NEW_LINE> x = relay.nn.relu(x) <NEW_LINE> x = relay.add(x, in_bias) <NEW_LINE> x_var = relay.Var("x_var") <NEW_LINE>... | testcase where we canont fold | 625941c6d4950a0f3b08c368 |
def do_or_form(vals, env): <NEW_LINE> <INDENT> if vals == nil: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> for v in vals: <NEW_LINE> <INDENT> if scheme_true(v): <NEW_LINE> <INDENT> return v <NEW_LINE> <DEDENT> <DEDENT> return False | Evaluate short-circuited or with parameters VALS in environment ENV. | 625941c6b545ff76a8913e2e |
def get_instance(self, project_id, instance_id): <NEW_LINE> <INDENT> client = self.get_client(project_id) <NEW_LINE> instance = client.instance(instance_id) <NEW_LINE> if not instance.exists(): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> return instance | Gets information about a particular instance.
:param project_id: The ID of the project which owns the instances, tables and data.
:type project_id: str
:param instance_id: The ID of the instance.
:type instance_id: str
:return: Representation of a Cloud Spanner Instance. See:
https://googleapis.github.io/google-cl... | 625941c64f6381625f114a53 |
def to_matrix(datafile,n): <NEW_LINE> <INDENT> raise NotImplementedError("Problem 1 incomplete") | Return the nxn adjacency matrix described by datafile.
INPUTS:
datafile (.txt file): A .txt file describing a directed graph. Lines
describing edges should have the form '<from node> <to node>
'.
The file may also include comments.
n (int): The number of nodes in the graph described... | 625941c64f6381625f114a54 |
def delete_file(self, item: QModelIndex) -> None: <NEW_LINE> <INDENT> path = self.FsModel.filePath(item) <NEW_LINE> try: <NEW_LINE> <INDENT> if self.FsModel.isDir(item): <NEW_LINE> <INDENT> directory = QDir(path) <NEW_LINE> directory.removeRecursively() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> file = QFile(path) <... | Deletes a file or a directory by given ModelIndex | 625941c6283ffb24f3c5591b |
def _change_title(self, title): <NEW_LINE> <INDENT> title = os.path.basename(title) <NEW_LINE> self.setWindowTitle(title + ' - ' + '{' + ui.__edis__ + '}') | Cambia el título de la ventana (filename - {EDIS}) | 625941c6fb3f5b602dac36aa |
def aboutProgram(*evento): <NEW_LINE> <INDENT> aboutwindow = Toplevel(root) <NEW_LINE> Help(aboutwindow).about() | Create a new window (Toplevel) and makes an instance of Help class with the new window as atribute, and calls the about method. | 625941c60a50d4780f666ea9 |
def p_simple_expr_function_call(p): <NEW_LINE> <INDENT> p[0] = ('function_call', p[1]) | simple_expr : function_call | 625941c6ac7a0e7691ed40e7 |
def New(*args, **kargs): <NEW_LINE> <INDENT> obj = itkLogImageFilterIF3IF3.__New_orig__() <NEW_LINE> import itkTemplate <NEW_LINE> itkTemplate.New(obj, *args, **kargs) <NEW_LINE> return obj | New() -> itkLogImageFilterIF3IF3
Create a new object of the class itkLogImageFilterIF3IF3 and set the input and the parameters if some
named or non-named arguments are passed to that method.
New() tries to assign all the non named parameters to the input of the new objects - the
first non named parameter in the first... | 625941c6004d5f362079a34c |
def get_params(self, deep=True): <NEW_LINE> <INDENT> params = super().get_params(deep=deep) <NEW_LINE> params['lmbda'] = self.lmbda2 <NEW_LINE> return params | Get parameters for this estimator.
Parameters
----------
deep : bool, default=True
If True, will return the parameters for this estimator and
contained subobjects that are estimators.
Returns
-------
params : mapping of string to any
Parameter names mapped to their values. | 625941c68da39b475bd64f8a |
@app.route('/accept-rating') <NEW_LINE> def accept_rating(): <NEW_LINE> <INDENT> return | Allows users to both add new rating OR update and existing rating. | 625941c60fa83653e4656fd4 |
def set_role(role): <NEW_LINE> <INDENT> CFG['ROLE'] = role or CFG['ROLE'] | Changes the existing instances role. | 625941c68c0ade5d55d3e9d2 |
def unexecute(self): <NEW_LINE> <INDENT> pass | returns a user one tile back from where they came | 625941c6f7d966606f6aa01b |
def test_getTmpFilename_defaults_to_no_class_id(self): <NEW_LINE> <INDENT> app = CLAppTester() <NEW_LINE> self.assertFalse(app.getTmpFilename(). startswith('/tmp/tmpCLAppTester')) <NEW_LINE> self.assertTrue(app.getTmpFilename(include_class_id=True). startswith('/tmp/tmpCLAppTester')) | CLAppTester: getTmpFilename doesn't include class id by default
| 625941c607d97122c41788a1 |
def get_point_group(rotations): <NEW_LINE> <INDENT> if rotations.dtype == "float64": <NEW_LINE> <INDENT> rotations = np.int_(rotations) <NEW_LINE> <DEDENT> return spg.pointgroup(rotations) | Return point group in international table symbol and number.
The symbols are mapped to the numbers as follows:
1 "1 "
2 "-1 "
3 "2 "
4 "m "
5 "2/m "
6 "222 "
7 "mm2 "
8 "mmm "
9 "4 "
10 "-4 "
11 "4/m "
12 "422 "
13 "4mm "
14 "-42m "
15 "4/mmm"
16 "3 "
17 "-3 "
18 "... | 625941c63346ee7daa2b2d83 |
def _discard_tree(self, block, survivor_child = None): <NEW_LINE> <INDENT> children = self._discard_block(block) <NEW_LINE> for child in children: <NEW_LINE> <INDENT> if child is not survivor_child: <NEW_LINE> <INDENT> self._discard_tree(child) | recursively (DFS) discard a block and its children, except for its
"survivor" child, the one included in the longest chain. | 625941c6e1aae11d1e749cce |
def test_initialize_tet4_collocated(self): <NEW_LINE> <INDENT> cell = FIATSimplex() <NEW_LINE> cell.inventory.dimension = 3 <NEW_LINE> cell.inventory.degree = 1 <NEW_LINE> cell.inventory.collocateQuad = True <NEW_LINE> cell._configure() <NEW_LINE> cell.initialize(spaceDim=3) <NEW_LINE> cellE = Tet4Collocated() <NEW_LIN... | Test initialize() with tet4 cell. | 625941c6ad47b63b2c509f97 |
def train(self, states, targets): <NEW_LINE> <INDENT> return self.sess.run(self.train_op, feed_dict={self.states: states, self.targets: targets}) | states: numpy array
targets: numpy array | 625941c68da39b475bd64f8b |
def write_directory(treefile, data, counts, taxa, outputdir, colors, legend, legendshape, proportions, verbose=False): <NEW_LINE> <INDENT> allkeys = list(counts.keys()) <NEW_LINE> if len(allkeys) > len(colors): <NEW_LINE> <INDENT> sys.stderr.write("ERROR: Not enough colors. We have {} keys and {} colors\n".format(len(... | Write a directory with one multibar file per type
:param treefile: The tree file to parse
:param data: The data dict with leaves and labels
:param counts: the counts of label frequency
:param outputdir: the directory to create
:param colors: the array of colors to choose from
:param legend: the legend name
:param legen... | 625941c624f1403a92600b80 |
def __init__(self, cmd, all=False, separately=False, background=False, shell=False, notify_stdout=False, format='raw', add_tags=False, noop_msg='no command specified', confirm_msg='', done_msg=None, field_key='copiousoutput', **kwargs): <NEW_LINE> <INDENT> Command.__init__(self, **kwargs) <NEW_LINE> if isinstance(cmd, ... | :param cmd: shellcommand to open
:type cmd: str or list of str
:param all: pipe all, not only selected message
:type all: bool
:param separately: call command once per message
:type separately: bool
:param background: do not suspend the interface
:type background: bool
:param notify_stdout: display command's stdout as ... | 625941c6046cf37aa974cd61 |
def kthSmallest(self, root, k): <NEW_LINE> <INDENT> from queue import PriorityQueue <NEW_LINE> Q = PriorityQueue() <NEW_LINE> def traverse(root): <NEW_LINE> <INDENT> Q.put(root.val) <NEW_LINE> if root.left: <NEW_LINE> <INDENT> traverse(root.left) <NEW_LINE> <DEDENT> if root.right: <NEW_LINE> <INDENT> traverse(root.righ... | :type root: TreeNode
:type k: int
:rtype: int | 625941c644b2445a339320af |
def stashPop(stash): <NEW_LINE> <INDENT> if not stash[1].startswith('No local changes'): <NEW_LINE> <INDENT> pop = M2.git().stash(command='pop') <NEW_LINE> if pop[0] != 0: <NEW_LINE> <INDENT> logging.error('An error ocured while unstashing your changes') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> logging.info('Poppe... | Small helper to pop the stash has we have to do it in some different places | 625941c6442bda511e8be433 |
def get_remainder_set(self, j): <NEW_LINE> <INDENT> result = [] <NEW_LINE> ancestors = self.get_update_set(j) <NEW_LINE> for a in ancestors: <NEW_LINE> <INDENT> for c in a.children: <NEW_LINE> <INDENT> if c.index < j: <NEW_LINE> <INDENT> result.append(c) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return result | Return the set of children with indices less than j of all ancestors
of j. The set C from (arXiv:1701.07072).
:param int j: fermionic site index
:return: children of j-ancestors, with indices less than j
:rtype: list(FenwickNode) | 625941c64d74a7450ccd41dc |
def batch(inputs, max_sequence_length=None): <NEW_LINE> <INDENT> sequence_lengths = [len(seq) for seq in inputs] <NEW_LINE> batch_size = len(inputs) <NEW_LINE> if max_sequence_length is None: <NEW_LINE> <INDENT> max_sequence_length = max(sequence_lengths) <NEW_LINE> <DEDENT> inputs_batch_major = np.zeros(shape=[batch_s... | Args:
inputs:
list of sentences (integer lists)
max_sequence_length:
integer specifying how large should `max_time` dimension be.
If None, maximum sequence length would be used
Outputs:
inputs_time_major:
input sentences transformed into time-major matrix
(shape [ma... | 625941c68e05c05ec3eea38c |
def get(self): <NEW_LINE> <INDENT> return self.request().get() | Gets the specified Calendar.
Returns:
:class:`Calendar<microsoft.msgraph.model.calendar.Calendar>`:
The Calendar. | 625941c62ae34c7f2600d14a |
def createBzrBranch(self, db_branch, parent=None): <NEW_LINE> <INDENT> bzr_branch = self.createBranchAtURL(db_branch.getInternalBzrUrl()) <NEW_LINE> if parent: <NEW_LINE> <INDENT> bzr_branch.pull(parent) <NEW_LINE> naked_branch = removeSecurityProxy(db_branch) <NEW_LINE> naked_branch.last_scanned_id = bzr_branch.last_r... | Create a bzr branch for a database branch.
:param db_branch: The database branch to create the branch for.
:param parent: If supplied, the bzr branch to use as a parent. | 625941c6377c676e912721c2 |
def meet(self): <NEW_LINE> <INDENT> print("Everyone meet in the Board Room.") | Prints a message identifying a meeting location
for the Human Resources department | 625941c6fbf16365ca6f61da |
def test__fqdn_to_ip__called(self): <NEW_LINE> <INDENT> data = RecordDict({"fqdn": "cert.pl"}) <NEW_LINE> data.update(self.COMMON_DATA) <NEW_LINE> self.enricher.fqdn_to_ip = unittest.mock.MagicMock() <NEW_LINE> self.enricher.enrich(data) <NEW_LINE> self.enricher.fqdn_to_ip.assert_called_with("cert.pl") | Test if fqdn_to_ip is called if data does not contain address | 625941c6009cb60464c633cb |
@pytest.fixture(scope="session") <NEW_LINE> def bucket_name(settings, environment): <NEW_LINE> <INDENT> layer = [l for l in environment.layers if l.name == settings.bucket_layer_name][0] <NEW_LINE> return layer.outputs.get("BucketName") | The name of the output Kinesis stream. | 625941c6435de62698dfdc65 |
def FilenameToUri(self, path, use_http=False, use_ssl=False, port=8000): <NEW_LINE> <INDENT> if use_http: <NEW_LINE> <INDENT> protocol = 'http' <NEW_LINE> if use_ssl: <NEW_LINE> <INDENT> protocol = 'https' <NEW_LINE> <DEDENT> return "%s://127.0.0.1:%d/%s" % (protocol, port, path) <NEW_LINE> <DEDENT> return "file://" + ... | Convert a filesystem path to a URI.
Args:
path: For an http URI, the path relative to the httpd server's
DocumentRoot; for a file URI, the full path to the file.
use_http: if True, returns a URI of the form http://127.0.0.1:8000/.
If False, returns a file:/// URI.
use_ssl: if True, returns HTTPS URL ... | 625941c682261d6c526ab4b6 |
def add_export(exports='/etc/exports', path=None, hosts=None, options=None): <NEW_LINE> <INDENT> if options is None: <NEW_LINE> <INDENT> options = [] <NEW_LINE> <DEDENT> if type(hosts) is not str: <NEW_LINE> <INDENT> raise TypeError('hosts argument must be a string') <NEW_LINE> <DEDENT> edict = list_exports(exports) <N... | Add an export
CLI Example:
.. code-block:: bash
salt '*' nfs3.add_export path='/srv/test' hosts='127.0.0.1' options=['rw'] | 625941c607f4c71912b1149a |
def find_violations(self, instance_network_interface, force_rebuild=False): <NEW_LINE> <INDENT> violations = itertools.chain() <NEW_LINE> if self.rule_book is None or force_rebuild: <NEW_LINE> <INDENT> self.build_rule_book() <NEW_LINE> <DEDENT> resource_rules = self.rule_book.get_resource_rules() <NEW_LINE> for rule in... | Determine whether the networks violates rules.
Args:
instance_network_interface (list): list of
instance_network_interface
force_rebuild (bool): set to false to not force a rebuiid
Return:
list: iterator of all violations | 625941c630c21e258bdfa4b5 |
def Empty(self): <NEW_LINE> <INDENT> return _snap.TIntV_Empty(self) | Empty(TIntV self) -> bool
Parameters:
self: TVec< TInt,int > const * | 625941c67c178a314d6ef476 |
def getdynpath(): <NEW_LINE> <INDENT> s = inspect.getfile(inspect) <NEW_LINE> newpath = None <NEW_LINE> if "conda" in s: <NEW_LINE> <INDENT> pattern = re.compile('[\w\d]+conda[\s\S]+\/lib\/') <NEW_LINE> found = pattern.search(s) <NEW_LINE> if found: <NEW_LINE> <INDENT> newpath = s[:found.end()] + "libpython2.7.dylib" <... | get the path for the Python dynamic library | 625941c62c8b7c6e89b357da |
def __eq__(self, other): <NEW_LINE> <INDENT> return isinstance(other, self.__class__) and self.hash == other.hash | Two blocks are equal iff they have the same hash. | 625941c6796e427e537b05de |
def wrap_quote (self, **kwa): <NEW_LINE> <INDENT> quote = kwa.get ('quote') <NEW_LINE> item = dict ( href = self.mk_url (), data = [ dict ( name = 'author', value = quote.author, prompt = 'Author', ), dict ( name = 'text', value = quote.text, prompt = 'Text', ), dict ( name = 'id', value = quote.id, prompt = 'ID', ), ]... | wrap the given quote in a collection+json structure
| 625941c6090684286d50ecfd |
def set_hostname(self, hostname): <NEW_LINE> <INDENT> self.hostname = hostname <NEW_LINE> self.updateToolTips() | Set a hostname
| 625941c6fff4ab517eb2f454 |
def _import_shared_workflow(self, trans, stored): <NEW_LINE> <INDENT> imported_stored = model.StoredWorkflow() <NEW_LINE> imported_stored.name = "imported: " + stored.name <NEW_LINE> workflow = stored.latest_workflow.copy() <NEW_LINE> workflow.stored_workflow = imported_stored <NEW_LINE> imported_stored.latest_workflow... | Imports a shared workflow | 625941c6379a373c97cfab5d |
def rgb_roll(image, deg, radius): <NEW_LINE> <INDENT> dictio = convert_rotation(deg, radius) <NEW_LINE> b_channel, g_channel, r_channel = cv2.split(image) <NEW_LINE> b_channel = roll_image(b_channel, dictio['B_a'], dictio['B_b']) <NEW_LINE> g_channel = roll_image(g_channel, dictio['G_a'], dictio['G_b']) <NEW_LINE> r_ch... | todo: set parameters to roll: rotation & radius (R-G-B are set between 120 deg) | 625941c65fdd1c0f98dc024c |
def two_sum_optimized_2(nums: List[int], target: int) -> List[int]: <NEW_LINE> <INDENT> _helper = {} <NEW_LINE> for first_index, key in enumerate(nums): <NEW_LINE> <INDENT> second = target - key <NEW_LINE> try: <NEW_LINE> <INDENT> if first_index != _helper[key]: <NEW_LINE> <INDENT> return [first_index, _helper[key]] <N... | Second optimization | 625941c699cbb53fe6792c00 |
def empty(self): <NEW_LINE> <INDENT> return self.apply(EmptyTransformation()) | Empty selected elements of all content.
Example:
>>> html = HTML('<html><head><title>Some Title</title></head>'
... '<body>Some <em>body</em> text.</body></html>')
>>> print(html | Transformer('.//em').empty())
<html><head><title>Some Title</title></head><body>Some <em/>
text.</body></html>
:rtype: `Tran... | 625941c699cbb53fe6792bff |
def project_by_name(self, proj_name): <NEW_LINE> <INDENT> projects = self.get_projects() <NEW_LINE> for project in projects: <NEW_LINE> <INDENT> if project['name'] == proj_name: <NEW_LINE> <INDENT> return project['id'] <NEW_LINE> <DEDENT> <DEDENT> return self.create_project(proj_name) | :type proj_name: str
:rtype: int | 625941c69c8ee82313fbb78d |
@manager.command <NEW_LINE> def pull_messages(force=False): <NEW_LINE> <INDENT> command = "tx pull" <NEW_LINE> if force: <NEW_LINE> <INDENT> command += " -f" <NEW_LINE> <DEDENT> run(command) | Pull messages to transifex | 625941c6627d3e7fe0d68e68 |
def _next_channel_number(self): <NEW_LINE> <INDENT> limit = self.parameters.channel_max or channel.MAX_CHANNELS <NEW_LINE> if len(self._channels) == limit: <NEW_LINE> <INDENT> raise NoFreeChannels() <NEW_LINE> <DEDENT> if not self._channels: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ret... | Return the next available channel number or raise on exception. | 625941c676d4e153a657eb49 |
def cudnnCreateFilterDescriptor(): <NEW_LINE> <INDENT> filterDesc = ctypes.c_void_p() <NEW_LINE> status = _libcudnn.cudnnCreateFilterDescriptor(ctypes.byref(filterDesc)) <NEW_LINE> cudnnCheckStatus(status) <NEW_LINE> return filterDesc.value | "
Create a filter descriptor.
This function creates a filter descriptor object by allocating the memory needed
to hold its opaque structure.
Parameters
----------
Returns
-------
filterDesc : cudnnFilterDescriptor
Handle to a newly allocated filter descriptor. | 625941c6cdde0d52a9e5304b |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, CheckDiagnose): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.to_dict() == other.to_dict() | Returns true if both objects are equal | 625941c645492302aab5e2db |
def map(self, func): <NEW_LINE> <INDENT> for row in self.table: <NEW_LINE> <INDENT> for i, cell in enumerate(row): <NEW_LINE> <INDENT> row[i] = func(cell) | This will replace every cell in the function with func(cell)
:param func: func to call
:return: None | 625941c6d8ef3951e3243556 |
@pytest.mark.django_db <NEW_LINE> def test_invalid_version(client): <NEW_LINE> <INDENT> page = Page.objects.create(name="complex", data="title: 'some title'", template='tests/complex.html', path="complex") <NEW_LINE> assert not page.latest_version.valid | When the new version breaks the template - it should create a new version that is invalid | 625941c6c4546d3d9de72a4c |
def __configPortion(self): <NEW_LINE> <INDENT> if self.__numero == 1 : <NEW_LINE> <INDENT> return PortionGroup(Constants.CaloriePortionGrp1) <NEW_LINE> <DEDENT> elif self.__numero == 2 : <NEW_LINE> <INDENT> return PortionGroup(Constants.CaloriePortionGrp2) <NEW_LINE> <DEDENT> elif self.__numero == 3 : <NEW_LINE> <INDEN... | Configuration of portions in each group | 625941c6656771135c3eb886 |
def wget_exec(read_path, write_path, server_dir): <NEW_LINE> <INDENT> logging.info('Retrieving forecast files for date {}'.format(server_dir)) <NEW_LINE> file_list = map(lambda x: '{}_{}'.format(server_dir, str(x).zfill(3)), range(7)) <NEW_LINE> wget_log_path = os.path.join(base_dir, 'Log_files', 'Download.log') <NEW_L... | Build the complete wget string and retrieve temp file | 625941c6c432627299f04c5e |
def square(num1): <NEW_LINE> <INDENT> return num1 * num1 | Squares number and returns result | 625941c67b180e01f3dc4819 |
def powerUp(self): <NEW_LINE> <INDENT> self.mf.current = self.mf <NEW_LINE> pass | Powers up the card | 625941c60c0af96317bb8201 |
def supported_vpn_devices( self, resource_group_name, virtual_network_gateway_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_... | Gets a xml format representation for supported vpn devices.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param virtual_network_gateway_name: The name of the virtual network gateway.
:type virtual_network_gateway_name: str
:keyword callable cls: A custom type or function t... | 625941c6507cdc57c6306cf1 |
def parsing_sa_protocol_version_response(pdu: list) -> tuple: <NEW_LINE> <INDENT> packet = SAInfoResponsePacket.from_pdu(pdu=pdu) <NEW_LINE> if packet.service_id != SARegisterServiceIDEnum.READ_PROTOCOL_VERSION: <NEW_LINE> <INDENT> raise ValueError(f'pdu service id invalid, {pdu}') <NEW_LINE> <DEDENT> if len(packet.dat... | Parsing TaiSEIA device protocol version response protocol data. | 625941c650812a4eaa59c33c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.