code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def GMotionComplete(self, axes): <NEW_LINE> <INDENT> self._cc() <NEW_LINE> c_axes = _GCStringIn(axes.encode(_enc)) <NEW_LINE> _rc(_gclibo.GMotionComplete(self._gcon, c_axes)) <NEW_LINE> return
Blocking call that returns once all axes specified have completed their motion. See Link GMotionComplete() <http://www.galil.com/sw/pub/all/doc/gclib/html/gclibo_8h_a19c220879442987970706444197f397a.html#a19c220879442987970706444197f397a>
625941ead4950a0f3b08c80f
def convertToTitle(self, n): <NEW_LINE> <INDENT> if n == 0: <NEW_LINE> <INDENT> return "" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> num = n-1 // 26 <NEW_LINE> print('num {}'.format(num)) <NEW_LINE> tmp = self.convertToTitle((n - 1) // 26) <NEW_LINE> tmp2 = chr((n - 1) % 26 + ord('A')) <NEW_LINE> return tmp + tmp2
:type n: int :rtype: str
625941eaf548e778e58cda47
def __on_open_new_page_activate(self, action, variant, uri, ephemeral): <NEW_LINE> <INDENT> self._window.container.add_webview(uri, LoadingType.FOREGROUND, self.ephemeral or ephemeral)
Open link in a new page @param action as Gio.SimpleAction @param variant as GLib.Variant @param uri as str @param ephemeral as bool
625941ead53ae8145f87a72d
def findOrder(self, numCourses, prerequisites): <NEW_LINE> <INDENT> self.prev_courses = [set() for _ in xrange(numCourses)] <NEW_LINE> self.learned_courses = set() <NEW_LINE> self.want_to_learn = set() <NEW_LINE> self.schedule = [] <NEW_LINE> for preq in prerequisites: <NEW_LINE> <INDENT> self.prev_courses[preq[0]].add...
:type numCourses: int :type prerequisites: List[List[int]] :rtype: List[int]
625941eaa05bb46b383ecce4
def test(): <NEW_LINE> <INDENT> myDat, labels = tb.createDataSet() <NEW_LINE> myTree = tb.createTree(myDat, labels) <NEW_LINE> myDat, labels = tb.createDataSet() <NEW_LINE> print(classify(myTree, labels, [1, 1]))
测试
625941ea1f037a2d8b9466c4
def test_automatic_rename_option(self): <NEW_LINE> <INDENT> s = self.session <NEW_LINE> sconfig = kaptan.Kaptan(handler='yaml') <NEW_LINE> sconfig = sconfig.import_config(self.yaml_config).get() <NEW_LINE> builder = WorkspaceBuilder(sconf=sconfig) <NEW_LINE> window_count = len(self.session._windows) <NEW_LINE> self.ass...
With option automatic-rename: on.
625941eabd1bec0571d90af6
def classification_loss(logits, labels): <NEW_LINE> <INDENT> labels = tf.to_int64(labels) <NEW_LINE> cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=logits, labels=labels, name='xentropy') <NEW_LINE> loss = tf.reduce_mean(cross_entropy, name='xentropy_mean') <NEW_LINE> return loss
Calculates the loss from the logits and the labels. Args: logits: Logits tensor, float - [batch_size, NUM_CLASSES]. labels: Labels tensor, int32 - [batch_size]. Returns: loss: Loss tensor of type float.
625941eab57a9660fec33d52
def getTopRight(self): <NEW_LINE> <INDENT> return (float(self.get_cx()) + float(self.get_r()), float(self.get_cy()) + float(self.get_r()))
Retrieves a tuple with the x,y coordinates of the upper right point of the circle. Requires the radius and the coordinates to be numbers
625941ea94891a1f4081bf73
def asVerboseContainer(cont, onGet=None, onSet=None, onDel=None): <NEW_LINE> <INDENT> class VerboseContainer(type(cont)): <NEW_LINE> <INDENT> if onGet: <NEW_LINE> <INDENT> def __getitem__(self, key): <NEW_LINE> <INDENT> onGet(self, key) <NEW_LINE> return super(VerboseContainer, self).__getitem__(key) <NEW_LINE> <DEDENT...
Returns a 'verbose' version of container instance `cont`, that will execute `onGet`, `onSet` and `onDel` (if not `None`) every time __getitem__, __setitem__ and __delitem__ are called, passing `self`, `key` (and `value` in the case of set). E.g: >>> l = [1,2,3] >>> l = asVerboseContainer(l, ... onGet=la...
625941ea10dbd63aa1bd3069
def adhocquery_getschema(self, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> return self.adhocquery_getschema_with_http_info(**kwargs)
View the database schema for making ad hoc queries # noqa: E501 Allows the user to view the list of schema for ad hoc queries. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.adhocquery_getschema(async_req=True) >...
625941ea7d847024c06be787
def _init_norm(self): <NEW_LINE> <INDENT> kernel_norm = tf.sqrt(tf.reduce_sum(tf.square(self.weight_v), axis=self.kernel_norm_axes)) <NEW_LINE> self.weight_g.assign(kernel_norm[:, tf.newaxis, tf.newaxis])
Set the norm of the weight vector.
625941ea5510c4643540f89f
def collapseAll(self): <NEW_LINE> <INDENT> self._changeExpansionState(state=False, selected=False)
Collapses all test items including all descendants.
625941ea99cbb53fe67930ac
def test_cirrus_home(self): <NEW_LINE> <INDENT> home1 = cirrus_home() <NEW_LINE> self.assertEqual(home1, 'TESTVALUE') <NEW_LINE> del os.environ['CIRRUS_HOME'] <NEW_LINE> home2 = cirrus_home() <NEW_LINE> self.assertNotEqual(home2, 'TESTVALUE')
test cirrus home function
625941ea24f1403a92601029
def _get_router_status_entry(self, controller): <NEW_LINE> <INDENT> global TEST_ROUTER_STATUS_ENTRY <NEW_LINE> if TEST_ROUTER_STATUS_ENTRY is None: <NEW_LINE> <INDENT> for desc in controller.get_network_statuses(): <NEW_LINE> <INDENT> if desc.nickname != 'Unnamed' and Flag.NAMED in desc.flags: <NEW_LINE> <INDENT> TEST_...
Provides a router status entry for a relay with a nickname other than 'Unnamed'. This fails the test if unable to find one.
625941ead268445f265b5336
def force_clean_old_tweets(count=1000): <NEW_LINE> <INDENT> docs = db.result.find({}, ('_id',)) .sort('timestamp_ms', pymongo.ASCENDING) .limit(count) <NEW_LINE> selector = {'_id': {'$in': [doc['_id'] for doc in docs]}} <NEW_LINE> result = db.result.delete_many(selector) <NEW_LINE> log.info(f"Deleted {res...
Force delete a number of old tweets to make up for more space. :param count: the number of tweets to delete
625941ea7c178a314d6ef92e
def check(self, vs30, vs30_tolerance, gsims_by_trt): <NEW_LINE> <INDENT> for gsims in gsims_by_trt.values(): <NEW_LINE> <INDENT> for gsim in gsims: <NEW_LINE> <INDENT> gsim_ref = gsim.DEFINED_FOR_REFERENCE_VELOCITY <NEW_LINE> if gsim_ref and self.vs30_ref > gsim_ref: <NEW_LINE> <INDENT> raise ValueError( '%s.DEFINED_FO...
Raise a ValueError if some vs30 is different from vs30_ref within the tolerance. Called by the engine.
625941ea3d592f4c4ed1d527
def loop(lifewindow): <NEW_LINE> <INDENT> pass
This callback runs on every iteration of the Game of Life. Implement the rules of the game here. Any object returned from this method is ignored.
625941ea099cdd3c635f1120
def exposed(self, position): <NEW_LINE> <INDENT> for neighbor, _face in iter_neighbors(position): <NEW_LINE> <INDENT> if self.empty(neighbor): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> return False
Returns False if given `position` is surrounded on all 6 sides by blocks, True otherwise.
625941ea004d5f362079a7f7
def get_type(df, col_name): <NEW_LINE> <INDENT> pd_type = df[col_name].dtype <NEW_LINE> if pd_type == np.int64: <NEW_LINE> <INDENT> return Integer <NEW_LINE> <DEDENT> elif pd_type == np.float64: <NEW_LINE> <INDENT> return Float <NEW_LINE> <DEDENT> elif pd_type == np.bool: <NEW_LINE> <INDENT> return Boolean <NEW_LINE> <...
return sqlalcheymy type based on DataFrame col type
625941eacb5e8a47e48b7f6a
def is_valid_state(state): <NEW_LINE> <INDENT> return True
Check if state is valid
625941ea23e79379d52eea25
def describe_volumes(kwargs=None, call=None): <NEW_LINE> <INDENT> if call != "function": <NEW_LINE> <INDENT> log.error( "The describe_volumes function must be called with -f " "or --function." ) <NEW_LINE> return False <NEW_LINE> <DEDENT> if not kwargs: <NEW_LINE> <INDENT> kwargs = {} <NEW_LINE> <DEDENT> params = {"Act...
Describe a volume (or volumes) volume_id One or more volume IDs. Multiple IDs must be separated by ",". TODO: Add all of the filters.
625941ea26238365f5f0f33c
def activate_ssh(environ): <NEW_LINE> <INDENT> redshifts = {} <NEW_LINE> for envvar, localport in [ ("JB_REDSHIFT_CONNECTION", 5439), ("JB_HSTM_REDSHIFT_CONNECTION", 5438), ("JB_PREVERITY_REDSHIFT_CONNECTION", 5437), ]: <NEW_LINE> <INDENT> if envvar not in environ: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> url =...
Start the SSH tunnels, and manipulate the environment variables so that they are pointing at the right ports.
625941ea3d592f4c4ed1d528
def test_local_bind_hosts(self): <NEW_LINE> <INDENT> with self._test_server( (self.saddr, self.sport), ssh_username=SSH_USERNAME, ssh_password=SSH_PASSWORD, local_bind_addresses=[(self.saddr, 0)] * 2, remote_bind_addresses=[(self.eaddr, self.eport), (self.saddr, self.sport)], logger=self.log, ) as server: <NEW_LINE> <I...
Test local_bind_hosts property
625941ea56ac1b37e626468d
def test_initialization(): <NEW_LINE> <INDENT> from stocker.models import ShutterStock <NEW_LINE> sst = ShutterStock() <NEW_LINE> assert isinstance(sst, ShutterStock)
test initialization
625941ea925a0f43d254a343
def _verify_safe(self, this): <NEW_LINE> <INDENT> context = self._context <NEW_LINE> if context & contexts.FAIL_NEXT: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if context & contexts.WIKILINK_TITLE: <NEW_LINE> <INDENT> if this == "]" or this == "{": <NEW_LINE> <INDENT> self._context |= contexts.FAIL_NEXT <NEW...
Make sure we are not trying to write an invalid character.
625941ead8ef3951e3243a05
def __init__(self, *args, **kwds): <NEW_LINE> <INDENT> if args or kwds: <NEW_LINE> <INDENT> super(SpeechSynthesis, self).__init__(*args, **kwds) <NEW_LINE> if self.header is None: <NEW_LINE> <INDENT> self.header = std_msgs.msg.Header() <NEW_LINE> <DEDENT> if self.phoneme is None: <NEW_LINE> <INDENT> self.phoneme = '' <...
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: header,phoneme,duration :param ar...
625941ea9c8ee82313fbbc3e
def CRNN2DVGG(X_shape, nb_classes): <NEW_LINE> <INDENT> nb_layers = 5 <NEW_LINE> nb_filters = [64, 128, 256, 512, 512] <NEW_LINE> kernel_size = (3, 3) <NEW_LINE> activation = 'elu' <NEW_LINE> pool_size = [(2, 2), (2, 2), (2, 2), (4, 1), (4, 1)] <NEW_LINE> input_shape = (X_shape[1], X_shape[2], X_shape[3]) <NEW_LINE> fr...
Based on VGG-16 Architecture
625941ea7d43ff24873a316b
def _parse_date(self, input): <NEW_LINE> <INDENT> return datetime.strptime(input, "%a, %d %b %Y %H:%M:%S +0000")
Turn a string date into a datetime object
625941eadd821e528d63b66d
def _build_graph(self, encoder_emb, context_multi, name_scope): <NEW_LINE> <INDENT> self.b_query_state = [] <NEW_LINE> self.b_answer_state = [] <NEW_LINE> self.b_state = [] <NEW_LINE> self.b_logits = [] <NEW_LINE> self.b_loss = [] <NEW_LINE> self.b_train_op = [] <NEW_LINE> for i, bucket in enumerate(self.buckets): <NEW...
构建图 :param encoder_emb: 一个 Multi-LSTM 单元 :param context_multi: 一个 Multi-LSTM 单元 :param name_scope
625941ea31939e2706e4d32a
def libvlc_media_get_state(p_md): <NEW_LINE> <INDENT> f = _Cfunctions.get('libvlc_media_get_state', None) or _Cfunction('libvlc_media_get_state', ((1,),), State, Media) <NEW_LINE> if not __debug__: <NEW_LINE> <INDENT> global libvlc_media_get_state <NEW_LINE> libvlc_media_get_state = f <NEW_LINE> <DEDENT> return ...
Get current state of media descriptor object. Possible media states are defined in libvlc_structures.c ( libvlc_NothingSpecial=0, libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused, libvlc_Stopped, libvlc_Ended, libvlc_Error). See libvlc_state_t. @param p_md: a media descriptor object. @return: state of me...
625941ea97e22403b379d463
def residu3(self, fit_param, free, const): <NEW_LINE> <INDENT> sumsquare = 0.0 <NEW_LINE> npt = 0 <NEW_LINE> param = self.calc_param3(fit_param, free, const) <NEW_LINE> for single in self.single_geometries.values(): <NEW_LINE> <INDENT> motor_pos = single.get_position() <NEW_LINE> single_param = self.trans_function(para...
Evaluate the cost function: :param fit_param: numpy array of float :param free: names of the free parameters, array of same size as fit_param :param const: dict with constant (non-fitted) parameters :return: cost function value
625941ea8c0ade5d55d3ee87
def force_B(self, t): <NEW_LINE> <INDENT> if self._cacheF is None: <NEW_LINE> <INDENT> res = self._worker(t) <NEW_LINE> self._cacheF = res <NEW_LINE> return -res <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> res = self._cacheF <NEW_LINE> self._cacheF = None <NEW_LINE> return res
Função que calcula a força sobre o objeto B no instante t
625941eab7558d58953c53d1
def make_instance(self, include_optional): <NEW_LINE> <INDENT> if include_optional : <NEW_LINE> <INDENT> return ListServicesResponse( count = 56, services = [ onepanel.core.api.models.service.Service( name = '0', url = '0', ) ], page = 56, pages = 56, total_count = 56 ) <NEW_LINE> <DEDENT> else : <NEW_LINE> <INDENT> re...
Test ListServicesResponse include_option is a boolean, when False only required params are included, when True both required and optional params are included
625941ea45492302aab5e790
def contains(self, string): <NEW_LINE> <INDENT> return self.root == string
Return True if this prefix tree contains the given string.
625941ea3617ad0b5ed683be
def is_protected_doc(exc, mimetype): <NEW_LINE> <INDENT> stack_trace = str(exc.stack_trace) <NEW_LINE> if not stack_trace: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if mimetype in mimetypes.PDF_TYPES: <NEW_LINE> <INDENT> return any(msg in stack_trace for msg in PROTECTED_PDF_MSGS) <NEW_LINE> <DEDENT> if mime...
Figure out whether conversion failed because we're dealing with a password protected document, based on the document's MIME type and the Java exception.
625941ea15baa723493c4441
def get_values(path): <NEW_LINE> <INDENT> ret = [] <NEW_LINE> for item in fg.fg.ls(path): <NEW_LINE> <INDENT> if item.name == 'value': <NEW_LINE> <INDENT> ret.append(item.value) <NEW_LINE> <DEDENT> <DEDENT> return ret
Returns <path>/value[] as a list.
625941ea7047854f462a18cc
def env_step(self, action): <NEW_LINE> <INDENT> next_state = list(self.s) <NEW_LINE> if action == 0: <NEW_LINE> <INDENT> next_state[1] -= 1 <NEW_LINE> <DEDENT> elif action == 1: <NEW_LINE> <INDENT> next_state[0] += 1 <NEW_LINE> <DEDENT> elif action == 2: <NEW_LINE> <INDENT> next_state[1] += 1 <NEW_LINE> <DEDENT> elif a...
Arguments: action - integer[up:0, right:1, down:2, left:3] Returns: reward - float, state - numpy array - terminal - boolean
625941ea9c8ee82313fbbc3f
def set_message(self, msg): <NEW_LINE> <INDENT> self.__message = msg <NEW_LINE> self.__message_ticks = 250
Set message and number of ticks the message will be shown. Number of ticks = 250. :param msg: Message that will be shown in the info bar.
625941ea379a373c97cfb00e
def rotate(self, matrix: List[List[int]]) -> None: <NEW_LINE> <INDENT> n = len(matrix) <NEW_LINE> nl = [[0 for i in range(n)] for j in range(n)] <NEW_LINE> for i in range(n): <NEW_LINE> <INDENT> for j in range(n): <NEW_LINE> <INDENT> nl[j][n - i - 1] = matrix[i][j] <NEW_LINE> <DEDENT> <DEDENT> matrix[:] = nl
Do not return anything, modify matrix in-place instead.
625941ea442bda511e8be8d9
def get_module_path(modfile): <NEW_LINE> <INDENT> return os.path.dirname(modfile)
Return the current module path, given __file__ To find out in which directory on the filesystem the currently executing code is located, the __file__ special is passed to get_module_path(). The path of the current module is returned.
625941eaff9c53063f47c6b9
def compile_test_program(target_config, verbose, mname, source=None, debug=None): <NEW_LINE> <INDENT> metadata = MODULE_METADATA[mname] <NEW_LINE> name = 'cfgtest_' + mname <NEW_LINE> name_pro = name + '.pro' <NEW_LINE> name_makefile = name + '.mk' <NEW_LINE> name_source = name + '.cpp' <NEW_LINE> if source is None: <N...
Compile the source of a Qt program and return the name of the executable or None if it couldn't be created. target_config is the target configuration. verbose is set if the output is to be displayed. mname is the name of the PyQt module being tested. source is the C++ source of the program. If it is None then the ...
625941ea796e427e537b0a92
def buildTree(self, inorder, postorder): <NEW_LINE> <INDENT> if len(inorder) == 1: <NEW_LINE> <INDENT> return TreeNode(inorder[0]) <NEW_LINE> <DEDENT> elif len(inorder) == 0: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> val = postorder[-1] <NEW_LINE> pos = inorder.index(val) <NEW_LINE> root = TreeNode(val) <NEW_...
:type inorder: List[int] :type postorder: List[int] :rtype: TreeNode
625941ea24f1403a9260102a
def element_to_extension_element(element): <NEW_LINE> <INDENT> exel = ExtensionElement(element.c_tag, element.c_namespace, text=element.text) <NEW_LINE> exel.attributes.update(element.extension_attributes) <NEW_LINE> exel.children.extend(element.extension_elements) <NEW_LINE> for xml_attribute, (member_name, typ, req) ...
Convert an element into a extension element :param element: The element instance :return: An extension element instance
625941ea046cf37aa974d20b
def test_random_lists(): <NEW_LINE> <INDENT> for _ in range(10): <NEW_LINE> <INDENT> lst = [random() for i in range(0, randint(10, 100))] <NEW_LINE> slst = ms(lst) <NEW_LINE> for i in range(len(slst) - 1): <NEW_LINE> <INDENT> assert slst[i] <= slst[i + 1]
Validate random lists.
625941ea4e4d5625662d4899
def benchmark_against_others(repo_root: pathlib.Path, overwrite: bool) -> None: <NEW_LINE> <INDENT> script_rel_paths = [ 'benchmarks/against_others/compare_invariant.py', 'benchmarks/against_others/compare_precondition.py', 'benchmarks/against_others/compare_postcondition.py' ] <NEW_LINE> if not overwrite: <NEW_LINE> <...
Run benchmars against other libraries and include them in the Readme.
625941ea82261d6c526ab96f
def tearDown(self): <NEW_LINE> <INDENT> self.switch.delete() <NEW_LINE> self.hangupcause.delete()
Delete created object
625941ea498bea3a759b9f76
@pytest.mark.parametrize("method", ["get", "delete", "put"]) <NEW_LINE> def test_get_delete_put_team_unauthorized(client, add_teams, method): <NEW_LINE> <INDENT> rv = getattr(client, method)("/api/teams/1/") <NEW_LINE> response = rv.get_json() <NEW_LINE> assert rv.status_code == HTTPStatus.UNAUTHORIZED <NEW_LINE> asser...
Test get, put and delete team with not logged in user.
625941ea26068e7796caf1af
def build_join(self, dict_data): <NEW_LINE> <INDENT> join = '' <NEW_LINE> if self.sql_constants.JOIN in dict_data and dict_data[self.sql_constants.JOIN]: <NEW_LINE> <INDENT> for join_item in dict_data[self.sql_constants.JOIN]: <NEW_LINE> <INDENT> join += ' left join %s on ( %s ) ' % ( join_item[self.sql_constants.TABLE...
构建join :param dict_data: :return:
625941ea57b8e32f52483966
def _get_line_energy(self, Xray_line, FWHM_MnKa=None): <NEW_LINE> <INDENT> units_name = self.axes_manager.signal_axes[0].units <NEW_LINE> element, line = utils_eds._get_element_and_line(Xray_line) <NEW_LINE> if FWHM_MnKa == 'auto': <NEW_LINE> <INDENT> if self.metadata.Signal.signal_type == 'EDS_SEM': <NEW_LINE> <INDENT...
Get the line energy and the energy resolution of a Xray line. The return values are in the same units than the signal axis Parameters ---------- Xray_line : strings Valid element X-ray lines e.g. Fe_Kb. FWHM_MnKa: {None, float, 'auto'} The energy resolution of the detector in eV if 'auto', used the one ...
625941ea38b623060ff0b2b5
def run(self): <NEW_LINE> <INDENT> p1 = Process(target=self.multiple_filter) <NEW_LINE> p2 = Process(target=self.multiple_validation) <NEW_LINE> p1.start() <NEW_LINE> p2.start() <NEW_LINE> p1.join() <NEW_LINE> p2.join()
启动程序
625941ea29b78933be1e5b6e
def get_ckpt_db_name(self, node_name, epoch): <NEW_LINE> <INDENT> for node, manager in self._node_managers: <NEW_LINE> <INDENT> if str(node) == node_name: <NEW_LINE> <INDENT> return manager._db_name(epoch)
Returns the DB name of the given node and the given epoch. The DB name is effectively the checkpoint path of the given node and the given epoch. Args: node_name: A string. The node name of interest. epoch: An integer. The epoch of the checkpoint. Returns: checkpoint_db_name: A string. The checkpoint path...
625941eae8904600ed9f23fd
def step(self, action): <NEW_LINE> <INDENT> state, reward = self.mdp.step(action) <NEW_LINE> obs_dist = self.O[action, self.mdp.current_state] <NEW_LINE> obs = sample_multinomial(obs_dist) <NEW_LINE> return obs, reward
Execute the given action. Returns new obs and reward.
625941ea0a50d4780f66735e
def getConfig(self): <NEW_LINE> <INDENT> config = self.testInit.getConfiguration() <NEW_LINE> self.testInit.generateWorkDir(config) <NEW_LINE> config.section_("CoreDatabase") <NEW_LINE> config.CoreDatabase.connectUrl = os.getenv("DATABASE") <NEW_LINE> config.CoreDatabase.socket = os.getenv("DBSOCK") <NEW_LINE> conf...
_getConfig_
625941ea7cff6e4e81117e4e
def sparsity(X, percent=True): <NEW_LINE> <INDENT> s = np.sum(np.isnan(X)) / X.size <NEW_LINE> if percent: <NEW_LINE> <INDENT> s *= 100. <NEW_LINE> <DEDENT> return s
Compute the sparsity (proportion of NaNs) in given nparray
625941ea004d5f362079a7f8
def save_im(im, name): <NEW_LINE> <INDENT> im = cv2.cvtColor(im, cv2.COLOR_RGB2BGR) <NEW_LINE> cv2.imwrite(name, im.astype(np.uint8))
Save an image.
625941eaa8ecb033257d3594
def action_confirm(self, cr, uid, ids, context=None): <NEW_LINE> <INDENT> super(stock_picking, self).action_confirm(cr, uid, ids, context=context) <NEW_LINE> move_obj = self.pool.get('stock.move') <NEW_LINE> if isinstance(ids, (int, long)): <NEW_LINE> <INDENT> ids = [ids] <NEW_LINE> <DEDENT> for pick in self.read(cr, u...
stock.picking: action confirm if INCOMING picking: confirm and check availability
625941eadc8b845886cb59ff
def __contains__(self, value): <NEW_LINE> <INDENT> current = self._head <NEW_LINE> while current is not None: <NEW_LINE> <INDENT> if current.item == value: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> current = current.next <NEW_LINE> <DEDENT> <DEDENT> return False
Checks existence of value in the Multiset
625941ea287bf620b61d3f29
def test_has_contents(): <NEW_LINE> <INDENT> obj = Loader().get_object_documentation("tests.fixtures.pkg1") <NEW_LINE> assert obj.has_contents() <NEW_LINE> obj = Loader().get_object_documentation("tests.fixtures.__init__") <NEW_LINE> assert not obj.children <NEW_LINE> assert obj.has_contents() <NEW_LINE> obj = Loader()...
Check if an object has contents.
625941ead6c5a10208144517
def back_to_family_reset(self, jnk_unused): <NEW_LINE> <INDENT> self.divisionswin.hide() <NEW_LINE> self.familyresetwin.show_all()
Goes back to family reset window, from the division edition one
625941ea3346ee7daa2b3238
def __init__(self, version, payload, service_sid, identity, sid=None): <NEW_LINE> <INDENT> super(UserBindingInstance, self).__init__(version) <NEW_LINE> self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'credential_sid': payload['credential_sid'], ...
Initialize the UserBindingInstance :returns: twilio.rest.notify.v1.service.user.user_binding.UserBindingInstance :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingInstance
625941eaab23a570cc25064f
def dump_symbol_table(st, s=""): <NEW_LINE> <INDENT> print('Symbol Table', s) <NEW_LINE> if len(st) <= 0: <NEW_LINE> <INDENT> print(' - (symbol table is empty)\n') <NEW_LINE> return <NEW_LINE> <DEDENT> max_sym_len = max([len(k) for k in st.keys()]) <NEW_LINE> for v in sorted(st): <NEW_LINE> <INDENT> print('- {0:{width}...
Print Symbol Table to screen
625941ea56ac1b37e626468e
def __init__(self, py_dict=None): <NEW_LINE> <INDENT> super(EntrySchema, self).__init__() <NEW_LINE> self.string = [str()]
Constructor to create EntrySchema object @param py_dict : python dictionary to construct this object
625941ea8a349b6b435e863b
def write(self, msg): <NEW_LINE> <INDENT> self.writer.write(msg.encode())
Send the message on the asyncio stream writer
625941ea01c39578d7e75304
def get_legend(self, **kwargs): <NEW_LINE> <INDENT> if self._legend and not self.hidelegend: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return self._legend(**self._pick_params(kwargs)) <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> return self._legend <NEW_LINE> <DEDENT> <DEDENT> return None
Return legend for current menu entry. :param dict kwargs: Optional menu entry parameters. :return: Legend for current menu entry. :rtype: str
625941ea3539df3088e2e814
def getIoUOfRectangles(x1, y1, r1, x2, y2, r2): <NEW_LINE> <INDENT> intersection = getIntersectionOfRectangles(x1, y1, r1, x2, y2, r2) <NEW_LINE> union = (2.0 * r1)**2.0 + (2.0 * r2)**2.0 - intersection <NEW_LINE> return intersection / union
Computes Intersection over Union of Rectangles Parameters ---------- x1: ndarray or tensor x coordinates of the first rectangle. y1: ndarray or tensor y coordinates of the first rectangle. r1: ndarray or tensor Half width of the first rectangle (just to be consistent with circle impl). x2: ndarray o...
625941ea63d6d428bbe449b9
def test_create_git_project(self): <NEW_LINE> <INDENT> self.assertFalse(os.path.isdir(self.git_dir)) <NEW_LINE> project = GitManager().create_git_project(self.project_dir) <NEW_LINE> self.assertTrue(os.path.isdir(self.git_dir)) <NEW_LINE> shutil.rmtree(self.project_dir)
Testing the creation of a project directory using git for version control. :return:
625941ea85dfad0860c3b325
def _ensure_listlike_indexer(self, key, axis=None): <NEW_LINE> <INDENT> column_axis = 1 <NEW_LINE> if self.ndim != 2: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if isinstance(key, tuple): <NEW_LINE> <INDENT> key = key[column_axis] <NEW_LINE> axis = column_axis <NEW_LINE> <DEDENT> if ( axis == column_axis and not is...
Ensure that a list-like of column labels are all present by adding them if they do not already exist. Parameters ---------- key : _LocIndexer key or list-like of column labels Target labels. axis : key axis if known
625941ea0a50d4780f66735f
def getPhenotypes(self, file_pheno=None, delim=","): <NEW_LINE> <INDENT> if file_pheno is None: <NEW_LINE> <INDENT> raise MissingInput('No phenotype file specified') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if file_type(file_pheno) is not "delim": <NEW_LINE> <INDENT> raise FormatError('Supplied phenotype file is n...
Reads [`N` x `P`] phenotype file; file ending must be either .txt or .csv Arguments: file_pheno (string): path to [(`N`+1) x (`P`+1)] phenotype file with: [`N`] sample IDs in the first column and [`P`] phenotype IDs in the first row delim (string): delimiter of phenotype file, o...
625941ea0a366e3fb873ece7
def featureTemplateSetup_nonlocal(self, nonlocalFeatures): <NEW_LINE> <INDENT> self.featureTemplates_nonlocal.append(nonlocalFeatures.ff_nonlocal_isPuncAndHasMoreThanOneLink) <NEW_LINE> self.featureTemplates_nonlocal.append(nonlocalFeatures.ff_nonlocal_sameWordLinks) <NEW_LINE> self.featureTemplates_nonlocal.append(non...
Incorporate the following combination-cost features into our model.
625941eabde94217f36832b5
def __init__(self, options = None, debug = False): <NEW_LINE> <INDENT> self._routers = {} <NEW_LINE> self.debug = debug <NEW_LINE> self._options = options or types.RouterOptions()
Ctor. :param options: Default router options. :type options: Instance of :class:`autobahn.wamp.types.RouterOptions`.
625941ea596a897236089f82
def create_lookup_tables(words): <NEW_LINE> <INDENT> words = words.split() <NEW_LINE> word_counts = Counter(words) <NEW_LINE> sorted_vocab = sorted(word_counts, key=word_counts.get, reverse=True) <NEW_LINE> int2word = {ii: word for ii, word in enumerate(sorted_vocab)} <NEW_LINE> word2int = {word: ii for ii, word in int...
Create lookup tables for vocabulary :param words: Input list of words :return: A tuple of dicts. The first dict....
625941ea76e4537e8c351b3f
def get_point(coords, lat_first): <NEW_LINE> <INDENT> if lat_first: <NEW_LINE> <INDENT> point = (coords[1], coords[0]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> point = (coords[0], coords[1]) <NEW_LINE> <DEDENT> return point
Converts GeoJSON coordinates into a point tuple
625941ea4c3428357757c7ee
def serialize(self, buff): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> _x = self.trajectory_name <NEW_LINE> length = len(_x) <NEW_LINE> if python3 or type(_x) == unicode: <NEW_LINE> <INDENT> _x = _x.encode('utf-8') <NEW_LINE> length = len(_x) <NEW_LINE> <DEDENT> buff.write(struct.pack('<I%ss'%length, length, _x)) <NEW...
serialize message into buffer :param buff: buffer, ``StringIO``
625941ea4527f215b584c91b
def run(self, max_its=1000, verbose=None): <NEW_LINE> <INDENT> temp_verbose = self.verbose <NEW_LINE> if verbose is not None: <NEW_LINE> <INDENT> self.verbose = verbose <NEW_LINE> <DEDENT> for it in range(max_its): <NEW_LINE> <INDENT> if self.verbose: print("Iteration: ", it) <NEW_LINE> proposed_smirks = copy.deepcopy(...
Reduce the SMIRKS decorators for a number of iterations Parameters ---------- max_its : int The specified number of iterations verbose : boolean will set the verboseness while running (if None, the current verbose variable will be used) Returns ---------- final_smirks : list of tuples list of final sm...
625941eaad47b63b2c50a447
def data_as_string(self): <NEW_LINE> <INDENT> return string_at(self.imageData, self.imageSize)
Converts the internal data array into a string without doing a memory copy.
625941eafff4ab517eb2f908
def test_file_import(self): <NEW_LINE> <INDENT> print(sys._getframe().f_code.co_name) <NEW_LINE> self.assertIsNotNone(pc.AirlineData (*pc.get_METAS_data(airline='VAL',file_path=self.file_path)))
Test file import
625941eafb3f5b602dac3b61
def main(): <NEW_LINE> <INDENT> data_reqs = DataRequest.objects.filter( source_id__name__in=['CMCC-CM2-HR4', 'CMCC-CM2-VHR4'], experiment_id__name='highresSST-present', table_id='Prim6hr', cmor_name='sfcWindmax' ) <NEW_LINE> fixes = [ FileFix.objects.get(name='WindSpeedStandardNameAdd'), ] <NEW_LINE> for data_req in da...
Main entry point
625941ea91af0d3eaac9bee6
def subdomainVisits(self, cpdomains): <NEW_LINE> <INDENT> self.dic.clear() <NEW_LINE> for x in range(len(cpdomains)): <NEW_LINE> <INDENT> S = Solution.partit(cpdomains[x], ' ') <NEW_LINE> Solution.add(S[2], S[0]) <NEW_LINE> <DEDENT> final_list = list() <NEW_LINE> for x, y in Solution.dic.items(): <NEW_LINE> <INDENT> ss...
:type cpdomains: List[str] :rtype: List[str]
625941ea091ae3566866741e
def test_identifier_unknown_type(self) -> None: <NEW_LINE> <INDENT> self.auth1.type = "foo" <NEW_LINE> with self.assertRaisesRegex(ValueError, r"^Unknown identifier type: foo$"): <NEW_LINE> <INDENT> self.auth1.identifier
Test that an identifier with an unknown type raises a ValueError.
625941ead164cc6175783218
def hasCycle(self, head): <NEW_LINE> <INDENT> slow = head <NEW_LINE> fast = head <NEW_LINE> while fast and slow: <NEW_LINE> <INDENT> fast = fast.next <NEW_LINE> if fast is slow: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if fast: <NEW_LINE> <INDENT> fast = fast.next <NEW_LINE> <DEDENT> slow = slow.next <NEW_LI...
:type head: ListNode :rtype: bool
625941ea30dc7b7665901e2a
def undo(self): <NEW_LINE> <INDENT> self.canvas.addItem(self.textItem) <NEW_LINE> self.canvas.canvasTextBoxes[self.textItem] = self.textItem
The undo action.
625941ea091ae3566866741f
def model_train(model, trainloader, validloader, optimizer, epochs, gpu=True): <NEW_LINE> <INDENT> steps = 0 <NEW_LINE> running_loss = 0 <NEW_LINE> print_every = 20 <NEW_LINE> device = torch.device("cpu") <NEW_LINE> if gpu: <NEW_LINE> <INDENT> device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") <NEW...
Trains a model on a dataset, printing incremental gains for training and validation data, returns last captured train_loss, valid_loss, valid_accuracy.
625941ea6aa9bd52df037270
@task <NEW_LINE> def gh_pages_clean(): <NEW_LINE> <INDENT> _adjust_options() <NEW_LINE> remote_name = options.gh_pages.remote_name <NEW_LINE> repo = _get_repo(os.getcwd()) <NEW_LINE> dry('Update/reset "%s" submodule' % options.gh_pages.root, repo.submodules[options.gh_pages.root].update) <NEW_LINE> gh_repo = Git(option...
Clean your documentation. Update the submodule (every changes not committed and pushed will be lost), pull any changes and remove any file in options.gh_pages.docroot.
625941eaa8370b7717052d66
def run_migrations_online(): <NEW_LINE> <INDENT> connectable = engine_from_config( config.get_section(config.config_ini_section), prefix='sqlalchemy.', poolclass=pool.NullPool) <NEW_LINE> with connectable.connect() as connection: <NEW_LINE> <INDENT> context.configure( connection=connection, target_metadata=target_metad...
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context.
625941eabf627c535bc13698
def handle_analysis_feedback(self): <NEW_LINE> <INDENT> assert ( wx.IsMainThread() ), "PipelineController.handle_analysis_feedback() must be called from main thread!" <NEW_LINE> if self.interaction_pending: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> pri_func_args = ( self.interaction_reques...
Process any pending exception or interaction requests from the pipeline. This function guards against multiple modal dialogs being opened, which can overwhelm the user and cause UI hangs.
625941eaa219f33f34628e2b
def create_app(config: dict = None) -> Flask: <NEW_LINE> <INDENT> app = Flask(__name__) <NEW_LINE> app.config.setdefault("FREEZER_DESTINATION", os.path.join(os.getcwd(), "frozen")) <NEW_LINE> app.config.from_pyfile(os.path.join(os.getcwd(), "config.py")) <NEW_LINE> if config is not None: <NEW_LINE> <INDENT> app.config....
Idiomatic Flask way allowing to create different applications. This allows for creating more app objects, e.g., for unit testing or some special deployments. :return: configured Flask app
625941ea9b70327d1c4e12a0
def get_or_none(model, action, *args, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if action == 'get': <NEW_LINE> <INDENT> return model.objects.get(*args, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return model.objects.filter(*args, **kwargs).order_by('-id') <NEW_LINE> <DEDENT> <DEDENT> except m...
Service to abstract the get and filter method call on model objects, and handle DoesNotExist error by returning None instead
625941ead4950a0f3b08c811
def _flake(): <NEW_LINE> <INDENT> orig_dir = os.getcwd() <NEW_LINE> import_dir, dev = _get_import_dir() <NEW_LINE> os.chdir(op.join(import_dir, '..')) <NEW_LINE> if dev: <NEW_LINE> <INDENT> sys.argv[1:] = ['vispy', 'examples', 'make'] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> sys.argv[1:] = [op.basename(import_dir)...
Test flake8
625941ea796e427e537b0a93
def save_edit(self): <NEW_LINE> <INDENT> if check_is_empty(self.amount_field): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> payment_date = unicode(self.payment_date_field.text()) <NEW_LINE> libelle = unicode(self.libelle_field.toPlainText()) <NEW_LINE> amount = int(self.amount_field.text().replace(" ", "")) <NEW_LINE...
add operation
625941eaa05bb46b383ecce6
def _assert_splits_match(nested_splits_lists): <NEW_LINE> <INDENT> error_msg = 'Inputs must have identical ragged splits' <NEW_LINE> for splits_list in nested_splits_lists: <NEW_LINE> <INDENT> if len(splits_list) != len(nested_splits_lists[0]): <NEW_LINE> <INDENT> raise ValueError(error_msg) <NEW_LINE> <DEDENT> <DEDENT...
Checks that the given splits lists are identical. Performs static tests to ensure that the given splits lists are identical, and returns a list of control dependency op tensors that check that they are fully identical. Args: nested_splits_lists: A list of nested_splits_lists, where each split_list is a list of ...
625941ead53ae8145f87a72f
def myticks(*args,**kw): <NEW_LINE> <INDENT> if len(args) > 2: <NEW_LINE> <INDENT> raise TypeError('Illegal number of arguments to myticks') <NEW_LINE> <DEDENT> ax = kw.pop('axes',None) <NEW_LINE> if ax is None: <NEW_LINE> <INDENT> ax = gca() <NEW_LINE> <DEDENT> locs,labels = _mticks(ax.yaxis,*args,**kw) <NEW_LINE> dra...
myticks(*args,**kw) Get or set the current y-axis tick locations and labels locs, labels = myticks() myticks(arange(6)) myticks(arange(3),['Tom','Dick','Harry']) Labels can be specified with a format string: myticks(linspace(0,360,5),'{:.2e}°') Labels can be specified with a callable: myticks(linspace(0.0,1.0,5)...
625941ea2eb69b55b151cd7f
def notify_usage_exists(context, instance_ref, current_period=False, ignore_missing_network_data=True, system_metadata=None, extra_usage_info=None): <NEW_LINE> <INDENT> admin_context = nova.context.get_admin_context(read_deleted='yes') <NEW_LINE> begin, end = utils.last_completed_audit_period() <NEW_LINE> bw = {} <NEW_...
Generates 'exists' notification for an instance for usage auditing purposes. :param current_period: if True, this will generate a usage for the current usage period; if False, this will generate a usage for the previous audit period. :param ignore_missing_network_data: if True, log any exceptions generated ...
625941ea1f037a2d8b9466c6
def display_masked_data_points(self, i): <NEW_LINE> <INDENT> if i%1 == 0: <NEW_LINE> <INDENT> Image.fromarray(self.masked_data).show()
Show the masked data points in an image*. *This is done for the image segmentation. For different kind of problems, different visualization techniques may be implemented. :param i: iteration parameter
625941ea7b180e01f3dc4cbc
def set_penalty_term(self, name, penalty_term): <NEW_LINE> <INDENT> self._penalty_terms[name] = penalty_term <NEW_LINE> self._penalty_terms_set = True
Set the value of a named penlty term Args: name (string): Name of penalty term to set penalty_term (dict): Specify "parameter_value" and "sigma" values in dict.
625941ea3eb6a72ae02ec9b3
def __init__(self, environment, master_host, master_port): <NEW_LINE> <INDENT> super().__init__(environment) <NEW_LINE> self.worker_state = STATE_INIT <NEW_LINE> self.client_id = socket.gethostname() + "_" + uuid4().hex <NEW_LINE> self.master_host = master_host <NEW_LINE> self.master_port = master_port <NEW_LINE> self....
:param environment: Environment instance :param master_host: Host/IP to use for connection to the master :param master_port: Port to use for connecting to the master
625941ead10714528d6001b2
def equal_type(equality_operator: EqualityOperator) -> EqualityOperator: <NEW_LINE> <INDENT> @wraps(equality_operator) <NEW_LINE> def equality_operator_with_equal_type(self: Any, other: Any) -> bool: <NEW_LINE> <INDENT> if not isinstance(other, self.__class__): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> retur...
Return an equality operator which first checks if the other object has the same type.
625941ea293b9510aa2c375a
def test_partial_settings(self): <NEW_LINE> <INDENT> d = self.s.get_settings() <NEW_LINE> del d['baudrate'] <NEW_LINE> del d['bytesize'] <NEW_LINE> self.s.apply_settings(d) <NEW_LINE> for setting in d: <NEW_LINE> <INDENT> self.failUnlessEqual(getattr(self.s, setting), d[setting])
partial settings dictionaries are also accepted
625941eabe7bc26dc91cdac0
@bp.route('/user/', methods=['PUT']) <NEW_LINE> @jwt_required <NEW_LINE> def update_info(): <NEW_LINE> <INDENT> current_user = get_jwt_identity() <NEW_LINE> json = request.get_json() <NEW_LINE> user = User.query.filter_by(username=current_user).first() <NEW_LINE> check_json(json, ['current_password']) <NEW_LINE> if not...
Allow user to update personal info: username, email, and password Example input json: { "username": "admin1", "current_password": "Password0", "email": "test@test.com", "password": "Password1234" } Will only update provided fields. "current_password" is required. Raises: 400 if new password forma...
625941ea5510c4643540f8a1
def __init__( self, *, level: Optional[Union[str, "LogLevel"]] = None, **kwargs ): <NEW_LINE> <INDENT> super(FileSystemApplicationLogsConfig, self).__init__(**kwargs) <NEW_LINE> self.level = level
:keyword level: Log level. Possible values include: "Off", "Verbose", "Information", "Warning", "Error". :paramtype level: str or ~azure.mgmt.web.v2020_09_01.models.LogLevel
625941ead268445f265b5338
def __init__(self, ocsp_object=None): <NEW_LINE> <INDENT> self.raw = ocsp_object <NEW_LINE> self.response = getattr(ocsp_object, 'response_data') <NEW_LINE> self.tbsresponse = self.response['responses'][0]
Initialise an `asn1crypto.ocsp.OCSPResponse` object in self._response. Don't try to make this an extension of `asn1crypto.ocsp.OCSPResponse` because it will complain about missing arguments.
625941ea009cb60464c63877