code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def setPluginOption(self, name,status): <NEW_LINE> <INDENT> if self.FSettings.Settings.get_setting('accesspoint','statusAP',format=bool): <NEW_LINE> <INDENT> self.reactor.ThreadPumpkinProxy.m.disablePlugin(name, status) <NEW_LINE> <DEDENT> self.config.set_setting('plugins',name,status)
get each plugins status
625941eb627d3e7fe0d6933c
def test_negativeHostsCount(self): <NEW_LINE> <INDENT> exc = self.assertRaises( UsageError, self.options.parseOptions, ["--host-index=1", "--hosts-count=-1", "foo"]) <NEW_LINE> self.assertEquals( str(exc), "Specify a positive integer for hosts-count")
If a negative value is provided for I{--hosts-count}, a L{UsageError} is raised.
625941ebcdde0d52a9e53521
def test_signature_string_verification(self): <NEW_LINE> <INDENT> key = self.generate_key("Bruce Schneier", "schneier.com") <NEW_LINE> message = '...the government uses the general fear of ' <NEW_LINE> message += '[hackers in popular culture] to push for more power' <NEW_LINE> sig = self.gpg.sign(message, default_key=...
Test verification of a signature from a message string.
625941eb4c3428357757c80f
def print_mat(): <NEW_LINE> <INDENT> proj_setting.log+=tabulate(proj_setting.mat,tablefmt="grid") <NEW_LINE> proj_setting.log+='\n' <NEW_LINE> print("Matrix Computed")
writes the matrix to the log file
625941eb498bea3a759b9f98
def __init__(self): <NEW_LINE> <INDENT> self.DomainName = None <NEW_LINE> self.AppName = None <NEW_LINE> self.StreamName = None
:param DomainName: 推流域名。 域名+AppName+StreamName唯一标识单个转码规则,如需删除需要强匹配,例如AppName为空也需要传空字符串进行强匹配。 :type DomainName: str :param AppName: 推流路径,与推流和播放地址中的AppName保持一致,默认为 live。 域名+AppName+StreamName唯一标识单个转码规则,如需删除需要强匹配,例如AppName为空也需要传空字符串进行强匹配。 :type AppName: str :param StreamName: 流名称。 域...
625941ebd7e4931a7ee9e40a
def do_shutdown(self, arg): <NEW_LINE> <INDENT> self.__checkConnection() <NEW_LINE> self.__checkArg(arg, "<=1") <NEW_LINE> if arg == "abort": <NEW_LINE> <INDENT> self.db.shutdown("abort") <NEW_LINE> <DEDENT> elif arg == "immediate": <NEW_LINE> <INDENT> self.db.shutdown("immediate") <NEW_LINE> <DEDENT> else: <NEW_LINE> ...
Shuts database down (Oracle v10R2 or upper required)
625941eb004d5f362079a81a
def _split_list(s, predicate): <NEW_LINE> <INDENT> yes = [] <NEW_LINE> no = [] <NEW_LINE> for x in s: <NEW_LINE> <INDENT> if predicate(x): <NEW_LINE> <INDENT> yes.append(x) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> no.append(x) <NEW_LINE> <DEDENT> <DEDENT> return yes, no
Split sequence s via predicate, and return pair ([true], [false]). The return value is a 2-tuple of lists, ([x for x in s if predicate(x)], [x for x in s if not predicate(x)])
625941eb293b9510aa2c377b
@job.route("/getStatusOfAllDeployments", methods=["POST"]) <NEW_LINE> @login_required <NEW_LINE> def get_all_deployments(): <NEW_LINE> <INDENT> statuses = [] <NEW_LINE> for job_id in current_user.jobs: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> res_dict = get_job_status(job_id) <NEW_LINE> <DEDENT> except PermissionDe...
Get job ids **Example request** .. sourcecode:: http POST /getStatusOfAllDeployments HTTP/1.1 { "token": "<token>", } **Example response** .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json { "status": "OK", "jobs": [ { ...
625941eb091ae35668667440
def close(self): <NEW_LINE> <INDENT> self.dFile.close()
Close data file
625941eb63f4b57ef00015f5
def parse_objective_section(self, section_text): <NEW_LINE> <INDENT> return self.__parse_objective_section(section_text)
:rtype: MathExpression
625941eb30bbd722463cc2b3
def pay(self, transactionAmount, senderTokenId, recipientTokenId=None, callerTokenId=None, chargeFeeTo="Recipient", callerReference=None, senderReference=None, recipientReference=None, senderDescription=None, recipientDescription=None, callerDescription=None, metadata=None, transactionDate=None, reserve=False): <NEW_LI...
Make a payment transaction. You must specify the amount. This can also perform a Reserve request if 'reserve' is set to True.
625941eb76e4537e8c351b61
def _ParsePlugin(file_path): <NEW_LINE> <INDENT> with open(file_path, 'r') as f: <NEW_LINE> <INDENT> return json.load(f)
Reads the given file and parses it into an object.
625941eb63b5f9789fde75d1
def read_fastcgi_keyvalue_pairs(content, offset): <NEW_LINE> <INDENT> offset, name_len = read_encoded_int(content, offset) <NEW_LINE> offset, value_len = read_encoded_int(content, offset) <NEW_LINE> name = content[offset:(offset + name_len)] <NEW_LINE> offset += name_len <NEW_LINE> value = content[offset:(offset + valu...
Reads a FastCGI key/value pair stream
625941eb8a43f66fc4b5454a
def leave(self, p): <NEW_LINE> <INDENT> right = self.startMap[p] <NEW_LINE> left = self.endMap[p] <NEW_LINE> merged = (left[0], right[1]) <NEW_LINE> self.removeSeg(left) <NEW_LINE> self.removeSeg(right) <NEW_LINE> self.addSeg(merged)
:type p: int :rtype: None
625941ebec188e330fd5ac7f
def get_brillouin_zone(self): <NEW_LINE> <INDENT> return self.reciprocal_lattice.get_wigner_seitz_cell()
Returns the Wigner-Seitz cell for the reciprocal lattice, aka the Brillouin Zone. Returns: A list of list of coordinates. Each element in the list is a "facet" of the boundary of the Brillouin Zone. For instance, a list of four coordinates will represent a square facet.
625941eb4527f215b584c93c
def parse_chunks(self): <NEW_LINE> <INDENT> result_particles = [] <NEW_LINE> (timestamp, chunk, start, end) = self._chunker.get_next_data_with_index(True) <NEW_LINE> while chunk is not None: <NEW_LINE> <INDENT> particle = self._extract_sample(self._particle_class, ADCPA_PD0_PARSED_MATCHER, chunk, self._timestamp) <NEW_...
@retval a list of tuples with sample particles encountered in this parsing, plus the state. An empty list is returned if nothing was parsed.
625941eb4d74a7450ccd46b0
def retrieve_API_data(date_start, date_end): <NEW_LINE> <INDENT> with conn: <NEW_LINE> <INDENT> with conn.cursor() as cur: <NEW_LINE> <INDENT> query = "SELECT * FROM data_store WHERE (data_date >= %s AND data_date <= %s);" <NEW_LINE> query_data = (date_start, date_end) <NEW_LINE> cur.execute(query, query_data) <NEW_LIN...
This can be used by any user who has an api key Creates a new entry in the db
625941eb0a50d4780f667381
def delete_connection(self, from_block_name, to_block_name): <NEW_LINE> <INDENT> from_idx = self._get_block_idx_by_name(from_block_name) <NEW_LINE> to_idx = self._get_block_idx_by_name(to_block_name) <NEW_LINE> if self._adj_mat[from_idx, to_idx] == 0: <NEW_LINE> <INDENT> msg = "No connection between blocks " <NEW_LINE>...
Delete a connection between two blocks. Parameters ---------- from_block_name: str Name of the 'from'-block. to_block_name: str Name of the 'to'-block.
625941eba79ad161976cc630
def __repr__(self) -> str: <NEW_LINE> <INDENT> buf = StringIO("") <NEW_LINE> if self._info_repr(): <NEW_LINE> <INDENT> self.info(buf=buf) <NEW_LINE> return buf.getvalue() <NEW_LINE> <DEDENT> max_rows = get_option("display.max_rows") <NEW_LINE> min_rows = get_option("display.min_rows") <NEW_LINE> max_cols = get_option("...
Return a string representation for a particular DataFrame.
625941eb66673b3332b9257c
def replace_group(molec_ls, old_groups, new_group=""): <NEW_LINE> <INDENT> if _check.check_ls(ls=molec_ls, nt_flag=True) and _check.check_np_array(arr=molec_ls, nt_flag=True): <NEW_LINE> <INDENT> main_module, main_fn, main_lineno = _check.parent_fn_mod_3step() <NEW_LINE> calling_module, calling_fn, calling_lineno = _ch...
This function replaces a string sequence(s) within a molecule's name string with a new, user-specified group. An example of how this would be used is to remove cluster elements from an ion. For example, if the formula names for time series in a data set are of the form "CxHyOzI", then one can strip "I" from the...
625941eb8e71fb1e9831dc92
def spider_closed(self, spider): <NEW_LINE> <INDENT> total_time = 0 <NEW_LINE> for item in self.job_parsing_histogram.get_recorded_iterator(): <NEW_LINE> <INDENT> total_time += item.count_added_in_this_iter_step * item.value_iterated_to <NEW_LINE> <DEDENT> total_count = self.job_parsing_histogram.get_total_count() <NEW...
Call when a spider quits.
625941eb4428ac0f6e5bace2
def check_box_isselected(self,info,check=None): <NEW_LINE> <INDENT> element = self.get_element(info) <NEW_LINE> if element !=False: <NEW_LINE> <INDENT> flag = element.is_selected() <NEW_LINE> if flag == True: <NEW_LINE> <INDENT> if check != 'check': <NEW_LINE> <INDENT> self.click_element(info) <NEW_LINE> <DEDENT> <DEDE...
判断元素是否选中 如果没选中就选中,如果选中就补选中,根据参数来
625941ebcad5886f8bd274c3
def extract_emails(self): <NEW_LINE> <INDENT> pass
TBD Returns:
625941eb293b9510aa2c377c
@require_http_methods(['GET']) <NEW_LINE> def movie_details(request): <NEW_LINE> <INDENT> movie_id = request.GET.get('movie_id') <NEW_LINE> queryset = Movie.movie_details(movie_id) <NEW_LINE> return JsonResponse(queryset)
This method help us in getting detail of a Movie. :param request: Http Request object :param movie_id: Id of movie :return: Json containing details of movie
625941eb50812a4eaa59c808
def make_gagestations(directory, HUC8, verbose = True): <NEW_LINE> <INDENT> NWIS = '{}/{}/NWIS'.format(directory, HUC8) <NEW_LINE> flowdata = {} <NEW_LINE> waterquality = {} <NEW_LINE> for g in os.listdir(NWIS): <NEW_LINE> <INDENT> if is_integer(g): <NEW_LINE> <INDENT> with open('{}/{}'.format(NWIS, g), 'rb') as f: <NE...
Combines all the flow gage station data into a single file consisting of a dictionary with NWIS gage ids as keys and observations as values.
625941eb7d43ff24873a318f
@ops.RegisterShape("ExtractGlimpse") <NEW_LINE> def _ExtractGlimpseShape(op): <NEW_LINE> <INDENT> input_shape = op.inputs[0].get_shape().with_rank(4) <NEW_LINE> unused_size_shape = op.inputs[1].get_shape().merge_with( tensor_shape.vector(2)) <NEW_LINE> offsets_shape = op.inputs[2].get_shape().merge_with( input_shape[:1...
Shape function for ExtractGlimpse op.
625941eb07d97122c4178d82
def medidas_posicion(datos, k=4, columna=0): <NEW_LINE> <INDENT> if type(datos) is pandas.core.frame.DataFrame: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> datos = datos.iloc[:, columna].to_list() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> datos = datos.loc[:, columna].to_list() <NEW_LINE> <DEDENT> <DEDENT> n = l...
Ubica las posiciones para la agrupacion de los datos en cuartiles (k=4), deciles (k=10) y percentiles (k=100) Entrada: -Lista de datos no agrupados (pueden no estar ordenados) -DataFrame de la libreria de pandas: Se debera definir el nombre de la columna que contiene los datos (default: ...
625941eb091ae35668667441
def login(self, user): <NEW_LINE> <INDENT> self._user = user._obj
Log in as the given user. No auth is done.
625941eb99cbb53fe67930d0
def split_heads(x, num_heads): <NEW_LINE> <INDENT> return tf.transpose(split_last_dimension(x, num_heads), [0, 2, 1, 3])
Split channels (dimension 2) into multiple heads (becomes dimension 1). Args: x: a Tensor with shape [batch, length, channels] num_heads: an integer Returns: a Tensor with shape [batch, num_heads, length, channels / num_heads]
625941eb2eb69b55b151cda2
def test_convert_token_and_id(self): <NEW_LINE> <INDENT> token = "<s>" <NEW_LINE> token_id = 1 <NEW_LINE> self.assertEqual(self.get_tokenizer()._convert_token_to_id(token), token_id) <NEW_LINE> self.assertEqual(self.get_tokenizer()._convert_id_to_token(token_id), token)
Test ``_convert_token_to_id`` and ``_convert_id_to_token``.
625941eb099cdd3c635f1144
def sync_with_pilight(self): <NEW_LINE> <INDENT> groups = self.pilightDevices['groups'] <NEW_LINE> for name in groups: <NEW_LINE> <INDENT> if name in self.groups: <NEW_LINE> <INDENT> self.groups[name].sync_with_pilight()
sync hue devices with pilight devices
625941eb5fc7496912cc3e69
def __init__(self, controls=[], x=0, y=0, **kwargs): <NEW_LINE> <INDENT> kwargs["width"] = 0 <NEW_LINE> kwargs["height"] = 0 <NEW_LINE> Layer.__init__(self, x=x, y=y, **kwargs) <NEW_LINE> self._controls = {} <NEW_LINE> self.spacing = kwargs.get("spacing", Layout.SPACING) <NEW_LINE> self.extend(controls)
A group of controls with a specific layout. Controls can be added with Layout.append(). The layout will be applied when Layout.apply() is called. This happens automatically if a layout is appended to a Panel.
625941ebaad79263cf390f34
def _GetApksPath(self): <NEW_LINE> <INDENT> raise NotImplementedError()
Returns context manager providing path to the bundle's APKS archive. Must be implemented by subclasses.
625941eb0383005118ecfacc
def ms_graph_inactive_users(days=45): <NEW_LINE> <INDENT> from organisation.models import DepartmentUser <NEW_LINE> now = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) <NEW_LINE> then = now - timedelta(days=days) <NEW_LINE> token = ms_graph_client_token() <NEW_LINE> if not token: <NEW_LINE> <INDENT>...
Query the MS Graph (Beta) API for a list of Azure AD accounts which haven't had a login event within a defined number of days. Returns a list of DepartmentUser objects.
625941eba934411ee3751b80
def load_last_json(path, number): <NEW_LINE> <INDENT> list_path_json_file = sorted(glob.glob(f"{path}/*.json"), reverse=True) <NEW_LINE> data = [] <NEW_LINE> for one_path in list_path_json_file[:number]: <NEW_LINE> <INDENT> data.append(load_json(one_path))
load last json file parametter : path of folder, number of files return : list of dictionary
625941eb566aa707497f4a4d
def step(self, action): <NEW_LINE> <INDENT> total_reward = 0 <NEW_LINE> reward = 0 <NEW_LINE> done = 0 <NEW_LINE> obs = [] <NEW_LINE> for _ in range(self.action_repeat): <NEW_LINE> <INDENT> ob, reward, done, info = self.env.step(action) <NEW_LINE> total_reward += reward <NEW_LINE> obs.append(ob) <NEW_LINE> <DEDENT> nex...
Uses action to obtain next state, reward, done.
625941eb63d6d428bbe449dc
@access_control('Головний вчитель') <NEW_LINE> def teachers_list(request): <NEW_LINE> <INDENT> if request.method == 'POST': <NEW_LINE> <INDENT> ajax_teacher_managing(request) <NEW_LINE> <DEDENT> teacher = Teachers.objects.get(id=request.session['teacher_id']) <NEW_LINE> teachers = Teachers.objects.filter(state=1).exclu...
Render teachers list.
625941eba17c0f6771cbe53b
def addNode(self, node): <NEW_LINE> <INDENT> assert node not in self.nodes <NEW_LINE> assert node.network is None <NEW_LINE> if self.graph is not None: <NEW_LINE> <INDENT> self.graph.add_node(node) <NEW_LINE> <DEDENT> node.network = self <NEW_LINE> self.nodes.add(node) <NEW_LINE> for b in node.buckets: <NEW_LINE> <INDE...
Registers a new Node in the Network. This should only be called when registering a new Node. All links between this node and other nodes in this network must already exist, so in that sense adding the Node ought to be the last thing that is done.
625941eb851cf427c661a9f6
def mark_acquired(self, files=[]): <NEW_LINE> <INDENT> lfn_in_transfer = [] <NEW_LINE> dash_rep = () <NEW_LINE> if self.config.isOracle: <NEW_LINE> <INDENT> toUpdate = list() <NEW_LINE> for lfn in files: <NEW_LINE> <INDENT> if lfn['value'][0].find('temp') == 7: <NEW_LINE> <INDENT> docId = lfn['key'][5] <NEW_LINE> toUpd...
Mark the list of files as tranferred
625941eb5fcc89381b1e1bae
def __repr__(self): <NEW_LINE> <INDENT> return f"Employee({self.id}, '{self.name}')"
This function is called by repr(). It returns string representation to construct an employee.
625941eb6fece00bbac2dc30
def get_column_count(self,sname): <NEW_LINE> <INDENT> return sname.max_column
Function defined to get the maximum number of columns :param sname: :return: maximum number of columns
625941eb7b25080760e39942
def braille2unicode(self): <NEW_LINE> <INDENT> return(write.Writer().braille2unicode(self))
For the cell pattern, returns the unicode character representation
625941eb9f2886367277ad75
def __init__(self): <NEW_LINE> <INDENT> pass
this is a draft of selenium automation
625941eb5fcc89381b1e1baf
def choice_count_up(self, num): <NEW_LINE> <INDENT> self.choice_count = models.F("choice_count") + num
no save
625941ebc432627299f05135
def __init__(sefl, log_file_name: str, e: Exception): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> path_parts = log_file_name.split('/') <NEW_LINE> log_file = path_parts[-1:][0] <NEW_LINE> print(LOG_FOLDER + '/' + log_file + '.log') <NEW_LINE> logger = logging.getLogger() <NEW_LINE> logger.setLevel(logging.DEBUG) <NEW_...
Constructor open and append log file Args: log_file_name: name of log file e: object of Exception class
625941eb7b180e01f3dc4cdf
def assert_called_anytime(self, method, url, body=None): <NEW_LINE> <INDENT> expected = (method, url) <NEW_LINE> assert self.client.callstack, "Expected %s %s but no calls were made." % expected <NEW_LINE> found = False <NEW_LINE> for entry in self.client.callstack: <NEW_LINE> <INDENT> if expected == entry[0...
Assert that an HTTP method was called anytime in the test. :param method: HTTP method name which is expected to be called :param url: Expected request url to be called with given method :param body: Expected request body to be called with given method and url. Default is None. Usage:: self.run_command...
625941ebcc0a2c11143dd37d
def test_maxerror(self): <NEW_LINE> <INDENT> engine.config(minreadlength=25, minoverlap=25, Amin='!') <NEW_LINE> seqs = ( "CAGCATGTGGAGCAACTTGTGGGAGCGCCGGGCAACGCCCTGTCTCTTAT", "CTGCATGTGGAGCAACTTGTGGGAGCGCCGGGCAACGCCCTGTCTCTTAT", "CTCCATGTGGAGCAACTTGTGGGAGCGCCGGGCAACGCCCTGTCTCTTAT", ) <NEW_LINE> for maxerrors in range(...
test different values for ``maxerror`` config parameter
625941eb046cf37aa974d22e
def __init__(self, _file): <NEW_LINE> <INDENT> self.file = File.new_instance(_file) <NEW_LINE> self.lock = Lock("lock for persistent queue using file " + self.file.name) <NEW_LINE> self.please_stop = Signal() <NEW_LINE> self.db = Data() <NEW_LINE> self.pending = [] <NEW_LINE> if self.file.exists: <NEW_LINE> <INDENT> fo...
file - USES FILE FOR PERSISTENCE
625941eb92d797404e304678
def get_data(self): <NEW_LINE> <INDENT> while self.run_flag: <NEW_LINE> <INDENT> with self.lock: <NEW_LINE> <INDENT> self.data = self.get_value() <NEW_LINE> <DEDENT> time.sleep(self.polling_interval)
Thread method.
625941eb287bf620b61d3f4c
def save_to_file(weightM, weightL2): <NEW_LINE> <INDENT> for column in range(weightM.shape[1]): <NEW_LINE> <INDENT> for row in range(weightM.shape[0]): <NEW_LINE> <INDENT> if column == 0 and row == 0: <NEW_LINE> <INDENT> f = open('task2 hNN A weights.txt', 'w') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> f = open('ta...
Saves the weight matrix and final layer weight vector in .txt file given the specified format
625941ebff9c53063f47c6dd
def fixed_for_rotation(self, direction_of_origin): <NEW_LINE> <INDENT> do_fix = False <NEW_LINE> if direction_of_origin in (Direction.BOTTOM, Direction.LEFT): <NEW_LINE> <INDENT> if self.direction in (Direction.BOTTOM, Direction.LEFT): <NEW_LINE> <INDENT> do_fix = True <NEW_LINE> <DEDENT> <DEDENT> if direction_of_origi...
the side's value modified for comparing two sides in a rotation context. BOTTOM -> reverse BOTTOM or LEFT LEFT -> reverse BOTTOM or LEFT TOP -> reverse TOP or RIGHT RIGHT -> reverse TOP or RIGHT
625941ebf9cc0f698b140ae3
def dict_for_neutron(self, neutron): <NEW_LINE> <INDENT> out = dict() <NEW_LINE> if self.description: <NEW_LINE> <INDENT> out['description'] = self.description <NEW_LINE> <DEDENT> if self.direction: <NEW_LINE> <INDENT> out['direction'] = self.direction.name <NEW_LINE> <DEDENT> if self.port_range_min: <NEW_LINE> <INDENT...
Returns a dictionary object representing this object. This is meant to be converted into JSON designed for use by the Neutron API :param neutron: the neutron client for performing lookups :return: the dictionary object
625941eb15fb5d323cde1003
def transfer_function_2nd_stage(pype, lo_start_freq, lo_stop_freq, lo_step, source_power, channel, dig_time=1000): <NEW_LINE> <INDENT> for lo_val in arange(lo_start_freq, lo_stop_freq, lo_step): <NEW_LINE> <INDENT> pype.Set('lo_cw_freq', lo_val) <NEW_LINE> pype.Run(duration=dig_time)
Measure the transfer function of the low frequency receiver stage Inputs: <pype>: pypeline.DripInterface instance <lo_start_freq>: local oscillator scan start frequency (MHz) <lo_stop_freq>: local oscillator scan stop frequency (MHz) <lo_step>: local oscillator scan step size (MHz) <source_power>: ...
625941eb236d856c2ad44ccd
def send_activation_email(self, domain=None, resend=False, template=None, subject=None): <NEW_LINE> <INDENT> domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') <NEW_LINE> self._reset_activation_key(resend=resend) <NEW_LINE> activation_email(self, domain=domain, template=template, subject=subject)
Sends an activation email
625941eb1d351010ab856007
def execute(self): <NEW_LINE> <INDENT> return self._execute()
Public method to execute requested algorithm on the given environment Returns: output: (tuple) Raises: AlgorithmMethodNotImplemented
625941eb60cbc95b062c6a30
def verify_connection_certificate(self, do_verify, certificate_path=None): <NEW_LINE> <INDENT> self._lib_call('dwavdapi_set_connect_ssl_verify', (self._handle, int(do_verify))) <NEW_LINE> self._api_call('dwavdapi_set_connect_ssl_crt', (self._handle, certificate_path))
Gives *dwavdapi* library an instruction to verify or not to verify connection certificate. :param do_verify: boolean. If *True* connection certificate will be verified. :param certificate_path: expects full path to root certificate to verify connection validity against, or *None* is system certificates should be u...
625941eb0fa83653e46574a4
def levelOrderBottom(self, root): <NEW_LINE> <INDENT> if root == None: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> q = deque() <NEW_LINE> q.append(root) <NEW_LINE> q.append('#') <NEW_LINE> result = [] <NEW_LINE> temp = [] <NEW_LINE> while True: <NEW_LINE> <INDENT> if len(q) == 1: <NEW_LINE> <INDENT> result = [tem...
:type root: TreeNode :rtype: List[List[int]]
625941eb8e7ae83300e4b4ba
def find_nearest_larger(val, array): <NEW_LINE> <INDENT> s_array = np.sort(array, axis=None) <NEW_LINE> r = np.searchsorted(s_array, val, side='right') <NEW_LINE> return s_array[r]
Find the value which is nearest and larger than val in array.
625941eb32920d7e50b286c1
def get_lib_template(self): <NEW_LINE> <INDENT> rand_file = "db/madlibs/" + random.choice(os.listdir("db/madlibs")) <NEW_LINE> with open(rand_file,"r") as file: <NEW_LINE> <INDENT> title = file.readline().strip('\n') <NEW_LINE> blanks = file.readline().strip('\n') <NEW_LINE> text = file.readline() <NEW_LINE> return tit...
Returns a random lib from the db/madlibs folder
625941eb566aa707497f4a4e
def set_query_delay(size, config_file): <NEW_LINE> <INDENT> file_handle = open(config_file, 'r') <NEW_LINE> file_string = file_handle.read() <NEW_LINE> file_handle.close(); <NEW_LINE> file_string = re.sub(r'query_delay=[0-9]+', "query_delay=%d" % size, file_string) <NEW_LINE> file_handle = open(config_file, 'w') <NEW_L...
Changes the size of sent packets.
625941eb167d2b6e31219081
def add_errback(self, f): <NEW_LINE> <INDENT> assert callable(f), "A function needs to be passed into add_errback. Got: %s" % f <NEW_LINE> with self._cb_lock: <NEW_LINE> <INDENT> if self.state == self.PENDING: <NEW_LINE> <INDENT> self._errbacks.append(f) <NEW_LINE> return <NEW_LINE> <DEDENT> <DEDENT> if self.state == s...
Add a callback for when this promis is rejected. Note that if you intend to use the rejection reason of the promise somehow in the callback, it is more convenient to use the 'then' method.
625941eb57b8e32f5248398a
def create_question(question_text, days): <NEW_LINE> <INDENT> time = timezone.now() + datetime.timedelta(days=days) <NEW_LINE> return Question.objects.create(question_text=question_text, pub_date=time)
Creates a question with the given 'question_text' and published the given number of 'days' offset to now(negative for questions published in the past, positive for questions that have yet to be published).
625941eb44b2445a3393257e
def trainset_generator(batch_size, train_path, image_folder, mask_folder, aug_dict, image_color_mode = "grayscale", mask_color_mode = "grayscale", image_save_prefix= "image", mask_save_prefix = "mask", flag_multi_class = False, num_class = 2, save_to_dir =None, target_size = (model.height, model.width), seed = 1): <NE...
can generate image and mask at the same time use the same seed for image_datagen and mask_datagen to ensure the transformation for image and mask is the same if you want to visualize the results of generator, set save_to_dir = "your path"
625941eb01c39578d7e75327
def parallel_control(target_function, list2process, fixed_args=None, return_results=True, num_threads=None): <NEW_LINE> <INDENT> if num_threads is None: <NEW_LINE> <INDENT> num_threads = mp.cpu_count() <NEW_LINE> <DEDENT> num_threads = min(num_threads, len(list2process)) <NEW_LINE> if fixed_args is None: <NEW_LINE> <IN...
Process a list in parallel by spawning only necessary number of processes Parameters ---------- target_function : function Function to run, will be called as function(*args, *fixed_args) list2process : list[tuple] List with inputs to the target_function, if None an empty tuple is used fixed_args : tuple Fix...
625941eb55399d3f05588ba4
def get_requested_record_list(model, ids): <NEW_LINE> <INDENT> return map(lambda id: get_requested_record(model, id), _parse_id_list(ids))
Similar to get_requested_record(), but expects a comma-separated list of ids, and returns a list of (unique) records.
625941eb046cf37aa974d22f
@register <NEW_LINE> def log_log_message(self, message): <NEW_LINE> <INDENT> disconnected = [] <NEW_LINE> for user_id, logger in self.loggers.iteritems(): <NEW_LINE> <INDENT> if not logger.events or LOG_LOG_MESSAGE in logger.events: <NEW_LINE> <INDENT> data = {} <NEW_LINE> data['timestamp'] = time.time() <NEW_LINE> dat...
Log message that is displayed at listener
625941eb99cbb53fe67930d1
def _create_vpsa_server(self, iqn=None, iscsi_ip=None): <NEW_LINE> <INDENT> initiator = iscsi_ip if iscsi_ip else iqn <NEW_LINE> share = True if iscsi_ip else False <NEW_LINE> vpsa_srv = self._get_server_name(initiator, share) <NEW_LINE> if not vpsa_srv: <NEW_LINE> <INDENT> data = self.send_cmd('create_server', iqn=iqn...
Create server object within VPSA (if doesn't exist).
625941ebbde94217f36832d8
def __setup__(self): <NEW_LINE> <INDENT> self.f = open(self.sync_path.path, 'rb') <NEW_LINE> self.file_no = self.tr.new_file_sender(self.fid, self.parts_size(), self.sync_path.rel_path)
Notify that we will send a file
625941eb5f7d997b87174f89
@manager.command <NEW_LINE> def train_nlu(): <NEW_LINE> <INDENT> logger.info('Command: train_nlu') <NEW_LINE> trainer.train_intent_model()
start train NN responsible for intent classification
625941eb462c4b4f79d1dbbc
def test_login_success(self): <NEW_LINE> <INDENT> response = self.client.post("/user/logout/") <NEW_LINE> self.assertEqual(response.status_code, 302)
测试退出成功
625941eb56b00c62f0f14b49
def filter(self, x): <NEW_LINE> <INDENT> a0, a11, a12, a13, a14, a2, b0, b1, b2, gain = self._calculate_coefficients() <NEW_LINE> output = np.zeros((gain.shape[0], x.shape[-1])) <NEW_LINE> for chan in range(gain.shape[0]): <NEW_LINE> <INDENT> y1 = ss.lfilter([a0[chan] / gain[chan], a11[chan] / gain[chan], a2[chan] / ga...
Filters a signal along its last dimension. Parameters ---------- x : ndarray Signal to filter. Returns ------- ndarray Filtered signals with shape ``(M, N)``, where ``M`` is the number of channels, and ``N`` is the input signal's nubmer of samples.
625941eb283ffb24f3c55de8
def gen_srg_entry(self, ana, sec, k=2): <NEW_LINE> <INDENT> sigma_null = ana.doc.get("AuxValues", {}).get("SigmaNull") <NEW_LINE> sigma_corr_slope = ana.doc.get("AuxValues", {}).get("SigmaCorrSlope") <NEW_LINE> sigma_std = ana.doc.get("AuxValues", {}).get("SigmaStd") <NEW_LINE> if sigma_null and sigma_corr_slope and si...
..todo:: s. issue https://a75436.berlin.ptb.de/vaclab/vpy/issues/15
625941eb377c676e91272693
def handle_event(self, ev): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> msg = ("Handling event %s" % (ev.id)) <NEW_LINE> LOG.info(msg) <NEW_LINE> if ev.data['firewall'].get('file_path', None): <NEW_LINE> <INDENT> filename = ev.data['firewall']['file_path'] <NEW_LINE> string = str() <NEW_LINE> with open(filename, 'r') ...
Demultiplexes the firewall request to appropriate driver methods. :param ev: event object sent from process model event handler
625941ebf7d966606f6aa4f6
def get_sin_sig(t, freq, ampl): <NEW_LINE> <INDENT> return ampl * np.sin(2 * np.pi * freq * t) + ampl * np.cos(2 * 2 * np.pi * freq * t)
:return: ampl * sin(freeq * t) + ampl * sin(2 * freeq * t)
625941eb07f4c71912b11971
def get_raw_score(self, string1, string2): <NEW_LINE> <INDENT> dist_mat = np.zeros((len(string1) + 1, len(string2) + 1), dtype=np.float) <NEW_LINE> for i in range(len(string1) + 1): <NEW_LINE> <INDENT> dist_mat[i, 0] = -(i * self.gap_cost) <NEW_LINE> <DEDENT> for j in range(len(string2) + 1): <NEW_LINE> <INDENT> dist_m...
Computes the raw Needleman-Wunsch score between two strings. Args: string1,string2 (str) : Input strings. Returns: Needleman-Wunsch similarity score (float). Raises: TypeError : If the inputs are not strings or if one of the inputs is None. Examples: >>> nw = NeedlemanWunsch() >>> nw.get_raw_sco...
625941ebd8ef3951e3243a2a
def testManifestRequest(self): <NEW_LINE> <INDENT> pass
Test ManifestRequest
625941ebd99f1b3c44c67a72
def are_anomalies_created(path, number_of_anomalies): <NEW_LINE> <INDENT> anomaly_ids = [] <NEW_LINE> try: <NEW_LINE> <INDENT> with open("%s%sanomalies" % (path, os.sep)) as anomalies_file: <NEW_LINE> <INDENT> for line in anomalies_file: <NEW_LINE> <INDENT> anomaly = line.strip() <NEW_LINE> try: <NEW_LINE> <INDENT> ano...
Checks existence and reads the anomaly detector ids from the anomalies file in the path directory
625941eb57b8e32f5248398b
def current(): <NEW_LINE> <INDENT> user_ent = forCurrentUserId() <NEW_LINE> if user_ent: <NEW_LINE> <INDENT> return user_ent <NEW_LINE> <DEDENT> return forCurrentAccount()
Retrieves the user entity for the currently logged in user. Returns: The User entity of the logged in user or None if not available.
625941ebbd1bec0571d90b1b
def soil_at_height(self, height:float)->Soil: <NEW_LINE> <INDENT> assert isinstance(height,(int,float)) <NEW_LINE> height1=height-self.dm_height <NEW_LINE> try: <NEW_LINE> <INDENT> return self.ff.get_value(height1) <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> print(e.__str__()) <NEW_LINE> raise Except...
获取高程处的土体信息
625941eb3617ad0b5ed683e3
def on_surface(self, point): <NEW_LINE> <INDENT> n = len(self.pts) <NEW_LINE> angle_sum = 0 <NEW_LINE> p = np.array(point) <NEW_LINE> for i in range(n): <NEW_LINE> <INDENT> v1 = np.array(self.pts[i]) - p <NEW_LINE> v2 = np.array(self.pts[(i + 1) % n]) - p <NEW_LINE> m1 = magnitude(v1) <NEW_LINE> m2 = magnitude(v2) <NEW...
Returns True if the point is on the polygon's surface and false otherwise. :param point: :return:
625941ebd7e4931a7ee9e40c
def declination(voteshares, bdec=False): <NEW_LINE> <INDENT> s = _stats(voteshares, min_per_party_n_wins=1) <NEW_LINE> if s != s: <NEW_LINE> <INDENT> return s <NEW_LINE> <DEDENT> if bdec: <NEW_LINE> <INDENT> xtra_num = 1 + int(np.ceil(s['N'] / 20)) <NEW_LINE> s['r_voteshares'] = np.append( s['r_voteshares'], .5 * np.on...
Declination, expressed as a fraction of 90 degrees.
625941ebbde94217f36832d9
def getPortID(port): <NEW_LINE> <INDENT> if isinstance(port, int): <NEW_LINE> <INDENT> id = port <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if port: <NEW_LINE> <INDENT> port = port.strip() <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> id = int(port) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> try: <NEW_LINE> <IND...
Check and Get port id from port string or port id using socket.getservbyname @param port port string or port id @return Port id if valid, -1 if port can not be found and -2 if port is too big
625941eb287bf620b61d3f4d
def fit_transform(self, documents): <NEW_LINE> <INDENT> self.fit(documents) <NEW_LINE> return self.transform()
Fit transform ===== Function to perform the fit and transform sequence Parameters ----- Returns ----- self.transform(tagged_data) : list The featurized instances self.features : list The vocabulary
625941ebb5575c28eb68e4f1
def deserialize_numpy(self, str, numpy): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> end = 0 <NEW_LINE> start = end <NEW_LINE> end += 8 <NEW_LINE> (self.object_id,) = _struct_Q.unpack(str[start:end]) <NEW_LINE> return self <NEW_LINE> <DEDENT> except struct.error as e: <NEW_LINE> <INDENT> raise genpy.DeserializationErr...
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
625941eb1f037a2d8b9466e9
def test_delete_vpc(self): <NEW_LINE> <INDENT> pass
Test case for delete_vpc delete_vpc_request = ncloud_vpc.DeleteVpcRequest() try: api_response = self.api.delete_vpc(delete_vpc_request) print(api_response) except ApiException as e: print("Exception when calling V2Api->delete_vpc: %s " % e)
625941ebd164cc617578323c
def goto_place(self, obj, lat, lon): <NEW_LINE> <INDENT> self.set_center(None, None, lat, lon)
Center the map on latitude, longitude.
625941eb76e4537e8c351b63
def max_pool_backward_naive(dout, cache): <NEW_LINE> <INDENT> dx = None <NEW_LINE> x, pool_param = cache <NEW_LINE> N, C, H, W = x.shape <NEW_LINE> pool_height,pool_width,stride=pool_param['pool_height'],pool_param['pool_width'],pool_param['stride'] <NEW_LINE> N, C,H_prime,W_prime = dout.shape <NEW_LINE> dx=np.zeros(x....
A naive implementation of the backward pass for a max-pooling layer. Inputs: - dout: Upstream derivatives - cache: A tuple of (x, pool_param) as in the forward pass. Returns: - dx: Gradient with respect to x
625941eb3346ee7daa2b325d
def PlotPosteriors(self, other): <NEW_LINE> <INDENT> thinkplot.Clf() <NEW_LINE> thinkplot.PrePlot(num=2) <NEW_LINE> cdf1 = thinkbayes.MakeCdfFromPmf(self, 'posterior %d' % self.score) <NEW_LINE> cdf2 = thinkbayes.MakeCdfFromPmf(other, 'posterior %d' % other.score) <NEW_LINE> thinkplot.Cdfs([cdf1, cdf2]) <NEW_LINE> thin...
Plots posterior distributions of efficacy. self, other: Sat objects.
625941eb283ffb24f3c55de9
def __call__(self, **kw): <NEW_LINE> <INDENT> self.params.update(kw) <NEW_LINE> self.process_params() <NEW_LINE> for k, v in self.params.items(): <NEW_LINE> <INDENT> setattr(self, k, v)
Call can be used for stand-alone plotting, with any kw params supplied here overriding those from instantiation. Subclass should call this method at the start of its own __call__ method.
625941ebf7d966606f6aa4f7
def plot_cluster_ordered_candles(data): <NEW_LINE> <INDENT> mondays = WeekdayLocator(MONDAY) <NEW_LINE> alldays = DayLocator() <NEW_LINE> weekFormatter = DateFormatter("") <NEW_LINE> fig, ax = plt.subplots(figsize=(16,4)) <NEW_LINE> ax.xaxis.set_major_locator(mondays) <NEW_LINE> ax.xaxis.set_minor_locator(alldays) <NEW...
Plot a candlestick chart ordered by cluster membership with the dotted blue line representing each cluster boundary.
625941ebac7a0e7691ed45af
def float_array_string(arr): <NEW_LINE> <INDENT> return "[" + ", ".join(["{:.4f}".format(el) for el in arr]) + "]"
format array of floats to 4 decimal places Args: arr: array of floats Returns: formatted string
625941eb4527f215b584c93f
def test_to_python(self): <NEW_LINE> <INDENT> fld = forms.GeometryField() <NEW_LINE> for wkt in ('POINT(5 23)', 'MULTIPOLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))', 'LINESTRING(0 0, 1 1)'): <NEW_LINE> <INDENT> self.assertEqual(GEOSGeometry(wkt), fld.to_python(wkt)) <NEW_LINE> <DEDENT> for wkt in ('POINT(5)', 'MULTI POLYGON((...
Testing to_python returns a correct GEOSGeometry object or a ValidationError
625941eb38b623060ff0b2da
def __init__(self, reg_model, kernel, param_grid, data_ratio=None, nfolds=10): <NEW_LINE> <INDENT> LinearRegressionModel.__init__(self) <NEW_LINE> if data_ratio < 0 or data_ratio > 0.2: <NEW_LINE> <INDENT> raise ValueError('data_ratio must be in interval [0,0.2].') <NEW_LINE> <DEDENT> if nfolds < 1: <NEW_LINE> <INDENT>...
@todo: - check if kernel is a class not an instance and it is paramtrizeable
625941ebbe383301e01b5969
def test_pad_with_pad_width(sample_da_2d): <NEW_LINE> <INDENT> pad_width = {"x": (2, 3), "y": (1, 3)} <NEW_LINE> padded_da = pad(sample_da_2d, pad_width) <NEW_LINE> assert padded_da.shape == (21, 16) <NEW_LINE> npt.assert_allclose(padded_da.values[:1, :], 0) <NEW_LINE> npt.assert_allclose(padded_da.values[-3:, :], 0) <...
Test pad function by passing pad_width as argument
625941eb851cf427c661a9f7
def get_nucleusid(self): <NEW_LINE> <INDENT> cookies = {'futweb': self.futweb, 'EASFC-WEB-SESSION': self.easfc, 'hl': 'uk', 'XSRF-TOKEN': self.xsrf} <NEW_LINE> r = requests.get(self.IFRAME_FUT_URL, cookies=cookies, allow_redirects=False) <NEW_LINE> m = re.findall("var EASW_ID = \'\d+\'", r.text) <NEW_LINE> return m[0]....
Goes to /iframe/fut/ and parses the html to find the NucleusId returns the NucleusId
625941eb4428ac0f6e5bace3
def __calculatehooklength(self): <NEW_LINE> <INDENT> loaded = self.loaded <NEW_LINE> return functools.reduce(lambda x,y: len(y)+x, loaded.values(), 0)
Total the number of bytes in order to allocate all the user-supplied code
625941eba219f33f34628e4f
def attendance(request, id_class, date): <NEW_LINE> <INDENT> cl = Classes.objects.get(pk=id_class) <NEW_LINE> ss = Students.objects.filter(s_class=cl) <NEW_LINE> att = Attendance.objects.filter(student__in=[s for s in ss], date=date) <NEW_LINE> if not att: <NEW_LINE> <INDENT> for student in ss: <NEW_LINE> <INDENT> a = ...
View that lists the attendance of the specified class students
625941eb26238365f5f0f362
def send_param_command_packet(self, command_tuple, param_tuple=None, param_type_tuple=0,ack=True): <NEW_LINE> <INDENT> param_size_list = [0] * len(param_tuple) <NEW_LINE> pack_char_list = [0] * len(param_tuple) <NEW_LINE> if param_tuple is not None: <NEW_LINE> <INDENT> for i,param in enumerate(param_tuple): <NEW_LINE> ...
Send a command packet with parameters. Ack channel is optional for future flexibility, but currently commands are always send over the Ack channel so it defaults to True. Contributed by awm102 on github :param: command_tuple: the command tuple derived from command_parser.get_command_tuple() :param: param_tuple (optio...
625941eb30bbd722463cc2b6
def save(self): <NEW_LINE> <INDENT> if not self._dirty_fields: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> fields_to_save = self._get_fields_to_save() <NEW_LINE> self._field_data.set_many(self, fields_to_save) <NEW_LINE> <DEDENT> except KeyValueMultiSaveError as save_error: <NEW_LINE> <INDEN...
Save all dirty fields attached to this XBlock.
625941eb85dfad0860c3b349
def load(self, f): <NEW_LINE> <INDENT> self.W.set_value(pickle.load(f), borrow=True) <NEW_LINE> self.U.set_value(pickle.load(f), borrow=True) <NEW_LINE> self.b.set_value(pickle.load(f), borrow=True)
Load the model parameters from the opened pickle file `f`.
625941eb94891a1f4081bf99