code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def create_app(config_object=ProdConfig): <NEW_LINE> <INDENT> app = Flask(__name__, static_url_path='/static', static_folder=os.path.join('static', 'dist')) <NEW_LINE> app.config.from_object(config_object) <NEW_LINE> register_extensions(app) <NEW_LINE> register_blueprints(app) <NEW_LINE> register_errorhandlers(app) <NE...
An application factory, as explained here: http://flask.pocoo.org/docs/patterns/appfactories/. :param config_object: The configuration object to use.
625941c1dc8b845886cb54c0
def clean(self, value): <NEW_LINE> <INDENT> if self.required and not value: <NEW_LINE> <INDENT> raise ValidationError(self.error_messages['required'], code='required') <NEW_LINE> <DEDENT> elif not self.required and not value: <NEW_LINE> <INDENT> return self.queryset.none() <NEW_LINE> <DEDENT> if not isinstance(value, (...
Same as the original implementation, but we guarantee that the resulting list of assets is in the correct order.
625941c1462c4b4f79d1d65c
def __init__(self, systemdef, **kwargs): <NEW_LINE> <INDENT> super(SimulationDefinition, self).__init__(**kwargs) <NEW_LINE> self.sys = systemdef
Creates a new definition or loads one from a file. Parameters ---------- systemdef: :py:class:`SystemDefinition` A system definition for which this simulation is defined. This system definition is stored in :py:attr:`sys`, from where it can be modified. fname : str, optional See :py:class:`IDefinition`...
625941c129b78933be1e563b
def validate(self): <NEW_LINE> <INDENT> allowed_backbones = ['resnet18','resnet34','resnet50', 'resnet101', 'resnet152'] <NEW_LINE> backbone = self.backbone.split('_')[0] <NEW_LINE> if backbone not in allowed_backbones: <NEW_LINE> <INDENT> raise ValueError('Backbone (\'{}\') not in allowed backbones ({}).'.format(backb...
Checks whether the backbone string is correct.
625941c191f36d47f21ac47d
def game_won(self, board, player): <NEW_LINE> <INDENT> score = {'1': 0, '2': 0} <NEW_LINE> if (board[0] == board[4] == board[8] and board[0] != 0) or (board[2] == board[4] == board[6] and board[2] != 0): <NEW_LINE> <INDENT> self.running = False <NEW_LINE> <DEDENT> for i in range(0, 3): <NEW_LINE> <INDENT> if ...
Return the score of game, and set game.running = False if the game is done. The score is a dictionary, where the key '1' is the score of the Computer, and key '2' is the score of the Human. The winning player receives a score equal to 1, otherwise 0.
625941c18c0ade5d55d3e945
def deepnn(x): <NEW_LINE> <INDENT> with tf.name_scope('reshape'): <NEW_LINE> <INDENT> x_image = tf.reshape(x, [-1, 28, 28, 1]) <NEW_LINE> <DEDENT> with tf.name_scope('conv1'): <NEW_LINE> <INDENT> W_conv1 = weight_variable([5, 5, 1, 32]) <NEW_LINE> b_conv1 = bias_variable([32]) <NEW_LINE> h_conv1 = tf.nn.relu(conv2d(x_i...
deepnn builds the graph for a deep net for classifying digits. Args: x: an input tensor with the dimensions (N_examples, 784), where 784 is the number of pixels in a standard MNIST image. Returns: A tuple (y, keep_prob). y is a tensor of shape (N_examples, 10), with values equal to the logits of class...
625941c115baa723493c3f00
def results(race_id): <NEW_LINE> <INDENT> return _request("Results", {"RaceId": race_id})
Race results :param race_id: race identifier, get it by calling competitions(event_id) :return: list of races :rtype: dict
625941c1187af65679ca50aa
def _clean_book_items(self): <NEW_LINE> <INDENT> output_name = self.convert.name <NEW_LINE> settings = get_sections_settings(self.original_book) <NEW_LINE> count = 1 <NEW_LINE> for toc_item in parse_toc_nav(self.original_book): <NEW_LINE> <INDENT> if isinstance(toc_item[1], list): <NEW_LINE> <INDENT> section_title, cha...
Removes the items that are not supposed to be shown according to section settings
625941c1f548e778e58cd509
def pickPhase(self, evt): <NEW_LINE> <INDENT> _thisPick = {'time': self._pickTime(evt.pos()), 'amplitude': self.traceItem.getData()[1][int(evt.pos().x())], 'station_id': self.tr.id, 'station_lat': self.station.getCoordinates()[0], 'station_lon': self.station.getCoordinates()[1]} <NEW_LINE> self.station.parent.parent.ev...
Evoked when the trace graph is clicked
625941c1566aa707497f44f9
def save(self, *args, **kwargs): <NEW_LINE> <INDENT> return _algorithms.SpatialPooler_save(self, *args, **kwargs)
save(self, outStream)
625941c11b99ca400220aa3e
def get_season(self): <NEW_LINE> <INDENT> new_year_day = dt.date(year=self.searchdate.year, month=1, day=1) <NEW_LINE> intday = (self.searchdate - new_year_day).days + 1 <NEW_LINE> spring = range(80, 172) <NEW_LINE> summer = range(172, 264) <NEW_LINE> fall = range(264, 355) <NEW_LINE> if intday in spring: <NEW_LINE> <I...
Returns the Season of the date sent
625941c1d4950a0f3b08c2dd
def extract_Z2(self, method='regular', frac=0.5): <NEW_LINE> <INDENT> nz = self.Z.shape[1] <NEW_LINE> ind_z2 = np.zeros(nz) <NEW_LINE> if method == 'regular': <NEW_LINE> <INDENT> ix = np.arange(1 / frac - 1, nz, 1 / frac).astype(int) <NEW_LINE> ind_z2[ix] = 1 <NEW_LINE> Z2 = self.Z[:, ind_z2 == 1] <NEW_LINE> Z1 = self....
This function is used to split a big sample Z (dimension: nz x p, containing nz iid realisation of a random vector of size p) into two samples Z1 and Z2 (respectively of dimension nz1 x p and nz2 x p, with nz = nz1 + nz2). Further explanations in Ribes et al. (2012). :param method: str type of sampling used, for no...
625941c160cbc95b062c64cf
def export_metahuman_json2(ob, outputpath): <NEW_LINE> <INDENT> dict_channel = {} <NEW_LINE> for i in range(bpy.context.scene.frame_start, bpy.context.scene.frame_end): <NEW_LINE> <INDENT> bpy.context.scene.frame_set(i) <NEW_LINE> for block in ob.data.shape_keys.key_blocks: <NEW_LINE> <INDENT> if block.name != "Basis":...
export metahuman curve to json export the selected frame start frame end curve
625941c192d797404e304116
def eval(self, x, x_contains_var_shape=False): <NEW_LINE> <INDENT> x = np.asarray(x).copy() <NEW_LINE> if not x_contains_var_shape: <NEW_LINE> <INDENT> x = broadcast_to_shape(x, shape=self._shape, scheme='expand_left') <NEW_LINE> <DEDENT> x = cycle_axes(x, -self.ndim) <NEW_LINE> _y = None <NEW_LINE> if _y is None: <NEW...
Evaluate the probability distribution/mass at a given point/an array of given points. If `x` is a scalar, the probability distribution/mass function will be evaluated at the single point `x` for *all* different parameter values specified when constructing the object. If the parameter values are specified as *p*-dimens...
625941c1bd1bec0571d905bb
def request(self, method, url, query_params=None, headers=None, post_params=None, files_params=None): <NEW_LINE> <INDENT> response = None <NEW_LINE> if method == "GET": <NEW_LINE> <INDENT> response = requests.get(url, params=query_params, headers=headers, timeout=self._request_timeout) <NEW_LINE> <DEDENT> elif method =...
Makes the HTTP request using requests library. :raise requests.exceptions.RequestException :raise sphere_engine.exceptions.SphereEngineException
625941c13eb6a72ae02ec464
def symlink(self, src, dst): <NEW_LINE> <INDENT> self.debug("linking: '%s' -> '%s'" % (self.relpath(dst), self.relpath(src))) <NEW_LINE> if os.path.lexists(dst): <NEW_LINE> <INDENT> os.remove(dst) <NEW_LINE> <DEDENT> os.symlink(src, dst)
Like os.symlink, but overwrites dst and logs
625941c1d8ef3951e32434ca
def __getitem__(self, name): <NEW_LINE> <INDENT> return self._resources[name]
Get a Resource by name.
625941c124f1403a92600af5
def save(self): <NEW_LINE> <INDENT> click_css(self, '.save-button')
Clicks save button.
625941c101c39578d7e74dc8
def initialize(context): <NEW_LINE> <INDENT> content_types, constructors, ftis = atapi.process_types( atapi.listTypes(config.PROJECTNAME), config.PROJECTNAME) <NEW_LINE> for atype, constructor in zip(content_types, constructors): <NEW_LINE> <INDENT> utils.ContentInit( "%s: %s" % (config.PROJECTNAME, atype.portal_type),...
Register content types through Archetypes with Zope and the CMF.
625941c18c0ade5d55d3e946
def get( self, resource_group_name, cross_connection_name, **kwargs ): <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } <NEW_LINE> error_map.update(kwargs.pop('error_map', {})) <NEW_LINE> api_version = "2019...
Gets details about the specified ExpressRouteCrossConnection. :param resource_group_name: The name of the resource group (peering location of the circuit). :type resource_group_name: str :param cross_connection_name: The name of the ExpressRouteCrossConnection (service key of the circuit). :type cross_connection_name...
625941c115fb5d323cde0a99
def syrk(self, *args): <NEW_LINE> <INDENT> return _ndlml.matrix_syrk(self, *args)
syrk(matrix self, matrix A, double alpha, double beta, char const * type, char const * trans)
625941c1091ae35668666eef
def delete(self, user_id): <NEW_LINE> <INDENT> method_url = 'DELETE /api/users/{user_id}' <NEW_LINE> method_url = method_url.format(user_id=user_id) <NEW_LINE> return self._client._request(method_url)
Delete user. https://www.appveyor.com/docs/api/team/#delete-user
625941c1d18da76e23532460
def _pack(self, W1, W2, b1, b2): <NEW_LINE> <INDENT> return np.hstack((W1.ravel(), W2.ravel(), b1.ravel(), b2.ravel()))
Pack the coefficients and intercepts (W1,W2,b1,b2) from theta Parameters ---------- theta : array-like, shape (size(W1)*size(W2)*size(b1)*size(b2), 1) Contains concatenated flattened weights that represent the parameters "W1, W2, b1, b2" n_features : int Number of features
625941c11d351010ab855aa9
def __call__(self, entry): <NEW_LINE> <INDENT> new_entry = copy.copy(entry) <NEW_LINE> new_entry.clear() <NEW_LINE> new_entry.extend(self._process_tag(tag, value) for tag, value in entry) <NEW_LINE> return new_entry
Swap in-line links for markdown-style links. :returns: a modified copy of `entry`
625941c12eb69b55b151c83a
@skipif_yask <NEW_LINE> def test_forward_unroll(a, c, nt=5): <NEW_LINE> <INDENT> a.data[0, :] = 1. <NEW_LINE> c.data[0, :] = 1. <NEW_LINE> eqn_c = Eq(c.forward, c + 1.) <NEW_LINE> eqn_a = Eq(a.forward, c.forward) <NEW_LINE> Operator([eqn_c, eqn_a])(time=nt) <NEW_LINE> for i in range(nt): <NEW_LINE> <INDENT> assert np.a...
Test forward time marching with a buffered and an unrolled t
625941c10383005118ecf571
def filter_tag(self, trs): <NEW_LINE> <INDENT> q = Q() <NEW_LINE> if not self.slug: <NEW_LINE> <INDENT> q &= ~Q(resource__tag__isnull=True) <NEW_LINE> <DEDENT> if self.slug: <NEW_LINE> <INDENT> q &= Q(resource__tag__slug__contains=self.slug) <NEW_LINE> <DEDENT> if self.priority is not None: <NEW_LINE> <INDENT> if self....
Filters on tag.slug and tag.priority
625941c1de87d2750b85fd1d
def move_asynchronously(self, session, source_space, source_offset, source_width, destination_space, destination_offset, destination_width, length): <NEW_LINE> <INDENT> raise NotImplementedError
Moves a block of data asynchronously. Corresponds to viMoveAsync function of the VISA library. :param session: Unique logical identifier to a session. :param source_space: Specifies the address space of the source. :param source_offset: Offset of the starting address or register from which to read. :param source_widt...
625941c1097d151d1a222de8
def _planePositionChanged(self, source, *args, **kwargs): <NEW_LINE> <INDENT> if self.__plane.visible: <NEW_LINE> <INDENT> self._updated(ItemChangedType.POSITION)
Handle update of cut plane position and normal
625941c17b25080760e393e7
def translate_lines(self): <NEW_LINE> <INDENT> self.turing_code = ["# -*- coding: utf-8 -*-"] <NEW_LINE> self.turing_code.append("") <NEW_LINE> for s in self.raw_lines: <NEW_LINE> <INDENT> if s.strip() == "": <NEW_LINE> <INDENT> self.turing_code.append(s) <NEW_LINE> <DEDENT> elif s[0] == "/": <NEW_LINE> <INDENT> self.t...
Takes the list of lines in the input file and classifies each line as either a comment line or a code line. Comment lines have '#' appended, while code lines are reformatted for use in constructing _CodeLine objects.
625941c116aa5153ce362405
def wheelEvent(self, event): <NEW_LINE> <INDENT> if event.modifiers() & QtCore.Qt.ControlModifier == QtCore.Qt.ControlModifier: <NEW_LINE> <INDENT> if event.delta() > 0: <NEW_LINE> <INDENT> self.zoom_in() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.zoom_out() <NEW_LINE> <DEDENT> <DEDENT> else: <NE...
Overloaded to zoom/unzoom the image when the Ctrl key is pressed.
625941c1442bda511e8be3a8
def isSubtree(self, s, t): <NEW_LINE> <INDENT> def convert(p): <NEW_LINE> <INDENT> return "#" + str(p.val) + convert(p.left) + convert(p.right) if p else "$" <NEW_LINE> <DEDENT> return convert(t) in convert(s) <NEW_LINE> stack = [] <NEW_LINE> res = [] <NEW_LINE> stack.append(s) <NEW_LINE> node = None <NEW_LINE> x = 0 <...
:type s: TreeNode :type t: TreeNode :rtype: bool
625941c132920d7e50b2815b
def generate_nagios_service_cfg(): <NEW_LINE> <INDENT> pass
Returns a body of the configuraton file for the services currently monitored by the agent.
625941c1377c676e91272136
def _texture(func): <NEW_LINE> <INDENT> def inner(name, *args, **kwargs): <NEW_LINE> <INDENT> if isinstance(name, types.Texture): <NEW_LINE> <INDENT> texture = name <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> texture = data.textures[name] <NEW_LINE> <DEDENT> return func(texture, *args, **kwargs) <NEW_LINE> <DEDENT> r...
:param func:
625941c182261d6c526ab429
def items(self, category): <NEW_LINE> <INDENT> addons, _, _ = addon_listing(self.request, [self.TYPE], default='updated') <NEW_LINE> if category: <NEW_LINE> <INDENT> addons = addons.filter(categories__id=category.id) <NEW_LINE> <DEDENT> return addons[:30]
Return the Addons for this Category to be output as RSS <item>'s
625941c150812a4eaa59c2b1
def string2number(i): <NEW_LINE> <INDENT> return int(i.encode('hex'), 16)
Convert a string to a number Input: string (big-endian) Output: long or integer
625941c14c3428357757c2b7
def test_invalidate_existing_token_twice(self): <NEW_LINE> <INDENT> first_response = self.client.post(self.api_url) <NEW_LINE> second_response = self.client.post(self.api_url) <NEW_LINE> self.assertEqual(first_response.status_code, status.HTTP_200_OK) <NEW_LINE> self.assertEqual(second_response.status_code, status.HTTP...
Try to invalidate a token twice and expect an error
625941c1460517430c394117
def get_sub_items(item_url): <NEW_LINE> <INDENT> bf = visit_web(item_url) <NEW_LINE> sub_items = {} <NEW_LINE> try: <NEW_LINE> <INDENT> all_sub = bf.find('div', class_='sub-items') <NEW_LINE> sub_list = all_sub.find_all('a') <NEW_LINE> for sub in sub_list: <NEW_LINE> <INDENT> sub_items[sub.string] = sub.get('href') <NE...
二级区域
625941c150485f2cf553cd26
def test_unknown_offset_raises_error(): <NEW_LINE> <INDENT> with pytest.raises(ValueError): <NEW_LINE> <INDENT> assert parse_date("(2018-01-01) + 1century", "%Y-%m-%d")
It should raise an exception when an invalid offset is used.
625941c197e22403b379cf26
def _live(city): <NEW_LINE> <INDENT> return add_metadata(parse_html(city, get_html(city)))
Scrape data for a given city pulling all data now This function is only used in development mode for debugging the server without a database present.
625941c126068e7796caec68
def insertForwardIndexEntry(self, entry, documentId): <NEW_LINE> <INDENT> length = self._length <NEW_LINE> index_length = self._index_length <NEW_LINE> if index_length is None: <NEW_LINE> <INDENT> self._inline_migration() <NEW_LINE> length = self._length <NEW_LINE> index_length = self._index_length <NEW_LINE> <DEDENT> ...
If the value matches the indexed one, insert into treeset
625941c1099cdd3c635f0be9
def _random_pd_matrix(n, rng): <NEW_LINE> <INDENT> temp = rng.randn(n, n) <NEW_LINE> return temp.dot(temp.T)
Random postive definite matrix.
625941c1eab8aa0e5d26dae5
@check_mlist_private <NEW_LINE> def thread_index(request, mlist_fqdn, threadid, month=None, year=None): <NEW_LINE> <INDENT> mlist = get_object_or_404(MailingList, name=mlist_fqdn) <NEW_LINE> thread = get_object_or_404(Thread, mailinglist=mlist, thread_id=threadid) <NEW_LINE> starting_email = thread.starting_email <NEW_...
Displays all the email for a given thread identifier
625941c1de87d2750b85fd1e
def disallow_discussion(self, request, queryset): <NEW_LINE> <INDENT> queryset.update(allow_discussion=False) <NEW_LINE> self.message_user(request, u'Document(s) no longer allow discussion.')
Disallow discussion on several documents.
625941c130bbd722463cbd51
def capture(self, args): <NEW_LINE> <INDENT> commit = self.__get_newest_commit() <NEW_LINE> print(self.__make_macro(**commit))
Capture the most recent commit and macro it!
625941c1ac7a0e7691ed405d
def test_my_implementation(): <NEW_LINE> <INDENT> from implementation import CarDynamics, CarCommands, CarParameters <NEW_LINE> from check import check_car_dynamics_correct <NEW_LINE> klass = CarDynamics <NEW_LINE> commands = CarCommands <NEW_LINE> params = CarParameters <NEW_LINE> check_car_dynamics_correct(klass,comm...
This will be run by nose
625941c1009cb60464c63340
def result_summary(self): <NEW_LINE> <INDENT> return result_summary(self.results.all())
Return a dict summarizing status of results.
625941c17047854f462a1399
def set_mew(self, val): <NEW_LINE> <INDENT> self.set_markeredgewidth(val)
alias for set_markeredgewidth
625941c1004d5f362079a2c2
def get_selector_config(self): <NEW_LINE> <INDENT> if "selector" not in self._suite_config: <NEW_LINE> <INDENT> return {} <NEW_LINE> <DEDENT> selector = self._suite_config["selector"].copy() <NEW_LINE> if self.options.include_tags is not None: <NEW_LINE> <INDENT> if "include_tags" in selector: <NEW_LINE> <INDENT> selec...
Returns the "selector" section of the YAML configuration.
625941c126068e7796caec69
def _receive_message(self, queue_name: str) -> typing.Union[None, str]: <NEW_LINE> <INDENT> response = self._get_per_thread_client().receive_message( QueueUrl=self._get_per_queue_url(queue_name=queue_name), AttributeNames=["All"], MessageAttributeNames=["All"], MaxNumberOfMessages=self.MaxNumberOfMessages, VisibilityTi...
Retrieves one or more messages (up to 10), from the specified queue. Using the WaitTimeSeconds parameter enables long-poll support. 1. https://botocore.amazonaws.com/v1/documentation/api/latest/reference/services/sqs.html#SQS.Client.receive_message
625941c1a8ecb033257d305b
def update_sheet_activity(sheet_name, force=False): <NEW_LINE> <INDENT> name = 'ActivityBuffer' <NEW_LINE> sheet = topo.sim.objects(Sheet)[sheet_name] <NEW_LINE> view = sheet.views.Maps.get(name, False) <NEW_LINE> time = topo.sim.time() <NEW_LINE> metadata = AttrDict(precedence=sheet.precedence, row_precedence=sheet.ro...
Update the '_activity_buffer' SheetStack for a given sheet by name. If force is False and the existing Activity SheetView isn't stale, the existing view is returned.
625941c199fddb7c1c9de31f
def test_group_by_params_with_and_string_success(self): <NEW_LINE> <INDENT> group_by_params = {'and:account': 'account1,account2'} <NEW_LINE> serializer = GroupBySerializer(data=group_by_params) <NEW_LINE> self.assertTrue(serializer.is_valid())
Test that the and: prefix is allowed with a string of items.
625941c110dbd63aa1bd2b32
def check_reboot(): <NEW_LINE> <INDENT> return os.path.exists("/run/reboot-required")
Return true if the computer has a pending reboot.
625941c1d53ae8145f87a201
def colour_code_segmentation(image, label_values): <NEW_LINE> <INDENT> colour_codes = np.array(label_values) <NEW_LINE> x = colour_codes[image.astype(int)] <NEW_LINE> return x
Given a 1-channel array of class keys, colour code the segmentation results. # Arguments image: single channel array where each value represents the class key. label_values # Returns Colour coded image for segmentation visualization
625941c11d351010ab855aaa
def fix_files( in_dir: pathlib.Path, out_dir: pathlib.Path, *, transformer=networkconnectivityCallTransformer(), ): <NEW_LINE> <INDENT> pyfile_gen = ( pathlib.Path(os.path.join(root, f)) for root, _, files in os.walk(in_dir) for f in files if os.path.splitext(f)[1] == ".py" ) <NEW_LINE> for fpath in pyfile_gen: <NEW_LI...
Duplicate the input dir to the output dir, fixing file method calls. Preconditions: * in_dir is a real directory * out_dir is a real, empty directory
625941c14e4d5625662d4368
def __init__(self, email=None, password=None, local_vars_configuration=None): <NEW_LINE> <INDENT> if local_vars_configuration is None: <NEW_LINE> <INDENT> local_vars_configuration = Configuration() <NEW_LINE> <DEDENT> self.local_vars_configuration = local_vars_configuration <NEW_LINE> self._email = None <NEW_LINE> self...
LoginParams - a model defined in OpenAPI
625941c1d486a94d0b98e0d3
def ParseFileObject(self, parser_mediator, file_object): <NEW_LINE> <INDENT> regf_file = pyregf.file() <NEW_LINE> try: <NEW_LINE> <INDENT> regf_file.open_file_object(file_object) <NEW_LINE> <DEDENT> except IOError: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> root_key = regf_file.get_key_by_path('Root') <NEW_LINE> if...
Parses an AMCache.hve file-like object for events. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. file_object (dfvfs.FileIO): file-like object.
625941c13617ad0b5ed67e86
def get_commit(deployment): <NEW_LINE> <INDENT> version = deployment_util.get_application_version(deployment) <NEW_LINE> return version[(version.find('_') + 1):]
The version is in format "8.11.0_713eef5s", the last part is the git commit hash.
625941c1167d2b6e31218b23
def __load_config(self) -> Dict[str, Any]: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open(self.file, 'r') as f: <NEW_LINE> <INDENT> return yaml.safe_load(f) <NEW_LINE> <DEDENT> <DEDENT> except yaml.YAMLError as ye: <NEW_LINE> <INDENT> log.log(logging.ERROR, f'Error in YAML file {self.file}') <NEW_LINE> if hasat...
Loads YAML configuration file to Python dictionary. Does some basic error checking to help with debugging bad configuration files.
625941c13cc13d1c6d3c7308
@app.route('/genre/new/', methods=['GET', 'POST']) <NEW_LINE> def newGenre(): <NEW_LINE> <INDENT> if 'username' not in login_session: <NEW_LINE> <INDENT> return redirect('/login') <NEW_LINE> <DEDENT> if request.method == 'POST': <NEW_LINE> <INDENT> if not (session .query(Genre).filter_by(name=request.form['name']).firs...
Render template to add new genre and handle post request.
625941c1cc40096d615958df
def to_binary(self): <NEW_LINE> <INDENT> c = containerize(exclude_fields(self)) <NEW_LINE> self.payload = MsgLog._parser.build(c) <NEW_LINE> return self.pack()
Produce a framed/packed SBP message.
625941c14f88993c3716bff7
def parse(self): <NEW_LINE> <INDENT> CommentPat = re.compile(r'^\s*#.*') <NEW_LINE> LinePat = re.compile(r'^\s*(.+):\s*(.+)?\s*') <NEW_LINE> with self.path.open() as f: <NEW_LINE> <INDENT> for lineno, line in enumerate(f): <NEW_LINE> <INDENT> lineno += 1 <NEW_LINE> if line == "\n": continue <NEW_LINE> if CommentPat.mat...
Parses the file at self.path and yields all found 'key: value' pairs as a stream of KeyValue objects
625941c1cc0a2c11143dce1e
def remap(self, src): <NEW_LINE> <INDENT> return cv2.remap(src, self.mapx, self.mapy, cv2.INTER_LINEAR)
:param src: source image :type src: :class:`cvMat` Apply the post-calibration undistortion to the source image
625941c1293b9510aa2c3225
def create_member(self, pool_id, address, protocol_port, prefix = '', member_body = None, **kwargs): <NEW_LINE> <INDENT> _body = { "pool_id":pool_id, "address":address, "protocol_port":protocol_port } <NEW_LINE> if member_body and type(member_body) == dict : <NEW_LINE> <INDENT> _body.update(member_body) <NEW_LINE> <DED...
Creates a new load balancer member. :param pool_id: ID of the pool. :param address: IP address. :param protocol_port: Port number. :param kwargs: other values.
625941c144b2445a33932025
def test_post_email_already_verified(self): <NEW_LINE> <INDENT> user = UserFactory.create(email_verified=True) <NEW_LINE> data = {'email': user.email} <NEW_LINE> request = self.create_request('post', auth=False, data=data) <NEW_LINE> view = self.view_class.as_view() <NEW_LINE> response = view(request) <NEW_LINE> self.a...
Assert email already verified does not trigger another email.
625941c163b5f9789fde7073
def json_serial_datetime(obj): <NEW_LINE> <INDENT> if isinstance(obj, datetime): <NEW_LINE> <INDENT> serial = obj.strftime('%d/%m/%Y - %H:%M:%S') <NEW_LINE> return serial
Converts a datetime object to a string :param obj: datetime object :return:
625941c145492302aab5e24f
def label_encoder(column): <NEW_LINE> <INDENT> return LabelEncoder().fit_transform(column)
Converts categorical data to numerical data
625941c15f7d997b87174a23
def _get_date_filter(self): <NEW_LINE> <INDENT> ranges = { 'year': [ "EXTRACT('year' FROM {}.{}) = EXTRACT('year' FROM {})", ], 'month': [ "EXTRACT('year' FROM {}.{}) = EXTRACT('year' FROM NOW())", "EXTRACT('month' FROM {}.{}) = EXTRACT('month' FROM {})", ], 'week': [ "EXTRACT('year' FROM {}.{}) = EXTRACT('year' FROM N...
Contains a partition filter for date partition subtype
625941c1507cdc57c6306c64
def hasNext(self): <NEW_LINE> <INDENT> return bool(self.vectors)
:rtype: bool
625941c1f8510a7c17cf9689
def containment_radius(self, fraction, factor=20, **kwargs): <NEW_LINE> <INDENT> from gammapy.datasets.map import RAD_AXIS_DEFAULT <NEW_LINE> output = np.broadcast(*kwargs.values(), fraction) <NEW_LINE> try: <NEW_LINE> <INDENT> rad_axis = self.axes["rad"] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> rad_axi...
Containment radius at given axes coordinates Parameters ---------- fraction : float or `~numpy.ndarray` Containment fraction factor : int Up-sampling factor of the rad axis, determines the precision of the computed containment radius. **kwargs : dict Other coordinates Returns ------- radius : `~astrop...
625941c121bff66bcd6848e2
def get_localities(self): <NEW_LINE> <INDENT> return list(self.instances.keys())
Returns the list of available localities that are currently in the collection
625941c17047854f462a139a
def analyzemymeeting(indir, nspeakers, sr=16000, frame_size=50e-3, frame_step=25e-3, outdir=False): <NEW_LINE> <INDENT> fn = os.path.join(indir, os.listdir(indir)[0]) <NEW_LINE> y, sr = librosa.load(fn, sr=sr) <NEW_LINE> duration = librosa.get_duration(y, sr=sr) <NEW_LINE> y = (y - y.mean()) / ((np.abs(y)).max() + 0.00...
Parameters ---------- indir : .wav file location e.g. 'data/diarization/diarizationExample.wav' sr : sampling freq, default=16kHz frame_size : n_fft in librosa, default 50 ms frame_step : hop_length in librosa, default 25 ms nspeakers : number of speakers in meeting (int)
625941c12c8b7c6e89b35750
def GetInstance(self, request, timeout, metadata=None, with_call=False, protocol_options=None): <NEW_LINE> <INDENT> raise NotImplementedError()
Gets instance information.
625941c1adb09d7d5db6c71f
def create_dataset(data, seq_len=3, tt_split=0.90, normalise=True, pad=None): <NEW_LINE> <INDENT> import numpy as np <NEW_LINE> sequence_length = seq_len + 1 <NEW_LINE> if (pad): <NEW_LINE> <INDENT> sequence_length = pad+1 <NEW_LINE> <DEDENT> result = [] <NEW_LINE> data_np = np.array(data) <NEW_LINE> data_fl = data_np....
Convert an array of data into LSTM format test and train sequences :param data: array of data to convert :param seq_len: lookback value for number of entries per LSTM timestep: default 3 :param tt_split: ratio of training data to test data: default = .90 :param normalise_window: optional normalize :param pad: optional ...
625941c131939e2706e4cdfa
def _silent_restorecon(self, path): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if selinux.is_selinux_enabled(): <NEW_LINE> <INDENT> selinux.restorecon(path) <NEW_LINE> <DEDENT> <DEDENT> except: <NEW_LINE> <INDENT> self.logger.error("restorecon %s failed" % path, exc_info=True)
Execute selinux restorecon cmd to determined file Args path -- full path to file
625941c13346ee7daa2b2cf8
def frm_idx2angle(bw, i, j, k): <NEW_LINE> <INDENT> from math import pi, floor <NEW_LINE> phe=i*pi/bw <NEW_LINE> phc=j*pi/bw <NEW_LINE> ohm=k*pi/bw <NEW_LINE> phi = pi-ohm; phi -= 2.0*pi*floor(phi/2.0/pi) <NEW_LINE> the = pi-phc <NEW_LINE> psi = -phe; psi -= 2.0*pi*floor(psi/2.0/pi) <NEW_LINE> return [psi*180.0/pi, phi...
Transfer the index from correlation volume to the actual Euler angles in ZXZ convention (degree). Note the order of the returned Euler angle is [Phi, Psi, Theta], or [Z1, Z2, X] in Pytom format. Parameters ---------- bw: Bandwidth of the spherical harmonics. Integer i: First index of the correlation volume. In...
625941c13346ee7daa2b2cf9
def smoke_test(self): <NEW_LINE> <INDENT> input_size = 4 <NEW_LINE> input_length = 4 <NEW_LINE> batch_size = 2 <NEW_LINE> n_units = 4 <NEW_LINE> cell = ESNCell(n_units) <NEW_LINE> inputs = np.random.random([input_length, batch_size, input_size]) <NEW_LINE> state = cell.zero_state(batch_size, tf.float64) <NEW_LINE> for ...
A simple smoke test with random initialization
625941c1be8e80087fb20bd4
def run(game=Hangman(), flash=FlashMessage()): <NEW_LINE> <INDENT> GameClass, FlashClass = game.__class__, flash.__class__ <NEW_LINE> while True: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> game_loop(game=game, flash=flash) <NEW_LINE> <DEDENT> except KeyboardInterrupt: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> if ...
Run ``game_loop`` and handle exiting. Logic is separated from game_loop to cleanly avoid python recursion limits. :param hangman.model.Hangman game: Hangman game instance. :param hangman.utils.FlashMessage flash: FlashMessage utility
625941c18a43f66fc4b53ff5
def dp(): <NEW_LINE> <INDENT> global lis <NEW_LINE> ways = [1 for i in range(30001)] <NEW_LINE> for i in range(4): <NEW_LINE> <INDENT> for k in range(30001): <NEW_LINE> <INDENT> if k >= lis[i]: <NEW_LINE> <INDENT> ways[k] += ways[k-lis[i]] <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return ways
Se utiliza dinamica bottom-up para calcular todas las maneras hasta 30000 La funcion retorna la lista de maneras de obtener el cambio hasta 30000
625941c130bbd722463cbd52
def create_nodes(self, node, depth): <NEW_LINE> <INDENT> for index in range(0, self.depth): <NEW_LINE> <INDENT> work = [] <NEW_LINE> self.logger.info('Creating tree level %s' % (index + 1)) <NEW_LINE> for node in self.traverse( self.rootNode, node_filter=lambda n: n.level == index ): <NEW_LINE> <INDENT> work.append((no...
Build up tree
625941c1be383301e01b5418
def compare_full_name(list_of_records, email, first_name, last_name): <NEW_LINE> <INDENT> for rec in list_of_records: <NEW_LINE> <INDENT> if rec[1].get("first_name") == first_name and rec[1].get("last_name") == last_name: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> return False
fill in docstring
625941c10383005118ecf572
def gen_cups_display(cups, current, position): <NEW_LINE> <INDENT> index = cups.index(current) <NEW_LINE> if index != position: <NEW_LINE> <INDENT> cups = rotate_string(cups, position - index) <NEW_LINE> <DEDENT> string = "" <NEW_LINE> for i in cups: <NEW_LINE> <INDENT> if i == current: <NEW_LINE> <INDENT> string += f"...
Return a string to display of cups.
625941c1627d3e7fe0d68ddd
def calculate_adv_and_value_targets(self, vals, rews, lam=None): <NEW_LINE> <INDENT> if self.adv_estimation_method == 'gae': <NEW_LINE> <INDENT> lam = self.lam if lam is None else lam <NEW_LINE> deltas = rews[:-1] + self.gamma * vals[1:] - vals[:-1] <NEW_LINE> adv = discount_cumsum(deltas, self.gamma * lam) <NEW_LINE> ...
Compute the estimated advantage
625941c13539df3088e2e2da
def _post(self, which_port, msg): <NEW_LINE> <INDENT> return _ccsds_swig.rs_decode_sptr__post(self, which_port, msg)
_post(rs_decode_sptr self, swig_int_ptr which_port, swig_int_ptr msg)
625941c1b830903b967e989c
def isStringStyle(self, style): <NEW_LINE> <INDENT> return style in [QsciLexerIDL.DoubleQuotedString, QsciLexerIDL.SingleQuotedString, QsciLexerIDL.UnclosedString, QsciLexerIDL.VerbatimString]
Public method to check, if a style is a string style. @param style style to check (integer) @return flag indicating a string style (boolean)
625941c11b99ca400220aa3f
def getProximityIntEnable(self): <NEW_LINE> <INDENT> return (self._read_byte_data(REG_ENABLE) >> 5) & 0b00000001
Gets if proximity interrupts are enabled or not. Returns: bool: True if interrupts are enabled, False if not
625941c1851cf427c661a4a0
def pre_translation(self, query): <NEW_LINE> <INDENT> pass
In order to keep the API the same, Bugzilla4 needs to process the query and the result. This also applies to the refresh() function
625941c1956e5f7376d70dfd
def update(self, instance, validated_data): <NEW_LINE> <INDENT> current_password = validated_data.get('current_password') <NEW_LINE> for attr, value in validated_data.items(): <NEW_LINE> <INDENT> if attr == 'password': <NEW_LINE> <INDENT> if not instance.check_password(current_password): <NEW_LINE> <INDENT> raise seria...
Override update method to handle password change.
625941c1d8ef3951e32434cc
def _show_message(self, message, message_color=(255,255,255), background_color=(0, 0, 0)): <NEW_LINE> <INDENT> self._sense_hat.rotation = 0 <NEW_LINE> self._sense_hat.show_message(message, self.config.getfloat("PI_HAT_DISPLAY", "SCROLL_TEXT_SPEED"), message_color, background_color)
Internal. Shows message by scrolling it over HAT screen.
625941c18a43f66fc4b53ff6
def defineVariable(self, name='', value=''): <NEW_LINE> <INDENT> if not pmta.PmtaRcptDefineVariable(self.recipient, c_char_p(name), c_char_p(value)): <NEW_LINE> <INDENT> raise PmtaRecipientError(self.recipient)
used to bind mailmerge variable to a recipient. name: string for mailmerge variable's name value: string for mailmerge variable's value
625941c1dd821e528d63b139
def test_init(self): <NEW_LINE> <INDENT> msg = 'Object is not an top.Xlwriter' <NEW_LINE> self.assertIsInstance(self._x, top.Xlwriter, msg)
Initialise a Xlwriter object.
625941c18a349b6b435e8102
def emit(self, record): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> import smtplib <NEW_LINE> import ssl <NEW_LINE> from email.utils import formatdate <NEW_LINE> port = self.mailport <NEW_LINE> if not port: <NEW_LINE> <INDENT> port = smtplib.SMTP_SSL_PORT <NEW_LINE> <DEDENT> smtp = smtplib.SMTP_SSL(self.mailhost, port...
Overwrite the logging.handlers.SMTPHandler.emit function with SMTP_SSL. Emit a record. Format the record and send it to the specified addressees.
625941c124f1403a92600af7
def render_to_window(self): <NEW_LINE> <INDENT> if not self._onscreen_renderer: <NEW_LINE> <INDENT> self._onscreen_renderer = mujoco_py.MjViewer(self._sim) <NEW_LINE> self._update_camera_properties(self._onscreen_renderer.cam) <NEW_LINE> <DEDENT> self._onscreen_renderer.render()
Renders the simulation to a window.
625941c115fb5d323cde0a9b
def percent(self, key): <NEW_LINE> <INDENT> return float(self[key])/sum(self.values())
Returns what percentage a certain key is of all entries. >>> c = counter() >>> c.add('x') >>> c.add('x') >>> c.add('x') >>> c.add('y') >>> c.percent('x') 0.75 >>> c.percent('y') 0.25
625941c123849d37ff7b301f
def test_graphics_screen_rotation(): <NEW_LINE> <INDENT> print('\nTest the 4 different screen rotations, accept each one') <NEW_LINE> for rotation in ['landscape', 'landscape reverse', 'portrait', 'portrait reverse']: <NEW_LINE> <INDENT> PICASO.clear_screen() <NEW_LINE> print('= ' + rotation) <NEW_LINE> PICASO.screen_m...
Test the different screen rotations
625941c1b545ff76a8913da5
def __init__(self, movie_title, movie_year, imdb_rating, movie_storyline, poster_image, trailer_youtube): <NEW_LINE> <INDENT> self.title = movie_title <NEW_LINE> self.year = movie_year <NEW_LINE> self.imdbRating = imdb_rating <NEW_LINE> self.storyline = movie_storyline <NEW_LINE> self.poster_image_url = poster_image <N...
Init Movie instance
625941c1bf627c535bc1315d
def hit_string(target_str,str_list): <NEW_LINE> <INDENT> hit = False <NEW_LINE> for str in str_list: <NEW_LINE> <INDENT> if target_str in str: <NEW_LINE> <INDENT> hit = True <NEW_LINE> break <NEW_LINE> <DEDENT> <DEDENT> return hit
验证target_str是否在str_list中匹配到(字符串patial匹配)
625941c18e7ae83300e4af5b
def p_factor(p): <NEW_LINE> <INDENT> if p[1]==[]: <NEW_LINE> <INDENT> p[0]=p[2] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if get_type(p[2])=='INT': <NEW_LINE> <INDENT> type='INT' <NEW_LINE> ending='I' <NEW_LINE> <DEDENT> elif get_type(p[2])=='FLOAT': <NEW_LINE> <INDENT> type='FLOAT' <NEW_LINE> ending='F' <NEW_LINE>...
factor : factor_prefix postfix_expr
625941c163d6d428bbe4447e
def add_candidates(self, sample, seed): <NEW_LINE> <INDENT> rand = random.Random(seed) <NEW_LINE> if 'label_candidates' in sample: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> label = sample['labels'][0] <NEW_LINE> negs = [] <NEW_LINE> while len(negs) < 15: <NEW_LINE> <INDENT> neg_idx = rand.randint(0, len(self.all_c...
Add 16 candidates. Should be called only at train time.
625941c10383005118ecf573
def pop(self): <NEW_LINE> <INDENT> if self.is_empty(): <NEW_LINE> <INDENT> raise ValueError("No values in stack to POP") <NEW_LINE> <DEDENT> self.size -= 1 <NEW_LINE> return self.list.pop()
Remove and return the item on the top of this stack, or raise ValueError if this stack is empty. Running time: O(???) – Why? [TODO]
625941c1507cdc57c6306c65
def jobconf(self): <NEW_LINE> <INDENT> unfiltered_jobconf = combine_dicts(self.JOBCONF, self.options.jobconf) <NEW_LINE> filtered_jobconf = {} <NEW_LINE> def format_hadoop_version(v_float): <NEW_LINE> <INDENT> if v_float >= 1.0: <NEW_LINE> <INDENT> return '%.1f' % v_float <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> r...
``-jobconf`` args to pass to hadoop streaming. This should be a map from property name to value. By default, this combines :option:`jobconf` options from the command lines with :py:attr:`JOBCONF`, with command line arguments taking precedence. If :py:attr:`SORT_VALUES` is set, we also set these jobconf values:: ...
625941c1de87d2750b85fd1f