code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def token(self, token): <NEW_LINE> <INDENT> self.deviceToken = token <NEW_LINE> return self
Add deviceToken in binary format.
625941e4a934411ee3751aa6
def __init__(self, path, title=None): <NEW_LINE> <INDENT> self.__title = title <NEW_LINE> self.__files = [_VerseFile(text) for text in path.glob('*.txt') if text.is_file()] <NEW_LINE> self.__files.sort(key=VerseLibrary.TITLE)
Initialize instance's variables from information in directory.
625941e45fc7496912cc3d90
def convert_type(self, old_type, new_type): <NEW_LINE> <INDENT> for seg in self.compartment_list: <NEW_LINE> <INDENT> if seg[NODE_TYPE] == old_type: <NEW_LINE> <INDENT> seg[NODE_TYPE] = new_type
Converts all compartments from one type to another. Nodes of the original type are not affected so this procedure can also be used as a merge procedure. Parameters ---------- old_type: enum The compartment type to be changed. Use one of the following constants: SOMA, AXON, DENDRITE, BASAL_DENDRITE, or APIC...
625941e4e8904600ed9f2345
def test_aoa_badge(self): <NEW_LINE> <INDENT> year = date.today().year <NEW_LINE> u = UserFactory() <NEW_LINE> b = BadgeFactory( slug=AOA_BADGE['slug'].format(year=year), title=AOA_BADGE['title'].format(year=year), description=AOA_BADGE['description'].format(year=year)) <NEW_LINE> for _ in range(49): <NEW_LINE> <INDENT...
Verify the KB Badge is awarded properly.
625941e4ec188e330fd5aba9
def php_setup(): <NEW_LINE> <INDENT> php_ini_path = os.path.join(DEST_DIR, 'etc/php/php.ini') <NEW_LINE> with open(php_ini_path, 'r') as php_ini: <NEW_LINE> <INDENT> lines = php_ini.readlines() <NEW_LINE> <DEDENT> so_extensions = [ "mysql", "mcrypt", "mssql", "mysqli", "openssl", "iconv", "imap", "zip", "bz2"] <NEW_LIN...
Setup /etc/php/php.ini
625941e410dbd63aa1bd2fb4
def readElementText(self, QXmlStreamReader_ReadElementTextBehaviour=None): <NEW_LINE> <INDENT> return QString
QXmlStreamReader.readElementText() -> QString QXmlStreamReader.readElementText(QXmlStreamReader.ReadElementTextBehaviour) -> QString
625941e491f36d47f21ac909
def search(request, query): <NEW_LINE> <INDENT> current_basic_user = get_current_user(request, User, ObjectDoesNotExist) <NEW_LINE> current_basic_user_profile = get_current_user_profile( request, User, BasicUserProfile, ObjectDoesNotExist ) <NEW_LINE> topics_to_follow = get_topics_to_follow(Topic, ObjectDoesNotExist, r...
in this page the users can search other users
625941e46fb2d068a760f4b5
def attributes(self): <NEW_LINE> <INDENT> attributes = set() <NEW_LINE> for mapping in self.itervalues(): <NEW_LINE> <INDENT> attributes.update(mapping.attributes()) <NEW_LINE> <DEDENT> return list(attributes)
Return the list of attributes that are referenced in this attribute mapping. These are the attributes that should be requested in the search.
625941e40a366e3fb873ec30
def __init__(self, bot, mapping=None): <NEW_LINE> <INDENT> self.bot = bot <NEW_LINE> self.mapping = mapping
Init. map: a dictionary mapping a key to to an emoji name.
625941e4d53ae8145f87a67a
def _ignore(self, doi, other_dict): <NEW_LINE> <INDENT> if doi in self.ignored: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> elif doi not in other_dict: <NEW_LINE> <INDENT> self.ignored.add(doi) <NEW_LINE> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False
Ignore the DOI if it is not found in the other dictionary and record the DOI in self.ignored. The ignored instance var must be initialized before calling this method as a set. Returns True if ignored was initialized and the DOI isn't a key in the other dictionary, False otherwise.
625941e494891a1f4081bebd
def linear_activation_backward(dA, cache, activation): <NEW_LINE> <INDENT> linear_cache, activation_cache = cache <NEW_LINE> if activation == "relu": <NEW_LINE> <INDENT> dZ = relu_backward(dA, activation_cache) <NEW_LINE> dA_prev, dW, db = linear_backward(dZ, linear_cache) <NEW_LINE> <DEDENT> elif activation == "sigmoi...
Implement the backward propagation for the LINEAR->ACTIVATION layer. Arguments: dA -- post-activation gradient for current layer l cache -- tuple of values (linear_cache, activation_cache) we store for computing backward propag activation -- the activation to be used in this layer, stored as a text string: "sigmoid" or...
625941e4ac7a0e7691ed44d7
def applyMethod(self, name): <NEW_LINE> <INDENT> if DEBUG: <NEW_LINE> <INDENT> self.methodDict[name][0]() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.methodDict[name][0]() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> print(sys.exc_info()) <NEW_LINE> raise
The plugin is asked to apply the method associated to name.
625941e476d4e153a657ef44
def channel_3(self, value): <NEW_LINE> <INDENT> self._channel(3, value)
input from scratch to adapter, value = 0..100
625941e4d268445f265b5281
def test_match_state(self): <NEW_LINE> <INDENT> state = '1111111111111111' <NEW_LINE> for j in range(10): <NEW_LINE> <INDENT> self.p1.predictors[j].used = 1 <NEW_LINE> self.p1.predictors[j].accuracy = j / 100 <NEW_LINE> <DEDENT> self.p1._match_state(state) <NEW_LINE> self.assertEqual(len(self.p1.current), 1) <NEW_LINE>...
With numpy random seed == 39, the Chromosomes are: 0. Chromosome(2222222222222222, 00000000, 0.02) 1. Chromosome(2221222222222222, 10100011, 0.02) 2. Chromosome(0222222121221222, 11000110, 0.02) 3. Chromosome(2222122022122222, 10100101, 0.02) 4. Chromosome(2220222022222222, 11101011, 0.02) 5. Chromosome(222122222222220...
625941e463d6d428bbe44903
def __init__(self, compresslevel=9): <NEW_LINE> <INDENT> return None
x.__init__(...) initializes x; see help(type(x)) for signature
625941e45f7d997b87174ead
def set_tiles(self, tiles): <NEW_LINE> <INDENT> self._tiles = tiles
Set the tiles string once it is known
625941e40c0af96317bb85fa
def authenticate(self, request): <NEW_LINE> <INDENT> jwt_value = self.get_jwt_value(request) <NEW_LINE> if jwt_value is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> payload = jwt_decode_handler(jwt_value) <NEW_LINE> <DEDENT> except jwt.ExpiredSignature: <NEW_LINE> <INDENT> msg = _(...
Returns a two-tuple of `User` and token if a valid signature has been supplied using JWT-based authentication. Otherwise returns `None`.
625941e482261d6c526ab8b8
def find_storage_system(self, conn, configService): <NEW_LINE> <INDENT> foundStorageSystemInstanceName = None <NEW_LINE> groups = conn.AssociatorNames( configService, AssocClass='CIM_HostedService') <NEW_LINE> if len(groups) > 0: <NEW_LINE> <INDENT> foundStorageSystemInstanceName = groups[0] <NEW_LINE> <DEDENT> else: <...
Finds the storage system for a particular config service. Given the storage configuration service get the CIM_StorageSystem from it. :param conn: the connection to the ecom server :param configService: the storage configuration service :returns: int -- rc - the return code of the job :returns: dict -- jobDict - the j...
625941e44a966d76dd551425
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, RuleChainConnectionInfo): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__
Returns true if both objects are equal
625941e41f037a2d8b94660f
def delete_audio_file(obj): <NEW_LINE> <INDENT> if obj.audio_file: <NEW_LINE> <INDENT> if os.path.exists(obj.audio_file.path): <NEW_LINE> <INDENT> os.remove(obj.audio_file.path) <NEW_LINE> <DEDENT> <DEDENT> return True
Delete audio file from computer drive
625941e421bff66bcd684d61
def uniform_candidate_sampler_eager_fallback(true_classes, num_true, num_sampled, unique, range_max, seed=0, seed2=0, name=None): <NEW_LINE> <INDENT> _ctx = _context.context() <NEW_LINE> num_true = _execute.make_int(num_true, "num_true") <NEW_LINE> num_sampled = _execute.make_int(num_sampled, "num_sampled") <NEW_LINE> ...
This is the slowpath function for Eager mode. This is for function uniform_candidate_sampler
625941e41b99ca400220aec5
def create_document(ref, values, database=None): <NEW_LINE> <INDENT> update_document(ref, values, database)
Create a given document with given values, this leverages the same functionality as `update_document` thanks to `set` with `merge=True`. Args: ref (str): A document reference. values (str): A dictionary of values to update. database (Client): An optional existing Firestore database client.
625941e444b2445a339324a6
def server_work(message, pow_diff=3): <NEW_LINE> <INDENT> pow_check = pow_diff * '0' <NEW_LINE> seed = id_generator() <NEW_LINE> hash_value = create_hashvalue(seed+message) <NEW_LINE> while hash_value[:pow_diff] > pow_check: <NEW_LINE> <INDENT> seed = id_generator() <NEW_LINE> hash_value = create_hashvalue(seed+message...
genetrate POW string
625941e476e4537e8c351a88
def IF_NULL(expression, _else): <NEW_LINE> <INDENT> return {'$ifNull': [expression, _else]}
Evaluates an expression and returns the value of the expression if the expression evaluates to a non-null value. See https://docs.mongodb.com/manual/reference/operator/aggregation/ifNull/ for more details :param expression: expression that will be evaluated :param _else: value or expression if 'expression' is null :ret...
625941e43346ee7daa2b3181
def _update_conf(conf, target, project, repository): <NEW_LINE> <INDENT> if project: <NEW_LINE> <INDENT> conf.projects[target] = project <NEW_LINE> <DEDENT> if repository: <NEW_LINE> <INDENT> if target == 'default': <NEW_LINE> <INDENT> conf.images[target] = repository <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if no...
Update configuration target with given ``project`` and ``repository``
625941e4596a897236089ece
def __init__(self, delay=None, description=None, when=None, arguments=None, components=None): <NEW_LINE> <INDENT> self.__discriminator_value = "SendEvent" <NEW_LINE> self.object_type = self.__discriminator_value <NEW_LINE> super(SendEventCommand, self).__init__(object_type=self.__discriminator_value, delay=delay, descr...
The SendEvent command allows the APL author to generate and send an event to Alexa. :param delay: The delay in milliseconds before this command starts executing; must be non-negative. Defaults to 0. :type delay: (optional) int :param description: A user-provided description of this command. :type description: (optiona...
625941e416aa5153ce36288a
def __init__( self, coordinator: DataUpdateCoordinator, description: EntityDescription ) -> None: <NEW_LINE> <INDENT> super().__init__(coordinator) <NEW_LINE> self.entity_description = description <NEW_LINE> if coordinator.config_entry: <NEW_LINE> <INDENT> flipr_id = coordinator.config_entry.data[CONF_FLIPR_ID] <NEW_LI...
Initialize Flipr sensor.
625941e4e5267d203edce0aa
def _debugclient_start_new_thread(target, args, kwargs = {}): <NEW_LINE> <INDENT> if DebugClientBase.DebugClientInstance is not None: <NEW_LINE> <INDENT> return DebugClientBase.DebugClientInstance.attachThread(target, args, kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return _original_start_thread(target, args...
Module function used to allow for debugging of multiple threads. The way it works is that below, we reset _thread._start_new_thread to this function object. Thus, providing a hook for us to see when threads are started. From here we forward the request onto the DebugClient which will create a DebugThread object to a...
625941e4a05bb46b383ecc30
def tearDown(self): <NEW_LINE> <INDENT> os.remove(self.linkdir_path) <NEW_LINE> os.rmdir(self.actual_dir_path) <NEW_LINE> os.rmdir(self.base_dir_path)
Clean up the test paths.
625941e44e4d5625662d47e5
def run(): <NEW_LINE> <INDENT> if not isdir(settings.PID_PATH): <NEW_LINE> <INDENT> print('pid directory does not exist at %s' % settings.PID_PATH) <NEW_LINE> sys.exit(1) <NEW_LINE> <DEDENT> if not isdir(settings.LOG_PATH): <NEW_LINE> <INDENT> print('log directory does not exist at %s' % settings.LOG_PATH) <NEW_LINE> s...
Start the ThunderAgent. Start the logger.
625941e44f6381625f114e4e
@test_case('C210475') <NEW_LINE> @nondestructive <NEW_LINE> @web <NEW_LINE> def test_mobile_users_are_presented_a_drop_down_menu(web_base_url, selenium): <NEW_LINE> <INDENT> home = WebHome(selenium, web_base_url) <NEW_LINE> home.resize_window(width=600) <NEW_LINE> home.open() <NEW_LINE> press = home.footer.directory.pr...
A section drop down menu covers the page sections for phone viewers.
625941e48c3a8732951587d2
def test_compress_streaming_response(self): <NEW_LINE> <INDENT> r = GZipMiddleware().process_response(self.req, self.stream_resp) <NEW_LINE> self.assertEqual(self.decompress(b''.join(r)), b''.join(self.sequence)) <NEW_LINE> self.assertEqual(r.get('Content-Encoding'), 'gzip') <NEW_LINE> self.assertFalse(r.has_header('Co...
Tests that compression is performed on responses with streaming content.
625941e415baa723493c438b
def test(self, traindata, testdata): <NEW_LINE> <INDENT> correct = 0.0 <NEW_LINE> total = 0.0 <NEW_LINE> for example in testdata.data: <NEW_LINE> <INDENT> o, val = self.classify(example, traindata.data) <NEW_LINE> if o == int(example[-1]): <NEW_LINE> <INDENT> correct += 1.0 <NEW_LINE> <DEDENT> total += 1.0 <NEW_LINE> <...
Labels examples in test dataset according to alpha weight vector. traindata: Arff class, training dataset testdata: Arff class, testing dataset
625941e430c21e258bdfa8b4
def maxSubArray(self, nums): <NEW_LINE> <INDENT> max_ans = nums[0] <NEW_LINE> t = nums[0] <NEW_LINE> for i in range(1, len(nums)): <NEW_LINE> <INDENT> if t < 0: <NEW_LINE> <INDENT> t = nums[i] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> t = nums[i] + t <NEW_LINE> <DEDENT> if t > max_ans: <NEW_LINE> <INDENT> max_ans =...
:type nums: List[int] :rtype: int
625941e445492302aab5e6da
def crontab(attrs=None, where=None): <NEW_LINE> <INDENT> return _osquery_cmd(table='crontab', attrs=attrs, where=where)
Return crontab information from osquery CLI Example: .. code-block:: bash salt '*' osquery.crontab
625941e47d847024c06be6d2
def load_file(filename): <NEW_LINE> <INDENT> with open(filename, 'r', encoding='utf-8') as fin: <NEW_LINE> <INDENT> reader = csv.DictReader(fin, delimiter=',') <NEW_LINE> purchases = [] <NEW_LINE> for row in reader: <NEW_LINE> <INDENT> p = Purchase.create_from_dict(row) <NEW_LINE> purchases.append(p) <NEW_LINE> <DEDENT...
This function loads the date from the filename
625941e44527f215b584c865
def extend(self, g): <NEW_LINE> <INDENT> for (p, d) in g: <NEW_LINE> <INDENT> self.insert(p, d)
Inserts all the points in g.
625941e4a05bb46b383ecc31
def GINFO(message, *args): <NEW_LINE> <INDENT> LOGQ.info(message, *args)
INFO记录
625941e485dfad0860c3b26f
def _turn_on_sensors_one_by_one(self): <NEW_LINE> <INDENT> for s in self.sensors: <NEW_LINE> <INDENT> GPIO.output(s.get('shutdown_pin'), GPIO.HIGH) <NEW_LINE> sleep(0.1) <NEW_LINE> s.get('instance').start_ranging(VL53L0X.VL53L0X_BETTER_ACCURACY_MODE)
Set shutdown pin high one after the other for all sensors
625941e4851cf427c661a91f
def meshgrid(batch, height, width, is_homogeneous=True): <NEW_LINE> <INDENT> x_t = tf.matmul(tf.ones(shape=tf.stack([height, 1])), tf.transpose(tf.expand_dims( tf.linspace(-1.0, 1.0, width), 1), [1, 0])) <NEW_LINE> y_t = tf.matmul(tf.expand_dims(tf.linspace(-1.0, 1.0, height), 1), tf.ones(shape=tf.stack([1, width]))) <...
Construct a 2D meshgrid. Args: batch: batch size height: height of the grid width: width of the grid is_homogeneous: whether to return in homogeneous coordinates Returns: x,y grid coordinates [batch, 2 (3 if homogeneous), height, width]
625941e4be8e80087fb21050
def set_file_path(file_from_onedrive): <NEW_LINE> <INDENT> if platform.system() == "Windows": <NEW_LINE> <INDENT> if "/" in file_from_onedrive: <NEW_LINE> <INDENT> file_from_onedrive.replace("/", "\\") <NEW_LINE> <DEDENT> if file_from_onedrive[0:2] == "\\": <NEW_LINE> <INDENT> file_from_onedrive = file_from_onedrive[2:...
:param file_from_onedrive: file path within onedrive (excluding OneDrive/ root) :return: returns system-contextual full file path
625941e416aa5153ce36288b
def test_chunks_with_one_shown_record_are_shown(self): <NEW_LINE> <INDENT> c = Chunk(data="<div/>", is_normal=True) <NEW_LINE> c.save() <NEW_LINE> e = Entry() <NEW_LINE> e.update( self.foo, "q", c, "foo", ChangeRecord.CREATE, ChangeRecord.MANUAL) <NEW_LINE> e.latest.hidden = True <NEW_LINE> e.latest.save() <NEW_LINE> e...
``hidden`` is ``False`` if one ``ChangeRecord`` is shown.
625941e4d4950a0f3b08c75c
def get_programmes(self, url): <NEW_LINE> <INDENT> print('######## LOAD programmes') <NEW_LINE> print('URL: {}'.format(url)) <NEW_LINE> items = [] <NEW_LINE> soup = utils.get_soup_from_url(url) <NEW_LINE> for item in soup.find_all('div', {'class': 'gallery-item'}): <NEW_LINE> <INDENT> img = '' <NEW_LINE> try: <NEW_LINE...
get all programme by channel from given section url :param url: :return:
625941e48a43f66fc4b54474
def __init__(self, capacity): <NEW_LINE> <INDENT> self.tb = {} <NEW_LINE> self.cache = doubleLinkList() <NEW_LINE> self.capacity = capacity <NEW_LINE> self.size = 0
:type capacity: int
625941e4e64d504609d74c53
def __init__(self, x, constr=[], t=ConvexOuter.EXACT): <NEW_LINE> <INDENT> self._info= [] <NEW_LINE> super(ConvexSet, self).__init__(x, constr)
Args: x (cvxpy.Variable): a symbolic representation of members of the set constr (list of cvxpy.Expression): constraints to impose on members of set
625941e4a8370b7717052cb0
def get_edge( self, glm, nodeA, nodeB, entries = '', mln = False ): <NEW_LINE> <INDENT> warning = "No edge between {0} and {1} could be found".format( nodeA, nodeB ) <NEW_LINE> if isinstance(entries, text_type): <NEW_LINE> <INDENT> entries = entries.split(',') <NEW_LINE> <DEDENT> if not mln: <NEW_LINE> <INDENT> graph =...
Return the edge data for a given gain-loss model.
625941e40a366e3fb873ec31
def value_from_object(self, obj): <NEW_LINE> <INDENT> return getattr(obj, self.attname).all()
Return the value of this field in the given model instance.
625941e47d43ff24873a30b6
def has_left_child_only(self): <NEW_LINE> <INDENT> return self.left_child and not self.right_child
Check if the current node has a left child only
625941e43eb6a72ae02ec8fb
def new_url(module): <NEW_LINE> <INDENT> url_base = "/axapi/v3/debug/smpp" <NEW_LINE> f_dict = {} <NEW_LINE> return url_base.format(**f_dict)
Return the URL for creating a resource
625941e4bde94217f3683200
def _getElementValue(self, namespace, elementName): <NEW_LINE> <INDENT> if self.xmlDoc is None: <NEW_LINE> <INDENT> self.reload() <NEW_LINE> <DEDENT> typeEl = None <NEW_LINE> for e in self.xmlDoc.childNodes: <NEW_LINE> <INDENT> if e.nodeType == e.ELEMENT_NODE and e.localName == "type": <NEW_LINE> <INDENT> typeEl = e <N...
Helper method to retrieve child element values from type XML.
625941e4099cdd3c635f106c
def train(self, X, y, X_val, y_val, learning_rate=1e-3, learning_rate_decay=0.95, reg=5e-6, num_iters=100, batch_size=200, verbose=False): <NEW_LINE> <INDENT> num_train = X.shape[0] <NEW_LINE> iterations_per_epoch = max(num_train / batch_size, 1) <NEW_LINE> loss_history = [] <NEW_LINE> train_acc_history = [] <NEW_LINE>...
Train this neural network using stochastic gradient descent. Inputs: - X: A numpy array of shape (N, D) giving training data. - y: A numpy array f shape (N,) giving training labels; y[i] = c means that X[i] has label c, where 0 <= c < C. - X_val: A numpy array of shape (N_val, D) giving validation data. - y_val: A nu...
625941e415fb5d323cde0f28
def getint(self,section,option,default=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return int(configparser.ConfigParser.get(self, self.bestSection(section,option), option)) <NEW_LINE> <DEDENT> except configparser.NoOptionError: <NEW_LINE> <INDENT> if default!=None: <NEW_LINE> <INDENT> return default <NEW_LINE> ...
Overrides the original implementation from ConfigParser :param section: the section :param option: the option :param default: if set and the option is not found, then this value is used
625941e4e8904600ed9f2346
def normalise_stc(stc): <NEW_LINE> <INDENT> data = stc.data <NEW_LINE> data = data / np.absolute(data).max() <NEW_LINE> stc_norm = mne.SourceEstimate(data, stc.vertices, tmin=stc.tmin, tstep=stc.tstep) <NEW_LINE> return stc_norm
Normalise data in STC object to absolute maximum. Parameters ---------- stc: SourceEstimate The data to normalise. Returns ------- stc_norm: Source estimate. STC with data normalised to absolute maximum.
625941e4462c4b4f79d1dae3
def sea_dataset(): <NEW_LINE> <INDENT> return xr.open_dataset(SEA_MODEL)
Get SEA sample dataset :return: xarray Dataset
625941e430bbd722463cc1db
def add_recipe(self, recipe_id, recipe_title, recipe_detail, ingredient_cuisine_doc, user_doc): <NEW_LINE> <INDENT> recipe = { 'type': 'recipe', 'name': self.get_unique_recipe_name(recipe_id), 'title': recipe_title.strip(), 'instructions': recipe_detail } <NEW_LINE> recipe = self.add_doc_if_not_exists(recipe, 'name') <...
Adds a new recipe to Cloudant if a recipe with the specified name does not already exist. Parameters ---------- recipe_id - The ID of the recipe (typically the ID of the recipe returned from Spoonacular) recipe_title - The title of the recipe recipe_detail - The detailed instructions for making the recipe ingredient_cu...
625941e4c432627299f0505c
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, PaginatedWorkspaces): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__
Returns true if both objects are equal
625941e45fc7496912cc3d91
def unique_id(self): <NEW_LINE> <INDENT> return _filter_swig.freq_xlating_fir_filter_ccf_sptr_unique_id(self)
unique_id(freq_xlating_fir_filter_ccf_sptr self) -> long
625941e43539df3088e2e75e
def open_about(self): <NEW_LINE> <INDENT> self.info('{} version {}\n{}'.format(config.program_name, config.version, config.copyright))
Display program information.
625941e49c8ee82313fbbb89
def titleToNumber(self, s): <NEW_LINE> <INDENT> return reduce(lambda x,y: 26*x + y, map(lambda x: ord(x) - ord('A') +1, s))
:type s: str :rtype: int
625941e4de87d2750b8601aa
def test_basic_information_case21(self): <NEW_LINE> <INDENT> case = test_agency_basic_information_case21 <NEW_LINE> self.assertTrue(self.login_page.open_browser(config.BASE_URL), u"打开首页失败") <NEW_LINE> r = self.login_page.login(**case) <NEW_LINE> self.assertTrue(r.result, r.msg) <NEW_LINE> r = self.basic_information_pag...
验证对公账号输入框输入大于19个数字
625941e4d99f1b3c44c6799b
def get_drive_id(self, site=None, drive_name="Templates"): <NEW_LINE> <INDENT> if site is None: <NEW_LINE> <INDENT> site = self.default_site <NEW_LINE> <DEDENT> drive_id_url = "https://graph.microsoft.com/v1.0/sites/" <NEW_LINE> drive_id_url += site + ":/drives" <NEW_LINE> res = self.get_request(drive_id_url) <NEW_LINE...
Specify site like this: gblsma.sharepoint.com:/Units/Immigration
625941e42c8b7c6e89b35bd1
def user_percent_passed(self, user): <NEW_LINE> <INDENT> nlessons = self.lessons.filter(deleted__isnull=True).count() <NEW_LINE> from django.db.models import F <NEW_LINE> npassed = QuizAttempt.active_objects.filter(user=user, lesson_in=self.lessons, score__gte=F(lesson__passing_score)).count() <NEW_LINE> return Decimal...
Returns a Decimal telling what percentage of the tests in this module `user` has passed.
625941e445492302aab5e6db
def __init__(self): <NEW_LINE> <INDENT> self.content = TelegramCommand.KEEPALIVE
Initialize Telegram class.
625941e48da39b475bd6538c
def call(self, msg): <NEW_LINE> <INDENT> logger.debug("Called stub method: call().")
Call a RPC. @param mas A message to be sent.
625941e450485f2cf553d1af
def ANNUALIZED_RETURNS(ts, lookback=5, price='close', prevday=False): <NEW_LINE> <INDENT> def _cagr(s): <NEW_LINE> <INDENT> A = s[0] <NEW_LINE> B = s[-1] <NEW_LINE> n = len(s) <NEW_LINE> if B < 0: B = 0 <NEW_LINE> return (math.pow(B / A, 1 / n) - 1) * 100 <NEW_LINE> <DEDENT> if lookback <= 0: <NEW_LINE> <INDENT> raise ...
Calculate the rolling annualized returns. Parameters ---------- ts : pd.DateFrame A dataframe with 'open', 'high', 'low', 'close', 'volume'. lookback : float, optional The number of years to lookback, e.g. 5 years. 1/12 can be used for 1 month. Likewise 3/12 for 3 months, etc... (default is 5). price...
625941e49f2886367277ac9e
def _find_groups(url): <NEW_LINE> <INDENT> regex = re.compile(url) <NEW_LINE> pattern = url <NEW_LINE> if pattern.startswith('^'): <NEW_LINE> <INDENT> pattern = pattern[1:] <NEW_LINE> <DEDENT> if pattern.endswith('$'): <NEW_LINE> <INDENT> pattern = pattern[:-1] <NEW_LINE> <DEDENT> if regex.groups != pattern.count('('):...
Returns a tuple (reverse string, group count) for a url. For example: Given the url pattern /([0-9]{4})/([a-z-]+)/, this method would return ('/%s/%s/', 2).
625941e429b78933be1e5abb
def print_as(self, what='list'): <NEW_LINE> <INDENT> if what == 'map': <NEW_LINE> <INDENT> self.make_format = self._make_map <NEW_LINE> <DEDENT> elif what == 'number': <NEW_LINE> <INDENT> self.make_format = self._make_number <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.make_format = self._make_list <NEW_LINE> <DE...
PF.print_as([what='list']) -> print the results as specified. Valid format are: 'list' -> alphabetical order 'number' -> number of sites in the sequence 'map' -> a map representation of the sequence with the sites. If you want more flexibility over-ride the virtual method make_format.
625941e4bde94217f3683201
def modpow(a, k, p): <NEW_LINE> <INDENT> retval = type(a)(1) <NEW_LINE> cnt = 0 <NEW_LINE> while cnt < k: <NEW_LINE> <INDENT> retval = (retval * a) % p <NEW_LINE> cnt += 1 <NEW_LINE> <DEDENT> return retval
:param a: the base :param k: the exponent (a positive integer) :param p: the modulus :return: :math:`a^k(p)`. a can be of any type that has a multiplicative identity and supports multiplication and modding.
625941e431939e2706e4d278
def fromXML(self, root, dest, file='None'): <NEW_LINE> <INDENT> pass
Initialize the object from an XML description.
625941e4d486a94d0b98e55a
def custom_score_2(game, player): <NEW_LINE> <INDENT> if game.is_loser(player): <NEW_LINE> <INDENT> return float("-inf") <NEW_LINE> <DEDENT> if game.is_winner(player): <NEW_LINE> <INDENT> return float("inf") <NEW_LINE> <DEDENT> own_moves = len(game.get_legal_moves(player)) <NEW_LINE> opp_moves = len(game.get_legal_move...
Calculate the heuristic value of a game state from the point of view of the given player. Note: this function should be called from within a Player instance as `self.score()` -- you should not need to call this function directly. Parameters ---------- game : `isolation.Board` An instance of `isolation.Board` encodi...
625941e43317a56b8693a062
def html_fr_source(url): <NEW_LINE> <INDENT> r = requests.get(url) <NEW_LINE> return r.text
Get an HTML object from the source url.
625941e423849d37ff7b34a0
def generate_token(username): <NEW_LINE> <INDENT> timestamp = str(time.time()) <NEW_LINE> token = hashlib.md5(bytes(username, encoding='utf-8')) <NEW_LINE> token.update(bytes(timestamp, encoding='utf-8')) <NEW_LINE> return token.hexdigest()
生成token
625941e4e64d504609d74c54
def get_order_sentence_seq(item: tuple) -> int: <NEW_LINE> <INDENT> return item[1].get("order_sentence_sequence")
When iterating over dict.items(), this function can be used to sort by the nested dict key "order_sentence_sequence"
625941e48a43f66fc4b54475
def _user_default(self): <NEW_LINE> <INDENT> return self.user_db.user_factory()
Return the default current user.
625941e4c432627299f0505d
@synchronized(_clock_lock) <NEW_LINE> def cancel(clock): <NEW_LINE> <INDENT> now = getNow() <NEW_LINE> if clock == None: <NEW_LINE> <INDENT> clock = _getFirstRemindOrExpired(clocks, now) <NEW_LINE> if not clock: <NEW_LINE> <INDENT> raise ClockException(u'没有可取消的闹钟。') <NEW_LINE> <DEDENT> <DEDENT> if not clock['on']: <NEW...
取消闹钟 传入None为默认操作: 关掉第一个提醒或到期闹钟 对一次性闹钟: 删除 对星期重复: 取消下一个提醒 对周期重复: 以当前时间重新开始计时 对关闭的闹钟无效
625941e40a366e3fb873ec32
def test_get_self_user(self): <NEW_LINE> <INDENT> self.bb.username = username <NEW_LINE> success, result = self.bb.get_user() <NEW_LINE> self.assertTrue(success) <NEW_LINE> self.assertIsInstance(result, dict)
Test get_user on self username.
625941e44c3428357757c73a
def _signal(self): <NEW_LINE> <INDENT> for obj in self.entries.values(): <NEW_LINE> <INDENT> if 'signal' in obj.attrs and str(obj.signal) == '1': <NEW_LINE> <INDENT> return self[obj.nxname] <NEW_LINE> <DEDENT> <DEDENT> return None
Return the NXfield containing the signal data.
625941e455399d3f05588aca
def get_cumulative_rewards(rewards, gamma=0.99 ): <NEW_LINE> <INDENT> def get_discount_return(rewards): <NEW_LINE> <INDENT> if len(rewards) > 1: <NEW_LINE> <INDENT> return rewards[0] + gamma * get_discount_return(rewards[1:]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return rewards[0] <NEW_LINE> <DEDENT> <DEDENT> c...
take a list of immediate rewards r(s,a) for the whole session compute cumulative returns (a.k.a. G(s,a) in Sutton '16) G_t = r_t + gamma*r_{t+1} + gamma^2*r_{t+2} + ... The simple way to compute cumulative rewards is to iterate from last to first time tick and compute G_t = r_t + gamma*G_{t+1} recurrently You must re...
625941e4596a897236089ecf
def test_default_cache_when_nothing_provided(project_remote): <NEW_LINE> <INDENT> with freeze_time("2021-03-16 11:00") as frozen_datetime: <NEW_LINE> <INDENT> project_remote.assert_call_count(0) <NEW_LINE> project_remote.api_check().assert_violations().assert_call_count(1) <NEW_LINE> frozen_datetime.move_to("2021-03-16...
Test the default cache option when nothing is provided: 1 hour.
625941e4925a0f43d254a28f
def causal_pad(basis): <NEW_LINE> <INDENT> causal_basis = np.zeros((basis.shape[0], basis.shape[1]+1)) <NEW_LINE> causal_basis[:, 1:] = basis <NEW_LINE> return causal_basis
scipy's convolve dosn't enforce causality; (i.e. convolving only the history of a signal) We need to do that by adding zeroes to the convolution matrix
625941e4d8ef3951e3243952
def __call__(self, functor): <NEW_LINE> <INDENT> def wrapped_functor(*args, **kwargs): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return functor(*args, **kwargs) <NEW_LINE> <DEDENT> except self.source_exception: <NEW_LINE> <INDENT> exc_type, exc_value, _ = sys.exc_info() <NEW_LINE> exc_traceback = traceback.format_ex...
Returns a wrapped function.
625941e4d6c5a10208144462
def get_word_with_least_vowels(input): <NEW_LINE> <INDENT> mini = 999999999 <NEW_LINE> res = "" <NEW_LINE> inp = input <NEW_LINE> for x in inp: <NEW_LINE> <INDENT> a = set(x) <NEW_LINE> b = set("aeiou"); <NEW_LINE> a = a - b <NEW_LINE> c = x.__len__() - a.__len__() <NEW_LINE> if c < mini: <NEW_LINE> <INDENT> mini = c <...
returns the word with least number of vowels.
625941e44e4d5625662d47e6
def test_get_request_filters_with_falsey_values(self): <NEW_LINE> <INDENT> request = APIRequestFactory().get('/?q=&test=0') <NEW_LINE> request = APIView().initialize_request(request) <NEW_LINE> filters = HaystackRequestFilterMixin.get_request_filters(request) <NEW_LINE> self.assertNotIn('q', filters) <NEW_LINE> self.as...
Verify the method does not strip valid falsey values.
625941e42c8b7c6e89b35bd2
def get_connections_raw(self, id, connection_name, **args): <NEW_LINE> <INDENT> return self.request_raw(id + "/" + connection_name, args)
Fetchs the connections for given object.
625941e45fdd1c0f98dc0649
def set_logger(logger): <NEW_LINE> <INDENT> global tsqa_logger <NEW_LINE> tsqa_logger = logger
Set/replace the global logger
625941e473bcbd0ca4b2c48a
def __init__(self, cells, state_is_tuple=True): <NEW_LINE> <INDENT> if not cells: <NEW_LINE> <INDENT> raise ValueError("Must specify at least one cell for MultiRNNCell.") <NEW_LINE> <DEDENT> if not nest.is_sequence(cells): <NEW_LINE> <INDENT> raise TypeError( "cells must be a list or tuple, but saw: %s." % cells) <NEW_...
Create a RNN cell composed sequentially of a number of RNNCells. Args: cells: list of RNNCells that will be composed in this order. state_is_tuple: If True, accepted and returned states are n-tuples, where `n = len(cells)`. If False, the states are all concatenated along the column axis. This latter behav...
625941e40fa83653e46573cd
def rob(self, nums): <NEW_LINE> <INDENT> if len(nums) == 0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> if len(nums) == 1: <NEW_LINE> <INDENT> return nums[0] <NEW_LINE> <DEDENT> if len(nums) == 2: <NEW_LINE> <INDENT> return max(nums[0], nums[1]) <NEW_LINE> <DEDENT> dp = [None] * (len(nums)+1) <NEW_LINE> dp[0] = 1 ...
:type nums: List[int] :rtype: int
625941e4c4546d3d9de72e4c
def dump_lines(output_file, lines, quiet=True): <NEW_LINE> <INDENT> generated = '\n'.join(lines) + '\n' <NEW_LINE> if output_file and output_file.name != '-': <NEW_LINE> <INDENT> output_file.parent.mkdir(parents=True, exist_ok=True) <NEW_LINE> if output_file.exists(): <NEW_LINE> <INDENT> output_file.replace(output_file...
Handle dumping to stdout or file Creates parent folders if required
625941e41b99ca400220aec8
def __init__(self, layers, actvFn = 'tanh', batchSize = None, learnRate = 1e-3, loss = 'smce', maxIter = 1024, name = 'tfann', optmzrn = 'adam', reg = 1e-3, tol = 1e-2, verbose = False): <NEW_LINE> <INDENT> self.layers = layers <NEW_LINE> super().__init__(actvFn, batchSize, learnRate, loss, maxIter, name, optmzrn, reg,...
layers: A list of layer sizes
625941e4d18da76e235328ef
def get_subregions(self, iso_code): <NEW_LINE> <INDENT> items = dict() <NEW_LINE> for key, value in self.region_registry.items(): <NEW_LINE> <INDENT> if key.startswith(f"{iso_code}-"): <NEW_LINE> <INDENT> items[key] = value <NEW_LINE> <DEDENT> <DEDENT> return items
Returns subregion calendar classes for given region iso_code. >>> registry = IsoRegistry() >>> # assuming calendars registered are: DE, DE-HH, DE-BE >>> registry.get_subregions('DE') # doctest: +SKIP {'DE-HH': <class 'calendra.europe.germany.Hamburg'>, 'DE-BE': <class 'calendra.europe.germany.Berlin'>} :rtype dict :r...
625941e444b2445a339324a8
def rotate(self, nums, k): <NEW_LINE> <INDENT> k %= len(nums) <NEW_LINE> nums.reverse() <NEW_LINE> nums[0:k] = nums[0:k][::-1] <NEW_LINE> nums[k:] = nums[k:][::-1]
:type nums: List[int] :type k: int :rtype: void Do not return anything, modify nums in-place instead. Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].
625941e4f9cc0f698b140a0c
def geoj2geom(shapeobj): <NEW_LINE> <INDENT> geojson = shapeobj.__geo_interface__ <NEW_LINE> geotype = geojson["type"] <NEW_LINE> coords = geojson["coordinates"] <NEW_LINE> if geotype == "Point": <NEW_LINE> <INDENT> x,y = coords <NEW_LINE> geom = Point(x,y) <NEW_LINE> <DEDENT> elif geotype == "MultiPoint": <NEW_LINE> <...
Takes any object that has the __geo_interface__ attribute and creates and returns a ready-to-use geometry instance.
625941e494891a1f4081bec0
def euclidianDist(x1, x2): <NEW_LINE> <INDENT> dist =np.sqrt(np.sum(np.power(x1-x2, 2), -1)) <NEW_LINE> return dist
compute euclidian distance of two points :param x1: :param x2: :return:
625941e40a50d4780f6672aa
def get_scaled_volume(self, listener_position): <NEW_LINE> <INDENT> return 1.0
Return the sound volume according to the listener position
625941e4cc0a2c11143dd2a7
def translate_grid(pitch_grid, dx, dy): <NEW_LINE> <INDENT> new_grid = pitch_grid.copy() <NEW_LINE> new_grid[:,0] += dx <NEW_LINE> new_grid[:,1] += dy <NEW_LINE> return new_grid
Shifts the grid points by dx and dy. Args: dx: Translation in x direction dy: Translation in y direction Returns: The same grid with grid points translated.
625941e48c3a8732951587d4
def checkMatch(origVal, storedVal): <NEW_LINE> <INDENT> match = False <NEW_LINE> if hashVal(origVal) == storedVal: <NEW_LINE> <INDENT> match = True <NEW_LINE> <DEDENT> return match
Confirms if an unhashed value matches a stored value Args: origVal (str): unhashed value storedVal (str): hashed value Returns: True if values match, False otherwise
625941e44e4d5625662d47e7
def send(self, data): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> HydraUtils.socket_send(self.client_conn, data) <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> self.log.exception(e) <NEW_LINE> return False <NEW_LINE> <DEDENT> return True
A HydraClient can use this method to send commands to the worker
625941e4dc8b845886cb594b
def __str__(self): <NEW_LINE> <INDENT> return f"{(self.x, self.y)}"
output point coordinates as string in tuple format: (x,y)
625941e438b623060ff0b202
def test_process_run_client(self): <NEW_LINE> <INDENT> error = self.process_run_client() <NEW_LINE> for err in error: assert err == 0
Calls the test function for the run_client action.
625941e41f037a2d8b946612
def cleanup_old_versions(src, keep_last_versions): <NEW_LINE> <INDENT> if keep_last_versions <= 0: <NEW_LINE> <INDENT> print("Won't delete all versions. Please do this manually") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> path_to_config_file = os.path.join(src, 'config.yaml') <NEW_LINE> cfg = read(path_to_config_fil...
Deletes old deployed versions of the function in AWS Lambda. Won't delete $Latest and any aliased version :param str src: The path to your Lambda ready project (folder must contain a valid config.yaml and handler module (e.g.: service.py). :param int keep_last_versions: The number of recent versions to ke...
625941e47d847024c06be6d4