code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def requestSelfInfo(self): <NEW_LINE> <INDENT> d = defer.Deferred() <NEW_LINE> self.sendSNAC(0x01, 0x0E, '').addCallback(self._cbRequestSelfInfo, d) <NEW_LINE> return d
ask for the OSCARUser for ourselves
625941d921a7993f00bc7f94
def wait_for_shutdown(self): <NEW_LINE> <INDENT> wait_thread = threading.Thread(target=self.process.wait) <NEW_LINE> self.logger.pr('waiting for client %d to shutdown' % self.client_id) <NEW_LINE> wait_thread.start() <NEW_LINE> wait_thread.join(CLIENT_TIMEOUT) <NEW_LINE> if wait_thread.isAlive(): <NEW_LINE> <INDENT> se...
Block until a client has shutdown. Typically called automatically by shutdown() or start_or_restart(). Shutdown should previously have been initiated by queuing a 'shutdown' or 'restart' request. Waits CLIENT_TIMEOUT for graceful shutdown. If client is still alive, a SIGTERM signal is sent. If this has had no effect ...
625941d960cbc95b062c67e4
def write_latex_stream(latex_stream, latex): <NEW_LINE> <INDENT> latex_stream.write(f"{latex} ")
Write to the LaTeX stream.
625941d9de87d2750b860036
def test_local_receive_call(self): <NEW_LINE> <INDENT> cost = self.network.calculate_operator_cost('on_network_receive', 'call') <NEW_LINE> self.assertEqual(0, cost)
Local receive calls should cost the default.
625941d97b180e01f3dc4a9a
def assertReactivateEmailSent(self, email_user): <NEW_LINE> <INDENT> context = { 'name': self.user.profile.name, 'key': self.registration.activation_key } <NEW_LINE> self.assertEmailUser( email_user, 'emails/activation_email_subject.txt', context, 'emails/activation_email.txt', context )
Assert that the correct reactivation email has been sent
625941d9e76e3b2f99f3aaa9
def is_image_size_above(base64_source_1, base64_source_2): <NEW_LINE> <INDENT> if not base64_source_1 or not base64_source_2: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if base64_source_1[:1] in (b'P', 'P') or base64_source_2[:1] in (b'P', 'P'): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> image_sourc...
Return whether or not the size of the given image `base64_source_1` is above the size of the given image `base64_source_2`.
625941d9d18da76e23532779
def merge_inplace(nums1, m, nums2, n): <NEW_LINE> <INDENT> idx1, idx2, end = m-1, n-1, len(nums1)-1 <NEW_LINE> while (idx1 >= 0) and (idx2 >= 0): <NEW_LINE> <INDENT> if nums1[idx1] > nums2[idx2]: <NEW_LINE> <INDENT> nums1[end] = nums1[idx1] <NEW_LINE> idx1 -= 1 <NEW_LINE> <DEDENT> elif nums2[idx2] >= nums1[idx1]: <NEW_...
The idea is to populate from the end of nums1 in descending order while keeping track of two pointers that is traversing nums1 and num2 backwards. When either index finishes traversing, it becomes more managable to "merge" the two arrays. Compare nums1[m:-1:-1] to nums2[n:-1:-1] and move larger value to end of nums1
625941d9091ae356686671fc
def restrict(self, subdomain): <NEW_LINE> <INDENT> if subdomain == self._domain: <NEW_LINE> <INDENT> return self <NEW_LINE> <DEDENT> if subdomain not in self._restrictions: <NEW_LINE> <INDENT> if not subdomain.is_subset(self._domain): <NEW_LINE> <INDENT> raise ValueError("the provided domain is not a subdomain of " + "...
Return the restriction of the connection to some subdomain. If such restriction has not been defined yet, it is constructed here. INPUT: - ``subdomain`` -- open subset `U` of the connection's domain (must be an instance of :class:`~sage.manifolds.differentiable.manifold.DifferentiableManifold`) OUTPUT: - insta...
625941d9e8904600ed9f21d1
def checkPass(self, uid, password): <NEW_LINE> <INDENT> return False
This function checks the password for a given uid. - returns true in case of success - false if password does not match
625941d9f548e778e58cd820
def complette_col(plateau, colonne): <NEW_LINE> <INDENT> for i16 in range(len(plateau)): <NEW_LINE> <INDENT> if plateau[i16][colonne] != 1: <NEW_LINE> <INDENT> plateau[i16][colonne] = 2
complete les autres case par des croix lorsqu'une ligne remplit ses conditions :param plateau: liste de liste :param colonne: int donne le numero de la liste :return:
625941d9a8370b7717052b3f
def test_03(self): <NEW_LINE> <INDENT> tag = self.eth.pop_tag() <NEW_LINE> self.assertEqual(tag.get_buffer_as_string(), '\x81\x00\xac\xf3') <NEW_LINE> self.assertEqual(tag.get_tpid(), 0x8100) <NEW_LINE> self.assertEqual(tag.get_pcp(), 5) <NEW_LINE> self.assertEqual(tag.get_dei(), 0) <NEW_LINE> self.assertEqual(tag.get_...
Test EthernetTag getters
625941d94f88993c3716c307
def wrls(Phi, Y, alpha=2000, forget_factor=1, NRLS=20): <NEW_LINE> <INDENT> Phi, Y = extractTrainingSet(G) <NEW_LINE> M = Phi.shape[0] <NEW_LINE> N = Phi.shape[1] <NEW_LINE> thetahat = np.array([0.,0.]).T <NEW_LINE> P = alpha * np.identity(N) <NEW_LINE> for i in range(M * NRLS): <NEW_LINE> <INDENT> x = Phi[i%M, :] <NEW...
Weighted Recursive Least Squares
625941d96aa9bd52df037046
def invariant(self): <NEW_LINE> <INDENT> _ldns.ldns_buffer_invariant(self)
Performs no action. In debugging mode this method performs a buffer settings check. It asserts if something is wrong.
625941d963b5f9789fde7387
def __call__(self, *args): <NEW_LINE> <INDENT> c_args = args[1:3] <NEW_LINE> if c_args[0] == "connect": <NEW_LINE> <INDENT> tmp_dir = os.path.dirname(args[0].sql_path) <NEW_LINE> self.con = sqlite3.connect(join(tmp_dir, "pw.db")) <NEW_LINE> self.c = self.con.cursor() <NEW_LINE> self.c.execute("PRAGMA synchronous = OFF"...
Wraps the call of `func`. When the decorated method is called, this code is wrapped around its execution. It accepts an arbitrary number of positional arguments but is is currently designed to decorate the `_get_similarity` method of the `AlignmentList` class. There are three expected calling modes: 1. decorated_...
625941d921bff66bcd684bf1
def fusion(A,B,C,D): <NEW_LINE> <INDENT> res1=np.concatenate((A,B),axis=1) <NEW_LINE> res2=np.concatenate((C,D),axis=1) <NEW_LINE> return np.concatenate((res1,res2),axis=0)
Cette fonction fusionne les 4 matrices pour en faire une seule
625941d9e64d504609d74ae1
@cli.command("setattrs", short_help="Set a string attribute for a subscriber") <NEW_LINE> @click.option( "dbtname", "--dbtname", "-T", default="subscriber", help='Database table name (default: "subscriber")', ) <NEW_LINE> @click.argument("userid", metavar="<userid>") <NEW_LINE> @click.argument("attr", metavar="<attribu...
Set a string attribute a subscriber  Parameters: <userid> - username, AoR or SIP URI for subscriber <attribute> - the name of the attribute (column name in subscriber table) <value> - the value to be set for the attribute
625941d9bde94217f3683090
def _calc(x, y): <NEW_LINE> <INDENT> rvs_ = np.array(samples) <NEW_LINE> rvs_[:, dim_locs[j]:dim_locs[j + 1]] = x <NEW_LINE> rvs_[:, dim_locs[i]:dim_locs[i + 1]] = y <NEW_LINE> return np.mean(model.predict(rvs_))
Helper-function to calculate the average predicted objective value for the given model, when setting the index1'th dimension of the search-space to the value x and setting the index2'th dimension to the value y, and then averaging over all samples.
625941d907f4c71912b11725
def get_peaks_alt(data, *, threshold=1): <NEW_LINE> <INDENT> peaks_idx = [] <NEW_LINE> feature_peaks_mean = [] <NEW_LINE> for count, row in enumerate(data.T): <NEW_LINE> <INDENT> idx, _ = find_peaks(row, threshold) <NEW_LINE> peaks_idx.append(idx) <NEW_LINE> feature_peaks_mean.append(np.mean(idx)) <NEW_LINE> <DEDENT> f...
Alt getPeaks function (depr)
625941d9be8e80087fb20ee1
def image_mode(image): <NEW_LINE> <INDENT> mode = image.mode <NEW_LINE> return mode
Show mode of image is 'RGB' or 'RGBA' image: an Image object return: mode
625941d9d99f1b3c44c6782c
def cleanup(self): <NEW_LINE> <INDENT> GPIO.cleanup((self.red, self.green, self.blue))
cleans the GPIO pins
625941d9d6c5a102081442ee
def connection_lost(self): <NEW_LINE> <INDENT> pass
triggered when connection is lost
625941d956b00c62f0f148fc
def test_parse_get_log_w_time(self): <NEW_LINE> <INDENT> text = "90" <NEW_LINE> self.assertEqual(parse_webhook_text(text), "logs")
test parsing getting a log with time argument
625941d9566aa707497f4807
def p_multi_arg_tag(p): <NEW_LINE> <INDENT> args = p[4] <NEW_LINE> p[0] = OpenTag(p[2], "".join(raw(item) for item in p[1:]), **args.args)
opentag : LBRACKET SYMBOL WHITESPACE args RBRACKET
625941d93cc13d1c6d3c761b
def getKeyDown(self, keyName): <NEW_LINE> <INDENT> return PYGAME_KEY_MAP[keyName] in self._keysDown
Boolean: was the given key pressed this frame?
625941d999fddb7c1c9de632
def optimize(self, objectivefx): <NEW_LINE> <INDENT> self.optimizers[0].set_initial(self.get_initial()) <NEW_LINE> results = [] <NEW_LINE> for current, following in zip(self.optimizers[:-1], self.optimizers[1:]): <NEW_LINE> <INDENT> result = current.optimize(objectivefx) <NEW_LINE> results.append(result) <NEW_LINE> if ...
The StagedOptimizer overwrites the default behaviour of optimize(). It passes the best point of the previous stage to the next stage. If the optimization is interrupted or fails, this process stops and the OptimizeResult is returned.
625941d957b8e32f5248373e
def register_plugin(self): <NEW_LINE> <INDENT> self.focus_changed.connect(self.main.plugin_focus_changed) <NEW_LINE> self.main.add_dockwidget(self) <NEW_LINE> self.shell.exception_occurred.connect(self.exception_occurred)
Register plugin in Spyder's main window
625941d9cdde0d52a9e532d7
def test_public_item_editable_by_anon(self): <NEW_LINE> <INDENT> item = models.MediaItem.objects.get(id='emptyperm') <NEW_LINE> self.assert_user_cannot_edit(AnonymousUser(), item) <NEW_LINE> self.assert_user_cannot_edit(None, item) <NEW_LINE> item.channel.edit_permission.is_public = True <NEW_LINE> item.channel.edit_pe...
An item with public editable permissions is still not editable by anonymous.
625941d93317a56b86939ef5
def top(self): <NEW_LINE> <INDENT> if self.is_empty(): <NEW_LINE> <INDENT> raise Empty('Stack is empty') <NEW_LINE> <DEDENT> return self.head()
Return (but do not remove) the element at the top of the stack. Raise Empty exception if the stack is empty.
625941d97cff6e4e81117c27
def lemmatize(self, word): <NEW_LINE> <INDENT> return self.lemmatizer.lemmatize(word)
Lemmatize the given word
625941d9f8510a7c17cf999f
def generate_author_combinations(ambiguous_authors): <NEW_LINE> <INDENT> ambiguous_authors_list = list(ambiguous_authors) <NEW_LINE> pair_list = itertools.combinations(ambiguous_authors_list, 2) <NEW_LINE> return pair_list
Generates combinations for all author names Input: List of unique authors Output: List of tuples for author name combinations
625941d963d6d428bbe44791
def set(self, x, y): <NEW_LINE> <INDENT> if not self.is_legal(x, y): <NEW_LINE> <INDENT> raise ValueError("Coordinates {}, {} out of range 0..{}, 0..{}".format( x, y, self.xsize, self.ysize)) <NEW_LINE> <DEDENT> key = (x, y) <NEW_LINE> self.state.add(key)
Set a cell to the live state.
625941d9a219f33f34628c08
def _check_interface_output(output, link): <NEW_LINE> <INDENT> if 'not found' in output: <NEW_LINE> <INDENT> return ('%s not found' % link) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return True
Used to check the output from commands which target a specific interface name, validating the output before handing it off for further processing. Checks for empty return, or common errors such as interface not found
625941d95fdd1c0f98dc04d6
@check50.check(class_compiles) <NEW_LINE> def test_7(): <NEW_LINE> <INDENT> check50.run("java Grader 7").stdout("16, 11, 6, 1, -4\n10, 5, 0, -5", regex=False).exit(0)
pattern works
625941d915baa723493c4219
def drag_object_to_xy(self, locator, coord, options): <NEW_LINE> <INDENT> self._find(locator).drag.to(*coord, **options)
Drag a UI object to given coordinates xy UI object is specified by the locator. Args: locator (object): Locator object to locate the UI object which is to be dragged. coord (tuple): Destination coordinates (x, y) options (dict): Key-value pairs which contains optional parameters to uiautoma...
625941d9cc0a2c11143dd133
def intermediate_certificates(self): <NEW_LINE> <INDENT> return filter(None, [authority.current_certificate(required=False) for authority in self.chain() if authority.issuer_id is not None])
Returns a list of Certificates between us and our anchor.
625941d98e7ae83300e4b26f
def AddSitemap(self, site_uri, sitemap_uri, sitemap_type='WEB', uri=SITEMAPS_FEED_TEMPLATE, url_params=None, escape_params=True, converter=None): <NEW_LINE> <INDENT> sitemap_entry = webmastertools.SitemapsEntry( atom_id=atom.Id(text=sitemap_uri), category=atom.Category( scheme='http://schemas.google.com/g/2005#kind', t...
Adds a regular sitemap to a site. Args: site_uri: str URI of which site to add sitemap for. sitemap_uri: str URI of sitemap to add to a site. sitemap_type: str Type of added sitemap. Valid types: WEB, VIDEO, or CODE. uri: str (optional) URI template to add a sitemap. Default SITEMAP_FEED_TEMPLATE. ur...
625941d9d58c6744b4257f00
def test_conversions(self): <NEW_LINE> <INDENT> juju_str = FakeJuju( "/fake-juju", "1.25.6", "/x", "/y", Failures("/...")) <NEW_LINE> juju_unicode = FakeJuju( u"/fake-juju", u"1.25.6", u"/x", u"/y", Failures(u"/...")) <NEW_LINE> for name in ('filename version datadir logsdir'.split()): <NEW_LINE> <INDENT> self.assertIs...
FakeJuju() doesn't convert the type of any value.
625941d950485f2cf553d03d
def iterfiles(root=_globals.ROOT, *, progress_after: int = _tools.PROGRESS_AFTER ) -> typing.Iterator[FileInfo]: <NEW_LINE> <INDENT> root = _tools.path_from_filename(root).resolve() <NEW_LINE> log.info(f'start parsing {BASENAME} files from %r', root) <NEW_LINE> msg = f'%s {BASENAME} files parsed' <NEW_LINE> kwargs = {'...
Yield triples of ((<path_part>, ...), <ConfigParser object>, <DirEntry object>).
625941d95f7d997b87174d3c
def _create_engine(self): <NEW_LINE> <INDENT> db_path = os.path.abspath(os.path.join(self.folder, ".iris", "data.db")) <NEW_LINE> engine = create_engine(f"sqlite:///{db_path}") <NEW_LINE> self.session_maker = sessionmaker(bind=engine)
Sets up the SQLAlchemy engine and session manager
625941d9287bf620b61d3d04
def setup(self, y, m): <NEW_LINE> <INDENT> left = tk.Button(self.parent, text='<', command=self.go_prev) <NEW_LINE> self.wid.append(left) <NEW_LINE> left.grid(row=0, column=1) <NEW_LINE> header = tk.Label(self.parent, height=2, text='{} {}'.format(calendar.month_abbr[m], str(y)) ) <NEW_LINE> self.wid.append(header) <...
Method to create widgets inside calendar
625941d9460517430c394422
def txt_box(self, matplotlib_text): <NEW_LINE> <INDENT> size = matplotlib_text.get_size() <NEW_LINE> matplotlib_text.set_size(size*self.zoom_texte) <NEW_LINE> box = matplotlib_text.get_window_extent(self.get_renderer()) <NEW_LINE> matplotlib_text.set_size(size) <NEW_LINE> return box
Retourne l'espace (rectangulaire) occupé par le texte. Retourne un objet Bbox, possédant des attributs xmin, xmax, ymin, ymax, height et width. (En pixels).
625941d9a8ecb033257d336e
def test_company_no_color_change_logo(self): <NEW_LINE> <INDENT> self.company.write({ 'primary_color': False, 'secondary_color': False, 'logo': False, 'external_report_layout_id': self.env.ref('base.layout_template1').id, }) <NEW_LINE> default_colors = self.default_colors <NEW_LINE> with Form(self.env['base.document.la...
When neither a logo nor the colors are set The wizard displays the colors of the report layout Changing logo means the colors on the wizard change too Emptying the logo works and doesn't change the colors
625941d9796e427e537b086a
def getAction(self, state): <NEW_LINE> <INDENT> action = QLearningAgent.getAction(self,state) <NEW_LINE> self.doAction(state,action) <NEW_LINE> return action
Simplemente llama al metodo getAction ya implementado y luego informa al padre la accion para pacman, no cambie o quite este metodo
625941d9956e5f7376d7110e
def test_to_list(self): <NEW_LINE> <INDENT> result = Formatter.to_list(self.string_as_list) <NEW_LINE> self.assertEqual(result, self.correct)
Test string is properly split into list.
625941d9e8904600ed9f21d2
def test_device_detail(self): <NEW_LINE> <INDENT> url = '/devices/add/' <NEW_LINE> response = self.client.get(url) <NEW_LINE> self.assertEqual(response.status_code, 404) <NEW_LINE> self._add_device(self.device) <NEW_LINE> self.assertEqual(self.device, self._get_device(1)) <NEW_LINE> device = self._get_device(1) <NEW_LI...
Testing function for class devices/views/DeviceDetail
625941d96fb2d068a760f343
def before(self, p): <NEW_LINE> <INDENT> node = self._validate(p) <NEW_LINE> return self._make_position(node._prev)
Return Position just before Position p
625941d98da39b475bd65218
def _get_node_grouping(label_groups, orig_labels): <NEW_LINE> <INDENT> label_names = list() <NEW_LINE> for group in label_groups: <NEW_LINE> <INDENT> label_names += list(group.values())[0] <NEW_LINE> <DEDENT> lh_labels = [name + '-lh' for name in label_names if name + '-lh' in orig_labels] <NEW_LINE> rh_labels = [name ...
Bring the labels in the right order for the circular plot. Parameters: ----------- label_groups : list of dict Each element of the list contains a dict with a single cortical region and its labels. orig_labels : list Contains the names of all labels. Returns: -------- labels_ordered : list Contains th...
625941d9f8510a7c17cf99a0
def load_seds(self): <NEW_LINE> <INDENT> log.info("Loading the SEDs ...") <NEW_LINE> observed_sed_path = fs.join(this_dir_path, "DustPedia.dat") <NEW_LINE> sim_sed_path_1 = fs.join(this_dir_path, "M81_earth_sed1.dat") <NEW_LINE> sim_sed_path_2 = fs.join(this_dir_path, "M81_earth_sed2.dat") <NEW_LINE> mock_sed_path = fs...
This function ... :return:
625941d9e76e3b2f99f3aaaa
def header_required(response, name, get_headers, callback=do_nothing): <NEW_LINE> <INDENT> headers = get_headers(response) <NEW_LINE> if name not in headers: <NEW_LINE> <INDENT> callback() <NEW_LINE> raise exceptions.InvalidResponse( response, u'Response headers must contain header', name) <NEW_LINE> <DEDENT> return he...
Checks that a specific header is in a headers dictionary. Args: response (object): An HTTP response object, expected to have a ``headers`` attribute that is a ``Mapping[str, str]``. name (str): The name of a required header. get_headers (Callable[Any, Mapping[str, str]]): Helper to get headers ...
625941d9cc40096d61595bf2
def nltkprocess(text): <NEW_LINE> <INDENT> punct = set(string.punctuation) <NEW_LINE> tokenizer = WordPunctTokenizer() <NEW_LINE> new_text = [] <NEW_LINE> for token in (tokenizer.tokenize(text)): <NEW_LINE> <INDENT> token = token.lower() <NEW_LINE> if all(char in punct for char in token): <NEW_LINE> <INDENT> continue <...
:param text: give the raw text of each post :return: tokenize, lemmatize, remove stop words and punctuations
625941d9f9cc0f698b14089c
def getpostrequest(self, params, input_properties): <NEW_LINE> <INDENT> for section in params.keys(): <NEW_LINE> <INDENT> print("try connect %s" % params[section]) <NEW_LINE> conn = http.client.HTTPConnection(params[section]['url']) <NEW_LINE> print("Connected to url") <NEW_LINE> if params[section]['content_file'] and ...
Get the url and content and parse it and get the response and display :param params: :param input_properties: input and output location , debug position
625941d90fa83653e465725c
def set_up(self): <NEW_LINE> <INDENT> pass
test setup
625941d930bbd722463cc06b
def add_to_df(line): <NEW_LINE> <INDENT> regex = r'([(\d\.)]+) ([^ ]+) ([^ ]+) \[(.*?)\] "(.*?)" (\d+|-) (\d+|-) (?:"(.*?)" "(.*?)")' <NEW_LINE> match = re.match(regex, line) <NEW_LINE> if match: <NEW_LINE> <INDENT> parsed_line = match.groups() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return log.error(line) <NEW_L...
Add line to the dataframe
625941d966673b3332b92334
def parse_atom_string(self, code): <NEW_LINE> <INDENT> method_name = 'add_atom(' <NEW_LINE> parameter_start_ind = code.index(method_name) + len(method_name) <NEW_LINE> if parameter_start_ind < 0: <NEW_LINE> <INDENT> raise ValueError('Could not parse the code, add_atom method') <NEW_LINE> <DEDENT> code = code[parameter_...
Parses code and returns defined values in the object - note that the values are represented as strings. The code should be on the form: [XXXX].add_atom([parameter]=[value], ....) Parameters: code (string): A string that represent the construction of the object
625941d9442bda511e8be6b8
def get_recursive_archive_handler(path, destination_dir, type=None): <NEW_LINE> <INDENT> archive = get_archive_handler(path, type=type) <NEW_LINE> if archive is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> from mcomix.archive import archive_recursive <NEW_LINE> return archive_recursive.RecursiveArchive(arc...
Same as <get_archive_handler> but the handler will transparently handle archives within archives.
625941d95fc7496912cc3c20
def read_header(header): <NEW_LINE> <INDENT> request = str(header, "ASCII").split("\r\n", 1)[0] <NEW_LINE> request_headers = str(header, "ASCII").split("\r\n", 1)[1] <NEW_LINE> request_headers = message_from_string(request_headers) <NEW_LINE> request_headers = dict(request_headers) <NEW_LINE> request_headers["Method"] ...
Takes an HTTP request as a string and returns the headers as a dict.
625941d9fbf16365ca6f646a
def p_id_u(t): <NEW_LINE> <INDENT> t[0] = [t[1]]
idList : ID
625941d9b545ff76a89140b8
def test_sender_as_handler_static(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> engine_config = {"address": self.server, "port": self.port, "key": self.key, "cert": self.cert, "chain": self.chain, "check_hostname": False, "verify_mode": CERT_NONE} <NEW_LINE> con = Sender.for_logging(config=engine_config, tag=self...
Test that tries to check that Sender class can be used as a Handler through the static functions and related logs are send to remote server
625941d926238365f5f0f114
def test_ros_discovery_plugin_scan_invalid_badpath(): <NEW_LINE> <INDENT> rdp = RosDiscoveryPlugin() <NEW_LINE> package = Package( "invalid_package", os.path.join(os.path.dirname(__file__), "invalid_package") ) <NEW_LINE> os.environ["ROS_VERSION"] = "1" <NEW_LINE> rdp.scan(package, "level") <NEW_LINE> assert not packag...
Test the behavior when the ROS plugin scans a nonexistent directory.
625941d92ae34c7f2600d3d4
def testCallback(self, client_limit=None): <NEW_LINE> <INDENT> with hunts.GRRHunt.StartHunt( hunt_name="SampleHunt", regex_rules=[rdfvalue.ForemanAttributeRegex( attribute_name="GRR client", attribute_regex="GRR")], client_limit=client_limit, client_rate=0, token=self.token) as hunt: <NEW_LINE> <INDENT> hunt.GetRunner(...
Checks that the foreman uses the callback specified in the action.
625941d976d4e153a657edd5
def deleteURI(self): <NEW_LINE> <INDENT> return '/evaluation/%s' %self.id
TODO_Sphinx.
625941d93617ad0b5ed68199
def getSum(self, a, b): <NEW_LINE> <INDENT> carry = 0 <NEW_LINE> mask = 0xffffffff <NEW_LINE> while b & mask != 0: <NEW_LINE> <INDENT> carry = (a & b) << 1 <NEW_LINE> a = a ^ b <NEW_LINE> b = carry <NEW_LINE> <DEDENT> return a & mask if b > mask else a
:type a: int :type b: int :rtype: int
625941d9d10714528d5fff88
def isdefined(obj): <NEW_LINE> <INDENT> return obj in globals() or obj in locals()
isdefined obj is a string actually
625941d923e79379d52ee804
def errorbars(self, *args, **kwargs): <NEW_LINE> <INDENT> if len(args)==2: <NEW_LINE> <INDENT> kwargs.update(y=args[0]) <NEW_LINE> kwargs.update(errorbars=args[1]) <NEW_LINE> <DEDENT> elif len(args)==3: <NEW_LINE> <INDENT> kwargs.update(x=args[0]) <NEW_LINE> kwargs.update(y=args[1]) <NEW_LINE> kwargs.update(errorbars=a...
create and add an errordataitem errorbars(<xdata>, <ydata>, <error>, *kwargs) errorbars(<ydata>, <errors>, **kwargs) to assume x as an index errorbars(x=<xdata>, y=<ydata>, errorbars=<errors>, **kwargs) errorbars(Nx(2, 3), **kwargs) to unpack as x, y, yerr
625941d9d10714528d5fff89
def all(self, **kwargs): <NEW_LINE> <INDENT> return self.client.all(self.typ, **kwargs)
List all
625941d9be7bc26dc91cd89f
def get_type_code(type_name): <NEW_LINE> <INDENT> return tvm.runtime._ffi_api._datatype_get_type_code(type_name)
Get the type code of a custom datatype from its type name Note that this only works for custom datatypes registered with tvm.target.datatype.register(). It does not work for TVM-native types. Example: .. code-block:: python tvm.target.datatype.register('posites2', 130) assert tvm.target.datatype.get_type_co...
625941d973bcbd0ca4b2c319
def suite(): <NEW_LINE> <INDENT> suite = TestSuite() <NEW_LINE> suite.addTests(TestLoaderFiltered().loadTestsFromTestCase(TclModuleGeneratorTest, sys.argv[1:])) <NEW_LINE> suite.addTests(TestLoaderFiltered().loadTestsFromTestCase(LuaModuleGeneratorTest, sys.argv[1:])) <NEW_LINE> return suite
returns all the testcases in this module
625941d9d18da76e2353277b
def send_report(self, callingClass, callingMethod, callingUser='', callingRequest='', traceback='', subtitle='', xtra='', mail=None, sender=None): <NEW_LINE> <INDENT> mail = self.mail if not mail else mail <NEW_LINE> sender = self.sender if not sender else sender <NEW_LINE> title, body = self._build_message(callingClas...
Send an email reporting error and including debug info. The only arguments that are strictly necessary are callingClass and callingMethod which should be strings giving the names of the class and method in which the error occurred. The 'mail' argument is only necessary if a mailer object was not assigned earlier to s...
625941d9e76e3b2f99f3aaab
def is_six_connected_neighbor(coord_first, coord_second): <NEW_LINE> <INDENT> (x1, y1, z1) = coord_first <NEW_LINE> (x2, y2, z2) = coord_second <NEW_LINE> dist_x = abs(x2 - x1) <NEW_LINE> dist_y = abs(y2 - y1) <NEW_LINE> dist_z = abs(z2 - z1) <NEW_LINE> return dist_x + dist_y + dist_z == 1
Determines if the voxel with the second coordinates is a six-connected neighbor of the voxel with the first coordinates. Note: Assumes voxel coordinates are integers. :type coord_first: tuple[int] :param coord_first: first coordinate set :type coord_second: tuple[int] :param coord_second: second coordinate set :return:...
625941d94e4d5625662d4678
def evaluate(eval_data, eval_dir, model_dir, client): <NEW_LINE> <INDENT> FLAGS = parser.parse_args() <NEW_LINE> with tf.Graph().as_default() as g: <NEW_LINE> <INDENT> images, labels = cifar10.inputs(eval_data=eval_data, client=client) <NEW_LINE> logits = cifar10.inference(images) <NEW_LINE> predict = tf.argmax(logits...
Eval CIFAR-10 for a number of steps.
625941d9f548e778e58cd822
def __ne__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, V1StatefulSetUpdateStrategy): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return self.to_dict() != other.to_dict()
Returns true if both objects are not equal
625941d93346ee7daa2b3010
def transition(x,inchannels): <NEW_LINE> <INDENT> outchannels = int(inchannels*compressing) <NEW_LINE> x = bn_relu(x) <NEW_LINE> x = conv(x,outchannels,(1,1)) <NEW_LINE> x = AveragePooling2D((2,2),strides=(2,2))(x) <NEW_LINE> return x,outchannels
Parameters: x - 输入 inchannels - 输入的通道数 Transition层包括一个1x1的卷积和2x2的AvgPooling,结构为BN+ReLU+1x1 Conv+2x2 AvgPooling。 另外,Transition层可以起到压缩模型的作用。 假定Transition的上接DenseBlock得到的特征图channels数为 m ,Transition层可以产生 theta*m 个特征
625941d9ab23a570cc250427
def is_apt_transport_tor_enabled(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> aug = get_augeas() <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> for uri_path in iter_apt_uris(aug): <NEW_LINE> <INDENT> uri_path = get_real_apt_uri_path(aug, uri_path) <NEW_LINE> uri = aug.get(...
Return whether APT is set to download packages over Tor.
625941d9d164cc6175782ff2
def save(self): <NEW_LINE> <INDENT> db.session.add(self) <NEW_LINE> db.session.commit()
Save item details when creating and editing an item
625941d91d351010ab855dbf
def default_test(): <NEW_LINE> <INDENT> rep_file = None <NEW_LINE> xml_file = None <NEW_LINE> xml_file = open(sys.argv[1], 'rt', encoding='utf-8') <NEW_LINE> input_source = xmlreader.InputSource() <NEW_LINE> input_source.setByteStream(xml_file) <NEW_LINE> xml_reader = xml.sax.make_parser() <NEW_LINE> xml_parser = icXML...
Тестовая функция.
625941d950485f2cf553d03e
def popPkg(self): <NEW_LINE> <INDENT> return self.__pkgs.pop(0)
:return: :rtype: Package
625941d96aa9bd52df037048
def __init__(self, model_dim=512, scale_factor=1, warmup_steps=4000, **kwargs): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.model_dim = model_dim <NEW_LINE> self.scale_factor = scale_factor <NEW_LINE> self.warmup_steps = warmup_steps <NEW_LINE> self.hyperparameters = { "id": "NoamScheduler", "model_dim": sel...
The Noam learning rate scheduler, originally used in conjunction with the Adam optimizer in [1]. Notes ----- The Noam scheduler increases the learning rate linearly for the first `warmup_steps` steps, and decreases it thereafter proportionally to the inverse square root of the step number:: lr = scale_factor * ( ...
625941d95fdd1c0f98dc04d7
def depth2xyzuv(depth, u=None, v=None): <NEW_LINE> <INDENT> if u is None or v is None: <NEW_LINE> <INDENT> u, v = np.mgrid[:480, :640] <NEW_LINE> <DEDENT> C = np.vstack((u.flatten(), v.flatten(), depth.flatten(), 0 * u.flatten() + 1)) <NEW_LINE> X, Y, Z, W = np.dot(xyz_matrix(), C) <NEW_LINE> X, Y, Z = X / W, Y / W, Z ...
Return a point cloud, an Nx3 array, made by projecting the kinect depth map through intrinsic / extrinsic calibration matrices Parameters: depth - comes directly from the kinect u,v - are image coordinates, same size as depth (default is the original image) Returns: xyz - 3D world coordinates in meters (Nx3) ...
625941d938b623060ff0b091
def get_spin_arts(self): <NEW_LINE> <INDENT> return self.spin_arts
Returns spin_art list
625941d960cbc95b062c67e7
def get_notes_for_date(line): <NEW_LINE> <INDENT> note = "" <NEW_LINE> for l in line: <NEW_LINE> <INDENT> if "NOTE" in l[0]: <NEW_LINE> <INDENT> mytext = l[1].replace("<", "&lt;").replace(">", "&gt;") <NEW_LINE> note += "%s " % mytext <NEW_LINE> <DEDENT> <DEDENT> match = re.search(r"[\n ]*$", note) <NEW_LINE> if match:...
this is the actual user entered stuff!
625941d9e64d504609d74ae3
def getFood(self): <NEW_LINE> <INDENT> return self._food
Returns the amount of food that the Tile produces
625941d921bff66bcd684bf3
def init(): <NEW_LINE> <INDENT> with open("words.txt", "r") as f: <NEW_LINE> <INDENT> for x in f: <NEW_LINE> <INDENT> if not x: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> ch, en = x.strip().split(",") <NEW_LINE> en = en.strip("_") <NEW_LINE> dictionary[ch] = en <NEW_LINE> <DEDENT> <DEDENT> with open("jieba_dict.t...
1 加载字典文件到内存 2 将所有中文词导入 jieba 字典库 可以考虑把 words.txt 写入数据库或者 ES 做持久化处理 可以做一个 jieba 服务来不断添加词汇 (jieba.add_word()) 但是必须要需要维护一个 jieba_dict.txt 记录所有的中文词汇,以便 jieba 服务 重启后可以重新加载所有的历史数据
625941d963f4b57ef00013b6
def sign_node_cert(self, token, nodename): <NEW_LINE> <INDENT> request_found = self.check_for_cert_request(nodename) <NEW_LINE> if (not request_found): <NEW_LINE> <INDENT> signed_name = "/var/lib/puppet/ssl/ca/signed/" + nodename + ".pem" <NEW_LINE> if (os.path.exists(signed_name)): <NEW_LINE> <INDENT> return success()...
calls puppetca to sign pending client certificate
625941d9bf627c535bc13472
def execute(self, context): <NEW_LINE> <INDENT> aws_hook = AwsHook(self.aws_credentials_id) <NEW_LINE> credentials = aws_hook.get_credentials() <NEW_LINE> redshift = PostgresHook(postgres_conn_id=self.redshift_conn_id) <NEW_LINE> self.log.info("Clearing data from destination Redshift table") <NEW_LINE> redshift.run("DE...
Copy data from S3 buckets to redshift cluster into staging tables. - redshift_conn_id: redshift cluster connection - aws_credentials_id: AWS connection - table: redshift cluster table name - s3_bucket: S3 bucket name holding source data - s3_key: S3 key files of source data - file_format: source...
625941d93317a56b86939ef6
def paste(self, pm, loc): <NEW_LINE> <INDENT> x, y = loc <NEW_LINE> for srcy in range(pm.height): <NEW_LINE> <INDENT> for srcx in range(pm.width): <NEW_LINE> <INDENT> srcpx = pm.get_pixel((srcx, srcy)) <NEW_LINE> self.set_pixel(srcpx, (x + srcx, y + srcy))
Pastes another pixmap at the given location Arguments: pm - Pixmap to paste loc - Location tuple (x, y)
625941d9d6c5a102081442f0
def test_extract(self): <NEW_LINE> <INDENT> for url in self.should_extract: <NEW_LINE> <INDENT> assert isinstance(url, str) and len(url) > 0, ( f'given url {url!r} for extractor {self.extractor!r} ' f'is not a non-zero length string' ) <NEW_LINE> extractor = self.extractor() <NEW_LINE> for content_list in extractor.ext...
Tests the bas extract of the extractor with test's should_extract.
625941d9a17c0f6771cbe2f3
def get_cluster_vols_with_ssc(na_server, vserver, volume=None): <NEW_LINE> <INDENT> volumes = query_cluster_vols_for_ssc(na_server, vserver, volume) <NEW_LINE> sis_vols = get_sis_vol_dict(na_server, vserver, volume) <NEW_LINE> mirrored_vols = get_snapmirror_vol_dict(na_server, vserver, volume) <NEW_LINE> aggrs = {} <NE...
Gets ssc vols for cluster vserver.
625941d90383005118ecf885
def testRecordMaxlengthFinishTimeout(self): <NEW_LINE> <INDENT> r = twilio.Response() <NEW_LINE> r.addRecord(timeout=4,finishOnKey="#", maxLength=30) <NEW_LINE> r = self.strip(r) <NEW_LINE> self.assertEquals(r, '<Response><Record finishOnKey="#" maxLength="30" timeout="4"/></Response>')
should record with an maxlength, finishonkey, and timeout
625941d967a9b606de4a815c
def inet_pton(family, text): <NEW_LINE> <INDENT> if family == AF_INET: <NEW_LINE> <INDENT> return dns.ipv4.inet_aton(text) <NEW_LINE> <DEDENT> elif family == AF_INET6: <NEW_LINE> <INDENT> return dns.ipv6.inet_aton(text) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise NotImplementedError
Convert the textual form of a network address into its binary form. *family* is an ``int``, the address family. *text* is a ``text``, the textual address. Raises ``NotImplementedError`` if the address family specified is not implemented. Returns a ``binary``.
625941d97047854f462a16aa
def _get_current_processors(): <NEW_LINE> <INDENT> return current_app.extensions['invenio-files-processor']
Return current state of the processors extension.
625941d9851cf427c661a7b0
def close(self, exc_info=False): <NEW_LINE> <INDENT> if not self.closed(): <NEW_LINE> <INDENT> if exc_info: <NEW_LINE> <INDENT> if not isinstance(exc_info, tuple): <NEW_LINE> <INDENT> exc_info = sys.exc_info() <NEW_LINE> <DEDENT> if any(exc_info): <NEW_LINE> <INDENT> self.error = exc_info[1] <NEW_LINE> <DEDENT> <DEDENT...
Close this stream. If ``exc_info`` is true, set the ``error`` attribute to the current exception from `sys.exc_info` (or if ``exc_info`` is a tuple, use that instead of `sys.exc_info`).
625941d9cc0a2c11143dd134
def endswith(self, suffix): <NEW_LINE> <INDENT> return self.map_predicate(lambda elem: elem.endswith(suffix))
Elementwise endswith. Parameters ---------- suffix : str Returns ------- matches : np.ndarray[bool] An array with the same shape as self indicating whether each element of self ended with ``suffix``
625941d9d99f1b3c44c6782f
def triangle_wave(t, fre, n=15): <NEW_LINE> <INDENT> f = np.zeros(t.shape[0]) <NEW_LINE> n = int(n) <NEW_LINE> freqs = np.array([]) <NEW_LINE> amps = np.array([]) <NEW_LINE> for i in xrange(1, n+1): <NEW_LINE> <INDENT> f -= (8 / pi**2) * (1.0 / (2*i-1)**2) * cos((2*i-1)*2*pi*fre*t) <NEW_LINE> freqs = np.append(freqs, f...
Triangle wave composed of n sine waves Same parameters as the sine_wave method
625941d966673b3332b92335
def get_open_id_configuration(self) -> Optional[dict]: <NEW_LINE> <INDENT> response = self._connection.get(path="/.well-known/openid-configuration") <NEW_LINE> if response.status_code == 200: <NEW_LINE> <INDENT> return response.json() <NEW_LINE> <DEDENT> if response.status_code == 404: <NEW_LINE> <INDENT> return None <...
Get the openid-configuration. Returns ------- dict The configuration or None if not configured. Raises ------ weaviate.UnexpectedStatusCodeException If weaviate reports a none OK status.
625941d924f1403a92600e08
def handle_get_photo_as_image(num_cam): <NEW_LINE> <INDENT> filename = 'test_{}.jpg'.format(num_cam) <NEW_LINE> return (get_folder(APP_PHOTOS, filename), filename, 'image/jpg')
Handle get latest photo Param arguments: num_cam -- camera id Return: None
625941d929b78933be1e594c
def add_item(self, item, overwrite=False): <NEW_LINE> <INDENT> pass
:param item: :param overwrite: :return:
625941d97d43ff24873a2f45
def test_absolute_url_success(self): <NEW_LINE> <INDENT> url_string = self.global_settings.get_absolute_url() <NEW_LINE> self.assertEqual(url_string, f"/plugins/golden-config/setting/{self.global_settings.slug}/")
Verify that get_absolute_url() returns the expected URL.
625941d9bd1bec0571d908d3
def read_triangle_mesh(dbfile, ext="ply"): <NEW_LINE> <INDENT> from open3d import io <NEW_LINE> b = dbfile.read_raw() <NEW_LINE> with tempfile.TemporaryDirectory() as d: <NEW_LINE> <INDENT> fname = os.path.join(d, "temp.%s" % ext) <NEW_LINE> with open(fname, "wb") as fh: <NEW_LINE> <INDENT> fh.write(b) <NEW_LINE> <DEDE...
Reads triangular mesh from a DB file. Parameters ---------- dbfile : db.File The `File` object used to load the associated file. ext : str, optional File extension, defaults to "ply". Returns ------- open3d.geometry.PointCloud The loaded point cloud object.
625941d9fbf16365ca6f646b
def houseclean (): <NEW_LINE> <INDENT> present_dir = os.getcwd() <NEW_LINE> os.chdir (processing_dir) <NEW_LINE> for simfile in glob.glob ('*.simfile'): <NEW_LINE> <INDENT> dest_simfile = os.path.join (pending_dir, simfile) <NEW_LINE> shutil.move (simfile, dest_simfile) <NEW_LINE> print ('Housecleaning: I moved the fol...
Function to clean up the processing directory. Do not call this function when there are batch workers presently operating as you will delete the files underneath the batch workers and they will probably fail. Global variables required: pending_dir: pending simfile directory processing_dir: processing directory
625941d930c21e258bdfa742
def testUsedFlag(self): <NEW_LINE> <INDENT> self.exposure.setWcs(self.tanWcs) <NEW_LINE> config = AstrometryTask.ConfigClass() <NEW_LINE> config.wcsFitter.order = 2 <NEW_LINE> config.wcsFitter.numRejIter = 0 <NEW_LINE> sourceSchema = afwTable.SourceTable.makeMinimalSchema() <NEW_LINE> measBase.SingleFrameMeasurementTas...
Test that the solver will record number of sources used to table if it is passed a schema on initialization.
625941d921bff66bcd684bf4