code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def create(self, name: Optional[str] = None, **kwargs) -> Volume: <NEW_LINE> <INDENT> data = { "Driver": kwargs.get("driver"), "Labels": kwargs.get("labels"), "Name": name, "Options": kwargs.get("driver_opts"), } <NEW_LINE> response = self.client.post( "/volumes/create", data=api.prepare_body(data), headers={"Content-T...
Create a Volume. Args: name: Name given to new volume Keyword Args: driver (str): Volume driver to use driver_opts (Dict[str, str]): Options to use with driver labels (Dict[str, str]): Labels to apply to volume Raises: APIError: when service reports error
625941d31d351010ab855cef
def get_app_start_total_time(self, component): <NEW_LINE> <INDENT> time = self.shell("am start -W %s | %s TotalTime" % (component, find_util)).stdout.read().split(": ")[-1] <NEW_LINE> return int(time)
获取启动应用所花时间 usage: getAppStartTotalTime("com.android.settings/.Settings")
625941d3498bea3a759b9c82
def forwards(self, orm): <NEW_LINE> <INDENT> for gift in orm.Gift.objects.all(): <NEW_LINE> <INDENT> ty_status = 'todo' <NEW_LINE> if gift.status == 'written' or gift.status == 'sent': <NEW_LINE> <INDENT> ty_status = gift.status <NEW_LINE> gift.status = 'recv' <NEW_LINE> gift.save() <NEW_LINE> <DEDENT> ty = orm.ThankYo...
Write your forwards methods here.
625941d3fff4ab517eb2f610
def unquote_colors(context): <NEW_LINE> <INDENT> for k, v in context.items(): <NEW_LINE> <INDENT> if len(v) == 9 and v.startswith("%23"): <NEW_LINE> <INDENT> context[k] = "#" + v[3:] <NEW_LINE> <DEDENT> <DEDENT> return context
URL unqote colors from context.
625941d3d18da76e235326aa
def New(*args, **kargs): <NEW_LINE> <INDENT> obj = itkVectorConfidenceConnectedImageFilterIRGBUS2IUC2.__New_orig__() <NEW_LINE> import itkTemplate <NEW_LINE> itkTemplate.New(obj, *args, **kargs) <NEW_LINE> return obj
New() -> itkVectorConfidenceConnectedImageFilterIRGBUS2IUC2 Create a new object of the class itkVectorConfidenceConnectedImageFilterIRGBUS2IUC2 and set the input and the parameters if some named or non-named arguments are passed to that method. New() tries to assign all the non named parameters to the input of the ne...
625941d37d847024c06be491
def check_events(ai_settings, screen, stats, sb, play_button, bird, pigs,bullets, super_bullets): <NEW_LINE> <INDENT> for event in pygame.event.get(): <NEW_LINE> <INDENT> if event.type == pygame.QUIT: <NEW_LINE> <INDENT> sys.exit() <NEW_LINE> <DEDENT> elif event.type == pygame.KEYDOWN: <NEW_LINE> <INDENT> check_keydown...
监视键盘和鼠标事件 :param ai_settings: 游戏设置对象 :param screen: 屏幕对象 :param stats: 游戏统计信息对象 :param sb: 游戏计分牌对象 :param play_button: 开始游戏按钮对象 :param bird: 小鸟对象 :param pigs: 猪编组对象 :param bullets: 子弹编组对象 :param super_bullets: 导弹对象
625941d34a966d76dd5511e4
def seg_str(seg, seg_term, ele_term, subele_term, eol=''): <NEW_LINE> <INDENT> tmp = [] <NEW_LINE> for a in seg: <NEW_LINE> <INDENT> if type(a) is ListType: <NEW_LINE> <INDENT> tmp.append(subele_term.join(a)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> tmp.append(a) <NEW_LINE> <DEDENT> <DEDENT> return '%s%s%s' % (ele...
Join a list of elements @param seg: List of elements @type seg: list[string|list[string]] @param seg_term: Segment terminator character @type seg_term: string @param ele_term: Element terminator character @type ele_term: string @param subele_term: Sub-element terminator character @type subele_term: string @param eol: E...
625941d392d797404e30435e
def test_not_contraction_1(self): <NEW_LINE> <INDENT> f = lambda x: self.T(x, self.mu_1) <NEW_LINE> fp = (4 * self.mu_1 - 1) / (4 * self.mu_1) <NEW_LINE> for i in self.unit_inverval: <NEW_LINE> <INDENT> self.assertFalse(abs(compute_fixed_point(f, i, **self.kwargs)-fp) < 1e-4)
compute_fp: no convergence outside interval of convergence
625941d33c8af77a43ae3974
def delegate(self, request, *args, **kwargs): <NEW_LINE> <INDENT> return HttpResponseNotImplemented()
Map the captured arguments from the URL to a resource in this collection, and call the resource with appropriate arguments.
625941d338b623060ff0afc1
def upload_to_s3(file): <NEW_LINE> <INDENT> callback = None <NEW_LINE> md5 = None <NEW_LINE> reduced_redundancy = False <NEW_LINE> content_type = None <NEW_LINE> try: <NEW_LINE> <INDENT> size = os.fstat(file.fileno()).st_size <NEW_LINE> <DEDENT> except (AttributeError, OSError): <NEW_LINE> <INDENT> file.seek(0, os.SEEK...
Uploads the given file to the AWS S3 bucket and key specified. callback is a function of the form: def callback(complete, total) The callback should accept two integer parameters, the first representing the number of bytes that have been successfully transmitted to S3 and the second representing the size of the to b...
625941d3293b9510aa2c3468
def _run_step_sqls(self, step): <NEW_LINE> <INDENT> oldstep = self._complete_previous_steps(step) <NEW_LINE> if oldstep: <NEW_LINE> <INDENT> self._try_complete_waiting_steps(STEP_NOBLOCK | STEP_RETRY) <NEW_LINE> self._report_multiple_error_messages(oldstep) <NEW_LINE> <DEDENT> session_tag = step.session() <NEW_LINE> db...
execute one step sqls, firstly need to know which session the sqls need to executed in. the sql execution has possiblity to be blocked by something, for example, by last step, for some interval data lock, if it is blocked by something, we call it a waiting step. we have a waiting list to hold all the current waiting s...
625941d3cc0a2c11143dd064
def __ge__(self, other: object) -> bool: <NEW_LINE> <INDENT> if isinstance(other, Fraction): <NEW_LINE> <INDENT> return ( self.numerator / self.denominator >= other.numerator / other.denominator ) <NEW_LINE> <DEDENT> raise TypeError("Can only compare Fractions")
Greater than or equal comparison
625941d3ac7a0e7691ed429d
def __str__(self): <NEW_LINE> <INDENT> return self._pretty_str()
Handle str(dataset).
625941d301c39578d7e7500f
def _a_r_b(a_label, path_type, p_depth, r_type, b_label, conditions, output): <NEW_LINE> <INDENT> if a_label: <NEW_LINE> <INDENT> cy = f"MATCH (a:{a_label})" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> cy = 'MATCH (a)' <NEW_LINE> <DEDENT> if output not in ['CREATE_RELATIONSHIP']: <NEW_LINE> <INDENT> if path_type in [...
[Cypher scripts initiate] [Build a initiative cypher scripts] Arguments: a_label {[str]} -- [Start node label] path_type {Str} -- [path finder type] p_depth {int} -- [path depth to search] r_type {[str]} -- [The relationship type] b_label {[str]} -- [End node label] conditions {[str]} -- [where ...
625941d3796e427e537b079a
def get_last_auto_increment_value(self): <NEW_LINE> <INDENT> raise Exception('get_last_auto_increment_value is not implemented')
Return the last value that was generatead using auto-increment :return: int
625941d3bf627c535bc133a2
def viewer(scene=None,background=(1.0,1.0,1.0),lightdir=None): <NEW_LINE> <INDENT> from pivy import coin <NEW_LINE> from pivy import sogui <NEW_LINE> win = sogui.SoGui.init() <NEW_LINE> if win is None: <NEW_LINE> <INDENT> print("Unable to create a SoGui window") <NEW_LINE> return <NEW_LINE> <DEDENT> win.setBackgroundCo...
viewer(scene=None,background=(1.0,1.0,1.0),lightdir=None): starts a standalone coin viewer with the contents of the given scene. You can give a background color, and optionally a light direction as a (x,y,z) tuple. In this case, a directional light will be added and shadows will be turned on. This might not work with s...
625941d3377c676e9127237c
def generate_random_uuid(): <NEW_LINE> <INDENT> return uuid4().hex
Generate random uuid :return:
625941d3d8ef3951e3243711
def compose(s1, s2): <NEW_LINE> <INDENT> return s1.replace(b":", b"\\:") + b":" + s2
Construct a value of Compose value type. s1, s2 -- serialised form of a property value (This is only needed if the type of the first value permits colons.)
625941d34c3428357757c4fb
def cityList(dic): <NEW_LINE> <INDENT> lst=dic.values() <NEW_LINE> s = 0 <NEW_LINE> for x in lst: <NEW_LINE> <INDENT> s += x <NEW_LINE> <DEDENT> return s
This will return the total number of employees a company has from a dictionary with cities as keys and the numbers of employees in that city as its value.
625941d329b78933be1e587d
def hci_send(self, cmd): <NEW_LINE> <INDENT> packet = bt.HCI_Hdr() / bt.HCI_Command_Hdr() / cmd <NEW_LINE> self.logger.debug("Packet to be send out with 'hci_send':\n###[ Structure ]###\n {}\n{}" .format(packet.summary(), packet.show2(dump=True))) <NEW_LINE> return self.socket.send(packet)
send HCI Command via acquired socket BUT DON'T block waiting for an answer
625941d33d592f4c4ed1d23f
def adjust_learning_rate(optimizer, epoch, args): <NEW_LINE> <INDENT> lr = args.learning_rate * (0.1 ** (epoch // 150)) * (0.1 ** (epoch // 225)) <NEW_LINE> for param_group in optimizer.param_groups: <NEW_LINE> <INDENT> param_group['lr'] = lr
Sets the learning rate to the initial LR decayed by 10 after 150 and 225 epochs
625941d3009cb60464c63584
def drawpolycone_worker(params): <NEW_LINE> <INDENT> if not _DRAW_BONDS: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> (pos_array, rad_array) = params <NEW_LINE> glePolyCone(pos_array, None, rad_array) <NEW_LINE> return
Draw a polycone. Receive parameters through a sequence so that this function and its parameters can be passed to another function for deferment. Right now this is only ColorSorter.schedule (see below)
625941d37b180e01f3dc49cf
def process_song_data(spark, input_data, output_data): <NEW_LINE> <INDENT> song_data = os.path.join(input_data, 'song_data/*/*/*/*.json') <NEW_LINE> df = spark.read.json(song_data) <NEW_LINE> songs_table = df.select(['song_id', 'title', 'artist_id', 'year', 'duration']).dropDuplicates() <NEW_LINE> songs_table.write ...
:param spark: spark connection instance :param input_data: str, input data path :param output_data: str, output data path
625941d39f2886367277aa60
def pad(sequences, pad_value=-1): <NEW_LINE> <INDENT> max_length = -float('inf') <NEW_LINE> for sequence in sequences: <NEW_LINE> <INDENT> if len(sequence) > max_length: <NEW_LINE> <INDENT> max_length = len(sequence) <NEW_LINE> <DEDENT> <DEDENT> padded_sequences = np.full(shape=[len(sequences), max_length], fill_value=...
Convert sequences into a 2D matrix. 'pad_value' is used to signal that the line has already ended. :param sequences: A list of integer observation sequences :param pad_value: The value to pad with. :return: padded_sequences:
625941d356ac1b37e62643a2
def update_client_status(self,clients): <NEW_LINE> <INDENT> self.log("in update_client_status") <NEW_LINE> impl = Implementation(self.data['implementation'],self.data['name']) <NEW_LINE> nodes = impl.nodes <NEW_LINE> tree = compatibility_tree.create_compatibility_tree(nodes,clients) <NEW_LINE> self.log(str(tree))
compares app tuples and dedicated app lists. updates whether the service can be enabled then disable the service if it is insufficient client status TODO: All of nodes in implementation is used as dedicated components at the moment. Will replace this in later milestone
625941d3a17c0f6771cbe224
def get_form(): <NEW_LINE> <INDENT> tree = NewickIO.parse(g_default_string, FelTree.NewickTree) <NEW_LINE> formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60) <NEW_LINE> form_objects = [ Form.MultiLine('tree', 'newick tree with branch lengths', formatted_tree_string), Form.SingleLine('lhs_a', 'the first...
@return: the body of a form
625941d3956e5f7376d71040
def on_open_search_result(self, username): <NEW_LINE> <INDENT> pass
Événement <on_search_result_selected>: passe le nom d'utilisateur de l'utilisateur sélectionné au récepteur de lévénement :param username: Le nom d'utilisateur de l'utilisateur sélectionné :type username: str :return: :rtype: None
625941d38e05c05ec3eea549
def flip_pose(pose): <NEW_LINE> <INDENT> flippedParts = [0, 1, 2, 6, 7, 8, 3, 4, 5, 9, 10, 11, 15, 16, 17, 12, 13, 14 ,18, 19, 20, 24, 25, 26, 21, 22, 23, 27, 28, 29, 33, 34, 35, 30, 31, 32, 36, 37, 38, 42, 43, 44, 39, 40, 41, 45, 46, 47, 51, 52, 53, 48, 49, 50, 57, 58, 59, 54, 55, 56, 63, 64, 65, 60, 61, 62, 69, 70, 7...
Flip pose. The flipping is based on SMPL parameters.
625941d3d18da76e235326ab
def generate_property_deprecation_message(to_be_removed_in_version, old_name, new_name, new_attribute, module_name='Client'): <NEW_LINE> <INDENT> message = "Call to deprecated property '{name}'. This property will be removed in version '{version}'".format( name=old_name, version=to_be_removed_in_version, ) <NEW_LINE> m...
Generate a message to be used when warning about the use of deprecated properties. :param to_be_removed_in_version: Version of this module the deprecated property will be removed in. :type to_be_removed_in_version: str :param old_name: Deprecated property name. :type old_name: str :param new_name: Name of the new prop...
625941d3046cf37aa974cf1a
def t_CONSTANT(t): <NEW_LINE> <INDENT> if t.value[:2] == '0x': <NEW_LINE> <INDENT> t.value = str(int(t.value.replace('0h', '0x'), 16)) <NEW_LINE> <DEDENT> t.type = 'CONSTANT' <NEW_LINE> return t
0[xX][0-9a-fA-F]+|[0-9]+
625941d3851cf427c661a6e1
def prepare_template_vals(dtype, rounding=False): <NEW_LINE> <INDENT> template_vals = dict() <NEW_LINE> for key in ("common", "inits", "finish", "stats_args", "mul_by_scale", "atomic_max"): <NEW_LINE> <INDENT> template_vals[key] = "" <NEW_LINE> <DEDENT> if dtype == "f2": <NEW_LINE> <INDENT> template_vals["common"] += _...
Set up template code snippets that are reused across multiple kernels. Most are data type conversion and statistics collection related.
625941d3baa26c4b54cb12f2
def out(self, message): <NEW_LINE> <INDENT> self.file.write(message + "\n")
output one line to the log file
625941d33317a56b86939e29
def isSameTreeIter(self, p, q): <NEW_LINE> <INDENT> if p and q: <NEW_LINE> <INDENT> que = Queue.Queue() <NEW_LINE> q.put((p, q)) <NEW_LINE> while not que.empty(): <NEW_LINE> <INDENT> p, q = que.get() <NEW_LINE> if p.val != q.val: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if [p.left, q.left].count(None) == 1 ...
:type p: TreeNode :type q: TreeNode :rtype: bool
625941d3099cdd3c635f0e2e
def identity_rmse(Z, Y): <NEW_LINE> <INDENT> N = Z.shape[0] <NEW_LINE> Y_pred = Z <NEW_LINE> cost = np.sqrt(np.sum(np.power(Y_pred - Y, 2) / N)) <NEW_LINE> D = (Y_pred - Y) / N <NEW_LINE> return Y_pred, cost, D
Identity output layer with root mean square error (RMSE) for regression tasks.
625941d396565a6dacc8f89f
@mock.patch('drydock_provisioner.drivers.kubernetes' '.promenade_driver.promenade_client' '.PromenadeSession._get_prom_url', return_value=PROM_URL) <NEW_LINE> @mock.patch('drydock_provisioner.drivers.kubernetes' '.promenade_driver.promenade_client' '.PromenadeSession.set_auth', return_value=None) <NEW_LINE> @responses....
Test relabel node call from Promenade Client
625941d363f4b57ef00012ea
def getSysDataPath(subPath = ""): <NEW_LINE> <INDENT> if subPath: <NEW_LINE> <INDENT> path = getSysPath( os.path.join("data", subPath) ) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> path = getSysPath("data") <NEW_LINE> <DEDENT> return formatPath(path)
Path to the data folder that is installed with MakeHuman system-wide. NOTE: do NOT assume that getSysPath("data") == getSysDataPath()!
625941d3ab23a570cc250357
def test_loaddata_no_fixture_specified(self): <NEW_LINE> <INDENT> with six.assertRaisesRegex(self, management.CommandError, "No database fixture specified. Please provide the path of " "at least one fixture in the command line."): <NEW_LINE> <INDENT> management.call_command( 'loaddata', verbosity=0, )
Regression for #7043 - Error is quickly reported when no fixtures is provided in the command line.
625941d37d43ff24873a2e74
def _replace_field_list_block(match): <NEW_LINE> <INDENT> heading, data = match.group(1), match.group(2) <NEW_LINE> return '<tr><td>{0}:</td><td>{1}</td></tr>'.format( heading, data)
Return an HTML <table> version of the reStructured Text-like field list found in the passed re.match object. See tableifyrst for more information.
625941d31b99ca400220ac85
def check_diskspace(app_configs=None, **kwargs): <NEW_LINE> <INDENT> stat = os.statvfs(settings.DATA_DIR) <NEW_LINE> if stat.f_bavail * stat.f_bsize < 10000000: <NEW_LINE> <INDENT> return [weblate_check("weblate.C032", "The disk is nearly full")] <NEW_LINE> <DEDENT> return []
Check free disk space.
625941d3a4f1c619b28b020a
def selectionSort(lst): <NEW_LINE> <INDENT> for i in range(20): <NEW_LINE> <INDENT> current = lst[i] <NEW_LINE> minimumItem = current <NEW_LINE> for j in range (i+1, len(lst)-1): <NEW_LINE> <INDENT> if lst[j].count < minimumItem.count: <NEW_LINE> <INDENT> minimumItem = lst[j] <NEW_LINE> <DEDENT> <DEDENT> lst[i], lst[mi...
This function uses a for loop to take the unsorted list created from the input file and print out the sorted list after comapring the different elements and properly sorting the elements contained in the file.
625941d34527f215b584c629
def _write_properties(self, parent_node, gadget, child): <NEW_LINE> <INDENT> properties = prop_registry.get_writable_properties(gadget.widget, child) <NEW_LINE> properties.sort(lambda a, b: cmp(a.name, b.name)) <NEW_LINE> for prop_type in properties: <NEW_LINE> <INDENT> if prop_type.child: <NEW_LINE> <INDENT> prop = ga...
@parent_node: the node of the parent, could be a widget node or a child node when setting packing properties @gadget: @child: boolean, if true write child properties, if false write normal
625941d3e76e3b2f99f3a9dd
def environment(self, atomi, rmax=3.2, polaronly=True): <NEW_LINE> <INDENT> atom = self.atoms[atomi] <NEW_LINE> listik = self.atom_lister('polar') if polaronly else self.atom_lister() <NEW_LINE> listik = [i for (i,a) in self.__enumerate_atoms_(listik) if abs(atom.dx(a))<rmax] <NEW_LINE> listik = [i for (i,a) in self.__...
Returns the environment of the atom. List of the contact atoms is generated using maximum distance of rmax and only include polar atoms by default (use polaronly=False to include carbons). Method returns the dictionary of bonds. Keys are atom IDs and values are bond distances. Intra-residue contacts are included. Us...
625941d3a934411ee3751867
def scaleof(R, value): <NEW_LINE> <INDENT> return scaleofunit(R, getattr(value, "unit", ''))
return the 'scale' of a quantity or value itself return scaleofunit( getattr(value, "unit", '') ) Parameter --------- value : numerical like, quantity Outputs ------- value : numerical
625941d316aa5153ce36264b
def set_roles_for_edx_users(user, permissions, strategy): <NEW_LINE> <INDENT> was_set_global_staff = False <NEW_LINE> role_ids = set(user.courseaccessrole_set.values_list('id', flat=True)) <NEW_LINE> new_role_ids = [] <NEW_LINE> for role in permissions: <NEW_LINE> <INDENT> if role['obj_id']: <NEW_LINE> <INDENT> role = ...
This function is specific functional for open-edx platform. It create roles for edx users from sso permissions.
625941d34428ac0f6e5ba9c7
def _darwin_is_battery_present(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> get_level() <NEW_LINE> <DEDENT> except RegexDidNotMatchError: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True
Check if there's a battery present for macOS systems.
625941d397e22403b379d16e
def AddsOnes(self, request_iterator, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!')
Add 1 to multiple numbers
625941d3b7558d58953c50e6
def _dir_deletions(self): <NEW_LINE> <INDENT> return self._accessors
delete unwanted __dir__ for this object
625941d3d99f1b3c44c67761
def post_detail(request, year, month, day, slug, template_name="blog/post/detail.html"): <NEW_LINE> <INDENT> return render_to_response( template_name, context_instance=RequestContext( request, processors=[blog_post_processor(year=year, month=month, day=day, slug=slug),] ) )
Post Detail
625941d3f7d966606f6aa1da
def GetArgDetails(self, arg): <NEW_LINE> <INDENT> if getattr(arg, 'detailed_help', None): <NEW_LINE> <INDENT> raise ValueError( '{}: Use add_argument(help=...) instead of detailed_help="""{}""".' .format(self._command_name, getattr(arg, 'detailed_help'))) <NEW_LINE> <DEDENT> return usage_text.GetArgDetails(arg)
Returns the detailed help message for the given arg.
625941d33c8af77a43ae3975
def from_iso_datetime(datestring): <NEW_LINE> <INDENT> dt = dateutil.parser.parse(datestring) <NEW_LINE> return to_utc(dt)
Parse an ISO 8601 datetime and create a TZ aware datetime object in UTC.
625941d385dfad0860c3b02f
def readRBCFields(filePath, minTime=0.0, includeMinMax=False): <NEW_LINE> <INDENT> with open(filePath, 'r') as f: <NEW_LINE> <INDENT> data = load_csv_to_dictionary(f) <NEW_LINE> <DEDENT> timeIndices = np.where(data['//- Time'] >= minTime)[0] <NEW_LINE> results = {'times' : data['//- Time'][timeIndices], 'Hb_mean' : d...
Read RBC fields stored in file 'filePath' and return them in a dictionary with entries 'time', 'PO2_mean', 'PO2_max', 'PO2_min', 'Hb_mean', 'Hb_max', 'Hb_min'.
625941d34c3428357757c4fc
def get_pager(self): <NEW_LINE> <INDENT> pager = {} <NEW_LINE> if self.has_pages: <NEW_LINE> <INDENT> pager['first'] = self.first_page <NEW_LINE> pager['prev'] = self.prev_page if self.has_prev else None <NEW_LINE> pager['curr'] = self._curr_page <NEW_LINE> pager['next'] = self.next_page if self.has_next else None <NEW...
Get pager dict. Returns a dict having current and edged page numbers.
625941d34d74a7450ccd4397
def test_recryption_ciphertext(self): <NEW_LINE> <INDENT> encrypted_array = self.pk.encrypt([0, 1, 0, 0, 1, 0, 0, 1]) <NEW_LINE> old_array = [make_c_mpz_t() for i in range(8)] <NEW_LINE> for a, b in zip(old_array, encrypted_array._array): <NEW_LINE> <INDENT> assign_c_mpz_t(a, b) <NEW_LINE> <DEDENT> encrypted_array.recr...
Test that the ciphertext changes when using recrypt function in EncryptedArray class.
625941d31b99ca400220ac86
def IsReferenced(self, axis): <NEW_LINE> <INDENT> return self._readAxisValue("FRF?", axis) == 1
Report whether the given axis has been referenced Note: setting position with RON disabled will also put it in this mode axis (1<int<16): axis number returns (bool)
625941d3099cdd3c635f0e2f
def check_rxn_mechanism_order(data_dict: dict) -> bool: <NEW_LINE> <INDENT> print('\nChecking if non enzymatic mechanisms come only after enzymatic ones and if fixedExchange is the ' + 'very last one.\n') <NEW_LINE> hard_coded_mechs = {'diffusion', 'freeExchange', 'fixedExchange', 'massAction'} <NEW_LINE> kinetics_df =...
Given the excel file as argument, it goes through the 'kinetic mechanism' column in the 'kinetics1' sheet and checks if hard coded mechanisms ('diffusion', 'freeExchange', 'fixedExchange', 'massAction') come before enzymatic mechanisms. Also checks if 'fixedExchange' mechanisms are the very last ones. Args: data...
625941d301c39578d7e75010
def get_fault_four_corners(fault_object, coords="cartesian"): <NEW_LINE> <INDENT> W = fault_vector_functions.get_downdip_width(fault_object.top, fault_object.bottom, fault_object.dipangle); <NEW_LINE> strike = fault_object.strike; <NEW_LINE> updip_point0 = [fault_object.xstart, fault_object.ystart]; <NEW_LINE> updip_po...
Get the four corners of the object, including updip and downdip. depth is fault_object.top dip is fault_object.dipangle (in case you need it) coords can be "cartesian" or "geographic" for lon/lat
625941d3d164cc6175782f22
def getReport(self): <NEW_LINE> <INDENT> index = None <NEW_LINE> if self.all_data: <NEW_LINE> <INDENT> index = self.all_data[self.data_index] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> index = self.theory_item <NEW_LINE> <DEDENT> params = FittingUtilities.getStandardParam(self._model_model) <NEW_LINE> poly_params = ...
Create and return HTML report with parameters and charts
625941d33cc13d1c6d3c754e
def get_typed(self, key, expect_type, default=None): <NEW_LINE> <INDENT> if type(expect_type) is not str: <NEW_LINE> <INDENT> wrong_type_for_arg(expect_type, "str", "expect_type") <NEW_LINE> <DEDENT> expect_type = self.TYPE_ALIAS.get(expect_type, expect_type) <NEW_LINE> if key in self.fields: <NEW_LINE> <INDENT> type_n...
Return the raw value associated with key if its type matches. Raises a warning if a value exists under key but is of the wrong type.
625941d35510c4643540f5b6
@root_blueprint.route('/logout/') <NEW_LINE> @login_required <NEW_LINE> def logout(): <NEW_LINE> <INDENT> logout_user() <NEW_LINE> return redirect(url_for('main.login'))
User Logout
625941d332920d7e50b283a6
def __init__(self, G, s): <NEW_LINE> <INDENT> self._marked = [False] * G.V() <NEW_LINE> self._dist_to = [math.inf] * G.V() <NEW_LINE> self._edgeTo = [0] * G.V() <NEW_LINE> self._validateVertex(s) <NEW_LINE> self._bfs(G, s) <NEW_LINE> assert self._check(G, s)
Computes the shortest path between the source vertex s and every other vertex in the graph G. :param G: the graph :param s: the source vertex :raises ValueError: unless 0 <= s < V
625941d3507cdc57c6306eb2
def password(self, action: CustomerChangePassword) -> Customer: <NEW_LINE> <INDENT> params: typing.Dict[str, str] = {} <NEW_LINE> return self._client._post( endpoint="customers/password", params=params, data_object=action, response_class=Customer, )
Change a customers password
625941d3f9cc0f698b1407cf
def test_import_dbt_main(self): <NEW_LINE> <INDENT> import dbt.main
just test that the project can be imported
625941d30383005118ecf7b7
def get_blockdev_size(path): <NEW_LINE> <INDENT> fd = os.open(path, os.O_RDONLY) <NEW_LINE> try: <NEW_LINE> <INDENT> buf = bytearray(u64.size) <NEW_LINE> rc = fcntl.ioctl(fd, BLKGETSIZE64, buf) <NEW_LINE> if rc != 0: <NEW_LINE> <INDENT> raise OSError("BLKGETSIZE64 failed") <NEW_LINE> <DEDENT> return u64.unpack(buf)[0] ...
Get the size of a block device, in bytes
625941d3d268445f265b5043
def table_rows(self): <NEW_LINE> <INDENT> for orga in self.organisers: <NEW_LINE> <INDENT> table_row = [orga.get_full_name()] <NEW_LINE> table_row += self._make_row(self._organiser_totals.get(orga, {})) <NEW_LINE> yield table_row <NEW_LINE> <DEDENT> total_row = ["Total"] <NEW_LINE> total_row += self._make_row(self._ove...
Yields rows with the contents of a table with collected sums Each returned row corresponds to an organiser, plus a row for total sums Columns of the rows are, in order: * the full name of the organiser ("Total" for the last row) * sum per category for the organiser, in same order as self.categories * total sum for the ...
625941d33eb6a72ae02ec6b5
def __init__(self, x=0, y=0, w=0, h=0): <NEW_LINE> <INDENT> self.image = pygame.image.load('resources/AirSpeedNeedle.png').convert() <NEW_LINE> self.frameImage = pygame.image.load('resources/Indicator_Background.png').convert() <NEW_LINE> Dial.__init__(self, self.image, self.frameImage, x, y, w, h)
Initialise dial at x,y. Default size of 300px can be overidden using w,h.
625941d3956e5f7376d71041
def build(self, input_shape): <NEW_LINE> <INDENT> check_and_throw_if_fail(len(input_shape) == 3, "input_shape") <NEW_LINE> input_dim = input_shape[2] <NEW_LINE> self.Ws = self.init_Ws((input_dim, self.attention_weight_vector_dim)) <NEW_LINE> self.bs = K.zeros((self.attention_weight_vector_dim,)) <NEW_LINE> self.us = se...
input_shape: batch_size * time_steps* input_dim
625941d3fff4ab517eb2f611
def make_flat_dict(name, selector=None, subselector=None, ns=None, colon_ns=False, root=None, ignore_sub_dicts=False): <NEW_LINE> <INDENT> if ns is None: <NEW_LINE> <INDENT> elemname = name <NEW_LINE> tagname = Selector(0) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> elemname = '{%s}%s' % (ns, name) <NEW_LINE> tagname...
Utility for simple XML templates that traditionally used XMLDictSerializer with no metadata. Returns a template element where the top-level element has the given tag name, and where sub-elements have tag names derived from the object's keys and text derived from the object's values.
625941d3435de62698dfde22
def __init__(self, path_to_config=cc_con.CC_DEFAULT_CONFIG_PATH): <NEW_LINE> <INDENT> self.path_to_config = path_to_config <NEW_LINE> try: <NEW_LINE> <INDENT> open(self.path_to_config, 'a').close() <NEW_LINE> <DEDENT> except OSError: <NEW_LINE> <INDENT> raise OSError('unable to create config file: ' + self.path_to_conf...
Create a new CloudCrypt ConfigParser @param: path_to_config: The path to the config file the parser shall act upon. If this is left empty, a default value of a value specified in the methods is used @returns: A new CloudCrypt ConfigParse object
625941d315fb5d323cde0ce6
def __init__(self, dir=None, filepath=None, hdf_basepath='/', overwrite_if_exist=False, remove_on_destroy=False): <NEW_LINE> <INDENT> if dir is None: <NEW_LINE> <INDENT> dir = tempfile.gettempdir() <NEW_LINE> <DEDENT> if filepath is None: <NEW_LINE> <INDENT> self._fname = self.get_temp_file(dir) <NEW_LINE> <DEDENT> els...
:param dir: string :param filepath: string :param hdf_basepath: string :param overwrite_if_exist: bool :param remove_on_destroy: bool
625941d36aa9bd52df036f79
def main(argv=None): <NEW_LINE> <INDENT> if len(argv) != 1: <NEW_LINE> <INDENT> print("Error, need one argument!", file=sys.stderr) <NEW_LINE> return 2 <NEW_LINE> <DEDENT> cachefile = argv[0] <NEW_LINE> with open(cachefile, "rb") as cachefile: <NEW_LINE> <INDENT> pickled = pickle.Unpickler(cachefile) <NEW_LINE> while c...
Get the mapping for the target recipe.
625941d30a50d4780f667068
def receive(self, packet): <NEW_LINE> <INDENT> super(Allowent, self).receive(packet) <NEW_LINE> if packet.data['tk'] == TrnsKind.allow: <NEW_LINE> <INDENT> if packet.data['pk'] == PcktKind.hello: <NEW_LINE> <INDENT> self.hello() <NEW_LINE> <DEDENT> elif packet.data['pk'] == PcktKind.initiate: <NEW_LINE> <INDENT> self.i...
Process received packet belonging to this transaction
625941d385dfad0860c3b030
def test_remove_array_wrapper(self): <NEW_LINE> <INDENT> array_wrappers = self.flow_service.get_available_datatypes(self.test_project.id, "tvb.datatypes.arrays.MappedArray") <NEW_LINE> self.assertEqual(len(array_wrappers), 1, "There should be no array") <NEW_LINE> data = {'param_1': 'some value'} <NEW_LINE> OperationSe...
Tests the happy flow for the deletion of an array wrapper.
625941d345492302aab5e49a
def deleteMatches(): <NEW_LINE> <INDENT> con = connect() <NEW_LINE> cursor = con.cursor() <NEW_LINE> query = "DELETE FROM match" <NEW_LINE> cursor.execute(query) <NEW_LINE> con.commit() <NEW_LINE> con.close()
Remove all the match records from the database.
625941d307d97122c4178a63
def get_hardware_page_url(url, search_words): <NEW_LINE> <INDENT> source_code = requests.get(url) <NEW_LINE> plain_text = source_code.text <NEW_LINE> soup = BeautifulSoup(plain_text) <NEW_LINE> hardware_page_url = "none" <NEW_LINE> for component in range(len(search_words.titles)): <NEW_LINE> <INDENT> for tab in soup.fi...
Every <a> with 'search words' as text
625941d391af0d3eaac9bbef
def convert_context_to_list(self): <NEW_LINE> <INDENT> given_context = [] <NEW_LINE> user = User.objects.get(id = self.USER_ID) <NEW_LINE> user_profile = user.get_profile() <NEW_LINE> given_context.append(str(self.contexto.companion)) <NEW_LINE> given_context.append(str(self.contexto.weather)) <NEW_LINE> given_context....
Convert the current user context to Python list
625941d356b00c62f0f1482f
def get_location_data(ip_address): <NEW_LINE> <INDENT> location_data_url = f'http://ipinfo.io/{ip_address}/json' <NEW_LINE> response = requests.get(location_data_url) <NEW_LINE> data = response.json() <NEW_LINE> return data
Return the location data of ip_address.
625941d3f7d966606f6aa1db
def detect_gphoto_info(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> cams = {} <NEW_LINE> detect_ret = subprocess.check_output(["/usr/bin/gphoto2", "--auto-detect"], universal_newlines=True) <NEW_LINE> for bus, addr in re.findall(r'usb:(\d+),(\d+)', detect_ret): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> bus, addr ...
detects cameras connected via gphoto2 command line. this can potentially cause long wait times if a camera is attempting to capture for the split second that it tries to gphoto2, however it is the preferred method because it is the most robust and comparmentalised. :param type: :return: a dict of port:serialnumber va...
625941d33c8af77a43ae3976
def length(self, squared=False): <NEW_LINE> <INDENT> d_squared = (self.end.x - self.start.x) ** 2 + (self.end.y - self.start.y) ** 2 <NEW_LINE> if squared: <NEW_LINE> <INDENT> return d_squared <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return math.sqrt(d_squared)
Calculate distance between start & end using Pythagorean theorem.
625941d3ab23a570cc250358
def test__Standard_Data_G10(setup): <NEW_LINE> <INDENT> params = dict(paramsBase) <NEW_LINE> params["GroupSize"] = 10 <NEW_LINE> pluginStandard = TransformationPlugin("Standard") <NEW_LINE> pluginStandard.setParameters(params) <NEW_LINE> pluginStandard.setInputData(data) <NEW_LINE> res = pluginStandard.run() <NEW_LINE>...
Test StandardPlugin: input data, active.
625941d32ae34c7f2600d306
def find_common_ele(a1, a2, a3): <NEW_LINE> <INDENT> i = j = k = 0 <NEW_LINE> while i < len(a1) and j < len(a2) and k < len(a3): <NEW_LINE> <INDENT> if a1[i] == a2[j] == a3[k]: <NEW_LINE> <INDENT> print(a1[i], end=' ') <NEW_LINE> i += 1 <NEW_LINE> j += 1 <NEW_LINE> k += 1 <NEW_LINE> <DEDENT> elif a1[i] < a2[j]: <NEW_LI...
Find common elements in three common sorted arrays. :param a1: :param a2: :param a3: :return:
625941d3293b9510aa2c346a
@app.route("/articles") <NEW_LINE> def articles(): <NEW_LINE> <INDENT> geo = request.args.get("geo") <NEW_LINE> if geo == "": <NEW_LINE> <INDENT> raise RuntimeError("geo value not set") <NEW_LINE> <DEDENT> rows = lookup(geo) <NEW_LINE> return jsonify(rows)
Look up articles for geo.
625941d3de87d2750b85ff69
def testDifferent(self): <NEW_LINE> <INDENT> a = A() <NEW_LINE> b = B() <NEW_LINE> self.assertEqual(a.doA(), "A") <NEW_LINE> self.assertEqual(b.doA(), "A") <NEW_LINE> self.assertEqual(b.doB(), "B")
if a class defines a class variable, values are different for parent and child
625941d3187af65679ca52f4
def test_get_measure(self): <NEW_LINE> <INDENT> self.assertEqual(ucal.ucal.to_string(ucal.ucal.calculate('1m'), include_measure=True), '1 m [length]') <NEW_LINE> self.assertEqual(ucal.ucal.to_string(ucal.ucal.calculate('1'), include_measure=True), '1')
Test ucal.get_measure.
625941d3d4950a0f3b08c523
def _get_population_by_region(self, builder): <NEW_LINE> <INDENT> return _partition_counts(builder, key='region')
Returns a dictionary mapping region to number of partitions in that region.
625941d3fb3f5b602dac386a
def get_dict_from_etree(node): <NEW_LINE> <INDENT> if node is None: <NEW_LINE> <INDENT> return {} <NEW_LINE> <DEDENT> args = {} <NEW_LINE> for child in node: <NEW_LINE> <INDENT> name = child.get('name').strip() <NEW_LINE> if child.tag == 'variable': <NEW_LINE> <INDENT> args[name] = child.text.strip() <NEW_LINE> <DEDENT...
Given a parent node, this function looks for child elements and returns a dictionary of arguments:: <argument-list name="myargs"> <variable name="myvar">myvalue</variable> <list name="mylist"> <list-item>foo</list-item> <list-item>bar</list-item> </list> </argument-list> @typ...
625941d301c39578d7e75011
def set_identity(self, identity): <NEW_LINE> <INDENT> self.identity = identity <NEW_LINE> if identity and identity != self.notified_identity: <NEW_LINE> <INDENT> log.info("m2m identity changed (%s)", identity.decode("utf-8", "replace")) <NEW_LINE> self.notified_identity = self.client.set_m2m_identity(identity)
Set the m2m identity, and also notifies the dataplicity server if required.
625941d37c178a314d6ef637
def load_failed(self): <NEW_LINE> <INDENT> return self.data == None
Expose the state of the load.
625941d3796e427e537b079c
def _init_dapp(parser: ArgumentParser) -> None: <NEW_LINE> <INDENT> group_dapp = parser.add_argument_group("Dapp options") <NEW_LINE> group_dapp.add_argument( "--dapp-ignore-compile", help="Do not run dapp build", action="store_true", dest="dapp_ignore_compile", default=DEFAULTS_FLAG_IN_CONFIG["dapp_ignore_compile"], )
Init dapp arguments Args: parser (ArgumentParser): argparser where the cli flags are added
625941d363b5f9789fde72bb
def add_member(self,list_id,data={}): <NEW_LINE> <INDENT> path = "lists/{}/members/".format(list_id) <NEW_LINE> json_respose = self._post_request(path,data) <NEW_LINE> return json_respose
add_member adds a new contact to a mailchimp list
625941d366656f66f7cbc382
def test_string_repr_AceCard(self): <NEW_LINE> <INDENT> a = AceCard(1, 'Spades') <NEW_LINE> self.assertEqual('A of Spades', repr(a))
AceCard should have correct string repr
625941d332920d7e50b283a7
def employee_list(): <NEW_LINE> <INDENT> cur = QuickReportSettings().db.cursor() <NEW_LINE> cur.execute('SELECT ReportsTo FROM Employee WHERE EmployeeId=?;', (QuickReportSettings().current_user,)) <NEW_LINE> a = cur.fetchall()[0][0] <NEW_LINE> return a in (None, 1)
abilita solo se l'utente e' il gran capo o i suoi diretti sottoposti.
625941d3cb5e8a47e48b7c7e
def parse_arguments(self, args=sys.argv[1:]): <NEW_LINE> <INDENT> parser = argparse.ArgumentParser( description='Zuul Project Gating System Cloner.') <NEW_LINE> parser.add_argument('-m', '--map', dest='clone_map_file', help='specifiy clone map file') <NEW_LINE> parser.add_argument('--workspace', dest='workspace', defau...
Parse command line arguments and returns argparse structure
625941d3377c676e9127237e
def proj_error(proj, p, R, angle = 0): <NEW_LINE> <INDENT> (px, py) = proj(p[1], p[0]) <NEW_LINE> random_p = earth.point_on_earth(p[0], p[1], float(R) / 1000, angle) <NEW_LINE> (rx, ry) = proj(random_p[1], random_p[0]) <NEW_LINE> return math.hypot(px - rx, py - ry) - R
Error in the projected plane due to projection used. The error is calculated measuring a distance @R from point @p @R distance in m on sphere @angle is the angle for maximum distortion for the projection
625941d3a219f33f34628b3d
def getDictEightSeedRankperTourney(matches): <NEW_LINE> <INDENT> MAX_SEED = 32 <NEW_LINE> tgroup = matches.groupby('tourney_id') <NEW_LINE> rankdict = {} <NEW_LINE> rankdict['id'] = {} <NEW_LINE> rankdict['altid'] = {} <NEW_LINE> for tid, t in tgroup: <NEW_LINE> <INDENT> found = False <NEW_LINE> for n in range(MAX_SEED...
util function which returns a dictionary containing ranks of 8 seeds per tournament
625941d34c3428357757c4fd
def __init__(self, connection, backup_file, backup_type=None, **kwargs): <NEW_LINE> <INDENT> Request.__init__(self, connection, 'backup', **kwargs) <NEW_LINE> self.add_property(self.set_backup_file, 'backup_file', backup_file, 'file') <NEW_LINE> self.add_property(self.set_backup_type, 'backup_type', backup_type, 'type'...
Args: backup_file -- String with full path of the backup archive to be created. File name must end with '.tar.gz'. See Request.__init__(). Keyword args: backup_type -- Backup type string, can be ether 'full' or 'incremental'. Default is 'incremental' if posible. See Request.__init...
625941d329b78933be1e587f
def fullJustify(self, words, maxWidth): <NEW_LINE> <INDENT> def addSpace(i, n, spaceNum): <NEW_LINE> <INDENT> if i < n: <NEW_LINE> <INDENT> return (spaceNum // n + int(i < spaceNum % n)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> <DEDENT> def connect(begin, end, lineLength): <NEW_LINE> <...
:type words: List[str] :type maxWidth: int :rtype: List[str]
625941d3956e5f7376d71042
def _repr_type(self) -> str: <NEW_LINE> <INDENT> return "Conversion"
Return the type of this map (a conversion), for the purposes of printing out self. EXAMPLES:: sage: K.<x> = FunctionField(QQ) sage: QQ.convert_map_from(K) # indirect doctest Conversion map: From: Rational function field in x over Rational Field To: Rational Field
625941d34e696a04525c9621
@utils.arg('id', metavar='<FLAVOR_ID>', help='ID of flavor to make private') <NEW_LINE> def do_flavor_private(client, args): <NEW_LINE> <INDENT> flavor = client.flavors.perform_action(args.id, 'private') <NEW_LINE> utils.print_dict(flavor)
Make a flavor private
625941d324f1403a92600d3b
def __onCalltipTimer(self): <NEW_LINE> <INDENT> if self.__calltip: <NEW_LINE> <INDENT> if self.absCursorPosition < self.__callPosition: <NEW_LINE> <INDENT> self.__resetCalltip() <NEW_LINE> return <NEW_LINE> <DEDENT> QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) <NEW_LINE> signatures = getCallSignatures(self, s...
Handles the calltip update timer
625941d371ff763f4b549863
def test_links_in_table_cells(self): <NEW_LINE> <INDENT> with self.settings(**TEST_SETTINGS): <NEW_LINE> <INDENT> self.selenium.get(self.live_server_url) <NEW_LINE> time.sleep(3) <NEW_LINE> self.assertNotIn( reverse('help_page'), self.selenium.current_url) <NEW_LINE> link = self.selenium.find_element_by_xpath( "//div[@...
1. Go to search page 2. Find link added by study resolver 3. Click on links 4. Check that page changed to help page (srudy_resolver function upper)
625941d3090684286d50eebc