code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def getValidityConstr(self): <NEW_LINE> <INDENT> for period in self._sections.keys(): <NEW_LINE> <INDENT> section = self._sections[period] <NEW_LINE> hasClass = 0 <NEW_LINE> if section != None and section.courseType != CourseType.OFF: <NEW_LINE> <INDENT> hasClass = 1 <NEW_LINE> <DEDENT> expr = [(var, 1) for var in self... | Yields expressions of if periods have 0 or 1 class. | 625941a26aa9bd52df03693e |
def _get_axis_labels(self, in_dataset): <NEW_LINE> <INDENT> labels = in_dataset.data_info.get('axis_labels')[0] <NEW_LINE> volX, volY, volZ = self._get_volume_dimensions() <NEW_LINE> labels = [str(volX) + '.voxel_x.voxels', str(volZ) + '.voxel_z.voxels'] <NEW_LINE> if volY: <NEW_LINE> <INDENT> labels.append(str(volY) +... | Get the new axis labels for the output dataset - this is now a volume.
Parameters
----------
in_dataset : :class:`savu.data.data_structures.data.Data`
The input dataset to the plugin.
Returns
-------
labels : dict
The axis labels for the dataset that is output from the plugin. | 625941a26aa9bd52df036940 |
def bonferroni_correction(pvals): <NEW_LINE> <INDENT> n = len(pvals) <NEW_LINE> return [min(x * n , 1.0) for x in pvals] | Bonferroni correction.
Reference: http://en.wikipedia.org/wiki/Bonferroni_correction | 625941a26aa9bd52df036944 |
def main(self): <NEW_LINE> <INDENT> sys.path.append(os.curdir) <NEW_LINE> sys.path.append(os.path.join(os.curdir, "applications")) <NEW_LINE> sys.path.append(os.path.join(os.curdir, "plugins")) <NEW_LINE> sys.path.append(os.path.join(os.curdir, "framework")) <NEW_LINE> if not self.settings.consolelog: <NEW_LINE> <INDEN... | Set some things to work the framework.
Then launch the application | 625941a36aa9bd52df036948 |
def unlisten_multicast_group(self, multicast_address, source = None, network_interface = None, handler = None): <NEW_LINE> <INDENT> def converter(server): <NEW_LINE> <INDENT> return self <NEW_LINE> <DEDENT> if network_interface is not None and source is not None: <NEW_LINE> <INDENT> self.java_obj.unlistenMulticastGroup... | Leaves a multicast group and so stop listen for packets send to it on the given network interface.
The handler is notified once the operation completes.
@param multicast_address: the address of the multicast group to leave
@param source: the address of the source for which we will stop listen fo... | 625941a36aa9bd52df036952 |
def __handle_response(self, msg, handler): <NEW_LINE> <INDENT> packets = msg.packets <NEW_LINE> if packets[0] == flags.response: <NEW_LINE> <INDENT> self.__print__( "Response received for request id %s" % packets[1], level=1) <NEW_LINE> if self.requests.get(packets[1]): <NEW_LINE> <INDENT> addr = packets[2] <NEW_LINE> ... | This callback is used to deal with response signals. Its two
primary jobs are:
- if it was your request, send the deferred message
- if it was someone else's request, relay the information
Args:
msg: A :py:class:`~py2p.base.Message`
handler: A :py:class:`~py2p.mesh.MeshConnection`
Returns:
Eith... | 625941a36aa9bd52df036959 |
def get_darksky_data(self, service, location, timestamp=None): <NEW_LINE> <INDENT> service_json_name = '' <NEW_LINE> if service in SERVICES_MAPPING: <NEW_LINE> <INDENT> service_json_name = SERVICES_MAPPING[service]['json_name'] <NEW_LINE> <DEDENT> if "lat" in location and 'long' in location: <NEW_LINE> <INDENT> if time... | Generic method called by the current and forecast service endpoint
methods to fetch a forecast request from the Darksky API. If
performance mode is set to True, the url adds exclusions for the
services provided by the API that were not requested.
:param service: requested service endpoint
:param location: location dict... | 625941a46aa9bd52df036973 |
def append(self, obj, **kw): <NEW_LINE> <INDENT> obj = self.sanitize(obj, **kw) <NEW_LINE> return super(MeshHookList, self).append(obj) | The input :py:class:`~.hook.MeshHook` *obj* will be appended into the
list. The *obj* argument is usually a :py:class:`~.hook.MeshHook` type
or a :py:class:`~.anchor.MeshAnchor` type, instead of an instance of
them. The method will automatically create the necessary Hook object
when detect acceptable type object pass... | 625941a46aa9bd52df036975 |
def only_classmethods(cls): <NEW_LINE> <INDENT> for k, v in cls.__dict__.items(): <NEW_LINE> <INDENT> if (not k.startswith('__') and callable(v) and not isinstance(v, (classmethod, staticmethod))): <NEW_LINE> <INDENT> setattr(cls, k, classmethod(v)) <NEW_LINE> <DEDENT> <DEDENT> return cls | convert all normal methods to classmethods | 625941a56aa9bd52df03698d |
def model_filter(func): <NEW_LINE> <INDENT> def process_terms(terms): <NEW_LINE> <INDENT> new_terms = [] <NEW_LINE> cand = '' <NEW_LINE> for term in terms: <NEW_LINE> <INDENT> if term.startswith(sign) or cand.endswith(sign): <NEW_LINE> <INDENT> cand = cand + term <NEW_LINE> continue <NEW_LINE> <DEDENT> if cand: <NEW_LI... | Decorator to format query before passing it to a filter function.
The purpose of the decorator is to:
a) Split the queries into multiple keywords (space/tab separated).
b) Concatenate terms that have the ADMIN_FIELD_SIGN ("=") between them.
b) Ignore any empty queries. | 625941a56aa9bd52df036993 |
def convertToTitle(self, n): <NEW_LINE> <INDENT> str = "" <NEW_LINE> stack = [] <NEW_LINE> while n // 26 != 0: <NEW_LINE> <INDENT> stack.append(n % 26) <NEW_LINE> n = n // 26 <NEW_LINE> <DEDENT> stack.append(n % 26) <NEW_LINE> i = 0 <NEW_LINE> while i < len(stack): <NEW_LINE> <INDENT> if stack[i] == 0: <NEW_LINE> <INDE... | :type n: int
:rtype: str | 625941a56aa9bd52df036997 |
def test_01(self): <NEW_LINE> <INDENT> flag = True <NEW_LINE> try: <NEW_LINE> <INDENT> from xobox.utils.compat import EX_OK <NEW_LINE> <DEDENT> except ImportError: <NEW_LINE> <INDENT> flag = False <NEW_LINE> <DEDENT> self.assertTrue(flag) | Test Case 01:
Verify EX_OK is provided
Test is passed if no exception is raised. | 625941a56aa9bd52df0369a3 |
def execute(self,statement): <NEW_LINE> <INDENT> self.engine.execute(statement) | 执行sql语句。
:param statement:
:return: | 625941a66aa9bd52df0369ad |
@app.route('/group/<group_codename>/events/<int:event_id>/delete', methods=['GET', 'POST']) <NEW_LINE> def event_delete(group_codename, event_id): <NEW_LINE> <INDENT> (infonav, this_group, this_event) = gbot.views.get_context(group_codename=group_codename, event_id=event_id) <NEW_LINE> current_member = gbot.views.get_c... | This page essentially confirms whether or not the current_member (who must be a host) REALLY wants to
delete the event. | 625941a66aa9bd52df0369b1 |
def reduce(self, start, limit, reduce_op=operator.add): <NEW_LINE> <INDENT> if limit is None: <NEW_LINE> <INDENT> limit = self.capacity <NEW_LINE> <DEDENT> if limit < 0: <NEW_LINE> <INDENT> limit += self.capacity <NEW_LINE> <DEDENT> if reduce_op == operator.add: <NEW_LINE> <INDENT> result = 0.0 <NEW_LINE> <DEDENT> elif... | Applies an operation to specified segment.
Args:
start (int): Start index to apply reduction to.
limit (end): End index to apply reduction to.
reduce_op (Union(operator.add, min, max)): Reduce op to apply.
Returns:
Number: Result of reduce operation | 625941a66aa9bd52df0369b7 |
def plot_with_difference(original, fooled): <NEW_LINE> <INDENT> fooled_v = fooled.clone().view(3,224,224).cpu().detach() <NEW_LINE> fooled_back = inv_transform(fooled_v) <NEW_LINE> original_back = inv_transform(original.clone()) <NEW_LINE> plt.figure() <NEW_LINE> plt.subplot(131) <NEW_LINE> plt.imshow(original_back) <N... | Takes the normalised tensor of two images and plot them | 625941a66aa9bd52df0369bb |
def circ_moment(alpha, w, p=1, cent=False, dim=0): <NEW_LINE> <INDENT> if w.size == 0: <NEW_LINE> <INDENT> w = np.ones(alpha.shape) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> checkShapesEqual(w, alpha) <NEW_LINE> <DEDENT> if cent: <NEW_LINE> <INDENT> theta = np.array(circ_mean(alpha, w, dim)) <NEW_LINE> theta = thet... | Calculates the complex p-th centred or non-centred moment
of the angular data in angle.
Input:
alpha sample of angles
[w weightings in case of binned angle data]
[p p-th moment to be computed, default is p=1]
[cent if true, central moments are computed, default = false]
[dim compu... | 625941a66aa9bd52df0369c5 |
def _get_prefix_limit(self): <NEW_LINE> <INDENT> return self.__prefix_limit | Getter method for prefix_limit, mapped from YANG variable /bgp/neighbors/neighbor/afi_safis/afi_safi/l3vpn_ipv4_multicast/prefix_limit (container)
YANG Description: Configure the maximum number of prefixes that will be
accepted from a peer
| 625941a76aa9bd52df0369d5 |
def setup_platform(hass, config, add_entities, discovery_info=None): <NEW_LINE> <INDENT> import pywink <NEW_LINE> for sensor in pywink.get_sensors(): <NEW_LINE> <INDENT> _id = sensor.object_id() + sensor.name() <NEW_LINE> if _id not in hass.data[DOMAIN]['unique_ids']: <NEW_LINE> <INDENT> if sensor.capability() in SENSO... | Set up the Wink binary sensor platform. | 625941a76aa9bd52df0369d9 |
def dumps_request( self, method, params=(), id=0 ): <NEW_LINE> <INDENT> if not isinstance(method, (str, unicode)): <NEW_LINE> <INDENT> raise TypeError('"method" must be a string (or unicode string).') <NEW_LINE> <DEDENT> if not isinstance(params, (tuple, list)): <NEW_LINE> <INDENT> raise TypeError("params must be a tup... | serialize JSON-RPC-Request
:Parameters:
- method: the method-name (str/unicode)
- params: the parameters (list/tuple)
- id: if id=None, this results in a Notification
:Returns: | {"method": "...", "params": ..., "id": ...}
| "method", "params" and "id" are always in this order.
:Raises: ... | 625941a76aa9bd52df0369db |
def p_consume_id_funcion(p): <NEW_LINE> <INDENT> global variable_nombre_funcion <NEW_LINE> if not func_table.existeFuncion(p[1]): <NEW_LINE> <INDENT> raise NameError("La funcion no existe") <NEW_LINE> <DEDENT> variable_nombre_funcion = p[1] | consume_id_funcion : ID | 625941a76aa9bd52df0369e3 |
def get_size(self): <NEW_LINE> <INDENT> return self.size | 获取队列元素个数
:return: | 625941a76aa9bd52df0369e7 |
def show_port(self, context, port_id): <NEW_LINE> <INDENT> return dict(port=self._show_port(context, port_id)) | Return the port for the client given the port id.
:param context - Request context.
:param port_id - The id of port to be queried.
:returns: A dict containing port data keyed by 'port'.
e.g. {'port': {'port_id': 'abcd',
'fixed_ip_address': '1.2.3.4'}} | 625941a86aa9bd52df0369ff |
def p_TypeArgumentList(p): <NEW_LINE> <INDENT> p[0] = mytuple(["TypeArgumentList"]+p[1:]) | TypeArgumentList : TypeArgument COMMATypeArgumentS
| IDENT COMMATypeArgumentS | 625941a86aa9bd52df036a03 |
def check_response_errors(response, session): <NEW_LINE> <INDENT> if response['status'] != 'ok': <NEW_LINE> <INDENT> from wi.utils.auth import logout <NEW_LINE> error_code = response['status'] <NEW_LINE> error_msg = get_error(error_code) <NEW_LINE> raise RestErrorException(error_msg) <NEW_LINE> <DEDENT> return response | Checks status of response response and throws appropriate error. | 625941a96aa9bd52df036a0f |
def construct_data(kills, pilots): <NEW_LINE> <INDENT> return '\n'.join(kills + pilots) | Construct textarea content for resubmission
Given a list of kills and a list of pilots, put them together in a
form that enables them to be fed back into this view | 625941a96aa9bd52df036a22 |
def process_tracklog_file_v1(point_file, track_file, protocol, database_path): <NEW_LINE> <INDENT> print("building track logs") <NEW_LINE> track_log_oids = {} <NEW_LINE> mission_field_names, mission_field_types = extract_mission_attributes_from_protocol( protocol ) <NEW_LINE> mission_fields_count = len(mission_field_na... | Build a track log feature class and return the object IDs of the new track logs. | 625941aa6aa9bd52df036a28 |
def setSocialNetwork(self, newSocialNetwork): <NEW_LINE> <INDENT> self._socialNetwork = newSocialNetwork | Set a new SocialNetwork
Requires: newSocialNetwork SocialNetwork
Ensures: self.getSocialNetwork() == newSocialNetwork | 625941aa6aa9bd52df036a2a |
def matlab_style_gauss2D(shape=np.array([11,11]),sigma=1.5): <NEW_LINE> <INDENT> siz = (shape-np.array([1,1]))/2 <NEW_LINE> std = sigma <NEW_LINE> eps = 2.2204e-16 <NEW_LINE> x = np.arange(-siz[1], siz[1]+1, 1) <NEW_LINE> y = np.arange(-siz[0], siz[1]+1, 1) <NEW_LINE> m,n = np.meshgrid(x, y) <NEW_LINE> h = np.exp(-(m*m... | 2D gaussian mask - should give the same result as MATLAB's
fspecial('gaussian',[shape],[sigma]) | 625941aa6aa9bd52df036a2c |
@home.route('/') <NEW_LINE> def homepage(): <NEW_LINE> <INDENT> return make_response(jsonify( { 'message':'welcome to the hello-books app you can register in order to get the most out of the app' } )), 200 | get requests for homepage | 625941aa6aa9bd52df036a38 |
def __init__(self, atoms, protcomplex, cclass, altconf): <NEW_LINE> <INDENT> Mol.__init__(self, altconf) <NEW_LINE> self.complex = cclass <NEW_LINE> self.full_mol = protcomplex <NEW_LINE> self.all_atoms = atoms <NEW_LINE> self.rings = self.find_rings(self.full_mol, self.all_atoms) <NEW_LINE> self.hydroph_atoms = self.h... | Find all relevant parts which could take part in interactions | 625941aa6aa9bd52df036a3e |
def hamming_weight(n: int) -> int: <NEW_LINE> <INDENT> count = 0 <NEW_LINE> while n != 0: <NEW_LINE> <INDENT> n &= n - 1 <NEW_LINE> count += 1 <NEW_LINE> <DEDENT> return count | # 191: Write a function that takes an unsigned integer and return the number of '1' bits it has
(also known as the Hamming weight). | 625941aa6aa9bd52df036a42 |
def convert_obs_groups_binning_def_michi_to_default(): <NEW_LINE> <INDENT> altitude_edges = Angle([0, 20, 23, 27, 30, 33, 37, 40, 44, 49, 53, 58, 64, 72, 90], 'degree') <NEW_LINE> azimuth_edges = Angle([-90, 90, 270], 'degree') <NEW_LINE> list_obs_group_axis = [ObservationGroupAxis('ALT', altitude_edges, 'bin_edges'), ... | Convert observation groups binning definition "michi" to "default".
| 625941aa6aa9bd52df036a48 |
def _file_wr(self, filename, data): <NEW_LINE> <INDENT> with open(filename, 'w') as f: <NEW_LINE> <INDENT> json.dump([data], f) | Helper function to write a file | 625941ab6aa9bd52df036a4c |
def monsterate(match): <NEW_LINE> <INDENT> if not match: <NEW_LINE> <INDENT> return '' <NEW_LINE> <DEDENT> bits = match.groupdict('') <NEW_LINE> body = match.group(0) <NEW_LINE> if bits['count'] == '1': <NEW_LINE> <INDENT> bits['count'] = '' <NEW_LINE> <DEDENT> if bits['name'] in names: <NEW_LINE> <INDENT> sys.stderr.w... | Thing with monster. | 625941ab6aa9bd52df036a50 |
@api.route('/logout', methods=['GET']) <NEW_LINE> def logout(): <NEW_LINE> <INDENT> response = make_response( jsonify({'success': 'The user has been logged out.'}), 200 ) <NEW_LINE> response.delete_cookie('public_id') <NEW_LINE> unset_jwt_cookies(response) <NEW_LINE> return response | Logs out user and sends a response to clear access and refresh
tokens, public_id cookie, and returns success message
Returns {Object<json>} 200
success: {string} | 625941ac6aa9bd52df036a6e |
def dir_is_empty(path): <NEW_LINE> <INDENT> return isdir(path) and len(os.listdir(path)) == 0 | Check if a directory is empty | 625941ac6aa9bd52df036a74 |
def play_episode(act, embedding, features): <NEW_LINE> <INDENT> env = gym_environment.WSNEnvironment( problem_generator=lambda: (embedding, None), features=features, early_exit_factor=np.infty, additional_timeslot_reward=-1, restart_reward=0, success_reward=0, seedgen=None, ) <NEW_LINE> return _play_episode_in_env(act,... | Play an entire episode and report the reward | 625941ac6aa9bd52df036a7a |
def resize(self, width=None, height=None, filter='triangle', blur=1): <NEW_LINE> <INDENT> if width is None: <NEW_LINE> <INDENT> width = self.width <NEW_LINE> <DEDENT> if height is None: <NEW_LINE> <INDENT> height = self.height <NEW_LINE> <DEDENT> if not isinstance(width, numbers.Integral): <NEW_LINE> <INDENT> raise Typ... | Resizes the image.
:param width: the width in the scaled image. default is the original
width
:type width: :class:`numbers.Integral`
:param height: the height in the scaled image. default is the original
height
:type height: :class:`numbers.Integral`
:param filter: a filter type to use for... | 625941ac6aa9bd52df036a88 |
def unload(self, key): <NEW_LINE> <INDENT> assert isinstance(key, PGPKey) <NEW_LINE> pkid = id(key) <NEW_LINE> if pkid in self._keys: <NEW_LINE> <INDENT> [ kd.remove(pkid) for kd in [self._pubkeys, self._privkeys] if pkid in kd ] <NEW_LINE> self._keys.pop(pkid) <NEW_LINE> for m, a in [ (m, a) for m in self._aliases for... | Unload a loaded key and its subkeys.
The easiest way to do this is to select a key using :py:meth:`PGPKeyring.key` first::
with keyring.key("DSA von TestKey") as key:
keyring.unload(key)
:param key: The key to unload.
:type key: :py:obj:`PGPKey` | 625941ad6aa9bd52df036a9b |
def _check_project_dir(project_dir, force=False): <NEW_LINE> <INDENT> if os.path.exists(project_dir) and not os.path.isdir(project_dir): <NEW_LINE> <INDENT> raise CommandError(f'The path {project_dir} already exists and is a file.') <NEW_LINE> <DEDENT> if not os.path.isdir(project_dir): <NEW_LINE> <INDENT> return <NEW_... | Check if a project directory with the given name already exists.
If such a project exists, only continue if the ``force`` flag has been
specified. | 625941ad6aa9bd52df036a9f |
def get_field_alias_grid_column_names_by_order(self): <NEW_LINE> <INDENT> self.column_name_list = self.get_grid_column_names_by_order(self.field_alias_grid_div_id) <NEW_LINE> return self.column_name_list | Implementing get field alias grid column names by order functionality
:return: column_name_list | 625941add7e4931a7ee9dc18 |
def StockTable(inputfilename,taxbracketfile): <NEW_LINE> <INDENT> input=open(inputfilename) <NEW_LINE> UniqTickers=UT.UniqueTickers(inputfilename) <NEW_LINE> data_string=json.load(input) <NEW_LINE> emailReportMsg="" <NEW_LINE> htmlOutput=" " <NEW_LINE> jsonOutput="{ \"date\":\""+DTH.GetDate()+"\",\n \"portfolio\":[" <N... | #This methoad traverses a portfolio and outputs the performance of each stock in the portfolio
#as well as overall performance. | 625941add7e4931a7ee9dc1c |
def save(self): <NEW_LINE> <INDENT> self.config.set_space_placement(self.choice.GetStringSelection()) | Write all parameters to the config. | 625941ad6aa9bd52df036aa6 |
def debug(self): <NEW_LINE> <INDENT> print(str(self)) <NEW_LINE> print('<internal> %s: %s' % ('src', getattr(self, 'src', None))) <NEW_LINE> print('<internal> %s: %s' % ('meta', getattr(self, 'meta', None))) <NEW_LINE> for k, v in self._attrs.items(): <NEW_LINE> <INDENT> if k: <NEW_LINE> <INDENT> print('%s: %s' % (k, v... | Print all attributes | 625941ae6aa9bd52df036aaa |
def __init__(self, name, title, description, datatype, gateway=None, device=None): <NEW_LINE> <INDENT> if name in parameters and isinstance(parameters[name], Parameter): <NEW_LINE> <INDENT> raise Exception('parameter with same name already exists') <NEW_LINE> <DEDENT> self.name = name <NEW_LINE> self.title = title <NEW... | init the object parameter.
:param gateway: optional, in case of device or asset relative to a gateway
:param device: optional, in case of asset relative to a device
:param name: name of the parameter, Should be unique, within the application (checked), used to identify the value.
:param title: a human readable title
:p... | 625941ae6aa9bd52df036ab0 |
def get_recommendations(srs): <NEW_LINE> <INDENT> assert len(srs) == 1 and srs[0].__class__ == Subreddit <NEW_LINE> sr = srs[0] <NEW_LINE> recs = _get_recommendations(sr._id36) <NEW_LINE> if not recs: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> srs = Subreddit._byID36(recs, return_dict=True, data=True) <NEW_LINE>... | Return the subreddits recommended if you like the given subreddit | 625941ae6aa9bd52df036ab8 |
def MakePrediction(self, X, parameters, hidden_func, output_func): <NEW_LINE> <INDENT> X = X.T <NEW_LINE> AL, _ = self.ForwardProp(X, parameters, hidden_func, output_func) <NEW_LINE> if output_func=='softmax': <NEW_LINE> <INDENT> y_pred = np.argmax(AL, axis=0) <NEW_LINE> <DEDENT> if output_func=='sigmoid': <NEW_LINE> <... | Make prediction of the data X
---------
Input
- X : Input data (m, n_x)
- parameters : parameters W, b of each layers of the NN model
Output
- y_pred : Predicted labels for X (m,) | 625941ae293b9510aa2c2fb3 |
def on_disconnect(self): <NEW_LINE> <INDENT> logger.error('Disconnected from server!') | Handler for disconnection events | 625941ae6aa9bd52df036abc |
def op_2(program, pc, opcode): <NEW_LINE> <INDENT> multiplicand1, multiplicand2 = get_parameters(program, pc, opcode, 2) <NEW_LINE> output_register = program[pc + 3] <NEW_LINE> program[output_register] = multiplicand1 * multiplicand2 <NEW_LINE> return 4 | Multiplication Operation | 625941ae293b9510aa2c2fb5 |
def draw_random_bst(n): <NEW_LINE> <INDENT> from random import randint <NEW_LINE> nums = set() <NEW_LINE> max_num = 10 * n <NEW_LINE> if 0 < n < MAX_HEIGHT: <NEW_LINE> <INDENT> while len(nums) != n: <NEW_LINE> <INDENT> nums.add(randint(1, max_num)) <NEW_LINE> <DEDENT> <DEDENT> draw_bst(list(nums)) | Draw random binary search tree of n nodes
| 625941ae3317a56b86939981 |
def reset(self): <NEW_LINE> <INDENT> self._timestep = np.array([0]) | See base class (Policy) for description.
Subclasses are expected to feed self._timestep to their q_func graphs and
increment self._timestep in `sample_action`. | 625941aed7e4931a7ee9dc38 |
def test_cut(self): <NEW_LINE> <INDENT> url = self.tpl + '/cut' <NEW_LINE> res = requests.post(url, data=self.data) <NEW_LINE> self.assertEqual(res.status_code, 200) <NEW_LINE> result = res.json() <NEW_LINE> self.assertEqual(result['text'], self.text) <NEW_LINE> self.assertEqual(''.join(result['words']), self.text) | 测试默认分词模式 | 625941ae6aa9bd52df036ac1 |
def execute(self, env, out): <NEW_LINE> <INDENT> raise NotImplementedError('abstract') | Appends output to out, or returns the result if an expression. | 625941ae3346ee7daa2b2a87 |
def Realize(self): <NEW_LINE> <INDENT> status = True <NEW_LINE> self._collapse_stack = [] <NEW_LINE> for child in self.GetChildren(): <NEW_LINE> <INDENT> if not isinstance(child, RibbonControl): <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> if not child.Realize(): <NEW_LINE> <INDENT> status = False <NEW_LINE> <DEDEN... | Perform a full re-layout of all panels on the page.
Should be called after panels are added to the page, or the sizing behaviour of
a panel on the page changes (i.e. due to children being added to it). Usually
called automatically when :meth:`RibbonBar.Realize() <lib.agw.ribbon.bar.RibbonBar.Realize>` is called. Will ... | 625941aed7e4931a7ee9dc3e |
def __init__(self, data): <NEW_LINE> <INDENT> question_url, question_title, question_desc, question_stats, answers, comments, dup_url = data <NEW_LINE> self.dup_url = dup_url <NEW_LINE> self.question_title = question_title <NEW_LINE> self.question_desc = question_desc <NEW_LINE> self.question_stats = question_stats <NE... | Construct the Question Page.
:param data: tuple of (question_url, question_title, question_desc, question_stats, answers, comments, dup_url) | 625941ae3317a56b86939989 |
def draw_hull(self): <NEW_LINE> <INDENT> plt.plot(self._points[:,0], self._points[:,1], 'o') <NEW_LINE> for simplex in self.hull.simplices: <NEW_LINE> <INDENT> plt.plot(self._points[simplex, 0], self._points[simplex, 1], 'k-') | Draws, but does not display, all points along with an outlined
convex hull. A call to plt.show() must be made to show this shape. | 625941ae3346ee7daa2b2a8d |
def resolve(self, max_rounds: int = 10) -> Set[InstallRequirement]: <NEW_LINE> <INDENT> if self.clear_caches: <NEW_LINE> <INDENT> self.dependency_cache.clear() <NEW_LINE> self.repository.clear_caches() <NEW_LINE> <DEDENT> with update_env_context_manager(PIP_EXISTS_ACTION="i"): <NEW_LINE> <INDENT> for current_round in c... | Finds concrete package versions for all the given InstallRequirements
and their recursive dependencies. The end result is a flat list of
(name, version) tuples. (Or an editable package.)
Resolves constraints one round at a time, until they don't change
anymore. Protects against infinite loops by breaking out after ... | 625941af6aa9bd52df036acb |
def clear_journal_entry_terms(self): <NEW_LINE> <INDENT> raise errors.Unimplemented() | Clears all journal entry terms.
*compliance: mandatory -- This method must be implemented.* | 625941af3317a56b8693998d |
def stack_to_scaled(self, stack_coords, tgt_zoom, src_zoom=0): <NEW_LINE> <INDENT> return { dim: self.stack_to_scaled_coord(dim, proj_coord, tgt_zoom, src_zoom) for dim, proj_coord in stack_coords.items() } | Convert a point in stack space into a point in stack space at a different zoom level.
Whether z coordinates are scaled is controlled by the `scale_z` constructor argument/ instance variable.
Parameters
----------
stack_coords : dict
x, y, and/or z coordinates in stack / voxel space
tgt_zoom : float
Desired zo... | 625941af5166f23b2e1a4e82 |
def get_endpoint_profiles(self, kaauser, group_id): <NEW_LINE> <INDENT> url = 'http://{}:{}/kaaAdmin/rest/api/endpointProfileBodyByGroupId?endpointGroupId={}'.format(self.host, self.port, str(group_id)) <NEW_LINE> req = requests.get(url, auth=(kaauser.name, kaauser.password)) <NEW_LINE> if req.status_code != requests.c... | Returns a list of endpoint profiles by the the endpoint group ID.
:param kaauser: The Kaa server IP address.
:type kaauser: KaaUser.
:param group_id: A unique endpoint group identifier. | 625941af6aa9bd52df036acd |
def noun_stem (s): <NEW_LINE> <INDENT> if s in identical_plurals: <NEW_LINE> <INDENT> return s <NEW_LINE> <DEDENT> elif s[-3:] == "man": <NEW_LINE> <INDENT> return s[:-2] + "en" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return verb_stem(s) | extracts the stem from a plural noun, or returns empty string | 625941af3317a56b8693998f |
def delete(self): <NEW_LINE> <INDENT> selectedItems = self.piirtoalusta.scene.selectedItems() <NEW_LINE> command = CommandDelete(self.piirtoalusta.scene, selectedItems) <NEW_LINE> self.piirtoalusta.undoStack.push(command) | Poistaa valitut esineet ja/tai ryhmät | 625941af293b9510aa2c2fc7 |
def testdx(self): <NEW_LINE> <INDENT> gr = GaussianRestraint(*self.all) <NEW_LINE> for i in range(100): <NEW_LINE> <INDENT> map(self.change_value, self.all) <NEW_LINE> map(self.change_sign, self.locations) <NEW_LINE> gr.evaluate(True) <NEW_LINE> self.assertAlmostEqual(Nuisance(self.x).get_nuisance_derivative(), self.de... | Test GaussianRestraint(13) x derivative | 625941af293b9510aa2c2fc9 |
def setCalibParsDefault (self) : <NEW_LINE> <INDENT> for type in self.list_of_clib_types : <NEW_LINE> <INDENT> self.cpars[type] = self.getCalibParsDefault (type) <NEW_LINE> self.cpars_status[type] = 'DEFAULT' | Loads default calibration parameters from singleton object.
| 625941afadb09d7d5db6c4c5 |
def value_interval_cmp(value, interval): <NEW_LINE> <INDENT> if interval[0] <= value <= interval[1]: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> elif value < interval[0]: <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return 1 | Comparator that indicates if a value is within, higher or lower than an interval | 625941afd7e4931a7ee9dc4a |
def download_file(url: str, local_file: str) -> str: <NEW_LINE> <INDENT> log('Downloading {} to {}'.format(url, local_file)) <NEW_LINE> with requests.get(url, stream=True) as r: <NEW_LINE> <INDENT> r.raise_for_status() <NEW_LINE> with local_file.open(mode='wb') as f: <NEW_LINE> <INDENT> for chunk in r.iter_content(chun... | Download a file from an arbitrary URL to a local file | 625941afadb09d7d5db6c4c7 |
def __repr__(self): <NEW_LINE> <INDENT> return 'TippyGameState({}, {}, False)'.format(repr(self.next_player), repr(self.board)) | (TippyGameState) -> str
Return a string representation of TippyGameState self
that evaluates to an equivalent TippyGameState
>>> board = matrix(3)
>>> t = TippyGameState('p1', board)
>>> t
TippyGameState('p1', [['_', '_', '_'], ['_', '_', '_'], ['_', '_', '_']], False) | 625941af293b9510aa2c2fcd |
def phase_by_window_spec(self,source,windowSpec,trial_type): <NEW_LINE> <INDENT> selection = [] <NEW_LINE> for specix,spec in enumerate(windowSpec): <NEW_LINE> <INDENT> ix = self._fetch_windowspec_indices([spec],trial_type,precision=precision) <NEW_LINE> if len(ix)>0: <NEW_LINE> <INDENT> selection.append(( self.windows... | Parameters
----------
source : str
windowSpec : list
trial_type : str | 625941af925a0f43d2549ba5 |
def get_tdar_items_by_site_keyword_objs(self, keyword_objs): <NEW_LINE> <INDENT> output = False <NEW_LINE> keyword_uris = [] <NEW_LINE> if isinstance(keyword_objs, list): <NEW_LINE> <INDENT> for keyword_obj in keyword_objs: <NEW_LINE> <INDENT> if isinstance(keyword_obj, dict): <NEW_LINE> <INDENT> if 'id' in keyword_obj... | gets site information by tdar keyword objects | 625941af3317a56b86939997 |
def display_start_menu(update, context): <NEW_LINE> <INDENT> update.message.reply_text( lernen_menu_message(), reply_markup=lernen_menu(), parse_mode="HTML", ) | Show learning journey articles | 625941afadb09d7d5db6c4c9 |
def decideTheBestTree(test_set,prun_tree_list): <NEW_LINE> <INDENT> correct_rate_max = predictCorrectRate(test_set, prun_tree_list[0]) <NEW_LINE> best_tree = prun_tree_list[0] <NEW_LINE> for i in range(len(prun_tree_list)): <NEW_LINE> <INDENT> correct_rate = predictCorrectRate(test_set, prun_tree_list[i]) <NEW_LINE> if... | 函数功能:找到最优决策树
输入参数:test_set:测试集; prun_tree_list:剪枝树列表
输出参数:对于这个测试集而言最优的决策树 | 625941af925a0f43d2549ba7 |
def test_empty_list(self): <NEW_LINE> <INDENT> response = self.client.get(self.test_link) <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_LINE> self.assertContains(response, "empty-message") | view has no showstoppers on returning empty list | 625941af6aa9bd52df036ad7 |
def testHistogram(self): <NEW_LINE> <INDENT> self.testslicer.plotHistogram(self.metricdata, title='Mean of random test data', xlabel=None, ylabel='Area (1000s of square degrees)', fignum=None, legendLabel=None, addLegend=False, legendloc='upper left', bins=100, cumulative=False, histRange=None, logScale=False, flipXaxi... | Test plotting the histogram (mean of random data). | 625941af3317a56b8693999a |
def _get_query_string(self, params): <NEW_LINE> <INDENT> pairs = [(self._unicode_safe(k), self._unicode_safe(v)) for k, v in params.iteritems()] <NEW_LINE> pairs.sort() <NEW_LINE> query_string = '&'.join(['%s=%s' % pair for pair in pairs]) <NEW_LINE> return query_string | URL Encode Parameters as query string | 625941af596a8972360897f8 |
def __init__(self, user, skip=None, *args, **kwargs): <NEW_LINE> <INDENT> if skip is None: <NEW_LINE> <INDENT> skip = [] <NEW_LINE> <DEDENT> super(AgentFilterForm, self).__init__(*args, **kwargs) <NEW_LINE> self.fields['related_user'].required = True <NEW_LINE> self.fields['related_user'].label = _("Related user") | Sets allowed values | 625941af046cf37aa974ca80 |
def test_ticket47553_moddn_staging_prod_1(topology): <NEW_LINE> <INDENT> topology.master1.log.info("\n\n######################### MOVE staging -> Prod (1) ######################\n") <NEW_LINE> _bind_normal(topology) <NEW_LINE> old_rdn = "cn=%s1" % NEW_ACCOUNT <NEW_LINE> old_dn = "%s,%s" % (old_rdn, STAGING_DN) <NEW_LI... | This test case MOVE entry NEW_ACCOUNT1 from staging to prod
target_to/target_from: substring/equality filter | 625941af6aa9bd52df036ad9 |
def download_artifacts(job_name, local_fname): <NEW_LINE> <INDENT> sm_client = boto3.Session().client('sagemaker') <NEW_LINE> response = sm_client.describe_trial_component(TrialComponentName=job_name) <NEW_LINE> model_artifacts_full_path = response['OutputArtifacts']['SageMaker.ModelArtifact']['Value'] <NEW_LINE> p = r... | Given a trial name in a SageMaker Experiment, extract the model file and download it locally | 625941afd164cc6175782a87 |
def recalc_face_normals(bm, faces): <NEW_LINE> <INDENT> pass | Computes an “outside” normal for the specified input faces.
:param bm: The bmesh to operate on.
:type bm: bmesh.types.BMesh
:param faces: Undocumented.
:type faces: list of (bmesh.types.BMFace) | 625941af3346ee7daa2b2aa1 |
def test_w_refseqs_file(self): <NEW_LINE> <INDENT> inseqs = parse_fasta(self.inseqs1) <NEW_LINE> actual = qiime_blast_seqs(inseqs, refseqs=self.refseqs1) <NEW_LINE> self.assertEqual(len(actual), 5) <NEW_LINE> self.assertEqual(actual['s2_like_seq'][0][0]['SUBJECT ID'], 's2') <NEW_LINE> self.assertEqual(actual['s105'][0]... | qiime_blast_seqs functions with refseqs file
| 625941af293b9510aa2c2fd3 |
def __stop(self): <NEW_LINE> <INDENT> self._running = False | Stop console loop
| 625941af3317a56b869399a0 |
def __fetch_and_update_regions(self): <NEW_LINE> <INDENT> regions = list( set([row['location'] for row in self.__rows])) <NEW_LINE> for region in regions: <NEW_LINE> <INDENT> get_or_create(db.session, Region, name=region) | Fetches and updates regions table | 625941af6aa9bd52df036ae1 |
def dice_coeff(Q, D): <NEW_LINE> <INDENT> Q, D = set(Q), set(D) <NEW_LINE> try: <NEW_LINE> <INDENT> return 2.0 * len(Q & D) / (len(Q) + len(D)) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> pass | Similarity | 625941af3317a56b869399a4 |
def parse_module(self, program_text: str, incremental_step: int = 0) -> List[Tuple[str, str, str]]: <NEW_LINE> <INDENT> m = re.search('# cmd: mypy -m ([a-zA-Z0-9_. ]+)$', program_text, flags=re.MULTILINE) <NEW_LINE> if incremental_step > 1: <NEW_LINE> <INDENT> alt_regex = '# cmd{}: mypy -m ([a-zA-Z0-9_. ]+)$'.format(in... | Return the module and program names for a test case.
Normally, the unit tests will parse the default ('__main__')
module and follow all the imports listed there. You can override
this behavior and instruct the tests to check multiple modules
by using a comment like this in the test case input:
# cmd: mypy -m foo.ba... | 625941afd164cc6175782a8c |
def thanks(year=None): <NEW_LINE> <INDENT> nov_first = datetime.date(_year, 11, 1) if not year else datetime.date(int(year), 11, 1) <NEW_LINE> weekday_seq = nov_first.weekday() <NEW_LINE> if weekday_seq > 3: <NEW_LINE> <INDENT> current_day = 32 - weekday_seq <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> current_day = 2... | 4rd Thursday in Nov
:param year: int
:return: Thanksgiving Day | 625941af596a897236089804 |
def test_restart_cf4(run_in_tmpdir): <NEW_LINE> <INDENT> op = dummy_operator.DummyOperator() <NEW_LINE> output_dir = "test_restart_cf4" <NEW_LINE> op.output_dir = output_dir <NEW_LINE> dt = [0.75] <NEW_LINE> power = 1.0 <NEW_LINE> openmc.deplete.cf4(op, dt, power, print_out=False) <NEW_LINE> prev_res = openmc.deplete.R... | Integral regression test of integrator algorithm using CF4. | 625941af046cf37aa974ca8c |
def pipeline(self,processing_col): <NEW_LINE> <INDENT> self.lowercase(processing_col,'lowercase') <NEW_LINE> self.url_removal('lowercase','urlremoval') <NEW_LINE> self.html_tag('urlremoval','html_tag') <NEW_LINE> self.rm_punc('html_tag','rmpunc') <NEW_LINE> self.remove_emoji('rmpunc','rmemoji') <NEW_LINE> self.word_tok... | This is the default pipeline we can use in most of the text data.
In this first we are lowercasing the text data, after lower case we are removing the url, html tag and punctuations.
Once punctuations are removed, we are removing the emojis. After removal of emojis we are tokenizing it into word tokens, And lemmatizin... | 625941af2c8b7c6e89b35506 |
def display(self): <NEW_LINE> <INDENT> if self.dim == 2: <NEW_LINE> <INDENT> self.image = plt.imshow(self.config) <NEW_LINE> plt.show() | Plot the current spin configuration, if `self.dim == 2`.
| 625941af4a966d76dd550d4c |
def get_function_or_wrapper(self, func, before_change_func, wrapper, is_method): <NEW_LINE> <INDENT> if self.is_forbidden(func): <NEW_LINE> <INDENT> return func <NEW_LINE> <DEDENT> if self.is_decorator(before_change_func): <NEW_LINE> <INDENT> if self.is_method(before_change_func): <NEW_LINE> <INDENT> self.remove(before... | Здесь принимается решение, декорировать функцию или оставить оригинал.
Если декорирование функции ранее было запрещено, вернется оригинал.
Если функция ранее уже была задекорирована, тут надо смотреть на приоритеты. У декоратора класса приоритет ниже, чем у декоратора функций. Если функция ранее была задекорирована че... | 625941afd7e4931a7ee9dc5d |
def get_nom(self): <NEW_LINE> <INDENT> return self.nom | :return: Retorna el nom del jugador | 625941af5166f23b2e1a4e9b |
def reset_energie(self): <NEW_LINE> <INDENT> self.energie_courante = self.energie_depart | Remet l’énergie courante du personnage à sa valeur de départ. | 625941af097d151d1a222b9f |
def enable_voice(self): <NEW_LINE> <INDENT> self._jarvis.enable_voice = True | Use text to speech for every text passed to jarvis.say() | 625941af7b180e01f3dc454c |
def calcTempInEV(self, expFitCoeffWithVoltUnits): <NEW_LINE> <INDENT> eV=1.60218e-19; <NEW_LINE> q=1.6e-19 <NEW_LINE> return q*expFitCoeffWithVoltUnits/eV | Calulates temperature from langmuir exp fit
Parameters
----------
expFitCoeffWithVoltUnits : float
| 625941afd164cc6175782a8f |
def __init__(self, data, input_dims=None, output_dims=None): <NEW_LINE> <INDENT> if isinstance(data, (list, np.ndarray)): <NEW_LINE> <INDENT> ptm = np.asarray(data, dtype=complex) <NEW_LINE> dout, din = ptm.shape <NEW_LINE> if input_dims: <NEW_LINE> <INDENT> input_dim = np.product(input_dims) <NEW_LINE> <DEDENT> else: ... | Initialize a PTM quantum channel operator.
Args:
data (QuantumCircuit or
Instruction or
BaseOperator or
matrix): data to initialize superoperator.
input_dims (tuple): the input subsystem dimensions.
[Default: None]
output_dims (tuple): the output subsys... | 625941af8a43f66fc4b53daf |
def set_app_lifetime(self, env, app_lifetime): <NEW_LINE> <INDENT> env.app_lifetime = app_lifetime | sets the lifetime of the application
Input: env: AutomotiveEnvironmentSpec: specification of the Environment
Output: - | 625941af596a897236089808 |
def test_get_trajectory_lengths(self): <NEW_LINE> <INDENT> TF_TEST_MASK = tf.constant(NP_TEST_MASK) <NEW_LINE> TF_TEST_MASK_TF_F64 = tf.cast(TF_TEST_MASK, tf.float64) <NEW_LINE> NP_TEST_MASK_NP_F64 = NP_TEST_MASK.astype(np.float64) <NEW_LINE> ALL_MASKS = [ TF_TEST_MASK, NP_TEST_MASK, TF_TEST_MASK_TF_F64, NP_TEST_MASK_N... | Checks if the length of each trajectory in the batch is correct. | 625941afd7e4931a7ee9dc61 |
def set_undo_callback(self, callback): <NEW_LINE> <INDENT> raise NotImplementedError | Define the callback function that is called whenever an undo operation
is executed.
The callback function receives a single argument that is a text string
that defines the operation. | 625941af925a0f43d2549bb9 |
def get_ip_lb_services(ovh_client): <NEW_LINE> <INDENT> return ovh_client.get('/ip/loadBalancing') | Get all legacy load balancing services
GET /ip/LoadBalancing | 625941af6aa9bd52df036ae9 |
@api.route('/comments/<int:id>/like/', methods=["GET", "POST", "DELETE"]) <NEW_LINE> @auth.login_required <NEW_LINE> def new_comments_id_like(id): <NEW_LINE> <INDENT> comment = Comments.query.get_or_404(id) <NEW_LINE> if request.method == "POST": <NEW_LINE> <INDENT> if comment.liked: <NEW_LINE> <INDENT> return jsonify(... | 点赞特定id的课程
:param id:
:return: | 625941af3346ee7daa2b2aad |
def timestamp_2_readable(time_stamp): <NEW_LINE> <INDENT> return datetime.fromtimestamp(time_stamp).strftime('%Y-%m-%d %H:%M:%S') | 时间戳转换为可读时间
:param time_stamp: 时间戳,当前时间:time.time()
:return: 可读时间字符串 | 625941b073bcbd0ca4b2bdbd |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.