code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def album(request, pk, view="thumbnails"): <NEW_LINE> <INDENT> num_images = 30 <NEW_LINE> if view == "full": <NEW_LINE> <INDENT> num_images = 10 <NEW_LINE> <DEDENT> album = Album.objects.get(pk=pk) <NEW_LINE> if not album.public and not request.user.is_authenticated(): <NEW_LINE> <INDENT> return HttpResponse("Error: yo...
Album listing.
625941c6796e427e537b05ef
def test_LatLon_complex(): <NEW_LINE> <INDENT> palmyra = LatLon(5.8833, -162.0833) <NEW_LINE> complex_coords = palmyra.complex() <NEW_LINE> assert complex_coords.real == 5.8833 <NEW_LINE> assert complex_coords.imag == -162.0833
Test LatLon method complex
625941c6ec188e330fd5a7cc
def go_left(self): <NEW_LINE> <INDENT> self.change_x = -4
Called when the user hits the left arrow.
625941c64527f215b584c483
def __init__(self, controller, poll=True): <NEW_LINE> <INDENT> self._controller = controller <NEW_LINE> if poll: <NEW_LINE> <INDENT> self._state = self._poll_update() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._state = None
Initialize a new Rachio switch.
625941c610dbd63aa1bd2bce
def _get_label_id(self) -> int: <NEW_LINE> <INDENT> pointer = self.last_label_id <NEW_LINE> self.last_label_id += 1 <NEW_LINE> return pointer
Generates new pointer for label :return: pointer to label
625941c6ab23a570cc2501ac
def get_arg_parser(): <NEW_LINE> <INDENT> launch_datetime = time.strftime('%c') <NEW_LINE> parser = argparse.ArgumentParser() <NEW_LINE> parser.add_argument('--loss', type=str, help=LOSS_OPTIONS_STR) <NEW_LINE> parser.add_argument('--epochs', type=int, help='The number of epochs to run the model') <NEW_LINE> parser.add...
:return: an ArgumentParser with the common configuration for all tasks
625941c60a50d4780f666ebc
def secure_filename(filename): <NEW_LINE> <INDENT> _filename_ascii_strip_re = re.compile(r'[^A-Za-z0-9_.-]') <NEW_LINE> _windows_device_files = ('CON', 'AUX', 'COM1', 'COM2', 'COM3', 'COM4', 'LPT1', 'LPT2', 'LPT3', 'PRN', 'NUL') <NEW_LINE> if isinstance(filename, text_type): <NEW_LINE> <INDENT> from unicodedata import ...
Borrowed from :mod:`werkzeug.utils`, under the BSD 3-clause license. Pass it a filename and it will return a secure version of it. This filename can then safely be stored on a regular file system and passed to :func:`os.path.join`. The filename returned is an ASCII only string for maximum portability. On windows sy...
625941c6046cf37aa974cd73
def getStructureName(self): <NEW_LINE> <INDENT> if self.hasValidStructure(): <NEW_LINE> <INDENT> return self.struct.name <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None
Returns the name string of self.struct if there is a valid structure. Otherwise returns None. This information is used by the name edit field of this command's PM when we call self.propMgr.show() @see: DnaStrand_PropertyManager.show() @see: self.setStructureName
625941c663d6d428bbe4451a
def start_sql(model, tracename='model_trace.db'): <NEW_LINE> <INDENT> if os.path.isfile(tracename): <NEW_LINE> <INDENT> raise Exception('Will not overwrite existing trace {}'.format(tracename)) <NEW_LINE> <DEDENT> cxn = sql.connect(tracename) <NEW_LINE> cursor = cxn.cursor() <NEW_LINE> cursor.execute(customize_create_t...
Start a SQLite connection to a local database, specified by tracename.
625941c6d99f1b3c44c675bb
def plot_diagnostics(self, variable=0, lags=10, fig=None, figsize=None): <NEW_LINE> <INDENT> from statsmodels.graphics.utils import _import_mpl, create_mpl_fig <NEW_LINE> _import_mpl() <NEW_LINE> fig = create_mpl_fig(fig, figsize) <NEW_LINE> d = self.loglikelihood_burn <NEW_LINE> resid = self.filter_results.standardize...
Diagnostic plots for standardized residuals of one endogenous variable Parameters ---------- variable : integer, optional Index of the endogenous variable for which the diagnostic plots should be created. Default is 0. lags : integer, optional Number of lags to include in the correlogram. Default is 10. fi...
625941c6046cf37aa974cd74
def get_disks_xhci(self): <NEW_LINE> <INDENT> udev_client = GUdev.Client() <NEW_LINE> udev_devices = get_udev_block_devices(udev_client) <NEW_LINE> udev_devices_xhci = get_udev_xhci_devices(udev_client) <NEW_LINE> if platform.machine() in ("aarch64", "armv7l"): <NEW_LINE> <INDENT> enumerator = GUdev.Enumerator(client=u...
Compare 1. the pci slot name of the devices using xhci 2. the pci slot name of the disks, which is usb3 disks in this case so far, to make sure the usb3 disk does be on the controller using xhci
625941c656b00c62f0f14683
def p_B_id(p): <NEW_LINE> <INDENT> p[0] = p[1]
B : ID
625941c6e76e3b2f99f3a838
def parse_file(self, path): <NEW_LINE> <INDENT> with open(path, 'rt', encoding=self.encoding) as fh: <NEW_LINE> <INDENT> return self.parse_stream(fh)
Parse the content of the file at ``path`` :param path: The file to parse :return: a list of tasks found in ``file``.
625941c667a9b606de4a7ee6
def tuple(data, field_name): <NEW_LINE> <INDENT> if isinstance(data, Cube): <NEW_LINE> <INDENT> Log.error("not supported yet") <NEW_LINE> <DEDENT> if isinstance(data, FlatList): <NEW_LINE> <INDENT> Log.error("not supported yet") <NEW_LINE> <DEDENT> if isinstance(field_name, Mapping) and "value" in field_name: <NEW_LINE...
RETURN LIST OF TUPLES
625941c676d4e153a657eb5b
def cross(self, vec): <NEW_LINE> <INDENT> return Vector( self.y * vec.z - self.z * vec.y, self.z * vec.x - self.x * vec.z, self.x * vec.y - self.y * vec.x)
Returns the cross product of two vectors in a new vector ex: <1,0,0> x <0,1,0> = <0,0,1>
625941c699cbb53fe6792c11
def cmd_show_dates(self): <NEW_LINE> <INDENT> d = dict(flags=self.args.flags, number=self.args.number, sortkey=self.args.sortkey) <NEW_LINE> names = None <NEW_LINE> for feed in self.generate_feeds(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> deltas, stats, names = feed.get_daystats(include_now=True, **d) <NEW_LINE> ...
Show stats about publish date deltas, or deltas themselves (verbose).
625941c6e1aae11d1e749ce1
def get_synonym(self, pos="noun"): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self.valid_entry_check(): <NEW_LINE> <INDENT> if pos == "noun": <NEW_LINE> <INDENT> response = urlopen( 'http://www.thesaurus.com/browse/{}/noun'.format(self.entry)) <NEW_LINE> <DEDENT> elif pos == "verb": <NEW_LINE> <INDENT> response = ...
Fetches the synonyms from the thesaurus.com using Beautiful Soup
625941c60c0af96317bb8213
def show(job): <NEW_LINE> <INDENT> return flask.render_template('models/images/generic/show.html', job=job)
Called from digits.model.views.models_show()
625941c6656771135c3eb898
def testRecord1080PVideo500times(self): <NEW_LINE> <INDENT> sm.switchCaptureMode('Video') <NEW_LINE> for i in range(500): <NEW_LINE> <INDENT> tb.captureAndCheckPicCount('video',5)
Summary: test Record 1080P video 500 times Steps : 1.Launch video capture activity 2.Record 1080P video 500 times 3.Exit activity
625941c62eb69b55b151c8d8
@app.route('/user/sign_in/', methods=['POST']) <NEW_LINE> def sign_in(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> data = request.get_json(force=True) <NEW_LINE> response, code = authenticate_user(data.get('email'), data.get('password')) <NEW_LINE> return make_response(jsonify(response), code) <NEW_LINE> <DEDENT> ex...
function of sign in with user email and hashed password
625941c6d4950a0f3b08c37b
def get_alarms(username, auth, url): <NEW_LINE> <INDENT> f_url = url + "/imcrs/fault/alarm?operatorName=" + username + "&recStatus=0&ackStatus=0&timeRange=0&size=50&desc=true" <NEW_LINE> response = requests.get(f_url, auth=auth, headers=HEADERS) <NEW_LINE> try: <NEW_LINE> <INDENT> if response.status...
Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API :param username OpeatorName, String type. Required. Default Value "admin". Checks the operator has the privileges to view the Real-Time Alarms. :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: ...
625941c6e8904600ed9f1f56
def test_steps(self): <NEW_LINE> <INDENT> err_msg = "present steps: {}, expected steps: {}" <NEW_LINE> present = self.magnetcycling.steps <NEW_LINE> self.assertEqual(present, STEPS, err_msg.format(present, STEPS)) <NEW_LINE> value = 3 <NEW_LINE> self.magnetcycling.steps = 3 <NEW_LINE> present = self.magnetcycling.steps...
r/w in attribute wait_step.
625941c63317a56b86939c86
def delete_object_permission(sender, instance, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> permission = Permission.objects.get( uuid_codename=instance.str_code() ) <NEW_LINE> permission.delete() <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> print(e.args)
Delete a permission when delete model object :param sender: :param instance: :param kwargs: :return:
625941c67b180e01f3dc482b
def t_CPP_COMMENT(t): <NEW_LINE> <INDENT> t.lexer.lineno += t.value.count("\n") <NEW_LINE> return t
(/\*(.|\n)*?\*/)|(//.*?\n)
625941c676d4e153a657eb5c
def myimshow(img, unnormalize=False): <NEW_LINE> <INDENT> if unnormalize: <NEW_LINE> <INDENT> img = img * 255 <NEW_LINE> <DEDENT> np_img = img.numpy() <NEW_LINE> plt.imshow(np.transpose(np_img[0], (1, 2, 0))) <NEW_LINE> plt.show()
:param img: tensor of images, first dimension is number of images in the batch :param unnormalize: whenever to unnormalize the image before plotting :return: void
625941c6b7558d58953c4f42
def set_lang(self,prefix): <NEW_LINE> <INDENT> self.api_url = 'http://' + prefix.lower() + '.wikipedia.org/w/api.php' <NEW_LINE> self.clear_cache()
Change the language of the API being requested. Set `prefix` to one of the two letter prefixes found on the `list of all Wikipedias <http://meta.wikimedia.org/wiki/List_of_Wikipedias>`_. After setting the language, the cache for ``search``, ``suggest``, and ``summary`` will be cleared. .. note:: Make sure you search ...
625941c630dc7b7665901993
@main.group() <NEW_LINE> def bos(): <NEW_LINE> <INDENT> pass
BOS related calls
625941c6cad5886f8bd27005
def __init__(self, master): <NEW_LINE> <INDENT> super(Application, self).__init__(master) <NEW_LINE> self.grid() <NEW_LINE> self.create_widgets()
Initializes the frame.
625941c67b25080760e39485
def requires(self): <NEW_LINE> <INDENT> return [StreamsHdfs(date) for date in self.date_interval]
This task's dependencies: * :py:class:`~.StreamsHdfs` :return: list of object (:py:class:`luigi.task.Task`)
625941c64c3428357757c354
def detect_speech(self): <NEW_LINE> <INDENT> detected_windows = np.array([]) <NEW_LINE> sample_window = int(self.rate * self.sample_window) <NEW_LINE> sample_overlap = int(self.rate * self.sample_overlap) <NEW_LINE> data = self.data <NEW_LINE> sample_start = 0 <NEW_LINE> start_band = self.speech_start_band <NEW_LINE> e...
Detects speech regions based on ratio between speech band energy and total energy. Output is array of window numbers and speech flags (1 - speech, 0 - nonspeech).
625941c6e64d504609d7486b
def next(self): <NEW_LINE> <INDENT> with self.lock: <NEW_LINE> <INDENT> index_array, current_index, current_batch_size = next(self.index_generator) <NEW_LINE> <DEDENT> batch_x = np.zeros((current_batch_size,) + self.image_shape, dtype=K.floatx()) <NEW_LINE> grayscale = self.color_mode == 'grayscale' <NEW_LINE> for i, j...
For python 2.x. # Returns The next batch.
625941c6ff9c53063f47c220
def move(self, src, dst, overwrite=False, chunk_size=16384): <NEW_LINE> <INDENT> if self.isdir(src): <NEW_LINE> <INDENT> raise ResourceInvalidError( "Specified src is a directory. Please use movedir.") <NEW_LINE> <DEDENT> f = self.client.get_file(src) <NEW_LINE> f['parents'] = [{"id": dst}] <NEW_LINE> return self.clien...
Move a file to another folder. .. note:: Google Drive can have many parents for one file, when using this method a file will be moved from all current parents to the new parent 'dst'. :param src: id of the file to be moved :param dst: id of the folder in which the file will be moved :param overwrite: for Goog...
625941c6009cb60464c633de
def test_python_console(self): <NEW_LINE> <INDENT> email = 'test_python_console@google.com' <NEW_LINE> self.assertFalse(modules.admin.admin.DIRECT_CODE_EXECUTION_UI_ENABLED) <NEW_LINE> modules.admin.admin.DIRECT_CODE_EXECUTION_UI_ENABLED = True <NEW_LINE> actions.login(email) <NEW_LINE> response = self.testapp.get('/ad...
Test access rights to the Python console.
625941c66e29344779a6263f
def get_sections( self ): <NEW_LINE> <INDENT> return( self.sections_ordered )
Return a list of the section names in a config file sections = conf.get_sections()
625941c626068e7796caed08
def setDateEditEnabled(self, bool): <NEW_LINE> <INDENT> pass
setDateEditEnabled(self, bool)
625941c6566aa707497f4597
def fit(self, X, y): <NEW_LINE> <INDENT> X, y = check_X_y(X, y, y_numeric=True) <NEW_LINE> myorder = np.argsort(X[:, 0]) <NEW_LINE> self._training_set = X[myorder, :] <NEW_LINE> ysort = np.array(y, dtype=np.float64)[myorder] <NEW_LINE> indices = [] <NEW_LINE> indptr = [0] <NEW_LINE> for (i, Xrow) in enumerate(self._tra...
Fit a multidimensional isotonic regression model Parameters ---------- X : array-like, shape=(n_samples, n_features) Training data y : array-like, shape=(n_samples,) Target values Returns ------- self : object Returns an instance of self
625941c645492302aab5e2ee
def as_dict(self, verbosity=1, fmt=None, **kwargs): <NEW_LINE> <INDENT> if fmt == "abivars": <NEW_LINE> <INDENT> from pymatgen.io.abinit.abiobjects import structure_to_abivars <NEW_LINE> return structure_to_abivars(self, **kwargs) <NEW_LINE> <DEDENT> latt_dict = self._lattice.as_dict(verbosity=verbosity) <NEW_LINE> del...
Dict representation of Structure. Args: verbosity (int): Verbosity level. Default of 1 includes both direct and cartesian coordinates for all sites, lattice parameters, etc. Useful for reading and for insertion into a database. Set to 0 for an extremely lightweight version that only...
625941c6a05bb46b383ec84e
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, EdgeNode): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__
Returns true if both objects are equal
625941c68e05c05ec3eea39f
def determineBackboneSidechainType(self): <NEW_LINE> <INDENT> if self.bb1 > self.sc1: <NEW_LINE> <INDENT> self.atom1contactsBy = BackboneSidechainType.contactsBb <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.atom1contactsBy = BackboneSidechainType.contactsSc <NEW_LINE> <DEDENT> if self.bb2 > self.sc2: <NEW_LINE> <...
Returns the Backbone-Sidechain type.
625941c6bd1bec0571d9065b
def create_template(self): <NEW_LINE> <INDENT> self.template.add_version('2010-09-09') <NEW_LINE> self.template.add_description( 'Creates an ALB Target Group' ) <NEW_LINE> self.add_resources_and_outputs()
Create template (main function called by Stacker).
625941c6ec188e330fd5a7cd
def countby(key, seq): <NEW_LINE> <INDENT> if not callable(key): <NEW_LINE> <INDENT> key = getter(key) <NEW_LINE> <DEDENT> return frequencies(map(key, seq))
Count elements of a collection by a key function >>> countby(len, ['cat', 'mouse', 'dog']) {3: 2, 5: 1} >>> def iseven(x): return x % 2 == 0 >>> countby(iseven, [1, 2, 3]) # doctest:+SKIP {True: 1, False: 2} See Also: groupby
625941c6cc40096d6159597d
def open(self): <NEW_LINE> <INDENT> log("{0}: Opened".format(self)) <NEW_LINE> enable_listener(self) <NEW_LINE> if self.buffer_id is None: <NEW_LINE> <INDENT> log("{0}: Empty buffer ID. Creating view.".format(self)) <NEW_LINE> self_view = sublime.active_window().new_file() <NEW_LINE> self_view.set_scratch(True) <NEW_LI...
Enable listening to events, Create view and buffer_id
625941c638b623060ff0ae1a
def get_dihedral_patterns(self): <NEW_LINE> <INDENT> return self.get_sequence_patterns("dihedral")
Return a set of unique sequences of atom types appearing in all the sequences describing dihedrals.
625941c63346ee7daa2b2d96
def install_packages(package_names, sudo_cmd='sudo', **kwargs): <NEW_LINE> <INDENT> pm = find_package_manager_command() <NEW_LINE> argv = package_manager_commands[pm][:] <NEW_LINE> if '{packages_wsjoin}' in argv: <NEW_LINE> <INDENT> ix = argv.index('{packages_wsjoin}') <NEW_LINE> argv[ix] = ' '.join(package_names) <NEW...
Install a list of packages using the system package manager. If not running as root, sudo_cmd will be placed before the list of arguments. **kwargs will be passed on to :class;`subprocess.Popen` Returns a 3-tuple (stdout, stderr, returncode). stdout and stderr will be None unless you pass :data:`subprocess.PIPE`.
625941c6adb09d7d5db6c7bc
def create_New_Toplevel_1(root, *args, **kwargs): <NEW_LINE> <INDENT> global w, w_win, rt <NEW_LINE> rt = root <NEW_LINE> w = Toplevel (root) <NEW_LINE> top = New_Toplevel_1 (w) <NEW_LINE> holdem_main_support.init(w, top, *args, **kwargs) <NEW_LINE> return (w, top)
Starting point when module is imported by another program.
625941c6379a373c97cfab70
def test_get(self): <NEW_LINE> <INDENT> ocsp = build_request_good() <NEW_LINE> body = quote(b64encode(ocsp.dump()).decode('utf8')) <NEW_LINE> response = self.client.get('/' + body) <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_LINE> ocsp = OCSPResponse.load(response.content) <NEW_LINE> self.assertEqual(oc...
Valid GET request.
625941c6a17c0f6771cbe07d
def test_unicode(self): <NEW_LINE> <INDENT> s = unicode('asdf') <NEW_LINE> self.assertRaises(TypeError, zmq.Message, s) <NEW_LINE> u = '§' <NEW_LINE> if str is not unicode: <NEW_LINE> <INDENT> u = u.decode('utf8') <NEW_LINE> <DEDENT> for i in range(16): <NEW_LINE> <INDENT> s = (2**i)*u <NEW_LINE> m = zmq.Message(s.enco...
Test the unicode representations of the Messages.
625941c691f36d47f21ac51d
def mail_to_user(devices_data, db): <NEW_LINE> <INDENT> possible_status = ['changed_devices', 'new_devices'] <NEW_LINE> if sorted(possible_status) == sorted(devices_data.keys()): <NEW_LINE> <INDENT> if len(devices_data['changed_devices']) > 0 or len(devices_data['new_devices']) > 0: <NEW_LINE> <INDENT> m...
Routine that sends email to the user when something is detected :param devices_data: (dict) A dict returned :param db: database connection :return:
625941c6b545ff76a8913e43
def save_game(self, gamedir=''): <NEW_LINE> <INDENT> if not gamedir: <NEW_LINE> <INDENT> gamedir = self.gamedir <NEW_LINE> <DEDENT> self.room_manager.save_rooms(gamedir) <NEW_LINE> self.char_manager.save_characters(gamedir) <NEW_LINE> self.item_manager.save_item_templates(gamedir) <NEW_LINE> print('Game saved.')
Saves the game to the current game's directory.
625941c6a219f33f34628998
def batchnorm_forward(x, gamma, beta, bn_param): <NEW_LINE> <INDENT> mode = bn_param['mode'] <NEW_LINE> eps = bn_param.get('eps', 1e-5) <NEW_LINE> momentum = bn_param.get('momentum', 0.9) <NEW_LINE> N, D = x.shape <NEW_LINE> running_mean = bn_param.get('running_mean', np.zeros(D, dtype=x.dtype)) <NEW_LINE> running_var ...
Forward pass for batch normalization. During training the sample mean and (uncorrected) sample variance are computed from minibatch statistics and used to normalize the incoming data. During training we also keep an exponentially decaying running mean of the mean and variance of each feature, and these averages are us...
625941c6fb3f5b602dac36be
@api_view(['PATCH', ]) <NEW_LINE> @permission_classes((IsInsuranceOrStaff,)) <NEW_LINE> def order_status_change(request, order_id, status_id): <NEW_LINE> <INDENT> order_status = get_object_or_404(OrderStatus, pk=status_id) <NEW_LINE> order = get_object_or_404(Order, pk=order_id) <NEW_LINE> order.status = order_status <...
Changes order status for an order
625941c6ad47b63b2c509fab
def save_notebook_model(self, model, name='', path=''): <NEW_LINE> <INDENT> path = path.strip('/') <NEW_LINE> if 'content' not in model: <NEW_LINE> <INDENT> raise web.HTTPError(400, u'No notebook JSON data provided') <NEW_LINE> <DEDENT> new_path = model.get('path', path).strip('/') <NEW_LINE> new_name = model.get('name...
Save the notebook model and return the model with no content.
625941c6d58c6744b4257c8c
def description (self) : <NEW_LINE> <INDENT> return self._description
Return the description associated with this quantity.
625941c68da39b475bd64f9f
def input_text_into_alert(self, text: str, action=ACCEPT, timeout=10): <NEW_LINE> <INDENT> self.logger.info(f"发送内容到警告框:{text}") <NEW_LINE> alert = self._wait_alert(timeout) <NEW_LINE> alert.send_keys(text) <NEW_LINE> self._handle_alert(alert, action)
将给定的文本输入到警告框中 :param text: 文本内容 :param action: 可选值:ACCEPT(接收)、DISMISS(取消)、LEAVE(保持不处理) :param timeout: 等待警告框出现的延迟 :return: None
625941c6be7bc26dc91cd62e
def read_ntp_service_with_http_info(self, **kwargs): <NEW_LINE> <INDENT> all_params = [] <NEW_LINE> all_params.append('async_req') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE> all_params.append('_request_timeout') <NEW_LINE> params = locals() <NEW_LI...
Read NTP service properties # noqa: E501 Read NTP service properties # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.read_ntp_service_with_http_info(async_req=True) >>> result = thread.get() :param async_req bool...
625941c65f7d997b87174ac3
def fetch_report(self): <NEW_LINE> <INDENT> report = FetchReportRepository().fetch_report() <NEW_LINE> return report
send users data :param user: :return:
625941c6377c676e912721d5
def find_track_curvature(track, labels, hits): <NEW_LINE> <INDENT> trk_ix = np.where(labels == track)[0] <NEW_LINE> if len(trk_ix) < 5: <NEW_LINE> <INDENT> return (1, 1, 1) <NEW_LINE> <DEDENT> df = hits.loc[trk_ix] <NEW_LINE> df = df.sort_values('z_abs') <NEW_LINE> x = df.x.values <NEW_LINE> y = df.y.values <NEW_LINE> ...
Estimate the helix track curvature, assuming the helix includes (x,y)=(0,0). 3 curvatures are returned: curv02a: curvature using 0,0, the first hit, and the mid-point hit of the helix curv02b: curvature using 0,0, the mid-point hit, and the last hit of the helix curv02c: curvature using 0,0, the second hit, and the las...
625941c6be383301e01b54b5
def ReadCommand(sock): <NEW_LINE> <INDENT> command = '' <NEW_LINE> data = sock.recv(1024) <NEW_LINE> if (data.find("\n") != -1 ): <NEW_LINE> <INDENT> command += data <NEW_LINE> <DEDENT> return command
Read a single command from a socket. The command must end in newline.
625941c6f7d966606f6aa02f
def _run_container_editor(self, container_name=None): <NEW_LINE> <INDENT> container_names = set(self._get_container_names()) <NEW_LINE> container_names.discard(container_name) <NEW_LINE> container_name = container_name or self._device_tree.GenerateContainerName() <NEW_LINE> request = DeviceFactoryRequest.from_structure...
Run container edit dialog and return True if changes were made.
625941c694891a1f4081bad5
def outdegree(self, vertex): <NEW_LINE> <INDENT> return len(self.successors(vertex))
Get the outdegree of the specified vertex
625941c69f2886367277a8ba
def feature_to_split(dataset): <NEW_LINE> <INDENT> numfeature = len(dataset[0]) - 1 <NEW_LINE> base_entropy = calc_entropy(dataset) <NEW_LINE> best_infogain = 0.0 <NEW_LINE> best_feature_index = -1 <NEW_LINE> for i in range(numfeature): <NEW_LINE> <INDENT> feature_list = [example[i] for example in dataset] <NEW_LINE> f...
根据信息增益最大的原则选择最优划分特征,ID3算法 :param dataset: list :return: 最优特征索引
625941c6d268445f265b4e9b
def test_list(self): <NEW_LINE> <INDENT> self.assertAlmostEqual(max_integer([1, 3, 6, 3]), 6) <NEW_LINE> self.assertAlmostEqual(max_integer([6]), 6) <NEW_LINE> self.assertAlmostEqual(max_integer([1, 3, 3]), 3) <NEW_LINE> self.assertAlmostEqual(max_integer([-1, -3, -4]), -1) <NEW_LINE> self.assertAlmostEqual(max_integer...
You must find the max integer
625941c6796e427e537b05f1
def test_add_processor_override(caplog): <NEW_LINE> <INDENT> testapp = holocron.Application() <NEW_LINE> marker = None <NEW_LINE> def processor_a(app, items): <NEW_LINE> <INDENT> nonlocal marker <NEW_LINE> marker = 42 <NEW_LINE> yield from items <NEW_LINE> <DEDENT> def processor_b(app, items): <NEW_LINE> <INDENT> nonlo...
.add_processor() overrides registered one.
625941c6287bf620b61d3a91
def __init__(self, hass, username, password, language, bring_data): <NEW_LINE> <INDENT> self.bring = bring_data <NEW_LINE> self.hass = hass <NEW_LINE> self.map_items = {} <NEW_LINE> self.items = []
Initialize the shopping list.
625941c69f2886367277a8bb
def process_logs_standard_procedure(procedure, name, end_date=None, day_window=None, run_code=None): <NEW_LINE> <INDENT> time_window = DAY_WINDOW if day_window is None else day_window <NEW_LINE> tz = pytz.timezone(settings.TIME_ZONE) <NEW_LINE> end_date_localized = None if end_date is None else tz.localize(end_date) <N...
Recovers logs from DB and computes a procedure Computes procedure for each day until the end date given a day window. Timezone localization will be set according to settings.py Arguments - procedure to compute stats given a dataframe with daily logs for a course. Expected signature is procedure(dataframe, co...
625941c666673b3332b920bd
def exit_config_mode(self, exit_config='', pattern=''): <NEW_LINE> <INDENT> debug = False <NEW_LINE> output = '' <NEW_LINE> if self.check_config_mode(): <NEW_LINE> <INDENT> self.write_channel(self.normalize_cmd(exit_config)) <NEW_LINE> output = self.read_until_pattern(pattern=pattern) <NEW_LINE> if self.check_config_mo...
Exit from configuration mode.
625941c60383005118ecf610
def __init__( self, *, source: Union[str, "RoutingSource"], endpoint_names: List[str], is_enabled: bool, name: Optional[str] = None, condition: Optional[str] = None, **kwargs ): <NEW_LINE> <INDENT> super(FallbackRouteProperties, self).__init__(**kwargs) <NEW_LINE> self.name = name <NEW_LINE> self.source = source <NEW_L...
:keyword name: The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. :paramtype name: str :keyword source: Required. The source to which the routing rule is to be applied to. For example, DeviceMessages. Poss...
625941c6009cb60464c633df
def __init__(self, filename, axis=0, optimize='memory'): <NEW_LINE> <INDENT> self.filename = filename <NEW_LINE> self.axis = axis <NEW_LINE> self.optimize = optimize <NEW_LINE> self.buffer = cv2.VideoCapture(filename) <NEW_LINE> if not self.buffer.isOpened(): <NEW_LINE> <INDENT> raise IOError('Cannot open video file: {...
Initialization Parameters ---------- filename : str Path to video file axis : int, optional Iteration axis (default: 0) optimize : str, optional Optimization method (speed or memory; default: memory)
625941c6b7558d58953c4f43
def clear_events(): <NEW_LINE> <INDENT> while len(events) > 0: <NEW_LINE> <INDENT> canvas.delete(events.pop())
Clears all events off of the canvas.
625941c6956e5f7376d70e9b
def field_type_from_value(self, value): <NEW_LINE> <INDENT> result = self._field_type_from_value_type.get(type(value)) <NEW_LINE> if result is None and isinstance(value, (list,tuple)): <NEW_LINE> <INDENT> if not value: <NEW_LINE> <INDENT> raise TypeError('Cannot guess the item type of an empty list') <NEW_LINE> <DEDENT...
Return a valid field type for a Python value or None if no field type is valid for that value. If the value is an empty list or tuple, a TypeError is raised since the item type cannot be identified.
625941c691af0d3eaac9ba44
def big_multiply(a, b, base=10, export_length=64): <NEW_LINE> <INDENT> export = [0] * export_length <NEW_LINE> new_a = bu_wei(a, export_length) <NEW_LINE> new_b = bu_wei(b, export_length) <NEW_LINE> effect_a = - zui_gao_wei(new_a) <NEW_LINE> effect_b = - zui_gao_wei(new_b) <NEW_LINE> if new_a[0] != new_b[0]: <NEW_LINE>...
带符号数的乘法
625941c68a349b6b435e81a0
def stream_file(self, filename, digits='', offset='0'): <NEW_LINE> <INDENT> cmd = 'STREAM FILE %s "%s" %s' % (filename, digits, offset) <NEW_LINE> return self._parse_get_option_or_stream_file(cmd)
Plays the audio file to the current channel. :param filename: Filename to play. The extension must not be included in the filename. :type filename: str :param digits: Digits to interrupt audio stream. :type digits: str :param offset: If an offset is provided the audio will seek to the offs...
625941c671ff763f4b5496b6
def addPrefix(self, prefix): <NEW_LINE> <INDENT> prefix = prefix.strip().strip(':'); <NEW_LINE> if not prefix : <NEW_LINE> <INDENT> return; <NEW_LINE> <DEDENT> for route in self.__routes.values(): <NEW_LINE> <INDENT> route.setPath(prefix + ':' + route.getPath()); <NEW_LINE> <DEDENT> return self;
Adds a prefix to the path of all child routes. @param: string prefix An optional prefix to add before each pattern of the route collection @return: RouteCollection The current instance @api
625941c6d18da76e23532502
def w2rho(v, ds): <NEW_LINE> <INDENT> grid = ds.attrs['xgcm-Grid'] <NEW_LINE> var = grid.interp(v,'s') <NEW_LINE> add_coords(ds, var, ['lon_r','lat_r']) <NEW_LINE> var.attrs = v.attrs <NEW_LINE> return var.rename(v.name)
interpolate horizontally variable from rho to psi point
625941c6442bda511e8be447
def dbl_line_list(text): <NEW_LINE> <INDENT> import re <NEW_LINE> return re.split('\n{2}|\r{2}|\n\r\n\r', text)
Split the text into a list of content. Two LFs or CRs or two LFCRs are considered a paragraph break. All other line breaks are left as is.
625941c632920d7e50b281fc
def trainModel(self): <NEW_LINE> <INDENT> self.images, self.trainImageCount = self.file_helper.getFiles(self.train_path) <NEW_LINE> print(self.images.items()) <NEW_LINE> label_count = 0 <NEW_LINE> for word, imlist in self.images.items(): <NEW_LINE> <INDENT> print("why not", len(imlist)) <NEW_LINE> self.name_dict[str(la...
This method contains the entire module required for training the bag of visual words model Use of helper functions will be extensive.
625941c6cdde0d52a9e5305f
def re_medical_btn_cmd(): <NEW_LINE> <INDENT> medical_image_label.configure(image="") <NEW_LINE> medical_image_label.grid(column=1, row=9, sticky="w") <NEW_LINE> show_medical_image() <NEW_LINE> add_medical_btn.state(["!disabled"]) <NEW_LINE> return
The button command to reselect the medical image This function is intended to allow the users to reselect the medical image if they are not satisfied with the current image. This function will also enable the add image button. Returns: None
625941c69b70327d1c4e0e01
def __init__( self, method: Callable[..., Awaitable[knowledge_base.ListKnowledgeBasesResponse]], request: knowledge_base.ListKnowledgeBasesRequest, response: knowledge_base.ListKnowledgeBasesResponse, *, metadata: Sequence[Tuple[str, str]] = () ): <NEW_LINE> <INDENT> self._method = method <NEW_LINE> self._request = kno...
Instantiates the pager. Args: method (Callable): The method that was originally called, and which instantiated this pager. request (google.cloud.dialogflow_v2beta1.types.ListKnowledgeBasesRequest): The initial request object. response (google.cloud.dialogflow_v2beta1.types.ListKnowledgeBase...
625941c68c3a8732951583e6
def format_index_header(self): <NEW_LINE> <INDENT> debug.warning( 'Formatting index header: uuid: "%s", base_iv: "%s"', self.blockstore.uuid, repr(self.sequential_iv.base_iv)) <NEW_LINE> return bytes( 'dti1' + self.blockstore.uuid) + self.sequential_iv.base_iv
Format a Tarzan index header. Header format: block magic number ("dti1"). uuid (36 bytes identifying the BlockStorage) base_iv (16 random bytes) :returns: str -- Tarzan index header
625941c650485f2cf553cdc6
def _ParseSubKey( self, parser_context, key, parent_value_string, registry_type=None, file_entry=None, parser_chain=None, codepage='cp1252'): <NEW_LINE> <INDENT> text_dict = {} <NEW_LINE> value_strings = {} <NEW_LINE> for index, entry_number in self._ParseMRUListExValue(key): <NEW_LINE> <INDENT> if entry_number == 0xff...
Extract event objects from a MRUListEx Registry key. Args: parser_context: A parser context object (instance of ParserContext). key: the Registry key (instance of winreg.WinRegKey). parent_value_string: string containing the parent value string. registry_type: Optional Registry type string. The default is None...
625941c6be8e80087fb20c71
def __init__(self, gameState, agentIndex=None, costFn = lambda x: 1, goal=(1,1), start=None, warn=True, visualize=True): <NEW_LINE> <INDENT> self.walls = gameState.getWalls() <NEW_LINE> if start != None: <NEW_LINE> <INDENT> self.startState = start <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.startState = gameStat...
Stores the start and goal. gameState: A GameState object (pacman.py) costFn: A function from a search state (tuple) to a non-negative number goal: A position in the gameState
625941c6462c4b4f79d1d6fd
def __ne__(self, another): <NEW_LINE> <INDENT> return not self.__eq__(another)
Check if two Cubies are different.
625941c6adb09d7d5db6c7bd
def __init__(self, test, tester): <NEW_LINE> <INDENT> self.__dict__.update(test) <NEW_LINE> self.breaks = test['breaks'] if 'breaks' in test else None <NEW_LINE> self.tester = tester
Args: test dict(): tester Tester: Notes: messages should contain an array with the messages for the different results that the test can return, if messages is a function it should return a str[]
625941c6796e427e537b05f2
def is_set(self, card1, card2, card3): <NEW_LINE> <INDENT> if ( (card1.color + card2.color + card3.color) % 3 == 0 and (card1.shape + card2.shape + card3.shape) % 3 == 0 and (card1.shading + card2.shading + card3.shading) % 3 == 0 and (card1.number + card2.number + card3.number) % 3 == 0): <NEW_LINE> <INDENT> return Tr...
Determines whether or not three cards are in a set There are three values for each property of a card which I assign 0, 1, and 2. If a property of three cards have the same value, it can be 0,0,0, 1,1,1, and 2,2,2, which add up to 0, 3, and 6 respectively. If a feature of three cards have all different values, then ...
625941c6f7d966606f6aa030
def __init__(self, filename): <NEW_LINE> <INDENT> self._filename = filename <NEW_LINE> self.refresh()
Create a new `YmRaster` instance from an image file. Parameters ---------- filename : str path to the image file to read
625941c656b00c62f0f14685
def update_data(id, classify): <NEW_LINE> <INDENT> conn = pool.connection() <NEW_LINE> cursor = conn.cursor() <NEW_LINE> sql = 'update tb_learning_video set classify="%s" where url_object_id="%s"' % (classify, id) <NEW_LINE> cursor.execute(sql) <NEW_LINE> conn.commit() <NEW_LINE> cursor.close() <NEW_LINE> conn.close()
获取数据 :return:返回值为list包dict类型
625941c676d4e153a657eb5d
def __add__(self, other): <NEW_LINE> <INDENT> return self.merge(other)
Return the merge with other.
625941c69c8ee82313fbb7a1
def swipe_down_entire_scroll_view(self): <NEW_LINE> <INDENT> location = self._scroll_view.location <NEW_LINE> size = self._scroll_view.size <NEW_LINE> x = location['x'] + size['width']/2 <NEW_LINE> end_y = location['y'] + size['height'] - 1 <NEW_LINE> start_y = location['y'] + 1 <NEW_LINE> log.logger.info("开始向下滑动整个可滑动区...
Summary: 向下滑动整个scroll view的高度
625941c663b5f9789fde7112
def set_speed(self,speed=None,address=1): <NEW_LINE> <INDENT> if speed == None: <NEW_LINE> <INDENT> speed = self.default_speed <NEW_LINE> <DEDENT> speed = int(speed) <NEW_LINE> if speed < 1 or speed > 40: <NEW_LINE> <INDENT> raise ValueError("speed must be between 1 and 40 (inclusive)") <NEW_LINE> <DEDENT> self._ready_...
sets speed of pump to speed levels 1-40 speed := 1 => fastest 1.2s per sstroke speed := 40 => slowest 600s per stroke
625941c6c4546d3d9de72a60
def GetTotal(self): <NEW_LINE> <INDENT> return time.clock() - self.tstart
Returms time since timer object created.
625941c6627d3e7fe0d68e7c
def objective(X, y, trial): <NEW_LINE> <INDENT> n_components = (trial.suggest_int("n_components", 1, len(list(X.columns))),) <NEW_LINE> pca = PCA(n_components=n_components[0]).fit(X) <NEW_LINE> x_pca = pd.DataFrame(pca.transform(X)) <NEW_LINE> print(x_pca, y) <NEW_LINE> acc_results = [] <NEW_LINE> kfold = StratifiedKFo...
最適化する目的関数
625941c601c39578d7e74e68
def _update(self, buildscript): <NEW_LINE> <INDENT> archive, version = split_name(self.module) <NEW_LINE> if archive == self.repository.archive: <NEW_LINE> <INDENT> self.repository._ensure_registered() <NEW_LINE> <DEDENT> if date: <NEW_LINE> <INDENT> raise BuildStageError(_('date based checkout not yet supported\n')) <...
Perform a "baz update" (or possibly a checkout)
625941c60c0af96317bb8215
def set(self, var, value): <NEW_LINE> <INDENT> cmd = '%s=%s;'%(var,value) <NEW_LINE> out = self.eval(cmd) <NEW_LINE> if out.find('***') != -1: <NEW_LINE> <INDENT> raise TypeError("Error executing code in GP:\nCODE:\n\t%s\nPARI/GP ERROR:\n%s"%(cmd, out))
Set the GP variable var to the given value. INPUT: - ``var`` (string) -- a valid GP variable identifier - ``value`` -- a value for the variable EXAMPLES:: sage: gp.set('x', '2') sage: gp.get('x') '2'
625941c663f4b57ef0001149
def get_house_monsters(self): <NEW_LINE> <INDENT> return self.__house_monsters
Returns the total monster count in the house. :return: __total_monsters: total monsters in the house
625941c666656f66f7cbc1d7
def __init__(self, configuration_id=None, username=None, api_password=None, override_config_file=None, base_url=DEFAULT_BASE_URL): <NEW_LINE> <INDENT> self._recs_vars = {u"base_url":base_url, u"username":username, u"api_password":api_password} <NEW_LINE> self._empty_inventory = {u"_meta":{u"hostvars...
Excecution path
625941c6e8904600ed9f1f58
def dice_coefficient(a, b): <NEW_LINE> <INDENT> a_bigram_list = a.flatten() <NEW_LINE> b_bigram_list = b.flatten() <NEW_LINE> lena = len(a_bigram_list) <NEW_LINE> one_a = 0 <NEW_LINE> one_b = 0 <NEW_LINE> matches = i = 0 <NEW_LINE> while (i < lena): <NEW_LINE> <INDENT> if (a_bigram_list[i] ==1): <NEW_LINE> <INDENT> one...
use python list comprehension, preferred over list.append()
625941c697e22403b379cfc6
def can_view(self, user): <NEW_LINE> <INDENT> if not isinstance(user, get_user_model()): <NEW_LINE> <INDENT> raise TypeError('%s is not an auth user' % str(user)) <NEW_LINE> <DEDENT> if user == self.user or user.is_superuser: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False
' Checks if a User instance is allowed to view this object instance or not. ' ' Keyword Arguments: ' user - AuthUser to check if they have permissions. ' ' Return: True if user is allowed to view and False otherwise.
625941c621a7993f00bc7d1b
def stop(self): <NEW_LINE> <INDENT> if self.spotify and self.is_playing: <NEW_LINE> <INDENT> if self.dev_id: <NEW_LINE> <INDENT> self.schedule_event(self.do_stop, 0, name='StopSpotify') <NEW_LINE> <DEDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False
Stop playback.
625941c615baa723493c3fa2
def testFourKindLow(self): <NEW_LINE> <INDENT> score = self.game.poker_score((3, 2, 3, 3, 3)) <NEW_LINE> check = [6, 3, 3, 3, 3, 2] <NEW_LINE> self.assertEqual(check, score)
Test scoring four of a kind with a low kicker.
625941c67cff6e4e811179b3
def predict(self, X): <NEW_LINE> <INDENT> return np.argmax(self.predict_proba(X), axis=1)
Predict the class. ## Inputs - **X**: a dataframe to be used ## Output A numpy array containing the predicted classes.
625941c694891a1f4081bad6