code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def ArrangeOverride(self,*args): <NEW_LINE> <INDENT> pass | ArrangeOverride(self: Rectangle,finalSize: Size) -> Size | 625941f78e05c05ec3eea9f0 |
def testNoDeadlockFromQueue(self): <NEW_LINE> <INDENT> config = tf.ConfigProto(inter_op_parallelism_threads=1, intra_op_parallelism_threads=1) <NEW_LINE> with self.test_session(config=config) as sess: <NEW_LINE> <INDENT> thread_data_t = collections.namedtuple("thread_data_t", ["thread", "queue", "output"]) <NEW_LINE> t... | Tests that reading does not block main execution threads. | 625941f7956e5f7376d714e1 |
def stop_nodes(self): <NEW_LINE> <INDENT> for node in self.nodes: <NEW_LINE> <INDENT> node.stop_node() <NEW_LINE> <DEDENT> for node in self.nodes: <NEW_LINE> <INDENT> time.sleep(5) <NEW_LINE> node.wait_until_stopped() | Stop multiple ultragated test nodes | 625941f771ff763f4b549d0e |
def _time_order_data_and_metadata_reverse(data, metadata, rays_per_sweep): <NEW_LINE> <INDENT> if 'XHDR' in data: <NEW_LINE> <INDENT> ref_time = data['XHDR'].copy() <NEW_LINE> ref_time.shape = ref_time.shape[:-1] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ref_time = metadata[metadata.keys()[0]]['time'].astype('int32... | Put Sigmet data and metadata in time increasing order by reverse sweep in
time reversed order. | 625941f7442bda511e8bea84 |
def projects_project_id_domains_domain_id_delete_with_http_info(self, project_id, domain_id, **kwargs): <NEW_LINE> <INDENT> all_params = ['project_id', 'domain_id'] <NEW_LINE> all_params.append('callback') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE>... | This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.projects_project_id_domains_domain_id_delete_with_http_info(pro... | 625941f776d4e153a657f1a8 |
def _get_next_fill_color(color): <NEW_LINE> <INDENT> current_index = _get_current_index(color) <NEW_LINE> if current_index == -1: <NEW_LINE> <INDENT> return '%s,%s' % (color.stroke, color.fill) <NEW_LINE> <DEDENT> next_index = _next_index(current_index) <NEW_LINE> while (colors[next_index][_STROKE_COLOR] != colors[curr... | Return the next color pair in the list that shares the same stroke
as color. | 625941f78a349b6b435e87e8 |
def test_finding_all_elements_by_tag(self): <NEW_LINE> <INDENT> value = self.browser.find_by_tag('h1')[0].value <NEW_LINE> value |should| equal_to('Example Header') | should find elements by tag | 625941f7099cdd3c635f12ce |
def to_map(self, db, no_owner, no_privs): <NEW_LINE> <INDENT> dct = super(ForeignServer, self).to_map(db, no_owner, no_privs) <NEW_LINE> for attr in ('type', 'version'): <NEW_LINE> <INDENT> if getattr(self, attr) is None: <NEW_LINE> <INDENT> dct.pop(attr) <NEW_LINE> <DEDENT> <DEDENT> key = self.extern_key() <NEW_LINE> ... | Convert servers and subsidiary objects to a YAML-suitable format
:param no_owner: exclude server owner information
:param no_privs: exclude privilege information
:return: dictionary | 625941f7d8ef3951e3243bb4 |
def writing(self): <NEW_LINE> <INDENT> return self._write_buffer_size > 0 | Returns true if we are currently writing to the stream. | 625941f791f36d47f21acb70 |
def history(self): <NEW_LINE> <INDENT> return _gnuradio_core_gengen.gr_add_const_vss_sptr_history(self) | history(self) -> unsigned int | 625941f7a05bb46b383ece91 |
def test_ansi2latex(self): <NEW_LINE> <INDENT> correct_outputs = { '%s' % (TermColors.Red) : r'{\color{red}}', 'hello%s' % TermColors.Blue: r'hello{\color{blue}}', 'he%s%sllo' % (TermColors.Green, TermColors.Cyan) : r'he{\color{green}}{\color{cyan}llo}', '%shello' % TermColors.Yellow : r'\textbf{\color{yellow}hello}',... | ansi2latex test | 625941f7d99f1b3c44c67bf8 |
@_patch_objstorages(["src", "dst"]) <NEW_LINE> def test_replay_content_check_dst_retry( objstorages, kafka_prefix: str, kafka_consumer_group: str, kafka_server: Tuple[Popen, int], monkeypatch_retry_sleep, caplog, redis_proc, redisdb, ): <NEW_LINE> <INDENT> contents = _fill_objstorage_and_kafka( kafka_server, kafka_pref... | Check the content replayer with a flaky dst objstorage
for 'in' operations. | 625941f78da39b475bd655f3 |
def update_score(player_info, word): <NEW_LINE> <INDENT> player_info[1]=player_info[1]+word_score(word) <NEW_LINE> print(player_info) | ([str, int] list, str) -> NoneType
player_info is a list with the player's name and score. Update player_info
by adding the point value word earns to the player's score.
>>> update_score(['Jonathan', 4], 'ANT') | 625941f744b2445a33932707 |
def zDS(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> x = dataStack.pop() <NEW_LINE> <DEDENT> except IndexError: <NEW_LINE> <INDENT> raise IndexError('DS: ' + hlasky[1]) <NEW_LINE> <DEDENT> return x | vyberie vrchny prvok zo zasobnika dataStack | 625941f7fff4ab517eb2fab7 |
def test_raise_NameError_no_arguments(self): <NEW_LINE> <INDENT> self.assertRaises(NameError, RetrieveMaterialMetadata) | Assert in RetrieveMaterialMetadata - NameError is raised when no arguments is given | 625941f7d53ae8145f87a8d8 |
def next_permutationS(l): <NEW_LINE> <INDENT> n = len(l) <NEW_LINE> last = n-1 <NEW_LINE> while last>0: <NEW_LINE> <INDENT> if l[last-1] < l[last]: break <NEW_LINE> last -= 1 <NEW_LINE> <DEDENT> if last>0: <NEW_LINE> <INDENT> small = l[last-1] <NEW_LINE> big = n-1 <NEW_LINE> while l[big] <= small: big -= 1 <NEW_LINE> l... | Changes a list to its next permutation, in place.
Returns true unless wrapped around so result is lexicographically smaller. | 625941f76e29344779a62c88 |
def _compute_flux_err_conf(amplitude, counts, background, model, c_1, error_sigma): <NEW_LINE> <INDENT> from scipy.optimize import brentq <NEW_LINE> def ts_diff(x, counts, background, model): <NEW_LINE> <INDENT> return (c_1 + error_sigma ** 2) - f_cash(x, counts, background, model) <NEW_LINE> <DEDENT> args = (counts, b... | Compute amplitude errors using likelihood profile method. | 625941f77b25080760e39acb |
def compare_opts_vs_opts(self, olist, sep_ind): <NEW_LINE> <INDENT> EGS = self.egs() <NEW_LINE> olist1 = [] <NEW_LINE> for oind in range(sep_ind): <NEW_LINE> <INDENT> opt = olist[oind] <NEW_LINE> if opt.name.startswith('-compare'): continue <NEW_LINE> olist1.append([opt.name, opt.parlist]) <NEW_LINE> <DEDENT> olist2 = ... | compare first part of option list vs. second part,
split around sep_ind (separation index)
- ignore -compare* options | 625941f7ad47b63b2c50a5f6 |
def _parse_full_series(self, data): <NEW_LINE> <INDENT> series = self._parse_entry(data, Series, './Series') <NEW_LINE> if series: <NEW_LINE> <INDENT> series._load_episodes(data) <NEW_LINE> <DEDENT> return series | Parse XML response and return expected cls instance(s). | 625941f757b8e32f52483b16 |
def setUserPrivilegePrefix(self, prefixes): <NEW_LINE> <INDENT> self.__prefixToPrivilege = {} <NEW_LINE> for privilege, prefix in prefixes.items(): <NEW_LINE> <INDENT> if prefix: <NEW_LINE> <INDENT> self.__prefixToPrivilege[prefix] = privilege | Public method to set the user privilege to prefix mapping.
@param prefixes dictionary with privilege as key and prefix as value | 625941f726238365f5f0f4ed |
def __init__(self, reporter): <NEW_LINE> <INDENT> self.reporter = reporter | @param reporter: A C{TestResult} object. | 625941f7004d5f362079a9a4 |
def test_task_swipe(self): <NEW_LINE> <INDENT> look_card = Home(self.driver) <NEW_LINE> try: <NEW_LINE> <INDENT> card_total = look_card.card_total_num() <NEW_LINE> look_card.get_windows_img() <NEW_LINE> if int(card_total) > 1: <NEW_LINE> <INDENT> before_card_num = look_card.card_current_num() <NEW_LINE> print(before_ca... | 这里一定要以test开头,把测试逻辑封装到一个test开头的方法里面。
:return: | 625941f72eb69b55b151cf30 |
def willExecutePreJobs(self): <NEW_LINE> <INDENT> pass | Indicates that executePreJobs(...) will be executed. | 625941f7bd1bec0571d90ca6 |
def scope(self): <NEW_LINE> <INDENT> return self | return the first node defining a new scope (i.e. Module,
Function, Class, Lambda but also GenExpr, DictComp and SetComp) | 625941f7b5575c28eb68e67d |
def spinn5_fpga_link(x, y, link, root_x=0, root_y=0): <NEW_LINE> <INDENT> x, y = spinn5_chip_coord(x, y, root_x, root_y) <NEW_LINE> return SPINN5_FPGA_LINKS.get((x, y, link)) | Get the identity of the FPGA link which corresponds with the supplied
link.
.. note::
This function assumes the system is constructed from SpiNN-5 boards
whose FPGAs are loaded with the SpI/O 'spinnaker_fpgas' image.
Parameters
----------
x, y : int
The chip whose link is of interest.
link : :py:class:`~r... | 625941f732920d7e50b2884c |
def transform(self, *args): <NEW_LINE> <INDENT> return _robotsim.PointCloud_transform(self, *args) | transform(PointCloud self, double const [9] R, double const [3] t)
void
PointCloud::transform(const double R[9], const double t[3]) | 625941f71f037a2d8b946872 |
def binBoundariesAsList( self): <NEW_LINE> <INDENT> keyword = 'binBoundaries' <NEW_LINE> if keyword not in self._cache: <NEW_LINE> <INDENT> self._cache[keyword] = self._storage.asList() <NEW_LINE> <DEDENT> return self._cache[keyword] | binBoundariesAsList() -> list of bin boundaries | 625941f7be7bc26dc91cdc6a |
def __init__(self, alignment): <NEW_LINE> <INDENT> self._data = alignment <NEW_LINE> d = self.as_dict() <NEW_LINE> for key in d.keys(): <NEW_LINE> <INDENT> setattr(self, key, d[key]) | .. rubric:: constructor
:param alignment: alignment instance from :class:`BAM` | 625941f791af0d3eaac9c094 |
def turn_on(self, **kwargs): <NEW_LINE> <INDENT> self._node.set_switch(self._value.value_id, True) | Turn the device on. | 625941f7d10714528d600362 |
def after_step(self): <NEW_LINE> <INDENT> pass | Called after each iteration. | 625941f7851cf427c661ab7f |
def simple_momentum_comparison(data_obj, strategy_dictionary, fitting_dictionary): <NEW_LINE> <INDENT> validation_indices = fitting_dictionary['validation_indices'] <NEW_LINE> try: <NEW_LINE> <INDENT> validation_indices.remove(len(data_obj.fractional_close)) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> pass <NEW_LIN... | implement simple momentum strategy for comparison to machine learning | 625941f70c0af96317bb885d |
def get_species_schemas(schema_id, species_id, base_url, headers_get): <NEW_LINE> <INDENT> schemas_url, schema_get = simple_get_request(base_url, headers_get, ['species', species_id, 'schemas']) <NEW_LINE> schema_get_status = schema_get.status_code <NEW_LINE> if schema_get_status in [200, 201]: <NEW_LINE> <INDENT> spec... | Determines if a species in Chewie-NS has a schema
with specified identifier.
Parameters
----------
schema_id : str
The identifier of the schema in Chewie-NS.
species_id : str
The identifier of the schema's species in
Chewie-NS.
base_url : str
Base URL of the Chewie-NS instance.
headers_get : dict
H... | 625941f75166f23b2e1a57d0 |
def colorhash(self, slist): <NEW_LINE> <INDENT> clr = generate_colors() <NEW_LINE> chash = {} <NEW_LINE> print(slist) <NEW_LINE> for oris in slist: <NEW_LINE> <INDENT> print(oris) <NEW_LINE> chash[str(oris)] = next(clr) <NEW_LINE> <DEDENT> return chash | Assign a specific color to each ORIS code. | 625941f7b830903b967e9f7a |
def det_toolchain_mpi(ec): <NEW_LINE> <INDENT> tc_elems = ec.toolchain.definition() <NEW_LINE> if TOOLCHAIN_MPI in tc_elems: <NEW_LINE> <INDENT> if not tc_elems[TOOLCHAIN_MPI]: <NEW_LINE> <INDENT> raise EasyBuildError("Empty list of MPI libs for %s toolchain definition: %s", ec.toolchain.as_dict(), tc_elems) <NEW_LINE>... | Determine MPI library of toolchain for given EasyConfig instance.
:param ec: a parsed EasyConfig file (an AttributeError will occur if a simple dict is passed) | 625941f7711fe17d825429d3 |
def test_enumerate_range_start_zero(): <NEW_LINE> <INDENT> output = list(enumerate_range(["a", "b", "c"], start=0)) <NEW_LINE> assert output == [(0, "a"), (1, "b"), (2, "c")] | Verify start=0. | 625941f721bff66bcd684fc3 |
def apply_shift(self, shift): <NEW_LINE> <INDENT> shiftdict = self.build_shift_dict(shift) <NEW_LINE> new_message_text = '' <NEW_LINE> for letter in self.message_text: <NEW_LINE> <INDENT> if letter in shiftdict.keys(): <NEW_LINE> <INDENT> new_message_text += shiftdict[letter] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDEN... | Applies the Caesar Cipher to self.message_text with the input shift.
Creates a new string that is self.message_text shifted down the
alphabet by some number of characters determined by the input shift
shift (integer): the shift with which to encrypt the message.
0 <= shift < 26
Returns: the message text (string) in w... | 625941f7596a89723608a12e |
def purge_account(self, num): <NEW_LINE> <INDENT> account = self.accounts['accounts'][num] <NEW_LINE> userfolder = "%s.%s" % (account['username'], account['api']) <NEW_LINE> utils.make_dir(userfolder + '.old') <NEW_LINE> utils.regex_rename_files('(.*.queue)|(.*.info)|(.*.list)|(.*.meta)', userfolder, userfolder + '.old... | Renames stale cache files for account number **num**. | 625941f7379a373c97cfb1be |
def variable_transformation(v): <NEW_LINE> <INDENT> out = np.zeros_like(v) <NEW_LINE> out[6:10] = v[6:10] <NEW_LINE> out[0:2] = v[0:2] <NEW_LINE> out[2] = v[4] * np.cos(2 * np.pi * v[2]) <NEW_LINE> out[3] = v[4] * np.sin(2 * np.pi * v[2]) <NEW_LINE> out[4] = v[5] * np.cos(2 * np.pi * (v[2] + v[3])) <NEW_LINE> out[5] = ... | v = (x, y, phi_1, phi_2, rho_1, rho_2)
phi_1: angle from horizontal to first point
phi_2: angle from first point to second point
rho_i: distance from fixed point to point_i
Transform v from mixed polar to cartesian coordinates
:param v: v = (x, y, phi_1, phi_2, rho_1, rho_2, R, G, B, alpha)
:return: x = (x1, y1, x2, y... | 625941f7460517430c3947e9 |
def __setitem__(self, *args): <NEW_LINE> <INDENT> return _pyBasePython.mapSCSC___setitem__(self, *args) | __setitem__(self, key_type key, mapped_type x) | 625941f7ff9c53063f47c866 |
def test_escape_regexp_symbols_only_strings(self): <NEW_LINE> <INDENT> self.assertFalse( self.instance.escape_regexp_symbols(42), msg="An integer should not be escaped", ) <NEW_LINE> self.assertFalse( self.instance.escape_regexp_symbols(1.2), msg="A double should not be escaped", ) <NEW_LINE> self.assertFalse( self.ins... | Return false if not a string | 625941f72c8b7c6e89b35e32 |
def is_upper_diagonal(self): <NEW_LINE> <INDENT> if not(self.is_square()): <NEW_LINE> <INDENT> return False; <NEW_LINE> <DEDENT> for i in range(1,self.N_rows): <NEW_LINE> <INDENT> for j in range(0,i): <NEW_LINE> <INDENT> if (self.mat[i,j] != 0): <NEW_LINE> <INDENT> return False; <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> re... | Check whether the matrix is in upper diagonal form | 625941f73346ee7daa2b33e9 |
def animar_fondo(self): <NEW_LINE> <INDENT> self.nubes.rect.move_ip(self.vel_nube, 0) <NEW_LINE> if self.nubes.rect.left + self.nubes.rect.width + 100 < 0: <NEW_LINE> <INDENT> self.nubes.mover(1024) | Cada vez que la pantalla se actualiza, desplaza ligeramente la posición de la nube para simular un
movimiento constante en el fondo. | 625941f763b5f9789fde775d |
def delete(self, location): <NEW_LINE> <INDENT> loc = location.store_location <NEW_LINE> fn = loc.path <NEW_LINE> if os.path.exists(fn): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> LOG.debug(_("Deleting image at %(fn)s"), {'fn': fn}) <NEW_LINE> os.unlink(fn) <NEW_LINE> <DEDENT> except OSError: <NEW_LINE> <INDENT> rais... | Takes a `glance.store.location.Location` object that indicates
where to find the image file to delete
:location `glance.store.location.Location` object, supplied
from glance.store.location.get_location_from_uri()
:raises NotFound if image does not exist
:raises Forbidden if cannot delete because of permissi... | 625941f796565a6dacc8fd3f |
def mysql_restart(): <NEW_LINE> <INDENT> log("restart mysql", yellow) <NEW_LINE> sudo("/etc/init.d/mysql restart") | Restart mysql no servidor | 625941f76aa9bd52df03741f |
def recommend_ad(self): <NEW_LINE> <INDENT> epsilon = self.epsilon <NEW_LINE> if np.random.random() > epsilon: <NEW_LINE> <INDENT> index_ad = np.argmax(self.values) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> index_ad = np.random.randint(self.n - 1) <NEW_LINE> <DEDENT> self.update(index_ad, 1) <NEW_LINE> return index... | Recommends ads | 625941f7baa26c4b54cb178e |
def testCallback(self, client_limit=None): <NEW_LINE> <INDENT> client_rule_set = rdf_foreman.ForemanClientRuleSet(rules=[ rdf_foreman.ForemanClientRule( rule_type=rdf_foreman.ForemanClientRule.Type.REGEX, regex=rdf_foreman.ForemanRegexClientRule( attribute_name="GRR client", attribute_regex="GRR")) ]) <NEW_LINE> with i... | Checks that the foreman uses the callback specified in the action. | 625941f7bde94217f3683461 |
def replacehashtag(text): <NEW_LINE> <INDENT> text = re.sub('#([^\s]+)', 'hashtag', text) <NEW_LINE> return text | Removes hastag in front of a word | 625941f7cb5e8a47e48b8115 |
def get_ds_info(self, ds, metric): <NEW_LINE> <INDENT> mbean = 'jboss.jca:name=%s,service=ManagedConnectionPool' % ds <NEW_LINE> return self.get_prop(mbean, metric) | Get jboss datasource info | 625941f731939e2706e4d4d7 |
def mid_order(self, root): <NEW_LINE> <INDENT> if root is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if root.lchild: <NEW_LINE> <INDENT> self.mid_order(root.lchild) <NEW_LINE> <DEDENT> print(root.data, end=',') <NEW_LINE> if root.rchild: <NEW_LINE> <INDENT> self.mid_order(root.rchild) | 中序遍历 | 625941f766656f66f7cbc824 |
def test_save(self): <NEW_LINE> <INDENT> dummy = BaseModel() <NEW_LINE> init_date = dummy.updated_at <NEW_LINE> dummy.save() <NEW_LINE> final_date = dummy.updated_at <NEW_LINE> self.assertNotEqual(init_date, final_date) | test proper save working
| 625941f750485f2cf553d413 |
def test_Merge_Sort_class__run(self): <NEW_LINE> <INDENT> d = Merge_Sort() <NEW_LINE> d.set_list(self.test_list) <NEW_LINE> d.run(test=True) <NEW_LINE> self.assertEqual(d.list, self.test_list_sorted) <NEW_LINE> for i in range(20): <NEW_LINE> <INDENT> d.set_random(random.randrange(1, 50)) <NEW_LINE> sorted = list(d.list... | Main execution function | 625941f7cad5886f8bd2764f |
def define_data_format(self): <NEW_LINE> <INDENT> data = javabridge.call(self.jobject, "defineDataFormat", "()Lweka/core/Instances;") <NEW_LINE> if data is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return Instances(data) | Returns the data format.
:return: the data format
:rtype: Instances | 625941f7004d5f362079a9a5 |
def page(self): <NEW_LINE> <INDENT> if not hasattr(self, '_page'): <NEW_LINE> <INDENT> self._page = pywikibot.User(self.site, self['title']) <NEW_LINE> <DEDENT> return self._page | Return the target user.
This returns a User object instead of the Page object returned by the
superclass method.
:return: target user
:rtype: pywikibot.User | 625941f763d6d428bbe44b69 |
def getProbabilities(self, filterNames, fiberFlux, fiberFluxErr): <NEW_LINE> <INDENT> if not (len(filterNames) == len(fiberFlux) == len(fiberFluxErr)): <NEW_LINE> <INDENT> raise ValueError("Lengths of arguments must be equal.") <NEW_LINE> <DEDENT> if not filterNames: <NEW_LINE> <INDENT> nSEDs = len(self.fluxLibrary) <N... | Calculate a chi square and a probability for each model SED.
Parameters
----------
filterNames : `list` of `str`
List of filters used to measure the fiber fluxes for each filter.
e.g. ``["g", "i"]``.
fiberFlux : `list` of `float`
Array of fiber fluxes for each fiber, in [nJy].
fiberFluxErr : `list` of `flo... | 625941f791f36d47f21acb71 |
def set_monitored_resource_attributes(span): <NEW_LINE> <INDENT> resource = monitored_resource.get_instance() <NEW_LINE> if resource is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> resource_type = resource.get_type() <NEW_LINE> resource_labels = resource.get_labels() <NEW_LINE> def set_attribute_label(attribute... | Set labels to span that can be used for tracing.
:param span: Span object | 625941f76fb2d068a760f71f |
def check_gender(self, gender_code): <NEW_LINE> <INDENT> if self.is_male(): <NEW_LINE> <INDENT> current_gender_codes = self.male_codes <NEW_LINE> <DEDENT> elif self.is_female(): <NEW_LINE> <INDENT> current_gender_codes = self.female_codes <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise ValueError("unknown gender co... | makes sure that the parents match their expected gender.
Rather than returning true/false I've chosen to raise an error, as this
is a problem with the input data that needs to be fixed.
Args:
gender_code: mothers, are "2", while fathers, are "1" | 625941f71d351010ab856191 |
def show_how_it_works(func): <NEW_LINE> <INDENT> def myfunction(*args, **kwargs): <NEW_LINE> <INDENT> print('Running function:', func.__name__) <NEW_LINE> print('Positional arguments:', args) <NEW_LINE> print('Keyword argments:', kwargs) <NEW_LINE> result = func(*args, **kwargs) <NEW_LINE> print('Result:', result) <NEW... | 引数と戻り値を表示するデコレータ | 625941f723849d37ff7b3701 |
def recur(n: int) -> int: <NEW_LINE> <INDENT> s = Stack(n) <NEW_LINE> while True: <NEW_LINE> <INDENT> if n > 0: <NEW_LINE> <INDENT> s.push(n) <NEW_LINE> n = n - 1 <NEW_LINE> continue <NEW_LINE> <DEDENT> if not s.is_empty(): <NEW_LINE> <INDENT> n = s.pop() <NEW_LINE> print(n) <NEW_LINE> n = n - 2 <NEW_LINE> continue <NE... | 재귀를 제거한 recur() 함수 | 625941f7e76e3b2f99f3ae77 |
def add_dot2path(): <NEW_LINE> <INDENT> sep = ':' <NEW_LINE> if os.name == 'nt': sep = ';' <NEW_LINE> paths = os.environ.get('PATH','').split(sep) <NEW_LINE> paths.insert(0, os.path.abspath(os.curdir)) <NEW_LINE> os.environ['PATH'] = sep.join(paths) | add this folder to begninng of PATH environmental variable | 625941f701c39578d7e754b2 |
def radial_average_spectrum(kx, ky, pds2d): <NEW_LINE> <INDENT> N = kx.shape[0] <NEW_LINE> df = np.unique(kx)[np.unique(kx) > 0][0] <NEW_LINE> k = np.sqrt(np.square(kx) + np.square(ky)) <NEW_LINE> psd1d = np.zeros(int(N/2-1)) <NEW_LINE> for i in range(len(psd1d)): <NEW_LINE> <INDENT> ind = np.multiply(k >= (i+0.5)*df, ... | Calculate the radially averaged power spectrum
Parameters: kx - 2D np.ndarray in size of (N,N) for frequency in x direction
kx - 2D np.ndarray in size of (N,N) for frequency in y direction
psd2d - 2D np.ndarray in size of (N,N) for 2D power spectral density
Returns: freq - 1D np.ndarra... | 625941f7090684286d50f368 |
def MktFund(self,etfLof='',listStatusCd='L',secID='',ticker='',category='',operationMode='',field=''): <NEW_LINE> <INDENT> code, result = self.client.getData(vs.FUND%(etfLof, listStatusCd, secID, ticker, category, operationMode, field)) <NEW_LINE> return _ret_data(code, result) | 获取基金的基本档案信息,包含基金名称、交易代码、分级情况、所属类别、保本情况、
上市信息、相关机构、投资描述等信息。收录了2005年以来的历史数据,数据更新频率为不定期。 | 625941f7046cf37aa974d3b8 |
def connect(): <NEW_LINE> <INDENT> conv_dict = MySQLdb.converters.conversions <NEW_LINE> conv_dict[type(None)] = lambda a, b: str("DEFAULT") <NEW_LINE> if config.CURSOR is not None: <NEW_LINE> <INDENT> close() <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> conn = MySQLdb.connect(host=config.LOCAL["db"]["host"], user=conf... | Connnect to the database and close if necesarry | 625941f74f88993c3716c6d7 |
def is_smartcd_installed(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> run("bash", "-ic", "smartcd", "--help") <NEW_LINE> return True <NEW_LINE> <DEDENT> except CalledProcessError: <NEW_LINE> <INDENT> return False | Run smartcd command to check if it"s installed. | 625941f721a7993f00bc8374 |
def isBytes(s): <NEW_LINE> <INDENT> if g.isPython3: <NEW_LINE> <INDENT> return isinstance(s, bytes) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | Return True if s is Python3k bytes type. | 625941f75510c4643540fa4a |
def appendChildren(self, parentPage): <NEW_LINE> <INDENT> grandParentExpanded = self.__getItemExpandState(parentPage.parent) <NEW_LINE> if grandParentExpanded: <NEW_LINE> <INDENT> for child in parentPage.children: <NEW_LINE> <INDENT> if child not in self._pageCache: <NEW_LINE> <INDENT> self.insertChild(child) <NEW_LINE... | Добавить детей в дерево
parentPage - родительская страница, куда добавляем дочерние страницы | 625941f79f2886367277aeff |
def GetOutputBackgroundValue(self): <NEW_LINE> <INDENT> return _itkBinaryImageToStatisticsLabelMapFilterPython.itkBinaryImageToStatisticsLabelMapFilterIUS2IF2LM2_GetOutputBackgroundValue(self) | GetOutputBackgroundValue(self) -> unsigned long | 625941f7a79ad161976cc7bd |
def testRenderConfiguration(self): <NEW_LINE> <INDENT> pass | Test RenderConfiguration | 625941f7cc0a2c11143dd509 |
def url(self): <NEW_LINE> <INDENT> return URL("tcp://%s:%d"%self.name()) if self.family()==ip.PF_INET else URL("tcp://[%s]:%d"%self.name()) | Return the socket's URL, i.e. tcp://<host>:<port>. | 625941f7090684286d50f369 |
def tokenized_text_reader(encoding: str = "utf-8") -> PlainTextFileReader: <NEW_LINE> <INDENT> def reader(files: List[str]) -> Iterable[List[str]]: <NEW_LINE> <INDENT> lines = string_reader(encoding) <NEW_LINE> for line in lines(files): <NEW_LINE> <INDENT> yield line.strip().split(' ') <NEW_LINE> <DEDENT> <DEDENT> retu... | Get reader for space-separated tokenized text. | 625941f74c3428357757c99a |
def __init__(self, **kwargs): <NEW_LINE> <INDENT> self.attributes = kwargs.get("attributes", {}) <NEW_LINE> self.tag_name = kwargs.get("tag_name", None) <NEW_LINE> self.body = kwargs.get("body", "") <NEW_LINE> self.elements = kwargs.get("elements", []) | Create a new Element with the given attributes.
:param tag_name: Can be used to dynamically add a tag name different
from the class tag name.
:param attributes: The element attributes
:param elements: Initial list of sub-elements
:param body: Element body
:return: | 625941f7ec188e330fd5ae08 |
def _get_timeout(): <NEW_LINE> <INDENT> timeout = config.get_config_val('core.timeout') <NEW_LINE> if not timeout: <NEW_LINE> <INDENT> timeout = DEFAULT_TIMEOUT <NEW_LINE> <DEDENT> return timeout | :returns: timout value for API calls
:rtype: str | 625941f7e1aae11d1e74a336 |
def test_print_words(self): <NEW_LINE> <INDENT> buffer = StringIO() <NEW_LINE> with redirect_stdout(buffer): <NEW_LINE> <INDENT> self.module.print_words("books/alice.txt") <NEW_LINE> output = buffer.getvalue().splitlines() <NEW_LINE> <DEDENT> self.assertEqual(len(output), 4950) | Check the console output from print_words() | 625941f78c3a873295158a3b |
def __init__(self, data=None, **kwds): <NEW_LINE> <INDENT> self.data = data <NEW_LINE> self.aes = make_aes(**kwds) <NEW_LINE> self.legend = {} | Initialize layer object.
Parameters:
-----------
data: pandas DataFrame instance
aes: aesthetics dictionary with bindings | 625941f7d10714528d600363 |
def remove (self, values, times=1) : <NEW_LINE> <INDENT> self.__mutable__() <NEW_LINE> for value in iterate(values) : <NEW_LINE> <INDENT> self._remove(value, times) | Remove values to the multiset.
>>> m = MultiSet([1, 2, 2, 3] * 2)
>>> list(sorted(m.items()))
[1, 1, 2, 2, 2, 2, 3, 3]
>>> m.remove(2, 3)
>>> list(sorted(m.items()))
[1, 1, 2, 3, 3]
>>> m.remove([1, 3], 2)
>>> list(sorted(m.items()))
[2]
@param values: the values to remove or a single value to
remove
@type values... | 625941f7d7e4931a7ee9e597 |
def predict(model, input_shape, windowed, ground_truth, features, normalizer): <NEW_LINE> <INDENT> results = {} <NEW_LINE> for key in ground_truth.labels.keys(): <NEW_LINE> <INDENT> spectrogram = np.copy(features[key]) <NEW_LINE> effective_shape = input_shape <NEW_LINE> if input_shape[0] != spectrogram.shape[1] and inp... | Predict values using the given model, spectrogram input shape, ground truth,
features dict and normalizer function.
:param model: model
:param input_shape: single spectrogram shape
:param windowed: if ``true``, predict for multiple windows
:param ground_truth: ground truth necessary to convert indices to actual labels... | 625941f73d592f4c4ed1d6d2 |
def move_down(self): <NEW_LINE> <INDENT> for columns in range(0, self.cols, 1): <NEW_LINE> <INDENT> temp_list = [] <NEW_LINE> for rows in range(self.rows - 1, -1, -1): <NEW_LINE> <INDENT> temp_list.append(self.grid[rows][columns]) <NEW_LINE> <DEDENT> new_list = merge(temp_list) <NEW_LINE> for rows in range(self.rows - ... | Move all tiles down | 625941f767a9b606de4a852d |
def annotate_body( self, soup: bs4.BeautifulSoup, df: pd.DataFrame, show_mean: bool ) -> None: <NEW_LINE> <INDENT> for i, row in enumerate(soup.find("tbody").findAll("tr")): <NEW_LINE> <INDENT> cell = row.find("th") <NEW_LINE> if self.transposed: <NEW_LINE> <INDENT> cell["title"] = self.tests[i].describe() <NEW_LINE> <... | [summary]
Args:
soup (BeautifulSoup): [description]
df (DataFrame): [description]
show_mean (bool): [description] | 625941f766673b3332b92709 |
def obtener(self): <NEW_LINE> <INDENT> return self.valor | Retorna el puntaje en forma de número. | 625941f730bbd722463cc442 |
def form_valid(self, form): <NEW_LINE> <INDENT> response = super().form_valid(form) <NEW_LINE> set_language(self.request, response, form.cleaned_data['language']) <NEW_LINE> return response | Set or reset the current language. | 625941f73317a56b8693a2bf |
def throttleExp2Lin(self,y): <NEW_LINE> <INDENT> xmax=self.throttleControl.maximum() <NEW_LINE> ymax=0.5 <NEW_LINE> beta=3. <NEW_LINE> return xmax*(y/ymax)**(1./beta) | Convert Scene.throttle (in seconds) to the position of the throttle control. This is the inverse of :obj:`throttleInt2Float` giving :math:`x(y)=\exp\left(\frac{y}{y_{\max}}\log(x_{\max}+1)\right)-1`. | 625941f78a43f66fc4b546d5 |
@u.quantity_input( p=[u.Hz, u.s], pd=[u.Hz / u.s, u.s / u.s], pdd=[u.Hz / u.s ** 2, u.s / u.s ** 2] ) <NEW_LINE> def p_to_f(p, pd, pdd=None): <NEW_LINE> <INDENT> f = 1.0 / p <NEW_LINE> fd = -pd / (p * p) <NEW_LINE> if pdd is None: <NEW_LINE> <INDENT> return [f, fd] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if pdd =... | Converts P, Pdot to F, Fdot (or vice versa)
Convert period, period derivative and period second
derivative (if supplied) to the equivalent frequency counterparts.
Will also convert from F to P.
Parameters
----------
p : astropy.units.Quantity
pulsar period (or frequency), :math:`P` (or :math:`f`)
pd : astropy.uni... | 625941f7287bf620b61d40d7 |
def pull_highest_priority_element(pq): <NEW_LINE> <INDENT> ind, _ = min(enumerate(pq), key=lambda k: k[1][1]) <NEW_LINE> print(pq[ind][0]) <NEW_LINE> pq.pop(ind) | pull element with the highest priority | 625941f7b7558d58953c557d |
def create_response(self, request, data, response_class=HttpResponse, **response_kwargs): <NEW_LINE> <INDENT> if type(data) is Bundle: <NEW_LINE> <INDENT> data = { self.Meta.resource_name: data } <NEW_LINE> <DEDENT> desired_format = self.determine_format(request) <NEW_LINE> serialized = self.serialize(request, data, de... | Extracts the common "which-format/serialize/return-response" cycle.
Mostly a useful shortcut/hook. | 625941f7c432627299f052c3 |
def config_keychains(keychains): <NEW_LINE> <INDENT> pass | Add config data to keychains object. | 625941f7d18da76e23532b57 |
def __init__(self, obj): <NEW_LINE> <INDENT> self.object = obj <NEW_LINE> self.claimed = False | Creates a new Element, wrapping the passed object as the
pooled resource.
:param obj: the resource to wrap
:type obj: object | 625941f75166f23b2e1a57d1 |
def from_db_value(self, value, expression, connection, context): <NEW_LINE> <INDENT> return value.split("|") | Renvoyer la valeur python depuis la valeur de la db | 625941f771ff763f4b549d10 |
def show_dhcp_server( enode): <NEW_LINE> <INDENT> cmd = [ 'show dhcp-server' ] <NEW_LINE> result = enode( (' '.join(cmd)).format(**locals()), shell='vtysh' ) <NEW_LINE> return parse_show_dhcp_server(result) | Display DHCP server configuration.
This function runs the following vtysh command:
::
# show dhcp-server
:return: A dictionary as returned by
:func:`topology_lib_vtysh.parser.parse_show_dhcp_server` | 625941f7e76e3b2f99f3ae78 |
def __init__(self, api_key='', key_file=None, method_cache=missing, log=None): <NEW_LINE> <INDENT> if not getattr(self, 'api_url', None): <NEW_LINE> <INDENT> raise AssertionError('No api_url configured.') <NEW_LINE> <DEDENT> if self.api_url.endswith('/'): <NEW_LINE> <INDENT> raise AssertionError('api_url should not end... | Creates a new API instance. When called with no arguments,
reads the appropriate API key from the default ($HOME/.etsy/keys)
file.
Parameters:
api_key - An explicit API key to use.
key_file - A file to read the API keys from.
method_cache - A file to save the API method table in for
... | 625941f7796e427e537b0c44 |
def createTest(request): <NEW_LINE> <INDENT> if Doctor.objects.filter(pk=request.user.id): <NEW_LINE> <INDENT> ex = 'TestDoctor' <NEW_LINE> if request.method == 'POST': <NEW_LINE> <INDENT> form = forms.CreateTestForm(request.POST) <NEW_LINE> if form.is_valid(): <NEW_LINE> <INDENT> form.save() <NEW_LINE> log = LogEntry(... | view for creating a new test
:param request: the request to create a new test
:return: Redirect to the test creation form | 625941f763b5f9789fde775e |
def test_acidity(self): <NEW_LINE> <INDENT> ionic_strength_list = [0, .01, .1] <NEW_LINE> temperature_list = [20., 25., 30.] <NEW_LINE> for name in self.database.keys(): <NEW_LINE> <INDENT> ion = self.database.load(name) <NEW_LINE> for T in temperature_list: <NEW_LINE> <INDENT> for I in ionic_strength_list: <NEW_LINE> ... | Test that all acidities are computable. | 625941f7ac7a0e7691ed4736 |
def getDataInfo(self, templates, histStack = True): <NEW_LINE> <INDENT> useData = ((not self.plotBlind) and histStack) <NEW_LINE> if self.realData and not self.dataName in templates: <NEW_LINE> <INDENT> printer.printWarning( "\tno {} template available for data".format(self.dataName)) <NEW_LINE> useData = False <NEW_LI... | get info if data is used and label for data | 625941f7956e5f7376d714e3 |
def _getUserPresetNames(self): <NEW_LINE> <INDENT> preset = self._userPresetsDict.get(self._sysName, dict()) <NEW_LINE> return sorted(preset.keys()) | Get a sorted list of current preset names
| 625941f72ae34c7f2600d7a8 |
def test_assert_none(): <NEW_LINE> <INDENT> b = BST() <NEW_LINE> assert not len(bft(b)) | Test passing an empty bst. | 625941f7462c4b4f79d1dd47 |
def add_data(self, name, data): <NEW_LINE> <INDENT> self._add_data(self.el_request, {name: data}) | Generate a request from a data dictionary.
To create a node hierarchy, the values can be dicts or lists (which
must contain dicts). For example::
.add_data(
'root-name',
data={
'outer': {'inner': 0},
'items': [{'item': 1}, {'item': 2}],
})
<FbiXml>
<Ticke... | 625941f7a4f1c619b28b06a0 |
def __init__(self, acquisition: Acquisition): <NEW_LINE> <INDENT> self.acquisition = acquisition | :param acquisition: Base acquisition function that is log transformed. This acquisition function must output
positive values only. | 625941f726068e7796caf361 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, SiteRoleCreate): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941f794891a1f4081c125 |
def stop(self): <NEW_LINE> <INDENT> if self.status in (TransferState.PAUSED, TransferState.RUNNING): <NEW_LINE> <INDENT> self._running.clear() <NEW_LINE> self._stop_signal = True <NEW_LINE> self.join() <NEW_LINE> self._abort_upload() <NEW_LINE> self._status = TransferState.STOPPED <NEW_LINE> if self._callback: <NEW_LIN... | Stops the upload.
:raises SbgError: If upload is not in PAUSED or RUNNING state. | 625941f7566aa707497f4bd7 |
def train(model, dataloader, optimizer, criterion, epoch_number, max_gradient_norm): <NEW_LINE> <INDENT> model.train() <NEW_LINE> device = model.device <NEW_LINE> epoch_start = time.time() <NEW_LINE> batch_time_avg = 0.0 <NEW_LINE> running_loss = 0.0 <NEW_LINE> correct_preds = 0 <NEW_LINE> tqdm_batch_iterator = tqdm(da... | Train a model for one epoch on some input data with a given optimizer and
criterion.
Args:
model: A torch module that must be trained on some input data.
dataloader: A DataLoader object to iterate over the training data.
optimizer: A torch optimizer to use for training on the input model.
criterion: A ... | 625941f715fb5d323cde1192 |
def p_cardinality_many(self, p): <NEW_LINE> <INDENT> if p[1] not in ['M', 'MC']: <NEW_LINE> <INDENT> raise ParsingException("illegal cardinality (%s) at %s:%d" % (p[1], p.lexer.filename, p.lineno(1))) <NEW_LINE> <DEDENT> p[0] = p[1] | cardinality : ID | 625941f7009cb60464c63a24 |
def set_max_output_buffer(self, *args): <NEW_LINE> <INDENT> return _lora_swig.mod_sptr_set_max_output_buffer(self, *args) | set_max_output_buffer(mod_sptr self, long max_output_buffer)
set_max_output_buffer(mod_sptr self, int port, long max_output_buffer) | 625941f77b25080760e39acd |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.