code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def create_markdown(self): <NEW_LINE> <INDENT> coverpath = "" <NEW_LINE> if not self.coverimage is None: <NEW_LINE> <INDENT> coverpath = ( settings.url_prefix + self.cover_path[len(settings.output_dir) :] ) <NEW_LINE> coverpath = coverpath.replace("\\", "/") <NEW_LINE> <DEDENT> if self.properties is None: <NEW_LINE> <I... | Create the markdown file, always overwrite existing | 625941db287bf620b61d3d45 |
def __init__(self, can_disable_l3=None, can_enable_l3=None, children=None, health_flags=None, id=None, l3=None, l3_status=None, lnns=None, manual=None, name=None, protection_policy=None, type=None, usage=None): <NEW_LINE> <INDENT> self._can_disable_l3 = None <NEW_LINE> self._can_enable_l3 = None <NEW_LINE> self._childr... | StoragepoolStoragepool - a model defined in Swagger | 625941dbcad5886f8bd272bb |
def doMoments(self, data): <NEW_LINE> <INDENT> self.x_off1 = 1.0e-6 <NEW_LINE> self.y_off1 = 0.0 <NEW_LINE> self.x_off2 = 1.0e-6 <NEW_LINE> self.y_off2 = 0.0 <NEW_LINE> total_good = 0 <NEW_LINE> data_band = data[self.half_y-15:self.half_y+15,:] <NEW_LINE> x = numpy.arange(self.half_x) <NEW_LINE> data_ave = numpy.averag... | Perform a moment based calculation of the distances. | 625941dbff9c53063f47c4d5 |
def __init__(self,idN, threshold, x , y , af): <NEW_LINE> <INDENT> self.id = idN <NEW_LINE> self.threshold = threshold <NEW_LINE> self.input = 0.0 <NEW_LINE> self.active = False <NEW_LINE> self.function = af <NEW_LINE> self.output = 0.0 <NEW_LINE> self.becktrack = [] <NEW_LINE> self.maxin = 0.0 <NEW_LINE> self.x = x <N... | Constructor | 625941db16aa5153ce36275a |
def test_sequence_compilation18(root): <NEW_LINE> <INDENT> root.external_vars = OrderedDict({'a': 1.5}) <NEW_LINE> root.time_constrained = True <NEW_LINE> root.sequence_duration = '100' <NEW_LINE> pulse1 = Pulse(def_1='1.0', def_2='{a}') <NEW_LINE> pulse2 = Pulse(def_1='{a} + 1.0', def_2='3.0') <NEW_LINE> pulse3 = Puls... | Test compiling a nested fixed duration sequence.
| 625941db099cdd3c635f0f3d |
@pytest.fixture <NEW_LINE> def client(app): <NEW_LINE> <INDENT> return app.test_client() | A test client agent for the app.
Client has get(), post() and so on to make a http request.
Besides, using client in a with block allows accessing context variables
such as session after the response is returned. In other words, even the
request has been done, the context variables(`request`, `session`) will
still be ... | 625941db21a7993f00bc7fd7 |
def getCurPlistVal(self, plist, key): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if not os.path.exists(plist): <NEW_LINE> <INDENT> self.detailedresults += '\ngetCurPlistVal(): could not find specified plist file: ' + str(plist) <NEW_LINE> <DEDENT> self.cmhelper.executeCommand('defaults read ' + plist + ' ' + key) <NE... | get the value of the given plist key
@param: string plist name of plist file to query
@param: string key name of key to query
@return: list
@author: bemalmbe | 625941db30bbd722463cc0ab |
def run(test, params, env): <NEW_LINE> <INDENT> vm_name = params.get("main_vm") <NEW_LINE> bandwidth = params.get("bandwidth", "default") <NEW_LINE> options_extra = params.get("options_extra", "") <NEW_LINE> status_error = "yes" == params.get("status_error", "yes") <NEW_LINE> virsh_dargs = {'debug': True} <NEW_LINE> if... | Test command: virsh migrate-setspeed <domain> <bandwidth>
virsh migrate-getspeed <domain>.
1) Prepare test environment.
2) Try to set the maximum migration bandwidth (in MiB/s)
for a domain through valid and invalid command.
3) Recover test environment.
4) Check result. | 625941dbfb3f5b602dac3979 |
def num_instances(self): <NEW_LINE> <INDENT> return self._impl.numInstances() | Get the number of instances in this entity. | 625941db925a0f43d254a15c |
def polynomial_output_parallel_helper(equation: ExpressionOrInt) -> ExpressionOrInt: <NEW_LINE> <INDENT> if isinstance(equation, int) or equation.is_constant(): <NEW_LINE> <INDENT> return int(equation) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return equation.as_polynomial() | Converter from an ExpressionOrInt, to one which is a polynomial.
Required because python won't let you use lambdas in multiprocessing
Parameters
----------
equation
The equation to convert
Returns
-------
ExpressionOrInt | 625941dbeab8aa0e5d26de3b |
def log(self, message): <NEW_LINE> <INDENT> if self.log_queue: <NEW_LINE> <INDENT> self.log_queue.put("Interpreter#{}".format(message)) | Send the message to the log queue
params: message [String]
return: None | 625941db3d592f4c4ed1d34a |
@then('我应该新增成功') <NEW_LINE> def check_add_todo(context): <NEW_LINE> <INDENT> assert_that('1', '1', '待调整') | 查看返回的基本数据 | 625941dbad47b63b2c50a261 |
def test_index(admin_client): <NEW_LINE> <INDENT> url = "/nothing-to-see-here/" <NEW_LINE> HTTP_OK_200 = 200 <NEW_LINE> Conference.objects.create( code=settings.CONFERENCE_CONFERENCE, name=settings.CONFERENCE_CONFERENCE, ) <NEW_LINE> respnse = admin_client.get(url) <NEW_LINE> assert respnse.status_code == HTTP_OK_200 | Basic test to see if it even works. | 625941db55399d3f05588998 |
def powerset(s): <NEW_LINE> <INDENT> result = [] <NEW_LINE> for length in range(len(s)+1): <NEW_LINE> <INDENT> for subset in combinations(s,length): <NEW_LINE> <INDENT> result.append(set(subset)) <NEW_LINE> <DEDENT> <DEDENT> return result | Return a list of subsets as set type
| 625941db7b180e01f3dc4adb |
def test_isCurrent_no_uses_key(self): <NEW_LINE> <INDENT> key = Key.objects.get(key = "no_uses_key") <NEW_LINE> self.assertFalse(key.isCurrent()) | ' Test that a key with no uses get's false returned from Key's isCurrent | 625941db004d5f362079a615 |
@app.route('/make_application', methods=['POST']) <NEW_LINE> def make_application(): <NEW_LINE> <INDENT> candidate = { 'first_name': request.form['first_name'], 'last_name': request.form['last_name'], 'email': request.form['email'] } <NEW_LINE> JOB_APPLICATIONS.append({ 'candidate': candidate, 'connect_status': 'In Pro... | Save an application to our JOB_APPLICATIONS and send it to Connect for
processing. | 625941dbde87d2750b860078 |
def pca(data, r): <NEW_LINE> <INDENT> if data.ndim < 2: <NEW_LINE> <INDENT> data = array(data, ndmin=2, copy=False) <NEW_LINE> data = data.T <NEW_LINE> <DEDENT> if data.size == 0: <NEW_LINE> <INDENT> return data <NEW_LINE> <DEDENT> data -= data.mean(axis=0) <NEW_LINE> R = cov(data, rowvar=False) <NEW_LINE> R = array(R,... | input: data (D dimensions x N observations), r rank of PCA
output: PCA | 625941db76e4537e8c351958 |
def p_parse_command_parse_from_as(p): <NEW_LINE> <INDENT> p[0] = p[1] <NEW_LINE> p[0].addParserObject(p[3], p[5], p[7]) | parse_command : parse_command ',' ID FROM expression AS ID | 625941db3617ad0b5ed681d9 |
def write(self, dst: Union[str, PathLike, TextIO]): <NEW_LINE> <INDENT> if isinstance(dst, (str, PathLike)): <NEW_LINE> <INDENT> dst = open(fspath(dst), 'w') <NEW_LINE> own = True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> own = False <NEW_LINE> <DEDENT> dst.writelines( it.chain.from_iterable(zip(self, it.repeat('\n... | write the lines of the swim to a file or path | 625941db57b8e32f52483780 |
def __eq__(self, other): <NEW_LINE> <INDENT> return (other is not None and self.id == other.id and self.vol_id == other.vol_id) | Return true if objects are the same ID. | 625941dbfbf16365ca6f64ab |
def main(): <NEW_LINE> <INDENT> logger = LoggingUtil.create_log(__name__) <NEW_LINE> print("Starting: " + str(datetime.now())) <NEW_LINE> logger.info("Starting...") <NEW_LINE> mc = MongoConnector.MongoConnector() <NEW_LINE> jobs_manager = JobsManager.JobsManager(mc, "get_infoblox_zone_extattrs") <NEW_LINE> jobs_manager... | Begin Main... | 625941db283ffb24f3c55be1 |
def __init__(self): <NEW_LINE> <INDENT> self._create_preset_point_symbols() <NEW_LINE> self._create_preset_polygon_symbols() | Initiates the preset symbols for the symbolset | 625941dbd18da76e235327bc |
def drop_features(fin, fout, drops): <NEW_LINE> <INDENT> with open(fout, 'wb') as ostream: <NEW_LINE> <INDENT> for _, line in enumerate(open(fin, 'r')): <NEW_LINE> <INDENT> elements = line.split() <NEW_LINE> attributes = [] <NEW_LINE> for item in line.split(): <NEW_LINE> <INDENT> name = item.split(':')[0] <NEW_LINE> if... | Add namespaces into VW input file | 625941dba8ecb033257d33af |
def setSpanish(self): <NEW_LINE> <INDENT> pass | Initialize all the string to Spanish | 625941db4f88993c3716c348 |
def api20_admins_api_tokens_post_with_http_info( self, admin_ids=None, admin_names=None, timeout=None, async_req=False, _return_http_data_only=False, _preload_content=True, _request_timeout=None, ): <NEW_LINE> <INDENT> if admin_ids is not None: <NEW_LINE> <INDENT> if not isinstance(admin_ids, list): <NEW_LINE> <INDENT>... | POST admins/api-tokens
Creates API tokens for the specified administrators.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.api20_admins_api_tokens_post_with_http_info(async_req=True)
>>> result = thread.get()
:param list[str] ... | 625941db6fece00bbac2da24 |
def setL2name( self, nbtname=None ): <NEW_LINE> <INDENT> self.reset() <NEW_LINE> if( not nbtname ): <NEW_LINE> <INDENT> raise ValueError( "Invalid NBT name (Empty or None)." ) <NEW_LINE> <DEDENT> if( ('\x20' != nbtname[0]) and (ord(nbtname[0]) < 0x40) ): <NEW_LINE> <INDENT> raise ValueError( "Malformed NBT name; invali... | Assign an L2 (wire) format name to the NBT Name object.
Input:
nbtname - A fully encoded wire-format NBT name. This name will
overwrite the existing name, in all it's forms.
Output: The length, in bytes, of the L2-encoded NBT name. This is
useful for parsing packets, as it indicates the locati... | 625941db4428ac0f6e5baad7 |
def clean_detected_words(self,cutted_list): <NEW_LINE> <INDENT> detected_list = [] <NEW_LINE> with open("predictor/res/Detected_words.txt",'r',encoding='utf-8',errors='ignore') as f: <NEW_LINE> <INDENT> detected_list = f.readlines() <NEW_LINE> <DEDENT> for i in range(0,len(detected_list)): <NEW_LINE> <INDENT> detected_... | 清除停用词
:param cutted_list:
:return: | 625941db6fece00bbac2da25 |
def get_gene(self): <NEW_LINE> <INDENT> warn("deprecated, use the genes property instead") <NEW_LINE> return list(self._genes) | .. deprecated :: 0.3 use genes property instead | 625941db16aa5153ce36275b |
def __init__(self): <NEW_LINE> <INDENT> self.AutoScalingGroupId = None <NEW_LINE> self.ScheduledActionName = None <NEW_LINE> self.MaxSize = None <NEW_LINE> self.MinSize = None <NEW_LINE> self.DesiredCapacity = None <NEW_LINE> self.StartTime = None <NEW_LINE> self.EndTime = None <NEW_LINE> self.Recurrence = None | :param AutoScalingGroupId: 伸缩组ID
:type AutoScalingGroupId: str
:param ScheduledActionName: 定时任务名称。名称仅支持中文、英文、数字、下划线、分隔符"-"、小数点,最大长度不能超60个字节。同一伸缩组下必须唯一。
:type ScheduledActionName: str
:param MaxSize: 当定时任务触发时,设置的伸缩组最大实例数。
:type MaxSize: int
:param MinSize: 当定时任务触发时,设置的伸缩组最小实例数。
:type MinSize: int
:param DesiredCapacity:... | 625941db6fb2d068a760f384 |
def check_tag(obj, tag_name): <NEW_LINE> <INDENT> rfctag = None <NEW_LINE> if obj.get('Tags'): <NEW_LINE> <INDENT> for tag in obj.get('Tags'): <NEW_LINE> <INDENT> if tag.get('Key') == tag_name: <NEW_LINE> <INDENT> tag_value = tag.get('Value') <NEW_LINE> tag_value = re.sub('[,]', '/', tag_value) <NEW_LINE> return tag_va... | returns tag_name values if tag_name exist
Args:
obj (dict): list of tags
tag_name (string): tag name value
Returns:
tag_name values (string) | 625941db92d797404e30446e |
def test_wrong_user_can_only_get(self): <NEW_LINE> <INDENT> user = self.users[0] <NEW_LINE> profile = self.users[1].profile <NEW_LINE> pk = profile.pk <NEW_LINE> request = self.factory.get( reverse('userprofile-detail', args=[pk]) ) <NEW_LINE> force_authenticate(request, user=user) <NEW_LINE> response = self.detailview... | User should be able to `GET` any profile, but not `POST`, `PUT`, or
`DELETE` anyone else. | 625941db7b25080760e3973b |
def _factor(self, nt, factors): <NEW_LINE> <INDENT> new_nt = self._get_next_nt(nt) <NEW_LINE> self.non_terminals.add(new_nt) <NEW_LINE> factor_part = self._get_factor_part(factors) <NEW_LINE> for f in factors: <NEW_LINE> <INDENT> self.productions.discard(Prod(nt, f)) <NEW_LINE> <DEDENT> factor_part.append(new_nt) <NEW_... | Factor the productions passed. | 625941db283ffb24f3c55be2 |
def parse_dane(df): <NEW_LINE> <INDENT> msg = """Input doesn't contain 4 columns, you sure this is DANE format?""" <NEW_LINE> assert len(df.columns) == 4, msg <NEW_LINE> df = df.dropna(axis=0, how="all") <NEW_LINE> original_columns = ["raw_secdiv", "raw_group", "raw_class", "name"] <NEW_LINE> df.columns = original_colu... | Convert messed-up DANE excel treelike correlation table format into a
clean dataframe. You basically copy one side of the correlation table into
a separate sheet, including header, and then save as UTF-16 text. Then you
can read it like:
df = pd.read_table("Correlativas3.0vs4_only3.txt", encoding="utf-16")
The co... | 625941db1b99ca400220ad96 |
def login(appid, weibo_tokenstring, binduser): <NEW_LINE> <INDENT> user = None <NEW_LINE> apps = App.objects.filter(appid=appid) <NEW_LINE> if not apps.exists(): <NEW_LINE> <INDENT> return user <NEW_LINE> <DEDENT> app = apps[0] <NEW_LINE> thirdparty_app_infos = ThirdPartyAppInfo.objects.filter(app=app, thirdparty='weib... | 使用qq账户登陆本Heyi系统 | 625941db8a349b6b435e8456 |
def delete_applications_by_application_id(self, application_id, **kwargs): <NEW_LINE> <INDENT> function_endpoint = urljoin(self._baseurl, 'applications/{application_id}'.format(application_id=application_id)) <NEW_LINE> return self._call('DELETE', function_endpoint, response_type='text/plain', **kwargs) | DELETE /gui_app_framework/applications/{application_id}
Deletes an application instance. | 625941db097d151d1a22313b |
@njit <NEW_LINE> def calculate_le_timestamp(monopix_match_table): <NEW_LINE> <INDENT> m_i0=0 <NEW_LINE> latest_timestamp = monopix_match_table[m_i0]['token_timestamp'] <NEW_LINE> cluster_tmp = monopix_match_table[m_i0:1] <NEW_LINE> for m_i,m in enumerate(monopix_match_table): <NEW_LINE> <INDENT> if m['token_timestamp']... | This function calculates the timestamp of the Leading Edge of every hit in a cluster, based on the timestamp of the token associated
to that cluster. Note that the token goes high and is time-stamped right after the Falling Edge of the shortest hit in the cluster. | 625941dbfff4ab517eb2f721 |
def run_analysis(self, argv): <NEW_LINE> <INDENT> args = self._parser.parse_args(argv) <NEW_LINE> if not args.rosters: <NEW_LINE> <INDENT> raise RuntimeError("You must specify at least one target roster") <NEW_LINE> <DEDENT> if is_null(args.ttype): <NEW_LINE> <INDENT> raise RuntimeError("You must specify a target type"... | Run this analysis | 625941dbcb5e8a47e48b7d8a |
def _make_or_mod_server_block(self, achall): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> vhosts = self.configurator.choose_redirect_vhosts(achall.domain, '%i' % self.configurator.config.http01_port, create_if_no_match=True) <NEW_LINE> <DEDENT> except errors.MisconfigurationError: <NEW_LINE> <INDENT> return self._make_... | Modifies a server block to respond to a challenge.
:param achall: Annotated HTTP-01 challenge
:type achall:
:class:`certbot.achallenges.KeyAuthorizationAnnotatedChallenge` | 625941dba4f1c619b28b0317 |
def get_collection(identifier): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return DatasetSeries.objects.get(identifier=identifier) <NEW_LINE> <DEDENT> except ObjectDoesNotExist: <NEW_LINE> <INDENT> raise ValueError("Invalid EOObject identifier %r!" % identifier) | Get an existing DatastSeries database object for given identifier. | 625941db3346ee7daa2b3051 |
def get_icon(self, name): <NEW_LINE> <INDENT> return None | Return the IMG element for the named icon.
Return None if not defined. | 625941db627d3e7fe0d69134 |
def _get_path_visibility(self): <NEW_LINE> <INDENT> path_visible = True <NEW_LINE> if not self._item.visible: <NEW_LINE> <INDENT> path_visible = False <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> for parent in self._parents: <NEW_LINE> <INDENT> if not parent.item.visible: <NEW_LINE> <INDENT> path_visible = False <NEW_... | If this item and all of its parents are visible, return True, otherwise
return False. | 625941dbb7558d58953c51f3 |
def menu_b_or_w(): <NEW_LINE> <INDENT> title = (f'Quelle couleur choisissez vous {player1.name} ?') <NEW_LINE> liste = ['Blancs (O)', 'Noirs (X)', 'Au hasard'] <NEW_LINE> option = menu(title, liste) <NEW_LINE> if option == 3: <NEW_LINE> <INDENT> player1.color = random.choice('OX') <NEW_LINE> <DEDENT> elif option == 2: ... | Choisir noir ou blanc ou aléatoire. | 625941db5510c4643540f6c1 |
def _chromepath(self, path): <NEW_LINE> <INDENT> self._frozen_chrome = True <NEW_LINE> return mozpath.basedir(path, self._chrome) | Return the chrome base directory under which the given path is. Used to
detect under which .jar (if any) the path should go. | 625941dbff9c53063f47c4d6 |
def __init__(self): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self._coreobject = None <NEW_LINE> self._file = None <NEW_LINE> self._log = MusicLogger() <NEW_LINE> self._soup_session = Soup.Session.new() | Initialize StoreArtistArt
:param coreobject: The CoreArtist or CoreAlbum to store art for
:param string uri: The art uri | 625941db82261d6c526ab786 |
def test_controller_instance(self): <NEW_LINE> <INDENT> class DaController(object): pass <NEW_LINE> da_instance = DaController() <NEW_LINE> da_instance = ControllerProtector(None)(da_instance) <NEW_LINE> assert hasattr(da_instance, '__before__') <NEW_LINE> assert ismethod(da_instance.__before__) | The ``__before__`` method must be defined if passed a class
instance. | 625941dbac7a0e7691ed43ab |
def __init__(self, repository, tag="latest", identifier=None, pull_policy=DockerImagePullPolicy.IF_NOT_PRESENT): <NEW_LINE> <INDENT> super(DockerImage, self).__init__(repository, tag=tag) <NEW_LINE> if not isinstance(tag, (six.string_types, None.__class__)): <NEW_LINE> <INDENT> raise ConuException("'tag' is not a strin... | :param repository: str, image name, examples: "fedora", "registry.fedoraproject.org/fedora",
"tomastomecek/sen", "docker.io/tomastomecek/sen"
:param tag: str, tag of the image, when not specified, "latest" is implied
:param identifier: str, unique identifier for this image
:param pull_policy: enum, ... | 625941dbbaa26c4b54cb1401 |
def get_all(self): <NEW_LINE> <INDENT> return db.session.query(Study).all() | # Get all the registered studies
:return: All study objects in a list | 625941db56ac1b37e62644af |
def is_prime(num): <NEW_LINE> <INDENT> if isinstance(num, int): <NEW_LINE> <INDENT> if num <= 1: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> for element in range(2,num): <NEW_LINE> <INDENT> if num % element == 0: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> else : <NEW_LINE> <INDENT> ... | Return True if num is prime. | 625941db4e4d5625662d46b8 |
def delete_group(self, group_id: int) -> Response: <NEW_LINE> <INDENT> url = f"{self.session.root_url}/epi/api/group/{group_id}/" <NEW_LINE> return self.session.delete(url) | Delete a group
Args:
group_id (int): group ID
Returns:
Response: The response object. | 625941db0c0af96317bb84cc |
def send_posts_to_contact(self, client, contact, now, date): <NEW_LINE> <INDENT> microposts = MicroPostManager.get_mine( startKey=date_util.get_db_date_from_date(now), endKey=date_util.get_db_date_from_date(date)) <NEW_LINE> for micropost in microposts: <NEW_LINE> <INDENT> body = micropost.toJson(localized=False) <NEW_... | Send microposts from last month to given contact. | 625941dbb57a9660fec33b6c |
def hasPathSum(self, root, sum): <NEW_LINE> <INDENT> if sum in self.graphPath(root): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | :type root: TreeNode
:type sum: int
:rtype: bool | 625941db379a373c97cfae2a |
def segments(self, __=0) -> List[Segment]: <NEW_LINE> <INDENT> return [self.segment.segments()] | Return the segment of the line | 625941db7d43ff24873a2f85 |
def maxSubArray(self, nums): <NEW_LINE> <INDENT> n = len(nums) <NEW_LINE> if n == 0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> ans = [nums[0]] <NEW_LINE> for i in range(1, n, 1): <NEW_LINE> <INDENT> if ans[i-1]<= 0: <NEW_LINE> <INDENT> ans.append(nums[i]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ans.append(... | :type nums: List[int]
:rtype: int | 625941db009cb60464c63694 |
def get_user_id_from_html(html): <NEW_LINE> <INDENT> soup = BeautifulSoup(html, 'html.parser') <NEW_LINE> return get_user_id_from_soup(soup) | Get user_id from html of home or subject or episode page when logged in
Args:
html (unicode or str): html of home, subject, or episode page
Returns:
str or unicode: user id of the logged in user | 625941db63d6d428bbe447d4 |
def rangerand(start, stop, count): <NEW_LINE> <INDENT> array = [] <NEW_LINE> i = 0 <NEW_LINE> while i < count: <NEW_LINE> <INDENT> array.append(int(random() * (stop - start)) + start) <NEW_LINE> i += 1 <NEW_LINE> <DEDENT> return array | Return array of C random numbers | 625941db94891a1f4081bd8e |
def combinations_np(n, k): <NEW_LINE> <INDENT> a = np.ones((k, n-k+1), dtype=int) <NEW_LINE> a[0] = np.arange(n-k+1) <NEW_LINE> for j in range(1, k): <NEW_LINE> <INDENT> reps = (n-k+j) - a[j-1] <NEW_LINE> a = np.repeat(a, reps, axis=1) <NEW_LINE> ind = np.add.accumulate(reps) <NEW_L... | A NumPy-based analogue of itertools.combinations. Assume you have an
ndarray x with n elements and want to generate all ways of selecting k
indices of x.
Let r = (n choose k). This function generates an ndarray of shape (r,n)
where each column is a set of k indices. | 625941dbd268445f265b5152 |
def add_game_thread_links(self, gtl, gameDate=None): <NEW_LINE> <INDENT> key_date_format = "%Y%m%d" <NEW_LINE> if gameDate is None: <NEW_LINE> <INDENT> gameDate = datetime.now(self.bot_timezone) <NEW_LINE> <DEDENT> key = gameDate.strftime(key_date_format) <NEW_LINE> self.game_thread_links[key] = gtl | adds a game_thread_links object to self.game_thread_links dict with today's date as a key | 625941dbb545ff76a89140f9 |
def DeleteString(self,pos:'Any') -> 'Any': <NEW_LINE> <INDENT> pass | Deletes an item from a listbox.
Args:
pos(Any):The zero based index of the item to delete.MFC References
Returns:
Any:CListBox::DeleteString
Return ValueThe count of the items remaining in the list.
| 625941dbfb3f5b602dac397a |
def __init__(self, iouType='keypoints'): <NEW_LINE> <INDENT> if iouType == 'keypoints': <NEW_LINE> <INDENT> self.setKpParams() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise Exception('iouType not supported') <NEW_LINE> <DEDENT> self.iouType = iouType <NEW_LINE> self.useSegm = None | if iouType == 'segm' or iouType == 'bbox':
self.setDetParams() | 625941dbdd821e528d63b48b |
def test_default_fields(self): <NEW_LINE> <INDENT> job = Job.objects.get(title="Python dev") <NEW_LINE> self.assertEqual(job.remote, False) <NEW_LINE> self.assertIs(job.salary, None) <NEW_LINE> self.assertIsInstance(job.published, datetime) | Jobs default field are correctly | 625941dbcdde0d52a9e53319 |
@raises(ValueError) <NEW_LINE> def test_Sobol_G_raises_error_if_values_gt_one(): <NEW_LINE> <INDENT> evaluate(np.array([0, 1, .02, 0.23, 1.234, 0.02848848, 0, 0.78])) | Tests that a value error is raised if the Sobol G function is called with
values greater than one | 625941db3cc13d1c6d3c765d |
def parse(bibtex): <NEW_LINE> <INDENT> bibtex = special_sequence_cleanup(bibtex) <NEW_LINE> d = search_for_tag(bibtex) <NEW_LINE> m = TYPE_SEARCH(bibtex) <NEW_LINE> if m is not None: <NEW_LINE> <INDENT> d['cite_type'] = m[1].strip().lower() <NEW_LINE> <DEDENT> author = d['author'] <NEW_LINE> if author: <NEW_LINE> <INDE... | Parse bibtex string and return a dictionary of information. | 625941db21bff66bcd684c34 |
def setUp(self): <NEW_LINE> <INDENT> super(TestCCXGrades, self).setUp() <NEW_LINE> self.coach = coach = AdminFactory.create() <NEW_LINE> self.client.login(username=coach.username, password="test") <NEW_LINE> role = CourseCcxCoachRole(self._course.id) <NEW_LINE> role.add_users(coach) <NEW_LINE> ccx = CcxFactory(course_i... | Set up tests | 625941db167d2b6e31218e79 |
def __init__( self, *, path: str = "", db: Union[str, int] = 0, username: Optional[str] = None, password: Optional[str] = None, socket_timeout: Optional[float] = None, socket_connect_timeout: Optional[float] = None, encoding: str = "utf-8", encoding_errors: str = "strict", decode_responses: bool = False, retry_on_timeo... | Initialize a new UnixDomainSocketConnection.
To specify a retry policy, first set `retry_on_timeout` to `True`
then set `retry` to a valid `Retry` object | 625941db21a7993f00bc7fd8 |
def fromSpherToCart(self): <NEW_LINE> <INDENT> return _ParaMEDMEM.DataArrayDouble_fromSpherToCart(self) | fromSpherToCart(self) -> DataArrayDouble
1 | 625941db07d97122c4178b75 |
@bot.command("greetMe") <NEW_LINE> def greetMe_command(chat,message,args): <NEW_LINE> <INDENT> test_str="Konichiwa" <NEW_LINE> test_str_2="Senpai, watashi Anata no jujun'na shimo be" <NEW_LINE> if len(args)>0: <NEW_LINE> <INDENT> test_str+= " "+args[0] <NEW_LINE> test_str+=test_str_2 <NEW_LINE> <DEDENT> else: <NEW_LINE... | Says hello world to the person whose name is provided | 625941db10dbd63aa1bd2e86 |
def _create_subnet(self, network, client=None, namestart='subnet-smoke', **kwargs): <NEW_LINE> <INDENT> if not client: <NEW_LINE> <INDENT> client = self.network_client <NEW_LINE> <DEDENT> def cidr_in_use(cidr, tenant_id): <NEW_LINE> <INDENT> cidr_in_use = self._list_subnets(tenant_id=tenant_id, cidr=cidr) <NEW_LINE> re... | Create a subnet for the given network within the cidr block
configured for tenant networks. | 625941db2eb69b55b151cb97 |
def forward(self, x): <NEW_LINE> <INDENT> conv1 = self.conv_layer1(x) <NEW_LINE> net = self.stem(conv1) <NEW_LINE> net = net + conv1 <NEW_LINE> net = self.pool1(net) <NEW_LINE> net = self.bottle_neck1(net) <NEW_LINE> net = self.residual_block_1(net) <NEW_LINE> net = self.pool2(net) <NEW_LINE> net = self.bottle_neck2(ne... | :param x: x should be a vector containing three successive heartbeats,
which has a length of 600
:return: | 625941dbdc8b845886cb581a |
def split_alphanum(s): <NEW_LINE> <INDENT> s = utils.to_unicode(s) <NEW_LINE> s = RE_AL_NUM.sub(r"\1 \2", s) <NEW_LINE> return RE_NUM_AL.sub(r"\1 \2", s) | Add spaces between digits & letters in `s` using :const:`~hitexsumm.parsing.preprocessing.RE_AL_NUM`.
Parameters
----------
s : str
Returns
-------
str
Unicode string with spaces between digits & letters.
Examples
--------
>>> from hitexsumm.parsing.preprocessing import split_alphanum
>>> split_alphanum("24.0hou... | 625941db96565a6dacc8f9af |
def _find_pg(cs, pg): <NEW_LINE> <INDENT> return utils.find_pg(cs, pg) | Get a pg by name or ID. | 625941db435de62698dfdf31 |
def testEmail(self): <NEW_LINE> <INDENT> report.Email(self.msg) | Try sending a plain message. | 625941dbdc8b845886cb581b |
def initCentral(self): <NEW_LINE> <INDENT> widgetMarketM, dockMarketM = self.createMarketMonitor(MarketMonitor, '行情', QtCore.Qt.RightDockWidgetArea) <NEW_LINE> widgetContractM, dockContractM = self.createDock(ContractMonitor, '合约列表', QtCore.Qt.RightDockWidgetArea) <NEW_LINE> widgetLogM, dockLogM = self.createDock(LogMo... | 初始化中心区域 | 625941db3eb6a72ae02ec7c8 |
def set_options(self, options): <NEW_LINE> <INDENT> for opt in options.keys(): <NEW_LINE> <INDENT> if opt in self.options: <NEW_LINE> <INDENT> self.options[opt] = options[opt] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.log.raiseException("set_options: undefined toolchain option %s specified (possible names %s)"... | Process toolchain options | 625941db0383005118ecf8c6 |
def get_autocomplete(sequence, freq_dict): <NEW_LINE> <INDENT> match_words = match(sequence, freq_dict) <NEW_LINE> if len(match_words) > 0: <NEW_LINE> <INDENT> top_of_freq = top(match_words, 10) <NEW_LINE> words = [word for word, freq in top_of_freq] <NEW_LINE> result = '\n'.join(words) <NEW_LINE> return result <NEW_LI... | The most frequently used words, in descending order of frequency in string | 625941db442bda511e8be6f9 |
def schedule(self, event, priority=NORMAL, delay=0): <NEW_LINE> <INDENT> heappush(self._queue, (self._now + delay, priority, next(self._eid), event)) | Schedule an *event* with a given *priority* and a *delay*. | 625941dba17c0f6771cbe334 |
def __get__(self, SC, cls): <NEW_LINE> <INDENT> if len(self.dates) == 0: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> date = SC.date <NEW_LINE> idx = np.searchsorted(self.dates, date, side='right') - 1 <NEW_LINE> return self.values[idx] if (idx >= 0) else None | Get the value at the last sample which occurs before or at SC.date.
For instance::
idx = [0, 1, 2, 3, 4]
| | | | |
dates = [0, 1, 2, 2, 3] # idx = 3 for date=2
dates = [0, 1, 2, 2, 3] # idx = -1 for date=-0.1 (no value)
dates = [0, 1, 2, 2, 3] # idx = 1 for date=1.0
dates = [0, 1, 2, 2, 3... | 625941db9f2886367277ab70 |
def height(self): <NEW_LINE> <INDENT> return self.cell_width * len(self.matrix[0]) | returns the height of the grid matrix in pixils | 625941db2ae34c7f2600d415 |
def __post_init__(self) -> None: <NEW_LINE> <INDENT> if self.name.endswith("_add") or self.name.endswith("_remove"): <NEW_LINE> <INDENT> self.name, self.modifier = self.name.rsplit("_", maxsplit=1) <NEW_LINE> <DEDENT> self.value = _sanitise_value(self.value) | Parse modifiers and convert list values to sets. | 625941dbb545ff76a89140fa |
def test_user_creation(global_integration_cli_args, example_user): <NEW_LINE> <INDENT> username, user_description = example_user <NEW_LINE> args = ['-v', 'user', 'create', 'ingest', username] <NEW_LINE> if user_description: <NEW_LINE> <INDENT> args.extend(['--description', user_description]) <NEW_LINE> <DEDENT> _run_cl... | Add a user, grant them, delete them.
This test requires role creation privileges on the PostgreSQL instance used for testing...
:type global_integration_cli_args: tuple[str]
:type db: datacube.index.postgres._api.PostgresDb | 625941db76e4537e8c351959 |
def get_least_popular_server(): <NEW_LINE> <INDENT> servers_data = scrape_servers_data() <NEW_LINE> servers_data = apply_whitelist(servers_data) <NEW_LINE> min_plyr_qty = 9999 <NEW_LINE> min_plyr_ip = "" <NEW_LINE> for ip_addr, data in servers_data.items(): <NEW_LINE> <INDENT> active_players = get_active_players(data) ... | Returns the IP of the server with the least players, used only for development | 625941dbe1aae11d1e749f9e |
def test_if_no_agreements_dont_source_by_agreement(self): <NEW_LINE> <INDENT> product_without_agreement = self.env.ref('product.product_product_7') <NEW_LINE> lrl = next(line for line in self.requisition.line_ids if line.product_id == product_without_agreement) <NEW_LINE> source = lrl._generate_default_source() <NEW_LI... | We choose an existing lrl for a product that has an agreement | 625941dbff9c53063f47c4d7 |
def __init__(self, config_file_name=None, config=None, cmd_args=None): <NEW_LINE> <INDENT> if not config: <NEW_LINE> <INDENT> if not config_file_name or not os.path.exists(config_file_name): <NEW_LINE> <INDENT> raise ElmConfigError('config_file_name {} does not ' 'exist'.format(config_file_name)) <NEW_LINE> <DEDENT> wi... | Parses an elm config dictionary or yaml file
Params:
config_file_name: file name of a yaml elm config
config: elm config dict
Returns:
ConfigParser instance | 625941db16aa5153ce36275c |
def testLRBackwardsCompatibility(self): <NEW_LINE> <INDENT> opt = optimizers.Kfac( learning_rate=3.0, damping=5.0, model=_simple_mlp(), loss='mse') <NEW_LINE> self.assertEqual(backend.get_value(opt.lr), 3.0) <NEW_LINE> self.assertEqual(backend.get_value(opt.learning_rate), 3.0) <NEW_LINE> opt.lr = 7.0 <NEW_LINE> self.a... | This tests learning rate getting/setting used by old Keras callbacks. | 625941db090684286d50efcd |
def __call__(self, *, response: Response, expression: str) -> Dict[str, Any]: <NEW_LINE> <INDENT> root: etree._Element = self.parser(response.content) <NEW_LINE> if root is not None: <NEW_LINE> <INDENT> tree: etree._ElementTree = root.getroottree() <NEW_LINE> result = root.xpath(expression) <NEW_LINE> if isinstance(res... | Parse response with a given XPath expression.
:param response: HTTP response to parse
:param expression: XPath query string
:returns: parsed response
:raises: etree.LxmlError | 625941db50812a4eaa59c604 |
def configureSlewRate(self, rate): <NEW_LINE> <INDENT> if rate > 10.0 and rate <= 4000.0: <NEW_LINE> <INDENT> self.write("SF") <NEW_LINE> <DEDENT> elif rate > 4000.0: <NEW_LINE> <INDENT> self.write("SS") <NEW_LINE> <DEDENT> self.write("SR %s" % str(rate)) | Set the slew rate for a zero to full-scale transision.
:param rate: Rise and Fall time (in microseconds)
:type rate: float | 625941db236d856c2ad44ac2 |
def read_single_objects(container, size, dkey, akey, obj): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> data = container.read_an_obj(size, dkey, akey, obj) <NEW_LINE> <DEDENT> except DaosApiError as error: <NEW_LINE> <INDENT> raise DaosTestError( "Error reading data (dkey={}, akey={}, size={}) from the " "container: {}... | Read data from the container.
Args:
container (DaosContainer): the container from which to read objects
size (int): amount of data to read
dkey (bytes): dkey used to access the data
akey (bytes): akey used to access the data
obj (object): object to read
txn (int): transaction number
Returns:
... | 625941db925a0f43d254a15e |
def __update_statistics_table(self): <NEW_LINE> <INDENT> format_dict = {} <NEW_LINE> category_df = self.chosen_category_df.groupby(self.monthyear).sum() <NEW_LINE> if self.months[-1] in category_df.index: <NEW_LINE> <INDENT> last = category_df[self.price].iloc[-1] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> last = np... | Function updates text in "Statistics" Table Div.
Statistics Table Div is the most complex Div in the Gridplot. It defines several descriptive statistic
values corresponding to .chosen_category Category Expenses. Template for this text is located in
.statistics_table attribute and it should define all format keywords d... | 625941db23849d37ff7b3372 |
def _add_connection(self, event_name, callback): <NEW_LINE> <INDENT> cid = self.figure.canvas.mpl_connect(event_name, callback) <NEW_LINE> self._cids.append(cid) | Called to add a connection to an event of the figure
:param str event_name: The matplotlib event name to connect to.
:param callback: The callback to register to this event. | 625941db3346ee7daa2b3052 |
def limpiar(): <NEW_LINE> <INDENT> if os.name == "nt": <NEW_LINE> <INDENT> os.system("cls") <NEW_LINE> <DEDENT> elif os.name == "posix": <NEW_LINE> <INDENT> os.system("clear") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print("<-No se pudo borrar la pantalla->") | Limpiar pantalla | 625941dbd10714528d5fffcb |
def getProcess(self): <NEW_LINE> <INDENT> proc_list =[] <NEW_LINE> for proc in psutil.process_iter(attrs=['pid', 'name', 'username', 'cmdline']): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if proc.info['cmdline'][1] == '/root/hospital/lora_receiver.py': <NEW_LINE> <INDENT> proc_list.append(proc.info) <NEW_LINE> <DEDE... | process_iter() : 실행중인 모든 프로세스의 클래스 인스턴스 생성 반복자(iterator) 반환. 일회성
cmdline : 해당 프로세스를 실행 하는 커맨드 라인.
이를 통해 우리 프로젝트 개발자들이 지정해놓은 프로세스 이름을 반환 받을 수 있음 | 625941db23e79379d52ee845 |
def BiezerPoint(x, y, sectionEnd=False, strfmt="{:.5f}"): <NEW_LINE> <INDENT> return Element( "BezierPoint", x=strfmt.format(x), y=strfmt.format(y), sectionEnd=str(sectionEnd).lower(), ) | Biezer Curve Control point.
Parameters
----------
x, y : :class:`float`
Location of the control point.
sectionEnd : :class:`bool`, :code:`False`
Whether the control point is an end point (for non-closed paths).
strfmt : :class:`str`
Float formatting string.
Notes
------
* Line segments which have onl... | 625941db24f1403a92600e49 |
def testAutoAccept(self): <NEW_LINE> <INDENT> console.terse("{0}\n".format(self.testAutoAccept.__doc__)) <NEW_LINE> self.opts['auto_accept'] = True <NEW_LINE> self.assertTrue(self.opts['auto_accept']) <NEW_LINE> self.assertDictEqual(self.mainKeeper.all_keys(), {'accepted': [], 'local': [], 'rejected': [], 'pending': []... | Basic function of RaetKey in auto accept mode | 625941dbf9cc0f698b1408de |
def minCost_3(self, grid: List[List[int]]) -> int: <NEW_LINE> <INDENT> import collections <NEW_LINE> import math <NEW_LINE> from typing import Iterator, Tuple <NEW_LINE> m, n = len(grid), len(grid[0]) <NEW_LINE> def neighborhood(y: int, x: int) -> Iterator[Tuple[int, int, int]]: <NEW_LINE> <INDENT> if x + 1 < n: <NEW_L... | 0-1 BFS | 625941dbd4950a0f3b08c630 |
def load_skeleton_json(node): <NEW_LINE> <INDENT> skeleton = [] <NEW_LINE> for line in node: <NEW_LINE> <INDENT> if line[0] in ('literal', 'pragma', 'grflangid', 'plural', 'case', 'gender'): <NEW_LINE> <INDENT> skeleton.append((line[0], line[1])) <NEW_LINE> <DEDENT> elif line[0] == 'string': <NEW_LINE> <INDENT> skeleto... | Load skeleton file from the Json node.
@param node: The node with the saved skeleton data in Json format.
@type node: C{list}
@return: The loaded skeleton data, as described in the L{Project} class.
@rtype: C{list} of (C{str}, C{str}) | 625941dba219f33f34628c4b |
def setUpClassData(klass): <NEW_LINE> <INDENT> mod_dir = os.path.realpath(os.path.dirname(data_importer.tests.__file__)) <NEW_LINE> klass.files = { 'csv_invalid_cpf_sheet': os.path.join(mod_dir,'fixtures','csv_invalid_cpf_sheet.csv'), 'csv_sheet': os.path.join(mod_dir,'fixtures','csv_sheet.csv'), 'xls_sheet': os.path.j... | This method should receive one test class and setup common data used over all tests classes.
If you will write a new reader, use this csv data as base:
cpf;field3;field4;field5
437.692.351-69;;Emperor Palpatine: Soon the Rebellion will be crushed and young Skywalker will be one of us!
541.903.660-64;Darth Vader: When... | 625941db0fa83653e465729e |
def _step3(state): <NEW_LINE> <INDENT> marked = (state.marked == 1) <NEW_LINE> state.col_uncovered[np.any(marked, axis=0)] = False <NEW_LINE> if marked.sum() < state.C.shape[0]: <NEW_LINE> <INDENT> return _step4 | Cover each column containing a starred zero. If n columns are covered,
the starred zeros describe a complete set of unique assignments.
In this case, Go to DONE, otherwise, Go to Step 4. | 625941db046cf37aa974d02a |
def get_swift_tunnel_httpgw_listen_port(self): <NEW_LINE> <INDENT> return self.sessconfig['swifttunnelhttpgwlistenport'] | Returns the TCP listen port for the CMDGW of the swift process.
@return Port number. | 625941db460517430c394464 |
def cairns(aboveground_biomass): <NEW_LINE> <INDENT> if aboveground_biomass <= 0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return math.exp(-1.085 + 0.9256 * math.log(aboveground_biomass)) | Calculates belowground biomass as a function of aboveground biomass.
Derived from "Equation 1" in Cairns, Brown, Helmer & Baumgardner (1997),
available online at:
www.arb.ca.gov/cc/capandtrade/protocols/usforest/references/cairns1997.pdf
Aboveground biomass expected in units of kg, and returns units of kg. | 625941db3617ad0b5ed681db |
def change_dt_to_crontab(_datetime): <NEW_LINE> <INDENT> if type(_datetime) == str: <NEW_LINE> <INDENT> matchend = re.match("(.*?)-(.*?)-(.*?) (.*?):(.*?):(.*?)", _datetime) <NEW_LINE> if not matchend: <NEW_LINE> <INDENT> return False, "Error: Datetime Str should like 2019-1-2 11:11:12" <NEW_LINE> <DEDENT> _dt = dateti... | # 将 DateTime 的字符串类型或者是时间类型转化为crontab的格式。
# crontab * * * * *
:param datetime: 字符串或者是时间类型
:return: True, Crontab | 625941dbfbf16365ca6f64ad |
def publish_event(self, stale_event): <NEW_LINE> <INDENT> event = Event.objects().get(id=stale_event.id) <NEW_LINE> if not event.published: <NEW_LINE> <INDENT> raise GoogleCalendarAPIError('Event must have published as `True` before publishing') <NEW_LINE> <DEDENT> return self.move_event(event, from_id=self.private_cal... | Publish an event, moving it to the public calendar.
- event (Event): The event to publish | 625941db3c8af77a43ae3a87 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.