code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def alias_cset(alias, engine, csets): <NEW_LINE> <INDENT> return csets[alias]
alias a cset to another
625941bfa17c0f6771cbdf9b
def getRender(self): <NEW_LINE> <INDENT> return self.render
This method return the html rendered
625941bf6fb2d068a760efe3
def hadamard_matrix_www(url_file, comments=False): <NEW_LINE> <INDENT> n = eval(url_file.split(".")[1]) <NEW_LINE> rws = [] <NEW_LINE> url = "http://neilsloane.com/hadamard/" + url_file <NEW_LINE> f = urlopen(url) <NEW_LINE> s = f.readlines() <NEW_LINE> for i in range(n): <NEW_LINE> <INDENT> r = [] <NEW_LINE> for j in ...
Pulls file from Sloane's database and returns the corresponding Hadamard matrix as a Sage matrix. You must input a filename of the form "had.n.xxx.txt" as described on the webpage http://neilsloane.com/hadamard/, where "xxx" could be empty or a number of some characters. If comments=True then the "Automorphism..." li...
625941bf71ff763f4b5495d0
def _get_dset_array(self, dspath): <NEW_LINE> <INDENT> branch = self._my_ds_from_path(dspath) <NEW_LINE> if isinstance(branch, h5py.Group): <NEW_LINE> <INDENT> return 'group' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return (H5Array(branch), dict(branch.attrs))
returns a pickle-safe array for the branch specified by dspath
625941bf3617ad0b5ed67e41
def cast(*args): <NEW_LINE> <INDENT> return _itkNeighborhoodConnectedImageFilterPython.itkNeighborhoodConnectedImageFilterIUL3IUL3_cast(*args)
cast(itkLightObject obj) -> itkNeighborhoodConnectedImageFilterIUL3IUL3
625941bfe8904600ed9f1e72
def tr(self, message): <NEW_LINE> <INDENT> return QCoreApplication.translate('VERSAOVegaMonitor', 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
625941bf046cf37aa974cc92
def match(self, object_id): <NEW_LINE> <INDENT> if self._regexp is None: <NEW_LINE> <INDENT> self._regexp = re.compile(self.regexp) <NEW_LINE> <DEDENT> return self._regexp.match(object_id)
Validate that object ids match the generator. This is used mainly when an object id is picked arbitrarily (e.g with ``PUT`` requests). :returns: `True` if the specified object id matches expected format. :rtype: bool
625941bf5e10d32532c5ee70
def __init__(self, cursor=None, sort_ascending=None, sort_by=None, result_count=None, results=None, *args, **kwargs): <NEW_LINE> <INDENT> self._cursor = None <NEW_LINE> self._sort_ascending = None <NEW_LINE> self._sort_by = None <NEW_LINE> self._result_count = None <NEW_LINE> self._results = None <NEW_LINE> self.discri...
IpfixCollectorConfigListResult - a model defined in Swagger
625941bfa934411ee37515dc
def url_grep(): <NEW_LINE> <INDENT> for page in urls: <NEW_LINE> <INDENT> responce = requests.get(page) <NEW_LINE> result = re.findall(r"/docs/ps/mr\d{2}\S+pdf", responce.text) <NEW_LINE> for i in result: <NEW_LINE> <INDENT> links.add(''.join(i))
This function will fill the list "links" with direct links on guides.
625941bf56ac1b37e626411c
def __init__(self, lib=None): <NEW_LINE> <INDENT> self._root = TocCategory() <NEW_LINE> self._root.add_primary_titles("TOC", u"שרש") <NEW_LINE> self._path_hash = {} <NEW_LINE> self._library = lib <NEW_LINE> vss = db.vstate.find({}, {"title": 1, "first_section_ref": 1, "flags": 1}) <NEW_LINE> self._vs_lookup = {vs["titl...
:param lib: Library object, in the process of being created
625941bfadb09d7d5db6c6da
def _get_xlsx(obj, auto): <NEW_LINE> <INDENT> col_widths: Dict[Any, float] = defaultdict(float) <NEW_LINE> col = 'A' <NEW_LINE> workbook = openpyxl.Workbook() <NEW_LINE> worksheet = workbook.active <NEW_LINE> for row, data in enumerate(_tabulate(obj, auto=auto), start=1): <NEW_LINE> <INDENT> for col_idx, value in enume...
Create an XLSX workbook object. :param obj: Item, list of Items, or Document to export :param auto: include placeholders for new items on import :return: new workbook
625941bfbe383301e01b53d4
def supprDirichletConditions(vector): <NEW_LINE> <INDENT> return vector[1:-1]
Requires: -------- * vector is a np.array 2D of size (n, 1) Returns: -------- * newVector is a np.array 2D of size (n-2, 1)
625941bfbde94217f3682d3c
def _is_json_response(self, response): <NEW_LINE> <INDENT> ct_options, _ = response.get_headers().iget('X-Content-Type-Options', '') <NEW_LINE> content_type, _ = response.get_headers().iget('Content-Type', '') <NEW_LINE> if 'application/json' in content_type and 'nosniff' in ct_options: <NEW_LINE> <INDENT> return True ...
This is something I've seen in as a false positive during my assessments and is better explained in this stackoverflow question https://goo.gl/BgXVJY
625941bf99fddb7c1c9de2db
def export2pdf(self, path=None, tex_file_path=None): <NEW_LINE> <INDENT> if not tex_file_path: <NEW_LINE> <INDENT> tex_file_path = self.export2tex(path) <NEW_LINE> <DEDENT> pdf_file_path = '{}.pdf'.format(tex_file_path[:-3]) <NEW_LINE> command = 'pdflatex {}'.format(tex_file_path) <NEW_LINE> subprocess.check_call(comma...
Exports to pdf and returns the file_path
625941bfb7558d58953c4e61
def remember_me(context, request, info, *args, **kw): <NEW_LINE> <INDENT> log.debug('remember_me(%s)' % locals()) <NEW_LINE> log.debug('request.params = %r' % request.params) <NEW_LINE> endpoint = request.params['openid.op_endpoint'] <NEW_LINE> if endpoint != request.registry.settings['openid.provider']: <NEW_LINE> <IN...
Called upon successful login
625941bfad47b63b2c509ec9
def input_fn(filenames, num_epochs=None, shuffle=True, skip_header_lines=0, batch_size=200): <NEW_LINE> <INDENT> global data_p <NEW_LINE> filename_queue = tf.train.string_input_producer( filenames, num_epochs=num_epochs, shuffle=shuffle) <NEW_LINE> reader = tf.TextLineReader(skip_header_lines=skip_header_lines) <NEW_LI...
Generates an input function for training or evaluation. This uses the input pipeline based approach using file name queue to read data so that entire data is not loaded in memory. Args: filenames: [str] list of CSV files to read data from. num_epochs: int how many times through to read the data. If None ...
625941bf1b99ca400220a9f9
def get_buffet_input(self, message, markup): <NEW_LINE> <INDENT> db.set_state(message.chat.id, State.BUFFETS.value) <NEW_LINE> self.bot.send_photo(message.chat.id, open('images/other/miet.jpg', 'rb'), caption="Схема расположения корпусов «МИЭТ»", reply_markup=markup) <NEW_LINE> markup = types.ReplyKeyboardMarkup() <NEW...
Возвращаем сообщение с просьбой о вводе корпуса, в котором он сейчас находится
625941bf1b99ca400220a9fa
def batch_generator(X, labels, batch_size, steps_per_epoch, scores, rng, dk): <NEW_LINE> <INDENT> number_of_batches = steps_per_epoch <NEW_LINE> rng = np.random.RandomState(rng.randint(MAX_INT, size = 1)) <NEW_LINE> counter = 0 <NEW_LINE> while 1: <NEW_LINE> <INDENT> X1, X2, X3 = tripletBatchGeneration(X, batch_size, r...
batch generator
625941bf379a373c97cfaa8c
def test_AlphaEqualThreeWithoutMixing(self): <NEW_LINE> <INDENT> W = [1]*4+[4]*3+[16]*3 <NEW_LINE> L = dvl(W) <NEW_LINE> self.assertEqual(sorted(L),[2]*3+[4]*3+[6]*4)
Alpha Equal Three with no Mixing.
625941bff8510a7c17cf9644
def __init__(self, stream): <NEW_LINE> <INDENT> self.stream = stream
Construct a parser with the given stream. The stream is expected to contain the output of the command: xinput --list --long
625941bf3c8af77a43ae36e7
def unset_event_handler(self, event_name, handler_id): <NEW_LINE> <INDENT> self.tab.evaljs(u"{element}['on' + {event_name}] = null".format( element=self.element_js, event_name=escape_js(event_name), )) <NEW_LINE> self.event_handlers_storage.remove(handler_id)
Remove on-event type event listeners from the element
625941bfeab8aa0e5d26daa0
def add_hours(minutes_list): <NEW_LINE> <INDENT> hours_progress = [] <NEW_LINE> total = 0 <NEW_LINE> for minutes in minutes_list: <NEW_LINE> <INDENT> total += minutes / 60 <NEW_LINE> hours_progress.append(total) <NEW_LINE> <DEDENT> return hours_progress
Take a list of minutes and convert it into cumulative list of hours
625941bfc4546d3d9de7297a
def load_data(): <NEW_LINE> <INDENT> return bson.json_util.loads(open(FILE_LOCATION).read())
Load Data From JSON File :return: List representation of local "popularity" data :rtype: List
625941bf4f6381625f114986
def _get_arg_parser(): <NEW_LINE> <INDENT> desc = "Ramrod Updater v{0}: Updates STIX and CybOX documents." <NEW_LINE> desc = desc.format(ramrod.__version__) <NEW_LINE> parser = argparse.ArgumentParser(description=desc) <NEW_LINE> parser.add_argument( "--infile", default=None, required=True, help="Input STIX/CybOX docum...
Returns an ArgumentParser instance for this script.
625941bfe76e3b2f99f3a759
def build_stockholm_from_clustal_alig(clustal_file, alif_file): <NEW_LINE> <INDENT> ml.debug(fname()) <NEW_LINE> with open(clustal_file, 'r') as cf, open(alif_file, 'r') as af: <NEW_LINE> <INDENT> clust = AlignIO.read(cf, format='clustal') <NEW_LINE> temp = StringIO() <NEW_LINE> AlignIO.write(clust, temp, format='stock...
build stockholm alignment :return:
625941bf5fdd1c0f98dc017b
def __init__(self, conf, channel, topic, **kwargs): <NEW_LINE> <INDENT> options = {'durable': conf.rabbit_durable_queues, 'auto_delete': False, 'exclusive': False} <NEW_LINE> options.update(kwargs) <NEW_LINE> exchange_name = rpc_amqp.get_control_exchange(conf) <NEW_LINE> super(TopicPublisher, self).__init__(channel, ex...
init a 'topic' publisher. Kombu options may be passed as keyword args to override defaults
625941bf5f7d997b871749de
def mean_NFI(srcid, source = "all", unit="hours"): <NEW_LINE> <INDENT> unitDict = {"seconds":1, "minutes":60, "hours":3600, "days":86400} <NEW_LINE> if(type(source) == str): <NEW_LINE> <INDENT> if(source.lower() == "all"): <NEW_LINE> <INDENT> dt = srcid.sort_index() <NEW_LINE> NFIlst = pd.Series([(dt.index[i+1] - (dt.i...
Returns the average NFI for selected source type. Parameters ---------- srcid: pandas dataframe representing NPS NSNSD srcid file, formatted by soundDB library. source: str or list of floats, optional. Which subset of srcid codes to summarize - choose either "all", "air", or specify a list of srcID codes as float. D...
625941bf5166f23b2e1a50a2
def resolve_rrsets(fqdn, rdtypes): <NEW_LINE> <INDENT> assert rdtypes, "rdtypes must not be empty" <NEW_LINE> if not isinstance(fqdn, DNSName): <NEW_LINE> <INDENT> fqdn = DNSName(fqdn) <NEW_LINE> <DEDENT> fqdn = fqdn.make_absolute() <NEW_LINE> rrsets = [] <NEW_LINE> for rdtype in rdtypes: <NEW_LINE> <INDENT> try: <NEW_...
Get Resource Record sets for given FQDN. CNAME chain is followed during resolution but CNAMEs are not returned in the resulting rrset. :returns: set of dns.rrset.RRset objects, can be empty if the FQDN does not exist or if none of rrtypes exist
625941bf66673b3332b91fda
def evaluer(self, ancien_plateau, nouveau_plateau, joueur): <NEW_LINE> <INDENT> if joueur == 1: <NEW_LINE> <INDENT> result = (nouveau_plateau[13] - ancien_plateau[13])- (nouveau_plateau[6] - ancien_plateau[6]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> result = (nouveau_plateau[6] - ancien_plateau[6])- (nouveau_plat...
Evaluation des scores entre deux plateau différents :param ancien_plateau: ancien plateau :param nouveau_plateau: nouveau plateau :param joueur: joueur qui vient de jouer :return result: score
625941bf91f36d47f21ac439
def regimes_before(regime): <NEW_LINE> <INDENT> regimes = [] <NEW_LINE> for key in spectrum_wavelengths: <NEW_LINE> <INDENT> if key[0] == regime or key[1] == regime: break <NEW_LINE> else: regimes.append(key) <NEW_LINE> <DEDENT> return regimes
Thisj function ... :param regime: :return:
625941bf16aa5153ce3623c2
def max_subarray_sum_circular(A: List[int]) -> int: <NEW_LINE> <INDENT> max_curr = max_so_far = float("-inf") <NEW_LINE> min_curr = min_so_far = total = 0 <NEW_LINE> for a in A: <NEW_LINE> <INDENT> max_curr = max(max_curr + a, a) <NEW_LINE> max_so_far = max(max_so_far, max_curr) <NEW_LINE> min_curr = min(min_curr + a, ...
Time: O(n) Space: O(1)
625941bf3317a56b86939ba7
def __init__(self, conf): <NEW_LINE> <INDENT> super(QNetwork, self).__init__(conf) <NEW_LINE> with tf.name_scope(self.name): <NEW_LINE> <INDENT> self.target_ph = tf.placeholder('float32', [None], name='target') <NEW_LINE> self.loss = self._build_q_head() <NEW_LINE> self._build_gradient_ops()
Set up remaining layers, loss function, gradient compute and apply ops, network parameter synchronization ops, and summary ops.
625941bf56b00c62f0f145a1
def get_domain_http_header(self, domain, config=None): <NEW_LINE> <INDENT> return self._send_request( http_methods.GET, '/domain/' + domain + '/config', params={'httpHeader': ''}, config=config)
get http header configuration of a domain :param domain: the domain name :type domain: string :param config: None :type config: baidubce.BceClientConfiguration :return: :rtype: baidubce.bce_response.BceResponse
625941bfbd1bec0571d90577
def imread(self, filename, flags=cv2.IMREAD_COLOR, dtype=np.uint8): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> n = np.fromfile(filename, dtype) <NEW_LINE> img = cv2.imdecode(n, flags) <NEW_LINE> return img <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> print(e) <NEW_LINE> return None
OpenCVのimreadが日本語ファイル名が読めない対策
625941bf379a373c97cfaa8d
def sample_user(email='[email protected]', password='testpass'): <NEW_LINE> <INDENT> return get_user_model().objects.create_user(email, password)
Create a sample user
625941bf442bda511e8be365
def invitable(self): <NEW_LINE> <INDENT> return self.bloggers().filter( consent_form_received=False ).exclude( user__received_letters__type="consent_form" )
No invitation letter has been created for them.
625941bf090684286d50ec2c
def _y_boxes_to_xbs(boxes, voxel_size, origin) -> "[(x0, x1, y0, y1, z0, z1), ...]": <NEW_LINE> <INDENT> print("BFDS: _y_boxes_to_xbs:", len(boxes)) <NEW_LINE> xbs = list() <NEW_LINE> voxel_size_half = voxel_size / 2. <NEW_LINE> while boxes: <NEW_LINE> <INDENT> ix0, ix1, iy0, iy1, iz0, iz1 = boxes.pop() <NEW_LINE> x0, ...
Trasform boxes (int coordinates) to xbs (global coordinates).
625941bf31939e2706e4cdb6
def test_019(self): <NEW_LINE> <INDENT> grid = WaldorfGrid(["axy", "xby", "xyc"], 3, 3) <NEW_LINE> result = grid.get_char(0, 0) <NEW_LINE> self.assertEqual("a", result) <NEW_LINE> projection = grid.get_projection(0, 0, 3, Direction.SOUTH_EAST) <NEW_LINE> self.assertEqual("abc", projection)
get_projection south should value given longer valid length
625941bf50812a4eaa59c26d
def _index_to_alphabet(index): <NEW_LINE> <INDENT> return chr(ord("A") + index)
Convert the index to the alphabet.
625941bf3cc13d1c6d3c72c4
def set_dst(self,dst): <NEW_LINE> <INDENT> self.__dst = dst
! Set destination @param self this object @param dst destintion @return none
625941bf7b180e01f3dc474b
def assert_histories_equal(actual_history, expected_history): <NEW_LINE> <INDENT> local_timezone = tz.gettz() <NEW_LINE> assert _detach_timezone_stamp(actual_history) == _detach_timezone_stamp( (expected_history[0].astimezone(local_timezone), expected_history[1]) )
Assert that two histories are equal, accounting for differing timezones. Use of any Python standard library timezone-management option, such as: datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo instead of a dedicated external library, notably here dateutil.tz, would result in failures for certain...
625941bf498bea3a759b99f9
def test_str(self): <NEW_LINE> <INDENT> for i in range(512): <NEW_LINE> <INDENT> f = flag.Flag(i) <NEW_LINE> self.assertEqual(str(f), str(i))
Test __str__
625941bf44b2445a33931fe0
def transform(self,data): <NEW_LINE> <INDENT> data = [i if i in self.vocab.keys() else 'unseen' for i in list(data)] <NEW_LINE> transformed_data = [self.vocab[value] for value in data] <NEW_LINE> return np.array(transformed_data).reshape(-1,1)
This is the transform function of the label encoder. It takes the data to tansform as an argument. For every value, it looks up in the dictionary to find a match and replace it with its label. If a match is not found it relaces it with the label for the unseen values.
625941bfbe7bc26dc91cd54e
def get_last_block_header(self): <NEW_LINE> <INDENT> return self.raw_jsonrpc_request("get_last_block_header")
Block header information for the most recent block is easily retrieved with this method. Output: { "block_header": { "block_size": unsigned int; The block size in bytes. "depth": unsigned int; The number of blocks succeeding this block on the blockchain. A larger number means an older block. "difficulty" u...
625941bf23849d37ff7b2fda
def surface_plot(matrix1, matrix2, x_vec, y_vec, **kwargs): <NEW_LINE> <INDENT> (x, y) = np.meshgrid(x_vec, y_vec) <NEW_LINE> fig = plt.figure() <NEW_LINE> ax = fig.add_subplot(111, projection='3d') <NEW_LINE> surf1 = ax.plot_surface(x, y, matrix1, label = 'Approximated Surface', **kwargs) <NEW_LINE> surf2 = ax.plot_su...
Function to create 3d plot
625941bfec188e330fd5a6ed
def add_card(cards): <NEW_LINE> <INDENT> card_set = prompt.query('Enter card set: ', default='None') <NEW_LINE> card_color = prompt.query('Enter card color: ') <NEW_LINE> card_text = prompt.query('Enter card text: ') <NEW_LINE> card_creator = prompt.query('Enter card creator: ', default='None') <NEW_LINE> cards.create_...
Adds card to the database based on user input Args: cards (Cards): Cards object to interface with MongoDB Returns: None
625941bfc4546d3d9de7297b
def swapPairs(self, head): <NEW_LINE> <INDENT> p = dummy = ListNode(0); <NEW_LINE> p.next = head; <NEW_LINE> while p.next != None and p.next.next != None: <NEW_LINE> <INDENT> p.next.next.next, p.next.next, p.next, p = p.next, p.next.next.next, p.next.next, p.next <NEW_LINE> <DEDENT> return dummy.next
:type head: ListNode :rtype: ListNode
625941bf15baa723493c3ebd
def get_current_obs(self): <NEW_LINE> <INDENT> raw_obs = self.get_raw_obs() <NEW_LINE> noisy_obs = self._inject_obs_noise(raw_obs) <NEW_LINE> if self.position_only: <NEW_LINE> <INDENT> return self._filter_position(noisy_obs) <NEW_LINE> <DEDENT> return noisy_obs
This method should not be overwritten.
625941bf07d97122c41787d0
def countAndSay(self, n): <NEW_LINE> <INDENT> result = "1" <NEW_LINE> for _ in range(1, n): <NEW_LINE> <INDENT> result = self.get_result(result) <NEW_LINE> <DEDENT> return result
:type n: int :rtype: str
625941bf76e4537e8c3515bb
def simplify_coord(G): <NEW_LINE> <INDENT> for n in sorted(G.nodes, key=lambda node: node.height): <NEW_LINE> <INDENT> if n.isCoord: <NEW_LINE> <INDENT> newhead = next(iter(sorted(n.coords, key=lambda v: v.name))) <NEW_LINE> maxht = float('-inf') <NEW_LINE> for c in n.coords | n.conjuncts: <NEW_LINE> <INDENT> if c is n...
Simplify the graph by removing coordination nodes, choosing one of the coordinators as the head.
625941bfbde94217f3682d3d
def viewData(self): <NEW_LINE> <INDENT> if self.storage == []: <NEW_LINE> <INDENT> print("NO DATA IN STORAGE\n") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print('DISPLAYING STORAGE DATA:') <NEW_LINE> print(self.storage, "\n")
View data in storage.
625941bfd10714528d5ffc2a
def test00_fileCopyFileClosed(self): <NEW_LINE> <INDENT> self.h5file.close() <NEW_LINE> h5cfname = tempfile.mktemp(suffix='.h5') <NEW_LINE> try: <NEW_LINE> <INDENT> self.assertRaises(ClosedFileError, self.h5file.copy_file, h5cfname) <NEW_LINE> <DEDENT> finally: <NEW_LINE> <INDENT> if os.path.exists(h5cfname): <NEW_LINE...
Test copying a closed file.
625941bfde87d2750b85fcda
def __set__(self, records, value): <NEW_LINE> <INDENT> protected_ids = [] <NEW_LINE> new_ids = [] <NEW_LINE> other_ids = [] <NEW_LINE> for record_id in records._ids: <NEW_LINE> <INDENT> if record_id in records.env._protected.get(self, ()): <NEW_LINE> <INDENT> protected_ids.append(record_id) <NEW_LINE> <DEDENT> elif not...
set the value of field ``self`` on ``records``
625941bff7d966606f6a9f4b
@task <NEW_LINE> def dev(*args): <NEW_LINE> <INDENT> if not args: <NEW_LINE> <INDENT> print('Tips: \n1. `fab dev:hostname1,hostname2,hostname3`' '\n2. `fab dev:all`') <NEW_LINE> return <NEW_LINE> <DEDENT> if args[0] == 'all': <NEW_LINE> <INDENT> env.hosts = ['t-walis-1', 't-walis-2', 't-walis-3', 't-walis-4', 't-walis-...
Deploy dev env. :param args: host names :return:
625941bfe5267d203edcdbe9
def filerevancestors(repo, fctxs, followfirst=False): <NEW_LINE> <INDENT> gen = (rev for rev, _cs in filectxancestors(fctxs, followfirst)) <NEW_LINE> return generatorset(gen, iterasc=False, repo=repo)
Like filectx.ancestors(), but can walk from multiple files/revisions, and includes the given fctxs themselves Returns a smartset.
625941bf0fa83653e4656f06
def __init__(self, userid, name, desc, contactNumber, alternateNumber, address, landmark, pincode, locationObj, img): <NEW_LINE> <INDENT> self.userid = userid <NEW_LINE> self.name = name <NEW_LINE> self.desc = desc <NEW_LINE> self.contactNumber = contactNumber <NEW_LINE> self.alternateNumber = alternateNumber <NEW_LINE...
Return a new Car object.
625941bf73bcbd0ca4b2bfc0
def interassemblage_distance_euclidean(assemblage1freq, assemblage2freq): <NEW_LINE> <INDENT> a1 = np.array(assemblage1freq) <NEW_LINE> a2 = np.array(assemblage2freq) <NEW_LINE> return np.asscalar(np.sqrt(np.dot(a1-a2,a1-a2)))
Efficient calculation of Euclidean distance between two assemblages using Numpy dot product. :param assemblage1freq: List of frequencies for assemblage 1 :param assemblage2freq: List of frequencies for assemblage 2 :return:
625941bf0a366e3fb873e762
def do_take_replaces(self): <NEW_LINE> <INDENT> self.take_vi_replaces()
Take keyboard Input Chords to mean replace Chars, till Esc
625941bf21a7993f00bc7c36
def current_price(self, block_identifier: BlockIdentifier) -> TokenAmount: <NEW_LINE> <INDENT> return self.proxy.functions.currentPrice().call(block_identifier=block_identifier)
Gets the currently required deposit amount.
625941bf3c8af77a43ae36e8
def create_table(self): <NEW_LINE> <INDENT> conn = self.create_connection() <NEW_LINE> c = self.create_cursor(conn) <NEW_LINE> try: <NEW_LINE> <INDENT> c.execute('''CREATE TABLE material_properties (material text, band_gap real, color text)''') <NEW_LINE> self.print_or_not(' Table was created successfully.') <NEW_LINE>...
Creates table material_properties with three columns.
625941bf8da39b475bd64ebb
def str2bool(self, v): <NEW_LINE> <INDENT> return v.lower() in ("yes", "true", "t", "1")
Converts a string to a bool
625941bf8c3a873295158301
def standardize(s,ty=2): <NEW_LINE> <INDENT> data = s.dropna().copy() <NEW_LINE> if int(ty) == 1: <NEW_LINE> <INDENT> re = (data - data.min()) / (data.max() - data.min()) <NEW_LINE> <DEDENT> elif ty == 2: <NEW_LINE> <INDENT> re = (data - data.mean()) / data.std() <NEW_LINE> <DEDENT> elif ty == 3: <NEW_LINE> <INDENT> re...
标准化函数 s为Series数据 ty为标准化类型:1 MinMax,2 Standard,3 maxabs
625941bf925a0f43d2549dbf
def __init__(self, request_data, old_settings=None, custom_base_path=None): <NEW_LINE> <INDENT> self.__request_data = request_data <NEW_LINE> self.__settings = OneLogin_Saml2_Settings(old_settings, custom_base_path) <NEW_LINE> self.__attributes = [] <NEW_LINE> self.__nameid = None <NEW_LINE> self.__session_index = None...
Initializes the SP SAML instance. :param request_data: Request Data :type request_data: dict :param settings: Optional. SAML Toolkit Settings :type settings: dict|object :param custom_base_path: Optional. Path where are stored the settings file and the cert folder :type custom_base_path: string
625941bffb3f5b602dac35db
def p_adicionales(p): <NEW_LINE> <INDENT> pass
adicionales : size | rindex | sublist | contains
625941bfb57a9660fec337cc
def test_empty(self): <NEW_LINE> <INDENT> builtIns = CompilerBuiltIns([], None) <NEW_LINE> self.assertEqual(len(builtIns.include_paths), 0) <NEW_LINE> self.assertEqual(len(builtIns.defines), 0) <NEW_LINE> self.assertEqual(builtIns.compiler, None) <NEW_LINE> self.assertEqual(builtIns.std, None) <NEW_LINE> self.assertEqu...
Test empty.
625941bf82261d6c526ab3e6
def can_manage_comment_aliases(self): <NEW_LINE> <INDENT> return
Tests if this user can manage ``Id`` aliases for ``Comnents``. A return of true does not guarantee successful authorization. A return of false indicates that it is known changing an alias will result in a ``PermissionDenied``. This is intended as a hint to an application that may opt not to offer alias operations to a...
625941bf8c3a873295158302
def calculate_angle(self): <NEW_LINE> <INDENT> face_a, face_b = self.main_faces <NEW_LINE> if face_a.normal.length_squared == 0 or face_b.normal.length_squared == 0: <NEW_LINE> <INDENT> self.angle = -3 <NEW_LINE> return <NEW_LINE> <DEDENT> a_is_clockwise = ((face_a.vertices.index(self.va) - face_a.vertices.index(self.v...
Calculate the angle between the main faces
625941bf07f4c71912b113cb
def set_min_noutput_items(self, *args, **kwargs): <NEW_LINE> <INDENT> return _filter_swig.pfb_arb_resampler_fff_sptr_set_min_noutput_items(self, *args, **kwargs)
set_min_noutput_items(pfb_arb_resampler_fff_sptr self, int m)
625941bf566aa707497f44b7
def set_request_token_user(self, key, userid): <NEW_LINE> <INDENT> token = self.get_request_token(key) <NEW_LINE> if not token: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> token.userid = userid <NEW_LINE> if not token.verifier: <NEW_LINE> <INDENT> token.generate_verifier() <NEW_LINE> <DEDENT> self.DBSession.flush() ...
Register the user id for this token and also generate a verification code.
625941bf8e71fb1e9831d6f4
def getHint1(secret,guess): <NEW_LINE> <INDENT> s,g=Counter(secret),Counter(guess) <NEW_LINE> bull = sum(i == j for i,j in zip(secret,guess)) <NEW_LINE> cow = sum((s & g).values()) - bull <NEW_LINE> return '%sA%sB' %(bull,cow)
use Counter to count guess and secret and sum their overlap. use zip to counter bulls
625941bf76d4e153a657ea7a
def get_object(self): <NEW_LINE> <INDENT> user = User.objects.get( pk=self.kwargs.get('student_pk', '') ) <NEW_LINE> grade = Grade.objects.get( student=user ) <NEW_LINE> return grade
Get student grade.
625941bf442bda511e8be366
def __init__(self): <NEW_LINE> <INDENT> self.swaggerTypes = { 'EmfPlusDualRenderingMode': 'str', 'RenderingMode': 'str', 'UseEmfEmbeddedToWmf': 'bool' } <NEW_LINE> self.attributeMap = { 'EmfPlusDualRenderingMode': 'EmfPlusDualRenderingMode','RenderingMode': 'RenderingMode','UseEmfEmbeddedToWmf': 'UseEmfEmbeddedToWmf'} ...
Attributes: swaggerTypes (dict): The key is attribute name and the value is attribute type. attributeMap (dict): The key is attribute name and the value is json key in definition.
625941bf99fddb7c1c9de2dc
def base_exception_handler(*args): <NEW_LINE> <INDENT> header, frames, trcback = format_report(*extract_exception(*args)) <NEW_LINE> LOGGER.error("!> {0}".format(Constants.logging_separators)) <NEW_LINE> map(lambda x: LOGGER.error("!> {0}".format(x)), header) <NEW_LINE> LOGGER.error("!> {0}".format(Constants.logging_se...
Provides the base exception handler. :param \*args: Arguments. :type \*args: \* :return: Definition success. :rtype: bool
625941bf32920d7e50b28118
def _load_nav_graphs(self): <NEW_LINE> <INDENT> print('Loading navigation graphs for %d scans' % len(self.scans)) <NEW_LINE> self.graphs = load_nav_graphs(self.scans) <NEW_LINE> self.paths = {} <NEW_LINE> for scan, G in self.graphs.items(): <NEW_LINE> <INDENT> self.paths[scan] = dict(nx.all_pairs_dijkstra_path(G)) <NEW...
load graph from self.scan, Store the graph {scan_id: graph} in self.graphs Store the shortest path {scan_id: {view_id_x: {view_id_y: [path]} } } in self.paths Store the distances in self.distances. (Structure see above) Load connectivity graph for each scan, useful for reasoning about shortest paths :return: None
625941bfd164cc6175782c98
def __init__(self, dmavendors=None): <NEW_LINE> <INDENT> self._dmavendors = None <NEW_LINE> self.discriminator = None <NEW_LINE> if dmavendors is not None: <NEW_LINE> <INDENT> self.dmavendors = dmavendors
NdmpSettingsDmas - a model defined in Swagger
625941bfb545ff76a8913d60
def get_scrobbler(self, client_id, client_version): <NEW_LINE> <INDENT> return Scrobbler(self, client_id, client_version)
Returns a Scrobbler object used for submitting tracks to the server Quote from http://www.last.fm/api/submissions: ======== Client identifiers are used to provide a centrally managed database of the client versions, allowing clients to be banned if they are found to be behaving undesirably. The client ID is associated...
625941bf0a50d4780f666dda
def _format_download_uri(etextno, mirror): <NEW_LINE> <INDENT> uri_root = (mirror or _GUTENBERG_MIRROR).strip().rstrip('/') <NEW_LINE> _check_mirror_exists(uri_root) <NEW_LINE> extensions = ('.txt', '-8.txt', '-0.txt') <NEW_LINE> for extension in extensions: <NEW_LINE> <INDENT> path = _etextno_to_uri_subdirectory(etext...
Returns the download location on the Project Gutenberg servers for a given text. Raises: UnknownDownloadUri: If no download location can be found for the text.
625941bf23e79379d52ee4b0
def averageOfLevels(self, root): <NEW_LINE> <INDENT> q = deque() <NEW_LINE> if root: <NEW_LINE> <INDENT> q.append((root, 0)) <NEW_LINE> <DEDENT> m = defaultdict(list) <NEW_LINE> max_level = 0 <NEW_LINE> while q: <NEW_LINE> <INDENT> node, level = q.popleft() <NEW_LINE> if node: <NEW_LINE> <INDENT> m[level].append(node.v...
:type root: TreeNode :rtype: List[float]
625941bf046cf37aa974cc94
def prepare(data): <NEW_LINE> <INDENT> return (data[0].astype(np.float32).reshape([-1, 784]) / 255.0, data[1].astype(np.int32))
Cast to float, normalize and reshape from 28x28 2D images to a vector of 784
625941bf9c8ee82313fbb6bf
def _repr_(self): <NEW_LINE> <INDENT> return ('Semimonomial transformation group over %s'%self.base_ring() + ' of degree %s'%self.degree())
Returns a string describing ``self``. EXAMPLES:: sage: F.<a> = GF(4) sage: SemimonomialTransformationGroup(F, 3) # indirect doctest Semimonomial transformation group over Finite Field in a of size 2^2 of degree 3
625941bf66673b3332b91fdb
def __init__(self, dct): <NEW_LINE> <INDENT> for k in self.__slots__: <NEW_LINE> <INDENT> v = dct.get(k, None) <NEW_LINE> if k in {"train_root", "val_root", "trainval_root"}: <NEW_LINE> <INDENT> v = Path(v) <NEW_LINE> <DEDENT> setattr(self, k, v)
:param dct:
625941bf460517430c3940d5
def sum_hand_points(self): <NEW_LINE> <INDENT> self.hand_points = 0 <NEW_LINE> for card in self.cards_in_hand: <NEW_LINE> <INDENT> self.hand_points += card_to_value(card)
Calculates the sum of point in a hand
625941bfbe8e80087fb20b91
def __init__(self, integ_br, root_helper, polling_interval): <NEW_LINE> <INDENT> self.int_br = ovs_lib.OVSBridge(integ_br, root_helper) <NEW_LINE> self.polling_interval = polling_interval <NEW_LINE> self.cur_ports = [] <NEW_LINE> self.datapath_id = "0x%s" % self.int_br.get_datapath_id() <NEW_LINE> self.agent_state = { ...
Constructor. :param integ_br: name of the integration bridge. :param root_helper: utility to use when running shell cmds. :param polling_interval: interval (secs) to check the bridge.
625941bf63f4b57ef0001069
def test_api_v1_template_programmer_project_project_id_delete(self): <NEW_LINE> <INDENT> pass
Test case for api_v1_template_programmer_project_project_id_delete Deletes the project # noqa: E501
625941bf711fe17d825422bb
def get_quota_work_hours(year, month, hours_per_day): <NEW_LINE> <INDENT> return get_number_of_work_days(year, month) * hours_per_day
Return quota hours for given year and month - enter work hours_per_day.
625941bf7047854f462a1357
def test_get_allowed_origins_with_substitute(self): <NEW_LINE> <INDENT> apt_pkg.config.clear("Unattended-Upgrade::Allowed-Origins") <NEW_LINE> apt_pkg.config.set("Unattended-Upgrade::Allowed-Origins::", "${distro_id} ${distro_codename}-security") <NEW_LINE> li = get_allowed_origins() <NEW_LINE> self.assertTrue(("o=MyDi...
test if substitute for get_allowed_origins works
625941bfa219f33f346288b7
def size(self, taxonomy=None): <NEW_LINE> <INDENT> size = 0 <NEW_LINE> for field in self.fields: <NEW_LINE> <INDENT> size = size + field.size(taxonomy) <NEW_LINE> <DEDENT> return size
Compute the size for the fields in the message.
625941bfbe383301e01b53d6
def filtrarPeliculaPorActor(self): <NEW_LINE> <INDENT> self.ui.peliculaImagenLabel.setPixmap(QtGui.QPixmap("")) <NEW_LINE> self.ui.tramaPLabel.clear() <NEW_LINE> index = self.ui.buscarPActorComboBox.currentIndex() <NEW_LINE> if (index != 0): <NEW_LINE> <INDENT> nombre = self.ui.buscarPActorComboBox.itemText(index) <NEW...
Filtra las películas por el actor que participo en ellas luego de seleccionar dicho actor desde el comboBox en el Tab de las Películas.
625941bfbde94217f3682d3e
def __sub__(self, dist): <NEW_LINE> <INDENT> if not isinstance(dist, Distance): <NEW_LINE> <INDENT> raise TypeError('Cannot subtract', type(dist), 'from a', type(self), 'object.') <NEW_LINE> <DEDENT> return self + -1 * dist
Subtract a Distance object from another Distance object and return a new Distance.
625941bfb7558d58953c4e63
def global_settings(request): <NEW_LINE> <INDENT> account_links = [] <NEW_LINE> tools_links = [] <NEW_LINE> footer_links = [] <NEW_LINE> context = {} <NEW_LINE> tools_title = _('Tools') <NEW_LINE> context['user'] = request.user <NEW_LINE> if request.user.is_authenticated(): <NEW_LINE> <INDENT> context['is_reviewer'] = ...
Store global Marketplace-wide info. used in the header.
625941bf3eb6a72ae02ec421
def newNDChannel(self, project_name, channel_name): <NEW_LINE> <INDENT> ch = NDChannel.fromName(self.pr, channel_name) <NEW_LINE> pass
Create the tables for a channel
625941bf377c676e912720f4
def get_xy_contiguous_bounded_grids(cube): <NEW_LINE> <INDENT> x_coord, y_coord = cube.coord(axis="X"), cube.coord(axis="Y") <NEW_LINE> x = x_coord.contiguous_bounds() <NEW_LINE> y = y_coord.contiguous_bounds() <NEW_LINE> x, y = np.meshgrid(x, y) <NEW_LINE> return (x, y)
Return 2d arrays for x and y bounds. Returns array of shape (n+1, m+1). Example:: xs, ys = get_xy_contiguous_bounded_grids(cube)
625941bff548e778e58cd4c7
def mask_secret_parameters(parameters, secret_parameters, result=None): <NEW_LINE> <INDENT> iterator = None <NEW_LINE> is_dict = isinstance(secret_parameters, dict) <NEW_LINE> is_list = isinstance(secret_parameters, list) <NEW_LINE> if is_dict: <NEW_LINE> <INDENT> iterator = six.iteritems(secret_parameters) <NEW_LINE> ...
Introspect the parameters dict and return a new dict with masked secret parameters. :param parameters: Parameters to process. :type parameters: ``dict`` or ``list`` or ``string`` :param secret_parameters: Dict of parameter names which are secret. The type must be the same type as ``parameters...
625941bf091ae35668666ead
def test_number_set_attribute(self): <NEW_LINE> <INDENT> attr = NumberSetAttribute() <NEW_LINE> assert attr is not None <NEW_LINE> attr = NumberSetAttribute(default={1, 2}) <NEW_LINE> assert attr.default == {1, 2}
NumberSetAttribute.default
625941bf01c39578d7e74d86
def create(self, validated_data): <NEW_LINE> <INDENT> return Project.objects.create(**validated_data)
Create and return a new `Project` instance, given the validated data.
625941bf7cff6e4e811178d0
def test_message_already_unreacted(url, user_1, user_2, public_channel_1): <NEW_LINE> <INDENT> requests.post(f"{url}/channel/join", json={ 'token': user_2['token'], 'channel_id': public_channel_1['channel_id'] }) <NEW_LINE> msg_1 = request_message_send(url, user_1['token'], public_channel_1['channel_id'], "Hello").json...
Test for unreacting to a message that is already unreacted to.
625941bfff9c53063f47c13f
def playfile(filename,mimetable=mimetable,**options): <NEW_LINE> <INDENT> contenttype,encoding = mimetypes.guess_type(filename) <NEW_LINE> if contenttype == None or encoding is not None: <NEW_LINE> <INDENT> contenttype = '?/?' <NEW_LINE> <DEDENT> maintype,subtype = contenttype.split('/',1) <NEW_LINE> if maintype == 'te...
播放任意类型媒体文件:使用mimetypes猜测媒体类型并对应到平台特异的播放器表格; 如果是文本/html,或者未知媒体类型,或者没有播放器表格,则派生网页浏览器 :param filename: :param mimetable: :param options: :return:
625941bf7d847024c06be204
def setFast(self): <NEW_LINE> <INDENT> self.max_num_bases = 7
For some unit tests, calling this will speed the run of the test by making some model build parameters very high-speed, low accuracy.
625941bf507cdc57c6306c20
def __init__(self): <NEW_LINE> <INDENT> SloaneSequence.__init__(self, offset=0)
The all 1's sequence. INPUT: - ``n`` -- non negative integer OUTPUT: - ``integer`` -- function value EXAMPLES:: sage: a = sloane.A000012; a The all 1's sequence. sage: a(1) 1 sage: a(2007) 1 sage: a.list(12) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] AUTHORS: - Jaap Spies (2007-01-12)
625941bf85dfad0860c3ada4
def update_collection(collection_uuid, title): <NEW_LINE> <INDENT> assert isinstance(collection_uuid, UUID) <NEW_LINE> data = {"title": title} <NEW_LINE> result = api_request('patch', api_url('collections', str(collection_uuid)), json=data) <NEW_LINE> return _collection_from_response(result)
Update a collection's title
625941bf94891a1f4081b9f3