code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def usfm3_to_usfm2(usfm): <NEW_LINE> <INDENT> usfm = re.sub(r'\\zaln-s[^\*]*\*', r'', usfm, flags=re.UNICODE | re.MULTILINE) <NEW_LINE> usfm = re.sub(r'\\zaln-e\\\*', r'', usfm, flags=re.UNICODE | re.MULTILINE) <NEW_LINE> usfm = re.sub(r'\\w ([^|]+)\|.*?\\w\*', r'\1', usfm, flags=re.UNICODE | re.MULTILINE) <NEW_LINE> u...
Converts a USFM 3 string to a USFM 2 compatible string :param usfm3: :return: the USFM 2 version of the string
625941d663f4b57ef0001356
def set_volt_scale(self, channel, scale): <NEW_LINE> <INDENT> self.inst.write(":CHAN{}:SCAL {}".format(channel, scale))
Sets voltage scale of the selected channel to chosen value. Args: channel -- selected channel scale -- voltage scale to set
625941d6a8ecb033257d330e
def test_bug535(self): <NEW_LINE> <INDENT> pass
"P-P": "{^.^}", "KR*UR": "{*($c)}", 1/P-P/2/KR*UR " $1.20"
625941d66aa9bd52df036fe7
def clip_b(self, bi_new, bj_new, ai_new, aj_new): <NEW_LINE> <INDENT> if 0 < ai_new < self.C: <NEW_LINE> <INDENT> b = bi_new <NEW_LINE> <DEDENT> elif 0 < aj_new < self.C: <NEW_LINE> <INDENT> b = bj_new <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> b = (bi_new + bj_new) / 2.0 <NEW_LINE> <DEDENT> return b
b边界截断
625941d6c4546d3d9de72c77
def test_issue4120(en_vocab): <NEW_LINE> <INDENT> matcher = Matcher(en_vocab) <NEW_LINE> matcher.add("TEST", [[{"ORTH": "a"}, {"OP": "?"}]]) <NEW_LINE> doc1 = Doc(en_vocab, words=["a"]) <NEW_LINE> assert len(matcher(doc1)) == 1 <NEW_LINE> doc2 = Doc(en_vocab, words=["a", "b", "c"]) <NEW_LINE> assert len(matcher(doc2)) ...
Test that matches without a final {OP: ?} token are returned.
625941d60c0af96317bb842b
def setup_plot(self, plot): <NEW_LINE> <INDENT> pass
This method does nothing by default, but can be overridden by the child class in order to set up custom options for the plot window, via its PlotItem_. :param plot: This window's PlotItem_ instance. .. _PlotItem: https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/plotitem.html
625941d67b25080760e3969b
def check_all_files_in_config_list( self, package_name: str, config_list: tp.List[str], exclude_list: tp.Optional[tp.List[str]] = None ): <NEW_LINE> <INDENT> if exclude_list is None: <NEW_LINE> <INDENT> exclude_list = [] <NEW_LINE> <DEDENT> importlib.import_module(package_name) <NEW_LINE> path = getattr(sys.modules[pac...
Check if all python files in a folder are added to the benchbuild project config.
625941d6498bea3a759b9cf1
def dtmaa(dt, dt_fl, phi_NS): <NEW_LINE> <INDENT> dtmaa = (dt - phi_NS * dt_fl) / (1-phi_NS) <NEW_LINE> return dtmaa
dtmaa(dt, dt_fl, phi_NS) *Input parameters: - dt - sonic transit time from log [us/ft] - dt_fl - sonic transit time in the formation fluid[us/ft] - phi_NS - neutron-sonic crossplot porosity [decimal] *It calculates: - dtmaa - apparent matrix transit time [us/ft]
625941d65f7d997b87174cdc
def write_dl(self, rows, col_max=30, col_spacing=2, widths=None): <NEW_LINE> <INDENT> rows = list(rows) <NEW_LINE> if widths is None: <NEW_LINE> <INDENT> widths = measure_table(rows) <NEW_LINE> <DEDENT> if len(widths) != 2: <NEW_LINE> <INDENT> raise TypeError('Expected two columns for definition list') <NEW_LINE> <DEDE...
Writes a definition list into the buffer. This is how options and commands are usually formatted. :param rows: a list of two item tuples for the terms and values. :param col_max: the maximum width of the first column. :param col_spacing: the number of spaces between the first and second column. :p...
625941d676d4e153a657ed74
def __le__(self, other): <NEW_LINE> <INDENT> return self == other or self.__lt__(other)
EXAMPLES:: sage: from sage.combinat.crystals.tensor_product import ImmutableListWithParent, TestParent sage: l = ImmutableListWithParent(TestParent(), [1,2,3]) sage: m = ImmutableListWithParent(ZZ, [1,2,3]) sage: n = ImmutableListWithParent(ZZ, [2,3,4]) sage: l <= l True sage: l <= m Tr...
625941d63539df3088e2e58d
def write(plates, handle, format): <NEW_LINE> <INDENT> if not isinstance(format, str): <NEW_LINE> <INDENT> raise TypeError("Need a string for the file format (lower case)") <NEW_LINE> <DEDENT> if not format: <NEW_LINE> <INDENT> raise ValueError("Format required (lower case string)") <NEW_LINE> <DEDENT> if format != for...
Write complete set of PlateRecords to a file. - plates - A list (or iterator) of PlateRecord objects. - handle - File handle object to write to, or filename as string (note older versions of Biopython only took a handle). - format - lower case string describing the file format to write. You...
625941d699cbb53fe6792e29
def render(self): <NEW_LINE> <INDENT> for item in self.items: <NEW_LINE> <INDENT> self.draw.text((self.x + item.x, self.y + item.y), item.text, font=item.font, fill=item.color)
Draw items
625941d6f548e778e58cd7c1
def softmax(predictions): <NEW_LINE> <INDENT> maximums = np.amax(predictions, axis=1).reshape(predictions.shape[0], 1) <NEW_LINE> predictions_ts = predictions - maximums <NEW_LINE> predictions_exp = np.exp(predictions_ts) <NEW_LINE> sums = np.sum(predictions_exp, axis=1).reshape(predictions_exp.shape[0], 1) <NEW_LINE> ...
Computes probabilities from scores Arguments: predictions, np array, shape is either (N) or (batch_size, N) - classifier output Returns: probs, np array of the same shape as predictions - probability for every class, 0..1
625941d6a8370b7717052ae1
def __init__(self): <NEW_LINE> <INDENT> pass
Unfortunately, we cannot instantiate CointipBot only once due to the way pifkoin works. Pifkoin will open an HTTP connection to the RPC client which will eventually close when the bot completes its checks. Therefore, if we try to loop CointipBot.main() without reinstanting the object, httplib will throw BadStatusLine...
625941d6442bda511e8be658
def set_distance_max(self): <NEW_LINE> <INDENT> self.dist = sys.maxsize
Set vertex distance to sys.maxsize.
625941d6ff9c53063f47c435
def build_heap(self, elem): <NEW_LINE> <INDENT> self.heap = elem[:] <NEW_LINE> last_leaf = int(math.ceil( (len(self.heap)- 2) / 2)) <NEW_LINE> for i in range(last_leaf, -1, -1): <NEW_LINE> <INDENT> self.heapify(i)
transforms a list of elements into a heap in linear time
625941d656ac1b37e626440f
def delete(self): <NEW_LINE> <INDENT> endpoint = 'https://outlook.office.com/api/v2.0/me/messages/' + self.message_id <NEW_LINE> self._make_api_call('delete', endpoint)
Deletes the email
625941d6a8ecb033257d330f
def test_multi_dim_logits(self): <NEW_LINE> <INDENT> base_global_step = 100 <NEW_LINE> _create_checkpoint(( ([[.6, .5]], [.1, -.1]), ([[1., .8], [-.8, -1.]], [.2, -.2]), ([[-1., 1., .5], [-1., 1., .5]], [.3, -.3, .0]), ), base_global_step, self._model_dir) <NEW_LINE> for mode in [model_fn.ModeKeys.TRAIN, model_fn.ModeK...
Tests multi-dimensional logits. input_layer = [[10]] hidden_layer_0 = [[relu(0.6*10 +0.1), relu(0.5*10 -0.1)]] = [[6.1, 4.9]] hidden_layer_1 = [[relu(1*6.1 -0.8*4.9 +0.2), relu(0.8*6.1 -1*4.9 -0.1)]] = [[relu(2.38), relu(-0.12)]] = [[2.38, 0]] logits = [[-1*2.38 +0.3, 1*2.38 -0.3, 0.5*2.38]] = [[...
625941d6be7bc26dc91cd840
def determinant(self, name="det"): <NEW_LINE> <INDENT> with self._name_scope(name): <NEW_LINE> <INDENT> return self._determinant()
Determinant for every batch member. Args: name: A name for this `Op. Returns: `Tensor` with shape `self.batch_shape` and same `dtype` as `self`.
625941d6d53ae8145f87a4af
def test_generateLine_package(): <NEW_LINE> <INDENT> sut = make_SphinxInventory() <NEW_LINE> result = sut._generateLine( model.Package('ignore-system', 'package1', 'ignore-docstring')) <NEW_LINE> assert 'package1 py:module -1 package1.html -\n' == result
Check inventory for package.
625941d630dc7b7665901ba7
@login_required <NEW_LINE> def create_demand(request): <NEW_LINE> <INDENT> return _create(request, Demand, DemandForm, dashboard)
Creates a demand belonging to the logged in user. After that, redirects to the dashboard.
625941d6e76e3b2f99f3aa4b
def test_protobuf_field_subdissector(self, cmd_tshark, features, dirs, capture_file): <NEW_LINE> <INDENT> if not features.have_lua: <NEW_LINE> <INDENT> self.skipTest('Test requires Lua scripting support.') <NEW_LINE> <DEDENT> well_know_types_dir = os.path.join(dirs.protobuf_lang_files_dir, 'well_know_types').replace('\...
Test "protobuf_field" subdissector table
625941d663b5f9789fde7328
def Scene_plot_reverseData(P): <NEW_LINE> <INDENT> for k in P.data: P.data[k].reverse()
Reverse woo.core.Plot.data order. Useful for tension-compression test, where the initial (zero) state is loaded and, to make data continuous, last part must *end* in the zero state.
625941d68a43f66fc4b542a6
def _pollard_rho(n, rand=True): <NEW_LINE> <INDENT> f = lambda x, c: x*x + c <NEW_LINE> if not rand: <NEW_LINE> <INDENT> x, c = 1, 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> x, c = random.randrange(2, 1e6), random.randrange(2, 1e6) <NEW_LINE> <DEDENT> y, d = x, 1 <NEW_LINE> while d == 1 and d != n: <NEW_LINE> <IND...
Pollard rho prime factorization algorithm https://en.wikipedia.org/wiki/Pollard's_rho_algorithm
625941d68a349b6b435e83b6
def update_or_create_student(self, student_id: str, **kwargs: dict) -> Student: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> student = self.find_student(student_id) <NEW_LINE> <DEDENT> except MissingEntry: <NEW_LINE> <INDENT> student = self.add_student(student_id, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT>...
Update an existing student, or create it if it doesn't exist. Parameters ---------- student_id: The unique id of the student `**kwargs` additional keyword arguments for the :class:`~nbgrader.api.Student` object Returns ------- student
625941d68e71fb1e9831d9eb
def _twoDecimalPlaces(amount): <NEW_LINE> <INDENT> return decimal.Decimal(amount).quantize(decimal.Decimal("0.01"))
Quantizes to two decimal places.
625941d6bde94217f3683032
def get_all_answers(self, init_state): <NEW_LINE> <INDENT> states, _ = self.process(init_state, first_only=False, backtracking=True) <NEW_LINE> return [s.get_answer() for s in states]
Return all answers obtained from an initial state. (No duplicate elimination is performed.)
625941d67c178a314d6ef6a5
def mg(val): <NEW_LINE> <INDENT> if fmt == 'greta': <NEW_LINE> <INDENT> out = float(val) if number else val <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> val = val[:7] + val[8:] <NEW_LINE> out = int(val) if number else val <NEW_LINE> <DEDENT> if bytestr and isinstance(out, str): <NEW_LINE> <INDENT> out = out.encode('as...
Munge greta-style string input to desired type for CxoTime init
625941d6cc40096d61595b93
def checkparent(self, directory): <NEW_LINE> <INDENT> self.send_checkparent(directory) <NEW_LINE> return self.recv_checkparent()
Parameters: - directory
625941d6d10714528d5fff28
def print_stories(self, stories: list, per_page: int): <NEW_LINE> <INDENT> self._setup() <NEW_LINE> for index, story in enumerate(stories): <NEW_LINE> <INDENT> if index % per_page == 0 and index: <NEW_LINE> <INDENT> continue_key = input("Hit any key to continue or press q to quit\n: ") <NEW_LINE> if continue_key.lower(...
Print all stories in the list. Limit the output to per_page and wait for user input to show more.
625941d691f36d47f21ac737
@app_views.route('/users', methods=['GET'], strict_slashes=False) <NEW_LINE> @app_views.route('/users/<user_id>', methods=['GET'], strict_slashes=False) <NEW_LINE> def view_user(user_id=None): <NEW_LINE> <INDENT> if user_id is None: <NEW_LINE> <INDENT> all_users = [state.to_json() for state in storage.all("User").value...
Example endpoint returning a list of all users or of one specified Retrieves a list of all users or of one specified by user_id --- parameters: - name: user_id in: path type: string enum: ["all", "32c11d3d-99a1-4406-ab41-7b6ccb7dd760"] required: true default: None definitions: User: type: ...
625941d60a50d4780f6670d6
def run(self): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> task = None <NEW_LINE> timeout = None <NEW_LINE> flag = False <NEW_LINE> self.cond.acquire() <NEW_LINE> while True: <NEW_LINE> <INDENT> while len(self.queue) == 0 or flag: <NEW_LINE> <INDENT> flag = False <NEW_LINE> if timeout is None: <NEW_LINE> <INDEN...
Run by server thread
625941d615fb5d323cde0d55
def register(): <NEW_LINE> <INDENT> HaydeeMenuIcon.registerCustomIcon() <NEW_LINE> registerClasses() <NEW_LINE> HaydeeExporter.register() <NEW_LINE> HaydeeImporter.register() <NEW_LINE> addon_updater_ops.register(bl_info)
Register addon classes.
625941d667a9b606de4a80fb
def evaluate(self, text): <NEW_LINE> <INDENT> return self.t1.evaluate(text) and self.t2.evaluate(text)
text:string return bool is text match two triger evaluate both
625941d6d8ef3951e3243780
def calculate_em_f1(best_span, metadata, batch_size, squad_metrics): <NEW_LINE> <INDENT> if metadata is not None: <NEW_LINE> <INDENT> best_span_str = [] <NEW_LINE> for i in range(batch_size): <NEW_LINE> <INDENT> passage_str = metadata[i]['original_passage'] <NEW_LINE> offsets = metadata[i]['token_offsets'] <NEW_LINE> p...
Calculates EM and F1 scores.
625941d6925a0f43d254a0bb
def test_multiple_info(self): <NEW_LINE> <INDENT> info = Info(**INFO_DATA) <NEW_LINE> info.save() <NEW_LINE> form = InfoForm(data = INFO_DATA) <NEW_LINE> self.assert_(form.is_valid() == False)
Tries to add two different infos
625941d6711fe17d825425ab
def initialize(self, tr_case): <NEW_LINE> <INDENT> mod = 10 ** 9 + 7 <NEW_LINE> self.str_case = tr_case <NEW_LINE> cur = 0 <NEW_LINE> for ch_ar in tr_case: <NEW_LINE> <INDENT> tmp = [i for i in self.alpha_count[-1]] <NEW_LINE> tmp[self.alpha.find(ch_ar)] += 1 <NEW_LINE> self.alpha_count.append(tmp) <NEW_LINE> cur ^= (1...
docstring
625941d6aad79263cf390c87
def encode_hook(self, hook, msg): <NEW_LINE> <INDENT> if 'name' in hook: <NEW_LINE> <INDENT> msg.name = str_to_bytes(hook['name']) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.encode_modfun(hook, msg.modfun) <NEW_LINE> <DEDENT> return msg
Encodes a commit hook dict into the protobuf message. Used in bucket properties. :param hook: the hook to encode :type hook: dict :param msg: the protobuf message to fill :type msg: riak.pb.riak_pb2.RpbCommitHook :rtype riak.pb.riak_pb2.RpbCommitHook
625941d6460517430c3943c4
def test_clear_and_initialize(self): <NEW_LINE> <INDENT> DatabaseRegistry.clear() <NEW_LINE> self.assertTrue(len(DatabaseRegistry.registered_databases) == 0) <NEW_LINE> self.assertTrue(len(DatabaseRegistry.registered_profiles) == 0) <NEW_LINE> self.assertFalse(DatabaseRegistry.is_initialized) <NEW_LINE> DatabaseRegistr...
Tests the method clear() and initialize().
625941d69b70327d1c4e1019
def count_unique_permutations(A): <NEW_LINE> <INDENT> num = numbers.fac(len(A)) <NEW_LINE> d = defaultdict(int) <NEW_LINE> for x in A: <NEW_LINE> <INDENT> d[x] += 1 <NEW_LINE> <DEDENT> den = 1 <NEW_LINE> for v in d.values(): <NEW_LINE> <INDENT> den = den * numbers.fac(v) <NEW_LINE> <DEDENT> return num//den
returns the number of unique permutations that can be generated with the elements in A
625941d6dc8b845886cb5779
def writeInt64Array (self, v: numpy.array, includelen = True): <NEW_LINE> <INDENT> vlen = len(v) <NEW_LINE> if includelen: <NEW_LINE> <INDENT> self.writeInt32 (vlen) <NEW_LINE> <DEDENT> for i in range(0,vlen): <NEW_LINE> <INDENT> self.writeInt64(v[i])
write an int64 array
625941d63cc13d1c6d3c75bd
def calc_error(self, data): <NEW_LINE> <INDENT> errors = np.zeros(data.shape) <NEW_LINE> errors[data <= self.min_error_dist] = self.min_error <NEW_LINE> errors[data > self.min_error_dist] = data[data > self.min_error_dist] * self.error_prop <NEW_LINE> return errors
Calculate errors for each element in a dataset
625941d6cb5e8a47e48b7ceb
def deserialize_numpy(self, str, numpy): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self.trajectories is None: <NEW_LINE> <INDENT> self.trajectories = None <NEW_LINE> <DEDENT> end = 0 <NEW_LINE> start = end <NEW_LINE> end += 4 <NEW_LINE> (length,) = _struct_I.unpack(str[start:end]) <NEW_LINE> self.trajectories = [...
unpack serialized message in str into this message instance using numpy for array types :param str: byte array of serialized message, ``str`` :param numpy: numpy python module
625941d6a4f1c619b28b0278
def key_word(user_input): <NEW_LINE> <INDENT> user_input.strip(' ') <NEW_LINE> data['lowcase_title'] = data['Title'].apply(lambda x: x.lower()) <NEW_LINE> df_to_display = data[data['lowcase_title'].str.contains(user_input.lower())] <NEW_LINE> data.drop('lowcase_title', axis=1, inplace=True) <NEW_LINE> df_to_display.ren...
function used to find a serie by a key word from it's title user_input is a text variable it can be a single word half a word or even the whole title return a json file with all series that contain the piece of text in its title
625941d656ac1b37e6264410
def has_admin(self, member): <NEW_LINE> <INDENT> from member.models import Membership <NEW_LINE> memberships = Membership.objects.filter(club=self) <NEW_LINE> for membership in memberships: <NEW_LINE> <INDENT> if membership.member.ref == member.ref: <NEW_LINE> <INDENT> if membership.role == CLUB_ADMIN: <NEW_LINE> <INDE...
This function checks whether the member has admin membership with the club.
625941d6d7e4931a7ee9e161
def focusOutEvent(self, event): <NEW_LINE> <INDENT> self.focus_changed.emit() <NEW_LINE> return super(PageControlWidget, self).focusOutEvent(event)
Reimplement Qt method to send focus change notification
625941d6ac7a0e7691ed430c
def f(n): <NEW_LINE> <INDENT> result = 0 <NEW_LINE> di = [] <NEW_LINE> for i in range(1, n + 1): <NEW_LINE> <INDENT> result += Di(i) <NEW_LINE> di.append(result) <NEW_LINE> <DEDENT> for i in count(1): <NEW_LINE> <INDENT> if i * i >= n: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> for j in range(1, i + 1): <NEW_LINE> <...
if a * a + b * b == n: (a, b) in g(k * n) , k in count(1) (k * a, k * b) in g(k * n), k in count(1) #>>> f(10 ** 8) #17971254122360635 >>> f(5) 35 >>> f(10 ** 5) 17924657155
625941d638b623060ff0b031
def removeDuplicates(self, S): <NEW_LINE> <INDENT> stk = [] <NEW_LINE> for s in S: <NEW_LINE> <INDENT> if not stk: <NEW_LINE> <INDENT> stk.append(s) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if stk[-1] == s: <NEW_LINE> <INDENT> stk.pop(-1) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> stk.append(s) <NEW_LINE> <DEDE...
:type S: str :rtype: str
625941d64e4d5625662d4619
def validate_ranking(value): <NEW_LINE> <INDENT> if value < 1: <NEW_LINE> <INDENT> raise ValidationError(_('%(value)d is not a valid ranking'), params={'value': value}) <NEW_LINE> <DEDENT> if value > GreatPower.objects.count(): <NEW_LINE> <INDENT> raise ValidationError(_('%(value)d is not a valid ranking'), params={'va...
Checks for a valid power rank - 1..7
625941d623849d37ff7b32d1
def cover_state_changed(self, state): <NEW_LINE> <INDENT> if isinstance(state, (list, tuple)): <NEW_LINE> <INDENT> state = state[1] <NEW_LINE> <DEDENT> if state == 0: <NEW_LINE> <INDENT> self.cover_state = "closed" <NEW_LINE> <DEDENT> elif state == 1: <NEW_LINE> <INDENT> self.cover_state = "opened" <NEW_LINE> <DEDENT> ...
Updates guillotine state" :param state: guillotine state (close, opened, ..) :type state: str
625941d623e79379d52ee7a5
def test_rust_library(self): <NEW_LINE> <INDENT> env = self._consume('rust-library', RecursiveMakeBackend) <NEW_LINE> backend_path = mozpath.join(env.topobjdir, 'backend.mk') <NEW_LINE> lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]] <NEW_LINE> expected = [ 'RUST_LIBRARY_FILE := ./x86_64-unknown-l...
Test that a Rust library is written to backend.mk correctly.
625941d621bff66bcd684b94
def watchcell(self, map, y, x): <NEW_LINE> <INDENT> return map.get_cellat(self.yant_ + y, self.xant_ + x)
:param y: distance y depuis notre pos :param x: distance x depuis notre pos :return: valeur de la case regardée
625941d6566aa707497f47a9
def audit(self, freq, orig_response): <NEW_LINE> <INDENT> if not self._should_run: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> initial_uri = freq.get_uri() <NEW_LINE> insecure_uri = initial_uri.copy() <NEW_LINE> secure_uri = initial_uri.copy() <NEW_LINE> insecure_uri.set_protocol('http') <NEW_LINE> insecure_fr = cop...
Check if the protocol specified in freq is https and fetch the same URL using http. ie: - input: https://w3af.org/ - check: http://w3af.org/ :param freq: A FuzzableRequest
625941d64c3428357757c56b
def __exit__(self, *args): <NEW_LINE> <INDENT> self.close()
Implementation of context manager API
625941d6f548e778e58cd7c2
def sort(sample_args, count=None): <NEW_LINE> <INDENT> sample_args = sample_args() <NEW_LINE> context = composition.Context() <NEW_LINE> entropy, sample_args = sample_args.peel() <NEW_LINE> values = _unique_values( entropy, only_integers=random.choice([False, True]), count=count) <NEW_LINE> entities = context.sample(sa...
Ask to sort numbers in increasing or decreasing order.
625941d666656f66f7cbc3ef
def get_students_from_class(self, class_id): <NEW_LINE> <INDENT> _c, _c_err = self.get_class(class_id) <NEW_LINE> if _c: <NEW_LINE> <INDENT> return ", ".join(map(str, _c.class_students)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return f"НЕТ -> {_c_err}"
Возвращает список учеников класса :param class_id: идентификатор анализируемого класса
625941d63539df3088e2e58e
def test_get_access_control_does_not_add_to_template_on_fail(self): <NEW_LINE> <INDENT> test_payload = {"AccessControl": "test"} <NEW_LINE> expected = {} <NEW_LINE> self.mock_s3_cf.set_payload(test_payload) <NEW_LINE> self.mock_s3_cf.set_template() <NEW_LINE> sut = self.mock_s3_cf.get_template() <NEW_LINE> assert sut =...
Test Failure: Access control not added to template with incorrect configuration
625941d6adb09d7d5db6c9d2
def collect_incoming_data(self, data): <NEW_LINE> <INDENT> if self.AESKey_is_init: <NEW_LINE> <INDENT> if data == '\r\n'.encode('utf-8'): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> data = self.AESinstance.AESDecrypt(data) <NEW_LINE> self.data.append(data) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.data.appe...
缓存从用户收到的数据 转码成 unicode :param data: :return:
625941d6442bda511e8be659
def build_info(url, **kwargs): <NEW_LINE> <INDENT> info = {} <NEW_LINE> info['url'] = url <NEW_LINE> info['domain'] = url.partition('//')[2].split('/')[0] <NEW_LINE> defaults = {'title': None, 'images': 0, 'timestamp': None, 'broadcast': '$BROADCAST', 'is_sponsored': False, 'is_partner': True, 'archive': 'core', 'keep_...
probably flawed, derived from sample zipballs
625941d6046cf37aa974cf8a
def _filter_generic(self, key): <NEW_LINE> <INDENT> if key in LENSE.REQUEST.data: <NEW_LINE> <INDENT> key_data = LENSE.REQUEST.data[key] <NEW_LINE> if '%7C' in key_data: <NEW_LINE> <INDENT> self._filters[key] = reduce(lambda q,value: q|Q(**{key:value}), key_data.split('%7C'), Q()) <NEW_LINE> <DEDENT> else: <NEW_LINE> <...
Generic filter method for single or multiple key values.
625941d6bd1bec0571d90873
def BeginInvoke(self,sender,e,callback,object): <NEW_LINE> <INDENT> pass
BeginInvoke(self: DataGridViewCellErrorTextNeededEventHandler,sender: object,e: DataGridViewCellErrorTextNeededEventArgs,callback: AsyncCallback,object: object) -> IAsyncResult
625941d6be383301e01b56c7
def xyz_points(packet, os16=False): <NEW_LINE> <INDENT> channels = OS_16_CHANNELS if os16 else OS_64_CHANNELS <NEW_LINE> if not isinstance(packet, tuple): <NEW_LINE> <INDENT> packet = unpack(packet) <NEW_LINE> <DEDENT> x = [] <NEW_LINE> y = [] <NEW_LINE> z = [] <NEW_LINE> for b in range(AZIMUTH_BLOCK_COUNT): <NEW_LINE>...
Returns a tuple of x, y, z points where each x, y, z is a list of all the x, y or z points in the packet ( [x1, x2, ...], [y1, y2, ...], [z1, z2, ...], )
625941d68c3a8732951585ff
@node.commandWrap <NEW_LINE> def AlembicExportSelection(*args, **kwargs): <NEW_LINE> <INDENT> u <NEW_LINE> return cmds.AlembicExportSelection(*args, **kwargs)
:rtype: list|str|basestring|DagNode|AttrObject|ArrayAttrObject|Components1Base
625941d68c3a873295158600
def getSolidsByTags(self, tags): <NEW_LINE> <INDENT> return _getObjectsByTags(self.solids.values(), tags)
eturn a list of solids which contains at least one tag from tags
625941d6eab8aa0e5d26dd9c
def get_all_matching_models(grep='trail'): <NEW_LINE> <INDENT> result = [] <NEW_LINE> for _, models in cars.items(): <NEW_LINE> <INDENT> result.extend([model for model in models if re.search(grep, model, re.I)]) <NEW_LINE> <DEDENT> return sorted(result)
return a list of all models containing the case insensitive 'grep' string which defaults to 'trail' for this exercise, sort the resulting sequence alphabetically
625941d6cdde0d52a9e53278
def message_ports_in(self): <NEW_LINE> <INDENT> return _filter_swig.pfb_channelizer_ccf_sptr_message_ports_in(self)
message_ports_in(pfb_channelizer_ccf_sptr self) -> swig_int_ptr
625941d630bbd722463cc00b
def get_interpolated_gains(self,fileName): <NEW_LINE> <INDENT> cal_freqs,cal_gains=get_gains_from_csv(cal_files(fileName)) <NEW_LINE> inter_freqs=scipy.interpolate.interp1d(cal_freqs,cal_gains,kind='linear') <NEW_LINE> return inter_freqs(self.config['freqs'])
Retrieves antenna gain mapping from bandpass csv files and interpolates data to return values at 'freqs'.
625941d697e22403b379d1de
def vnl_c_vector_vcl_complexD_fill(*args): <NEW_LINE> <INDENT> return _vnl_c_vectorPython.vnl_c_vector_vcl_complexD_fill(*args)
vnl_c_vector_vcl_complexD_fill(vcl_complexD x, unsigned int arg1, vcl_complexD v)
625941d6851cf427c661a751
def evolve(self, nsteps, T): <NEW_LINE> <INDENT> if T <= 0: <NEW_LINE> <INDENT> raise ValueError("The temperature must be greater than zero.") <NEW_LINE> <DEDENT> beta = 1./T <NEW_LINE> self.spins, naccept = cevolve.evolve_nofieldCouplGlauber( self.spins, self.neighlist, self.network.adjmatrix, self.nneigh, beta, nstep...
Evolve the lattice in nsteps. Accept arbitrary couplings. Parameters ---------- nsteps : int Number of Monte Carlo steps. T : float Temperature of the system in units of the inverse of the Boltzmann's constant times the coupling constant times the parti...
625941d6baa26c4b54cb1361
def __init__(self, mID, modelStrand, virtualHelixItem): <NEW_LINE> <INDENT> self._modelStrand = modelStrand <NEW_LINE> self._virtualHelixItem = virtualHelixItem <NEW_LINE> self._viewroot = app().activeDocument.win.solidroot <NEW_LINE> mayaNodeInfo = () <NEW_LINE> if(modelStrand.strandSet().isScaffold()): <NEW_LINE> <IN...
The parent should be a VirtualHelixItem. Initialize function creates the Maya Node for the strand, and setups the lookup tables inside of mayaObjectManager (Mom) so that the Maya Node can be globally found given a strand, and the other way around. Also, sets up StrandItemController that is used to setup all the slots a...
625941d6a79ad161976cc389
def rename(self, new): <NEW_LINE> <INDENT> pass
.. seealso:: :func:`os.rename`
625941d6dd821e528d63b3ec
def GetPointer(self): <NEW_LINE> <INDENT> return _itkReconstructionByErosionImageFilterPython.itkReconstructionByErosionImageFilterIUS2IUS2_GetPointer(self)
GetPointer(self) -> itkReconstructionByErosionImageFilterIUS2IUS2
625941d616aa5153ce3626bb
def get_db(self, guild: typing.Union[int, str]): <NEW_LINE> <INDENT> return DataBase.get(self.bot, guild)
Get DataBase object -- wrapper of discord.Guild. Parameters ---------- guild : int, str, discord.Guild id or name of the guild to wrap Returns ------- database : DataBase
625941d601c39578d7e7507f
def __init__(self): <NEW_LINE> <INDENT> self.swaggerTypes = { 'annotations': 'any', 'apiVersion': 'str', 'creationTimestamp': 'str', 'deletionTimestamp': 'str', 'generateName': 'str', 'kind': 'str', 'labels': 'any', 'name': 'str', 'namespace': 'str', 'resourceVersion': 'str', 'selfLink': 'str', 'spec': 'v1beta3_PodSpec...
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.
625941d6462c4b4f79d1d914
def at_s(self, s, minsteps=1000): <NEW_LINE> <INDENT> return self.at_t(self.s_to_t(s, minsteps=minsteps))
Gives the point on the curve at arc length s. This is a call to s_to_t followed by a call to at_t, passing minsteps along. Note that this may use the lookup table.
625941d6236d856c2ad44a20
def client_login(self, user=None): <NEW_LINE> <INDENT> if user is None: <NEW_LINE> <INDENT> user = UserFactory.create() <NEW_LINE> <DEDENT> with mock_browserid(user.email): <NEW_LINE> <INDENT> self.client.login(assertion='asdf', audience='asdf') <NEW_LINE> <DEDENT> return user
Authenticate the test client as the given user. If no user is given, a test user is created and returned.
625941d65fc7496912cc3bc2
def _softmax_2d(self, x, temp): <NEW_LINE> <INDENT> B, C, W, H = x.size() <NEW_LINE> x_flat = x.view((B, C, W*H)) / temp <NEW_LINE> x_softmax = self.softmax(x_flat) <NEW_LINE> return x_softmax.view((B, C, W, H))
For the lack of a true 2D softmax in pytorch, we reshape each image from (C, W, H) to (C, W*H) and then apply softmax, and then restore the original shape. :param x: A 4D tensor of shape (B, C, W, H) to apply softmax across the W and H dimensions :param temp: A scalar temperature to apply as part of the softmax functi...
625941d663d6d428bbe44734
def searchitem(self, branch, finditem): <NEW_LINE> <INDENT> compare = False <NEW_LINE> columnone = self.tree.item(branch)["values"][0].lower() <NEW_LINE> columntwo = self.tree.item(branch)["values"][1].lower() <NEW_LINE> columnthree = self.tree.item(branch)["values"][2].lower() <NEW_LINE> if (columnone.startswith(findi...
Condense the compare of search.
625941d67b25080760e3969c
def sortColors(self, nums): <NEW_LINE> <INDENT> r = 0 <NEW_LINE> b = len(nums)-1 <NEW_LINE> cur = 0 <NEW_LINE> while (cur < len(nums) and cur <= b): <NEW_LINE> <INDENT> if (nums[cur] == 0): <NEW_LINE> <INDENT> nums[cur] = nums[r] <NEW_LINE> nums[r] = 0 <NEW_LINE> cur += 1 <NEW_LINE> r += 1 <NEW_LINE> <DEDENT> elif (num...
:type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead.
625941d626238365f5f0f0b5
def _bitsfor(maxval): <NEW_LINE> <INDENT> maxvalbits = int(round(math.log(maxval)/math.log(2))) <NEW_LINE> if maxval != (1 << maxvalbits): <NEW_LINE> <INDENT> raise ValueError("maxval must be a power of 2, not %d" % maxval) <NEW_LINE> <DEDENT> return maxvalbits
Convert a maxval into a number of bits (left shift). Raises a ValueError if the maxval is not a power of 2.
625941d630c21e258bdfa6e2
def test_get_id(self, space): <NEW_LINE> <INDENT> hyperband = Hyperband(space) <NEW_LINE> assert hyperband.get_id(['whatever', 1]) == hyperband.get_id(['is here', 1]) <NEW_LINE> assert hyperband.get_id(['whatever', 1]) != hyperband.get_id(['is here', 2])
Test valid id of points
625941d6a79ad161976cc38a
def _gto_from_ccdata(self): <NEW_LINE> <INDENT> gbasis = self.ccdata.gbasis <NEW_LINE> label_template = '{:s} {:5d} 1.00' <NEW_LINE> basis_template = '{:15.9e} {:15.9e}' <NEW_LINE> lines = [] <NEW_LINE> for no, basis in enumerate(gbasis): <NEW_LINE> <INDENT> lines.append('{:3d} 0'.format(no + 1)) <NEW_LINE> for prims i...
Create [GTO] section using gbasis. atom_sequence_number1 0 shell_label number_of_primitives 1.00 exponent_primitive_1 contraction_coeff_1 (contraction_coeff_1) ... empty line atom_sequence__number2 0
625941d6fb3f5b602dac38d9
def __init__(self, index=None, content=None): <NEW_LINE> <INDENT> self._index = None <NEW_LINE> self._content = None <NEW_LINE> self.discriminator = None <NEW_LINE> if index is not None: <NEW_LINE> <INDENT> self.index = index <NEW_LINE> <DEDENT> if content is not None: <NEW_LINE> <INDENT> self.content = content
Thumbnail - a model defined in Swagger
625941d6e76e3b2f99f3aa4c
def _create_port_chain(self, context, vnf_mapping, template_db, nfp_name): <NEW_LINE> <INDENT> chain_list = [] <NEW_LINE> prev_forwarder = None <NEW_LINE> vnfm_plugin = manager.TackerManager.get_service_plugins()['VNFM'] <NEW_LINE> logical_chain = self._get_nfp_attribute(template_db.template, nfp_name, 'path') <NEW_LIN...
Creates a list of physical port ids to represent an ordered chain :param context: SQL session context :param vnf_mapping: dict of VNFD to VNF instance mappings :param template_db: VNFFG Descriptor :param nfp_name: name of the forwarding path with chain requirements :return: list of port chain including vnf name and li...
625941d660cbc95b062c6787
def is_repeating(sequence, period): <NEW_LINE> <INDENT> seq_len = len(sequence) <NEW_LINE> if period <= 1 or period >= seq_len: <NEW_LINE> <INDENT> raise ValueError('The period must be greater than one and less than ' 'the length of the sequence') <NEW_LINE> <DEDENT> if seq_len % period != 0: <NEW_LINE> <INDENT> raise ...
Returns true if the elements in the sequence repeat with the given period. Parameters ---------- sequence : sequence The sequence of elements to check. period : int The period over which the elements should repeat.
625941d62c8b7c6e89b35a04
def fit_func(p, x): <NEW_LINE> <INDENT> bin_width = x[1] - x[0] <NEW_LINE> p[2] = np.sqrt(p[2]**2 + bin_width**2/12.) <NEW_LINE> return p[0] / p[2] / np.sqrt(2. * np.pi) * np.exp(-(np.asfarray(x) - p[1]) ** 2 / (2. * p[2] ** 2))
Simple gaussian pdf :param p: [norm,mean,sigma] :param x: x :return: G(x)
625941d60c0af96317bb842c
def set_sensor_value(self, sensor_number: int, value) -> dict: <NEW_LINE> <INDENT> return self.call_api(Command.SET_STATE_SENSOR, { UrlParam.NUMBER: sensor_number, UrlParam.VALUE: value })
Sets a new value for the specified sensor. WARNING: Only use this for "virtual" sensors or for debugging! :param sensor_number: sensor number (not id!) to set the new value on :param value: the new value to set on the specified sensor :return: the api response
625941d6a934411ee37518d8
def get_tree_no_parents_abc_content_2(self, tree, converter=None): <NEW_LINE> <INDENT> self._make_abc_tree(tree) <NEW_LINE> f = open(tree.basedir + '/a', 'wb') <NEW_LINE> try: <NEW_LINE> <INDENT> f.write('foobar\n') <NEW_LINE> <DEDENT> finally: <NEW_LINE> <INDENT> f.close() <NEW_LINE> <DEDENT> return self._convert_tree...
return a test tree with a, b/, b/c contents. This variation changes the content of 'a' to foobar .
625941d6a8ecb033257d3310
def minimise_grid_search(self, inc=11, verbosity=0, methods=None, model=None, model_from=None, analysis=None, analysis_from=None, list_glob_ini=None, force=False): <NEW_LINE> <INDENT> if model_from == None: <NEW_LINE> <INDENT> model_from = model <NEW_LINE> <DEDENT> if analysis_from == None: <NEW_LINE> <INDENT> analysis...
Use value.set on all pipes.
625941d69c8ee82313fbb9ba
def get_inter_graph_connections(self, key = "", other_graph_id = ""): <NEW_LINE> <INDENT> if key == "": <NEW_LINE> <INDENT> return self.inter_graph_connections <NEW_LINE> <DEDENT> elif other_graph_id == "": <NEW_LINE> <INDENT> return self.inter_graph_connections[key] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise ...
Gets the connections to other graphs of the Node requested. If none requested, returns the full dictionary. Keyword arguments: key -- the unique identifier of the node in the graph (default = "").
625941d60c0af96317bb842d
def servo_one(self, angle): <NEW_LINE> <INDENT> if not self._enable_servo1: <NEW_LINE> <INDENT> self._enable_servo1 = True <NEW_LINE> self._set_config() <NEW_LINE> <DEDENT> us_min, us_max = self._servo_range(0) <NEW_LINE> us = self._servo_degrees_to_us(angle, us_min, us_max) <NEW_LINE> self._i2c_write_word(self.REG_SER...
Set position of servo 1 in degrees. :param angle: Angle in degrees from -90 to 90
625941d6c4546d3d9de72c79
def canConstruct(self, ransomNote, magazine): <NEW_LINE> <INDENT> magazine_list = list(magazine) <NEW_LINE> for x in ransomNote: <NEW_LINE> <INDENT> if x not in magazine_list: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> magazine_list.remove(x) <NEW_LINE> <DEDENT> <DEDENT> return True
:type ransomNote: str :type magazine: str :rtype: bool
625941d65f7d997b87174cdd
def _finalize_self(self): <NEW_LINE> <INDENT> self._merge_dates() <NEW_LINE> self.slug = os.path.splitext(os.path.basename(self.filename))[0] <NEW_LINE> self._sort_key = (self.startdate, self.venue) <NEW_LINE> self.instructor = [self._app_meta('author_id', x) for x in self.instructor] <NEW_LINE> if len(self.instructor)...
Finish creating this object: * Create normalized date for display. * Create slug. * Create sort key (start date and venue).
625941d68c0ade5d55d3ec00
def agb_input_defaults(profile=None): <NEW_LINE> <INDENT> if profile is None: <NEW_LINE> <INDENT> keys = ['over_write', 'agbtrack_dir', 'agb_mix', 'set_name', 'trilegal_dir', 'isotrack_dir', 'tracce_dir', 'diagnostic_dir0', 'make_imfr', 'mass_loss', 'metals_subset'] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> logger....
# COLIBRI directory structure must be [agbtrack_dir]/[agb_mix]/[set_name] agbtrack_dir /home/rosenfield/research/TP-AGBcalib/AGBTracks agb_mix CAF09 set_name S_NOV13 ### Parameters for TRILEGAL INPUT: # Where input files will go for TRILEGAL trilegal_dir cmd_inputfiles/ # Non-TP-AGB tracks to us...
625941d6e5267d203edcdedf
def GetPointer(self): <NEW_LINE> <INDENT> return _itkInPlaceImageFilterBPython.itkInPlaceImageFilterIUS3VIUS3_GetPointer(self)
GetPointer(self) -> itkInPlaceImageFilterIUS3VIUS3
625941d6cc0a2c11143dd0d5
def _deactivate(self): <NEW_LINE> <INDENT> for ob in reversed(self._activated_objects): <NEW_LINE> <INDENT> ob.deactivate() <NEW_LINE> <DEDENT> gl.glUseProgram(0) <NEW_LINE> self._active = False
Deactivate any objects that were activated on our behalf, and then deactivate ourself.
625941d6f8510a7c17cf9941
def _getNamedMainChild(name): <NEW_LINE> <INDENT> mainWin = _getMayaWin() <NEW_LINE> if mainWin: <NEW_LINE> <INDENT> mainChildren = mainWin.children() <NEW_LINE> matching = [] <NEW_LINE> for child in mainChildren: <NEW_LINE> <INDENT> if name == child.objectName(): <NEW_LINE> <INDENT> matching.append(child) <NEW_LINE> <...
Get the named child of the main window as a Qt object
625941d64527f215b584c699
def draw(self, mode='tex'): <NEW_LINE> <INDENT> if mode == 'tex': <NEW_LINE> <INDENT> self._format_style() <NEW_LINE> self._check_color() <NEW_LINE> string = '\\Edge[' <NEW_LINE> for k in self.tikz_kwds: <NEW_LINE> <INDENT> if k in self.attributes and self.attributes.get(k, None) is not None: <NEW_LIN...
Function to draw an virtual edge. Parameters ---------- mode : str, optional (default = 'tex') The mode defines which kind of result should be returned. Currently a string for a tex file or a string for a csv file can be returned. Returns ------- string : str Returns a string defining the edge. If 'tex' m...
625941d6be7bc26dc91cd842
def determine_polygon_extrema(slabname, slabfile): <NEW_LINE> <INDENT> slabbounds = slabpolygon(slabname, slabfile) <NEW_LINE> coords = np.size(slabbounds) <NEW_LINE> def is_odd(num): <NEW_LINE> <INDENT> return num & 0x1 <NEW_LINE> <DEDENT> lons = [] <NEW_LINE> lats = [] <NEW_LINE> for i in range(coords-1): <NEW_LINE> ...
inputs: slabname to be referenced against stored slab coordinates in slabfile outputs: the maximum and minimum latitude and longitude values for the input slab
625941d65fcc89381b1e1905
def trainAndSaveNN(train_dl, test_dl, model): <NEW_LINE> <INDENT> nn.train_model(train_dl, test_dl, model) <NEW_LINE> torch.save(model.state_dict(), 'trainedNN.pt')
Train the Neural Network and save the trained model Parameters ---------- train_dl : Training data test_dl : Test data model : Neural Network model Returns ------- None.
625941d68e05c05ec3eea5bb