code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def register_component(server, super_type, attrs): <NEW_LINE> <INDENT> name = str(attrs['name']) <NEW_LINE> if server.components.has_key(name): <NEW_LINE> <INDENT> raise SAXException("Attempted to add %s component with non-unique name: \"%s\"" % (super_type, name)) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> mod = __i...
Reads a component described by the content of the given XML element attributes object and stores it in the given server.components.
625941d960cbc95b062c67ed
def get_projects(self, source=None): <NEW_LINE> <INDENT> with PoolConnection(self.conn_pool) as cur: <NEW_LINE> <INDENT> if source: <NEW_LINE> <INDENT> cur.execute("SELECT uuid FROM projects WHERE source_id=%s;", (source,)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> cur.execute("SELECT uuid FROM projects;") <NEW_LIN...
Return an iterable of project id strings. :param source: Optional source filter.
625941d9ff9c53063f47c49c
def to_numpy(self, dtype=None, copy=False, na_value=lib.no_default): <NEW_LINE> <INDENT> result = np.asarray(self, dtype=dtype) <NEW_LINE> if copy or na_value is not lib.no_default: <NEW_LINE> <INDENT> result = result.copy() <NEW_LINE> <DEDENT> if na_value is not lib.no_default: <NEW_LINE> <INDENT> result[self.isna()] ...
Convert to a NumPy ndarray. .. versionadded:: 1.0.0 This is similar to :meth:`numpy.asarray`, but may provide additional control over how the conversion is done. Parameters ---------- dtype : str or numpy.dtype, optional The dtype to pass to :meth:`numpy.asarray`. copy : bool, default False Whether to ensure...
625941d9097d151d1a223101
def clipPath(self, **attrs:Any) -> 'ClipPath': <NEW_LINE> <INDENT> return self.child(ClipPath, **attrs)
Create a child `clipPath` element.
625941d9ad47b63b2c50a228
def base_model(): <NEW_LINE> <INDENT> input_ras = Input(shape=(NUM_OP, NUM_CP), name='ra_input') <NEW_LINE> input_dps = Input(shape=(NUM_DP,), name='da_input') <NEW_LINE> first_layer = input_ras <NEW_LINE> repeat = 2 <NEW_LINE> next_layer = first_layer <NEW_LINE> for i in range(repeat): <NEW_LINE> <INDENT> next_layer =...
TODO: Add Query Representation layer using hierarchical RNNs/CNNs. :return:
625941d93346ee7daa2b3017
def custom_cutout(imgs, n_holes, length): <NEW_LINE> <INDENT> items = imgs.size(0) <NEW_LINE> channels = imgs.size(1) <NEW_LINE> h = imgs.size(2) <NEW_LINE> w = imgs.size(3) <NEW_LINE> patch_length = int(length * w) <NEW_LINE> margin = int(0.15 * w) <NEW_LINE> mask = np.ones((items, h, w), np.float32) <NEW_LINE> for cu...
Args: img (Tensor): Tensor image of size (B, C, H, W). Returns: Tensor: Image with n_holes of dimension length x length cut out of it.
625941d9851cf427c661a7b6
def lp_heuristic(V: np.ndarray, k: int, niter=100): <NEW_LINE> <INDENT> M = _get_upperbound(V) <NEW_LINE> Z = _label_group_milp(V, M, k) <NEW_LINE> rng_list = [np.random.RandomState(i) for i in range(niter)] <NEW_LINE> with Parallel(n_jobs=-1) as p: <NEW_LINE> <INDENT> res = p(delayed(_run_heuristic)(V, Z, rng) for rng...
Runs the LP heuristic and returns a final label map
625941d9d18da76e23532782
def stop(self): <NEW_LINE> <INDENT> self.step = -1 <NEW_LINE> self.status = 'idle' <NEW_LINE> self.message = '' <NEW_LINE> self.options = [] <NEW_LINE> self.time = ''
Stop running the recipe. TODO: figure out how to stop any running celery tasks :return: None
625941d99b70327d1c4e107f
def vjp(fun, *primals, **kwargs): <NEW_LINE> <INDENT> has_aux = kwargs.pop('has_aux', False) <NEW_LINE> assert not kwargs <NEW_LINE> if not isinstance(fun, lu.WrappedFun): <NEW_LINE> <INDENT> fun = lu.wrap_init(fun) <NEW_LINE> <DEDENT> primals_flat, in_trees = unzip2(map(pytree_to_jaxtupletree, primals)) <NEW_LINE> _ch...
Compute a (reverse-mode) vector-Jacobian product of `fun`. `grad` is implemented as a special case of `vjp`. Args: fun: Function to be differentiated. Its arguments should be arrays, scalars, or standard Python containers of arrays or scalars. It should return an array, scalar, or standard Python container ...
625941d9c4546d3d9de72cdf
def cname(self, fully_qualified=False, name_buffer=None): <NEW_LINE> <INDENT> if name_buffer is not None and id(self) in name_buffer: <NEW_LINE> <INDENT> return name_buffer[id(self)] <NEW_LINE> <DEDENT> c = self.parent_component() <NEW_LINE> if c is self: <NEW_LINE> <INDENT> return super(ComponentData, self).cname(full...
Return a string with the component name and index
625941d94f6381625f114ce5
def test_read_fileobj(tmpdir): <NEW_LINE> <INDENT> test_file = tmpdir.join('test.parquet') <NEW_LINE> t1 = Table() <NEW_LINE> t1.add_column(Column(name='a', data=[1, 2, 3])) <NEW_LINE> t1.write(test_file) <NEW_LINE> import io <NEW_LINE> with io.FileIO(test_file, mode='r') as input_file: <NEW_LINE> <INDENT> t2 = Table.r...
Test reading a file object.
625941d9bf627c535bc13479
def gen_code(self, file_handler): <NEW_LINE> <INDENT> self._gen_func_declaration(file_handler) <NEW_LINE> file_handler.tab() <NEW_LINE> final_var_name = self._gen_code_expr(self.expr, file_handler) <NEW_LINE> file_handler.untab() <NEW_LINE> self._gen_return_code(final_var_name, file_handler)
Generates code for a function to evaluate the input expression Args: file_handler : an instance of FileCodeWriter that handles writing generated code to a file.
625941d96fb2d068a760f34a
def compute_Z_level_sets_for_gradient_image(self): <NEW_LINE> <INDENT> gradient_image_as_array = self.gradient_image_as_array <NEW_LINE> height,width = gradient_image_as_array.shape <NEW_LINE> decimation_factor = self.level_decimation_factor <NEW_LINE> self.max_grad_level = int(self.max_grad_level / decimation_factor )...
For any value of n between 0 and 255, both ends inclusive, a pixel is in the set Z_n if the gradient value at that pixel is less than or equal to n. Note that the gradient values are normalized to be between 0 and 255.
625941d9097d151d1a223102
def check(self, cfg, path, peek_blocks): <NEW_LINE> <INDENT> raise NotImplementedError()
:param angr.analyses.CFGAccurate cfg: An instance of CFGAccurate. :param angr.Path path: The path to check. :param int peek_blocks: Number of blocks to peek ahead from the current point. :return: True if we can determine that this condition is definitely satisfiable if the path is tak...
625941d98e71fb1e9831da52
def files(root): <NEW_LINE> <INDENT> import os <NEW_LINE> for cur_root, dirs, files in os.walk(root, topdown=False): <NEW_LINE> <INDENT> for name in files: <NEW_LINE> <INDENT> yield os.path.join(cur_root, name)
生成器 返回根目录root下的所有文件的文件名,忽视目录结构 :param root: 根目录 :return:
625941d9ab23a570cc25042e
def _mount_iso(isofile, mnt_point): <NEW_LINE> <INDENT> MKMNT = False <NEW_LINE> if not os.path.exists(mnt_point): <NEW_LINE> <INDENT> MKMNT = True <NEW_LINE> <DEDENT> return __salt__['mount.mount'](mnt_point, isofile, mkmnt=MKMNT, fstype='iso9660', opts='loop')
SaltStack migration - mount ISO isofile : str name of ISO file mnt_point : str path of mount point
625941d9e1aae11d1e749f63
def neutron_to_osvif_vif(vif_plugin, neutron_port, subnets): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> mgr = _VIF_MANAGERS[vif_plugin] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> mgr = stv_driver.DriverManager(namespace=_VIF_TRANSLATOR_NAMESPACE, name=vif_plugin, invoke_on_load=False) <NEW_LINE> _VIF_MA...
Converts Neutron port to os-vif VIF object. :param vif_plugin: name of the os-vif plugin to use :param neutron_port: dict containing port information as returned by neutron client :param subnets: subnet mapping as returned by PodSubnetsDriver.get_subnets :return: os-vif VIF object
625941d93539df3088e2e5f4
def resource(name): <NEW_LINE> <INDENT> def wrapper(klass): <NEW_LINE> <INDENT> return add_resource(klass, name) <NEW_LINE> <DEDENT> return wrapper
Class decorator to register a resource. :param name: resource name
625941d90c0af96317bb8492
def process_item(self, item): <NEW_LINE> <INDENT> for products in self.process.process(item): <NEW_LINE> <INDENT> for oi, oname in enumerate(self.outputnames): <NEW_LINE> <INDENT> station = self.inputname_to_station[oname] <NEW_LINE> self.queue.put((station, products[oi])) <NEW_LINE> <DEDENT> <DEDENT> self.queue.task_d...
The method to run to process an item. :param item: The object to process.
625941d97047854f462a16b1
def flags(self, rev): <NEW_LINE> <INDENT> if rev in self.filteredrevs: <NEW_LINE> <INDENT> raise error.FilteredIndexError(rev) <NEW_LINE> <DEDENT> return super(changelog, self).flags(rev)
filtered version of revlog.flags
625941d991f36d47f21ac79e
def __calc_time(self, seconds): <NEW_LINE> <INDENT> hours = 0 <NEW_LINE> minutes = 0 <NEW_LINE> if seconds < 60: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> elif seconds/60 >= 1 and seconds/3600 < 1: <NEW_LINE> <INDENT> minutes = math.floor(seconds/60 ) <NEW_LINE> seconds = seconds - minutes*60 <NEW_LINE> <DEDENT> els...
Transfer unit from seconds to hours、minutes and seconds. Args: ----- seconds: Input elpased seconds time.
625941d9adb09d7d5db6ca38
def kthSmallest(self, matrix, k): <NEW_LINE> <INDENT> l = [] <NEW_LINE> for i in matrix: <NEW_LINE> <INDENT> l += i <NEW_LINE> <DEDENT> return sorted(l)[k - 1]
:type matrix: List[List[int]] :type k: int :rtype: int
625941da851cf427c661a7b7
def __init__(self): <NEW_LINE> <INDENT> SloaneSequence.__init__(self, offset=0)
Motzkin numbers: number of ways of drawing any number of nonintersecting chords among `n` points on a circle. INPUT: - ``n`` - non negative integer OUTPUT: - ``integer`` - function value EXAMPLES:: sage: a = sloane.A001006;a Motzkin numbers: number of ways of drawing any number of nonintersecting ch...
625941da82261d6c526ab74c
def plot(self, zid, band1, band2, axis, **args): <NEW_LINE> <INDENT> mb1 = self.get_magnitude(zid, band1) <NEW_LINE> mb2 = self.get_magnitude(zid, band2) <NEW_LINE> return axis.plot(mb2, mb1 - mb2, '.-', **args)
plot the color-magnitude relation :param zid: redshift id :param band1: blue band :param band2: red band :param axis: axis to plot :param args: parameters passed to plot
625941da5510c4643540f688
def plot_J_J_est(J, J_est_EP, J_est_lasso, show_plot): <NEW_LINE> <INDENT> title = 'J_vs_J_est' <NEW_LINE> if list(J_est_lasso) and list(J_est_EP): <NEW_LINE> <INDENT> f, axarr = plt.subplots(2, sharex=True) <NEW_LINE> axarr[0].plot([J.min(), J.max()], [J.min(), J.max()], 'k') <NEW_LINE> axarr[0].plot(J.flatten(), J_es...
This functions plots a scatter plot of the infered couplings (J_est) versus the real coupling (J). If both J_est_EP and J_est_lasso are supplied then 2 subplots will be plotted. :param J: The real coupling :param J_est_EP: couplings infered by EP :param J_est_lasso: couplings infered by LASSO :param show_plot: if True...
625941da6e29344779a628ba
def crps_gmm(alpha, sigma2, mu, t): <NEW_LINE> <INDENT> crps = 0 <NEW_LINE> for m in range(len(alpha)): <NEW_LINE> <INDENT> crps += alpha[m]*_A(t-mu[m], sigma2[m]) <NEW_LINE> for n in range(len(alpha)): <NEW_LINE> <INDENT> crps -= 0.5*alpha[m]*alpha[n]*_A(mu[m]-mu[n], sigma2[m]+sigma2[n]) <NEW_LINE> <DEDENT> <DEDENT> r...
Evaluate the Continuous Ranked Probability Score (CRPS) for the given mixture of Gaussians. The CRPS is a strictly proper scoring rule [1]. Analytic formulas for a GMM are given in [2]. References: [1] Tilmann Gneiting and Adrian E. Raftery (2007): Strictly Proper Scoring Rules, Prediction, and Estimation, Journal o...
625941da7cff6e4e81117c2f
def initialize_content(self): <NEW_LINE> <INDENT> return NotImplemented
Declare the validators and event connections for the widgets loaded through the .ui file.
625941da63d6d428bbe4479a
def findRelativeRanks(nums): <NEW_LINE> <INDENT> sort = sorted(nums)[::-1] <NEW_LINE> res = [0 for i in range(len(nums))] <NEW_LINE> for pos, num in enumerate(sort): <NEW_LINE> <INDENT> k = nums.index(num) <NEW_LINE> if pos == 0: <NEW_LINE> <INDENT> res[k] = 'Gold Medal' <NEW_LINE> <DEDENT> elif pos == 1: <NEW_LINE> <I...
:type nums: List[int] :rtype: List[str]
625941da10dbd63aa1bd2e4c
def setDetune(self, x): <NEW_LINE> <INDENT> pyoArgsAssert(self, "O", x) <NEW_LINE> self._detune = x <NEW_LINE> x, lmax = convertArgsToLists(x) <NEW_LINE> [obj.setDetune(wrap(x, i)) for i, obj in enumerate(self._base_objs)]
Replace the `detune` attribute. :Args: x: float or PyoObject new `detune` attribute.
625941da97e22403b379d245
def size(dictionary): <NEW_LINE> <INDENT> return len(dictionary)
Returns the number of words in the English `dictionary`.
625941dadd821e528d63b451
def test_full_migration_flow_with_stopped_service(self): <NEW_LINE> <INDENT> self.full_migration_flow("stop")
Tests full service migration flow with stopped service.
625941da4d74a7450ccd446e
def test_basic_monitor_json_to_terraform(self): <NEW_LINE> <INDENT> basic_monitor_exported_dict = { "name": "Basic Datadog Metric Count: 2", "type": "query alert", "query": "some query", "message": "Some Message about how to\n\n handle it.", "tags": [ "tag:1", "tag:2" ], "options": { "notify_audit": False, "locked": Tr...
Test to ensure we can take a simple monitor from json to terraform.
625941dadd821e528d63b452
def __init__(self, Tolerance, Max_Iterations, dim, alpha): <NEW_LINE> <INDENT> self.Tolerance = Tolerance <NEW_LINE> self.Max_Iterations = Max_Iterations <NEW_LINE> self.dim = dim <NEW_LINE> self.alpha = alpha
@topic: Declare the initial parameters. @parameters: 1. Tolerance: tolerance used as your stopping condition; 2. Max_Iterations: maximum iterations that the program may run; 3. dim: first "dim" eigenvectors to project datapoints in the "dim"-dimensional subspace. 4. alpha: a rate between [0,1] that frac...
625941da56b00c62f0f14905
def test_Debugger_user_call_started(): <NEW_LINE> <INDENT> mock_socket = mock.MagicMock() <NEW_LINE> db = mu.debugger.runner.Debugger(mock_socket, 'localhost', 9999) <NEW_LINE> db.stop_here = mock.MagicMock(return_value=True) <NEW_LINE> db.output = mock.MagicMock() <NEW_LINE> db.interact = mock.MagicMock() <NEW_LINE> m...
Assuming the runner has started, ensure the passed in frame and argument list are output and an interact is called.
625941da796e427e537b0871
def randomize_ROI(rawdata, mask=None): <NEW_LINE> <INDENT> masklabel = np.unique(mask[mask!=0]) <NEW_LINE> rawshape = rawdata.shape <NEW_LINE> if mask is None: <NEW_LINE> <INDENT> rawdata_flatten = rawdata.flatten() <NEW_LINE> rddata_flatten = np.random.choice(rawdata_flatten, len(rawdata_flatten), replace=False) <NEW_...
Randomize the averaged data in ROI that defined by the mask if mask is None, randomized original data in global brain (but not cross the ROIs) Parameters: ------------ rawdata: original activation data mask: mask to define ROIs Return: ------- rand_data: randomized data
625941da82261d6c526ab74d
def _to_tfexample_coco_raw(image_id, image_data, label_data, height, width, num_instances, gt_boxes, masks): <NEW_LINE> <INDENT> return tf.train.Example(features=tf.train.Features(feature={ 'image/img_id': _int64_feature(image_id), 'image/encoded': _bytes_feature(image_data), 'image/height': _int64_feature(height), 'im...
just write a raw input
625941da8a43f66fc4b5430d
def remove_element_attribute(self, source, name, xpath='.'): <NEW_LINE> <INDENT> source = self.get_element(source) <NEW_LINE> attrib = self.get_element(source, xpath).attrib <NEW_LINE> if name in attrib: <NEW_LINE> <INDENT> attrib.pop(name) <NEW_LINE> <DEDENT> return source
Removes attribute ``name`` from the specified element. The element whose attribute to remove is specified using ``source`` and ``xpath``. They have exactly the same semantics as with `Get Element` keyword. The resulting XML structure is returned, and if the ``source`` is an already parsed XML structure, it is also mod...
625941dae8904600ed9f21da
def make_client(instance): <NEW_LINE> <INDENT> neutron_client = utils.get_client_class( API_NAME, instance._api_version[API_NAME], API_VERSIONS) <NEW_LINE> LOG.debug('Instantiating neutron client: %s', neutron_client) <NEW_LINE> client = neutron_client(session=instance.session, region_name=instance.region_name, endpoin...
Returns an neutron client.
625941da4428ac0f6e5baa9e
def test_ins_expansion2(): <NEW_LINE> <INDENT> ref_seq, vcf = load_data() <NEW_LINE> v = vcf[0]['v'][1][1] <NEW_LINE> samp_pos = 9 <NEW_LINE> ref_pos = 9 <NEW_LINE> ref_start_pos = 1 <NEW_LINE> nodes, n_samp_pos, n_ref_pos = rgen.insertion(ref_seq, samp_pos, ref_pos, v, ref_start_pos) <NEW_LINE> assert len(nodes) == 1,...
Read gen: INS expansion: No M section
625941dad8ef3951e32437e8
def get_interfaces_ip(self) -> Dict[str, models.InterfacesIPDict]: <NEW_LINE> <INDENT> raise NotImplementedError
Returns all configured IP addresses on all interfaces as a dictionary of dictionaries. Keys of the main dictionary represent the name of the interface. Values of the main dictionary represent are dictionaries that may consist of two keys 'ipv4' and 'ipv6' (one, both or none) which are themselves dictionaries with the I...
625941da63b5f9789fde7390
def main(args=None): <NEW_LINE> <INDENT> werkzeugLogger = logging.getLogger('werkzeug') <NEW_LINE> werkzeugLogger.setLevel(logging.INFO) <NEW_LINE> logger = logging.getLogger('ShacShifter') <NEW_LINE> logger.setLevel(logging.DEBUG) <NEW_LINE> formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(mes...
The main method of ShacShifter.
625941da7b180e01f3dc4aa3
def getSeriesSOS200(sos, station_number, offering_number, property_number, user_starting_time, user_ending_time, **kwargs): <NEW_LINE> <INDENT> dates = [] <NEW_LINE> values = [] <NEW_LINE> unit = '' <NEW_LINE> WGS84bbox_set=set(WGS84conversion(off) for off in sos.offerings) <NEW_LINE> WGS84bbox_list=list(WGS84bbox_set)...
Launch GetObservation request using OWSLib library, and retrieve useful data from the response. arguments: >>> sos: class 'owslib.swe.observation.sos200.SensorObservationService_2_0_0' object. >>> station_number: index (int) number of the station in WGS84bbox_list. >>> offering_n...
625941da31939e2706e4d111
def test_taint_union_register_register(self): <NEW_LINE> <INDENT> Triton = TritonContext() <NEW_LINE> Triton.setArchitecture(ARCH.X86_64) <NEW_LINE> self.assertFalse(Triton.isRegisterTainted(Triton.registers.rax)) <NEW_LINE> Triton.taintRegister(Triton.registers.rax) <NEW_LINE> self.assertTrue(Triton.isRegisterTainted(...
Check tainting union register U register.
625941da8da39b475bd65220
def residual_capacity(i, p, capac, flows, tails): <NEW_LINE> <INDENT> if tails[np.int64(i)] == np.int64(p): <NEW_LINE> <INDENT> return capac[np.int64(i)] - flows[np.int64(i)] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return flows[np.int64(i)]
Return the residual capacity of an edge i in the direction away from its endpoint p.
625941da8c0ade5d55d3ec67
def test_sqladvisor(self): <NEW_LINE> <INDENT> data = {} <NEW_LINE> r = self.client.get(f'/sqladvisor/', data=data) <NEW_LINE> self.assertEqual(r.status_code, 200)
测试sqladvisor页面
625941da004d5f362079a5dc
def is_allocated(self, reference, strict=False): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> reference = self.find_exchange(reference, reference=True) <NEW_LINE> <DEDENT> except NoExchangeFound: <NEW_LINE> <INDENT> print('Not a reference exchange.') <NEW_LINE> return False <NEW_LINE> <DEDENT> if self.alloc_qty is not ...
Tests whether a process's exchanges contain allocation factors for a given reference. :param reference: :param strict: [False] if True, raise an exception if some (but not all) exchanges are missing allocations. :return: True - allocations exist; False - no allocations exist; raise MissingFactor - some allocations exis...
625941dabde94217f3683099
def stable(self): <NEW_LINE> <INDENT> if self.stable_if_link_pair() == 1 and self.stable_if_non_link() == 1: <NEW_LINE> <INDENT> print("This network is Stable") <NEW_LINE> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print("This network is not Stable") <NEW_LINE> return False
When the network has the two attributes linkpair(i,j)=1 and nonlinkpair(i,j) at the same time, it is pairwise stable, otherwise it's unstable :return: boolean
625941daa219f33f34628c11
def update(self, room, robots): <NEW_LINE> <INDENT> for i in range(self.width): <NEW_LINE> <INDENT> for j in range(self.height): <NEW_LINE> <INDENT> if room.isTileCleaned(i, j): <NEW_LINE> <INDENT> self.w.delete(self.tiles[(i, j)]) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> if self.robots: <NEW_LINE> <INDENT> for robot in s...
Redraws the visualization with the specified room and robot state.
625941da0fa83653e4657264
def filename_from_dates(date): <NEW_LINE> <INDENT> y = str(date.year)[2:] <NEW_LINE> if len(str(date.month)) < 2: <NEW_LINE> <INDENT> m = '0'+str(date.month) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> m = str(date.month) <NEW_LINE> <DEDENT> if len(str(date.day)) < 2: <NEW_LINE> <INDENT> d = '0'+str(date.day) <NEW_LI...
Create a file structure 170238_2145 form from a datetime objects :param: date datetime object :return filestring: input string. Format assumed as: 20170120_0117
625941da507cdc57c6306f8a
def rmsprop_step(optimizer, detach_dp=True): <NEW_LINE> <INDENT> assert (isinstance(optimizer, optim.RMSprop)) <NEW_LINE> d_ps = [] <NEW_LINE> for group in optimizer.param_groups: <NEW_LINE> <INDENT> for p in group['params']: <NEW_LINE> <INDENT> if p.grad is None: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> if det...
Performs a single optimization step using the RMSprop optimizer. The code has been copied from: https://git.io/fjurp Note, this function does not change the inner state of the given optimizer object. Note, gradients are cloned and detached by default. Args: optimizer: An instance of class :class:`torch.opti...
625941dad4950a0f3b08c5f7
@set_module('numpy') <NEW_LINE> def full(shape, fill_value, dtype=None, order='C'): <NEW_LINE> <INDENT> if dtype is None: <NEW_LINE> <INDENT> fill_value = asarray(fill_value) <NEW_LINE> dtype = fill_value.dtype <NEW_LINE> <DEDENT> a = empty(shape, dtype, order) <NEW_LINE> multiarray.copyto(a, fill_value, casting='unsaf...
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 or array_like Fill value. dtype : data-type, optional The desired data-type for the array The default, None, me...
625941dab545ff76a89140c0
def smoothed_state(self,data,beta,H,mu): <NEW_LINE> <INDENT> T, Z, R, Q = self._ss_matrices(beta) <NEW_LINE> alpha, V = nld_univariate_KFS(data,Z,H,T,Q,R,mu) <NEW_LINE> return alpha, V
Creates smoothed state estimate given state matrices and parameters. Parameters ---------- data : np.array Data to be smoothed beta : np.array Contains untransformed starting values for parameters Returns ---------- - Smoothed states
625941daa05bb46b383ecacb
def copy(self, msg_set, dest_mbox, uid_command=False): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.mailbox.lock() <NEW_LINE> msgs = list(self.mailbox.keys()) <NEW_LINE> uid_vv, uid_max = self.get_uid_from_msg(msgs[-1]) <NEW_LINE> seq_max = len(self.mailbox) <NEW_LINE> if uid_command: <NEW_LINE> <INDENT> uid_list ...
Copy the messages in msg_set to the destination mailbox. Flags (sequences), and internal date are preserved. Messages get the '\Recent' flag in the new mailbox. Arguments: - `msg_set`: Set of messages to copy. - `dest_mbox`: mailbox instance messages are being copied to - `uid_command`: True if this is for a UID SEARCH...
625941da4c3428357757c5d1
def strip_key_strings(pofile): <NEW_LINE> <INDENT> newlist = [entry for entry in pofile if not is_key_string(entry.msgid)] <NEW_LINE> del pofile[:] <NEW_LINE> pofile += newlist
Removes all entries in PO which are key strings. These entries should appear only in messages.po, not in any other po files.
625941da8e71fb1e9831da53
def __call__(self, ustring): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> ustring = unicode(ustring) <NEW_LINE> <DEDENT> except UnicodeDecodeError: <NEW_LINE> <INDENT> ustring = unicode(ustring, 'utf-8', errors='replace') <NEW_LINE> <DEDENT> return self.charef_rex.sub(self._replacer, ustring)
xml-escape the given unicode string.
625941da7d43ff24873a2f4c
def print_my_vowels(phrase: str) -> set: <NEW_LINE> <INDENT> vowels = set('aeiou') <NEW_LINE> found = vowels.intersection(set(phrase)) <NEW_LINE> return found
the function returns a set of vowels from the string you've entered
625941daaad79263cf390cef
def spiralOrder(self, matrix): <NEW_LINE> <INDENT> m = len(matrix) <NEW_LINE> if m == 0: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> n = len(matrix[0]) <NEW_LINE> x = 0 <NEW_LINE> y = 0 <NEW_LINE> while x < m and y < n: <NEW_LINE> <INDENT> self.printMatrix(matrix,x,y,m,n) <NEW_LINE> m -= 1 <NEW_LINE> n -= 1 <NEW_...
:type matrix: List[List[int]] :rtype: List[int]
625941da507cdc57c6306f8b
def get_last_file(self): <NEW_LINE> <INDENT> files = os.listdir(self.logpath) <NEW_LINE> repo = r"(?P<name>\bapp.log)-(?P<date>\d{8}\b)" <NEW_LINE> file_list = list() <NEW_LINE> for each in files: <NEW_LINE> <INDENT> re_result = re.match(repo, each) <NEW_LINE> if str(re_result) == "None": <NEW_LINE> <INDENT> continue <...
获取最新的转存文件名 @return <str> 文件名
625941da15fb5d323cde0dbe
def setApplicationName(self, p_str): <NEW_LINE> <INDENT> pass
setApplicationName(str)
625941da3617ad0b5ed681a1
def __init__(self, movies_data=None): <NEW_LINE> <INDENT> self.movies = [] <NEW_LINE> for m in movies_data: <NEW_LINE> <INDENT> title = m['title'] <NEW_LINE> story_line = m['story_line'] <NEW_LINE> poster_image_url = m['poster_image_url'] <NEW_LINE> trailer_url = m['trailer_url'] <NEW_LINE> if sys.version < '3': <NEW_L...
By reading from movies data, initialize a list of media.Movie as instance variable. :param movies_data: a python dictionary of movies data
625941da656771135c3ebb1c
def test_refresh_token_success(self): <NEW_LINE> <INDENT> app_secret = "secret" <NEW_LINE> app = App(user=self.current_user, name="fortest", app_secret=app_secret) <NEW_LINE> self.db.add(app) <NEW_LINE> self.db.commit() <NEW_LINE> app_id = str(str(app.app_id)) <NEW_LINE> resp = self.api_post("/app_token", body={ "app_i...
刷新成功
625941da32920d7e50b2847d
def test_goodSVNEntries_9(self): <NEW_LINE> <INDENT> version = Version("dummy", 1, 0, 0) <NEW_LINE> self.assertEqual( version._parseSVNEntries_9(BytesIO(VERSION_9_ENTRIES)), b'22715')
Version should be able to parse an SVN format 9 entries file.
625941dade87d2750b86003f
def cal_persentage(self): <NEW_LINE> <INDENT> for member in self.members: <NEW_LINE> <INDENT> if self.num_game[member] != 0: <NEW_LINE> <INDENT> c = collections.Counter(self.chakujun[member]) <NEW_LINE> self.per_top[member] = c[1]*100/self.num_game[member] <NEW_LINE> self.per_2nd[member] = c[2]*100/self.num_game[member...
上の2関数の準備
625941da85dfad0860c3b106
def __init__(self,num_classes, learning_rate, batch_size, decay_steps, decay_rate,sequence_length, vocab_size,embed_size,is_training,initializer=tf.random_normal_initializer(stddev=0.1)): <NEW_LINE> <INDENT> self.num_classes = num_classes <NEW_LINE> self.batch_size = batch_size <NEW_LINE> self.sequence_length=sequence_...
init all hyperparameter here
625941da21a7993f00bc7f9e
def post_clone(function): <NEW_LINE> <INDENT> from lepl.matchers.core import Delayed <NEW_LINE> def new_clone(node, args, kargs): <NEW_LINE> <INDENT> copy = clone(node, args, kargs) <NEW_LINE> if not isinstance(node, Delayed): <NEW_LINE> <INDENT> copy = function(copy) <NEW_LINE> <DEDENT> return copy <NEW_LINE> <DEDENT>...
Generate a clone function that applies the given function to the newly constructed node, except for Delayed instances (which are effectively proxies and so have no functionality of their own) (so, when used with `DelayedClone`, effectively performs a map on the graph).
625941da8c3a873295158668
def reset_button() : <NEW_LINE> <INDENT> global timer_op, try_count, sucess_count <NEW_LINE> timer.stop() <NEW_LINE> timer_op = 0 <NEW_LINE> stopwatch_is_running = False <NEW_LINE> try_count = 0 <NEW_LINE> sucess_count = 0
Reset button event handler
625941da187af65679ca53ca
def get_identity(self): <NEW_LINE> <INDENT> return GetIdentity(*self.ipcon.send_request(self, BrickStepper.FUNCTION_GET_IDENTITY, (), '', '8s 8s c 3B 3B H'))
Returns the UID, the UID where the Brick is connected to, the position, the hardware and firmware version as well as the device identifier. The position can be '0'-'8' (stack position). The device identifiers can be found :ref:`here <device_identifier>`. .. versionadded:: 2.0.0~(Firmware)
625941da21a7993f00bc7f9f
def get_os_info(): <NEW_LINE> <INDENT> os_info = "\nThe information about the victim's computer.\n" <NEW_LINE> os_info += f"System: {uname().system}.\n" <NEW_LINE> os_info += f"Username: {getuser()}.\n" <NEW_LINE> os_info += f"Hostname: {uname().node}.\n" <NEW_LINE> os_info += f"Release: {uname().release}.\n" <NEW_LINE...
Gets the information about an operating system of the victim's computer.
625941da2eb69b55b151cb5d
def clear_flags(self, flags): <NEW_LINE> <INDENT> return frameset_clear_flags(self._Cstruct, int(flags))
Clear the given flags for this FrameSet
625941da498bea3a759b9d5a
def __init__(self, input_size, output_size, init_dropout=0.1, hidden_size=None, hidden_dropout=0.2): <NEW_LINE> <INDENT> self.input_size = input_size <NEW_LINE> self.output_size = output_size <NEW_LINE> self.hidden_size = hidden_size <NEW_LINE> self.hidden_dropout = hidden_dropout <NEW_LINE> self.init_dropout = init_dr...
A simple feedforward neural network with 1 or 2 layers that tries to predict attributes directly from 1) an embedding 2) embeddings averaged from the definition 3) some combination 4) etc. :param input_size: dimensionality of input features :param output_size: Dimensionality of output feature (use AttributePrediction.i...
625941daad47b63b2c50a229
def add_csv(result_negaposies, result_df): <NEW_LINE> <INDENT> result_df["negaposi"] = result_negaposies <NEW_LINE> result_df.to_csv("assesment.csv")
ネガポジの結果をデータフレームに追加
625941da7b180e01f3dc4aa4
def set_up_fig_and_axis(fig, axi): <NEW_LINE> <INDENT> if axi is None: <NEW_LINE> <INDENT> if fig is None: <NEW_LINE> <INDENT> fig, axi = plt.subplots() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> axi = fig.axes[0] <NEW_LINE> <DEDENT> except IndexError: <NEW_LINE> <INDENT> axi = fig.add_subpl...
Create a figure and axis if needed. Parameters ---------- fig : object like :class:`matplotlib.figure.Figure` The current figure. If None is given, we create a new one here. axi : object like :class:`matplotlib.axes.Axes` The current axis. If None is given, we create a new one here. Returns ------- fig : obje...
625941daf548e778e58cd82a
def isPalindrome(self, x): <NEW_LINE> <INDENT> if x<0 or (x%10==0 and x!=0): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> temp = 0 <NEW_LINE> origin =x <NEW_LINE> while x!=0: <NEW_LINE> <INDENT> temp = temp*10 + x%10 <NEW_LINE> x /= 10 <NEW_LINE> <DEDENT> return temp==origin
:type x: int :rtype: bool
625941da6aa9bd52df037050
def get(self): <NEW_LINE> <INDENT> token = self.request.get('token') <NEW_LINE> google_user = users.get_current_user() <NEW_LINE> if not google_user: <NEW_LINE> <INDENT> url = users.create_login_url('/signup?token=%s' % token) <NEW_LINE> self.redirect(url) <NEW_LINE> return <NEW_LINE> <DEDENT> if utils.get_current_user...
Crete a new User using an InviteToken
625941da091ae35668667205
def __Room_Timeslot_conflicts(self, given_R: Room, given_T: Timeslot, classes: List[Class]): <NEW_LINE> <INDENT> for c in classes: <NEW_LINE> <INDENT> if c.room.idx == given_R.idx: <NEW_LINE> <INDENT> if c.timeslot.idx == given_T.idx or c.timeslot.idx in given_T.conflicts_with_idxs: <NEW_LINE> <I...
return True if (given_R, given_T) exists in classes, else False
625941da3346ee7daa2b3018
def expand_property(self, property, rtype=str) -> (str, list): <NEW_LINE> <INDENT> return self.expand(self.properties[property], rtype=rtype)
Expand a select property held within this object :param property: The key name of the property we want to expand :param rtype: see expand() for more
625941dae76e3b2f99f3aab3
def publish(self, body, properties=None): <NEW_LINE> <INDENT> self._channel().basic_publish(exchange='', routing_key=self.name, properties=properties, body=body)
Publish a message args: body [str] properties [pika.spec.BasicProperties]
625941daa934411ee375193f
def test_temperature_min(self): <NEW_LINE> <INDENT> self.assertAlmostEqual(self.arrhenius_bm.Tmin.value_si, self.Tmin, 6)
Test that the ArrheniusBM Tmin property was properly set.
625941dad164cc6175782ffa
def __init__(self, cltt): <NEW_LINE> <INDENT> self.cltt = cltt <NEW_LINE> self.lmax = len(cltt)-1 <NEW_LINE> self.ntrm = 4 <NEW_LINE> self.wl = { i : {} for i in xrange(0, self.ntrm) } <NEW_LINE> self.sl = { i : {} for i in xrange(0, self.ntrm) } <NEW_LINE> self.wl[0][0] = self.wc_m1; self.sl[0][0] = +1 <NEW_LINE> self...
initialize the TT lensing potential curl-mode estimator. * cltt = lensed TT power spectrum.
625941da1b99ca400220ad5d
def DisplayJson(matches, args): <NEW_LINE> <INDENT> import json <NEW_LINE> if args.showall: <NEW_LINE> <INDENT> columns = [] <NEW_LINE> data = hostinfo_get('key') <NEW_LINE> for k in data['keys']: <NEW_LINE> <INDENT> columns.append(k['key']) <NEW_LINE> <DEDENT> columns.sort() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDEN...
Display hosts and other printables in JSON format
625941dad6c5a102081442f8
def __getattr__(self, name): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return self.safe_data[name] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> name = name.replace('_', '-') <NEW_LINE> if name in self.safe_data: <NEW_LINE> <INDENT> return self.safe_data[name] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT>...
Fetch object attributes from the underlying data dict held in the model.
625941da60cbc95b062c67ef
def map_analysis_function(frac_tomo, PlanckIQU, dust_map, mask, Nside=2048): <NEW_LINE> <INDENT> Tot_tomo_map = get_Stokes(frac_tomo, dust_map, mask) <NEW_LINE> frac_planck_map = get_Fractional(PlanckIQU, dust_map, mask) <NEW_LINE> diff_Tot = Difference(Tot_tomo_map, PlanckIQU, mask, Nside) <NEW_LINE> diff_frac = Diffe...
Compute the maps to return, incluedes parameter maps, difference maps, correlation maps and dust map in use.
625941dabf627c535bc1347a
def setAlignment(self, align): <NEW_LINE> <INDENT> self['ALIGN'] = align
Set (1) or unset (0) alignment mode Note: disabling alignment mode can take several seconds.
625941dabde94217f368309a
def get_cached_cairo_context(self, pixel_array): <NEW_LINE> <INDENT> return None
Since the frame can be moving around, the cairo context used for updating should be regenerated at each frame. So no caching.
625941da3317a56b86939efe
def upload_analyzer(self, monitor): <NEW_LINE> <INDENT> zip_data = StringIO() <NEW_LINE> zip_file = ZipFile(zip_data, "w", ZIP_STORED) <NEW_LINE> root = os.path.join(CUCKOO_ROOT, "analyzer", self.platform) <NEW_LINE> root_len = len(os.path.abspath(root)) <NEW_LINE> if not os.path.exists(root): <NEW_LINE> <INDENT> log.e...
Upload analyzer to guest. @return: operation status.
625941daad47b63b2c50a22a
def select_extracts_submenu(self): <NEW_LINE> <INDENT> self.switch_to_header_frame() <NEW_LINE> self.select_submenu(self.main_menu_locator, self.extracts_submenu_js_function, script_executor=True) <NEW_LINE> self.wait_for_legacy_screen_spinner_load() <NEW_LINE> time.sleep(5) <NEW_LINE> self.switch_to_default_content()
Implementing select extracts submenu functionality :return:
625941da851cf427c661a7b8
def on_qtm_connect(connection, version): <NEW_LINE> <INDENT> print('Connected to QTM, version {}'.format(version.decode("UTF-8"))) <NEW_LINE> print("Getting parameters from QTM...") <NEW_LINE> connection.get_parameters(on_ok=qtm_receive_params) <NEW_LINE> print("Starting to record new measurement in QTM...") <NEW_LINE>...
Callback to handle QTM connection
625941da6fb2d068a760f34c
def __init__(self, Ef, Em, Vf, Vm, nuf, num): <NEW_LINE> <INDENT> self.E1 = E1(Ef, Em, Vf, Vm) <NEW_LINE> self.E2 = E2(Ef, Em, Vf, Vm) <NEW_LINE> self.v12 = v12(Vf, Vm, nuf, num) <NEW_LINE> self.Gf = G(Ef, nuf) <NEW_LINE> self.Gm = G(Em, num) <NEW_LINE> self.G12 = G12(self.Gf, self.Gm, Vf, Vm)
Holds and computes Effective lamina properties. Based on matrix and fiber properties.
625941da71ff763f4b54993b
def nms_hard(boxes, scores, thresh=0.5): <NEW_LINE> <INDENT> x0 = boxes[:, 0] <NEW_LINE> y0 = boxes[:, 1] <NEW_LINE> x1 = boxes[:, 2] <NEW_LINE> y1 = boxes[:, 3] <NEW_LINE> areas = (x1 - x0 + 1) * (y1 - y0 + 1) <NEW_LINE> _, order = scores.sort(0, descending=True) <NEW_LINE> keep = [] <NEW_LINE> while order.numel() > 0...
:param boxes: tensor, [N, 4] :param scores: tensor, [N,] :param thresh: :return: tensor, selected index
625941da26068e7796caef8d
def geohash(lat, lon, precision=config.GEOHASH_PRECISION): <NEW_LINE> <INDENT> return encode(lat, lon, precision)
precision km (approx) 1 ±2500 2 ±630 3 ±78 4 ±20 5 ±2.4 6 ±0.61 7 ±0.076 8 ±0.019 9 ±0.0024 10 ±0.00060 11 ±0.000074
625941dacc40096d61595bfb
def process_files(options): <NEW_LINE> <INDENT> if options.fasta_files: <NEW_LINE> <INDENT> for fasta_filename in options.fasta_files: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> fasta_file = open(fasta_filename) <NEW_LINE> <DEDENT> except IOError as exception: <NEW_LINE> <INDENT> exit_with_error(str(exception), EXIT_...
Chop up all the FASTA files on the command line Arguments: options: the command line options of the program Result: None
625941da6fece00bbac2d9ed
def assertions(self) -> None: <NEW_LINE> <INDENT> if self._mode not in (tw.core.graph.ComputationGraph.TRAIN, tw.core.graph.ComputationGraph.USE): <NEW_LINE> <INDENT> tf.logging.fatal('Bad config passed to graph builder.') <NEW_LINE> raise ValueError('The config mode parameter ' 'must be "train" or "use".') <NEW_LINE> ...
Asserts valid classifier configuration and valid graph construction mode. Args: `mode` : the graph construction mode for the classifier `config` : the classifier configuration Raises: `ValueError` if: - mode is not 'train', 'use', or 'test' - activation function specified by config ...
625941da0c0af96317bb8494
def toXml(self, out, indent): <NEW_LINE> <INDENT> out.write('{1}<instance name="{0.instance}" id="{0.id}"/>\n'.format(self, indent))
Dump a (pretty-printed) XML-representation of the configuration. Keyword arguments: out - Output stream to write to indent - Amount of indentation
625941da8e05c05ec3eea622
def delete(self, id_): <NEW_LINE> <INDENT> id_ = get_int_arg('id_', id_) <NEW_LINE> site = g.db.query(Site).filter(Site.id == id_).first() <NEW_LINE> if site is None: <NEW_LINE> <INDENT> raise NotFound("Site '%s' does not exist." % id_) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> g.db.delete(site) <NEW_LINE> g.db.comm...
Delete site identified by `id_`.
625941dad268445f265b511a
def __next_view(self, action): <NEW_LINE> <INDENT> curpage = self.notebook.get_current_page() <NEW_LINE> for key in self.page_lookup: <NEW_LINE> <INDENT> if self.page_lookup[key] == curpage: <NEW_LINE> <INDENT> cat_num, view_num = key <NEW_LINE> break <NEW_LINE> <DEDENT> <DEDENT> if cat_num >= len(self.current_views)-1...
Callback that is called when the next category action is selected. It selects the next category as the active category. If we reach the end, we wrap around to the first.
625941da8a43f66fc4b5430e
def is_close(self, other: 'Person'): <NEW_LINE> <INDENT> return abs(self.x - other.x) <= MINIMUM_DISTANCE and abs(self.y - other.y) <= MINIMUM_DISTANCE
:param other :return: True if two persons are closer than the minimum_distance
625941da63d6d428bbe4479b
def set_event_mapping(self, state, ev): <NEW_LINE> <INDENT> if state not in self.STATES: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.event_mapping[state] = ev
Set from tasks dictionary like : {fulfilled: 'simpy.event' class, failed: 'simpy.event' class...} :param state: str| key for mapping :param ev: 'simpy.event'| event for mapping
625941da99cbb53fe6792e92
def start(self): <NEW_LINE> <INDENT> if self.autoRelease: <NEW_LINE> <INDENT> relfile = '%s.release' % ( self.os.path.basename(self.specfile).split('.')[0]) <NEW_LINE> try: <NEW_LINE> <INDENT> rfile = open(relfile, 'r') <NEW_LINE> rel = int(rfile.readline().strip()) <NEW_LINE> rfile.close() <NEW_LINE> <DEDENT> except: ...
Buildbot Calls Me when it's time to start
625941da71ff763f4b54993c
def p_mathEXP_0(self, p ) : <NEW_LINE> <INDENT> print('#',self.counter,'\t',p[2],'\t',p[1],'\t',p[3]) <NEW_LINE> p[0] = '('+str(self.counter)+')' <NEW_LINE> self.counter += 1
mathEXP : mathEXP PLUS mathEXP
625941da30c21e258bdfa74a
@_utilities.lift_output_func(get_users) <NEW_LINE> def get_users_output(searches: Optional[pulumi.Input[Sequence[pulumi.InputType['GetUsersSearchArgs']]]] = None, opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[GetUsersResult]: <NEW_LINE> <INDENT> ...
Use this data source to retrieve a list of users from Okta. ## Example Usage ```python import pulumi import pulumi_okta as okta example = okta.user.get_users(searches=[okta.user.GetUsersSearchArgs( comparison="sw", name="profile.company", value="Articulate", )]) ``` :param Sequence[pulumi.InputType['Ge...
625941da7d847024c06be56a