code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def __get_string_url(self, url): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> r = self.session.get("%s/%s" % (self.host_uri, url)) <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> if self.debug: <NEW_LINE> <INDENT> print("Failed to get object: ", e) <NEW_LINE> <DEDENT> raise KismetRequestException("Failed...
__get_string_url(url) -> (result, string) Internal function to perform a simple fetch of a URL and return it as an unprocessed string object
625941f12ae34c7f2600d6f3
def get_pushenctrigger(self): <NEW_LINE> <INDENT> return self.options['pushenctrigger']
PUSH packet triggering encryption Always - Any PUSH packet triggers encryption Ignore - Ignore PUSH packet for triggering encryption Merge - For consecutive sequence of PUSH packets, last PUSH packet triggers encryption Timer - PUSH packet triggering encryption delayed by timer period defined in 'set ssl parameter' .
625941f1462c4b4f79d1dc92
def create_volume(self, size, name, location=None, snapshot=None): <NEW_LINE> <INDENT> disk_param = { 'name': name, 'size': int(size), 'datacenter_id': int(location.id) } <NEW_LINE> if snapshot: <NEW_LINE> <INDENT> op = self.connection.request('hosting.disk.create_from', disk_param, int(snapshot.id)) <NEW_LINE> <DEDENT...
Create a volume (disk). :param size: Size of volume to create (in GB). :type size: ``int`` :param name: Name of volume to create :type name: ``str`` :keyword location: Location (zone) to create the volume in :type location: :class:`NodeLocation` or ``None`` :keyword snapshot: Snapshot to create image fr...
625941f1236d856c2ad44da6
def test_chair(self): <NEW_LINE> <INDENT> self.chair_committee = models.new_committee() <NEW_LINE> self.user = models.new_user( username='chair', password='chair', user_type=User.TYPE_CHAIR, committee_id=self.chair_committee.id, ) <NEW_LINE> self.client.login(username='chair', password='chair') <NEW_LINE> response = se...
Tests chair can get secretariat information
625941f1796e427e537b0b8e
def simplifyText(s): <NEW_LINE> <INDENT> s1 = unicode(str(s).strip().lower(), 'utf-8') <NEW_LINE> s2 = unicodedata.normalize('NFD', s1).encode('ascii', 'ignore') <NEW_LINE> return(s2)
Remove extra blanks (outside), replace uppercase letters by lowercase letters and remove all accents from 's'.
625941f11b99ca400220b077
def render(mazes, filename, tweaker=tweak): <NEW_LINE> <INDENT> mpl.rcParams['lines.linewidth'] = 0.5 <NEW_LINE> fig, axs = plt.subplots(2, 4) <NEW_LINE> tweaker(fig, axs) <NEW_LINE> for i in range(2): <NEW_LINE> <INDENT> for j in range(4): <NEW_LINE> <INDENT> print(" plotting maze %d..." % (4*i + j + 1)) <NEW_LINE> ...
render a set of mazes This is the main entry point to this script. If the script is run from the command line, eight rectangular weave grids will be created, and perfect mazes will be created from them using various growing tree algorithms. mazes = a (2,4) matrix of mazes. filename = filename or pathname for output...
625941f17d43ff24873a3268
def test_direction_unit_length_enforced(self): <NEW_LINE> <INDENT> m = IMP.Model() <NEW_LINE> p = IMP.Particle(m) <NEW_LINE> d = IMP.core.Direction.setup_particle( p, IMP.algebra.Vector3D(0, 0, 1)) <NEW_LINE> m.set_attribute(d.get_direction_key(0), p.get_index(), 0) <NEW_LINE> m.set_attribute(d.get_direction_key(1), p....
Test direction is unit length after model update.
625941f1377c676e9127276a
def get_node(self, index): <NEW_LINE> <INDENT> h, w = index <NEW_LINE> return self.nodes[h][w]
根据索引获得地图中的 Node 对象。 :param index: (height,weight) 元组 :return: Node 对象
625941f1283ffb24f3c55ebe
def new_func(*args, **kwargs): <NEW_LINE> <INDENT> self = args[0] <NEW_LINE> value = getattr(self, attr_name) <NEW_LINE> return value
Getter function
625941f13617ad0b5ed684ba
def setup_module(module): <NEW_LINE> <INDENT> print('pytest setup_module', module) <NEW_LINE> teardown_module(module) <NEW_LINE> schm.cmd_init(dbname, True)
Подключиться к тестовой базе
625941f121a7993f00bc82be
def test_dv_cq_traffic(self): <NEW_LINE> <INDENT> self.create_players(Mlx5CQRes) <NEW_LINE> u.traffic(**self.traffic_args, is_cq_ex=True)
Run SEND traffic using DC CQ.
625941f197e22403b379d55f
def __init__(self, user, pwd): <NEW_LINE> <INDENT> print("Connecting to Mint...\nIt may take a couple minutes to login and refresh all account data...") <NEW_LINE> self.mint = mintapi.Mint( user, pwd ) <NEW_LINE> print("Connected\n")
Login to Mint and refresh account data
625941f1c4546d3d9de72ffd
def lock_applies_to(self, user): <NEW_LINE> <INDENT> logging.info("Checking if the lock on `%s` applies to user `%s`" % (self, user)) <NEW_LINE> if self.is_locked and self.locked_by != user: <NEW_LINE> <INDENT> logging.info("Lock applies.") <NEW_LINE> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> logging.in...
A lock does not apply to the user who initiated the lock. Thus, ``lock_applies_to`` is used to ascertain whether a user is allowed to edit a locked object.
625941f1a79ad161976cc709
def test_delete_datafield(self): <NEW_LINE> <INDENT> bibrecord.record_delete_field(self.rec, "100", " ", " ") <NEW_LINE> self.assertEqual(bibrecord.record_get_field_values(self.rec, "001", " ", " ", ""), ['33']) <NEW_LINE> self.assertEqual(bibrecord.record_get_field_values(self.rec, "100", " ", " ", "b"), []) <NEW_LINE...
bibrecord - deleting datafield
625941f1460517430c394738
def walk_entries(path, entries=None, parent=None): <NEW_LINE> <INDENT> path = pathlib.Path(path) <NEW_LINE> entries = entries or {} <NEW_LINE> if path.is_dir(): <NEW_LINE> <INDENT> entries[path.name] = [] <NEW_LINE> for x in path.iterdir(): <NEW_LINE> <INDENT> walk_entries(x, entries, path.name) <NEW_LINE> <DEDENT> ret...
Walk jouranl recursively. Returns a dictionary of day_folder: entries
625941f1e76e3b2f99f3adc5
def List2NgxLua(Lists): <NEW_LINE> <INDENT> IPs = '' <NEW_LINE> for IP in Lists: <NEW_LINE> <INDENT> if IPs == '': <NEW_LINE> <INDENT> IPs = IPs + '"' + IP + '"' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> IPs = IPs + ',"' + IP + '"' <NEW_LINE> <DEDENT> <DEDENT> return '{' + IPs + '}'
transform list to ngxlua
625941f166673b3332b92654
def get(self, parameter_name): <NEW_LINE> <INDENT> return super(ProtocolAgentValues, self).get(name=parameter_name)
Get the parameter by it's name. This is a convenience for fetching. For example, fetch the proxy server (redir_cis) parameter from a HTTP or HTTPS protocol agent:: pv = newservice.protocol_agent_values.get('redir_cis') :return: Return the parameter value if it exists, otherwise None :rtype: ProtocolParameterValue
625941f10383005118ecfba4
def get_MDFW(structure, start_temp, end_temp, name="molecular dynamics", priority=None, args={}, **kwargs): <NEW_LINE> <INDENT> run_args = {"md_params": {"nsteps": 500, "start_temp": start_temp, "end_temp": end_temp}, "run_specs": {"vasp_input_set": None, "vasp_cmd": ">>vasp_cmd<<", "db_file": ">>db_file<<", "wall_time...
Helper function to get molecular dynamics firework for quench workflow Args: structure: Initial structure for molecular dynamics run start_temp: Starting Temperature end_temp: Ending Temperature name: name of firework priority: priority of job in database args: custom arguments dictionary for m...
625941f124f1403a92601124
def iterator(self): <NEW_LINE> <INDENT> return _moduleconnectorwrapper.sVector_iterator(self)
iterator(sVector self) -> SwigPyIterator
625941f130bbd722463cc38d
def download(self, resource): <NEW_LINE> <INDENT> filename = os.path.join(django_s3_settings.S3_LOCAL_PATH, resource.name) <NEW_LINE> if not os.path.exists(filename): <NEW_LINE> <INDENT> Transport.logger.info(_('Downloading {} to {}.'.format(resource.name, filename))) <NEW_LINE> try: <NEW_LINE> <INDENT> key_holder = Ke...
Download a resource. :param resource: An instance of `django_s3.resource.Resource` :return: The absolute filename of the downloaded file.
625941f150812a4eaa59c8df
def reg_on_status(self, callable_object, *args, **kwargs): <NEW_LINE> <INDENT> persistent = kwargs.pop('persistent', False) <NEW_LINE> event = self._create_event(callable_object, 'status', persistent, *args, **kwargs) <NEW_LINE> self.status_callbacks.append(event) <NEW_LINE> return event
Register a function/method to be called when a user or another program asks for an update, when status is done it will start running any tasks registered with the reg_on_resume method
625941f171ff763f4b549c5a
def _upgrade_level_succeed(self, data, req, timer): <NEW_LINE> <INDENT> res = hero_pb2.UpdateHeroRes() <NEW_LINE> res.status = 0 <NEW_LINE> response = res.SerializeToString() <NEW_LINE> log = log_formater.output(data, "Upgrade hero level succeed", req, res, timer.count_ms()) <NEW_LINE> logger.notice(log) <NEW_LINE> ret...
请求处理成功
625941f1d18da76e23532aa1
def update(self, game_state): <NEW_LINE> <INDENT> self._update_ball(game_state.field.ball) <NEW_LINE> self._update_team(self.friend, game_state.friends) <NEW_LINE> self._update_team(self.enemy, game_state.enemies) <NEW_LINE> ui_debug_commands = game_state.debug <NEW_LINE> if self.debug_manager: <NEW_LINE> <INDENT> for ...
Interface public pour update de l'infomanager.
625941f1046cf37aa974d305
def invBlock( self, xpos=0, nlay=2, noise=1.0, stmod=10., lam=100., lBound=1., uBound=0., verbose=False ): <NEW_LINE> <INDENT> self.transThk = RTransLog() <NEW_LINE> self.transRes = RTransLogLU( lBound, uBound ) <NEW_LINE> self.transData = RTrans() <NEW_LINE> if isinstance( nlay, FDEM1dModelling ): <NEW_LINE> <INDENT> ...
yield gimli inversion instance for block inversion.
625941f18e05c05ec3eea93d
def update(self): <NEW_LINE> <INDENT> for x in range(self.leds): <NEW_LINE> <INDENT> self.spi.write(self.buffer[x]) <NEW_LINE> self.spi.flush() <NEW_LINE> <DEDENT> self.spi.write(bytearray(b'\x00')) <NEW_LINE> self.spi.flush()
Flush the buffer to the strand
625941f17b25080760e39a19
def run_command(c): <NEW_LINE> <INDENT> return subprocess.run(c, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
Run a single command in a shell, capturing its output as text. Returns a single CompletedProcess instance.
625941f1d58c6744b4258221
def get_prescriptions(patientid): <NEW_LINE> <INDENT> logger.debug('in get_prescriptions') <NEW_LINE> resp_list = [] <NEW_LINE> try: <NEW_LINE> <INDENT> patient = PatientModel.get(PatientModel.email==patientid) <NEW_LINE> for prescription in PrescriptionModel.select().where(PrescriptionModel.patient==patient): <NEW_LIN...
Get info of a doctor in the system. :param doctorid: doctor's uid :returns: a status, a str ( doctor's info on success, err info on failure)
625941f1d4950a0f3b08c90a
def char_iter_backward_to_newline(self, char_iter): <NEW_LINE> <INDENT> if not char_iter.backward_char(): return False <NEW_LINE> while char_iter.get_char() != cons.CHAR_NEWLINE: <NEW_LINE> <INDENT> if not char_iter.backward_char(): return False <NEW_LINE> <DEDENT> return True
Backwards char iter to line start
625941f13346ee7daa2b3335
def get_form_fieldsets(form): <NEW_LINE> <INDENT> fieldsets = [] <NEW_LINE> form_fields = getattr(form, "fields", {}) <NEW_LINE> fields_values = list(form_fields.values()) <NEW_LINE> if form_fields: <NEW_LINE> <INDENT> fieldsets.append( { "id": "default", "title": translate( "label_schema_default", default="Default", d...
Get fieldsets from form
625941f1be7bc26dc91cdbb8
def encode_entrance_exam_and_student_input(usage_key, student=None): <NEW_LINE> <INDENT> assert isinstance(usage_key, UsageKey) <NEW_LINE> if student is not None: <NEW_LINE> <INDENT> task_input = {'entrance_exam_url': unicode(usage_key), 'student': student.username} <NEW_LINE> task_key_stub = "{student}_{entranceexam}"...
Encode usage_key and optional student into task_key and task_input values. Args: usage_key (Location): The usage_key identifying the entrance exam. student (User): the student affected
625941f163d6d428bbe44ab5
def test_construction_discrete_data(self): <NEW_LINE> <INDENT> x = np.linspace(0, 10, 101) <NEW_LINE> y = np.linspace(0, 10, 101) <NEW_LINE> f = Function(xdata=x, ydata=y) <NEW_LINE> self.assertTrue(np.allclose(f.domain, np.array([0.0, 10.0]), atol=1e-15)) <NEW_LINE> self.assertEqual(len(f), 2)
Test Constuction with discrete x and y data
625941f1187af65679ca56e4
def calculateChecksum(buffer, offset): <NEW_LINE> <INDENT> sum = 0 <NEW_LINE> for x in range(len(buffer)-offset): <NEW_LINE> <INDENT> sum += struct.unpack_from("b", buffer, x)[0] & 0xFF <NEW_LINE> <DEDENT> return sum
Calculates the checksum. This should be called after pack(). The checksum sums all bytes in the packet between 0 and buf.limit() - CHECKSUM_SIZE.
625941f16aa9bd52df03736c
def DescribeResourceList(self, request): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> params = request._serialize() <NEW_LINE> body = self.call("DescribeResourceList", params) <NEW_LINE> response = json.loads(body) <NEW_LINE> if "Error" not in response["Response"]: <NEW_LINE> <INDENT> model = models.DescribeResourceLis...
This API is used to get the resource list. :param request: Request instance for DescribeResourceList. :type request: :class:`tencentcloud.dayu.v20180709.models.DescribeResourceListRequest` :rtype: :class:`tencentcloud.dayu.v20180709.models.DescribeResourceListResponse`
625941f1f548e778e58cdb44
def prof_core(self): <NEW_LINE> <INDENT> prof_count = self.opts['slow_prof_count']//2 <NEW_LINE> for h in (True, False): <NEW_LINE> <INDENT> H = c_int(1) if h else c_int(0) <NEW_LINE> for out, in_, k, c in randargs(prof_count, [c_ubyte, 2**7], [c_ubyte, 2**7], [c_ubyte, 2**7], [c_ubyte, 2**7]): <NEW_LINE> <INDENT> OUT ...
test core functions
625941f1cdde0d52a9e535fc
def balance(self): <NEW_LINE> <INDENT> d = self._post(self._build_payload(BALANCE)) <NEW_LINE> d.addCallback(treq.text_content) <NEW_LINE> return d
Send post request for balance Return deferred
625941f110dbd63aa1bd3166
def getgoal(path, opts=None): <NEW_LINE> <INDENT> cmd = 'mfsgetgoal' <NEW_LINE> ret = {} <NEW_LINE> if opts: <NEW_LINE> <INDENT> cmd += ' -' + opts <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> opts = '' <NEW_LINE> <DEDENT> cmd += ' ' + path <NEW_LINE> out = __salt__['cmd.run_all'](cmd) <NEW_LINE> output = out['stdout'...
Return goal(s) for a file or directory CLI Example:: salt '*' moosefs.getgoal /path/to/file [-[n][h|H]] salt '*' moosefs.getgoal /path/to/dir/ [-[n][h|H][r]]
625941f15fdd1c0f98dc07f9
def _off(self): <NEW_LINE> <INDENT> pass
Turn off vision processing if it is running. To be set from outside (eg. by Vision Manager).
625941f18a43f66fc4b54623
def main(stdscr, serial_thread): <NEW_LINE> <INDENT> curses.noecho() <NEW_LINE> curses.cbreak() <NEW_LINE> stdscr.nodelay(True) <NEW_LINE> win = init_window(stdscr) <NEW_LINE> while True: <NEW_LINE> <INDENT> if should_redraw.is_set(): <NEW_LINE> <INDENT> max_y, max_x = win.getmaxyx() <NEW_LINE> column_width = 50 <NEW_L...
Main function displaying the UI.
625941f1be7bc26dc91cdbb9
def is_visible(self, files): <NEW_LINE> <INDENT> for f in files: <NEW_LINE> <INDENT> p = os.path.dirname(f) <NEW_LINE> if os.path.basename(p) == "aura": <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> p = os.path.dirname(p) <NEW_LINE> if os.path.basename(p) == "aura": <NEW_LINE> <INDENT> r...
Sample doc string.
625941f13317a56b8693a20d
def GetByteOrderAsString(self): <NEW_LINE> <INDENT> return _btk.btkEMxFileIO_GetByteOrderAsString(self)
GetByteOrderAsString(self) -> std::string Gets the byte order as a string.
625941f1ff9c53063f47c7b4
def genDataNormal(mu1, sigma1, mu2, sigma2, num_data_pts): <NEW_LINE> <INDENT> week_1 = [] <NEW_LINE> week_2 = [] <NEW_LINE> week_1_params = [mu1, sigma1] <NEW_LINE> week_2_params = [mu2, sigma2] <NEW_LINE> for i in range(num_data_pts): <NEW_LINE> <INDENT> numHelped = week_1_params <NEW_LINE> crowd = week_1_params <NEW...
mu1: the mean of the first method. sigma1: the sigma of the first method. mu2: the mean of the second method. sigma2: the sigma of the second method. num_data_pts: the sample size of each week. Returns a tuple-- the first item is the data for the first week, and the second item is the data for the second week.
625941f132920d7e50b28799
def utility(self, state_node): <NEW_LINE> <INDENT> total = 0 <NEW_LINE> agent = Othello_logic.WHITE <NEW_LINE> player = Othello_logic.BLACK <NEW_LINE> features = Heuristic.Features(state_node, agent) <NEW_LINE> feature_list = features.get_features() <NEW_LINE> for i in range(0, NUM_OF_FEATURES): <NEW_LINE> <INDENT> tot...
Evaluates the utility of given state according to features
625941f1e5267d203edce259
def __call__(self, target, cred, enforcer): <NEW_LINE> <INDENT> for rule in self.rules: <NEW_LINE> <INDENT> if not rule(target, cred, enforcer): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> return True
Check the policy. Requires that all rules accept in order to return True.
625941f199cbb53fe67931a8
def _default_structure(self, release): <NEW_LINE> <INDENT> if release.build.procfile and 'web' in release.build.procfile: <NEW_LINE> <INDENT> structure = {'web': 1} <NEW_LINE> <DEDENT> elif not release.build.sha: <NEW_LINE> <INDENT> structure = {'cmd': 1} <NEW_LINE> <DEDENT> elif release.build.dockerfile: <NEW_LINE> <I...
Scale to default structure based on release type
625941f1fbf16365ca6f6795
def test_post_me_not_allowed(self): <NEW_LINE> <INDENT> res = self.client.post(ME_URL, {}) <NEW_LINE> self.assertEqual(res.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
Test POST not allowed on the me url
625941f19f2886367277ae4c
def number_of_automorphisms(self, recompute=None): <NEW_LINE> <INDENT> if recompute is not None: <NEW_LINE> <INDENT> from sage.misc.superseded import deprecation <NEW_LINE> deprecation(6326, "the 'recompute' argument is no longer used") <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> return self.__number_of_automorphisms ...
Return a list of the number of automorphisms (of det 1 and -1) of the quadratic form. OUTPUT: an integer >= 2. EXAMPLES:: sage: Q = QuadraticForm(ZZ, 3, [1, 0, 0, 1, 0, 1], unsafe_initialization=True) sage: Q.number_of_automorphisms() 48 :: sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1,1]) sag...
625941f1a17c0f6771cbe613
@public <NEW_LINE> def assemble_partfrac_list(partial_list): <NEW_LINE> <INDENT> common = partial_list[0] <NEW_LINE> polypart = partial_list[1] <NEW_LINE> pfd = polypart.as_expr() <NEW_LINE> for r, nf, df, ex in partial_list[2]: <NEW_LINE> <INDENT> if isinstance(r, Poly): <NEW_LINE> <INDENT> an, nu = nf.variables, nf.e...
Reassemble a full partial fraction decomposition from a structured result obtained by the function ``apart_list``. Examples ======== This example is taken from Bronstein's original paper: >>> from sympy.polys.partfrac import apart_list, assemble_partfrac_list >>> from sympy.abc import x, y >>> f = 36 / (x**5 - 2*x*...
625941f17d847024c06be885
def P(self): <NEW_LINE> <INDENT> if self.data.minute == 0 and self.data.hour == 0: <NEW_LINE> <INDENT> return 'midnight' <NEW_LINE> <DEDENT> if self.data.minute == 0 and self.data.hour == 12: <NEW_LINE> <INDENT> return 'noon' <NEW_LINE> <DEDENT> return '%s %s' % (self.f(), self.a())
Time, in 12-hour hours, minutes and 'a.m.'/'p.m.', with minutes left off if they're zero and the strings 'midnight' and 'noon' if appropriate. Examples: '1 a.m.', '1:30 p.m.', 'midnight', 'noon', '12:30 p.m.' Proprietary extension.
625941f157b8e32f52483a63
def normalize_record(record): <NEW_LINE> <INDENT> assert type(record) is dict <NEW_LINE> tmp = load_ns(record, leaf_processor=lambda value: type(value) is str and value.lower() or value) <NEW_LINE> record = dump_ns(tmp) <NEW_LINE> return dict(DEFAULT_FIELDS.items() + record.items())
return a record with normalized fields
625941f129b78933be1e5c69
def execute_cli_str(cli_str: str): <NEW_LINE> <INDENT> os.system(cli_str)
Simple function to execute a cli_str. Kept separate primarily to ease testing. Args: cli_str: A string that can be parsed by a cli/bash. Returns: None
625941f18c0ade5d55d3ef84
def instance_for_line(self, line): <NEW_LINE> <INDENT> conclusion = self.lines[line].conclusion <NEW_LINE> assumptions = [self.lines[assLine].conclusion for assLine in self.lines[line].justification] <NEW_LINE> return InferenceRule(assumptions, conclusion)
Return the instantiated inference rule that corresponds to the given line number
625941f1e5267d203edce25a
def get_classifiers(n=0): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if isinstance(n, int): <NEW_LINE> <INDENT> if (n < 0): <NEW_LINE> <INDENT> classifiers = [("Nearest Neighbors", KNeighborsClassifier(3))] <NEW_LINE> <DEDENT> elif (n == 0): <NEW_LINE> <INDENT> this_file_path = '/'.join(__file__.split('/')[:-1]) <NEW...
********* Description ********* Return a list of classifiers, bigger or smaller depending of the value of n ********* Params ********* n : (int) or (str) = 0 : instructions over the classifiers to return : - if n is negative, it returns only one classifiern - if n is zero (default value), it returns one classifier o...
625941f126238365f5f0f43a
def programa_servidor(): <NEW_LINE> <INDENT> host = socket.gethostname() <NEW_LINE> porta = 5000 <NEW_LINE> socket_servidor = socket.socket() <NEW_LINE> socket_servidor.bind((host, porta)) <NEW_LINE> socket_servidor.listen() <NEW_LINE> conexao, endereco = socket_servidor.accept() <NEW_LINE> print("Conexão efetuada com ...
Função para abrir o programa do servidor
625941f1287bf620b61d4024
def log_message(self, msg, *args, **kwargs): <NEW_LINE> <INDENT> self._log(MESSAGE, msg, *args, **kwargs)
Use to call a message that should always print.
625941f12eb69b55b151ce7c
def get_test_ref_out_pair(self, dataset: DatasetBase, set_type: str='test'): <NEW_LINE> <INDENT> ref_lst = [SequenceClassificationModel.__to_list(index)[0] for index in self.get_test_ref_labels(dataset, set_type)] <NEW_LINE> return ref_lst, self.get_test_out_labels(dataset, set_type)
Get Reference and output pair for the selected test set
625941f156ac1b37e6264788
def connect(self, ro=True): <NEW_LINE> <INDENT> assert self.qemu_nbd is not None, "qemu-nbd command not found" <NEW_LINE> devs = self._list_devices() <NEW_LINE> if not devs: <NEW_LINE> <INDENT> self.modprobe('nbd', 'max_part=16') <NEW_LINE> time.sleep(1) <NEW_LINE> devs = self._list_devices() <NEW_LINE> if not devs: <N...
Connect the image to a free NBD device
625941f1a8370b7717052e62
def is_leap_year(year): <NEW_LINE> <INDENT> return divisible(year, 4) and not divisible(year, 100) or divisible(year, 400)
Returns True if year is a leap year. A year is a leap year if it is divisible by 4, unless it is divisible by 100, unless it is also divisible by 400.
625941f17c178a314d6efa2e
def configure(logdir, flush_secs=2): <NEW_LINE> <INDENT> global _default_logger <NEW_LINE> if _default_logger is not None: <NEW_LINE> <INDENT> raise ValueError('default logger already configured') <NEW_LINE> <DEDENT> _default_logger = Logger(logdir, flush_secs=flush_secs)
Configure logging: a file will be written to logdir, and flushed every flush_secs.
625941f15e10d32532c5f4e9
def _refreshAnomalyParams(self, engine, metricID, statsSampleCache, consumedSamples, defaultAnomalyParams): <NEW_LINE> <INDENT> if statsSampleCache is None: <NEW_LINE> <INDENT> tail = self._tailMetricDataWithRawAnomalyScoresIter( engine, metricID, max(0, self._statisticsSampleSize - len(consumedSamples))) <NEW_LINE> st...
Refresh anomaly likelihood parameters from the tail of statsSampleCache and consumedSamples up to self._statisticsSampleSize. Update statsSampleCache, including initializing from metric_data table, if needed, and appending of consumedSamples content. :param engine: SQLAlchemy engine object :type engine: sqlalchemy.en...
625941f14f88993c3716c625
def test_ed_002(self): <NEW_LINE> <INDENT> global signal <NEW_LINE> th = 0.8 <NEW_LINE> wd = WaveformDecision(th) <NEW_LINE> self.assertEqual(th, wd.threshold) <NEW_LINE> arr = [1] * 1024 <NEW_LINE> dec = wd.decision(np.array(arr)) <NEW_LINE> dec = (0, 0) <NEW_LINE> self.assertEqual((0, 0.0), dec)
Test Waveform threshold.
625941f2d58c6744b4258222
def read_data(infname): <NEW_LINE> <INDENT> with open(infname, 'rt', encoding='utf-8') as inf: <NEW_LINE> <INDENT> csvrd = csv.reader(inf) <NEW_LINE> for line in csvrd: <NEW_LINE> <INDENT> yield line
入力データ(csv)を読む
625941f2ec188e330fd5ad57
def enumerate_geneclust_output(cellpopdf, degdf, gene_count=False, outfilename=None, k=None, logscale=None, fc_range=None, method="ward", dist="euclidean"): <NEW_LINE> <INDENT> lod = [] <NEW_LINE> fc_range.sort() <NEW_LINE> for fc_lim in fc_range: <NEW_LINE> <INDENT> outerdict = defaultdict(list) <NEW_LIN...
Enumerate all the gene cluster cell population score given the range of fold change threshold. :param cellpopdf: Cell population data frame. :param degdf: DEGs data frame. :param fc_range: list of floats, range of fold change :param logscale: boolean, transform fold change to logscale. This does n...
625941f271ff763f4b549c5b
def serialize_config(config): <NEW_LINE> <INDENT> keys = sorted(config.keys()) <NEW_LINE> assert keys == sorted(make_config().keys()) <NEW_LINE> return '-'.join(str(int(config[key])) for key in keys)
Serialize a config dict to a short string for use in filenames.
625941f23346ee7daa2b3336
def add_utf8info(self, string, length): <NEW_LINE> <INDENT> index = self.get_utf8info_index(string, length) <NEW_LINE> if index > 0: <NEW_LINE> <INDENT> return index <NEW_LINE> <DEDENT> utf8 = Utf8Info() <NEW_LINE> utf8.length = length <NEW_LINE> utf8.bytes = bytes(string, 'utf-8') <NEW_LINE> self._count += 1 <NEW_LINE...
Adds a new Utf8Info entry in the constant pool in case one with the same value does not already exist
625941f28da39b475bd65540
def get_level_name(level): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return _level_names[level] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> raise LookupError('unknown level')
Return the textual representation of logging level 'level'.
625941f23d592f4c4ed1d622
def searchMatrix(self, matrix: List[List[int]], target: int) -> bool: <NEW_LINE> <INDENT> if not matrix: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> m = len(matrix) <NEW_LINE> n = len(matrix[0]) <NEW_LINE> row = m - 1 <NEW_LINE> col = 0 <NEW_LINE> while row >= 0 and col <= n - 1: <NEW_LINE> <INDENT> if matrix[...
左下角的元素是这一行中最小的元素,同时又是这一列中最大的元素。比较左下角元素和目标: 若左下角元素等于目标,则找到 若左下角元素大于目标,则目标不可能存在于当前矩阵的最后一行,问题规模可以减小为在去掉最后一行的子矩阵中寻找目标 若左下角元素小于目标,则目标不可能存在于当前矩阵的第一列,问题规模可以减小为在去掉第一列的子矩阵中寻找目标 若最后矩阵减小为空,则说明不存在
625941f2283ffb24f3c55ebf
def _pairing_five(self, client_username, client_ltpk, encryption_key): <NEW_LINE> <INDENT> logger.debug("Pairing [5/5]") <NEW_LINE> session_key = self.accessory_handler.srp_verifier.get_session_key() <NEW_LINE> output_key = hap_hkdf(long_to_bytes(session_key), self.PAIRING_5_SALT, self.PAIRING_5_INFO) <NEW_LINE> server...
At that point we know the client has the accessory password and has a valid key pair. Add it as a pair and send a sever proof. Parameters are as for _pairing_four.
625941f221bff66bcd684f12
def save_model(model, file, name, gamemode = None): <NEW_LINE> <INDENT> if gamemode == "multi_2": <NEW_LINE> <INDENT> model.save_weights( "data/" + file + "/training_pool/model_" + name + ".h5") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> model.save_weights( "data/" + file + "/model_" + name + ".h5") <NEW_LINE> <DEDE...
saves model structure to json and weights to h5 file
625941f207f4c71912b11a4a
def transform_url_to_helpdb(self, in_text, ): <NEW_LINE> <INDENT> lines0 = in_text.split("\n") <NEW_LINE> if len(lines0) < 2: <NEW_LINE> <INDENT> return (False, "not", "2 short") <NEW_LINE> <DEDENT> lines1 = [] <NEW_LINE> for i_line in lines0: <NEW_LINE> <INDENT> line = i_line.strip() <NEW_LINE> if line != "": <NEW_LIN...
now links to add *>url make output something like: Hot bed Module High Power MOS Tube Module with Cable Tube Add on Heated Bed Power Expansion Module-in Integrated Circuits from Electronic Components & Supplies on Aliexpress.com | Alibaba Group *>url https://www.aliexpress.com/item/S
625941f2d7e4931a7ee9e4e4
def submodule(self, name: str) -> 'IterableList': <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return self.submodules[name] <NEW_LINE> <DEDENT> except IndexError as e: <NEW_LINE> <INDENT> raise ValueError("Didn't find submodule named %r" % name) from e
:return: Submodule with the given name :raise ValueError: If no such submodule exists
625941f25fcc89381b1e1c89
def _to_xml_tree_from_string(self, xml: str): <NEW_LINE> <INDENT> tree = etree.parse(StringIO(xml)) <NEW_LINE> return tree.getroot()
Xml string to internal representation method.
625941f24a966d76dd5515db
def ice(self): <NEW_LINE> <INDENT> query = AccountingIcetray.objects.filter( db_owner__iexact=self.db_owner, db_currency__iexact=self.db_currency ) <NEW_LINE> output = [] <NEW_LINE> for entry in query: <NEW_LINE> <INDENT> output.append(entry.as_list("date", "owner", "value", "currency", "reason", "origin")) <NEW_LINE> ...
Display all log entries for the owner.
625941f2cad5886f8bd2759d
def _writedata_internal(self, fileobj): <NEW_LINE> <INDENT> if not fileobj.simulateonly: <NEW_LINE> <INDENT> fileobj.writearray(self.data) <NEW_LINE> <DEDENT> return self.data.size * self.data.itemsize
The beginning and end of most _writedata() implementations are the same, but the details of writing the data array itself can vary between HDU types, so that should be implemented in this method. Should return the size in bytes of the data written.
625941f2de87d2750b86035e
def datasetName(self): <NEW_LINE> <INDENT> return self.data[0]
Get dataset name.
625941f2656771135c3ebe3b
def get_cache_type(self, cache_name): <NEW_LINE> <INDENT> cache_name_hash = self._java_hash_code(cache_name) <NEW_LINE> self.write_int(25) <NEW_LINE> self.write_short(2000) <NEW_LINE> self.write_long(0) <NEW_LINE> self.write_int(cache_name_hash) <NEW_LINE> self.write_byte(0) <NEW_LINE> self.write_byte(101) <NEW_LINE> s...
Collects type information about objects stored in the specified cache.
625941f2e8904600ed9f24fc
def test_hapd_ctrl_set_accept_mac_file(dev, apdev): <NEW_LINE> <INDENT> ssid = "hapd-ctrl" <NEW_LINE> params = { "ssid": ssid } <NEW_LINE> hapd = hostapd.add_ap(apdev[0]['ifname'], params) <NEW_LINE> dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") <NEW_LINE> dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412...
hostapd and SET accept_mac_file ctrl_iface command
625941f260cbc95b062c6b09
def all(self): <NEW_LINE> <INDENT> return self.db.zrangebyscore(REDIS_KEY, MIN_SCORE, MAX_SCORE)
按分数排序返回所有代理 :return:
625941f2287bf620b61d4025
def translate(self, vec): <NEW_LINE> <INDENT> l = deepcopy(self) <NEW_LINE> l.p1 = l.p1.translate(vec) <NEW_LINE> l.p2 = l.p2.translate(vec) <NEW_LINE> return l
Translate a linesegment by vec.
625941f23617ad0b5ed684bb
def get_spherical_model() -> EarthEllipsoidModel: <NEW_LINE> <INDENT> average_rad = 6371.302e3 <NEW_LINE> return EarthEllipsoidModel(average_rad, average_rad)
Возвращает сферическую модель земли
625941f27b180e01f3dc4db5
def move_prev_char(text, start_offs, end_offs): <NEW_LINE> <INDENT> assert start_offs < end_offs <NEW_LINE> if isinstance(text, unicode): <NEW_LINE> <INDENT> return end_offs - 1 <NEW_LINE> <DEDENT> assert isinstance(text, bytes) <NEW_LINE> if _byte_encoding == "utf8": <NEW_LINE> <INDENT> o = end_offs - 1 <NEW_LINE> whi...
Return the position of the character before end_offs.
625941f2d164cc6175783314
def tokenizeOligo(oligo, settings): <NEW_LINE> <INDENT> token_list = [] <NEW_LINE> min_staple_leg_len = settings.get('minStapleLegLen', 2) <NEW_LINE> min_staple_len = settings.get('minStapleLen', 30) <NEW_LINE> min_staple_len_minus_one = min_staple_len - 1 <NEW_LINE> max_staple_len = settings.get('maxStapleLen', 40) <N...
Split the oligo into sub-tokens. Strands with insertions are not tokenized and their full length is added.
625941f2aad79263cf39100f
def _listVirtualBoxVMsSlot(self): <NEW_LINE> <INDENT> QtWidgets.QMessageBox.warning(self, "GNS3 VM on VirtualBox", "VirtualBox doesn't support nested virtualization, this means running Qemu based VM could be very slow") <NEW_LINE> self._refreshVMListSlot()
Slot to refresh the VirtualBox VMs list.
625941f20c0af96317bb87ac
def email(): <NEW_LINE> <INDENT> return Suppress('@@@').setParseAction(tag(type='email'))
Returns an email field parser. Example:: @@@
625941f2d8ef3951e3243b03
def __pow__(self, exponent): <NEW_LINE> <INDENT> m = self.copy() <NEW_LINE> for i in range(exponent-1): <NEW_LINE> <INDENT> m *= self.copy() <NEW_LINE> <DEDENT> return m
Returns: M_a ** exponent as new instance
625941f2b830903b967e9ec9
def __str__(self): <NEW_LINE> <INDENT> return self.email
Django to print this or to string
625941f2b7558d58953c54cc
def main(argv: List[str]) -> None: <NEW_LINE> <INDENT> args = parse_args(argv) <NEW_LINE> with open_gravity() as conn: <NEW_LINE> <INDENT> groups = get_group_names(conn) <NEW_LINE> group_ids = set() <NEW_LINE> for g in args.g: <NEW_LINE> <INDENT> if g not in groups: <NEW_LINE> <INDENT> print(f"{g} is not a valid group ...
Main function for `update_group` Arguments: argv (list[str]): Args from command-line
625941f2a17c0f6771cbe614
def injectBackproject(self, injection): <NEW_LINE> <INDENT> outlayer = self.getOutputLayer() <NEW_LINE> outlayer.outputbuffer[self.network.offset - 1][:] = injection
Injects a vector into the recurrent connection. This will be used in the evolino trainingsphase, where the target values need to be backprojected instead of the real output of the net. :key injection: vector of length self.network.outdim
625941f2796e427e537b0b90
def get_indices(array, target): <NEW_LINE> <INDENT> complements = {} <NEW_LINE> for idx, value in enumerate(array): <NEW_LINE> <INDENT> if value in complements: <NEW_LINE> <INDENT> return [complements[value], idx] <NEW_LINE> <DEDENT> complements[target - value] = idx
Find two numbers from `array` which add up to `target`. Args: array (List[int]): The list of numbers. target (int): The target sum. Example: >>> get_indices([2, 7, 11, 15], 9) [0, 1]
625941f2377c676e9127276c
def test_has_suggestion(self): <NEW_LINE> <INDENT> form = EventForm(group=self.group, instance=self.event).forms['obj'] <NEW_LINE> Suggestion.objects.create( event=self.event, from_date=now(), to_date=now()) <NEW_LINE> self.assertIn('suggestion', form.fields) <NEW_LINE> num_suggestion = len(form.fields['suggestion'].qu...
Should have suggestion field in form if instance given
625941f2ad47b63b2c50a545
def prepare_samples(self, X, sent_maxlen): <NEW_LINE> <INDENT> X_words = encoder.sentence_to_index(X, self.word2index, self.pre_word, sent_maxlen, self.sent_noise_proba) <NEW_LINE> out = X_words <NEW_LINE> if self.char_embed: <NEW_LINE> <INDENT> ce = self.char_embed <NEW_LINE> X_chars = encoder.sentence_to_characters(X...
Prepare samples to be classified by the model. :param X: List of sentences, where each sentence is a list of words :return W or [W, C]: where W are the word embeddings and C the char embeddings matrices (if applicable)
625941f27cff6e4e81117f4b
def New(*args, **kargs): <NEW_LINE> <INDENT> obj = itkBSplineInterpolateImageFunctionIF2DF.__New_orig__() <NEW_LINE> import itkTemplate <NEW_LINE> itkTemplate.New(obj, *args, **kargs) <NEW_LINE> return obj
New() -> itkBSplineInterpolateImageFunctionIF2DF Create a new object of the class itkBSplineInterpolateImageFunctionIF2DF 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 new objects - the first ...
625941f2d486a94d0b98e70c
@cp.route('/samples', methods=['GET']) <NEW_LINE> def get_samples(): <NEW_LINE> <INDENT> return ApiPagedResponse(Sample.query.filter_by(user_id=g.user.id))
Return a paginated list of samples **Example request**: .. sourcecode:: http GET /api/1.0/samples?page=1 HTTP/1.1 Host: cp.cert.europa.eu Accept: application/json **Example response**: .. sourcecode:: http HTTP/1.0 200 OK Content-Type: application/json Link: <.../api/1.0/samples?page=1&per...
625941f2c432627299f05210
def perform_create(self, serializer): <NEW_LINE> <INDENT> serializer.save(user=self.request.user)
After validation with other fields, simply adds user when saving to dbase table
625941f226068e7796caf2ad
def __init__(self, x=0, y=0): <NEW_LINE> <INDENT> self.x = x <NEW_LINE> self.y = y
Initialize a GameObject with a position. Args: x(int): Initial x position of object. y(int): Initial y position of object.
625941f294891a1f4081c072
def count_entries(df, col_name): <NEW_LINE> <INDENT> langs_count = {} <NEW_LINE> if col_name not in df.columns: <NEW_LINE> <INDENT> raise ValueError('The DataFrame does not have a ' + col_name + ' column.') <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> col = df[col_name] <NEW_LINE> for entry in col: <NEW_LINE> <INDENT> ...
Return a dictionary with counts of occurrences as value for each key.
625941f2b7558d58953c54cd
def create_topic(self): <NEW_LINE> <INDENT> template = self.template <NEW_LINE> pagerdutyalert = template.add_resource( sns.Topic( 'Topic' ) ) <NEW_LINE> template.add_output( Output( "%sARN" % pagerdutyalert.title, Description='SNS topic', Value=Ref(pagerdutyalert) ) )
Sets up the SNS topic.
625941f2de87d2750b86035f
def __enter__(self): <NEW_LINE> <INDENT> if ClientSession.count == 0: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> SpssClient.StartClient() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> raise RuntimeError(_("SpssClient.StartClient failed.")) <NEW_LINE> <DEDENT> <DEDENT> ClientSession.count += 1 <NEW_LINE> return self
initialization for with statement
625941f24e696a04525c9a13
def predict(self, X): <NEW_LINE> <INDENT> fc1_out=self.fc1.forward(X) <NEW_LINE> relu1_out=self.relu1.forward(fc1_out) <NEW_LINE> fc2_out=self.fc2.forward(relu1_out) <NEW_LINE> relu2_out=self.relu2.forward(fc2_out) <NEW_LINE> output = fc2_out <NEW_LINE> pred=np.argmax(output,axis=1) <NEW_LINE> return pred
Produces classifier predictions on the set Arguments: X, np array (test_samples, num_features) Returns: y_pred, np.array of int (test_samples)
625941f2a79ad161976cc70b
def birth_before_death(self): <NEW_LINE> <INDENT> query = "select INDI, NAME, BIRT, DEAT from indi" <NEW_LINE> for row in self.query_info(query): <NEW_LINE> <INDENT> birth = row[2] <NEW_LINE> death = row[3] <NEW_LINE> if not self.date_before(birth, death): <NEW_LINE> <INDENT> print("ERROR: US03: Birth {} occurs after d...
US03 - Birth before death :rtype: None
625941f263f4b57ef00016cd
def start_new_curve(self) -> int: <NEW_LINE> <INDENT> if self._fig is None: <NEW_LINE> <INDENT> self.reset() <NEW_LINE> <DEDENT> self._curve_ids.append(self._next_curve_id) <NEW_LINE> self._last_points[self._next_curve_id] = (0, 0) <NEW_LINE> self._next_curve_id += 1 <NEW_LINE> return self._next_curve_id - 1
Start a new curve and retrieve its handle. :return: handle to the new curve, needed to append further points
625941f20fa83653e465757d