code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def restricted_forum(**kwargs): <NEW_LINE> <INDENT> permission_code = kwargs.pop( 'permission_code', 'forums_forum.view_in_forum') <NEW_LINE> kwargs.pop('save', True) <NEW_LINE> new_forum = forum(save=True, **kwargs) <NEW_LINE> ct = ContentType.objects.get_for_model(new_forum) <NEW_LINE> permission(codename=permission_... | Creates a restricted forum.
:arg permission_code: Defaults to "forums_forum.view_in_forum"
Any additional arguments are passed to the created forum.
.. Note::
Always saves the forum it creates.
:returns: the created restricted forum | 625941eb4f88993c3716c552 |
def load_plugins(): <NEW_LINE> <INDENT> return { entry_point.name: entry_point.load()() for entry_point in iter_entry_points() } | Load and return a dictionary with plugins by their names. | 625941eb187af65679ca560f |
def pccc_decoder_combined_fs(*args, **kwargs): <NEW_LINE> <INDENT> return _trellis.pccc_decoder_combined_fs(*args, **kwargs) | pccc_decoder_combined_fs(fsm FSMo, int STo0, int SToK, fsm FSMi, int STi0, int STiK,
interleaver INTERLEAVER, int blocklength,
int repetitions, trellis_siso_type_t SISO_TYPE,
int D, __dummy_4__ TABLE, trellis_metric_type_t METRIC_TYPE,
float scaling) -> trellis_pccc_decoder_combined_fs_sptr | 625941ebac7a0e7691ed45b2 |
def get_length(): <NEW_LINE> <INDENT> length = get_float("What is the length? ") <NEW_LINE> return length | Get length from user | 625941eb9f2886367277ad79 |
def max_profit_5(prices, K): <NEW_LINE> <INDENT> inf = float("inf") <NEW_LINE> n = len(prices) <NEW_LINE> dp = [[[0, 0] for _ in range(K+1)] for _ in range(n)] <NEW_LINE> for i in range(n): <NEW_LINE> <INDENT> for k in range(1, K+1): <NEW_LINE> <INDENT> if i == 0: <NEW_LINE> <INDENT> dp[i][k][0] = 0 <NEW_LINE> dp[i][k]... | 最多交易2次,状态转移方程退化为
dp[i][k][0] = max(dp[i-1][k][0], dp[i-1][k][1]+prices[i])
dp[i][k][1] = max(dp[i-1][k][1], dp[i-1][k-1][0]-prices[i]) | 625941eb2ae34c7f2600d620 |
def mediatype_create(name, mediatype, **kwargs): <NEW_LINE> <INDENT> conn_args = _login(**kwargs) <NEW_LINE> ret = {} <NEW_LINE> try: <NEW_LINE> <INDENT> if conn_args: <NEW_LINE> <INDENT> method = 'mediatype.create' <NEW_LINE> params = {"description": name} <NEW_LINE> params['type'] = mediatype <NEW_LINE> params = _par... | Create new mediatype
.. note::
This function accepts all standard mediatype properties: keyword
argument names differ depending on your zabbix version, see here__.
.. __: https://www.zabbix.com/documentation/3.0/manual/api/reference/mediatype/object
:param mediatype: media type - 0: email, 1: script, 2: ... | 625941eb26068e7796caf1d7 |
def __init__(self, *args, **kwds): <NEW_LINE> <INDENT> if args or kwds: <NEW_LINE> <INDENT> super(Unicycle, self).__init__(*args, **kwds) <NEW_LINE> if self.velocity is None: <NEW_LINE> <INDENT> self.velocity = 0. <NEW_LINE> <DEDENT> if self.w is None: <NEW_LINE> <INDENT> self.w = 0. <NEW_LINE> <DEDENT> <DEDENT> else: ... | Constructor. Any message fields that are implicitly/explicitly
set to None will be assigned a default value. The recommend
use is keyword arguments as this is more robust to future message
changes. You cannot mix in-order arguments and keyword arguments.
The available fields are:
velocity,w
:param args: complete ... | 625941ebadb09d7d5db6cc7c |
def basic_cancel(self, callback=None, consumer_tag: str='', nowait=False): <NEW_LINE> <INDENT> raise NotImplemented() | tell server to not send any more message to a consumer | 625941eb379a373c97cfb037 |
def __init__(self, worker_count, libtrace_uri, args, server_mode): <NEW_LINE> <INDENT> self.worker_count = worker_count <NEW_LINE> self.args = args <NEW_LINE> self.libtrace_uri = libtrace_uri <NEW_LINE> self.server_mode = server_mode <NEW_LINE> self.__initialize_queues() <NEW_LINE> self.__set_interface_addresses() <NEW... | The initialisation of a pathspider plugin.
:param worker_count: The number of workers to use.
:type worker_count: int
:param libtrace_uri: The URI to pass to the Observer to describe the
interface on which packets should be captured.
:type libtrace_uri: str
:param server_mode: Whether the spider s... | 625941ebd99f1b3c44c67a75 |
def remove_by_id(self,studid): <NEW_LINE> <INDENT> self.__eraseOpAbove() <NEW_LINE> self.__undoController.eraseCtrlAbove() <NEW_LINE> oldstud=deepcopy(self.fetch_stud(studid)) <NEW_LINE> self.__repo.remove_by_id(studid) <NEW_LINE> if isinstance(oldstud,Student): <NEW_LINE> <INDENT> self.__operations.append(RemoveOperat... | Removes by id a student
Because we modify we insert a copy of our preceding list into the undo (stack)
Input:stud's id which will be removed
verifies if we have student's id if not we cannot remove anything and the remove_by_id methond stops | 625941eb92d797404e30467c |
def __init__(self, npop=40, ngen=30, cxpb=0.6, mutpb=0.2, mu=None, lambda_=None, skip=1): <NEW_LINE> <INDENT> self.__log.debug('Init Evolution') <NEW_LINE> self._npop = npop <NEW_LINE> self._ngen = ngen <NEW_LINE> self._cxpb = cxpb <NEW_LINE> self._mutpb = mutpb <NEW_LINE> if mu is None: <NEW_LINE> <INDENT> mu = npop <... | Init the evolution manager.
Parameters
----------
npop: int
Size of population
ngen: int
Number of evolve
cxpb: float
Crossover probability (<1).
mutpb: float
Mutation probability (<1).
mu: float
The number of individuals to select for the next generation.
lambda_: float
The number of children ... | 625941eb56ac1b37e62646b5 |
def __CreateGirderRigidarmSketch(self): <NEW_LINE> <INDENT> rGR=self.structureGeometry.rGirderRigidarmCoordinate <NEW_LINE> rRS=self.structureGeometry.rRigidarmSuspenderCoordinate <NEW_LINE> girderRigidarmSketch=[] <NEW_LINE> for i in range(len(rGR)): <NEW_LINE> <INDENT> mySketch = self.structureModel.ConstrainedSketch... | Create Girder Rigidarm Sketch
function summary
Args:
Returns:
Raises: | 625941ebd18da76e235329cc |
def plot_raster(trials, color="#3498db", lw=1, ax=None, marker='.', marker_size=10, ylabel='Trials', id_start=0, ylim=None): <NEW_LINE> <INDENT> from matplotlib.ticker import MaxNLocator <NEW_LINE> if ax is None: <NEW_LINE> <INDENT> fig, ax = plt.subplots() <NEW_LINE> <DEDENT> trial_id = [] <NEW_LINE> spikes = [] <NEW_... | Raster plot of trials
Parameters
----------
trials : list of neo.SpikeTrains
color : color of spikes
lw : line width
ax : matplotlib axes
Returns
-------
out : axes | 625941eb99fddb7c1c9de87e |
def test_existence_user(self): <NEW_LINE> <INDENT> user = User(email="john@snow.com", password="johnpwd") <NEW_LINE> user.save() <NEW_LINE> if user.id in models.storage.all('User'): <NEW_LINE> <INDENT> self.assertTrue(user.password, "johnpwd") | Testing if User class is being created properly | 625941eb097d151d1a223347 |
def get_schema_full(self, tablename): <NEW_LINE> <INDENT> colnames_full = self.get_colnames_full(tablename) <NEW_LINE> cctypes_full = self.get_cctypes_full(tablename) <NEW_LINE> schema_full = dict() <NEW_LINE> for colname, cctype in zip(colnames_full, cctypes_full): <NEW_LINE> <INDENT> schema_full[colname] = cctype <NE... | Return colnames and cctypes of all columns | 625941eba219f33f34628e52 |
def formKernel(X1, X2, param): <NEW_LINE> <INDENT> K = np.matmul(X1, X2.T) <NEW_LINE> K = normalizedKernel(K) <NEW_LINE> return K | Constructs a kernel to be used for further tasks | 625941eb187af65679ca5610 |
def __init__(self, sizepop, vardim, bound, MAXGEN, params): <NEW_LINE> <INDENT> self.sizepop = sizepop <NEW_LINE> self.vardim = vardim <NEW_LINE> self.bound = bound <NEW_LINE> self.MAXGEN = MAXGEN <NEW_LINE> self.params = params <NEW_LINE> self.population = [] <NEW_LINE> self.fitness = np.zeros(self.sizepop) <NEW_LINE>... | sizepop: population sizepop
vardim: dimension of variables
bound: boundaries of variables
MAXGEN: termination condition
params: algorithm required parameters, it is a list which is consisting of[fmax, fmin, Amax, Amin, alpha, gamma] | 625941eb91f36d47f21ac9e8 |
def update_amenu(self): <NEW_LINE> <INDENT> en = self.remote['Analysis_Simulation'] <NEW_LINE> for act in self.analysis_actions: <NEW_LINE> <INDENT> if act.isChecked(): <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> act.setEnabled(en) | Enable analysis menu actions only if an analysis is really running | 625941eb1f5feb6acb0c5039 |
def update_status(self): <NEW_LINE> <INDENT> self.set_modified(self.var_ops.is_var_modified(self.variable)) <NEW_LINE> self.keywidget.update_comment_display() <NEW_LINE> self.update_flags() | Handles variable modified status. | 625941ebd4950a0f3b08c838 |
def is_empty(self) -> bool: <NEW_LINE> <INDENT> return len(self._item) == 0 | Return whether this queue contains no items.
>>> q = Queue()
>>> q.is_empty()
True
>>> q.enqueue('hello')
>>> q.is_empty()
False | 625941eb7cff6e4e81117e76 |
def _available_languages(self): <NEW_LINE> <INDENT> language_list = [] <NEW_LINE> elements = self.browser.find_elements_by_css_selector( self._LANG_LIST) <NEW_LINE> for el in elements: <NEW_LINE> <INDENT> lang = el.find_element_by_css(self._LANG_TITLE).text <NEW_LINE> language_list.append(lang) <NEW_LINE> <DEDENT> retu... | Return a list of available languages in the menu.
| 625941ebfff4ab517eb2f92f |
def white_balance_match_pixel(im1, im2, radius=4, scale=4): <NEW_LINE> <INDENT> w, h = im1.size <NEW_LINE> if scale != 1: <NEW_LINE> <INDENT> im1 = im1.resize((w * scale, h * scale), resample=Image.BILINEAR) <NEW_LINE> <DEDENT> im1_blur = im1.filter(ImageFilter.GaussianBlur(radius=radius)) <NEW_LINE> im2_blur = im2.fil... | Pixel Level white balance match between LR and HR image.
Input, output PIL Image
:param im1: supposed to be LR (reference)
:param im2: HR
:param radius: blur kernel width
:param scale:
:return: | 625941eb3539df3088e2e83c |
def collection_aspect(self, axis, filename_width, filename_width_height): <NEW_LINE> <INDENT> mt = [0.91, -0.89, -0.02, 1.78, -1.55, 0.47] <NEW_LINE> fig = plt.figure() <NEW_LINE> ax = fig.add_subplot(111) <NEW_LINE> ax.add_collection(Beach(mt, width=400, xy=(0, 0), linewidth=.6, axes=ax)) <NEW_LINE> ax.axis(axis) <NEW... | Common part of the test_collection_aspect_[xy] tests. | 625941ebf8510a7c17cf9bf0 |
def test_create_token_for_user(self): <NEW_LINE> <INDENT> payload = {'email': 'test@tk.com', 'password': 'abc123'} <NEW_LINE> create_user(**payload) <NEW_LINE> res = self.client.post(TOKEN_URL, payload) <NEW_LINE> self.assertIn('token', res.data) <NEW_LINE> self.assertEqual(res.status_code, status.HTTP_200_OK) | Test that a token is created for the user | 625941ebf7d966606f6aa4fa |
def test_func_1(any_var, a_list: list, a_dict: dict, an_int: int, a_float: float = 3.14, a_bool=True, a_str: str = None) -> str: <NEW_LINE> <INDENT> return 'test_func_1 returned' | This is the first line,
continued on the next.
This function is meant to demo several combinations of type declaration (in signature or/and in docs),
as well as with or without defaults.
:param any_var: no type declared in either signature of doc
:param list a_list: type declared in signature AND doc
:param a_dict: t... | 625941eb046cf37aa974d233 |
def test_does_not_return_an_expired_job(self): <NEW_LINE> <INDENT> with self.flask_app.app_context(): <NEW_LINE> <INDENT> job_type = 'SIMILARITY' <NEW_LINE> params = { 'search_type': 'SIMILARITY', 'structure': '[H]C1(CCCN1C(=N)N)CC1=NC(=NO1)C1C=CC(=CC=1)NC1=NC(=CS1)C1C=CC(Br)=CC=1', 'threshold': '70' } <NEW_LINE> input... | Tests that when getting a job by id, it is not returned and it is deleted if has is expired | 625941eb627d3e7fe0d69342 |
def test_deserialize_with_bad_data(self): <NEW_LINE> <INDENT> pet = Pet(0) <NEW_LINE> self.assertRaises(DataValidationError, pet.deserialize, "string data") | Deserialize a Pet that has bad data | 625941ebbde94217f36832dd |
def collocated_onto(self, sample, how='', kernel=None, missing_data_for_missing_sample=True, fill_value=None, var_name='', var_long_name='', var_units='', **kwargs): <NEW_LINE> <INDENT> return sample.sampled_from(self, how=how, kernel=kernel, missing_data_for_missing_sample=missing_data_for_missing_sample, fill_value=f... | Collocate the CommonData object with another CommonData object using the specified collocator and kernel.
:param CommonData sample: The sample data to collocate onto
:param str how: Collocation method (e.g. lin, nn, bin or box)
:param str or cis.collocation.col_framework.Kernel kernel:
:param bool missing_data_for_mis... | 625941eb5fdd1c0f98dc0726 |
def assignAverageRevenue(): <NEW_LINE> <INDENT> mpaaTotal=assignTotalRevenue() <NEW_LINE> mpaaCount=assignCount() <NEW_LINE> mpaaAverage=populate() <NEW_LINE> for mpaa in mpaaAverage: <NEW_LINE> <INDENT> mpaaAverage[mpaa]=mpaaTotal[mpaa]/mpaaCount[mpaa] <NEW_LINE> <DEDENT> return mpaaAverage | This function calls all the three previous functions and stores
their return values in three separate variables. Then the values in
the mpaaAverage dictionary (the dictionary returned by the populate
function) are updated from zero to the average revenue generated by the
films with the mpaarating.( The keys are the mpa... | 625941eb30bbd722463cc2b9 |
def process_media(self, processPath, videoFiles, nzbName, process_method, force, is_priority): <NEW_LINE> <INDENT> processor = None <NEW_LINE> for cur_video_file in videoFiles: <NEW_LINE> <INDENT> cur_video_file_path = os.path.join(processPath, cur_video_file) <NEW_LINE> if self.already_postprocessed(processPath, cur_v... | Postprocess mediafiles
:param processPath: Path to postprocess in
:param videoFiles: Filenames to look for and postprocess
:param nzbName: Name of NZB file related
:param process_method: auto/manual
:param force: Postprocess currently postprocessing file
:param is_priority: Boolean, is this a priority download | 625941eb1f037a2d8b9466ed |
def _randomly_divide_connected_graph(adj, n_regions): <NEW_LINE> <INDENT> if not n_regions > 0: <NEW_LINE> <INDENT> msg = "n_regions is {} but must be positive.".format(n_regions) <NEW_LINE> raise ValueError(msg) <NEW_LINE> <DEDENT> n_areas = adj.shape[0] <NEW_LINE> if not n_regions <= n_areas: <NEW_LINE> <INDENT> msg ... | Divide the provided connected graph into `n_regions` regions.
Parameters
----------
adj : :class:`scipy.sparse.csr_matrix`
Adjacency matrix.
n_regions : int
The desired number of clusters. Must be > 0 and <= number of nodes.
Returns
-------
labels : :class:`numpy.ndarray`
Each element (an integer in {0, .... | 625941eb293b9510aa2c3781 |
def test_generic_2315_imag_is_zero_iff_conjugate_equals_self( self, a: ClassUnderTest ) -> None: <NEW_LINE> <INDENT> self.assertEqual(a == a.conjugate(), a.imag == self.abs_zero) | a.conjugate() == a ⇒ a.imag == 0 | 625941eb7d847024c06be7b1 |
def main(): <NEW_LINE> <INDENT> print("Let's play a game!") <NEW_LINE> print("Let's create a die") <NEW_LINE> my_die = Die(range(1, 7)) <NEW_LINE> print("Rolling die 10 times") <NEW_LINE> for i in range(10): <NEW_LINE> <INDENT> my_die.roll() <NEW_LINE> print(f"{i + 1:2}) {str(my_die):>2}") <NEW_LINE> <DEDENT> print(f"T... | Entry point | 625941eb283ffb24f3c55ded |
def lucas(n): <NEW_LINE> <INDENT> k = 4 <NEW_LINE> if n < 2: <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> if n != 2: <NEW_LINE> <INDENT> for i in range(3, n + 1): <NEW_LINE> <INDENT> k = next_lucas(k) <NEW_LINE> <DEDENT> <DEDENT> return k | Returns the Lucas_Lehmer number of n. | 625941eb4527f215b584c943 |
def restructure_instruction(instruction, state): <NEW_LINE> <INDENT> pre_instructions = [] <NEW_LINE> def for_call_break_out(): <NEW_LINE> <INDENT> if instruction.expression.tokens[2].kind == 'call': <NEW_LINE> <INDENT> gen_temp = state.next_id_binding() <NEW_LINE> pre_instructions.append( Assignment([], gen_temp, Expr... | Process a single instruction.
Returns:
A list of instructions to insert immediately before the processed
instruction. | 625941ebac7a0e7691ed45b3 |
def test_satellite_and_annual_parallax_calculation(): <NEW_LINE> <INDENT> model_parameters = {'t_0': 2456836.22, 'u_0': 0.922, 't_E': 22.87, 'pi_E_N': -0.248, 'pi_E_E': 0.234, 't_0_par': 2456836.2} <NEW_LINE> coords = "17:47:12.25 -21:22:58.2" <NEW_LINE> model_with_par = mm.Model(model_parameters, coords=coords) <NEW_L... | test parallax calculation with Spitzer data | 625941ebf548e778e58cda71 |
def update_table_item(primary_partition_value, primary_classification_value, attribute, value): <NEW_LINE> <INDENT> return table.update_item( Key={ "TenantAccountTimestamp": primary_partition_value, "Timestamp": primary_classification_value }, UpdateExpression='SET {} = :value'.format(attribute), ExpressionAttributeVal... | Update a single table item based on a column's atttribute.
Can specify attribute (col name) and its value to be changed along with the needed primary keys. Ex: | 625941eb6e29344779a62b01 |
def parse_range(range_str): <NEW_LINE> <INDENT> chrom, start_end = range_str.split(":") <NEW_LINE> start, end = start_end.split("-") <NEW_LINE> return str(chrom), int(start), int(end) | Parse the chrom, start and end from the range string
Args:
range_str (str): In format chrom:start-end
Returns:
chrom (str), start (int), end (int) | 625941eb596a897236089faa |
def scan_interfaces(address=None): <NEW_LINE> <INDENT> available = [] <NEW_LINE> found = [] <NEW_LINE> for driverClass in CLASSES: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> logger.debug('Scanning: %s', driverClass) <NEW_LINE> instance = driverClass() <NEW_LINE> found = instance.scan_interface(address) <NEW_LINE> ava... | Scan all the interfaces for available Espdrones | 625941eb3317a56b8693a13d |
def set_paused(self, paused: bool) -> None: <NEW_LINE> <INDENT> self.__update_source(paused=paused) | Change if the source is paused.
Args:
paused (bool): Whether the source should be paused. | 625941eb16aa5153ce362969 |
def _batch_map_offsets(self, features, grid_offsets, predicted_offsets): <NEW_LINE> <INDENT> with tf.name_scope("batch_map_offsets"): <NEW_LINE> <INDENT> b, h, w = tf.shape(features)[0], tf.shape(features)[1], tf.shape(features)[2] <NEW_LINE> coords = tf.expand_dims(grid_offsets, 0) <NEW_LINE> coords += tf.reshape(pred... | Batch map offsets into inputs.
Args:
features: A Tensor, has shape (b, h, w, c).
grid_offsets: A Tensor, the initial grid offsets, has shape (h, w, n_filters, 2)
predicted_offsets: A Tensor, the predicted offsets, has shape (b, h, w, n_filters * 2)
Returns:
A Tensor has shape (b, h, w, n_filters * 2, ... | 625941eb8e05c05ec3eea86a |
def format_ncx_text(self, description, dest=None): <NEW_LINE> <INDENT> massaged = unicode(BeautifulStoneSoup(description, convertEntities=BeautifulStoneSoup.HTML_ENTITIES)) <NEW_LINE> massaged = re.sub("&", "&", massaged) <NEW_LINE> if massaged.strip() and dest: <NEW_LINE> <INDENT> return self.generate_short_descri... | Massage NCX text for Kindle.
Convert HTML entities for proper display on Kindle, convert
'&' to '&' (Kindle fails).
Args:
description (str): string, possibly with HTM entities
dest (kwarg): author, title or description
Return:
(str): massaged, possibly truncated description | 625941eb6aa9bd52df037298 |
def run(): <NEW_LINE> <INDENT> iterator = parse('../data/parsed/ratings.txt.gz') <NEW_LINE> print('The username of the first ten ratings are:') <NEW_LINE> nbr = 0 <NEW_LINE> for item in iterator: <NEW_LINE> <INDENT> username = item['user_name'] <NEW_LINE> print(username) <NEW_LINE> nbr += 1 <NEW_LINE> if nbr == 10: <NE... | Example how to use the function parse | 625941eb9f2886367277ad7a |
def delete( self, resource_group_name, route_filter_name, rule_name, custom_headers=None, raw=False, **operation_config): <NEW_LINE> <INDENT> raw_result = self._delete_initial( resource_group_name=resource_group_name, route_filter_name=route_filter_name, rule_name=rule_name, custom_headers=custom_headers, raw=True, **o... | Deletes the specified rule from a route filter.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param route_filter_name: The name of the route filter.
:type route_filter_name: str
:param rule_name: The name of the rule.
:type rule_name: str
:param dict custom_headers: header... | 625941eb15baa723493c446a |
def setCtrllerResyncState(self, ctrllerMac, needResync): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> sql = ("UPDATE Controller SET needResync = {} WHERE macAddress = '{}'" "".format(int(needResync), ctrllerMac) ) <NEW_LINE> self.execute(sql) <NEW_LINE> <DEDENT> except pymysql.err.InternalError as internalError: <NEW_L... | Set a flag in the controller to inidicate if it needs to be
resynced. This can be used when a forece commit is used
because a controller is offline for long time. In this case,
the controller should be marked that need to be resynced.
In this way, when it is online again, the user should reprogram it | 625941eb4428ac0f6e5bace8 |
@pytest.mark.cnset_factory <NEW_LINE> @pytest.mark.parametrize('ranges, expected', [ ((('AA 0', 'AA 50'), ('AA 100', 'AB 0')), s.RangeSet((aa0, aa50), (aa100, ab0))), ((('AA 0', 'AA 100'), ('AA 100', 'AB 0')), s.RangeSet((aa0, ab0))), ((s.RangeSet((aa0, aa50)), ('AA 100', 'AB 0')), s.RangeSet((aa0, aa50), (aa100, ab0))... | Calls to the ``cnset`` factory should successfully create the
expected RangeSet object or raise the expected error, based on the
provided values for ranges. | 625941eb507cdc57c63071d8 |
def compute_output_shape(self, input_shape): <NEW_LINE> <INDENT> if isinstance(input_shape, list): <NEW_LINE> <INDENT> input_shape = input_shape[0] <NEW_LINE> <DEDENT> if self.units == 1: <NEW_LINE> <INDENT> return tuple(input_shape[:-1]) + (1,) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return input_shape[:-1] | Standard Keras compute_output_shape() method. | 625941ebff9c53063f47c6e2 |
def coverage(self): <NEW_LINE> <INDENT> if self.covered_by: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> if not self.subtopics: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> total = 0 <NEW_LINE> for subtopic in self.subtopics: <NEW_LINE> <INDENT> total += subtopic.coverage() <NEW_LINE> <DEDENT> return total / le... | determines the extent to which this topic is covered by recoreded syllabi | 625941ebbe7bc26dc91cdae7 |
def read_RTHyst(self, rtfiledir): <NEW_LINE> <INDENT> p = re.compile(r'\s*\d+\s+\d+.\d+(e[-+])?\d+\s+-?\d+.\d+\s+-?\d+.\d+') <NEW_LINE> freq = re.compile(r'^Hysteresis Period.') <NEW_LINE> field = re.compile(r'^Field.') <NEW_LINE> thick = re.compile(r'Sample Thickness.') <NEW_LINE> area = re.compile(r'Sample Area.') <N... | Imports Radiant Technologies measurement data
Parameters
----------
rtfiledir : str
RT file (with path) to open and parse. Stores data as
the associated HysteresisData object's attributes
Returns
-------
n/a | 625941eb2eb69b55b151cda8 |
def get_user_by_email(email): <NEW_LINE> <INDENT> return query(User).filter_by(email=email).first() or None | Return user by email or None
:param email: String
:return object: | 625941eb293b9510aa2c3782 |
def convert_single_example(ex_index, example, max_seq_length_src,max_seq_length_tgt, tokenizer): <NEW_LINE> <INDENT> tokens_a = tokenizer.tokenize(example.src_txt) <NEW_LINE> tokens_b = tokenizer.tokenize(example.tgt_txt) <NEW_LINE> if len(tokens_a) > max_seq_length_src - 2: <NEW_LINE> <INDENT> tokens_a = tokens_a[0:(m... | Converts a single `InputExample` into a single `InputFeatures`. | 625941ebd4950a0f3b08c839 |
@receiver(post_save, sender=UserLog) <NEW_LINE> def cull_records(sender, **kwargs): <NEW_LINE> <INDENT> if settings.USER_LOG_MAX_RECORDS_PER_USER and kwargs["created"]: <NEW_LINE> <INDENT> current_models = UserLog.objects.filter(user=kwargs["instance"].user, activity_type=kwargs["instance"].activity_type) <NEW_LINE> if... | Listen in to see when videos become available. | 625941eb099cdd3c635f114a |
def create_build_graph(self, target_roots, build_root=None): <NEW_LINE> <INDENT> logger.debug('target_roots are: %r', target_roots) <NEW_LINE> graph = LegacyBuildGraph.create(self.scheduler, self.symbol_table_cls) <NEW_LINE> logger.debug('build_graph is: %s', graph) <NEW_LINE> with self.scheduler.locked(): <NEW_LINE> <... | Construct and return a `BuildGraph` given a set of input specs.
:param TargetRoots target_roots: The targets root of the request.
:param string build_root: The build root.
:returns: A tuple of (BuildGraph, AddressMapper). | 625941eb91f36d47f21ac9e9 |
def predict(self, new_X): <NEW_LINE> <INDENT> if self.weights.all() == 0: <NEW_LINE> <INDENT> print('ERROR: The model is not fited!') <NEW_LINE> return <NEW_LINE> <DEDENT> new_X = list(new_X) <NEW_LINE> new_X.insert(0, 1) <NEW_LINE> new_X = mat(new_X) <NEW_LINE> return 1 if self.__sigmoid(new_X * self.weights) >= 0.5 e... | Function to predict the label based on new input X. | 625941eb8c0ade5d55d3eeb0 |
def read_file_moves(fp): <NEW_LINE> <INDENT> moves_list = [] <NEW_LINE> reader = csv.reader(fp) <NEW_LINE> next(reader, None) <NEW_LINE> for line in reader: <NEW_LINE> <INDENT> generation_id = int(line[2]) <NEW_LINE> name = line[1] <NEW_LINE> attack_type = int(line[9]) <NEW_LINE> if (generation_id == 1) and (attack_typ... | takes file pointer and returns a list of move objects | 625941eb15fb5d323cde1008 |
def generate_rf_rst_files(file_names, incl_tests=True, incl_keywords=True): <NEW_LINE> <INDENT> for file_name in file_names: <NEW_LINE> <INDENT> path = join(WORKING_DIR, *file_name.split('.')[:-1]) <NEW_LINE> dirs, files = scan_dir(path) <NEW_LINE> full_path = join(WORKING_DIR, file_name) <NEW_LINE> with open(full_path... | Generate rst files for the given robot modules.
:param file_names: List of file names to be included in the documentation
(rst files).
:param incl_tests: If true, tests will be included in the documentation.
:param incl_keywords: If true, keywords will be included in the
documentation.
:type file_names: set
:type incl... | 625941eb15baa723493c446b |
def query(self, peer, query): <NEW_LINE> <INDENT> self.checkstat("query") | Called for every query before processing | 625941ebab23a570cc250678 |
def pc_throughput_avg(self): <NEW_LINE> <INDENT> return _iio_swig.fmcomms2_source_sptr_pc_throughput_avg(self) | pc_throughput_avg(fmcomms2_source_sptr self) -> float | 625941ebd268445f265b5360 |
@set_module('numpy') <NEW_LINE> def full(shape, fill_value, dtype=None, order='C'): <NEW_LINE> <INDENT> if dtype is None: <NEW_LINE> <INDENT> dtype = array(fill_value).dtype <NEW_LINE> <DEDENT> a = empty(shape, dtype, order) <NEW_LINE> multiarray.copyto(a, fill_value, casting='unsafe') <NEW_LINE> return a | Return a new array of given shape and type, filled with `fill_value`.
Parameters
----------
shape : int or sequence of ints
Shape of the new array, e.g., ``(2, 3)`` or ``2``.
fill_value : scalar
Fill value.
dtype : data-type, optional
The desired data-type for the array The default, `None`, means
`np... | 625941eb5fc7496912cc3e6f |
def adapt_throttle(steering_angle): <NEW_LINE> <INDENT> throttle = 0.2 <NEW_LINE> if abs(steering_angle) > 0.12: <NEW_LINE> <INDENT> throttle = 0.1 <NEW_LINE> <DEDENT> return throttle | Adapt throttle to slow down on curves | 625941eb009cb60464c6389f |
def get_index_symbol_ticker(index_name): <NEW_LINE> <INDENT> pass | 返回index
:return: | 625941eb73bcbd0ca4b2c567 |
def parse(self, stream): <NEW_LINE> <INDENT> result = OrderedDict() <NEW_LINE> for i, line in enumerate(stream): <NEW_LINE> <INDENT> line = re.compile("(.*?)#.*").sub(r'\1', line).strip() <NEW_LINE> if not line: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> if '=' not in line: <NEW_LINE> <INDENT> raise configargpars... | Used to read the rdiffweb config file as dict. | 625941eb8c0ade5d55d3eeb1 |
def get_readings_as_uint32(self): <NEW_LINE> <INDENT> addr = struct.unpack('>H', self.my_payload[2:4])[0] <NEW_LINE> nrofbytes = self.my_payload[4] <NEW_LINE> if nrofbytes % 4 != 0: <NEW_LINE> <INDENT> raise CannotInterpretNonDivisibleByFourNumberOfBytesAsArrayOf32BitIntegersException <NEW_LINE> <DEDENT> r = [] <NEW_LI... | Return an array of (addr,reading) tuples containing all
data in our payload, interpreted as unsigned 32-bit integers. | 625941eb5e10d32532c5f416 |
def _parse_dicom_and_contour_files(filenames): <NEW_LINE> <INDENT> dicom_filename, icontour_filename, ocontour_filename = filenames <NEW_LINE> dicom_data, icontour_data, ocontour_data = None, None, None <NEW_LINE> icontour_path, ocontour_path = [], [] <NEW_LINE> if dicom_filename: <NEW_LINE> <INDENT> dicom_data = parsi... | Convert two filenames to valid image data
:param filenames: a 3-tuple record of dicom_filename, icontour_filename,
and ocontour_filename:
dicom_filename is the path string to the DICOM file
icontour_filename is the path string to the i-contour file
ocontour_filename is the path string to th... | 625941eb377c676e91272698 |
def t340001_x2(actionbutton1=_, flag1=6001, flag2=6000): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> assert (not GetOneLineHelpStatus() and not IsTalkingToSomeoneElse() and not IsClientPlayer() and not IsPlayerDead() and not IsCharacterDisabled()) <NEW_LINE> assert CompareBonfireState(1) <NEW_LINE> assert GetEv... | State 0 | 625941eb63f4b57ef00015fc |
def create_history_tag(self, history_id, tag): <NEW_LINE> <INDENT> payload = {} <NEW_LINE> url = self.url <NEW_LINE> url = '/'.join([url, history_id, 'tags', tag]) <NEW_LINE> return Client._post(self, payload, url=url) | Create history tag
:type history_id: str
:param history_id: Encoded history ID
:type tag: str
:param tag: Add tag to history
:rtype: dict
:return: A dictionary with information regarding the tag.
For example::
{'model_class':'HistoryTagAssociation', 'user_tname': 'NGS_PE_RUN', 'id': 'f792763bee8d2... | 625941ebde87d2750b860289 |
def set_height(self, height): <NEW_LINE> <INDENT> self.height = height | Set the page height in cm | 625941ebc4546d3d9de72f2a |
def test_jinja_union(self): <NEW_LINE> <INDENT> _expected = {'ret': [1, 2, 3, 4, 6]} <NEW_LINE> ret = self.run_function('state.sls', ['jinja_filters.jinja_union']) <NEW_LINE> self.assertIn('module_|-test_|-test.echo_|-run', ret) <NEW_LINE> self.assertEqual(ret['module_|-test_|-test.echo_|-run']['changes'], _expected) | test jinja filter jinja.union | 625941eb21bff66bcd684e3f |
def test_response_ok(): <NEW_LINE> <INDENT> from client import client <NEW_LINE> response = ("HTTP/1.1 200 OK\r\n" + "Date: Mon, 27 Jul 1884 12:28:53 GMT\r\n" + "Server: Teddy Bear\r\n" + "Last-Modified: Wed, 22 Jul 1884 19:15:56 GMT\r\n" + "Content-Length: 88\r\n" + "Content-Type: text/html\r\n" + "Connection: Closed\... | Tests to see if valid client request will return a 200 OK message. | 625941eb6fece00bbac2dc36 |
def load_data_and_labels_from_many_files(data_folder, data_files): <NEW_LINE> <INDENT> print("Loading data...") <NEW_LINE> x_text = [] <NEW_LINE> y = [] <NEW_LINE> for i, data_file in enumerate(data_files): <NEW_LINE> <INDENT> sentences = list(open(data_folder + "/" + data_file, "r").readlines()) <NEW_LINE> sentences =... | Loads sentences from files, splits the data into words and generates labels.
Returns split sentences and labels. | 625941eb26068e7796caf1d8 |
def advance(self, wordLk, copy_indices=None): <NEW_LINE> <INDENT> if self.done: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> numWords = wordLk.size(1) <NEW_LINE> if len(self.prevKs) > 0: <NEW_LINE> <INDENT> beamLk = wordLk + self.scores.unsqueeze(1).expand_as(wordLk) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT>... | Given prob over words for every last beam `wordLk` and attention
`attnOut`: Compute and update the beam search.
Parameters:
* `wordLk`- probs of advancing from the last step (K x words)
* `copy_indices` - copy indices (K x ctx_len)
Returns: True if beam search is complete. | 625941eb851cf427c661a9fc |
def query_folder(self, dir_name): <NEW_LINE> <INDENT> if dir_name[0] == '/': <NEW_LINE> <INDENT> dir_name = dir_name[1:len(dir_name)] <NEW_LINE> <DEDENT> self.url = 'http://' + self.config.region + '.file.myqcloud.com' + '/files/v2/' + str(self.config.app_id) + '/' + self.config.bucket + '/' + dir_name + '/?op=stat' <N... | 查询目录属性(https://www.qcloud.com/document/product/436/6063)
:param dir_name:查询的目录的名称
:return:查询出来的结果,为json格式 | 625941eb7b25080760e39947 |
def top_turn(self): <NEW_LINE> <INDENT> hold_variable = self.faces[self.front_face][0] <NEW_LINE> self.faces[self.front_face][0] = self.faces[self.right_face][0] <NEW_LINE> self.faces[self.right_face][0] = self.faces[self.back_face][0] <NEW_LINE> self.faces[self.back_face][0] = self.faces[self.left_face][0] <NEW_LINE> ... | Simulates a clockwise rotation of the top face | 625941ebd53ae8145f87a757 |
def add_loss_op(self, output): <NEW_LINE> <INDENT> loss=sequence_loss(output, tf.to_int32(tf.reshape( self.labels_placeholder, [self.config.batch_size * self.config.num_steps, -1])), tf.ones(shape=(self.config.batch_size, self.config.num_steps))) <NEW_LINE> return loss | Adds loss ops to the computational graph.
Hint: Use tensorflow.python.ops.seq2seq.sequence_loss to implement sequence loss.
Args:
output: A tensor of shape (None, self.vocab)
Returns:
loss: A 0-d tensor (scalar) | 625941eb66673b3332b92583 |
def all_jobs(groups): <NEW_LINE> <INDENT> jobs_dict = OrderedDict() <NEW_LINE> for group in groups: <NEW_LINE> <INDENT> name = namespace(group) <NEW_LINE> jobs_dict[group] = REDIS.lrange(name, 0, -1) <NEW_LINE> <DEDENT> return jobs_dict | Find all Jobs in the list of groups, return them as a dict. | 625941eb26068e7796caf1d9 |
def control(pos_x, pos_y, time, velocity): <NEW_LINE> <INDENT> global car_parameters <NEW_LINE> if pos_x < 125.8 and pos_y > 35: <NEW_LINE> <INDENT> car_parameters['throttle'] = -1 <NEW_LINE> car_parameters['steer'] = 5 <NEW_LINE> <DEDENT> elif pos_x < 130 and pos_y > 32.5: <NEW_LINE> <INDENT> car_parameters['throttle'... | Controls the simulated car | 625941ebadb09d7d5db6cc7e |
def ApplyDecimationFilter(polydata, reduction_factor): <NEW_LINE> <INDENT> decimation = vtk.vtkQuadricDecimation() <NEW_LINE> decimation.SetInputData(polydata) <NEW_LINE> decimation.SetTargetReduction(reduction_factor) <NEW_LINE> decimation.GetOutput().ReleaseDataFlagOn() <NEW_LINE> decimation.AddObserver("ProgressEven... | Reduce number of triangles of the given vtkPolyData, based on
reduction_factor. | 625941eb0a50d4780f667388 |
def test_version1_and_verbose_flag(self): <NEW_LINE> <INDENT> pattern = bregex.compile_search(r'Some pattern', flags=bregex.VERBOSE | bregex.V1) <NEW_LINE> self.assertTrue(pattern.flags & bregex.V1 and pattern.flags & bregex.VERBOSE) | Test that VERBOSE and V1 together come through. | 625941ebcc0a2c11143dd383 |
def end_node(self, id=None, shutdown=False, last_msg_stats=None): <NEW_LINE> <INDENT> lock = threading.Condition() <NEW_LINE> def shutdown_cb(): <NEW_LINE> <INDENT> nonlocal lock <NEW_LINE> NodeCluster.Log.log('Done.') <NEW_LINE> with lock: <NEW_LINE> <INDENT> lock.notify() <NEW_LINE> <DEDENT> <DEDENT> if not self.node... | Ends a running node.
@param id: The 40 hex chars id of the node.
@type id: bytes
@return: If a node was deleted or not.
@rtype : boolean | 625941eb046cf37aa974d234 |
def universal_transformer_skip(layer_inputs, step, hparams, ffn_unit, attention_unit, pad_remover=None): <NEW_LINE> <INDENT> state, inputs, memory = layer_inputs <NEW_LINE> new_state = step_preprocess(state, step, hparams) <NEW_LINE> for i in range(hparams.num_inrecurrence_layers): <NEW_LINE> <INDENT> with tf.variable_... | Universal Transformer with highway connection.
It transforms the state using attention and ffn and wrap this transformation
with a skip-all connection. (the new state is a combination of the state and
the inputs (original inputs) based on cary/transform gates.)
Observation:
Controlling the cary/transform gate with... | 625941eb656771135c3ebd66 |
def _identify_anomalies(self, X, yhat, prob): <NEW_LINE> <INDENT> y = DTA_LSTM._shift_traces_left(X) <NEW_LINE> for i in range(len(X)): <NEW_LINE> <INDENT> rp = self._compare_traces(y[i], yhat[i]) <NEW_LINE> self.rank_prob.append(rp) <NEW_LINE> if self.explain: <NEW_LINE> <INDENT> print('X[{}]: {} = {}'.format(i, X[i],... | mark anomalies based on the difference between X, y, and yhat
i.e.,
top_k = 5
top_k_yhat = np.argsort(yhat, axis=2)[:, :, -top_k:]
top_yhat = np.argmax(yhat, axis=2)
y = _shift_traces_left(X)
X[i]: Input: [ 0 0 0 0 0 0 0 0 0 0 0 10 10 17 5 5 7 7 6 6]
y[i]: Output: [ 0 0 0 0 0 0 0 ... | 625941eb15fb5d323cde1009 |
def __repr__(self): <NEW_LINE> <INDENT> return "SNP<(mat:{};pat:{};other:{})>".format( self.mat_counts, self.pat_counts, self.other_counts) | Summary info. | 625941eb99fddb7c1c9de880 |
def __init__(self, parent, fwapfile=None): <NEW_LINE> <INDENT> self.user = None <NEW_LINE> self.si = None <NEW_LINE> self.vcenter = None <NEW_LINE> self.eol = None <NEW_LINE> self.fonction = None <NEW_LINE> self.demandeur = None <NEW_LINE> self.vmfolder = None <NEW_LINE> self.esx = None <NEW_LINE> self.datastore = None... | Constructeur | 625941eb9c8ee82313fbbc69 |
def register_extensions(app): <NEW_LINE> <INDENT> db.init_app(app) <NEW_LINE> Migrate(app, db) <NEW_LINE> login_manager = LoginManager() <NEW_LINE> login_manager.session_protection="strong" <NEW_LINE> login_manager.init_app(app) <NEW_LINE> @login_manager.user_loader <NEW_LINE> def user_loader(id): <NEW_LINE> <INDENT> r... | 添加扩展 | 625941eb3539df3088e2e83d |
def Create_SSHClient(self,ip,port,user,pwd,command): <NEW_LINE> <INDENT> SSH = paramiko.SSHClient() <NEW_LINE> SSH.set_missing_host_key_policy(paramiko.AutoAddPolicy()) <NEW_LINE> res_msg = ip.center(50, '-') <NEW_LINE> try: <NEW_LINE> <INDENT> SSH.connect(hostname=ip,port=port,username=user,password=pwd) <NEW_LINE> st... | SSH执行命令
:param ip: 主机地址
:param port: 主机SSH端口
:param user: 用户名
:param pwd: 密码
:param command: 执行的命令
:return: 直接打印 | 625941eba219f33f34628e54 |
def set_nu(self, nu, x=None, y=None): <NEW_LINE> <INDENT> if all(self._nu[x,y] == nu): return <NEW_LINE> if x is None and y is None: <NEW_LINE> <INDENT> assert shape(nu) == (self._C, self._C) and all(nu>=0), '%s' % (nu) <NEW_LINE> if self._non_diagonal: <NEW_LINE> <INDENT> assert all(diag(nu)==0), "%s" % (nu) <NEW_LINE... | set the jump height matrix self._nu[x,y] to nu.
When setting the whole self._nu to an C x C matrix nu, passing x = None and y = None
nu[p, q] is the excitation height from p to q | 625941eb187af65679ca5612 |
def test_user_exists(self): <NEW_LINE> <INDENT> payload = { 'email': 'test@londonappdev.com', 'password': 'testpass' } <NEW_LINE> create_user(**payload) <NEW_LINE> res = self.client.post(CREATE_USER_URL, payload) <NEW_LINE> self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST) | Test creating user that already exists fails | 625941eb76d4e153a657f025 |
def test_message(): <NEW_LINE> <INDENT> m = SMSShell.models.message.Message('sender', 'content') <NEW_LINE> assert m.number == 'sender' <NEW_LINE> assert m.content == 'content' <NEW_LINE> assert isinstance(m.asString(), str) <NEW_LINE> assert 'content' in str(m) <NEW_LINE> assert 'sender' in repr(m) | Test Message attributes
| 625941eb67a9b606de4a83a9 |
def __init__(self, configuration, entity, entry_point_group): <NEW_LINE> <INDENT> TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group) <NEW_LINE> self.nuageBridgeName = self.configuration.get("NUAGE", "nuage_bridge") <NEW_LINE> self.database = None <NEW_LINE> ... | Initialize the plugin.
@type configuration: Configuration object
@param configuration: the configuration
@type entity: L{TNArchipelEntity}
@param entity: the entity that owns the plugin
@type entry_point_group: string
@param entry_point_group: the group name of plugin entry_point | 625941eb0fa83653e46574aa |
def loadPreferences(self): <NEW_LINE> <INDENT> config = prefcontrol.getConfig() <NEW_LINE> scope = config['scope server'] <NEW_LINE> scopeport = config['scope port'] <NEW_LINE> savefolder = config['savefolder'] <NEW_LINE> instport = config['instrument port'] <NEW_LINE> pixelscalex = config['pixel scale x'] <NEW_LINE> p... | Load the preferences and fill the text controls | 625941ebd486a94d0b98e639 |
def convert_key(self, spotify_key): <NEW_LINE> <INDENT> key_dict = { (0,1):'8B', (1,1):'3B', (2,1):'10B', (3,1):'5B', (4,1):'12B', (5,1):'7B', (6,1):'2B', (7,1):'9B', (8,1):'4B', (9,1):'11B', (10,1):'6B', (11,1):'1B', (0,0):'5A', (1,0):'12A', (2,0):'7A', (3,0):'2A', (4,0):'9A', (5,0):'4A', (6,0):'11A', (7,0):'6A', (8,0... | Convert Spotify key notation to Camelot notation
Args:
key: Spotify key value (str) | 625941ebe1aae11d1e74a1ae |
def test__api_edit_cart_no_get(self): <NEW_LINE> <INDENT> request = self.factory.get('/__cart/add.json') <NEW_LINE> request.GET = None <NEW_LINE> with self.assertRaisesRegex(Http404, r'Internal error \(No request was provided\) for /__cart/add.json'): <NEW_LINE> <INDENT> api_edit_cart(request, 'add') | [test_cart.py] api_edit_cart: no GET | 625941ebfff4ab517eb2f931 |
def isValidBST(self, root): <NEW_LINE> <INDENT> sta=[] <NEW_LINE> lastval=float('-inf') <NEW_LINE> now=root <NEW_LINE> while now: <NEW_LINE> <INDENT> sta.append(now) <NEW_LINE> now=now.left <NEW_LINE> <DEDENT> while sta: <NEW_LINE> <INDENT> temp=sta[-1] <NEW_LINE> sta.pop() <NEW_LINE> if temp.val<=lastval: <NEW_LINE> <... | :type root: TreeNode
:rtype: bool | 625941eb1f5feb6acb0c503c |
def test_get_video_attributes_bad_urls(self): <NEW_LINE> <INDENT> bad_urls = [ 'https://www.vrt.be/vrtnu/a-z/de-ideale-wereld/2019-nj/de-ideale-wereld-d20191218/', 'https://www.vrt.be/vrtnu/kanalen/studio-brussel/', 'https://vtm.be/vtmgo' ] <NEW_LINE> for bad_url in bad_urls: <NEW_LINE> <INDENT> video_attrs = get_video... | Test getting video attributes using bad urls | 625941eb38b623060ff0b2df |
def update_dicestring(): <NEW_LINE> <INDENT> dicetext1, dicetext2 = calculate_dicetext() <NEW_LINE> window["string1"].update(dicetext1.split(" ")[0]) <NEW_LINE> window["string2"].update(dicetext2.split(" ")[0]) | calculate the dicestrings from the formular fields | 625941ebf8510a7c17cf9bf2 |
def load_test_model(model, cfg): <NEW_LINE> <INDENT> map_location = (lambda storage, loc: storage) <NEW_LINE> if cfg.model_weight_file != '': <NEW_LINE> <INDENT> src_state_dict = torch.load(cfg.model_weight_file, map_location=map_location) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> checkpoint = torch.load(cfg.ckpt_f... | load the param from train model for test model
args:
model: the init model
cfg: Config object
return:
model: the model loaded the param | 625941eb21a7993f00bc81eb |
def getxml(filepath, item): <NEW_LINE> <INDENT> mail_list=[] <NEW_LINE> dom = xml.dom.minidom.parse(filepath) <NEW_LINE> root = dom.documentElement <NEW_LINE> mails = root.getElementsByTagName(item) <NEW_LINE> for mail in mails: <NEW_LINE> <INDENT> mail_list.append(mail.firstChild.data) <NEW_LINE> <DEDENT> return mail_... | 读取xml文件返回邮箱 | 625941eb4e4d5625662d48c3 |
def test_lars_cv(): <NEW_LINE> <INDENT> old_alpha = 0 <NEW_LINE> lars_cv = linear_model.LassoLarsCV() <NEW_LINE> for length in (400, 200, 100): <NEW_LINE> <INDENT> X = diabetes.data[:length] <NEW_LINE> y = diabetes.target[:length] <NEW_LINE> lars_cv.fit(X, y) <NEW_LINE> np.testing.assert_array_less(old_alpha, lars_cv.a... | Test the LassoLarsCV object by checking that the optimal alpha
increases as the number of samples increases.
This property is not actually garantied in general and is just a
property of the given dataset, with the given steps chosen. | 625941eb56b00c62f0f14b4f |
def test_on_kill(self): <NEW_LINE> <INDENT> path = "/tmp/airflow_on_kill" <NEW_LINE> try: <NEW_LINE> <INDENT> os.unlink(path) <NEW_LINE> <DEDENT> except OSError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> dagbag = models.DagBag( dag_folder=TEST_DAG_FOLDER, include_examples=False, ) <NEW_LINE> dag = dagbag.dags.get('t... | Test that ensures that clearing in the UI SIGTERMS
the task | 625941ebb5575c28eb68e4f7 |
def bytes(self, reverse: bool=False): <NEW_LINE> <INDENT> data = list(self.value) <NEW_LINE> if reverse: <NEW_LINE> <INDENT> data.reverse() <NEW_LINE> <DEDENT> return data | Returns the byte-array representation of the object.
Args:
reverse (bool, optional): Flag to indicate whether to return the list in the reversed order. Defaults to False.
Returns:
list: list of byte values of the object. | 625941ebd99f1b3c44c67a78 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.