code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def test_tag_str(self): <NEW_LINE> <INDENT> tag = models.Tag.objects.create( user=sample_user(), name='Vegan' ) <NEW_LINE> self.assertEqual(str(tag), tag.name)
Test Tag String Representation
625941d7d53ae8145f87a4c5
@options(base=10) <NEW_LINE> def list_plot_semilogx(data, plotjoined=False, **kwds): <NEW_LINE> <INDENT> return list_plot(data, plotjoined=plotjoined, scale='semilogx', **kwds)
Plot ``data`` in 'semilogx' scale, that is, the horizontal axis will be in logarithmic scale. INPUT: - ``base`` -- (default: 10) the base of the logarithm. This must be greater than 1. For all other inputs, look at the documentation of :func:`list_plot`. EXAMPLES:: sage: yl = [2**k for k in range(12)] sa...
625941d75fcc89381b1e191a
def vertimus_by_stats_id(request, stats_id, lang_id): <NEW_LINE> <INDENT> stats = get_object_or_404(Statistics, pk=stats_id) <NEW_LINE> lang = get_object_or_404(Language, pk=lang_id) <NEW_LINE> return vertimus(request, stats.branch, stats.domain, lang, stats)
Access to Vertimus view by a Statistics ID
625941d77cff6e4e81117bde
def isSameTree(self, p, q): <NEW_LINE> <INDENT> pp = p <NEW_LINE> qq = q <NEW_LINE> p_stack = [] <NEW_LINE> q_stack = [] <NEW_LINE> while True: <NEW_LINE> <INDENT> if pp is None and qq is None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> pp = p_stack.pop().right <NEW_LINE> qq = q_stack.pop().right <NEW_LINE> <DEDENT> ...
:type p: TreeNode :type q: TreeNode :rtype: bool
625941d71d351010ab855d75
def test_read_events(self): <NEW_LINE> <INDENT> filename = os.path.join(self.path, 'gse_2.0_2_events.txt') <NEW_LINE> catalog = read_events(filename) <NEW_LINE> self.assertEqual(len(catalog), 2)
Tests reading a GSE2.0 document via read_events.
625941d7fff4ab517eb2f696
def load_stl_binary(file_obj): <NEW_LINE> <INDENT> header_length = _stl_dtype_header.itemsize <NEW_LINE> header_data = file_obj.read(header_length) <NEW_LINE> if len(header_data) < header_length: <NEW_LINE> <INDENT> raise HeaderError('Binary STL file not long enough to contain header!') <NEW_LINE> <DEDENT> header = np....
Load a binary STL file from a file object. Parameters ---------- file_obj: open file- like object Returns ---------- loaded: kwargs for a Trimesh constructor with keys: vertices: (n,3) float, vertices faces: (m,3) int, indexes of vertices face_normals: (m,3) float, normal vect...
625941d7d58c6744b4257eb8
def __init__(self): <NEW_LINE> <INDENT> self._cached = None <NEW_LINE> self._callback = None
Constructor
625941d7097d151d1a2230b1
@log_json <NEW_LINE> @log_resources <NEW_LINE> @to_resources <NEW_LINE> def check_unused_rt(g): <NEW_LINE> <INDENT> return g.V().hasLabel("route_target").not_( __.in_().hasLabel(within("routing_instance", "logical_router")) )
unused route-target
625941d7377c676e91272401
def transpose(self): <NEW_LINE> <INDENT> pass
(SquareMatrix) -> SquareMatrix Returns the transpose of a square matrix
625941d707d97122c4178ae8
def loss(softmax_re, labels): <NEW_LINE> <INDENT> with tf.name_scope('loss'): <NEW_LINE> <INDENT> log_tf = tf.log(softmax_re, name = 'log_name') <NEW_LINE> entroy = tf.reduce_mean( -tf.reduce_sum(labels * log_tf, reduction_indices=[1])) <NEW_LINE> <DEDENT> return entroy
Calculates the loss. Args: softmax_re: net forward output tensor, float - [batch_size, NUM_CLASSES] labels: labels tensor, Return: entroy: Loss tensor of type float
625941d7046cf37aa974cfa0
def dropUpdate(self, path): <NEW_LINE> <INDENT> self.index = self.GetItemCount() <NEW_LINE> msg_dir = _("Directories are not allowed, just add files, please.") <NEW_LINE> msg_noext = _("File without format extension: please give an " "appropriate extension to the file name, example " "'.mkv', '.avi', '.mp3', etc.") <NE...
Update list-control during drag and drop
625941d707f4c71912b116dd
def append_exp_to_fixations(self): <NEW_LINE> <INDENT> _f = self.events <NEW_LINE> _e = self.experiment <NEW_LINE> _f.loc[:, 'res'] = np.nan <NEW_LINE> _f.loc[:, 'subject'] = self.subject <NEW_LINE> _f.loc[:, 'gi'] = np.nan <NEW_LINE> _f.loc[:, 'mi'] = np.nan <NEW_LINE> _f.loc[:, 'status'] = np.nan <NEW_LINE> _f.loc[:,...
Append the relevant data from experiment to fixations data
625941d732920d7e50b2842b
def spk_phase(t, V1, V2, spike_thresh=0): <NEW_LINE> <INDENT> time1 = t[sp.logical_and(V1[:-1] < spike_thresh, V1[1:] >= spike_thresh)] <NEW_LINE> time2 = t[sp.logical_and(V2[:-1] < spike_thresh, V2[1:] >= spike_thresh)] <NEW_LINE> l = sp.amin([len(time1), len(time2)]) <NEW_LINE> isi_mean = sp.mean(sp.diff(time1)) <NEW...
phase_mean, isi_mean = spk_phase(t, V1, V2, spike_thresh=0) Given two voltage vectors (V1 and V2) and time vector (t), phase calculates the mean phase of the spikes in radians (phase_mean) and the mean interspike interval (isi_mean). You can optionally specify the spike threshold (defaults to 0). This uses an assump...
625941d7a8370b7717052af8
def _pad_sequences(self, sequences: List[List[int]]): <NEW_LINE> <INDENT> for i in range(len(sequences)): <NEW_LINE> <INDENT> sequences[i] = sequences[i][ : self.config["max_sequence_length"] - 1 ] <NEW_LINE> <DEDENT> sequence_lengths = [len(sequence) for sequence in sequences] <NEW_LINE> maxpadded_sequences = torch.fu...
Given tokenized sequences (either questions, answers or answer options, tokenized in ``__getitem__``), padding them to maximum specified sequence length. Return as a tensor of size ``(*, max_sequence_length)``. This method is only called in ``__getitem__``, chunked out separately for readability. Parameters ---------...
625941d78c3a873295158616
def __write_sacXY(trace, buf, **kwargs): <NEW_LINE> <INDENT> t = SacIO(trace) <NEW_LINE> t.write_sac_xy(buf)
Writes a single trace to alphanumeric SAC file. .. warning:: This function should NOT be called directly, it registers via the the :meth:`~obspy.core.trace.Stream.write` method of an ObsPy :class:`~obspy.core.trace.Stream` object, call this instead. :param trace: The ObsPy Trace object to write. :type tra...
625941d730dc7b7665901bbe
def getProxyName(self): <NEW_LINE> <INDENT> return self.proxyName
Get the Proxy name @return: the proxy name
625941d7cb5e8a47e48b7d01
def top_split(measures_table, split_by, percentile=95, loud=False): <NEW_LINE> <INDENT> cutoff = np.percentile(measures_table[split_by].values, percentile) <NEW_LINE> column_name = "top_" + split_by <NEW_LINE> labelled_measures_table = measures_table.copy() <NEW_LINE> labelled_measures_table[column_name] = 0 <NEW_LINE>...
Labels player's behavioural measures according to their presence in the top percentile of a given measure (split_by). Label column will be 1 if in the top percentile, 0 if not. E.g. if split_by is 'total_wagered' and percentile is 95, players in the top 5% by total wagered will be labelled 1, and all others 0.
625941d7d4950a0f3b08c5a6
def __init__(self): <NEW_LINE> <INDENT> self.errors = 0 <NEW_LINE> self.fatals = 0 <NEW_LINE> self.warnings = 0 <NEW_LINE> self.totals = 0 <NEW_LINE> self.msgs = []
Constructor
625941d7498bea3a759b9d08
def genesisBlock(self): <NEW_LINE> <INDENT> genBlock = block(0, "Gensis Block", 0).findProof() <NEW_LINE> self.chain.append(genBlock)
Create the first block with special input
625941d70383005118ecf83b
def GetScores(self, d_thr=10.0): <NEW_LINE> <INDENT> self.__init(d_thr=d_thr) <NEW_LINE> self.rad_exp=self.Normalize(self.rad_exp) <NEW_LINE> self.rad_real_m=self.Normalize(self.rad_real_m) <NEW_LINE> mse=self.MSEerror(self.rad_exp, self.rad_real_m) <NEW_LINE> mpe=self.MPEerror(self.rad_exp, self.rad_real_m) <NEW_LINE>...
Compute errors between radius values in the expiremental graph the true one Output: - mse: minimum mean square error - mpe: mean percentage error - kse: kolomogorov smirnove measure
625941d7009cb60464c6360a
def get_range(expr): <NEW_LINE> <INDENT> def round(max, x): <NEW_LINE> <INDENT> if x < 0 or x > max: <NEW_LINE> <INDENT> return max <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return x <NEW_LINE> <DEDENT> <DEDENT> if type(expr) in [int, long]: <NEW_LINE> <INDENT> return (expr, expr) <NEW_LINE> <DEDENT> assert type(ex...
Get the range of bits for shifting :param expr: :return: A tuple of maximum and minimum bits to shift
625941d7596a897236089d18
def mktemp(self): <NEW_LINE> <INDENT> self.tempdir = tempfile.mkdtemp() <NEW_LINE> f = open(os.path.join(self.tempdir, 'instance0.log'), 'w') <NEW_LINE> f.close() <NEW_LINE> return f.name
Create a temporary file to use as the path for the eventlog. We don't actually care about the contents of this file, we just need it to get a valid writable path to pass to the eventlog config, so ftw.contentstats can derive its own logfile path from it. We create this in a known tempdir so we can also clean up the co...
625941d7e5267d203edcdef4
def supports_composition_lookup(self): <NEW_LINE> <INDENT> return False
Tests if composition lookup is supported. return: (boolean) - ``true`` if composition lookup is supported ``,`` ``false`` otherwise *compliance: mandatory -- This method must be implemented.*
625941d7adb09d7d5db6c9e8
@COMMENTS.route('/comments', methods=['GET']) <NEW_LINE> def get_comment(): <NEW_LINE> <INDENT> pass
This method allows a user to get their own comment(s)
625941d75fc7496912cc3bd8
def reduce_puzzle(values): <NEW_LINE> <INDENT> solved_values = [box for box in values.keys() if len(values[box]) == 1] <NEW_LINE> stalled = False <NEW_LINE> while not stalled: <NEW_LINE> <INDENT> solved_values_before = len([box for box in values.keys() if len(values[box]) == 1]) <NEW_LINE> values = eliminate(values) <N...
Reduces the sudoku by using combination of elimination, naked twin elimination, and filling only choice.
625941d767a9b606de4a8112
def simplify(s): <NEW_LINE> <INDENT> return ' '.join(''.join(c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) in PRINTABLE).split()).upper()
Function to remove any UTF-8 character transforming it to a [A-Z] character, any other symbol or punctuation is transformed into a space.
625941d7442bda511e8be66f
def fix_gff_names(abinit_list, gff_list, output_file): <NEW_LINE> <INDENT> remove_files(output_file) <NEW_LINE> with open(output_file, 'a+') as f: <NEW_LINE> <INDENT> for item in gff_list: <NEW_LINE> <INDENT> if len(item) > 2: <NEW_LINE> <INDENT> if item[2] == "match": <NEW_LINE> <INDENT> check_name = get_true_name(ite...
takes in both the gff and abinit list and replaces poorly annoated abinit gene names with the markings of a gene in gff3 format :abinit_list: TODO :gff_list: ['Chr6', 'maker', 'exon', '131200', '131899', '.', '+', '.', 'ID=maker-Chr6-snap-gene-0.137-mRNA-1:exon:31;Parent=maker-Chr6-snap-gene-0.137-mRNA-1'] :returns: f...
625941d7fb3f5b602dac38ef
def _weight_bias_variable(self, shape): <NEW_LINE> <INDENT> m = reduce(mul, shape[:-1]) + 1 <NEW_LINE> n = shape[-1] <NEW_LINE> limit = tf.sqrt(6./(m + n)) <NEW_LINE> tensor_var = tf.Variable(tf.random_uniform([m, n], minval=-limit, maxval=limit)) <NEW_LINE> weight, bias = tf.slice(tensor_var, [0, 0], [m-1, n]), tf.sli...
generates a weight and bias variable of a given shape.
625941d729b78933be1e5902
def suite(): <NEW_LINE> <INDENT> suite = unittest.TestSuite() <NEW_LINE> suite.addTest(unittest.makeSuite(ZoomClientTestCase)) <NEW_LINE> return suite
Define all the tests of the module.
625941d7656771135c3ebacb
def fit_slices_2d_expo(xdata, ydata, zdata, tdata, xbins, ybins, nbins_z, zrange=None, min_entries = 1e2, ignore_errors = _FIT_EXCEPTIONS): <NEW_LINE> <INDENT> nbins_x = np.size (xbins) - 1 <NEW_LINE> nbins_y = np.size (ybins) - 1 <NEW_LINE> nbins = nbins_x, nbins_y <NEW_LINE> const = np.zeros(nbins) <NEW_LINE> s...
Slice the data in x and y, make the profile in z of t, fit it to a exponential and return the relevant values. Parameters ---------- xdata, ydata, zdata, tdata: array_likes Values of each coordinate. xbins, ybins: array_like The bins in the x coordinate. nbins_z: int The number of bins in the z coordinate ...
625941d732920d7e50b2842c
def __call__(self, input): <NEW_LINE> <INDENT> stages, block_func = self.depth_cfg[self.depth] <NEW_LINE> stages = stages[0:5] <NEW_LINE> conv = self._conv_norm( input=input, ch_out=32, filter_size=3, stride=1, padding=1, name=self.prefix_name + "yolo_input") <NEW_LINE> downsample_ = self._downsample( input=conv, ch_ou...
Get the backbone of DarkNet, that is output for the 5 stages. Args: input (Variable): input variable. Returns: The last variables of each stage.
625941d7dd821e528d63b402
def get_annotated_oncokb_curated_genes_by_entrezId(): <NEW_LINE> <INDENT> curated_genes = get_oncokb_curated_genes() <NEW_LINE> entrez_ids = [] <NEW_LINE> for gene in curated_genes: <NEW_LINE> <INDENT> entrez_ids += [gene["entrezGeneId"]] <NEW_LINE> <DEDENT> return entrez_ids
Get a list with the Entrez Gene IDs of the OncoKB Curated Gene List, only the genes that have annotations.
625941d7293b9510aa2c34ee
def get_docval_args(func): <NEW_LINE> <INDENT> func_docval = getattr(func, docval_attr_name, None) <NEW_LINE> if func_docval: <NEW_LINE> <INDENT> return tuple(a for a in func_docval[__docval_args_loc] if 'default' not in a) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return tuple()
get_docval_args(func) Like get_docval, but return only positional arguments
625941d760cbc95b062c679d
def deserialize(self, str): <NEW_LINE> <INDENT> codecs.lookup_error("rosmsg").msg_type = self._type <NEW_LINE> try: <NEW_LINE> <INDENT> if self.header is None: <NEW_LINE> <INDENT> self.header = std_msgs.msg.Header() <NEW_LINE> <DEDENT> end = 0 <NEW_LINE> _x = self <NEW_LINE> start = end <NEW_LINE> end += 12 <NEW_LINE> ...
unpack serialized message in str into this message instance :param str: byte array of serialized message, ``str``
625941d7236d856c2ad44a36
def do_set(self, line): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if int(line) > -1: <NEW_LINE> <INDENT> cq.conf.set_cache('set', line) <NEW_LINE> <DEDENT> <DEDENT> except: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> self.prompt = '({}:{}) '.format(cq.settings['level'], cq.conf.cache('set'))
Overwrite target cacheset. Example: set 12
625941d7167d2b6e31218def
def _backup(self, node, value): <NEW_LINE> <INDENT> cur_node = node <NEW_LINE> if cur_node: <NEW_LINE> <INDENT> cur_node.N += 1 <NEW_LINE> cur_node.Q += 1.0 * (value - cur_node.Q) / cur_node.N <NEW_LINE> cur_node.u = settings.c_puct * cur_node.P * np.sqrt(cur_node.parent.N / (1 + cur_node.N)) <NEW_LINE> self._backup(cu...
:param node: tree nodes that are in the path to a leaf node :param value: leaf node value or the opposite value :return: update in-place
625941d70383005118ecf83c
def save_current_frame(self): <NEW_LINE> <INDENT> if self.cur_frame is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> dat = self.cur_frame.convert_to_json() <NEW_LINE> frame_path = os.path.join(self.project_path, "levels", "%d.lvl" % self.cur_frame.frame_no) <NEW_LINE> open(frame_path, "w").write(dat)
save the current frame to its json (.lvl) file
625941d797e22403b379d1f5
def get_recording_reply(_info): <NEW_LINE> <INDENT> recording_url = _info <NEW_LINE> api_url = 'http://www.tuling123.com/openapi/api/v2' <NEW_LINE> dat = { 'reqType': 2, 'perception': { 'inputMedia': { 'url': recording_url } }, 'userInfo': { 'apiKey': '40f93ab6a92a49ff909b329df2a54f0c', 'userId': 'weChatRobot' } } <NEW...
回复语音类的消息 :param _info: 语音链接,例如./fun.mp3 :return:一个list,可能有一个元素,可能有多个元素
625941d7a17c0f6771cbe2aa
def __ne__(self, other): <NEW_LINE> <INDENT> return not (self == other)
Checks if two vectors are unequal :param other: :type other: Vec2D :return: False if equal, true otherwise :rtype: bool
625941d799cbb53fe6792e40
def upload_file(fileID): <NEW_LINE> <INDENT> if request.method == 'POST': <NEW_LINE> <INDENT> if fileID not in request.files: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> inFile = request.files[fileID] <NEW_LINE> if inFile.filename == '': <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDE...
Returns the uploaded file with fileID. None if no file uploaded.
625941d7bd1bec0571d9088a
def delete_subscription(self, project, topic_name, subscription_name): <NEW_LINE> <INDENT> subscriber = pubsub_v1.SubscriberClient() <NEW_LINE> topic_path = subscriber.topic_path(project, topic_name) <NEW_LINE> subscription_path = subscriber.subscription_path( project, subscription_name) <NEW_LINE> subscription = subsc...
Delete a ubscription on the given topic.
625941d7a79ad161976cc3a0
def parse_partial(self, string): <NEW_LINE> <INDENT> return self.parse_input(Input(string, 0))
String -> Success | Failure
625941d7498bea3a759b9d09
@FourierTransformReconstructor.register("fried") <NEW_LINE> def fried_filter(n): <NEW_LINE> <INDENT> ff = scipy.fftpack.fftfreq(n, 1/(2*np.pi)) <NEW_LINE> fx, fy = np.meshgrid(ff, ff) <NEW_LINE> gx = (np.exp(1j*fy/2) + 1)*(np.exp(1j*fx) - 1) <NEW_LINE> gy = (np.exp(1j*fx/2) + 1)*(np.exp(1j*fy) - 1) <NEW_LINE> gx[n/2,:]...
The fried filter is for a system geometry where the slope measruement points are taken to be the difference between two adjacent points. As such, the slopes are reconstructed to be the phase points 1/2 a subaperture away from the measured point. In this scheme, the slope measruement in the center of four phase measur...
625941d7a934411ee37518ee
def text_cleaning(text): <NEW_LINE> <INDENT> text = str(text) <NEW_LINE> text = text.lower() <NEW_LINE> for punc_char in string.punctuation: <NEW_LINE> <INDENT> if punc_char == "-": <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> text = text.replace(punc_char, "") <NEW_LINE> <DEDENT> text = text.replace("—", "") <NEW_...
Функция получает текст, выводит текст без знаков препинания (оставляя дефис) и без цифр :param text: :return text:
625941d750812a4eaa59c57a
def format_tweet(user_id, template_options, game=None): <NEW_LINE> <INDENT> global config <NEW_LINE> user = config['streamers'][user_id] <NEW_LINE> time = strftime('%H:%M', gmtime()) <NEW_LINE> tweet = choice(template_options).format(time=time, display_name=user['display_name'], name=user['name'], game=game) <NEW_LINE>...
Given a twitch user id and a list of tweet string templates, pick a random tweet template and fill it with details from the given user and return it.
625941d731939e2706e4d0c1
def set_shader(self, shader): <NEW_LINE> <INDENT> self.sprite.set_shader(shader)
wrapper for Shape.set_shader
625941d7dc8b845886cb5790
def fill_func_dielectric(self, x, em, e1, v, w): <NEW_LINE> <INDENT> A = v * (e1 - em) / (e1 + 2.0*em + w*(x - em) ) <NEW_LINE> B = (x - em) / (x + 2.0*em + w*(x-em) ) <NEW_LINE> return B-A
From paper 'effect of interphase on effective permittivity of composites, used in conj w/ newton rhapson
625941d73d592f4c4ed1d2c3
def poll(self, timeout=None): <NEW_LINE> <INDENT> raise NotImplementedError()
The return value is two list of objects that are ready: (rlist, wlist).
625941d7e76e3b2f99f3aa62
def test_xjson_queries(self): <NEW_LINE> <INDENT> elems = self.xjson['.//nvcl:scannedBorehole'] <NEW_LINE> self.assertTrue(len(elems) > 0) <NEW_LINE> elems2 = self.xjson['.//nvcl:scannedBorehole'] <NEW_LINE> self.assertEqual(len(elems2), len(elems))
Check that queries can run multiple times and get the same results
625941d721a7993f00bc7f4d
def reset(self): <NEW_LINE> <INDENT> self._buffer = None
Reset the slip internal buffer.
625941d72eb69b55b151cb0c
def get_privat24_transaction_model(): <NEW_LINE> <INDENT> from . import app_settings <NEW_LINE> from django.db.models import get_model <NEW_LINE> transaction_model = None <NEW_LINE> try: <NEW_LINE> <INDENT> transaction_model_name = app_settings.PRIVAT24_TRANSACTION_MODEL <NEW_LINE> app_label, model_name = transaction_m...
Return the Privat24Transaction model that is active in this project
625941d7004d5f362079a58c
def process_directory_contents_acl(self, directory_contents, path): <NEW_LINE> <INDENT> for entry in directory_contents: <NEW_LINE> <INDENT> if entry['type'] == 'FS_FILE_TYPE_DIRECTORY': <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.fs_set_acl(os.path.join(path, entry['name']), is_directory=True) <NEW_LINE> <DEDENT...
do the right thing for files and directories
625941d74428ac0f6e5baa4d
@cache('run') <NEW_LINE> def wtw_space_requirements(): <NEW_LINE> <INDENT> return 2
Real Name: WTW Space Requirements Original Eqn: 2 Units: Dmnl Limits: (None, None) Type: constant
625941d78e7ae83300e4b227
def test_home_page(self): <NEW_LINE> <INDENT> response = self.client.get(reverse("pub-index")) <NEW_LINE> self.assertEqual(response.status_code, 200)
Test if the home page renders
625941d75fcc89381b1e191b
def SetProfile(self, profile): <NEW_LINE> <INDENT> logging.debug("SetProfile({})".format(profile)) <NEW_LINE> return self.direct_output.SetProfile(self.device_handle, profile)
Sets the profile used on the device. Required Arguments: device_handle -- ID of device profile -- full path of the profile to activate. passing None will clear the profile.
625941d7be8e80087fb20e9a
def ud_treeItem(self, item, **kwargs): <NEW_LINE> <INDENT> super(Groups, self).ud_treeItem(item, **kwargs) <NEW_LINE> item.setText(0, item.itemObj.grpCode) <NEW_LINE> item.setText(1, item.itemObj.grpName) <NEW_LINE> item.setText(2, str(item.itemObj.grpGrade)) <NEW_LINE> item.setBackgroundColor((self.tw_tree.columnCount...
Update item data and settings :param item: Group tree item :type item: newItem :param kwargs: Group item data (key must starts with 'grp') :type kwargs: dict
625941d75f7d997b87174cf4
def _update_style_picker(self): <NEW_LINE> <INDENT> paragraph_style_name, character_style_name = self.get_style_at_pos(self.GetBuffer(), self.GetAdjustedCaretPosition (self.GetCaretPosition())) <NEW_LINE> if character_style_name: <NEW_LINE> <INDENT> self._style_picker.SetSelection(self._style_picker.FindString(characte...
Show current style under cursor in the style box.
625941d7796e427e537b0822
def best_and_worst(n = 5): <NEW_LINE> <INDENT> if internet_state == 'offline': <NEW_LINE> <INDENT> print('Offline mode. Trend not available.') <NEW_LINE> return <NEW_LINE> <DEDENT> global currency_trends <NEW_LINE> global currency_rates <NEW_LINE> currency_trends = [] <NEW_LINE> i=0 <NEW_LINE> l=0 <NEW_LINE> l=len(curr...
Evaluate trend of the currencies in the market and returns the best and worst n coins
625941d74d74a7450ccd441e
def remove_vertex(self, m): <NEW_LINE> <INDENT> raise NotImplementedError
TODO do it yourself, it's not hard!
625941d7e1aae11d1e749f13
def repo_devel_job_data_file(repo_name, distro=None): <NEW_LINE> <INDENT> if distro: <NEW_LINE> <INDENT> return os.path.join(doc_path, distro, 'devel_jobs', repo_name, "results.yaml") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return os.path.join(doc_path, 'devel_jobs', repo_name, "results.yaml")
Generate filesystem path to results.yaml for repository
625941d7ac7a0e7691ed4323
def analyse(text, expand_tags=True, expand_dot=True, expand_underscore=True, dag=False, keep_whitespace=False): <NEW_LINE> <INDENT> expand_tags = _expand_tags if expand_tags else _dont_expand_tags <NEW_LINE> text = unicode(text) <NEW_LINE> text = text.encode('UTF-8') <NEW_LINE> analyse = _analyse_as_dag if dag else _an...
Analyse the text.
625941d7ec188e330fd5a9f6
def textLen(self): <NEW_LINE> <INDENT> return self.textlength
Return plaintext length in bytes
625941d78e71fb1e9831da03
def class_behavior(self): <NEW_LINE> <INDENT> return self.class_behaviors[self.__class__]
Get the ClassBehavior instance for this test.
625941d7627d3e7fe0d690ab
def download_global_csv(output_dir: str): <NEW_LINE> <INDENT> for filename, url_path in CSVS_TO_READ: <NEW_LINE> <INDENT> url = urljoin(GITHUB_BASE_URL, url_path) <NEW_LINE> path = os.path.join(output_dir, filename) <NEW_LINE> df = pd.read_csv(url) <NEW_LINE> df.to_csv(path)
Download John Hopkins COVID data as CSV to output_dir.
625941d7627d3e7fe0d690ac
def standardize(array): <NEW_LINE> <INDENT> if not np.isclose(array.std(), 0): <NEW_LINE> <INDENT> return (array - array.mean()) / (array.std()) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return (array - array.mean())
Normalize array such that the mean of its elements is zero and its variance is 1. If the variance of the array is zero, only makes the array zero mean. Parameters ---------- array : np.ndarray Array to be standardized Returns ------- np.ndarray Standardized array
625941d72ae34c7f2600d38b
def process(self, element, file_prefix, *schema_side_inputs): <NEW_LINE> <INDENT> destination = bigquery_tools.get_hashable_destination(element[0]) <NEW_LINE> row = element[1] <NEW_LINE> if destination not in self._destination_to_file_writer: <NEW_LINE> <INDENT> if len(self._destination_to_file_writer) < self.max_files...
Take a tuple with (destination, row) and write to file or spill out. Destination may be a ``TableReference`` or a string, and row is a Python dictionary for a row to be inserted to BigQuery.
625941d7442bda511e8be670
def validate(X, y, fitter, k = 10): <NEW_LINE> <INDENT> print("Validating...") <NEW_LINE> n = len(y) <NEW_LINE> total_train_error = 0.0 <NEW_LINE> total_val_error = 0.0 <NEW_LINE> for i in range(k): <NEW_LINE> <INDENT> print("step {}/{}".format(i + 1, k)) <NEW_LINE> l = i*n // k <NEW_LINE> r = (i+1)*n // k <NEW_LINE> t...
How good is our model? Use k-fold cross validation.
625941d726068e7796caef3c
def get_most_probable_instantiation(self): <NEW_LINE> <INDENT> simple_index=numpy.argmax(self.table) <NEW_LINE> tuple_index=numpy.unravel_index(simple_index, self.table.shape) <NEW_LINE> return self.get_node_value_pairs(tuple_index)
This method returns a list of (node,value)-pairs for which this density is at its maximum. Probably more useful if this represents a jpt than when it represents a cpt.
625941d7c4546d3d9de72c90
def test_p_a_comp_req_id_get(self): <NEW_LINE> <INDENT> response = self.client.open( '/5gt/so/v1/PAComp/{ReqId}'.format(ReqId='ReqId_example'), method='GET') <NEW_LINE> self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))
Test case for p_a_comp_req_id_get Retrieve a specific PA request
625941d7596a897236089d19
def parse_raw_data(raw_data: List[Tuple[str, str]]) -> List[Tuple[time, measurement]]: <NEW_LINE> <INDENT> to_float = lambda x: fast_float(x, default=0.0, nan=0.0, inf=0.0) <NEW_LINE> to_rounded_float = lambda x: round(to_float(x), 4) <NEW_LINE> return [(x[0], to_rounded_float(x[1])) for x in raw_data]
Parses the raw csv data. 'time' is left unchanged. 'measurement' is converted to float, rounded to 4 decimal places. Invadid floats default to 0.0 Parameters: - raw_data: List[Tuple[str,str]] The raw csv data.
625941d73346ee7daa2b2fc7
def __call__(self) -> ResultE[bool]: <NEW_LINE> <INDENT> return flow( self._get_all_enterprises(), bind(self._group_by_org_no), bind(self._remove_non_duplicates), bind(self._restructure_data), bind(self._restructure_with_payload), bind(safe(json.dumps)), bind(partial(self._write, file_path=self._output)), )
Load enterprises, remove duplicates, restructure, write worklist.
625941d776e4537e8c3518ce
def serialise_number(i, context=None): <NEW_LINE> <INDENT> return str(i).encode("ascii")
Serialise a Number value. i -- integer
625941d7fff4ab517eb2f697
def translate(decoder_bin, ini, weights, nl_file, kbest=0): <NEW_LINE> <INDENT> args = [decoder_bin, '-c', ini, '-w', weights, '-i', nl_file] <NEW_LINE> if kbest != 0: <NEW_LINE> <INDENT> args += ['-k', '%s' % kbest, '-r'] <NEW_LINE> <DEDENT> proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)...
Given a file of input sentence, a cdec configuration, some weights and the location of the decoder bin, sends a call to cdec and returns cdec'c translation as a string. Optionally returns a unique k-best list whose size can be set via kbest :param decoder_bin: the location of the cdec script :param ini: the cdec confi...
625941d7fb3f5b602dac38f0
def testDeleteInvalidates(self): <NEW_LINE> <INDENT> client = LDAPClientTestDriver( [pureldap.LDAPDelResponse(resultCode=0, matchedDN='', errorMessage=''), ]) <NEW_LINE> o=ldapsyntax.LDAPEntry(client=client, dn='cn=foo,dc=example,dc=com', attributes={ 'objectClass': ['a'], }) <NEW_LINE> d=o.delete() <NEW_LINE> def cb(d...
Deleting an LDAPEntry invalidates it.
625941d73617ad0b5ed68151
def _sortValue_isMonospace(font): <NEW_LINE> <INDENT> if font.info.postscriptIsFixedPitch: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> if not len(font): <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> testWidth = None <NEW_LINE> for glyph in font: <NEW_LINE> <INDENT> if testWidth is None: <NEW_LINE> <INDENT> test...
Returns 0 if the font is monospace. Returns 1 if the font is not monospace.
625941d70a366e3fb873ea76
def setStopTime(self, t1): <NEW_LINE> <INDENT> self._simulator_.update(t1=t1) <NEW_LINE> return
Sets the start time. :param t1: The stop time of the simulation in seconds. The default stop time is 1.
625941d756ac1b37e6264427
def treatExplorationScore(self,switch:int=0,new_val=None): <NEW_LINE> <INDENT> if switch == 0: <NEW_LINE> <INDENT> return self.__explore_score <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.__explore_score += new_val
returns current score of explored tiles or takes new value based on condition of *switch* defaults to return only if no argument is given
625941d791af0d3eaac9bc75
def longestCommonPrefix(self, strs): <NEW_LINE> <INDENT> str = '' <NEW_LINE> if len(strs) == 0: <NEW_LINE> <INDENT> return str <NEW_LINE> <DEDENT> min = len(strs[0]) <NEW_LINE> for i in range(len(strs)): <NEW_LINE> <INDENT> if len((strs[i]))<min: <NEW_LINE> <INDENT> min = len((strs[i])) <NEW_LINE> <DEDENT> <DEDENT> for...
:type strs: List[str] :rtype: str
625941d7bde94217f368304a
def moveZeroes(self, nums): <NEW_LINE> <INDENT> i = 0 <NEW_LINE> for elt in nums: <NEW_LINE> <INDENT> if elt != 0: <NEW_LINE> <INDENT> nums[i] = elt <NEW_LINE> i += 1 <NEW_LINE> <DEDENT> <DEDENT> for j in xrange(i, len(nums)): <NEW_LINE> <INDENT> nums[j] = 0
In-place :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead.
625941d776e4537e8c3518cf
def init(): <NEW_LINE> <INDENT> minutes = input("Enter the number of minutes between your brakes: ") <NEW_LINE> times = input("Enter the number of times you " "want the break to be repeated: ") <NEW_LINE> rest(float(minutes), float(times))
Takes input from the user and invokes the rest function using the given input
625941d7d8ef3951e3243798
def getnode(self, config, arg): <NEW_LINE> <INDENT> session = Session(config) <NEW_LINE> assert "::" not in str(arg) <NEW_LINE> p = py.path.local(arg) <NEW_LINE> config.hook.pytest_sessionstart(session=session) <NEW_LINE> res = session.perform_collect([str(p)], genitems=False)[0] <NEW_LINE> config.hook.pytest_sessionfi...
Return the collection node of a file. :param config: :py:class:`_pytest.config.Config` instance, see :py:meth:`parseconfig` and :py:meth:`parseconfigure` to create the configuration :param arg: a :py:class:`py.path.local` instance of the file
625941d7e1aae11d1e749f14
def test_add_column_ok(self): <NEW_LINE> <INDENT> helpers.set_dummy_context() <NEW_LINE> board = helpers.create_board() <NEW_LINE> assert (board.archive_column is not None) <NEW_LINE> self.assertEqual(board.count_columns(), 4) <NEW_LINE> board.create_column(0, helpers.word()) <NEW_LINE> self.assertEqual(board.count_col...
Add a column to a board
625941d75510c4643540f63a
def flatten_registration_metadata(self): <NEW_LINE> <INDENT> schema = self.registration_schema <NEW_LINE> registered_meta = self.get_registration_metadata(schema) <NEW_LINE> return flatten_registration_metadata(schema, registered_meta)
Extracts questions/nested registration_responses - makes use of schema block `registration_response_key` and block_type to assemble flattened registration_responses. For example, if the registration_response_key = "description-methods.planned-sample.question7b", this will recurse through the registered_meta, looking f...
625941d7d58c6744b4257eb9
def get_registration_parameters(self): <NEW_LINE> <INDENT> return self.B, self.t
Return the current estimate of the affine transformation parameters.
625941d77d847024c06be519
def makevls(self, varname, vlinfo): <NEW_LINE> <INDENT> isstring = self.vardict[varname].VariableType > 0 <NEW_LINE> vls = [] <NEW_LINE> for value, label in sorted(vlinfo): <NEW_LINE> <INDENT> if isstring: <NEW_LINE> <INDENT> value = spssaux._smartquote(value) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if value == i...
Return value label syntax varname is the variable to which the syntax applies vlinfo is the set of duples of (value, label)
625941d72ae34c7f2600d38c
def peek(self) -> float: <NEW_LINE> <INDENT> return self._dist
Look at current total for the distance of the trip
625941d738b623060ff0b048
def price_at(self, timestamp): <NEW_LINE> <INDENT> return ( Price.query.filter( Price.item == self, Price.start_at <= timestamp, Price.end_at > timestamp, Price.discount_policy_id.is_(None), ) .order_by(Price.created_at.desc()) .first() )
Return the price object for an item at a given time.
625941d724f1403a92600dbf
def draw_pie(t, n, r): <NEW_LINE> <INDENT> polypie(t, n, r) <NEW_LINE> t.pu() <NEW_LINE> t.fd(r*2 + 10) <NEW_LINE> t.pd()
Draws a pie, then moves into position to the right. t: Turtle n: number of segments r: length of the radial spokes
625941d796565a6dacc8f926
def wait_for_scenario_run(self, no_fail=False): <NEW_LINE> <INDENT> scenario_run = None <NEW_LINE> refresh_trigger_counter = 0 <NEW_LINE> while scenario_run is None: <NEW_LINE> <INDENT> refresh_trigger_counter += 1 <NEW_LINE> if refresh_trigger_counter == 10: <NEW_LINE> <INDENT> refresh_trigger_counter = 0 <NEW_LINE> <...
Polls, waiting for the run of the sceanrio that this trigger activation launched to be available, or for the trigger fire to be cancelled (possibly cancelled by another firing) :param no_fail: If no_fail=True, will return None if the trigger fire is cancelled, else will raise :returns a scenario run object, or None :...
625941d7be383301e01b56de
def load_arora(opt): <NEW_LINE> <INDENT> arora_fp = os.path.join(opt['datapath'], CONTROLLABLE_DIR, 'arora.pkl') <NEW_LINE> print("Loading Arora embedding info from %s..." % arora_fp) <NEW_LINE> with open(arora_fp, "rb") as f: <NEW_LINE> <INDENT> data = pickle.load(f) <NEW_LINE> <DEDENT> print("Done loading arora info....
Load the data in the arora.pkl file in data/controllable_dialogue.
625941d7d7e4931a7ee9e179
def _client(self, q=None): <NEW_LINE> <INDENT> if self._meta.max_limit is None: <NEW_LINE> <INDENT> max_limit = 2000000 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> max_limit = self._meta.max_limit <NEW_LINE> <DEDENT> return Search(search_query=q, idx=self._meta.resource_name, size=max_limit)
Get the Elastic client.
625941d7b830903b967e9b64
def pythonGetEnv(initialCreate=False, forCustomer=None): <NEW_LINE> <INDENT> envList = dcEnvCheckArgs() <NEW_LINE> if forCustomer is None: <NEW_LINE> <INDENT> if "FOR_CUSTOMER" in envList: <NEW_LINE> <INDENT> forCustomer = envList["FOR_CUSTOMER"] <NEW_LINE> <DEDENT> <DEDENT> if initialCreate: <NEW_LINE> <INDENT> getSet...
Process env when called from a python script.
625941d71d351010ab855d77
def hide_virtual_ip_holder_chassis_virtual_ip(self, **kwargs): <NEW_LINE> <INDENT> config = ET.Element("config") <NEW_LINE> hide_virtual_ip_holder = ET.SubElement(config, "hide-virtual-ip-holder", xmlns="urn:brocade.com:mgmt:brocade-chassis") <NEW_LINE> chassis = ET.SubElement(hide_virtual_ip_holder, "chassis") <NEW_LI...
Auto Generated Code
625941d74c3428357757c582
def get_line_id(line): <NEW_LINE> <INDENT> if line in LINE_ID: <NEW_LINE> <INDENT> return LINE_ID[line] <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> CURSOR['sage'].execute(READ['LINEID'], [line]) <NEW_LINE> lrow = CURSOR['sage'].fetchone() <NEW_LINE> <DEDENT> except MySQLdb.Error as err: <NEW_LINE> <INDENT> sql_error(e...
Get a line's ID
625941d721bff66bcd684bac
@APP.route( "/metadata/<scene>", methods=["GET"], cors=True, token=True, payload_compression_method="gzip", binary_b64encode=True, ttl=3600, tag=["metadata"], ) <NEW_LINE> def metadata( scene: str, pmin: Union[str, float] = 2., pmax: Union[str, float] = 98. ) -> Tuple[str, str, str]: <NEW_LINE> <INDENT> pmin = float(pm...
Handle metadata requests.
625941d73c8af77a43ae39fd
def retrieve_record(tablename, **kwargs): <NEW_LINE> <INDENT> if tablename not in globals(): <NEW_LINE> <INDENT> raise AttributeError(f"Table: '{tablename}' does not exist") <NEW_LINE> <DEDENT> table = globals()[tablename] <NEW_LINE> try: <NEW_LINE> <INDENT> return table.query.filter_by(**kwargs) <NEW_LINE> <DEDENT> ex...
Given a tablename query the table given the kwargs provided into that table.
625941d750812a4eaa59c57b
def get_downbeats(self, start_time=0.): <NEW_LINE> <INDENT> beats = self.get_beats(start_time) <NEW_LINE> time_signatures = copy.deepcopy(self.time_signature_changes) <NEW_LINE> if not time_signatures or time_signatures[0].time > start_time: <NEW_LINE> <INDENT> time_signatures.insert(0, TimeSignature(4, 4, start_time))...
Return a list of downbeat locations, according to MIDI tempo changes and time signature change events. Parameters ---------- start_time : float Location of the first downbeat, in seconds. Returns ------- downbeats : np.ndarray Downbeat locations, in seconds.
625941d7377c676e91272403
def groupAnagrams(self, strs): <NEW_LINE> <INDENT> anas = {} <NEW_LINE> for string in strs: <NEW_LINE> <INDENT> s = ''.join(sorted(string)) <NEW_LINE> if s in anas: <NEW_LINE> <INDENT> anas[s].append(string) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> anas[s] = [string] <NEW_LINE> <DEDENT> <DEDENT> return [ anas[x] f...
:type strs: List[str] :rtype: List[List[str]]
625941d756b00c62f0f148b6
def myPow(self, x, n): <NEW_LINE> <INDENT> if not -2147483648 < n < 2147483647: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> res = x <NEW_LINE> for i in xrange(1,abs(n)): <NEW_LINE> <INDENT> res *= x <NEW_LINE> <DEDENT> if n < 0: <NEW_LINE> <INDENT> return 1/res if n%2 ==0 or 0 < x < 1 else -(1/res) <NEW_LINE> <DE...
:type x: float :type n: int :rtype: float
625941d78c3a873295158617
def __init__(self): <NEW_LINE> <INDENT> self._locks = dict() <NEW_LINE> for lock_name in LOCK_NAMES: <NEW_LINE> <INDENT> self._locks[lock_name] = threading.Lock() <NEW_LINE> setattr( ThreadingLocks, lock_name, property(lambda self, key=lock_name: self._locks[key]), )
We will only define one instance of the ThreadingLocks class, called 'LOCKS', so the 'self' in the lambda expression will always be the LOCKS instance.
625941d7ff9c53063f47c44e