code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def _test_distance_correlation_vector_generic(self, vector_type=None, type_cov=None, type_cor=None): <NEW_LINE> <INDENT> if type_cov is None: <NEW_LINE> <INDENT> type_cov = vector_type <NEW_LINE> <DEDENT> if type_cor is None: <NEW_LINE> <INDENT> type_cor = vector_type <NEW_LINE> <DEDENT> arr1 = np.array([vector_type(1)... | Auxiliar function for testing distance correlation in vectors.
This function is provided to check that the results are the
same with different dtypes, but that the dtype of the result is
the right one. | 625941d894891a1f4081bd12 |
def makeRelativePath(self, fname): <NEW_LINE> <INDENT> return os.path.relpath(fname, self.operaRoot).replace(os.path.sep, '/') | Returns the path of fname relative to the opera root | 625941d84e696a04525c96b4 |
def monkey_patch(): <NEW_LINE> <INDENT> __builtin__.file = File <NEW_LINE> __builtin__.open = File | Replace file and open builtins. | 625941d83eb6a72ae02ec74a |
def read(self, where=None, columns=None, **kwargs): <NEW_LINE> <INDENT> if not self.read_axes(where=where, **kwargs): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> factors = [Categorical.from_array(a.values) for a in self.index_axes] <NEW_LINE> levels = [f.levels for f in factors] <NEW_LINE> N = [len(f.levels) fo... | we have n indexable columns, with an arbitrary number of data
axes | 625941d8c432627299f04eb0 |
def get_nns_by_id(self, embedding_id, n): <NEW_LINE> <INDENT> raise NotImplementedError | Returns the ``n`` nearest neighbors of the ``embedding_id`` | 625941d876d4e153a657ed9a |
def is_qos_grid_column_present(self, column_name): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.logger.info('Start: is qos grid column present') <NEW_LINE> return self._sell_page.is_qos_grid_column_present(column_name) <NEW_LINE> <DEDENT> except WebDriverException as exp: <NEW_LINE> <INDENT> self.logger.error(exp.... | Returning is qos grid column present
Implementing logging for is qos grid column present functionality
:param column_name:
:return: True/False | 625941d8004d5f362079a59b |
def group_by_centroid(restaurants, centroids): <NEW_LINE> <INDENT> locations = [restaurant_location(l) for l in restaurants] <NEW_LINE> closest_loc = [find_closest(c, centroids) for c in locations] <NEW_LINE> couple = [[closest_loc[x], restaurants[x]] for x in range(len(locations)) ] <NEW_LINE> return group_by_first(co... | Return a list of clusters, where each cluster contains all restaurants
nearest to a corresponding centroid in centroids. Each item in
restaurants should appear once in the result, along with the other
restaurants closest to the same centroid. | 625941d8e1aae11d1e749f21 |
def _execute_splitter_partitioner(self, pre_allocated_resources): <NEW_LINE> <INDENT> if not self._application_graph.n_vertices: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> with FecTimer(MAPPING, "Splitter partitioner"): <NEW_LINE> <INDENT> self._machine_graph, self._n_chips_needed = splitter_partitioner( self._appl... | Runs, times and logs the SplitterPartitioner if required
:param pre_allocated_resources: other preallocated resources
:type pre_allocated_resources:
~pacman.model.resources.PreAllocatedResourceContainer | 625941d8be8e80087fb20ea8 |
def test_untyped_linkable_dataset_accepts_link(self): <NEW_LINE> <INDENT> link = LinkBuilder(name='untyped_linkable_ds', builder=DatasetBuilder('foo')) <NEW_LINE> self.validate_linkability(link, expect_error=False) | Test that the validator accepts a link when the spec has an untyped linkable dataset | 625941d8c4546d3d9de72c9e |
def updateUnionTable(self, spinSystemComp): <NEW_LINE> <INDENT> intersectData = [] <NEW_LINE> colorMatrix = [] <NEW_LINE> for resComp in spinSystemComp.intersection: <NEW_LINE> <INDENT> oneRow = [resComp.resonance_name] <NEW_LINE> oneRow.extend(resComp.shifts_description) <NEW_LINE> oneRow.append(resComp.delta) <NEW_LI... | Update the table that shows the resonance types that are
present in both spin systems.
args: spinSystemComp: SpinSystemComparison comparing the two
selected spin systems. | 625941d8099cdd3c635f0ec2 |
def drum_name_to_note_number(drum_name): <NEW_LINE> <INDENT> normalized_drum_name = __normalize_str(drum_name) <NEW_LINE> normalized_drum_names = [__normalize_str(name) for name in __DRUM_MAP] <NEW_LINE> try: <NEW_LINE> <INDENT> note_index = normalized_drum_names.index(normalized_drum_name) <NEW_LINE> <DEDENT> except: ... | Converts a drum name to the corresponding MIDI note number for a percussion
instrument. Conversion is case, whitespace, and non-alphanumeric character
insensitive.
:parameters:
- drum_name : str
Name of a drum which exists in the general MIDI standard.
If the drum is not found, a ValueError is rai... | 625941d86fece00bbac2d9a9 |
def erase(self, *args): <NEW_LINE> <INDENT> return _iorange.VectorOfInt32_erase(self, *args) | erase(self, pos) -> std::vector< int >::iterator
erase(self, first, last) -> std::vector< int >::iterator | 625941d84428ac0f6e5baa5c |
def get_img_pages_and_download(self, url): <NEW_LINE> <INDENT> url = self.parser(self.request(url).decode(), '//div[@class="content"]/a/img/@src')[-1] <NEW_LINE> content = self.request(url) <NEW_LINE> filename = url.split('/')[-2] + '/' + url.split('/')[-1] <NEW_LINE> self.download_img(content, filename) | pass | 625941d84a966d76dd551279 |
def deleteChannel(self, channel): <NEW_LINE> <INDENT> del self.data[channel] | Removes the specified channel from the buffer.
:param channel: The channel to remove. | 625941d891f36d47f21ac75d |
def score_item(worda, wordb, components, scorer, phrasegrams): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return phrasegrams[tuple(components)][1] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> return -1 | score is retained from original dataset
| 625941d80a366e3fb873ea84 |
def _get_budget_limit() -> int: <NEW_LINE> <INDENT> return db.fetchall("budget", ["daily_limit"])[0]["daily_limit"] | Возвращает дневной лимит трат для основных базовых трат | 625941d8d7e4931a7ee9e186 |
def insert_record( self, record, record_encoding = "binary", is_data_encoded = True ): <NEW_LINE> <INDENT> if isinstance( record, dict ): <NEW_LINE> <INDENT> record = GPUdbRecord( self.record_type, record ) <NEW_LINE> <DEDENT> if not isinstance( is_data_encoded, bool ): <NEW_LINE> <INDENT> raise GPUdbException( "Input ... | Queues a record for insertion into GPUdb. If the queue reaches the
:meth:`batch size <get_batch_size>`, all records in the queue will be
inserted into GPUdb before the method returns. If an error occurs while
inserting the records, the records will no longer be in the queue nor in
GPUdb; catch :class:`InsertionExceptio... | 625941d8a8ecb033257d3335 |
def update(self): <NEW_LINE> <INDENT> return 'Updated GCP Cloud DNS Record.' | Update GCP Cloud DNS Records. | 625941d8711fe17d825425cf |
def context_get(self, stack, name): <NEW_LINE> <INDENT> def cast_to_str(arg): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return str(arg) <NEW_LINE> <DEDENT> except UnicodeEncodeError: <NEW_LINE> <INDENT> return arg <NEW_LINE> <DEDENT> <DEDENT> def unquote(arg): <NEW_LINE> <INDENT> if arg == "''": <NEW_LINE> <INDENT> ... | FIXME: doc | 625941d8e64d504609d74aa8 |
def main(script): <NEW_LINE> <INDENT> with open("/home/cohara/github/automate/data/vanilla_stdout2.txt") as stdout: <NEW_LINE> <INDENT> runtimes = [] <NEW_LINE> lines = stdout.readlines() <NEW_LINE> regex = re.compile(r'Runtime\: (\d+) seconds') <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> if regex.findall(line): ... | Pull out runtime data from stdout of incomplete Spark job. | 625941d85e10d32532c5f18f |
def _interp_universe(x, xmf, mf_val): <NEW_LINE> <INDENT> slope = (xmf[1] - xmf[0]) / float(x[1] - x[0]) <NEW_LINE> x_interp = (mf_val - xmf[0]) / slope <NEW_LINE> return x_interp | Finds the universe variable corresponding to membership `mf_val`.
Parameters
----------
x : 1d array
Independent discrete variable vector.
xmf : 1d array
Fuzzy membership function for x. Same length as x.
mf_val : float
Discrete singleton value on membership function mfx.
Returns
-------
x_interp : float... | 625941d831939e2706e4d0d0 |
def reset(self): <NEW_LINE> <INDENT> self._session_id = None | Indicate the current session IF is no longer valid | 625941d860cbc95b062c67ac |
def stack(*figure_numbers, **kwds): <NEW_LINE> <INDENT> wnds = find_figure_handles(*figure_numbers) <NEW_LINE> numfigs = len(wnds) <NEW_LINE> if numfigs > 0: <NEW_LINE> <INDENT> screenpos = get_screen_position_and_size(wnds) <NEW_LINE> y_step = 25 <NEW_LINE> x_step = border = 5 <NEW_LINE> figs_per_stack = kwds.get( 'fi... | Stack figure windows.
Parameters
----------
figure_numbers : list of integers or string
specifying which figures to stack (default 'all').
kwds : dict with the following keys
figs_per_stack :
number of figures per stack (default depends on screenheight)
Description
-----------
STACK stacks all open... | 625941d8e76e3b2f99f3aa71 |
def OnSecuritiesChanged(self, algorithm, changes): <NEW_LINE> <INDENT> pass | OnSecuritiesChanged(self: CompositeRiskManagementModel, algorithm: QCAlgorithm, changes: SecurityChanges)
Event fired each time the we add/remove
securities from the data feed.
This
method patches this call through the each of the
wrapped models.
algorithm: The algorithm ... | 625941d8de87d2750b85fffd |
def get_dc(self, dc_id): <NEW_LINE> <INDENT> dc_dict = {} <NEW_LINE> return dc_dict | Get data collection with id <dc_id>
:param int dc_id: The collection id
:returns: Data collection dict | 625941d8090684286d50ef50 |
@pytest.fixture(scope="module") <NEW_LINE> def rate_2g_mle(): <NEW_LINE> <INDENT> n_stimuli = 30 <NEW_LINE> n_dim = 10 <NEW_LINE> n_group = 2 <NEW_LINE> stimuli = tf.keras.layers.Embedding( n_stimuli+1, n_dim, mask_zero=True ) <NEW_LINE> shared_similarity = psiz.keras.layers.ExponentialSimilarity( beta_initializer=tf.k... | A MLE rate model with group-specific kernel. | 625941d8d6c5a102081442b5 |
def value(self): <NEW_LINE> <INDENT> Q = self.q_value.mev <NEW_LINE> x = Q / CoulombBarrier(self.smaller, self.larger).width(self.q_value).fermis <NEW_LINE> t0 = math.sqrt((2 * self.smaller.mass.mev)/(HBAR_MEV_S**2 * Q)) <NEW_LINE> t1 = self.smaller.atomic_number * self.larger.atomic_number * FINE_STRUCTURE_... | Compute the Gamow factor. | 625941d891af0d3eaac9bc84 |
def test_login_with_correct_email_and_password(self): <NEW_LINE> <INDENT> self.app.signup(self.user) <NEW_LINE> self.assertTrue(self.app.login('angelalehru@gmail.com','1234')) | user to login with correct email and password | 625941d81d351010ab855d84 |
def test_1_metadata(self): <NEW_LINE> <INDENT> A = tgis.open_old_stds("A", type="str3ds") <NEW_LINE> A.select() <NEW_LINE> self.assertEqual(A.get_map_time(), "point") <NEW_LINE> self.assertModule("t.snap", input="A", type="str3ds") <NEW_LINE> A.select() <NEW_LINE> self.assertEqual(A.get_map_time(), "interval") | Set title, description and aggregation | 625941d823849d37ff7b32f7 |
def create_new_attribute_list(self, direction, attrs): <NEW_LINE> <INDENT> assert direction in ('up', 'down', 'top', 'bottom'), direction <NEW_LINE> nodes = {attr.node() for attr in attrs} <NEW_LINE> self.new_attribute_order = {} <NEW_LINE> for node in nodes: <NEW_LINE> <INDENT> selected_attrs = [attr.longName() for at... | Move the given attributes up or down. | 625941d863f4b57ef000137d |
def to_http_info(self, config): <NEW_LINE> <INDENT> if self.drawing_data is None: <NEW_LINE> <INDENT> raise ValueError("Missing the required parameter `drawing_data` when calling `put_drawing_dxf`") <NEW_LINE> <DEDENT> collection_formats = {} <NEW_LINE> path = '/cad/dxf' <NEW_LINE> path_params = {} <NEW_LINE> query_par... | Prepares initial info for HTTP request
:param config: CAD API configuration
:type: asposecadcloud.Configuration
:return: http_request configured http request
:rtype: Configuration.models.requests.HttpRequest | 625941d8d164cc6175782fb7 |
def to_dict(self): <NEW_LINE> <INDENT> result = {} <NEW_LINE> for attr, _ in six.iteritems(self.swagger_types): <NEW_LINE> <INDENT> value = getattr(self, attr) <NEW_LINE> if isinstance(value, list): <NEW_LINE> <INDENT> result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) <NEW_LINE> <... | Returns the model properties as a dict | 625941d8fff4ab517eb2f6a6 |
def __init__(self, gene_symbol, ref_genome='hg38', uri=GENOME_EDITING_URI): <NEW_LINE> <INDENT> self.ref_genome = ref_genome <NEW_LINE> self.gene_symbol = gene_symbol.upper() <NEW_LINE> if ref_genome == 'mm10': <NEW_LINE> <INDENT> table_name = 'ucsc_mm10_refgene' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> table_name... | Args:
gene_symbol: gene symbol
table_name: the table name in db containing gene annotation
engine: sqla engine | 625941d83cc13d1c6d3c75e2 |
def register_all(engine): <NEW_LINE> <INDENT> for name, val in sys.modules[__name__].__dict__.items(): <NEW_LINE> <INDENT> if hasattr(val, 'is_registerable'): <NEW_LINE> <INDENT> engine.register(val.operator_name, val) | iterate over all members of this module and register all functors with
'register' attribute | 625941d882261d6c526ab70b |
def get_indices(self, query, knn): <NEW_LINE> <INDENT> assert query.dim() == 2 and query.size(1) == self.k_dim <NEW_LINE> if self.use_different_keys is False: <NEW_LINE> <INDENT> return self._get_indices(query, knn, self.keys) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> bs = len(query) <NEW_LINE> query = query.view(-... | Generate scores and indices given unnormalized queries. | 625941d856b00c62f0f148c4 |
def _get_joint_min_max_vel(self, jname): <NEW_LINE> <INDENT> root = self._robot_description_xml_root <NEW_LINE> if root is not None: <NEW_LINE> <INDENT> joint_type = root.findall(".joint[@name='" + jname + "']")[0].attrib['type'] <NEW_LINE> if joint_type == "continuous": <NEW_LINE> <INDENT> limit = root.findall(".//joi... | Get the min and max from the robot description for a given joint. | 625941d8f7d966606f6aa270 |
def get( self, resource_group_name, local_network_gateway_name, custom_headers=None, raw=False, **operation_config): <NEW_LINE> <INDENT> url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}' <NEW_LINE> path_format_arguments ... | Gets the specified local network gateway in a resource group.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param local_network_gateway_name: The name of the local network
gateway.
:type local_network_gateway_name: str
:param dict custom_headers: headers that will be adde... | 625941d832920d7e50b2843b |
def checkTypo(self, input_value, expected_value): <NEW_LINE> <INDENT> self.assertEqual(expected_value, typo.typography(input_value)) | Helper for checking typo.typography | 625941d810dbd63aa1bd2e0c |
def start_scrape(wrapper, course_id): <NEW_LINE> <INDENT> it = wrapper.get_post_iterator(limit=-1) <NEW_LINE> user_stats_dict = {} <NEW_LINE> scrape_record = Scrape(course_scanned=course_id) <NEW_LINE> for obj in it: <NEW_LINE> <INDENT> scrape_record.posts_scanned += 1 <NEW_LINE> cid = obj['nr'] <NEW_LINE> op = obj['hi... | Begin the scraping process targeting the specified Piazza course id
:param wrapper: Piazza wrapper
:param course_id: Piazza course ID
:type wrapper: PiazzaWrapper
:type course_id: str | 625941d873bcbd0ca4b2c2df |
def __init__(self): <NEW_LINE> <INDENT> self.first = [] <NEW_LINE> self.last = [] | Initialize your data structure here. | 625941d8d58c6744b4257ec8 |
def __newParticipant(self, nick): <NEW_LINE> <INDENT> if nick == "": <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> color = self.chatEdit.textColor() <NEW_LINE> self.chatEdit.setTextColor(Qt.gray) <NEW_LINE> self.chatEdit.append( QDateTime.currentDateTime().toString(Qt.SystemLocaleLongDate) + ":") <NEW_LINE> self.chatE... | Private slot handling a new participant joining.
@param nick nick name of the new participant (string) | 625941d8097d151d1a2230c1 |
def _centre(self,matrix,centre): <NEW_LINE> <INDENT> return mu.Matrix([ [ 1.0, 0.0, -centre[0] ], [ 0.0, 1.0, -centre[1] ], [ 0.0, 0.0, 1.0 ] ]) * matrix | convert from top-left origin to given origin | 625941d89c8ee82313fbb9df |
@pytest.mark.parametrize("mesh", [ create_unit_square(MPI.COMM_WORLD, 12, 13), create_unit_cube(MPI.COMM_WORLD, 12, 18, 15) ]) <NEW_LINE> @pytest.mark.parametrize("degree", [1, 2]) <NEW_LINE> def test_nullspace_orthogonal(mesh, degree): <NEW_LINE> <INDENT> V = VectorFunctionSpace(mesh, ('Lagrange', degree)) <NEW_LINE> ... | Test that null spaces orthogonalisation | 625941d8377c676e91272412 |
def add_image(dialog, widget, cat_shape): <NEW_LINE> <INDENT> element = cat_shape.lower() <NEW_LINE> if type(widget) is str or type(widget) is str: <NEW_LINE> <INDENT> widget = dialog.findChild(QWidget, widget) <NEW_LINE> <DEDENT> if not widget: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if type(widget) is QLabel: ... | Set pictures for UD | 625941d8a8370b7717052b08 |
def p_elsecondition(p): <NEW_LINE> <INDENT> pass | elsecondition : ELSE block
| | 625941d8d268445f265b50d8 |
def guess(self, id=None, model=None, limits=True, values=True): <NEW_LINE> <INDENT> if model is None: <NEW_LINE> <INDENT> id, model = model, id <NEW_LINE> <DEDENT> kwargs = {'limits': limits, 'values': values} <NEW_LINE> if model is not None: <NEW_LINE> <INDENT> model = self._check_model(model) <NEW_LINE> try: <NEW_LIN... | Estimate the parameter values and ranges given the loaded data.
The guess function can change the parameter values and
limits to match the loaded data. This is generally limited to
changing the amplitude and position parameters (sometimes just
the values and sometimes just the limits). The parameters that
are changed ... | 625941d80a366e3fb873ea85 |
def create_question(question_text, days): <NEW_LINE> <INDENT> time = timezone.now() + datetime.timedelta(days=days) <NEW_LINE> return Question.objects.create(question_text=question_text, pub_date=time) | Create a question with the give `question_text` and published the
given number of `days` offset to now (negative for questions published
in the past, positive for questions that have yet to be published). | 625941d826238365f5f0f0db |
def _connect_child(self, argv): <NEW_LINE> <INDENT> if os.name != "nt": <NEW_LINE> <INDENT> self._child_watcher = asyncio.get_child_watcher() <NEW_LINE> self._child_watcher.attach_loop(self._loop) <NEW_LINE> <DEDENT> coroutine = self._loop.subprocess_exec(self._fact, *argv) <NEW_LINE> self._loop.run_until_complete(coro... | Connect to Nvim using the 'child' method of attach.
Internally, uses asyncio subprocesses. At this time, the default
Windows default EventLoop does **NOT** support shelling out.
:param argv: Args to pass to the loop's :meth:`subprocess_exec`. | 625941d8ad47b63b2c50a1e9 |
def list_volume(self, object_id): <NEW_LINE> <INDENT> if self.features.SSC_API_V2: <NEW_LINE> <INDENT> return self._list_volume_v2(object_id) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return self._list_volume_v1(object_id) | Retrieve the given volume from array.
:param object_id: The volume id, label, or wwn
:return The volume identified by object_id
:raise VolumeNotFound if the volume could not be found | 625941d8507cdc57c6306f49 |
def display(self): <NEW_LINE> <INDENT> return self.__display or inflection.titleize(self.__name) | Returns the display text for this column.
:return <str> | 625941d8711fe17d825425d0 |
def view_post(self, title=None, index=None): <NEW_LINE> <INDENT> if title: <NEW_LINE> <INDENT> for article in self.articles: <NEW_LINE> <INDENT> if article.title == title: <NEW_LINE> <INDENT> return article.view() <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> if index: <NEW_LINE> <INDENT> return self.other_posts[index].view() ... | Open a blog entry to view the full article.
If no title or index is provided, return a random blog article
:param str title: (optional) select an article to view by its title
:param int index: (optional) select an article by it list index
:return: a blog article
:rtype: :py:class:`~pages.web.blog.Article` | 625941d816aa5153ce3626e1 |
def _create_session(self): <NEW_LINE> <INDENT> delay = 1 <NEW_LINE> while True: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.vim = self._get_vim_object() <NEW_LINE> session = self.vim.Login( self.vim.get_service_content().sessionManager, userName=self._host_username, password=self._host_password) <NEW_LINE> if sel... | Creates a session with the VC/ESX host. | 625941d8d6c5a102081442b6 |
def verifyHostKey(transport, host, pubKey, fingerprint): <NEW_LINE> <INDENT> actualHost = transport.factory.options['host'] <NEW_LINE> actualKey = keys.Key.fromString(pubKey) <NEW_LINE> kh = KnownHostsFile.fromPath(FilePath( transport.factory.options['known-hosts'] or os.path.expanduser(_KNOWN_HOSTS) )) <NEW_LINE> ui =... | Verify a host's key.
This function is a gross vestige of some bad factoring in the client
internals. The actual implementation, and a better signature of this logic
is in L{KnownHostsFile.verifyHostKey}. This function is not deprecated yet
because the callers have not yet been rehabilitated, but they should
eventual... | 625941d8d4950a0f3b08c5b6 |
def longestLine(self, M: List[List[int]]) -> int: <NEW_LINE> <INDENT> if len(M) == 0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> self.rows = len(M) <NEW_LINE> self.cols = len(M[0]) <NEW_LINE> self.graph = M <NEW_LINE> for row in range(self.rows): <NEW_LINE> <INDENT> for col in range(self.cols): <NEW_LINE> <INDENT... | Time Complexity: O(N^2*M^2)
Space Complexity: O(N*M)
[
[0, 1, 1, 0],
[0, 1, 1, 0],
[0, 0, 0, 1]
] | 625941d81b99ca400220ad1c |
def test_organism_part(self): <NEW_LINE> <INDENT> record = self.data[1] <NEW_LINE> breed = fill_uid_breed(record, self.country) <NEW_LINE> animal = fill_uid_animal( record, breed, self.submission, {}) <NEW_LINE> sample = fill_uid_sample( record, animal, self.submission) <NEW_LINE> organism_part = DictUberon.objects.get... | Check that an 'unknown' organims_part generate a DictUberon
relying on sample_type_name (see crbanim_test_data.csv file) | 625941d832920d7e50b2843c |
def retry(self): <NEW_LINE> <INDENT> for title, artist in self.fail_list: <NEW_LINE> <INDENT> self.set(title = title, artist = artist) | Rematch lyrics for the failed songs. | 625941d815fb5d323cde0d7c |
def test_page_alias(self): <NEW_LINE> <INDENT> c = self.get_admin_client() <NEW_LINE> c.login(username='batiste', password='b') <NEW_LINE> page_data = self.get_new_page_data() <NEW_LINE> page_data['title'] = 'home-page-title' <NEW_LINE> page_data['slug'] = 'home-page' <NEW_LINE> response = c.post('/admin/basic_cms/page... | Test page aliasing system | 625941d845492302aab5e530 |
def cat(ts1: Tensor, ts2: Tensor, axes: int) -> Tensor: <NEW_LINE> <INDENT> cat_op = CatOp(axes) <NEW_LINE> return cat_op(ts1, ts2) | Cat two tensors within given axes
:param ts1:
:param ts2:
:param axes:
:return: | 625941d8796e427e537b0831 |
def getRealizedResClassPriorsVect(self): <NEW_LINE> <INDENT> return PolytomyTopoPriorCalculatorBase.getRealizedResClassPriorsVect(self) | Constructs a vector of realized resolution class priors from the
vector of priors already stored. The mth element of the returned
vector is set to T_{n,m}*p_{n,m} for m > 0, where T_{n,m} is the
number of trees for n taxa and m internal nodes, and p_{n,m} is the
prior currently being used in MCMC analyses for tree topo... | 625941d82c8b7c6e89b35a2a |
def HostInternetScsiHbaTargetSet(vim, *args, **kwargs): <NEW_LINE> <INDENT> obj = vim.client.factory.create('ns0:HostInternetScsiHbaTargetSet') <NEW_LINE> if (len(args) + len(kwargs)) < 0: <NEW_LINE> <INDENT> raise IndexError('Expected at least 1 arguments got: %d' % len(args)) <NEW_LINE> <DEDENT> required = [ ] <NEW_... | A collection of one or more static targets or discovery addresses. At least one
of the arrays must be non-empty. | 625941d8adb09d7d5db6c9f8 |
def right_of(qubit: GridQubit) -> GridQubit: <NEW_LINE> <INDENT> return GridQubit(qubit.row + 1, qubit.col) | Gives node with one unit more on the first coordinate.
Args:
qubit: Reference node.
Returns:
New translated node. | 625941d8b830903b967e9b73 |
def get_current_pose_and_wait(self, unit='rad'): <NEW_LINE> <INDENT> self.__get_position_event.clear() <NEW_LINE> if self.__get_position_event.wait(20): <NEW_LINE> <INDENT> pos, rot = self.PyKDLFrame_to_NumpyArray(self.__position_cartesian_current) <NEW_LINE> if unit == 'deg': <NEW_LINE> <INDENT> rot = U.rad_to_deg(rot... | :param unit: 'rad' or 'deg'
:return: Numpy.array | 625941d82eb69b55b151cb1b |
def create(self, request, *args, **kwargs): <NEW_LINE> <INDENT> if isinstance(request.data, QueryDict): <NEW_LINE> <INDENT> request.data._mutable = True <NEW_LINE> <DEDENT> if request.data.get("parent_id") is not None: <NEW_LINE> <INDENT> if not has_perm(self.request.user, "motions.can_create_amendments"): <NEW_LINE> <... | Customized view endpoint to create a new motion. | 625941d87d847024c06be528 |
def two_factor_auth_callback( self, callback: Optional[Union[Callable, int]] ) -> None: <NEW_LINE> <INDENT> if not callback: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if not isinstance(callback, abc_collections.Callable): <NEW_LINE> <INDENT> raise ValueError("Your callback should be callable") <NEW_LINE> <DEDENT> ... | Register our 2FA callback specified by the user. | 625941d8796e427e537b0832 |
@requires_auth <NEW_LINE> def update_playlist(id, body): <NEW_LINE> <INDENT> logging.debug("{users_controller} BEGIN function update_playlist()") <NEW_LINE> if id is '': <NEW_LINE> <INDENT> return RESP.response_400(message='The id parameter is empty!') <NEW_LINE> <DEDENT> if body['name'] is '': <NEW_LINE> <INDENT> retu... | Updates a playlist matching a given id with given the given name | 625941d84c3428357757c591 |
def run(self, *args): <NEW_LINE> <INDENT> traverseObj = self.hierarchy_traverse = _HierarchyTraverse( self.window, self.on_done) <NEW_LINE> traverseObj.run() | Initializes the _HierarchyTraverse object and runs it.
The on_done method is passed as the function that's called once a
choice has been made in the panel.
This function is called when the user invokes the command. | 625941d863d6d428bbe4475a |
@render() <NEW_LINE> def show(request): <NEW_LINE> <INDENT> closed_statuses = [item.id for item in task_m.Status.objects.filter(status=1)] <NEW_LINE> tasks_assigned = task_m.Task.objects.filter( assigned = request.user ).exclude( status__in = closed_statuses ).order_by('-date_modified') <NEW_LINE> tasks_createdby = tas... | Pokazuje glowna strone tablicy uzytkownika | 625941d8a934411ee37518fe |
def total(number): <NEW_LINE> <INDENT> if number <= 0 or not number or number > 64: <NEW_LINE> <INDENT> raise ValueError(ERROR) <NEW_LINE> <DEDENT> return 2 ** number - 1 | Calculates the total number of grains
:param number:
:return: | 625941d8aad79263cf390cae |
def load_images_with_labels(type_of_data = "training", path = "./MNIST_data"): <NEW_LINE> <INDENT> if type_of_data is "training": <NEW_LINE> <INDENT> images = os.path.join(path, 'train-images-idx3-ubyte') <NEW_LINE> labels = os.path.join(path, 'train-labels-idx1-ubyte') <NEW_LINE> <DEDENT> elif type_of_data is "testing... | Extracts the imagesa and corresponding labels from the MNIST data set. | 625941d80c0af96317bb8452 |
def test_product_is_installed(self): <NEW_LINE> <INDENT> pid = 'collective.assets' <NEW_LINE> installed = [p['id'] for p in self.qi_tool.listInstalledProducts()] <NEW_LINE> self.assertTrue(pid in installed, 'package appears not to have been installed') | Validate that our products GS profile has been run and the product
installed | 625941d8bf627c535bc13439 |
def _update_config(template_name, template_source=None, template_path=None, template_hash=None, template_hash_name=None, template_user='root', template_group='root', template_mode='755', saltenv=None, template_engine='jinja', skip_verify=True, defaults=None, test=False, commit=True, debug=False, replace=False, **templa... | Call the necessary functions in order to execute the state.
For the moment this only calls the ``net.load_template`` function from the
:mod:`Network-related basic features execution module <salt.modules.napalm_network>`, but this may change in time. | 625941d8b5575c28eb68e26c |
@root.route('/img/<id:int>.svg') <NEW_LINE> def get_image(id): <NEW_LINE> <INDENT> path = None <NEW_LINE> for root, dirs, files in os.walk(IMAGE_DIR): <NEW_LINE> <INDENT> results = [file for file in files if file.startswith('{0:04d}'.format(id))] <NEW_LINE> if results: <NEW_LINE> <INDENT> path = results[0] <NEW_LINE> b... | Find an image with the given id.
Returns either an svg file or a 404 error. | 625941d8566aa707497f47d0 |
@main.command() <NEW_LINE> @click.argument('template', nargs=1, required=True) <NEW_LINE> @click.option('-v', '--version', default=None, help='Git SHA or branch of template to use for update') <NEW_LINE> def switch(template, version): <NEW_LINE> <INDENT> temple.update.update(new_template=template, new_version=version) | Switch a project's template to a different template. | 625941d8a79ad161976cc3b0 |
def get_state_dir(self): <NEW_LINE> <INDENT> in_config_path = self.sessconfig.get(u'general', u'state_dir') <NEW_LINE> return in_config_path or self.get_default_state_dir() | Returns the directory the Session stores its state in.
@return An absolute path name. | 625941d84e696a04525c96b6 |
def get_mtime(ssdroot, vol): <NEW_LINE> <INDENT> return os.stat("%s/%s" % (ssdroot, vol)).st_mtime | Get last modification time of snapshot/volume. | 625941d8cc40096d61595bba |
def setVerbose(self, verbose): <NEW_LINE> <INDENT> self._verbose = verbose | Sets if the channel should be in verbose mode or not.
:param verbose: True if the channel is in verbose mode, False otherwise
:type verbose: boolean | 625941d84428ac0f6e5baa5d |
def write_gui_wt(self, title, a_string ): <NEW_LINE> <INDENT> self.write_gui( " =============== " + title + " ==> \n" + a_string ) | write to gui with a title.
title the title
a_string additional stuff to write
make a better function with title = "" ??
title the string with some extra formatting
clear and write string to input area | 625941d85f7d997b87174d04 |
def admin_url(model, url, object_id=None): <NEW_LINE> <INDENT> opts = model._meta <NEW_LINE> url = f"admin:{opts.app_label}_{opts.object_name.lower()}_{url}" <NEW_LINE> args = () <NEW_LINE> if object_id is not None: <NEW_LINE> <INDENT> args = (object_id,) <NEW_LINE> <DEDENT> return reverse(url, args=args) | Returns the URL for the given model and admin url name. | 625941d8c432627299f04eb2 |
def test_function(first_param, *arguments, **keywords): <NEW_LINE> <INDENT> assert first_param == 'first param' <NEW_LINE> assert arguments == ('second param', 'third param') <NEW_LINE> assert keywords == { 'fourth_param_name': 'fourth named param', 'fifth_param_name': 'fifth named param' } | This function accepts its arguments through "arguments" tuple and keywords dictionary. | 625941d88a43f66fc4b542cd |
def fourth_order_beam(lmax, ltreshold, epstreshold=0.04): <NEW_LINE> <INDENT> rhs = 2 * np.log(epstreshold) <NEW_LINE> sigma = -rhs / (ltreshold**2 * (ltreshold + 1)**2) <NEW_LINE> l = np.arange(lmax + 1) <NEW_LINE> cl = np.exp(-l**2 * (l + 1)**2 * sigma) <NEW_LINE> return np.sqrt(cl) | Squared Gaussian beam in SH space. | 625941d89c8ee82313fbb9e0 |
def distance_theta(p1, p2, theta): <NEW_LINE> <INDENT> coord1 = to_coord(p1) <NEW_LINE> coord2 = to_coord(p2) <NEW_LINE> dist = distance(p1, p2) <NEW_LINE> angle = math.atan2(coord2[1]-coord1[1], coord2[0]-coord1[0]) <NEW_LINE> a_diff = theta - angle <NEW_LINE> projected = dist*math.cos(a_diff) <NEW_LINE> return projec... | This function calculates the theta component between two points,
the complementary component being orthogonal to theta. | 625941d871ff763f4b5498f9 |
def make_puma_church_prime_ripl(*args, **kwargs): <NEW_LINE> <INDENT> return Puma().make_church_prime_ripl(*args, **kwargs) | Construct and return a VentureScript RIPL object that parses input in the abstract syntax and traces models in the Puma backend. | 625941d866673b3332b922fc |
def write_case(self, updating=False): <NEW_LINE> <INDENT> FreeCAD.Console.PrintMessage("Start to write case to folder {}\n".format(self.solver_obj.WorkingDir)) <NEW_LINE> _cwd = os.curdir <NEW_LINE> os.chdir(self.solver_obj.WorkingDir) <NEW_LINE> self.write_mesh() <NEW_LINE> self.write_solver_name() <NEW_LINE> self.wri... | Write_case() will collect case setings, and finally build a runnable case
| 625941d8099cdd3c635f0ec4 |
def dtype(input): <NEW_LINE> <INDENT> pass | Return the data type of the tensor.
Parameters
----------
input : Tensor
The input tensor.
Returns
-------
data type
It should be one of the values in the data type dict. | 625941d8f7d966606f6aa271 |
def update_mirror_info(self, repo_id, dry_run): <NEW_LINE> <INDENT> repository_information = self.get_repo_info(repo_id) <NEW_LINE> repo = format_repo_information(repository_information, self.forge_url, self.github_org) <NEW_LINE> if not repo: <NEW_LINE> <INDENT> raise ValueError('Error when trying to retrieve detailed... | Given a repository identifier, retrieve information on such
repository and update github information on that repository. | 625941d8ec188e330fd5aa06 |
def get_service(self, service_id): <NEW_LINE> <INDENT> url = '/OS-KSADM/services/%s' % service_id <NEW_LINE> resp, body = self.get(url) <NEW_LINE> body = json.loads(body) <NEW_LINE> return resp, body['OS-KSADM:service'] | Get Service | 625941d8cad5886f8bd27243 |
def dfs_path(self, node=None, path=None, pathscore=0, store_all_paths=False, depth=0): <NEW_LINE> <INDENT> if path is None: <NEW_LINE> <INDENT> path = tuple() <NEW_LINE> <DEDENT> if node is None: <NEW_LINE> <INDENT> node = self.root <NEW_LINE> <DEDENT> newpath = path + tuple([node['id']]) <NEW_LINE> pathscore += self.s... | Depth-First-Search of access graph posibilities, where final score is calculated
whenever a leaf is reached.
This is the 'truest' traversal of the graph, and gives much more power when it comes
to determining schedule validity *as it is is built*, and not after the fact.
Main detriment is that it is godawfully slo... | 625941d84a966d76dd55127b |
def Start(self): <NEW_LINE> <INDENT> read_pipe, write_pipe = os.pipe() <NEW_LINE> self._output_stream = os.fdopen(write_pipe, 'w', 0) <NEW_LINE> self._thread = threading.Thread(target=self._Run) <NEW_LINE> self._thread.start() <NEW_LINE> return os.fdopen(read_pipe, 'r') | Returns a pipe to the merged output stream. | 625941d830bbd722463cc032 |
def marginal(self, i, name=None): <NEW_LINE> <INDENT> pmf = Pmf(name=name) <NEW_LINE> for vs, p in self.items(): <NEW_LINE> <INDENT> pmf[vs[i]] += p <NEW_LINE> <DEDENT> return pmf | Gets the marginal distribution of the indicated variable.
i: index of the variable we want
name: string
:return: Pmf | 625941d891f36d47f21ac75f |
def read_wav(filename): <NEW_LINE> <INDENT> fs, s = wavfile.read(filename) <NEW_LINE> s = np.array(s)/float(max(abs(s))) <NEW_LINE> s = add_wgn(s) <NEW_LINE> return fs,s | read wav file.
Normalizes signal to values between -1 and 1.
Also add some jitter to remove all-zero segments. | 625941d8442bda511e8be680 |
def containsNearbyDuplicate(self, nums, k): <NEW_LINE> <INDENT> d={} <NEW_LINE> for i,x in zip(range(len(nums )),nums): <NEW_LINE> <INDENT> if x not in d: <NEW_LINE> <INDENT> d[x]=i <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if i-d[x]<=k: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ... | :type nums: List[int]
:type k: int
:rtype: bool | 625941d80a366e3fb873ea86 |
def blur_value(self, value): <NEW_LINE> <INDENT> self.blur_value_now = value <NEW_LINE> print('Blur: ', value) <NEW_LINE> self.update() | This function will take value from the slider
for the blur from 0 to 99 | 625941d84f6381625f114ca6 |
def get_handler(self, tag): <NEW_LINE> <INDENT> self._handler = self.make_handler(tag) <NEW_LINE> self._handler.send(None) <NEW_LINE> return self._handler | Get a handler object that accepts objects to build the CID file
section corresponding to the tag. The handler object initializes
itself it has been closed.
Example:
h = c.get_handler('A1')
h.send(some_A1_obj) | 625941d8187af65679ca5389 |
def custom_contents_id_get(self, id, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('async_req'): <NEW_LINE> <INDENT> return self.custom_contents_id_get_with_http_info(id, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.custom_contents_id_get_with_h... | custom_contents_id_get # noqa: E501
Returns a custom content item, matching the provided ID # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.custom_contents_id_get(id, async_req=True)
>>> result = thread.get()
:pa... | 625941d87b180e01f3dc4a64 |
def sendTask( self, robot, task ): <NEW_LINE> <INDENT> while not ( self.task_pub.get_num_connections() >= self.config["performers"]["quantity"] ): <NEW_LINE> <INDENT> rospy.sleep( 0.1 ) <NEW_LINE> <DEDENT> self.task_pub.publish( robot.id, str(task) ) <NEW_LINE> self.robot_handlers[robot.id].assignTask( task, self.next_... | Assign and send a task to the robot | 625941d899cbb53fe6792e51 |
def is_bob_great(self): <NEW_LINE> <INDENT> return True | Hail Bob. | 625941d8099cdd3c635f0ec5 |
def _get_path(self, pos, dest, length): <NEW_LINE> <INDENT> path = {} <NEW_LINE> if pos[0] == dest[0]: <NEW_LINE> <INDENT> for i in range(pos[1], dest[1], 1 if dest[1]>pos[1] else -1): <NEW_LINE> <INDENT> if (pos[0], i) not in path: <NEW_LINE> <INDENT> path[(pos[0], i)] = length <NEW_LINE> <DEDENT> length += 1 <NEW_LIN... | Return dict of lengths on coords between possition and destination. | 625941d830c21e258bdfa709 |
def product(*generators, repeat=1): <NEW_LINE> <INDENT> if len(generators) == 0: <NEW_LINE> <INDENT> yield () <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> generators = generators * repeat <NEW_LINE> it = generators[0] <NEW_LINE> for item in it() if callable(it) else iter(it): <NEW_LINE> <INDENT> for items in product(*... | Cartesian product akin to :func:`itertools.product`, but accepting
generator functions
Unlike :func:`itertools.product` this function does not convert the input
iterables into tuples. Thus, it can handle large or infinite inputs. As a
drawback, however, it only works with "restartable" iterables (something
that :func:... | 625941d896565a6dacc8f935 |
def python_executable(): <NEW_LINE> <INDENT> if not sys.executable: <NEW_LINE> <INDENT> raise RuntimeError('Failed to retrieve the real path for the Python executable binary') <NEW_LINE> <DEDENT> return sys.executable | Returns the real path for the Python executable, if it exists. Returns RuntimeError otherwise.
Returns:
(str): the real path of the current Python executable | 625941d856ac1b37e6264437 |
def set_property(obj, key, val): <NEW_LINE> <INDENT> pass | This method should set the value of the property named "key" on the object whose
id is "obj" to the value "val". | 625941d89b70327d1c4e1040 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.