code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
@contextlib.contextmanager <NEW_LINE> def new_context(tracer_id: str=None, endpoint: str=None, environment: str=None): <NEW_LINE> <INDENT> context = GlobalContextManager.prepare_context(tracer_id, endpoint, environment) <NEW_LINE> stack_context = StackContext(partial(global_context_manager.push_context, context)) <NEW_... | Opens a new context.
:param tracer_id: string with tracer log information. If not given, one will be generated.
:param endpoint: name of the endpoint that was requested
:param environment: the customer identifier
Usage:
with new_context(my_tracer_id):
do_some_task_using_the_new_context() | 625941c60fa83653e4656ff1 |
def maxSubArray(self, nums): <NEW_LINE> <INDENT> result = float('-Inf') <NEW_LINE> sum = 0 <NEW_LINE> for i in range(0,len(nums)): <NEW_LINE> <INDENT> sum = max(sum + nums[i],nums[i]) <NEW_LINE> result = max(result,sum) <NEW_LINE> <DEDENT> return result | :type nums: List[int]
:rtype: int | 625941c6711fe17d825423a3 |
def get_mappings(self, start=0, end=2**64): <NEW_LINE> <INDENT> for pdpte_index in range(0, 4): <NEW_LINE> <INDENT> vaddr = pdpte_index << 30 <NEW_LINE> if vaddr > end: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> next_vaddr = (pdpte_index + 1) << 30 <NEW_LINE> if start >= next_vaddr: <NEW_LINE> <INDENT> continue <NE... | A generator of address, length tuple for all valid memory regions. | 625941c6cad5886f8bd2700f |
def test_trim_scene(self): <NEW_LINE> <INDENT> self.interp.trim_points(np.r_[True]) <NEW_LINE> self.failUnlessEqual(self.interp.interpolate().shape[0], 0.) | Dropping particles from the interpolated scene | 625941c67d847024c06be2f0 |
def create_blank_page(self, physical_address_of_page_table_entry): <NEW_LINE> <INDENT> frame_index = self.find_free_page_frame() <NEW_LINE> if frame_index == -1: <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> self.BM[frame_index] = True <NEW_LINE> self.PM[physical_address_of_page_table_entry] = frame_number_to_physi... | creates a blank page and updates the page table entry with the physical address to the beginning of
the page; returns 1 if page was created successfully; returns -1 otherwise | 625941c6b830903b967e9942 |
def insert(self): <NEW_LINE> <INDENT> sql = ("INSERT INTO happyhour.public.users (username," " password, email) VALUES ($1, $2, $3)" " RETURNING id" ) <NEW_LINE> result_obj = DbConnect.get_named_results(sql, True, self.username, self.password_hash, self.email) <NEW_LINE> self.user_id = result_obj... | Saves a new user in db. Username and PW validation done through
validate_userinfo | 625941c682261d6c526ab4d3 |
def _parse(self, fp): <NEW_LINE> <INDENT> MASK = 0xffffffff <NEW_LINE> unpack = struct.unpack <NEW_LINE> filename = getattr(fp, 'name', '') <NEW_LINE> self._catalog = catalog = {} <NEW_LINE> buf = fp.read() <NEW_LINE> buflen = len(buf) <NEW_LINE> magic = unpack('<i', buf[:4])[0] & MASK <NEW_LINE> if magic == self.LE_MA... | Override this method to support alternative .mo formats. | 625941c6167d2b6e31218bcb |
def get_projects_with_unknown_volumes(category): <NEW_LINE> <INDENT> volume_ids = [vol['id'] for vol in category.info.get('volumes', [])] <NEW_LINE> projects = project_repo.filter_by(category_id=category.id) <NEW_LINE> return [dict(id=p.id, name=p.name, short_name=p.short_name) for p in projects if not p.info.get('volu... | Return all projects not linked to a known volume. | 625941c6eab8aa0e5d26db8d |
def end(self): <NEW_LINE> <INDENT> size = len(lst)-self.pagesize*(self.lst-1) <NEW_LINE> data = lst[len(lst)-size:] <NEW_LINE> for d in data: <NEW_LINE> <INDENT> print(d) | 返回最后一页的内容 | 625941c645492302aab5e2f8 |
def compute_feature(self, wf, internal_request=False): <NEW_LINE> <INDENT> module = self.modules_dict[self.module_name] <NEW_LINE> class_method = getattr(module, self.class_name) <NEW_LINE> if self.source == 'new': <NEW_LINE> <INDENT> final_method = class_method <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> final_metho... | Note, the only caller of this function should be from:
WormFeaturesDos._get_and_log_feature()
This method takes care of the logic of retrieving a feature.
ALL features are created or loaded via this method.
Arguments
---------
wf : WormFeaturesDos
This is primarily needed to facilitate requesting additional
... | 625941c6bf627c535bc13204 |
def get_terms(terms): <NEW_LINE> <INDENT> if isinstance(terms, str): <NEW_LINE> <INDENT> lterms = terms.split(',') <NEW_LINE> terms = [{'$ref': dbl_quote(stripper(t))} for t in lterms] <NEW_LINE> return terms <NEW_LINE> <DEDENT> return None | Converts terms string into list of terms | 625941c6b7558d58953c4f4c |
def remove_backup(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> os.remove(LOG_CONFIGS_BAK_PATH) <NEW_LINE> <DEDENT> except FileNotFoundError: <NEW_LINE> <INDENT> pass | Remove the backup created by create_backup. | 625941c6656771135c3eb8a3 |
def test_foca_db(): <NEW_LINE> <INDENT> app = foca(VALID_DB_CONF) <NEW_LINE> my_db = app.app.config['FOCA'].db.dbs['my-db'] <NEW_LINE> my_coll = my_db.collections['my-col-1'] <NEW_LINE> assert isinstance(my_db.client, Database) <NEW_LINE> assert isinstance(my_coll.client, Collection) <NEW_LINE> assert isinstance(app, A... | Ensure foca() returns a Connexion app instance; valid db field | 625941c63d592f4c4ed1d0a6 |
def append_log(self, msg): <NEW_LINE> <INDENT> atend = True <NEW_LINE> if self.scroll and self.scroll.page_size > 0: <NEW_LINE> <INDENT> if self.scroll.upper - (self.scroll.value + self.scroll.page_size) > (0.5 * self.scroll.page_size): <NEW_LINE> <INDENT> atend = False <NEW_LINE> <DEDENT> <DEDENT> self.log.insert(self... | Append msg to the text view. | 625941c6566aa707497f45a1 |
def __init__(self, options={}, config=None): <NEW_LINE> <INDENT> self.config = config <NEW_LINE> self.options = options <NEW_LINE> self.options["dll"] = "Extraction.dll" | @param options: options dict. | 625941c673bcbd0ca4b2c0ac |
def refine_from_dataframe(self, df: 'DataFrame', processing_instructions: ProcessingInstructions = ProcessingInstructions()) -> 'RecordsSchema': <NEW_LINE> <INDENT> from .pandas import refine_schema_from_dataframe <NEW_LINE> return refine_schema_from_dataframe(records_schema=self, df=df, processing_instructions=process... | Adjust records schema based on facts found from a dataframe. | 625941c68e05c05ec3eea3a9 |
@main.route('/distance_computing/<geolocation>/<city>', methods=['GET', 'POST']) <NEW_LINE> def distance_computing(geolocation, city): <NEW_LINE> <INDENT> geo_split = geolocation.split(',') <NEW_LINE> global current_location <NEW_LINE> current_location = geo_split <NEW_LINE> if city == 'Ireland': <NEW_LINE> <INDENT> sc... | This function is used for distance computing and sorting
:param geolocation: the coordinate of the place
:param city: The city where the place is located
:return: Sorted school list (JSON) | 625941c699fddb7c1c9de3c7 |
def __init__(self, directory, map_extensions=['kap', 'tif'], include_only=None): <NEW_LINE> <INDENT> self.file_paths = [] <NEW_LINE> extensions = set() <NEW_LINE> for ext in map_extensions: <NEW_LINE> <INDENT> extensions.add(ext.upper()) <NEW_LINE> <DEDENT> if include_only is not None: <NEW_LINE> <INDENT> include_only ... | Searches for files ending with <map_extensions> in <directory> and all subdirectories
Optionally supply set of file names <include_only> to only return paths of files that
are contained in the set eg. {file1.kap, file2.tif}
file_paths is a list of all full paths found | 625941c67b180e01f3dc4836 |
def active_thread_priority(self): <NEW_LINE> <INDENT> return _analog_swig.agc2_cc_sptr_active_thread_priority(self) | active_thread_priority(agc2_cc_sptr self) -> int | 625941c623e79379d52ee59b |
def test_ensure_user_exists(self): <NEW_LINE> <INDENT> self.database = pgtools.PostgresDatabase( db_name='test_pgtools', port=self.port, ) <NEW_LINE> self.database.create_user() <NEW_LINE> self.database.ensure_user() | ensure_user should not fail if user already exists | 625941c6460517430c3941be |
def test_import_normal(self): <NEW_LINE> <INDENT> response = self.do_import() <NEW_LINE> self.assertRedirects(response, self.translation_url) <NEW_LINE> translation = self.get_translation() <NEW_LINE> self.assertEquals(translation.translated, 1) <NEW_LINE> self.assertEquals(translation.fuzzy, 0) <NEW_LINE> self.assertE... | Test importing normally. | 625941c6bd1bec0571d90665 |
def dbusName(self): <NEW_LINE> <INDENT> return QString() | QString KMainWindow.dbusName() | 625941c6e5267d203edcdcd4 |
def action_start(self): <NEW_LINE> <INDENT> return self.write({'state': 'inprogress'}) | Start a challenge | 625941c626238365f5f0eea3 |
def close_all_imgs(self): <NEW_LINE> <INDENT> pass | Close all PIL images | 625941c66fb2d068a760f0d2 |
def get_nodes(self): <NEW_LINE> <INDENT> return list(range(0, self.__nodes)) | Get the nodes.
Returns
-------
nodes : list
All nodes as an ordered list (starting from 0). | 625941c66aa9bd52df036dd9 |
def is_dir_python_module(directory): <NEW_LINE> <INDENT> dir_name = os.path.basename(directory) <NEW_LINE> try: <NEW_LINE> <INDENT> imp.find_module(dir_name) <NEW_LINE> return True <NEW_LINE> <DEDENT> except ImportError: <NEW_LINE> <INDENT> return False | True if directory is not taken by another python module | 625941c6925a0f43d2549eac |
def setPublication(publication): <NEW_LINE> <INDENT> pass | Set the request's publication object
| 625941c68e71fb1e9831d7e0 |
def process_response(self, request, response): <NEW_LINE> <INDENT> return self._response_sts(response) | Push Strict-Transport-Security into headers if configured | 625941c6b5575c28eb68e035 |
def __eq__(self, other): <NEW_LINE> <INDENT> if self.len == other.len: <NEW_LINE> <INDENT> if isinstance(other, ArrayList): <NEW_LINE> <INDENT> for i in range(0, self.len): <NEW_LINE> <INDENT> if self[i] != other[i]: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> return True <NEW_LINE> <DEDENT> else: <NE... | Returns True if this ArrayList contains the same elements (in order) as
other. If other is not an ArrayList, returns False. | 625941c632920d7e50b28205 |
def __init__(self, location=None, user_id=0, id=0, is_valid=1, update_time=datetime.datetime.now(), create_if_not_exist=False): <NEW_LINE> <INDENT> self.id = id <NEW_LINE> self.location = location <NEW_LINE> self.user_id = user_id <NEW_LINE> self.is_valid = is_valid <NEW_LINE> self.update_time = update_time <NEW_LINE> ... | id default:0
location default:None
user_id default:0
is_valid default:1
update_time
create_if_not_exist | 625941c630c21e258bdfa4d2 |
def add_to_found(self, found_char): <NEW_LINE> <INDENT> self.matches_found.append(found_char) | Adds a found match to the list of them.
type: (char) -> None | 625941c6fbf16365ca6f61f8 |
def csv2array(): <NEW_LINE> <INDENT> SEPERATOR = ',' <NEW_LINE> d = open('data.csv', 'r') <NEW_LINE> lines = [] <NEW_LINE> for line in d.readlines(): <NEW_LINE> <INDENT> line = line.replace('\n', '') <NEW_LINE> temp = line[line.index(',')+1:] <NEW_LINE> lines.append(temp.split(SEPERATOR)) <NEW_LINE> <DEDENT> d.close() ... | Reads data from a csv file and convert it to 2D array | 625941c6377c676e912721df |
def bls(self, irc, msg, args): <NEW_LINE> <INDENT> config = yaml.load(file(self.cfgfile, 'r')) <NEW_LINE> listbls = [] <NEW_LINE> for k,v in config['blacklists'].items(): <NEW_LINE> <INDENT> listbls.append('%s - %s' % (k, v)) <NEW_LINE> <DEDENT> msg_bls = 'Blacklists: %s' % (' \xB7 '.join(listbls)) <NEW_LINE> irc.reply... | takes no arguments
Lists the blacklists in use | 625941c64e4d5625662d440f |
def new_url(**kwargs): <NEW_LINE> <INDENT> url_base = "/axapi/v3/slb/ssl-cert-revoke" <NEW_LINE> f_dict = {} <NEW_LINE> return url_base.format(**f_dict) | Return the URL for creating a resource | 625941c6d58c6744b4257c96 |
def test_added_apps_are_displayed_in_home_page(self): <NEW_LINE> <INDENT> app = self.add_application() <NEW_LINE> response = self.client.get('/') <NEW_LINE> self.assertTrue(app.name.encode() in response.data) | _____Added applications should be displayed on the home page | 625941c6956e5f7376d70ea4 |
def lincomb_naive(group_elements, factors): <NEW_LINE> <INDENT> assert len(group_elements) == len(factors) <NEW_LINE> result = blst.P1_generator().mult(0) <NEW_LINE> for g, f in zip(group_elements, factors): <NEW_LINE> <INDENT> result.add(g.dup().mult(f)) <NEW_LINE> <DEDENT> return result | Direct linear combination | 625941c7bf627c535bc13205 |
def build_model(n_layers, num_in_layer): <NEW_LINE> <INDENT> one_input_length = get_num_features() <NEW_LINE> model = Sequential() <NEW_LINE> model.add( GRU( num_in_layer, input_shape=(None, one_input_length), return_sequences=True, W_regularizer=l2(REG_CONSTANT), U_regularizer=l2(REG_CONSTANT), ) ) <NEW_LINE> for i in... | Builds LSTM model as per specifications | 625941c78c0ade5d55d3e9f0 |
def isSparqlQueryRequest(self): <NEW_LINE> <INDENT> return not self.isSparqlUpdateRequest() | Returns TRUE if SPARQLWrapper is configured for executing SPARQL Query request
@return: bool | 625941c7498bea3a759b9ae6 |
def fit_parameter(estimates, fun, start_values, xval): <NEW_LINE> <INDENT> if start_values is None: <NEW_LINE> <INDENT> start_values = np.array([0, 0, 0, 1.]) <NEW_LINE> <DEDENT> if len(estimates) == 1: <NEW_LINE> <INDENT> em = [estimates[0], 1, 0.000649, 1] <NEW_LINE> estimates = np.array(em) <NEW_LINE> xv = [xval[0]]... | Fitting any numbers of given infectious rate function using least squares.
Used count of observed events in observation window as weights.
:param estimates: estimated values of function
:param fun: function to fit
:param start_values: initial guesses of parameters, should be a ndarray
:param xval: x axis values to est... | 625941c7a8ecb033257d3104 |
def parse_track_header(self, fp): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> h = fp.read(4) <NEW_LINE> self.bytes_read += 4 <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> raise IOError("Couldn't read track header from file. Byte %d." % self.bytes_read) <NEW_LINE> <DEDENT> if h != b'MTrk': <NEW_LINE> <INDENT> raise H... | Return the size of the track chunk. | 625941c79f2886367277a8c4 |
def match_with_gaps(my_word, other_word): <NEW_LINE> <INDENT> myword = ''.join(my_word.split()) <NEW_LINE> if len(other_word) != len(myword): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> for num, letters in enumerate(myword): <NEW_LINE> <INDENT> if letters == '_': <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> el... | my_word: string with _ characters, current guess of secret word
other_word: string, regular English word
returns: boolean, True if all the actual letters of my_word match the
corresponding letters of other_word, or the letter is the special symbol
_ , and my_word and other_word are of the same length;
False... | 625941c7d268445f265b4ea4 |
def set_shapes(self, batch_size, features): <NEW_LINE> <INDENT> if self.is_training and self.transpose_input: <NEW_LINE> <INDENT> features['image'].set_shape(features['image'].get_shape().merge_with( tf.TensorShape([None, None, None, batch_size]))) <NEW_LINE> features['label'].set_shape(features['label'].get_shape().me... | Statically set the batch_size dimension. | 625941c791af0d3eaac9ba4e |
def validate_set(self, props): <NEW_LINE> <INDENT> raise cmerror.CMError('Not implemented') | validate a configuration data addition/update
Arguments:
props: A dictionary of name-value pairs representing the changed
properties.
Raise:
CMError can be raised if the change is not accepted by this plugin. | 625941c77c178a314d6ef494 |
def get_priority_request(self, request): <NEW_LINE> <INDENT> return master_common.builderPriority(self, request) | returns the calculated priority of a builder/request | 625941c7796e427e537b05fb |
def find_stable_topk_neighborhood(self, k=20, max_iters=50, min_eps=0.1, reverse=False, return_type="ptr"): <NEW_LINE> <INDENT> assert return_type in ("ptr", "idx", "nbhd") <NEW_LINE> n_iteration = 0 <NEW_LINE> old_neighborhood = self <NEW_LINE> old_neighborhood_ptrs_set = set(old_neighborhood._init_ptrs) <NEW_LINE> ne... | return_type in ("ptr","idx","nbhd") | 625941c716aa5153ce3624af |
def recognize_entities(self): <NEW_LINE> <INDENT> grammar = "NP: {<DT>?<JJ>*<NN>}" <NEW_LINE> cp = nltk.RegexpParser(grammar) <NEW_LINE> token_set = self.word_tokenize() <NEW_LINE> token_set = [nltk.pos_tag(tokens) for tokens in token_set] <NEW_LINE> named_entities = [cp.parse(tokens) for tokens in token_set] <NEW_LINE... | The grammar says that an NP chunk should be formed whenever the chunker finds an optional determiner (DT)
followed by any number of adjectives (JJ) and then a noun (NN).
@return an array of recognized entities. | 625941c730bbd722463cbdfb |
def __eq__(self, other: 'KeywordsOptions') -> bool: <NEW_LINE> <INDENT> if not isinstance(other, self.__class__): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Return `true` when self and other are equal, false otherwise. | 625941c7d18da76e2353250c |
def test_start(self): <NEW_LINE> <INDENT> fake_gear = FakeGearClient() <NEW_LINE> api = Deployer(create_volume_service(self), gear_client=fake_gear) <NEW_LINE> docker_image = DockerImage(repository=u'clusterhq/flocker', tag=u'release-14.0') <NEW_LINE> ports = frozenset([Port(internal_port=80, external_port=8080)]) <NEW... | `Deployer.start_application` accepts an application object and returns
a `Deferred` which fires when the `gear` unit has been added and
started. | 625941c7097d151d1a222e91 |
def restart(self): <NEW_LINE> <INDENT> for p in self.processes: <NEW_LINE> <INDENT> p.reset() | Stops all of the agent's processes. | 625941c74c3428357757c35f |
def join_command_args(self, args: list[str]): <NEW_LINE> <INDENT> return self.platform.join_command_args(args) | This is used by the [`run`](../cli/reference.md#hatch-run) command to construct the root command string
from the received arguments. | 625941c7f7d966606f6aa03a |
def get_remove_code(loader_name): <NEW_LINE> <INDENT> source_path = path.realpath(path.join(path.dirname(__file__), loader_name, "remove.py")) <NEW_LINE> with open(source_path, "rb") as input_file: <NEW_LINE> <INDENT> code = input_file.read() <NEW_LINE> <DEDENT> return compress(code) | :return: Compressed code which can be run on the bot.
:type loader_name: str
:rtype: bytes | 625941c78a43f66fc4b5409d |
def __init__(self, R, S): <NEW_LINE> <INDENT> assert(R in Rings()) <NEW_LINE> self._base = R <NEW_LINE> self._S = S <NEW_LINE> Parent.__init__(self, category = Algebras(R).WithRealizations()) <NEW_LINE> category = self.Bases() <NEW_LINE> F = self.F() <NEW_LINE> In = self.In() <NEW_LINE> Out = self.Out() <NEW_LINE>... | EXAMPLES::
sage: from sage.categories.examples.with_realizations import SubsetAlgebra
sage: A = SubsetAlgebra(QQ, Set((1,2,3))); A
The subset algebra of {1, 2, 3} over Rational Field
sage: Sets().WithRealizations().example() is A
True
sage: TestSuite(A).run()
TESTS::
sage: A = Sets().With... | 625941c7d7e4931a7ee9df54 |
def refresh(self): <NEW_LINE> <INDENT> for child in self._pathwaybox.get_children(): <NEW_LINE> <INDENT> self._pathwaybox.remove(child) <NEW_LINE> <DEDENT> if self._pathway is None: <NEW_LINE> <INDENT> self._namebox.set_text("no pathway") <NEW_LINE> self._namebox.set_sensitive(False) <NEW_LINE> self.btn_save_name.set_s... | Refreshes display of this PathwayDisplay's LearningPathway | 625941c707f4c71912b114b8 |
def cmd_status(self, argv, help): <NEW_LINE> <INDENT> parser = argparse.ArgumentParser( prog="%s status" % self.progname, description=help, ) <NEW_LINE> instances = self.get_instances(command='status') <NEW_LINE> parser.add_argument("instance", nargs=1, metavar="instance", help="Name of the instance from the config.", ... | Prints status | 625941c7956e5f7376d70ea5 |
def __init__(self, controller, strategy, mtbf=1): <NEW_LINE> <INDENT> self.controller = controller <NEW_LINE> self.strategy = strategy <NEW_LINE> self.running_fevals = [] <NEW_LINE> self.lam = 1.0/mtbf <NEW_LINE> self.target = None <NEW_LINE> controller.add_feval_callback(self.on_new_feval) <NEW_LINE> controller.add_ti... | Release the chaos monkey!
Args:
controller: The controller whose fevals we will kill
strategy: Parent strategy
mtbf: Mean time between failure (assume Poisson process) | 625941c7796e427e537b05fc |
def search(self, data): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self.data > data: <NEW_LINE> <INDENT> if self.left is not None: <NEW_LINE> <INDENT> return self.left.search(data) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise ValueError <NEW_LINE> <DEDENT> <DEDENT> if self.data < data: <NEW_LINE> <INDENT> i... | Поиск данного значения в дереве | 625941c7ec188e330fd5a7d8 |
def replace_validating_webhook_configuration(self, name, body, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> return self.replace_validating_webhook_configuration_with_http_info(name, body, **kwargs) | replace_validating_webhook_configuration # noqa: E501
replace the specified ValidatingWebhookConfiguration # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.replace_validating_webhook_configuration(name, body, async... | 625941c7462c4b4f79d1d707 |
def greet_user(): <NEW_LINE> <INDENT> username=get_stored_username() <NEW_LINE> if username: <NEW_LINE> <INDENT> print("Welcome back, " + username + "!") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> username=get_new_username() <NEW_LINE> print("We'll remember you when you come back, " + username + "!") | Greet the user by name | 625941c73eb6a72ae02ec511 |
def measurement_update(particles, measured_marker_list, grid): <NEW_LINE> <INDENT> if len(measured_marker_list) == 0: <NEW_LINE> <INDENT> return particles <NEW_LINE> <DEDENT> particle_weights = []; <NEW_LINE> for p in particles: <NEW_LINE> <INDENT> if grid.is_free(*p.xy): <NEW_LINE> <INDENT> if len(measured_marker_list... | Particle filter measurement update
Arguments:
particles -- input list of particle represents belief ilde{p}(x_{t} | u_{t})
before meansurement update (but after motion update)
measured_marker_list -- robot detected marker list, each marker has format:
measured_marker_list[i] = (rx, ry, rh)
r... | 625941c7596a897236089af9 |
def on_stop(self, event): <NEW_LINE> <INDENT> self.thread_type.stop() <NEW_LINE> self.parent.statusbar_msg(_("wait... I'm aborting"), 'GOLDENROD', LogOut.WHITE) <NEW_LINE> self.thread_type.join() <NEW_LINE> self.parent.statusbar_msg(_("...Interrupted"), None) <NEW_LINE> self.abort = True <NEW_LINE> event.Skip() | The user change idea and was stop process | 625941c76e29344779a6264a |
def get_backends_by_owner(self, elixir_id): <NEW_LINE> <INDENT> self.send_get_backends_by_owner(elixir_id) <NEW_LINE> return self.recv_get_backends_by_owner() | Get all backends by owner
Parameters:
- elixir_id | 625941c7435de62698dfdc83 |
def sample_fake(self, sample_size,noise_var=1): <NEW_LINE> <INDENT> z = np.random.multivariate_normal(mean=np.zeros(shape=(self.g_config['dims'][0],)), cov=noise_var*np.eye(self.g_config['dims'][0],), size=sample_size) <NEW_LINE> return self.g_model.predict(z) | Samples from the generator
:param sample_size: number of generated samples | 625941c756b00c62f0f14690 |
def create_superuser(self,name,email,password): <NEW_LINE> <INDENT> user = self.create_user(name,email,password) <NEW_LINE> user.is_superuser = True <NEW_LINE> user.is_staff = True <NEW_LINE> user.save(using=self._db) <NEW_LINE> return user | create and save new superuser | 625941c73cc13d1c6d3c73b2 |
@pytest.mark.parametrize(("data", "index"), [ (range(24 * 60), dates), (np.arange(24 * 60), dates), ({"param": range(24 * 60)}, dates) ]) <NEW_LINE> def test_input(data, index): <NEW_LINE> <INDENT> sunpy.lightcurve.LightCurve(data, index=index) | Tests different types of expected input | 625941c7656771135c3eb8a4 |
def isMatch(self, s, p): <NEW_LINE> <INDENT> i, j = 0, 0 <NEW_LINE> i_, j_ = 0, -1 <NEW_LINE> while i < len(s): <NEW_LINE> <INDENT> if j < len(p) and (s[i] == p[j] or p[j] == '?'): <NEW_LINE> <INDENT> i += 1 <NEW_LINE> j += 1 <NEW_LINE> <DEDENT> elif j < len(p) and p[j] == '*': <NEW_LINE> <INDENT> i_, j_ = i, j <NEW_LI... | :type s: str
:type p: str
:rtype: bool | 625941c78c0ade5d55d3e9f1 |
def _start_thread(self): <NEW_LINE> <INDENT> shared = self.shared <NEW_LINE> def worker(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> while not shared.ending.is_set(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> task = shared.requests.get(timeout=1) <NEW_LINE> <DEDENT> except Empty: <NEW_LINE> <INDENT> continue <NEW... | Run the request processor | 625941c7e1aae11d1e749ced |
def wait_until_color_not(self, color): <NEW_LINE> <INDENT> while self.equals(color): <NEW_LINE> <INDENT> wait(10) <NEW_LINE> <DEDENT> return | Waits until the color does not equal a Color or a set of Colors
See ColorExt for color values
list, tuple or dict must have values of instance Color
:param color: Color to compare sensor color to
:type color: Color, int, float, list, tuple, dict | 625941c756ac1b37e6264208 |
def r_fdmi_port_objects(self): <NEW_LINE> <INDENT> rl = list() <NEW_LINE> for fab_obj in self.r_fabric_objects(): <NEW_LINE> <INDENT> rl.extend(fab_obj.r_fdmi_port_objects()) <NEW_LINE> <DEDENT> return rl | Returns all the FDMI port objects for logins associated with this chassis
:return: List of FdmiPortObj associated with this chassis
:rtype: list | 625941c7c432627299f04c7c |
def trigger(self, event, *args, **kwargs): <NEW_LINE> <INDENT> if not hasattr(self, 'events'): <NEW_LINE> <INDENT> self.events = {} <NEW_LINE> <DEDENT> ev = self.events.get(event, set()) <NEW_LINE> for listener in ev.copy(): <NEW_LINE> <INDENT> listener(self, *args, **kwargs) <NEW_LINE> <DEDENT> if hasattr(self, 'state... | Trigger an event. | 625941c723e79379d52ee59c |
def get_delegates(self, **kwargs): <NEW_LINE> <INDENT> resp = self.get("api/delegates", **kwargs) <NEW_LINE> return resp.json() | Get all delegates.
:param kwargs: Optionnal parameters. orderBy, limit, offset.
:return: | 625941c797e22403b379cfd0 |
def main(): <NEW_LINE> <INDENT> corpus = load_training_file('words.txt') <NEW_LINE> corpus = prep_training(corpus) <NEW_LINE> chains = [] <NEW_LINE> for n in range(1, 5): <NEW_LINE> <INDENT> chains.append(load_chains(corpus, order=n)) <NEW_LINE> <DEDENT> print("\nNew word generator\n") <NEW_LINE> while True: <NEW_LINE>... | Load the corpus, load chain dictionaries, generate words | 625941c77047854f462a1442 |
def setup_bridge(bridge, add_devices, add_groups): <NEW_LINE> <INDENT> lights = {} <NEW_LINE> @util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS) <NEW_LINE> def update_lights(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> bridge.update_all_light_status() <NEW_LINE> bridge.update_group_list() <NEW_LIN... | Set up the Lightify bridge. | 625941c72c8b7c6e89b357f8 |
def change_fleet_direction(game_settings, aliens): <NEW_LINE> <INDENT> for alien in aliens.sprites(): <NEW_LINE> <INDENT> alien.rect.y += game_settings.alien_fleet_drop_speed <NEW_LINE> <DEDENT> game_settings.alien_fleet_direction *= -1 | Drop the entire fleet and change direction
:param game_settings:
:param aliens: | 625941c76fece00bbac2d774 |
def create_wrapper(**attrs: Any) -> AnyOp: <NEW_LINE> <INDENT> def wrapper(op): <NEW_LINE> <INDENT> def meth(self, *args, **kwds): <NEW_LINE> <INDENT> return op(*args, **kwds) <NEW_LINE> <DEDENT> def func(*args, **kwds): <NEW_LINE> <INDENT> return op(*args, **kwds) <NEW_LINE> <DEDENT> caller = meth if isinstance(op, Me... | Create a function wrapper that adds attributes.
Args:
**attrs: Arbitrary keyword arguments
Returns:
Function wrapper for given function, with additional specified
attributes. | 625941c7fbf16365ca6f61f9 |
def __str__(self): <NEW_LINE> <INDENT> return str(self._data) | you don't have to do anything with this method | 625941c73539df3088e2e382 |
def test_api(self): <NEW_LINE> <INDENT> class Something(object): <NEW_LINE> <INDENT> def __init__(self, x, y): <NEW_LINE> <INDENT> self.x = x <NEW_LINE> self.y = y <NEW_LINE> <DEDENT> <DEDENT> with Timer("Creating Something"): <NEW_LINE> <INDENT> s = Something(1, 2) <NEW_LINE> <DEDENT> assert s.x == 1 and s.y == 2 <NEW... | Testing tonumber | 625941c7dc8b845886cb556b |
def __init__(self, name="petscapp"): <NEW_LINE> <INDENT> Application.__init__(self, name) <NEW_LINE> return | Constructor.
| 625941c75510c4643540f41e |
def scrape(self, force=False): <NEW_LINE> <INDENT> if (self.time_until_game() == 0 and not self.is_game_over(prev=True)) or force: <NEW_LINE> <INDENT> self.scrape_live_game(force=force) | Scrape the given game. Check if currently ongoing or started
:param bool force: Whether or not to force it to scrape even if it's over
:return: None | 625941c7de87d2750b85fdc9 |
def test_driver_policy_removal(self): <NEW_LINE> <INDENT> self.driver_policy_removal_helper("install") <NEW_LINE> self.driver_policy_removal_helper("exact-install") | Test for bug #9568 - that removing a policy for a
driver where there is no minor node associated with it,
works successfully. | 625941c730dc7b766590199f |
def annealing_cos(start, end, factor): <NEW_LINE> <INDENT> cos_out = cos(pi * factor) + 1 <NEW_LINE> return end + 0.5 * (start - end) * cos_out | Cosine anneal from `start` to `end` as pct goes from 0.0 to 1.0. | 625941c79c8ee82313fbb7ac |
def execute_command_line(self, command_line): <NEW_LINE> <INDENT> return self.system.process_command_line(command_line, None) | Executes the given command line using the default
output method.
:type command_line: String
:param command_line: The command line to be executed.
:rtype: bool
:return: If the execution of the command line was successful. | 625941c7be8e80087fb20c7c |
def test_output_dir_config_xml(self): <NEW_LINE> <INDENT> tmpdir = tempfile.mkdtemp() <NEW_LINE> self.addCleanup(shutil.rmtree, tmpdir) <NEW_LINE> args = [ "test", os.path.join(self.fixtures_path, "cmd-001.yaml"), "-o", tmpdir, "--config-xml", ] <NEW_LINE> self.execute_jenkins_jobs_with_args(args) <NEW_LINE> self.expec... | Run test mode with output to directory in "config.xml" mode and verify
that output files are generated. | 625941c7460517430c3941bf |
def __init__(self, path, port=None, autoreconnect=None): <NEW_LINE> <INDENT> if os.name not in ('posix', 'mac'): <NEW_LINE> <INDENT> raise NotImplementedError( "Killing processes under win32 not supported") <NEW_LINE> <DEDENT> self.path = path <NEW_LINE> self.port = port <NEW_LINE> self.autoreconnect = autoreconnect <N... | Instantiate an object with the given variables. | 625941c7435de62698dfdc84 |
def _rad_fit_ ( data , model , *args , **kwargs ) : <NEW_LINE> <INDENT> return model.fitTo ( data , *args , **kwargs ) | fitting
>>> model = ...
>>> data = ...
>>> data.fitTo ( model , ... )
>>> data.Fit ( model , ... ) ## ditto | 625941c75fc7496912cc39b5 |
def grab_xml(self, url): <NEW_LINE> <INDENT> r = requests.get(url) <NEW_LINE> return r.content | Given URL string, fetch the content and return it. | 625941c7fff4ab517eb2f473 |
def flip(self): <NEW_LINE> <INDENT> self.leaf_offset *= -1 <NEW_LINE> self.branch_offset *= -1 <NEW_LINE> ha = self.leaf_halign <NEW_LINE> self.leaf_halign = "right" if ha == "left" else "left" <NEW_LINE> ha = self.branch_halign <NEW_LINE> self.branch_halign = "right" if ha == "left" else "left" <NEW_LINE> self.invert_... | Reverse the direction of the x-axis. | 625941c7097d151d1a222e92 |
def predict_outcome(feature_matrix, weights): <NEW_LINE> <INDENT> return np.dot(feature_matrix, weights) | Calculates predicted outcomes based on regression values
:param feature_matrix: 2D array of features
:param weights: 1D array of weightes
:return: 1D array of predicted outcomes | 625941c74e696a04525c9483 |
@PURCHASE.route('/purchase/eway-cancel/<int:object_id>') <NEW_LINE> def eway_cancel(object_id): <NEW_LINE> <INDENT> transaction = models.CardTransaction.get_by_id(object_id) <NEW_LINE> transaction.cancel_eway_payment() <NEW_LINE> return flask.redirect(flask.url_for('dashboard.dashboard_home')) | Callback from a cancelled eWay transaction.
The user is redirected back to this page from the payment gateway if they
cancel the transaction.
Marks the transaction as cancelled and redirects to the dashboard. | 625941c7ff9c53063f47c22c |
def save(object, filename): <NEW_LINE> <INDENT> if filename.endswith('.bz2'): <NEW_LINE> <INDENT> with bz2.BZ2File(filename, 'w') as f: <NEW_LINE> <INDENT> f.write(bytes(object.toJSON(), 'UTF-8')) <NEW_LINE> <DEDENT> <DEDENT> elif filename.endswith('.gz'): <NEW_LINE> <INDENT> with gzip.open(filename, 'wb') as f: <NEW_L... | Save an Oom or Sequence object to file with given filename.
If the filename ends in .bz2 or .gz, compress using bzip2 or gzip. | 625941c70a366e3fb873e851 |
@memoized <NEW_LINE> def client(request): <NEW_LINE> <INDENT> api_url = _get_service_url(request) <NEW_LINE> credentials = { 'token': request.user.token.id, 'auth_url': getattr(settings, 'OPENSTACK_KEYSTONE_URL'), 'endpoint': api_url, 'project_id': request.user.project_id, } <NEW_LINE> credentials['project_domain_name'... | Return a freezer client object | 625941c73317a56b86939c93 |
def dist_mode_z(state, qudit_set): <NEW_LINE> <INDENT> x_errors = () <NEW_LINE> for z_errors in powerset(qudit_set): <NEW_LINE> <INDENT> if op_commutes(x_errors, z_errors, state.stabs) and not find_stab(state, x_errors, z_errors): <NEW_LINE> <INDENT> return "Logical error found: Xs - %s Zs - %s" % (x_errors, z_errors) ... | Args:
state:
qudit_set:
Returns: | 625941c729b78933be1e56e5 |
def get_label_map(meta, data=None, min_count=1): <NEW_LINE> <INDENT> count = {} <NEW_LINE> if data is None: <NEW_LINE> <INDENT> data = meta <NEW_LINE> <DEDENT> for i in data: <NEW_LINE> <INDENT> label = pid2label(i, meta) <NEW_LINE> count[label] = count.get(label,0) + 1 <NEW_LINE> <DEDENT> count = sorted([(count[i],i) ... | Get cancer names which have enough patient samples | 625941c716aa5153ce3624b0 |
def get_state(self, obs): <NEW_LINE> <INDENT> obs_disc = [ int(np.digitize(obs[i], bins=self._get_bins(self.obs_min[i], self.obs_max[i]))) for i in range(len(obs)) ] <NEW_LINE> state = sum([x * (2 * self.n_disc) ** i for i, x in enumerate(obs_disc)]) <NEW_LINE> return state | return discretized state given observation and action | 625941c7a05bb46b383ec85a |
def blit(self, msg, x, y): <NEW_LINE> <INDENT> row = list(self.screen[y]) <NEW_LINE> if (len(msg) + x) > len(row): <NEW_LINE> <INDENT> msg = msg[0:(len(msg) - x)] <NEW_LINE> <DEDENT> row[x:(len(msg) + x)] = msg <NEW_LINE> row = ''.join(row) <NEW_LINE> self.screen[y] = row | Output a string to the screen. Does not wrap around. | 625941c799fddb7c1c9de3c9 |
def get_end_dir(self, requirements, init_pos, orig_dir): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if len(requirements) > 1: <NEW_LINE> <INDENT> if (requirements[-1] - requirements[- 2] > 0): <NEW_LINE> <INDENT> direction = True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> direction = False <NEW_LINE> <DEDENT> <DED... | Checks and returns final direction in al list of requirements.
Keyword arguments:
requirements (list) -- List of requirements
init_pos (integer) -- Initial position in case the list has too few requirements
orig_dir (integer) -- Original directino in case the list has not enough requirements | 625941c75fc7496912cc39b6 |
def test_create_flickr_url(): <NEW_LINE> <INDENT> assert flickr.create_flickr_url({ 'farm': 4, 'server': 123, 'id': 456, 'secret': 789 }, 'm') == 'https://farm4.staticflickr.com/123/456_789_m.jpg' | It should return the correct url | 625941c7c432627299f04c7d |
def test_chain_update(self): <NEW_LINE> <INDENT> block1 = self.create_block() <NEW_LINE> self._identity_obsever.chain_update(block1, []) <NEW_LINE> self._identity_cache.get_role("network", "state_root") <NEW_LINE> self._identity_cache.get_policy("policy1", "state_root") <NEW_LINE> self.assertNotEqual(self._identity_cac... | Test that if there is no fork and only one value is udpated, only
that value is in validated in the catch. | 625941c726238365f5f0eea5 |
def makeConsensus(self, qryseq, hitseq, mindepth=1): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.printLog('#CONS','Generating consensus from qryseq and %d hit sequeces' % len(hitseq)) <NEW_LINE> conseq = '' <NEW_LINE> wild = {True: 'N', False: 'X'}[self.nt()] <NEW_LINE> nocons = ['*', wild, ''] <NEW_LINE> if mind... | Makes a consensus sequence from reference and subsequences.
>> qryseq:str = Full length Reference sequence
>> hitseq:list of strings making consensus (may be missing Cterm/3') | 625941c70a50d4780f666ec9 |
def get(self, topology_id: str, traffic_source: str): <NEW_LINE> <INDENT> errors: List[Dict[str, str]] = [] <NEW_LINE> if "cluster" not in request.args: <NEW_LINE> <INDENT> errors.append({"type": "MissingParameter", "error": "'cluster' parameter should be supplied"}) <NEW_LINE> <DEDENT> if "environ" not in request.args... | Method handling get requests to the current topology packing plan
modelling endpoint. | 625941c74a966d76dd551046 |
def getSalary(self,times): <NEW_LINE> <INDENT> self.readTeacherMsg(self.teacherFile) <NEW_LINE> self.salary += self.classFee * times <NEW_LINE> self.saveTeacherMsg(self.teacherFile) <NEW_LINE> return self.salary | 计算老师的课时费,本课程的课时费乘以次数 | 625941c755399d3f055886eb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.