code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def __init__(self, elgato: Elgato, info: Info, settings: Settings) -> None: <NEW_LINE> <INDENT> self._info = info <NEW_LINE> self._settings = settings <NEW_LINE> self._state: State | None = None <NEW_LINE> self.elgato = elgato <NEW_LINE> min_mired = 143 <NEW_LINE> max_mired = 344 <NEW_LINE> supported_color_modes = {COL...
Initialize Elgato Light.
625941e1e8904600ed9f22e2
def get(self, url): <NEW_LINE> <INDENT> get_url = self.api + url <NEW_LINE> logging.debug(get_url) <NEW_LINE> resp = self.session.get(get_url, verify=self.verify_ssl) <NEW_LINE> logging.debug(resp) <NEW_LINE> logging.debug(resp.text) <NEW_LINE> return resp
Perform a REST GET call to the Nexus switch. :param url: String containing the URL that will be used to send the object data to the Switch. :returns: Response class instance from the requests library. response.ok is True if request is sent successfully. response.json() will return the JSON data se...
625941e1956e5f7376d7121c
def __repr__(self): <NEW_LINE> <INDENT> return "<%s.%s: id %s> @ %s" % (self.__class__.__module__, self.__class__.__name__, self._model_unique_id, self._cb.session.server)
Return a representation of this object as a string. Returns: str: A representation of this object as a string.
625941e185dfad0860c3b20b
def get_starting_SVD_guess(self): <NEW_LINE> <INDENT> print("\n\nCalculating intial affine transformations:") <NEW_LINE> print("\n\nM = affine transformation for best fit of mol cxn -> rod cxn:") <NEW_LINE> for i in range(len(self.cxns)): <NEW_LINE> <INDENT> print("\nMol1 -> Rod cxn: %d" % (i)) <NEW_LINE> a = self.mol....
Get the affine transformation matrix that best matches the moelcules cxns to each rod cxn by SVD We do a Euclidean (rigid) transform
625941e126068e7796caf094
def output_dir_action(self): <NEW_LINE> <INDENT> fileDialog = QFileDialog() <NEW_LINE> directory = fileDialog.getExistingDirectory() <NEW_LINE> self.output_directory = str(directory) <NEW_LINE> self.badstrip.label_output.setText(str(directory)) <NEW_LINE> l.info("Changed analysis output file to: " + str(directory))
Changing the output directory file
625941e15fc7496912cc3d2e
def setLineMode(self, extra=b''): <NEW_LINE> <INDENT> self.line_mode = 1 <NEW_LINE> if extra: <NEW_LINE> <INDENT> return self.data_received(extra)
Sets the line-mode of this receiver. If you are calling this from a rawDataReceived callback, you can pass in extra unhandled data, and that data will be parsed for lines. Further data received will be sent to lineReceived rather than rawDataReceived. Do not pass extra data if calling this function from within a lineR...
625941e176d4e153a657eee2
def tokenize(s, ptb_escaping=False, use_single_quotes_only=False, escape_token_internal_parens=False): <NEW_LINE> <INDENT> if DEBUG_GTB_TOKENIZATION: <NEW_LINE> <INDENT> orig = s <NEW_LINE> <DEDENT> s = re.sub(r'^', ' ', s) <NEW_LINE> m = re.match(r'^((?:.+|\n)*?) *(\n*)$', s) <NEW_LINE> assert m, "INTERNAL ERROR on '%...
Tokenizes the given string with a GTB-like tokenization. Input will adjusted by removing surrounding space, if any. Arguments hopefully self-explanatory.
625941e14c3428357757c6d6
def layout_time_set_up(self): <NEW_LINE> <INDENT> self.tableWidget = QtWidgets.QTableWidget() <NEW_LINE> self.tableWidget.setRowCount(4) <NEW_LINE> self.tableWidget.setColumnCount(24) <NEW_LINE> self.tableWidget.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch) <NEW_LINE> self.tableWidget.vertical...
Create the qtable layout
625941e18a43f66fc4b54411
def get_membership(self, id: str = None, filter: str = 'all', org_member_type: bool = False, member: bool = False, member_field: str = None): <NEW_LINE> <INDENT> url_rquest = self.select_id(id=id, string=[f"memberships"]) <NEW_LINE> query = { 'key': self.app_key, 'token': self.token, 'filter': filter, 'orgMemberType': ...
Get information about the memberships users have to the board. future: add activity as optional :param id: The ID of the board :param filter: the filter applied [admins, all, none, normal] :param org_member_type: Shows the type of member to the org the user is. For instance, an org admin will have a orgMemberType of a...
625941e156b00c62f0f14a0c
def _add(self, port, pending=0): <NEW_LINE> <INDENT> from .env import flags <NEW_LINE> if port.failed or port.dependency.failed: <NEW_LINE> <INDENT> self.ports[port].stage_done() <NEW_LINE> return <NEW_LINE> <DEDENT> depends = port.dependency.check(self.stage) <NEW_LINE> self._pending[port] = len(depends) + pending <NE...
Add a ports dependencies and prior stage to be built.
625941e145492302aab5e677
def _expand(self, uri, schema, doc_scope): <NEW_LINE> <INDENT> uri = self._urljoin_cache(self.resolution_scope, uri) <NEW_LINE> schema_scope, frag = urldefrag(uri) <NEW_LINE> ref = schema.pop('$ref', None) <NEW_LINE> if ref: <NEW_LINE> <INDENT> ref = self._urljoin_cache(doc_scope, ref) <NEW_LINE> uri_, schema_ = RefRes...
expand a schema to add properties of all definitions it extends if a URI is given, it will be used to identify the schema in a cache store. If no resolver is given, use a resolver with local schema store, with the URI as referring document. :param schema: schema definition :type schema: dict :param uri: schema uri :ty...
625941e150485f2cf553d14b
def main(): <NEW_LINE> <INDENT> con = MySQLdb.connect('servcinf-sql', 'fridays', 'fridays', 'cinfdata', charset='utf8', use_unicode=False) <NEW_LINE> cursor = con.cursor() <NEW_LINE> print('\n========= Users ========') <NEW_LINE> cursor.execute('select name from fridays_user') <NEW_LINE> users = cursor.fetchall() <NEW_...
Run the decoding steps
625941e129b78933be1e5a58
def __init__(self, in_file, bug_handler, copy=None, run_level=1): <NEW_LINE> <INDENT> self.__file = in_file <NEW_LINE> self.__bug_handler = bug_handler <NEW_LINE> self.__copy = copy <NEW_LINE> self.__run_level = run_level <NEW_LINE> self.__write_to = better_mktemp()
Required: 'file'--file to parse Optional: 'copy'-- whether to make a copy of result for debugging 'temp_dir' --where to output temporary results (default is directory from which the script is run.) Returns: nothing
625941e1627d3e7fe0d69202
def parse_buckets(self, bucket, params): <NEW_LINE> <INDENT> bucket['name'] = bucket.pop('Name') <NEW_LINE> api_client = params['api_clients']['us-east-1'] <NEW_LINE> bucket['CreationDate'] = str(bucket['CreationDate']) <NEW_LINE> bucket['region'] = get_s3_bucket_location(api_client, bucket['name']) <NEW_LINE> if bucke...
Parse a single S3 bucket TODO
625941e123e79379d52ee90f
def CreateSortedArray(size = 100, max_gap = 100, likelihood = 3): <NEW_LINE> <INDENT> from random import randint, choice <NEW_LINE> t1 = clock() <NEW_LINE> arr = [randint(0, max_gap)] + [0]*(size-1) <NEW_LINE> for i in range(1, size): <NEW_LINE> <INDENT> step_size = randint(0, max_gap) <NEW_LINE> arr[i] = arr[i-1] + st...
Creates random sorted array of input size. max_gap is the maximum gap between two consecutive numbers in the array. Also creates random search element which has likelihood:1 chance of being present in the random sorted array. Higher the input likelihood, higher is the probability for random search element to be prese...
625941e14527f215b584c803
def my_r_csv(self,fname,L_name,ID_L_value,*list_name): <NEW_LINE> <INDENT> with open(fname,'rb') as cfile: <NEW_LINE> <INDENT> reader = csv.DictReader(cfile) <NEW_LINE> for row in reader: <NEW_LINE> <INDENT> if row.get(L_name) == ID_L_value: <NEW_LINE> <INDENT> re_list = [] <NEW_LINE> for name in list_name: <NEW_LINE> ...
fname为文件路径和名称,ex:d:\test.csv L_name为文件里唯一id列名,ID_L_value为唯一id值 *list_name为所要获取值的列名
625941e124f1403a92600f13
def compile_project(self, includes={}): <NEW_LINE> <INDENT> self.files = [] <NEW_LINE> for file_object in self.project.get_files(): <NEW_LINE> <INDENT> if os.path.isfile(file_object.path): <NEW_LINE> <INDENT> if file_object.fileType in self.filetypes: <NEW_LINE> <INDENT> self.files.append(file_object) <NEW_LINE> <DEDEN...
This method stages files for compilation as we cannot perform compilation until additional runtime information such as generic assignments and the desired top-level entity are known. Incremental compilation is not supported by Icarus so the cache and library tracking are not used at all.
625941e18e7ae83300e4b37e
def error(self, txt, *args, **kwargs): <NEW_LINE> <INDENT> self._lines.append((-1, txt.replace('\n', ' '))) <NEW_LINE> self._write_to_log("ERROR: " + txt.replace('\n', ' ')) <NEW_LINE> first_word = ('{:<' + str(COL_SPACE) +'}').format('ERROR:') <NEW_LINE> txt = self._format_text(kwargs, first_word, txt) <NEW_LINE> prin...
Write the passed string on the standard error, putting an "ERROR:" string before. Moreover, if the string is too long, the text will be reformatted to be suitable for the console of the user. If you do not want this (for example because you are printing a traceback) you can disable this behaviour with the optional argu...
625941e1b5575c28eb68e3b4
def pan(self, *args): <NEW_LINE> <INDENT> return self.send({'cmd': 'pan', 'args': args})
set/get pan location for current image This is a commmand-style routine, easier to type than the full routine at the expense of some flexibility: - with no arguments, the getter is called to retrieve current values. - with arguments, the setter is called to set current values. Returned results are of type string:...
625941e199fddb7c1c9de740
def rtuniform(n, rmax, m): <NEW_LINE> <INDENT> ri = rmax/float(n) *np.arange(0,n+1) <NEW_LINE> ni = np.concatenate([[1], m* np.arange(1, n+1)]) <NEW_LINE> return rtpairs(ri,ni)
Produces uniform polar coordinates Args: n (int) - number of rings to plot between maximum radius and origin rmax (float) - maximum radius of polar coordinates m (int) - density of points at each radius increases by m each step from origin Returns: tuple: radius of coordinate and list of phases a...
625941e13539df3088e2e6fb
def finish(self): <NEW_LINE> <INDENT> self.content = '\n'.join(self.lines)[::-1] <NEW_LINE> self.lines = None
Builds the string content by joining the lines and reversing them.
625941e1e1aae11d1e74a06b
def test_help(): <NEW_LINE> <INDENT> with inntest.connection() as conn: <NEW_LINE> <INDENT> def check(which): <NEW_LINE> <INDENT> lines=conn.help() <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> line.decode() <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> fail("HELP: %s respo...
inntest.Tests.test_help() Tests the HELP command.
625941e144b2445a33932444
def frown(self, window, center, size): <NEW_LINE> <INDENT> self.head.draw(window) <NEW_LINE> self.rightEye.draw(window) <NEW_LINE> self.leftEye.draw(window) <NEW_LINE> mouthSize = 0.8 * size <NEW_LINE> mouthOff = size / 4.0 <NEW_LINE> p1 = center.clone() <NEW_LINE> p1.move(-mouthSize/2, mouthOff) <NEW_LINE> p2 = center...
Draws a frowning face.
625941e1bf627c535bc13580
def __init__( self, *, logging: Optional["Logging"] = None, hour_metrics: Optional["Metrics"] = None, minute_metrics: Optional["Metrics"] = None, cors: Optional[List["CorsRule"]] = None, default_service_version: Optional[str] = None, delete_retention_policy: Optional["RetentionPolicy"] = None, static_website: Optional[...
:keyword logging: Azure Analytics Logging settings. :paramtype logging: ~azure.storage.blob.models.Logging :keyword hour_metrics: a summary of request statistics grouped by API in hour or minute aggregates for blobs. :paramtype hour_metrics: ~azure.storage.blob.models.Metrics :keyword minute_metrics: a summary of requ...
625941e173bcbd0ca4b2c426
def set_weights(self, W): <NEW_LINE> <INDENT> weight = np.random.randn(self.number_of_Nodes, self.input_Dimensions) <NEW_LINE> if (W.shape == weight.shape): <NEW_LINE> <INDENT> self.weights = W <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return -1
This function sets the weight matrix (Bias is included in the weight matrix). :param W: weight matrix :return: None if the input matrix, w, has the correct shape. If the weight matrix does not have the correct shape, this function should not change the weight matrix and it should return -1.
625941e1d268445f265b521f
def test_outfalls_8_mgd(): <NEW_LINE> <INDENT> sim = Simulation(MODEL_STORAGE_PUMP_MGD) <NEW_LINE> print("\n\n\nOUTFALL\n") <NEW_LINE> outfall = Nodes(sim)["J3"] <NEW_LINE> storage = Nodes(sim)["SU1"] <NEW_LINE> junction = Nodes(sim)["J2"] <NEW_LINE> for ind, step in enumerate(sim): <NEW_LINE> <INDENT> pass <NEW_LINE> ...
pytest pyswmm/tests/test_nodes.py -k `test_outfalls_8_mgd`
625941e1b57a9660fec33c3a
def __iter__(): <NEW_LINE> <INDENT> pass
Return an iteration on the ids
625941e110dbd63aa1bd2f53
def post(self, request, organization, member_id, team_slug): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> om = self._get_member(request, organization, member_id) <NEW_LINE> <DEDENT> except OrganizationMember.DoesNotExist: <NEW_LINE> <INDENT> raise ResourceDoesNotExist <NEW_LINE> <DEDENT> can_admin_team = self._can_admi...
Join or add a member to a team Join, request access to or add a member to a team. If the user is already a member of the team, this will simply return a 204. If the user needs permission to join the team, an access request will be generated and the returned status code will be 202.
625941e1796e427e537b0979
def raw_aux_encode(self, adc1, adc2, adc3, adc4, vbat, temp, baro): <NEW_LINE> <INDENT> return MAVLink_raw_aux_message(adc1, adc2, adc3, adc4, vbat, temp, baro)
adc1 : ADC1 (J405 ADC3, LPC2148 AD0.6) (uint16_t) adc2 : ADC2 (J405 ADC5, LPC2148 AD0.2) (uint16_t) adc3 : ADC3 (J405 ADC6, LPC2148 AD0.1) (uint16_t) adc4 : ADC4 (J405 ADC7, LPC2148 AD1.3) (uint16_t) vbat : Battery ...
625941e126068e7796caf095
def invoice_user_from_bill(*args, **kwargs): <NEW_LINE> <INDENT> invoice_entries = [] <NEW_LINE> associated_billing_accounts = [] <NEW_LINE> for account_charge in kwargs.pop('account_charges', []): <NEW_LINE> <INDENT> associated_billing_accounts.append(account_charge['billing_account']) <NEW_LINE> invoice_entry = gener...
Used when generating an invoice from a spefified list of charges resulting from a BillingAccount payment being charged.
625941e1e64d504609d74bf1
def _updateRoutingTable(self): <NEW_LINE> <INDENT> visited = list() <NEW_LINE> fringe = Queue.Queue() <NEW_LINE> fringe.put(self) <NEW_LINE> visited.append(self) <NEW_LINE> rootPort = dict() <NEW_LINE> "Loop." <NEW_LINE> while not fringe.empty(): <NEW_LINE> <INDENT> router = fringe.get() <NEW_LINE> if router in self.to...
Breadth First Search updating routing table. Since this project's background does not have a cost on each link, that each link costs 1, we can use the special edition of Dijkstra's algorithm - Breadth first search. P.S. We are using a special edition of Uniform cost search, Breadth first search. Special Idea: We ...
625941e167a9b606de4a8268
def get_other_team_wins(): <NEW_LINE> <INDENT> df = get_participants() <NEW_LINE> df2 = get_champs() <NEW_LINE> arraymatrix = np.zeros(690 * 690) <NEW_LINE> for i in range(len(df)): <NEW_LINE> <INDENT> if (df['win'][i] == True): <NEW_LINE> <INDENT> for j in range(min(max(i - 11, 0), len(df)), min(i + 11, len(df)), 1): ...
:return other_team_wins: (numpy.array[int]) 690 * 690 matrix with number of matches between champions in other teams. A(win) VS B(lose)
625941e11f037a2d8b9465ae
@api_method() <NEW_LINE> def get_reply(request, reply_id): <NEW_LINE> <INDENT> r = Post.query.get(reply_id) <NEW_LINE> if r is None or r.is_question: <NEW_LINE> <INDENT> raise NotFound() <NEW_LINE> <DEDENT> return dict(reply=r)
Returns a single reply.
625941e1287bf620b61d3e12
def etl_no_io(self, sc, sc_sql, loaded_inputs={}, jargs=None): <NEW_LINE> <INDENT> self.jargs = jargs or self.jargs <NEW_LINE> self.sc = sc <NEW_LINE> self.sc_sql = sc_sql <NEW_LINE> self.app_name = sc.appName <NEW_LINE> self.logger = logger <NEW_LINE> if self.jargs.job_name != self.app_name: <NEW_LINE> <INDENT> logger...
Function to load inputs (including from live vars) and run transform. No output to disk. Having this code isolated is useful for cases with no I/O possible, like testing.
625941e14428ac0f6e5baba6
def label_smoothing(indices: np.ndarray, num_classes: int, pos_sub: float) -> np.ndarray: <NEW_LINE> <INDENT> onehot_matrix = one_hot(indices, num_classes) <NEW_LINE> invert_matrix = np.negative(onehot_matrix) + 1 <NEW_LINE> neg_add = round(pos_sub / (num_classes - 1), 3) <NEW_LINE> result = (1 - pos_sub) * onehot_matr...
对样本标签进行平滑
625941e18c0ade5d55d3ed6f
def handleAttachmentUpload(self, ob, file): <NEW_LINE> <INDENT> if file != '': <NEW_LINE> <INDENT> if hasattr(file, 'filename'): <NEW_LINE> <INDENT> if file.filename != '': <NEW_LINE> <INDENT> if file.filename.find('\\') != -1: <NEW_LINE> <INDENT> id = file.filename.split('\\')[-1] <NEW_LINE> <DEDENT> else: <NEW_LINE> ...
Handle upload of a file. A B{File} object will be created inside the B{given} object.
625941e121bff66bcd684d00
def present(self, qt_notification: "QWebEngineNotification") -> None: <NEW_LINE> <INDENT> if self._adapter is None: <NEW_LINE> <INDENT> self._init_adapter() <NEW_LINE> assert self._adapter is not None <NEW_LINE> <DEDENT> replaces_id = self._find_replaces_id(qt_notification) <NEW_LINE> qtutils.ensure_valid(qt_notificati...
Show a notification using the configured adapter. Lazily initializes a suitable adapter if none exists yet. This should *not* be directly passed to setNotificationPresenter on PyQtWebEngine < 5.15 because of a bug in the PyQtWebEngine bindings.
625941e1fbf16365ca6f657c
def sendkey(self, args): <NEW_LINE> <INDENT> if not args.category: <NEW_LINE> <INDENT> return (False, ["Please specify seeds type."]) <NEW_LINE> <DEDENT> self.logger.debug(_unicode("ACTIONS: sendkey; args: %s") % _unicode(args)) <NEW_LINE> seeds = self.seedhandler.load_category(args.category, refresh=True) <NEW_LINE> s...
Send selected key(s) to the server
625941e16fece00bbac2daf3
def test_attribute_count(self): <NEW_LINE> <INDENT> real_estate_space = RealEstateSpaceFactory.create() <NEW_LINE> real_estate_space_dict = model_to_dict(real_estate_space) <NEW_LINE> self.assertEqual(len(real_estate_space_dict.keys()), 9)
Test that all attributes of RealEstateSpace server are counted. It will count the primary key and all editable attributes. This test should break if a new attribute is added.
625941e19f2886367277ac3c
def test(model, testloader, criterion, device='cpu', t=None, best_acc=None): <NEW_LINE> <INDENT> model.eval() <NEW_LINE> test_loss = 0 <NEW_LINE> correct = 0 <NEW_LINE> total = 0 <NEW_LINE> with torch.no_grad(): <NEW_LINE> <INDENT> for batch_idx, (inputs, targets) in enumerate(testloader): <NEW_LINE> <INDENT> inputs, t...
Test accuracy and loss of model on a dataloader object. :param model: The model to test. :param testloader: Dataloader object with images to test. :param criterion: The loss function for measuring model loss. :param device: 'cuda' if running on gpu, 'cpu' otherwise :param t: Optional tqdm object for showing progress i...
625941e1a17c0f6771cbe400
def cast_float_2_string(value: Union[Decimal, float], digits: int = 12, decimals: int = 2, comma_seperator: str = ',', remove_trailing_zeros: bool = False, strip: bool = False) -> str: <NEW_LINE> <INDENT> s_value = ('{value:' + str(digits) + '.' + str(decimals) + 'f}').format(value=value) <NEW_LINE> s_value = s_value.r...
decimal --> string >>> assert cast_float_2_string(100000.52) == ' 100000,52' >>> assert cast_float_2_string(-100000.52) == ' -100000,52' >>> assert cast_float_2_string(-100000.52, strip=True) ...
625941e1925a0f43d254a22b
def analyse_sharing_attributes(self, env): <NEW_LINE> <INDENT> for entry, (pos, op) in self.assignments.iteritems(): <NEW_LINE> <INDENT> if self.is_prange and not self.is_parallel: <NEW_LINE> <INDENT> if entry in self.parent.assignments: <NEW_LINE> <INDENT> error(pos, "Cannot assign to private of outer parallel block")...
Analyse the privates for this block and set them in self.privates. This should be called in a post-order fashion during the analyse_expressions phase
625941e101c39578d7e751ec
def prompt_init(): <NEW_LINE> <INDENT> init = House.prompt_init() <NEW_LINE> init.update(Rental.prompt_init()) <NEW_LINE> return init
Creates dictionary which contains details about House and Rental :return: dict
625941e18da39b475bd65329
def _get_plugins(group: str="slyce.plugin"): <NEW_LINE> <INDENT> plugins = {} <NEW_LINE> for ep in pkg_resources.iter_entry_points(group=group): <NEW_LINE> <INDENT> plugins.update({ep.name: ep.load()}) <NEW_LINE> <DEDENT> return plugins
Retrieve the items registered with setuptools entry_points for the given group (defaults to slither.plugin group). TODO: Whitelist/blacklist for plugins
625941e138b623060ff0b19e
def get_gcc_version(compiler_binary): <NEW_LINE> <INDENT> args = [compiler_binary, '-dumpversion'] <NEW_LINE> gcc = Popen(args, stdout=PIPE, stderr=PIPE) <NEW_LINE> stdout, stderr = gcc.communicate() <NEW_LINE> return stdout.split()[0]
Runs gcc and extracts the version string
625941e166656f66f7cbc55e
def get_completion_by_level_id_in_set(self, set_id, level_id_in_set): <NEW_LINE> <INDENT> self.cursor.execute( 'SELECT * FROM {} WHERE set_id = ? AND level_id_in_set = ?'.format(self.TABLE_NAME), (set_id, level_id_in_set) ) <NEW_LINE> self.connection.commit() <NEW_LINE> return self.cursor.fetchall()
Get level completed in set. :param set_id: Id of the set. :param level_id_in_set: Id of the level. :return: Completion by level.
625941e1a79ad161976cc4f6
def findUnsortedSubarray(self, nums): <NEW_LINE> <INDENT> L = len(nums) if nums != None else 0 <NEW_LINE> if L == 0: return 0 <NEW_LINE> e = 0 <NEW_LINE> s = L <NEW_LINE> i = 0 <NEW_LINE> j = L -1 <NEW_LINE> maxOnLeft = nums[i] <NEW_LINE> minOnRight = nums[j] <NEW_LINE> while i < L: <NEW_LINE> <INDENT> if nums[i] > max...
:type nums: List[int] :rtype: int
625941e17d847024c06be670
def hdmi_boost_custom_default(): <NEW_LINE> <INDENT> return '2'
Tests the users system to see which hdmi_boost figure should be used.
625941e1a79ad161976cc4f7
@utils.arg('id', metavar='<ID>', help='ID or name of baremetal') <NEW_LINE> def do_baremetal_delete(client, args): <NEW_LINE> <INDENT> baremetal = client.baremetals.delete(args.id) <NEW_LINE> utils.print_dict(baremetal)
Delete a baremetal
625941e12ae34c7f2600d4e2
def replace_uncommon_words(self, docarrays, vocabulary): <NEW_LINE> <INDENT> logger.info("Replacing missing words with *..") <NEW_LINE> starind = len(vocabulary) <NEW_LINE> for d in docarrays: <NEW_LINE> <INDENT> for di in range(len(d)): <NEW_LINE> <INDENT> if d[di]==-1: <NEW_LINE> <INDENT> d[di] = starind <NEW_LINE> <...
Replaces uncommon words (words that appear in fewer than [replace_uncommon] documents) with a "*" and returns the modified vocabulary along with the modified document arrays.
625941e1ad47b63b2c50a330
def DecodeByte(self, name, byte): <NEW_LINE> <INDENT> self.sensors[name] = struct.unpack('b', byte)[0]
Map signed 'byte' to 'name'.
625941e1099cdd3c635f100b
def climbStairs(self, n): <NEW_LINE> <INDENT> dp = [0] * n <NEW_LINE> dp[0] = 1 <NEW_LINE> if n > 1: dp[1] = 2 <NEW_LINE> for i in range(2,n): <NEW_LINE> <INDENT> dp[i] = dp[i-1] + dp[i-2] <NEW_LINE> <DEDENT> return dp[n-1]
:type n: int :rtype: int
625941e17d847024c06be671
def __init__(self, address=None, payload=None, sources=None, **kwargs): <NEW_LINE> <INDENT> payload = payload or Payload() <NEW_LINE> payload.add_field('sources', self.create_sources_field(sources, address.spec_path, key_arg='sources')) <NEW_LINE> super().__init__(payload=payload, address=address, **kwargs)
:param sources: thrift source files :type sources: :class:`pants.source.wrapped_globs.FilesetWithSpec` or list of strings. Paths are relative to the BUILD file's directory. :param import_path: Deprecated: unused.
625941e1cb5e8a47e48b7e56
def _daili66(self,page_count=5): <NEW_LINE> <INDENT> start_url = 'http://www.66ip.cn/{}.html' <NEW_LINE> urls = [start_url.format(page) for page in range(1, page_count + 1)] <NEW_LINE> for url in urls: <NEW_LINE> <INDENT> html = get_page(url) <NEW_LINE> soup = BeautifulSoup(html, 'lxml') <NEW_LINE> trs = soup.select('....
获取66ip代理 :param page_count:页码 :return: 代理
625941e1dd821e528d63b557
def get_index(x, list_of_x): <NEW_LINE> <INDENT> for index, name in enumerate(list_of_x): <NEW_LINE> <INDENT> if x == name: <NEW_LINE> <INDENT> return index
Function to get the index of x (str) from list of x (list). :param x: :param list_of_x: :return: index (int)
625941e1d7e4931a7ee9e2d0
@pytest.fixture(autouse=True) <NEW_LINE> def reset_file_config(request, monkeypatch): <NEW_LINE> <INDENT> def fin(): <NEW_LINE> <INDENT> ceph_medic.config.file = ceph_medic.UnloadedConfig() <NEW_LINE> <DEDENT> request.addfinalizer(fin)
The globally available ``ceph_medic.config.file`` might get mangled in tests, make sure that after evert test, it gets reset, preventing pollution going into other tests later.
625941e123849d37ff7b343e
def get_relative_error(self, avg, target): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> x = avg - target <NEW_LINE> return round((x/target)*100,2) <NEW_LINE> <DEDENT> except ZeroDivisionError: <NEW_LINE> <INDENT> return None
compute bias
625941e14e4d5625662d4784
def test_pagination(self, rest_api): <NEW_LINE> <INDENT> old_cves = [] <NEW_LINE> name, num = CVES_PAGE <NEW_LINE> pages = ceil(num / PAGE_SIZE) <NEW_LINE> for i in range(1, pages + 1): <NEW_LINE> <INDENT> request_body = tools.gen_cves_body( cves=[name], page=i, page_size=PAGE_SIZE) <NEW_LINE> cves = rest_api.get_cves(...
Tests CVEs pagination using POST.
625941e14e4d5625662d4785
def test_put_Data(self): <NEW_LINE> <INDENT> obj = Collector.get(self.uuid) <NEW_LINE> serializer_data2 = json.loads(json.dumps(self.data2)) <NEW_LINE> serializer = CollectorSerializer(obj, data=serializer_data2[0], partial=True, context={'pk': self.uuid}) <NEW_LINE> serializer.update(obj, serializer_data2[0]) <NEW_LIN...
test case to test update function with valid data
625941e1dd821e528d63b558
def vector_length(v): <NEW_LINE> <INDENT> return math.sqrt(vector_length2(v))
Returns the length of a vector
625941e144b2445a33932445
def _combine_thread_pipeline_steps(in_queue, need_converter, pipeline_steps, counter, options): <NEW_LINE> <INDENT> threads = [] <NEW_LINE> assert hasattr(in_queue, 'closed'), "The in-queue needs a 'closed' attribute!" <NEW_LINE> out_queue = in_queue <NEW_LINE> pipeline_steps = tuple(pipeline_steps) <NEW_LINE> i...
Construct the steps and connect them via queues
625941e10383005118ecf993
def parse_args(parser): <NEW_LINE> <INDENT> args = vars(parser.parse_args()) <NEW_LINE> options = { "run": RunMode(args["mode"]), "verbose": args["verbose"], "tor": args["tor"], "path": args["path"] } <NEW_LINE> if options["path"] is None and options["run"] in DEFAULT_PATHS: <NEW_LINE> <INDENT> options["path"] = DEFAUL...
:param parser: ArgumentParser Object that holds cmd arguments. :return: tuple Values of arguments.
625941e15e10d32532c5f2d7
def test_perform_action_too_few_arguments(self): <NEW_LINE> <INDENT> dsp_ap = self.wrap_subject(display.DisplayAction, "perform_action") <NEW_LINE> fake_options = self.m.CreateMock(optparse.Values) <NEW_LINE> fake_config = self.m.CreateMock(configparser.SafeConfigParser) <NEW_LINE> self.m.ReplayAll() <NEW_LINE> self.as...
U Display: perform_action without any argument displays an error.
625941e156ac1b37e626457a
def remove_environment_variable(self, *names): <NEW_LINE> <INDENT> for name in names: <NEW_LINE> <INDENT> value = del_env_var(name) <NEW_LINE> if value: <NEW_LINE> <INDENT> self._info("Environment variable '%s' deleted." % name) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._info("Environment variable '%s' does no...
Deletes the specified environment variable. Does nothing if the environment variable is not set. Starting from Robot Framework 2.7, it is possible to remove multiple variables by passing them to this keyword as separate arguments.
625941e1eab8aa0e5d26df0b
def find_all(self, params={}, **options): <NEW_LINE> <INDENT> return self.client.get_collection("/tags", params, **options)
Returns the compact tag records for some filtered set of tags. Use one or more of the parameters provided to filter the tags returned. Parameters ---------- [params] : {Object} Parameters for the request - [workspace] : {Id} The workspace or organization to filter tags on. - [team] : {Id} The team to filter tags o...
625941e1d4950a0f3b08c6fb
def titleToNumber(self, s): <NEW_LINE> <INDENT> res = 0 <NEW_LINE> for c in s: <NEW_LINE> <INDENT> d = ord(c) - ord('A') + 1 <NEW_LINE> res = res * 26 + d <NEW_LINE> <DEDENT> return res
:type s: str :rtype: int
625941e1d99f1b3c44c6793a
def test_delete_quote(self): <NEW_LINE> <INDENT> pass
Test case for delete_quote Delete quote # noqa: E501
625941e107d97122c4178c45
def test_limits(self): <NEW_LINE> <INDENT> points = 1000 <NEW_LINE> scale = math.pi * 2.0 / points <NEW_LINE> data1 = [math.sin(x*scale) for x in range(points)] <NEW_LINE> data2 = [math.cos(x*scale) for x in range(points)] <NEW_LINE> data3 = [2*math.sin(2*x*scale) for x in range(points)] <NEW_LINE> gdd = Diagram('Test ...
Check line graphs.
625941e1ac7a0e7691ed4477
def test_filter_none_function(self): <NEW_LINE> <INDENT> self.assertEqual(__, list(filter(None, [True, False, True, False])))
If function is None, the identity function is assumed. That is, all elements of iterable that are false are removed. ie. list.remove(x) if not x
625941e1293b9510aa2c3644
def update(remote_sources = urls): <NEW_LINE> <INDENT> hosts = Hosts(path=tmp_hosts) <NEW_LINE> for remote_source in remote_sources: <NEW_LINE> <INDENT> print(remote_source['url']) <NEW_LINE> hosts.import_url(url = remote_source['url'], single_format = remote_source['single_format'], sanitize = sanitize) <NEW_LINE> <DE...
Main update function - takes a list of remote source URLs, writes all available hosts and returns 0.
625941e110dbd63aa1bd2f54
def test_sections_clear(self): <NEW_LINE> <INDENT> class T: <NEW_LINE> <INDENT> SECTION_1 = None <NEW_LINE> SECTION_2 = None <NEW_LINE> SECTION_3 = None <NEW_LINE> SECTION_4 = None <NEW_LINE> SECTION_5 = None <NEW_LINE> <DEDENT> t = estimate.Theme(obj = T) <NEW_LINE> x = object() <NEW_LINE> self.assertIs( t.format(t.F_...
Test section color clears
625941e163f4b57ef00014c0
@app.teardown_request <NEW_LINE> def close_db(error): <NEW_LINE> <INDENT> if hasattr(g, 'db'): <NEW_LINE> <INDENT> g.db.close()
Zamykanie połączenia z bazą
625941e1460517430c39452e
def agglomerative_cluster_occurrences(X_data, thresh_sec): <NEW_LINE> <INDENT> label_arr = scipy.cluster.hierarchy.fclusterdata( X_data, thresh_sec, criterion='distance') <NEW_LINE> return label_arr
Agglomerative occurrence clustering algorithm Args: X_data (ndarray): Length N array of data to cluster thresh_sec (float): Returns: ndarray: (label_arr) - Length N array of cluster indexes CommandLine: python -m ibeis.algo.preproc.preproc_occurrence --exec-agglomerative_cluster_occurrences Referen...
625941e13317a56b8693a001
def __init__(self, benchmark_name, params, all_params): <NEW_LINE> <INDENT> for key in six.iterkeys(all_params): <NEW_LINE> <INDENT> if key not in params: <NEW_LINE> <INDENT> params[key] = None <NEW_LINE> <DEDENT> <DEDENT> self.benchmark_name = benchmark_name <NEW_LINE> self.params = params <NEW_LINE> self.data_points ...
Initially the graph contains no data. It must be added using multiple calls to `add_data_point`. Parameters ---------- benchmark_name : str A unique string to identify the benchmark, and display in the frontend. params : dict of str -> str A dictionary of parameters describing the benchmark. all_params ...
625941e1046cf37aa974d0f6
def chunks(n, iterable): <NEW_LINE> <INDENT> if not isinstance(iterable, GeneratorType): <NEW_LINE> <INDENT> for i in range(0, len(iterable), n): <NEW_LINE> <INDENT> yield iterable[i:i + n] <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> i = 0 <NEW_LINE> ans = list() <NEW_LINE> for x in iterable: <NEW_LINE> <IND...
chunks(n:int, iter:iterable) yield every successive n-sized chunks from l. args: n = 3, iter = [1,2,3,4,5,6,7] return: Lazyed!! return type is generator [1,2,3].. [4,5,6] .. [7]
625941e123849d37ff7b343f
def populate_graph(self): <NEW_LINE> <INDENT> if self.edges and self.vertices: <NEW_LINE> <INDENT> graph = Graph() <NEW_LINE> for edge in self.edges: <NEW_LINE> <INDENT> graph.add_edge(edge) <NEW_LINE> <DEDENT> self.graph = graph <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print("Populate edges & vertices first, then...
Populate the graph, using a list of Edges.
625941e1b7558d58953c52bf
def __unicode__(self): <NEW_LINE> <INDENT> return self.name
Human readable version of this object.
625941e196565a6dacc8fa7c
def GetAllModsByNamespace () -> typing.Dict[str, Mod]: <NEW_LINE> <INDENT> return dict(_allMods)
Get all mods listed in a dictionary by their namespaces
625941e18e05c05ec3eea729
def parse_tokens(self, tokens): <NEW_LINE> <INDENT> parse_str = "" <NEW_LINE> last_type = '' <NEW_LINE> modifier = '' <NEW_LINE> num_args = 0 <NEW_LINE> cls = [1] <NEW_LINE> i = 0 <NEW_LINE> tokens_len = len(tokens) <NEW_LINE> while i < tokens_len: <NEW_LINE> <INDENT> token = tokens[i] <NEW_LINE> if token == '_arg': <N...
Convert each token or token pair to its Excel 'ptg' equivalent.
625941e130c21e258bdfa852
def alert_consultant(context): <NEW_LINE> <INDENT> close_old_connections() <NEW_LINE> if outside_business_hours(): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> consultants = Consultant.objects.exclude(telegram_id=None).filter(active=True) <NEW_LINE> if not consultants: <NEW_LINE> <INDENT> logger.warning("No consultan...
Randomly alert consultant about important stuff to do
625941e1cdde0d52a9e533e7
def _default_wn(xloc, ylim): <NEW_LINE> <INDENT> wn = xloc <NEW_LINE> sep = xloc[1]-xloc[0] <NEW_LINE> while np.abs(wn[0]) < ylim[1]: <NEW_LINE> <INDENT> wn = np.insert(wn, 0, wn[0]-sep) <NEW_LINE> <DEDENT> while len(wn) > 7: <NEW_LINE> <INDENT> wn = wn[0:-1:2] <NEW_LINE> <DEDENT> return wn
Return default wn for root locus plot
625941e13eb6a72ae02ec898
def write_avahi_headers(tfo): <NEW_LINE> <INDENT> tfo.write("<?xml version=\"1.0\" standalone='no'?>\n") <NEW_LINE> tfo.write('<!DOCTYPE service-group SYSTEM "avahi-service.dtd">\n') <NEW_LINE> tfo.write("<service-group>\n") <NEW_LINE> tfo.write(' <name replace-wildcards="yes">%h</name>\n')
Simply write the headers for an avahi static service file. :param tfo: :return:
625941e121bff66bcd684d01
@pytest.mark.parametrize('argument', SPECIAL_ARGUMENT_NAMES_WHITELIST) <NEW_LINE> @pytest.mark.parametrize('code', [ correct_method_template, correct_classmethod_template, correct_function_template, ]) <NEW_LINE> def test_correct_argument_name( assert_errors, parse_ast_tree, default_options, code, mode, argument, ): <N...
Ensures that special names for arguments are restricted.
625941e1956e5f7376d7121e
def _load_config(self): <NEW_LINE> <INDENT> self.slice = self.config["core"]["slice"] <NEW_LINE> self.user = self.config["core"]["user"] <NEW_LINE> self._nodedir = self._to_absolute(self.config["core"]["nodes_dir"]) <NEW_LINE> self._datadir = self._to_absolute(self.config["core"]["data_dir"]) <NEW_LINE> self._logdir ...
Load configuration
625941e1a4f1c619b28b03e3
def _append(self, dcm): <NEW_LINE> <INDENT> self._datasets.append(dcm)
_append(dcm) Append a dicomfile (as a dicom.dataset.FileDataset) to the series.
625941e1be383301e01b5831
def get_time_end(self): <NEW_LINE> <INDENT> return self.time_end
Get the end time step for this ride.
625941e14c3428357757c6d8
def RiExposure(gain, gamma): <NEW_LINE> <INDENT> _ribout.write("Exposure %s %s\n"%(gain, gamma))
Sets the parameters for the output color transformation. The transformation is color_out = (color_in*gain)^(1/gamma) Example: RiExposure(1.3, 2.2)
625941e1d18da76e2353288c
def serialize(self, buff): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> buff.write(_struct_b.pack(self.type)) <NEW_LINE> _x = self.val <NEW_LINE> length = len(_x) <NEW_LINE> if python3 or type(_x) == unicode: <NEW_LINE> <INDENT> _x = _x.encode('utf-8') <NEW_LINE> length = len(_x) <NEW_LINE> <DEDENT> if python3: <NEW_LI...
serialize message into buffer :param buff: buffer, ``StringIO``
625941e115baa723493c432a
def get_playlists_for_channel(id): <NEW_LINE> <INDENT> param = {'key': cget(cSec, 'Key'), 'part': 'id, snippet', 'channelId': id} <NEW_LINE> response = requests.get(cget(cSec, 'PlaylistAccess'), params=param) <NEW_LINE> return json.loads(response.text)['items']
Returns all playlists of a given channel id
625941e132920d7e50b28585
def read(self): <NEW_LINE> <INDENT> return self.widget.selectedColor().getRgbF()
Get selected color
625941e194891a1f4081be5d
def send_mail(self, smtp_server="smtp.gmail.com", port=587): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.msg.attach(MIMEText(self.body, 'plain')) <NEW_LINE> text = self.msg.as_string() <NEW_LINE> server = smtplib.SMTP(smtp_server, port) <NEW_LINE> server.starttls() <NEW_LINE> server.login(self.credentials["email"...
Sends the mail built :param smtp_server: (optional, smtp.gmail.com by default) the smtp server to send the mail :type smtp_server: str :param port: (optional, 587 by default) the server ports :type port: int :return: if the mail has been sent :rtype: bool
625941e1ff9c53063f47c5a4
def submit_feed(self, feed, feed_type, marketplaceids=None, content_type="text/xml", purge='false'): <NEW_LINE> <INDENT> data = { 'Action': 'SubmitFeed', 'FeedType': feed_type, 'PurgeAndReplace': purge, } <NEW_LINE> data.update(utils.enumerate_param('MarketplaceIdList.Id.', marketplaceids)) <NEW_LINE> md5_hash = utils....
Uploads a feed for processing by Amazon MWS. `feed` should contain a file object in XML or flat-file format. Docs: http://docs.developer.amazonservices.com/en_US/feeds/Feeds_SubmitFeed.html
625941e1498bea3a759b9e61
def row_writer(row): <NEW_LINE> <INDENT> with open(FILEPATH, 'a') as csv_file: <NEW_LINE> <INDENT> rowWriter = csv.DictWriter(csv_file, fieldnames=FIELDNAMES) <NEW_LINE> rowWriter.writerow({ 'date': row[0], 'high_temp_ºF': row[1], 'ave_temp_ºF': row[2], 'low_temp_ºF': row[3], 'high_dew_pt_ºF': row[4], 'ave_dew_pt_ºF': ...
Writes each row of data to the csv.
625941e155399d3f05588a68
def bofh(): <NEW_LINE> <INDENT> return " ".join([w.capitalize() for w in _bofh()])
Generate a random BOFH excuse and format it for display
625941e199fddb7c1c9de741
def max_move(board, player): <NEW_LINE> <INDENT> best_score = 0 <NEW_LINE> best_pos = (-1, -1) <NEW_LINE> empty_squares = board.get_empty_squares() <NEW_LINE> for position in empty_squares: <NEW_LINE> <INDENT> cur_board = board.clone() <NEW_LINE> row, col = position <NEW_LINE> cur_board.move(row, col, player) <NEW_LINE...
To simulate PLAYERX's action in this game. Select the position with maximal score.
625941e123e79379d52ee911
def _createmap_for_one_family(self, family): <NEW_LINE> <INDENT> dbstate = self.dbstate <NEW_LINE> self.message_layer.add_message( _("Family places for %s") % self.family_label(family)) <NEW_LINE> person = None <NEW_LINE> if family: <NEW_LINE> <INDENT> person = dbstate.db.get_person_from_handle( family.get_father_handl...
Create all markers for one family : all event's places with a lat/lon.
625941e124f1403a92600f15
def _file_csv(obj, path, delimiter=',', auto=False): <NEW_LINE> <INDENT> with open(path, 'w', newline='', encoding='utf-8') as stream: <NEW_LINE> <INDENT> writer = csv.writer(stream, delimiter=delimiter) <NEW_LINE> for row in _tabulate(obj, auto=auto): <NEW_LINE> <INDENT> writer.writerow(row) <NEW_LINE> <DEDENT> <DEDEN...
Create a CSV file at the given path. :param obj: Item, list of Items, or Document to export :param path: location to export CSV file :param delimiter: character to delimit fields :param auto: include placeholders for new items on import :return: path of created file
625941e1b5575c28eb68e3b6
def test_swap_dequantize_all_ops(self): <NEW_LINE> <INDENT> class M(torch.nn.Module): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> super(M, self).__init__() <NEW_LINE> self.maxpool = torch.nn.MaxPool2d(kernel_size=3) <NEW_LINE> self.adaptive_avgpool = torch.nn.AdaptiveAvgPool2d((1, 1)) <NEW_LINE> self.dr...
A test that checks dequantize will be swapped for all supported general ops without actually checking for execution of these ops
625941e13346ee7daa2b3121
def sql_select(self, col_ref_fn, xs: CDXState): <NEW_LINE> <INDENT> for dcd in self.dependency_cds: <NEW_LINE> <INDENT> dcd.sql_select(col_ref_fn, xs.sfx(self, dcd))
Call col_ref_fn(col_desc) for every SQL column accessed to display this column
625941e171ff763f4b549a44
def test_register_array_shape_and_dtype(self): <NEW_LINE> <INDENT> slvr_cfg = SolverConfiguration(na=3, ntime=10, nchan=32, sources=montblanc.sources(point=10, gaussian=10)) <NEW_LINE> with montblanc.factory.get_base_solver(slvr_cfg) as slvr: <NEW_LINE> <INDENT> name='uvw' <NEW_LINE> gpu_name = mbu.gpu_name(name) <NEW_...
Test array registration requiring shape and dtype attributes to be created
625941e1c4546d3d9de72dea