code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def on_run_start(self, request): <NEW_LINE> <INDENT> self._update_run_calls_state(request.run_call_count, request.fetches, request.feed_dict) <NEW_LINE> if self._run_till_filter_pass: <NEW_LINE> <INDENT> return framework.OnRunStartResponse(framework.OnRunStartAction.DEBUG_RUN, self._get_run_debug_urls()) <NEW_LINE> <DE... | Overrides on-run-start callback.
Invoke the CLI to let user choose what action to take:
run / run --no_debug / step.
Args:
request: An instance of OnSessionInitRequest.
Returns:
An instance of OnSessionInitResponse.
Raises:
RuntimeError: If user chooses to prematurely exit the debugger. | 625941bb30bbd722463cbc74 |
def stdev(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return math.sqrt(sum([(x[0] - self._avg)**2 for x in self._history])/(self._count - 1)) <NEW_LINE> <DEDENT> except ZeroDivisionError: <NEW_LINE> <INDENT> return 0.0 | Returns the standard deviation of the recorded measurements.
@rtype: float
@return: standard deviation | 625941bb24f1403a92600a1a |
def disconnect_by_key(self, obj, name, key): <NEW_LINE> <INDENT> signals = setdefaultattr(obj, self._signal_attr, {}) <NEW_LINE> handlers = signals.get(name, []) <NEW_LINE> handlers[:] = [h for h in handlers if h[0] is not key] | :param obj: the object to disconnect the signal from
:type obj: object
:param name: the signal to disconnect, typically a string
:type name: signal name
:param key: the key for this signal handler, as returned by
connect_signal().
:type key: Key
This function will remove a callback from the list connected
... | 625941bb26238365f5f0ed1b |
def extractDay(self, input): <NEW_LINE> <INDENT> day = self.extractDay(input) <NEW_LINE> if day: <NEW_LINE> <INDENT> return day[0] <NEW_LINE> <DEDENT> return None | Returns the first time-related date found in the input string,
or None if not found. | 625941bb6fb2d068a760ef4b |
def get_queryset(self): <NEW_LINE> <INDENT> if not self.request.user.is_authenticated: <NEW_LINE> <INDENT> raise Http404 <NEW_LINE> <DEDENT> qs = Course.objects.filter( certifying_organisation=self.certifying_organisation) <NEW_LINE> return qs | Get the queryset for this view.
:returns: Course queryset filtered by Organisation
:rtype: QuerySet
:raises: Http404 | 625941bb090684286d50eb92 |
def test_delitem(self): <NEW_LINE> <INDENT> del self.hit[0] <NEW_LINE> self.assertEqual(2, len(self.hit)) <NEW_LINE> self.assertEqual([hsp112, hsp113], self.hit.hsps) | Test Hit.__delitem__. | 625941bbbe7bc26dc91cd4b6 |
def test_grant_to_super_user(self): <NEW_LINE> <INDENT> hosts = Host.objects.user_filter(self.admin) <NEW_LINE> self.assertEqual(hosts.count(), Host.objects.count(), "Superuser can't access to all hosts") | Superuser access to every hosts. | 625941bbc432627299f04af5 |
def build_dynamic_library(exprs, preferred_signature=None): <NEW_LINE> <INDENT> exprs_logic = parse_exprs_if_str(exprs) <NEW_LINE> signature, exprs = combine_signatures_or_rename_preds( exprs_logic, preferred_signature) <NEW_LINE> signature = remove_reserved_predicates(signature) <NEW_LINE> return signature, exprs | Create a dynamic library with types of objects that appear in coq formulae.
Optionally, it may receive partially specified signatures for objects
using the format by NLTK (e.g. {'_john' : e, '_mary' : e, '_love' : <e,<e,t>>}). | 625941bb7b25080760e3930c |
def set_acceleration(self, channel, acceleration): <NEW_LINE> <INDENT> logger.info("set acceleration CHAN({0}) = {1}".format(channel, acceleration)) <NEW_LINE> outStr = bytearray([_SET_ACCELERATION_CMD, channel, self.low_bits(acceleration), self.high_bits(acceleration)]) <NEW_LINE> return self.write(outStr) | Sets the acceleration limit of the servo channel
@brief This command limits the acceleration of a servo channel’s output. The acceleration limit is a value
from 0 to 255 in units of (0.25 microseconds)/(10 ms)/(80 ms), except in special cases. A value of 0
corresponds to no acceleration limit. An acceleration limit cau... | 625941bbd6c5a10208143ef9 |
def extrair_atributos(xml): <NEW_LINE> <INDENT> return dict(ER_ATRIB_VALOR.findall(xml)) | Extrair todos os pares atributo-valor de um xml | 625941bbbe383301e01b533d |
def getTopic(): <NEW_LINE> <INDENT> pass | get the graduation topic | 625941bb21bff66bcd684806 |
def installed(name, recurse=False, force=False): <NEW_LINE> <INDENT> ret = {'name': name, 'result': True, 'changes': {}, 'comment': ''} <NEW_LINE> if name not in __salt__['win_servermanager.list_installed'](): <NEW_LINE> <INDENT> ret['changes'] = {'feature': '{0} will be installed recurse={1}'.format(name, recurse)} <N... | Install the windows feature
name:
short name of the feature (the right column in win_servermanager.list_available)
recurse:
install all sub-features as well
force:
if the feature is installed but on of its sub-features are not installed set this to True to force
the installation of the sub-features
... | 625941bbd18da76e23532384 |
def test_gdal_translate_get_one_band(self): <NEW_LINE> <INDENT> generated_image = terre_image_processing.gdal_translate_get_one_band(self.terre_image_layer.source_file, 1, self.working_dir) <NEW_LINE> baseline = os.path.join(self.data_dir_baseline, "taredji_extract_b1.tif") <NEW_LINE> self.assertTrue(self.checkResult(g... | Test the gdal function to get a specific band
Returns: | 625941bb56b00c62f0f14508 |
def test_index_flavors_basic(self): <NEW_LINE> <INDENT> flavors = self._index_flavors() <NEW_LINE> for flavor in flavors: <NEW_LINE> <INDENT> self._assert_flavor_entity_basic(flavor) | List all flavors | 625941bb21a7993f00bc7b9c |
def analyze_single(self, target, amount = 5, output = None, extra_svm_feats = []): <NEW_LINE> <INDENT> if self.model is None: <NEW_LINE> <INDENT> raise Exception('Model not loaded.') <NEW_LINE> <DEDENT> if isinstance(target,str): <NEW_LINE> <INDENT> text = target <NEW_LINE> true_y = None <NEW_LINE> result = predict_sin... | return analyze result of a query
results will be stored into disk if output is specified | 625941bbe1aae11d1e749b66 |
def correlation_spectrum(x1, x2, Fs=2 * np.pi, norm=False): <NEW_LINE> <INDENT> x1 = x1 - np.mean(x1) <NEW_LINE> x2 = x2 - np.mean(x2) <NEW_LINE> x1_f = fftpack.fft(x1) <NEW_LINE> x2_f = fftpack.fft(x2) <NEW_LINE> D = np.sqrt(np.sum(x1 ** 2) * np.sum(x2 ** 2)) <NEW_LINE> n = x1.shape[0] <NEW_LINE> ccn = ((np.real(x1_f)... | Calculate the spectral decomposition of the correlation.
Parameters
----------
x1,x2: ndarray
Two arrays to be correlated. Same dimensions
Fs: float, optional
Sampling rate in Hz. If provided, an array of
frequencies will be returned.Defaults to 2
norm: bool, optional
When this is true, the spectrum is n... | 625941bb97e22403b379ce4a |
def print_result(result): <NEW_LINE> <INDENT> print("Total score: %s" % result["score"]) <NEW_LINE> for module_data in result["results"]: <NEW_LINE> <INDENT> print("Module %s score: %s" % (module_data["module"], module_data["score"])) <NEW_LINE> print("Module %s logfile: %s" % (module_data["module"], module_data["logfi... | Prints results well formated. | 625941bb462c4b4f79d1d582 |
def _guess_quote_and_delimiter( data, delimiters): <NEW_LINE> <INDENT> matches = [] <NEW_LINE> for restr in ( '(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\']).*?(?P=quote)(?P=delim)', '(?:^|\n)(?P<quote>["\']).*?(?P=quote)(?P<delim>[^\w\n"\'])(?P<space> ?)', '(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\']).*?(?P=... | Looks for text enclosed between two identical quotes
(the probable quotechar) which are preceded and followed
by the same character (the probable delimiter).
For example:
,'some text',
The quote with the most wins, same with the delimiter.
If there is no quotechar the delimiter can't be determined
this... | 625941bb50485f2cf553cc4a |
def update_power(self): <NEW_LINE> <INDENT> self.Sbus = self.makeSbus(self.baseMVA, self.bus, self.gen, self.active_generators, self.Cg) <NEW_LINE> self.some_power_changed = False | compute complex bus power injections [generation - load] | 625941bb1d351010ab8559cf |
def config_set(cwd=None, setting_name=None, setting_value=None, user=None, is_global=False): <NEW_LINE> <INDENT> if setting_name is None or setting_value is None: <NEW_LINE> <INDENT> raise TypeError <NEW_LINE> <DEDENT> if cwd is None and not is_global: <NEW_LINE> <INDENT> raise SaltInvocationError('Either `is_global` m... | Set a key in the git configuration file (.git/config) of the repository or
globally.
setting_name
The name of the configuration key to set
setting_value
The (new) value to set
cwd : None
Options path to the Git repository
.. versionchanged:: Helium
Made ``cwd`` optional
user : None
Run ... | 625941bb07f4c71912b11339 |
def store_other_info(self, rights_statement): <NEW_LINE> <INDENT> other_info = models.RightsStatementOtherRightsInformation() <NEW_LINE> other_info.rightsstatement = rights_statement <NEW_LINE> other_info.otherrightsbasis = self.column_value("basis").lower().capitalize() <NEW_LINE> other_info.otherrightsapplicablestart... | Store "other" basis column values in the database. | 625941bb23e79379d52ee419 |
def isPalindrome(palindrome, eq=lambda x,y: x==y): <NEW_LINE> <INDENT> length = len(palindrome) <NEW_LINE> for i in range(length/2): <NEW_LINE> <INDENT> if not eq(palindrome[i], palindrome[length-(i+1)]): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> return True | Returns whether a variable is a palindrome or not using a passed-in equals function. | 625941bb3cc13d1c6d3c7235 |
def columnCount(self, index): <NEW_LINE> <INDENT> return int() | int Akonadi.MessageThreaderProxyModel.columnCount(QModelIndex index) | 625941bb8a43f66fc4b53f1b |
def print_human_info(**info): <NEW_LINE> <INDENT> output_str = '' <NEW_LINE> for key, value in info.items(): <NEW_LINE> <INDENT> output_str += f'{key.capitalize()}: {value}. ' <NEW_LINE> <DEDENT> print(output_str) | Выводит имя, фамилию, год рождения, город проживания, email, телефон | 625941bbcdde0d52a9e52ee1 |
def getCoverageMetaInfo(self, Id, Chrom): <NEW_LINE> <INDENT> resourcePath = '/coverage/{Id}/{Chrom}/meta' <NEW_LINE> method = 'GET' <NEW_LINE> queryParams = {} <NEW_LINE> headerParams = {} <NEW_LINE> resourcePath = resourcePath.replace('{Chrom}', Chrom) <NEW_LINE> resourcePath = resourcePath.replace('{Id}', Id) <NEW_L... | Returns metadata about coverage of a chromosome.
Note that HrefCoverage must be available for the provided BAM file
:param Id: the Id of a Bam file
:param Chrom: chromosome name
:returns: a CoverageMetaData instance | 625941bba17c0f6771cbdf05 |
def check_sn(self, data): <NEW_LINE> <INDENT> check_sum = data[-2:] <NEW_LINE> check = self.gen_check(data[2:-2]) <NEW_LINE> return check == check_sum | 检查校验码
return protocal_version, cmd | 625941bbe64d504609d746f2 |
def get_Color(self): <NEW_LINE> <INDENT> return super(IMultiLayerFillSymbol, self).get_Color() | Method IFillSymbol.get_Color (from IFillSymbol)
OUTPUT
Color : IColor** | 625941bb73bcbd0ca4b2bf2f |
def p_struct_member_declaration(self, p): <NEW_LINE> <INDENT> result = self._symbol_table.get_symbol(p[2]) <NEW_LINE> struct = result.symbol <NEW_LINE> p[0] = ast.struct.Member() <NEW_LINE> p[0].set_line_number(p.lineno(3)) <NEW_LINE> p[0].set_file_name(self._filename) <NEW_LINE> p[0].set_type(struct) <NEW_LINE> p[0].s... | member-declaration : KW_STRUCT ID ID EOS | 625941bb3317a56b86939b1a |
def test_chi_transpose_random(self): <NEW_LINE> <INDENT> mats = [self.rand_matrix(4, 4) for _ in range(4)] <NEW_LINE> chans = [Chi(Operator(mat)) for mat in mats] <NEW_LINE> self._compare_transpose_to_operator(chans, mats) | Test transpose of Chi matrices is correct. | 625941bb45492302aab5e172 |
def check_files(user_input): <NEW_LINE> <INDENT> file_ext = ['*.fit*', '*.FIT*'] <NEW_LINE> data_files = [] <NEW_LINE> working_dir = os.path.exists(user_input) <NEW_LINE> if working_dir: <NEW_LINE> <INDENT> os.chdir(user_input) <NEW_LINE> if glob.glob('*.gz*'): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> sp.check_call... | Checks to make sure given directory is a valid directory.
If directory exists, returns list of .fit or .fits files. | 625941bbbde94217f3682cad |
def authenticate(self, content): <NEW_LINE> <INDENT> if content.get('nick') == 'admin': <NEW_LINE> <INDENT> self.set_admin() <NEW_LINE> <DEDENT> return True | Check if current user is admin | 625941bb5e10d32532c5ede0 |
def obj_type_dec(self, obj_type): <NEW_LINE> <INDENT> self.obj_type_count[obj_type] -= 1 <NEW_LINE> if self.obj_type_count[obj_type] == 0: <NEW_LINE> <INDENT> self.cluster_ids.add(obj_type) <NEW_LINE> self.obj_types.remove(obj_type) <NEW_LINE> del self.obj_type_count[obj_type] <NEW_LINE> del self.obj_type_mem[obj_type] | Decrement the number of objects with given type.
Remove from set of object types if no objects belong to type. | 625941bb50485f2cf553cc4b |
def compress(s): <NEW_LINE> <INDENT> x = lister(s) <NEW_LINE> y = map(printer,x) <NEW_LINE> return combineStrings(y) | compresses a sequence of binary digits into a condensed version | 625941bb63b5f9789fde6f97 |
def wait_for_statistic_of_metric(self, meter_name, query=None, period=None): <NEW_LINE> <INDENT> def check_status(): <NEW_LINE> <INDENT> stat_state_resp = self.ceilometer_client.statistics.list( meter_name, q=query, period=period) <NEW_LINE> if len(stat_state_resp) > 0: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDEN... | The method is a customization of test.status_timeout(). | 625941bbb830903b967e97c8 |
def test_add_second_task_x(client, jmb): <NEW_LINE> <INDENT> global session, tasks_db <NEW_LINE> jmb.add_page("tasks", TasksPage) <NEW_LINE> session = dict(user=User("admin"), wipdbs=dict()) <NEW_LINE> tasks_db = {1: Task(1, "Task 1", "First task")} <NEW_LINE> r = client.post( "/tasks/tasks/add", data=json.dumps( dict(... | Calling save without properly created seted wipdb_id and task_id | 625941bb96565a6dacc8f587 |
def setZeroes(self, matrix: List[List[int]]) -> None: <NEW_LINE> <INDENT> m = len(matrix) <NEW_LINE> n = len(matrix[0]) <NEW_LINE> columns = [] <NEW_LINE> rows = [] <NEW_LINE> for r in range(0, m): <NEW_LINE> <INDENT> c = [i for i, e in enumerate(matrix[r]) if e == 0] <NEW_LINE> if c: <NEW_LINE> <INDENT> rows.append(r)... | Do not return anything, modify matrix in-place instead. | 625941bb45492302aab5e173 |
def extract(url): <NEW_LINE> <INDENT> html_str = get_html(url) <NEW_LINE> if html_str == None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> article_temp = extract_text_by_block(html_str) <NEW_LINE> try: <NEW_LINE> <INDENT> article = extract_text_by_tag(html_str, article_temp) <NEW_LINE> <DEDENT> except: <NEW_LIN... | 抽取正文
:param url: 网页链接
:return:正文文本 | 625941bbfff4ab517eb2f2ec |
def firstBadVersion(self, n): <NEW_LINE> <INDENT> lo, md, hi = 0, 0, n <NEW_LINE> while lo <= hi: <NEW_LINE> <INDENT> md = (lo + hi) // 2 <NEW_LINE> if isBadVersion(md): <NEW_LINE> <INDENT> hi = md - 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> lo = md + 1 <NEW_LINE> <DEDENT> <DEDENT> return lo | :type n: int
:rtype: int | 625941bb287bf620b61d3920 |
def has_add_permission(self, request, obj=None): <NEW_LINE> <INDENT> return False | Adding stacks manually is not supported. | 625941bbab23a570cc250032 |
def submit_new_login(self, email, realname, password1, password2, *args, **kw): <NEW_LINE> <INDENT> if self.user_mgr.create_user(email, realname, password1, password2): <NEW_LINE> <INDENT> self.user_mgr.create_new_session(email) <NEW_LINE> raise RedirectException(DASHBOARD_URL) <NEW_LINE> <DEDENT> else: <NEW_LINE> <IND... | Creates a new login. | 625941bb7d847024c06be16c |
def run(self, params: dict): <NEW_LINE> <INDENT> for func in self.__func_array: <NEW_LINE> <INDENT> if not isinstance(func, str): <NEW_LINE> <INDENT> raise ValueError('__func_array value must str') <NEW_LINE> <DEDENT> if not hasattr(self, func): <NEW_LINE> <INDENT> raise AttributeError('"%s" object has not attribute "%... | 启动方法, 指定为run方法.子类中如果更换了启动方法, 需要将启动方法的方法名赋值给 __run 变量
:param params: 一个字典
:return: 返回整个实例的运行结果 | 625941bbd164cc6175782c00 |
def combine(label, accesskey, accesskey_marker=DEFAULT_ACCESSKEY_MARKER): <NEW_LINE> <INDENT> assert isinstance(label, unicode) <NEW_LINE> assert isinstance(accesskey, unicode) <NEW_LINE> if len(accesskey) == 0: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> searchpos = 0 <NEW_LINE> accesskeypos = -1 <NEW_LINE> in... | Combine a label and and accesskey to form a label+accesskey string
We place an accesskey marker before the accesskey in the label and this
creates a string with the two combined e.g. "File" + "F" = "&File"
:type label: unicode
:param label: a label
:type accesskey: unicode char
:param accesskey: The accesskey
:rtype:... | 625941bb63f4b57ef0000fd3 |
def test_roundtripNestedValue(self): <NEW_LINE> <INDENT> d = self.proxy.callRemote('defer', {'a': self.value}) <NEW_LINE> d.addCallback(self.assertEqual, {'a': self.value}) <NEW_LINE> return d | A C{dict} which contains C{self.value} can be round-tripped over an
XMLRPC method call/response. | 625941bb5f7d997b8717494e |
def makeLoggingPacket(self, name=None): <NEW_LINE> <INDENT> p = self._makePacket() <NEW_LINE> return LoggingPacket(p, name) | Create a direct ethernet server request packet with tracing | 625941bbcc0a2c11143dcd48 |
def test_task_data_flow(self): <NEW_LINE> <INDENT> params = {"func": "pow", "inputs": ["arg", "power", "modulo"], "stored_data_varname": "data"} <NEW_LINE> spec = {"arg": 2, "power": 3, "modulo": None} <NEW_LINE> action = PyTask(**params).run_task(spec) <NEW_LINE> self.assertEqual(action.stored_data["data"], 8) <NEW_LI... | test dataflow parameters: inputs, outputs and chunk_number | 625941bb7047854f462a12bf |
def getTheClassificaton(listofFour): <NEW_LINE> <INDENT> maxvalue = max(listofFour) <NEW_LINE> if listofFour[0] == maxvalue: <NEW_LINE> <INDENT> return 'financial_disclosure' <NEW_LINE> <DEDENT> elif listofFour[1] == maxvalue: <NEW_LINE> <INDENT> return 'crm' <NEW_LINE> <DEDENT> elif listofFour[2] == maxvalue: <NEW_LIN... | input the list of 4 and output the class defined
| 625941bbd6c5a10208143efa |
def index(request): <NEW_LINE> <INDENT> return render(request, 'SNP_Feature_View/index.html') | Home page. | 625941bbb5575c28eb68deb1 |
def _get_change_tree(self): <NEW_LINE> <INDENT> if self.parent and self.parent.parent: <NEW_LINE> <INDENT> headers_to_change = list(self.parent.parent.get_descendants()) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> headers_to_change = list(Header.objects.filter(type=self.type)) <NEW_LINE> <DEDENT> accounts_to_change =... | Get extra :class:`Headers<Header>` and :class:`Accounts<Account>`.
A change in a :class:`Header` may cause changes in the number of Headers
up to it's grandfather.
We only save one :class:`Account` under each :class:`Header` because
each :class:`Account` will save it's siblings.
:returns: Additional instances to sav... | 625941bbfbf16365ca6f6070 |
def __init__(self, k): <NEW_LINE> <INDENT> self.lst = [0] * k <NEW_LINE> self.k = k <NEW_LINE> self.front = 0 <NEW_LINE> self.back = 0 <NEW_LINE> self.size = 0 | Initialize your data structure here. Set the size of the queue to be k.
:type k: int | 625941bb92d797404e30403c |
def leadColor(*args, **kwargs): <NEW_LINE> <INDENT> pass | leadColor() -> MColor
Returns the color for lead objects. | 625941bb1f037a2d8b9460b1 |
def generate_date_filter(date_param_name, date_start=None, date_end=None): <NEW_LINE> <INDENT> search_param = dict() <NEW_LINE> if date_start is not None: <NEW_LINE> <INDENT> search_param[date_param_name + '__gte'] = date_start <NEW_LINE> <DEDENT> if date_end is not None: <NEW_LINE> <INDENT> search_param[date_param_nam... | 生成时间筛选 | 625941bb56ac1b37e6264088 |
def _parse_color_str(self, color_str): <NEW_LINE> <INDENT> rgb = [int(x) for x in color_str.split(',')] <NEW_LINE> return QColor(rgb[0], rgb[1], rgb[2]) | change str to int and set it as a color config
:param color_str: str from config file
:return: QColor object | 625941bbbe8e80087fb20afa |
def coinChange(self, coins, amount): <NEW_LINE> <INDENT> dp = [amount + 1 for x in range(amount + 1)] <NEW_LINE> dp[0] = 0 <NEW_LINE> for i in range(1, amount + 1): <NEW_LINE> <INDENT> for coin in coins: <NEW_LINE> <INDENT> if i - coin >= 0: <NEW_LINE> <INDENT> dp[i] = min(dp[i], 1 + dp[i - coin]) <NEW_LINE> <DEDENT> <... | :type coins: List[int]
:type amount: int
:rtype: int | 625941bb1f037a2d8b9460b2 |
def flatten( self: Self_DecayChain, stable_particles: Iterable[Union[Dict[str, int], List[str], str]] = (), ) -> Self_DecayChain: <NEW_LINE> <INDENT> vis_bf = self.bf <NEW_LINE> fs = DaughtersDict(self.decays[self.mother].daughters) <NEW_LINE> if stable_particles: <NEW_LINE> <INDENT> keys = [k for k in self.decays.keys... | Flatten the decay chain replacing all intermediate, decaying particles,
with their final states.
Parameters
----------
stable_particles: iterable, optional, default=()
If provided, ignores the sub-decays of the listed particles,
considering them as stable.
Note
----
After flattening the only `DecayMode` metad... | 625941bb046cf37aa974cbfd |
def delete(self, app, version, target='master', artifact=None): <NEW_LINE> <INDENT> if not artifact: <NEW_LINE> <INDENT> artifact = u'%s.tar.gz' % app <NEW_LINE> <DEDENT> artifact_path = os.path.join(app, target, artifact) <NEW_LINE> versions = self.list_versions(app, target, artifact) <NEW_LINE> if version and version... | Delete an object from the repository. | 625941bbcad5886f8bd26e95 |
def test_repeat_orbit_calls_asym_multi_day_0_UT_long_time_gap(self): <NEW_LINE> <INDENT> self.stime += dt.timedelta(days=334) <NEW_LINE> self.testInst.load(date=self.stime) <NEW_LINE> self.testInst.orbits.next() <NEW_LINE> control = self.testInst.copy() <NEW_LINE> for j in range(20): <NEW_LINE> <INDENT> self.testInst.o... | Test successful orbit calls for many different days with a long gap
| 625941bb099cdd3c635f0b0f |
def __init__(self): <NEW_LINE> <INDENT> super(Cursor, self).__init__(image=games.load_image("Sprites/cursor.png"), x=games.mouse.x, y=games.mouse.y) <NEW_LINE> self.mouseClicked = False <NEW_LINE> self.mouseCounter = 0 <NEW_LINE> self.gunShotSound = games.load_sound("Sounds/shot.wav") | Cursor Initializer | 625941bb63d6d428bbe443a2 |
def unregister(self, handler): <NEW_LINE> <INDENT> if not self.is_running_handlers: <NEW_LINE> <INDENT> self.handlers.remove(handler) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.to_remove.add(handler) <NEW_LINE> <DEDENT> return handler | Removes a handler so that it doesn't receive future messages.
>>> dispatch.unregister(handler) | 625941bb6e29344779a624c8 |
def bc_get_links(driver, in_link): <NEW_LINE> <INDENT> driver.get(in_link) <NEW_LINE> time.sleep(7) <NEW_LINE> html = driver.page_source <NEW_LINE> soup = BeautifulSoup(html, "html5lib") <NEW_LINE> recipe_links = [] <NEW_LINE> for i in range(5): <NEW_LINE> <INDENT> body = soup.find('main', {"class":"content"}) <NEW_LIN... | Inputs link and returns list of recipe links to scrape for BC | 625941bb3c8af77a43ae3650 |
def median_absolute_deviation(timeseries): <NEW_LINE> <INDENT> series = pandas.Series([x[1] for x in timeseries]) <NEW_LINE> median = series.median() <NEW_LINE> demedianed = np.abs(series - median) <NEW_LINE> median_deviation = demedianed.median() <NEW_LINE> if median_deviation == 0: <NEW_LINE> <INDENT> return False <N... | A timeseries is anomalous if the deviation of its latest datapoint with
respect to the median is X times larger than the median of deviations. | 625941bb8e7ae83300e4ae7f |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, SharedDataEntrySchema): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941bbbf627c535bc13089 |
def replaceInputSeriesName(seriesname): <NEW_LINE> <INDENT> for pat, replacement in Config['input_series_replacements'].items(): <NEW_LINE> <INDENT> if re.match(pat, seriesname, re.IGNORECASE|re.UNICODE): <NEW_LINE> <INDENT> return replacement <NEW_LINE> <DEDENT> <DEDENT> return seriesname | allow specified replacements of series names
in cases where default filenames match the wrong series,
e.g. missing year gives wrong answer, or vice versa
This helps the TVDB query get the right match. | 625941bb71ff763f4b549542 |
def gen_simulated_frb(NFREQ=1536, NTIME=2**10, sim=True, fluence=1.0, spec_ind=0.0, width=0.0005, dm=0, background_noise=None, delta_t=0.00008192, plot_burst=False, freq=(1520., 1220.), FREQ_REF=1400., scintillate=False, scat_tau_ref=0.0, disp_ind=2., conv_dmsmear=False): <NEW_LINE> <INDENT> plot_burst = False <NEW_LIN... | Simulate fast radio bursts using the EventSimulator class.
Parameters
----------
NFREQ : np.int
number of frequencies for simulated array
NTIME : np.int
number of times for simulated array
sim : bool
whether or not to simulate FRB or just create noise array
spec_ind : tuple
r... | 625941bb2eb69b55b151c75e |
def __coerce_type(self, key, value): <NEW_LINE> <INDENT> (default, typ, restrictions) = self._map[key] <NEW_LINE> if value is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if typ == "choice": <NEW_LINE> <INDENT> assert value in restrictions, "Invalid choice %s for %s. Valid choices include: %s" % (value, k... | For validating set functions and also for deserialization, this method ensures
the arguments are of the right type according to the map.
string accepts only strings
int accepts ints or strings
list accepts lists of objects or basic types, container type is required
choice accepts only certain... | 625941bbbe7bc26dc91cd4b8 |
def get_all(self, **kwargs): <NEW_LINE> <INDENT> kwarguments = {} <NEW_LINE> if 'language' in kwargs: <NEW_LINE> <INDENT> kwarguments['language'] = kwargs['language'] <NEW_LINE> <DEDENT> return [{'id': p.get_vocabulary_id(), 'concepts': p.get_all(**kwarguments)} for p in self.providers.values()] | Get all concepts from all providers.
.. code-block:: python
# get all concepts in all providers.
registry.get_all()
# get all concepts in all providers.
# If possible, display the results with a Dutch label.
registry.get_all(language='nl')
:param string language: Optional. If present, it should ... | 625941bb50812a4eaa59c1d8 |
def update(self, **kwargs): <NEW_LINE> <INDENT> for k, v in kwargs.iteritems(): <NEW_LINE> <INDENT> if k in self.attributes: <NEW_LINE> <INDENT> setattr(self, k, v) <NEW_LINE> <DEDENT> elif k == 'childs': <NEW_LINE> <INDENT> for n in sorted(kwargs['childs']): <NEW_LINE> <INDENT> newChild = self.newChild(**kwargs['child... | Update class data with given attributes
:param kwargs: child data (key must start with self.__attrPrefix__)
:type kwargs: dict | 625941bb7b180e01f3dc46b7 |
def all_exercises(self): <NEW_LINE> <INDENT> admin = Profile.objects.get(user__username='davidr') <NEW_LINE> return Exercise.objects.filter(Q(created_by=self) | Q(created_by=admin)) | Returns all default and user created exercises. | 625941bb3eb6a72ae02ec388 |
def customMouseRelease(self, event): <NEW_LINE> <INDENT> pass | Summary
Args:
event (TYPE): Description
Returns:
TYPE: Description | 625941bb2eb69b55b151c75f |
def test_search(): <NEW_LINE> <INDENT> root: Tk = tk.Tk() <NEW_LINE> app = JSONTreeFrame(root, json_path="../dat/list.json") <NEW_LINE> try: <NEW_LINE> <INDENT> x = app.find("fuzzy") <NEW_LINE> <DEDENT> except AttributeError as err: <NEW_LINE> <INDENT> assert False <NEW_LINE> <DEDENT> assert True | search should not break in case of numeric fields | 625941bb379a373c97cfa9fe |
def test_del_wrong_user(self): <NEW_LINE> <INDENT> self.client.login(username='test_user2', password='test_password2') <NEW_LINE> self.client.get('/delete_team/1/', follow=True) <NEW_LINE> self.assertTemplateUsed('scheduler/access_denied.html') | attempt to delete a team without being team admin | 625941bb23e79379d52ee41a |
def login(number,pwd): <NEW_LINE> <INDENT> login_url = 'http://222.206.65.12/reader/redr_verify.php' <NEW_LINE> data = { 'number':number, 'passwd':pwd, 'returnUrl':'', 'select':'cert_no', } <NEW_LINE> data = urllib.urlencode(data) <NEW_LINE> req = urllib2.Request(url=login_url, data=data) <NEW_LINE> login_ret = opener.... | 登陆 | 625941bbd6c5a10208143efb |
def isDone(*args, **kwargs): <NEW_LINE> <INDENT> pass | isDone() -> Bool
Indicates whether or not all nodes or plugs have been iterated over
in accordance with the direction, traversal, level and filter.
If a valid filter is set, the iterator only visits those nodes that match
the filter. | 625941bb8e71fb1e9831d660 |
def document(self): <NEW_LINE> <INDENT> self.prepare_document() <NEW_LINE> self._required_attrs(['template', 'name']) <NEW_LINE> doc = [] <NEW_LINE> header_text = "{} FAWS Template".format(self.resource_name()) <NEW_LINE> doc.append(header_text + "\n" + ('=' * len(header_text))) <NEW_LINE> doc.append(self.template.desc... | Returns documentation for the template | 625941bb21bff66bcd684808 |
def main(global_config, **settings): <NEW_LINE> <INDENT> config = Configurator(settings=settings) <NEW_LINE> config.include('pyramid_chameleon') <NEW_LINE> config.add_static_view('static', 'static', cache_max_age=3600) <NEW_LINE> config.add_route('home', '/') <NEW_LINE> config.add_route('add', '/add') <NEW_LINE> config... | This function returns a Pyramid WSGI application.
| 625941bb1b99ca400220a964 |
def iterate_transaction(self, start_date, end_date, callback): <NEW_LINE> <INDENT> sql = ('SELECT i.name,t.instrument,t.type,t.price,t.shares,t.fee,t.date FROM [transaction] t, instrument i ' 'WHERE t.instrument = i.rowid AND date >=? AND date<=? ORDER BY date') <NEW_LINE> epoch1 = int(timegm(start_date.timetuple())) <... | iterate stock transactions, callback signature:
callback(instrument id,instrument name,transaction type,price, shares,fee, date) | 625941bb21a7993f00bc7b9e |
def get(self): <NEW_LINE> <INDENT> context = { "title": "Geographic BLS Sources", "sources": [], } <NEW_LINE> query = "SELECT DISTINCT source FROM states_series" <NEW_LINE> for row in db.session.execute(query): <NEW_LINE> <INDENT> context["sources"].append({ "name": row[0], "url": self.get_detail_url(row[0]), }) <NEW_L... | Returns all the distinct sources and their urls | 625941bb8e05c05ec3eea225 |
def __init__(self, loginbutton_properties, credential_label_properties, loginscreen_properties, *args, **kwargs): <NEW_LINE> <INDENT> self.size = Window.size <NEW_LINE> self.login_screen = LoginScreen(loginbutton_properties=loginbutton_properties, credential_label_properties=credential_label_properties, **loginscreen_p... | This widget is supposed to be root of application! | 625941bbd10714528d5ffb93 |
def make_html_plot(figure): <NEW_LINE> <INDENT> script, div = bokeh.embed.components(figure, wrap_script=False) <NEW_LINE> script = "<script>;var _runBokehPlot = function() {\n" + script + "\n};\n</script>" <NEW_LINE> return script + "\n" + div | Wrap the bokeh figure into an embeddable HTML element, containing a function that can be called to draw the plot. | 625941bb1d351010ab8559d0 |
def main() -> None: <NEW_LINE> <INDENT> data = aocd.get_data(year=2021, day=25) <NEW_LINE> seafloor = read_map(data) <NEW_LINE> print(f"Part 1: {moves_until_still(seafloor)}") | Calculate and output the solutions based on the real puzzle input. | 625941bb9b70327d1c4e0c87 |
def process_response(self, request, response): <NEW_LINE> <INDENT> if ( hasattr(request, 'resolver_match') and hasattr(request.resolver_match, 'namespaces') and isinstance(request.resolver_match.namespaces, list) and 'api' in request.resolver_match.namespaces ): <NEW_LINE> <INDENT> add_never_cache_headers(response) <NE... | Args:
https://docs.djangoproject.com/en/1.10/topics/http/middleware/
Returns:
HttpResponse | 625941bbb7558d58953c4dce |
def log_in_interface_graphics(self, usn ="", pw="")->str: <NEW_LINE> <INDENT> items = ["Username: ", "Password: "] <NEW_LINE> input_list = [usn, "*"*len(pw)] <NEW_LINE> data_header = "LOGIN DETAILS" <NEW_LINE> login = self.IFmethods.creation_interface(items, input_list, data_header) <NEW_LINE> return self.defaultheader... | Is to be triggered every time a new input is made inlogin menu | 625941bb1d351010ab8559d1 |
def getnames(self): <NEW_LINE> <INDENT> return [am.filename for am in self.getmembers()] | Return a list of the (file)names of all the members in the archive
in the order they are in the archive. | 625941bb50485f2cf553cc4c |
def push(self, item): <NEW_LINE> <INDENT> self._size += 1 <NEW_LINE> return self.stack.append(item) | pushes new item to stack | 625941bb7d43ff24873a2b51 |
def pop(self): <NEW_LINE> <INDENT> return _osgAnimation.vectorVec2Keyframe_pop(self) | pop(vectorVec2Keyframe self) -> Vec2Keyframe | 625941bb5fdd1c0f98dc00e5 |
def get_logger(name: str, file_name_path: str = 'yang.log'): <NEW_LINE> <INDENT> exists = False <NEW_LINE> if os.path.isfile(file_name_path): <NEW_LINE> <INDENT> exists = True <NEW_LINE> <DEDENT> FORMAT = '%(asctime)-15s %(levelname)-8s %(filename)s %(name)5s => %(message)s - %(lineno)d' <NEW_LINE> DATEFMT = '%Y-%m-%d ... | Create formated logger with the specified name and store at path defined by
'file_name_path' argument.
Arguments:
:param file_name_path (str) filename and path where to save logs.
:param name (str) Set name of the logger.
:return a logger with the specified name. | 625941bb0c0af96317bb809d |
def test_SMCP(self): <NEW_LINE> <INDENT> check_instruction("SMCP $C15, 2047($SP)", "fffe07ff") <NEW_LINE> check_instruction("SMCP $C15, -1($SP)", "fffeffff") <NEW_LINE> check_instruction("SMCP $C4, 17362($9)", "f49e43d2") <NEW_LINE> check_instruction("SMCP $C3, 6490($4)", "f34e195a") <NEW_LINE> check_instruction("SMCP ... | Test the SMCP instruction | 625941bb3539df3088e2e1ff |
def _getTemplateFromFile( self, name ): <NEW_LINE> <INDENT> filename = self._config.render_template(name, self._variables ) <NEW_LINE> content = None <NEW_LINE> if os.path.isfile(filename): <NEW_LINE> <INDENT> with open( filename, 'r', encoding="utf-8") as myfile: <NEW_LINE> <INDENT> content = myfile.read() <NEW_LINE> ... | Load template from file
Parameters
----------
name: str
template filename
Returns
-------
filepath : str
Name and path for the new file
filename : str
Name only for the new file | 625941bb7c178a314d6ef30d |
def __init__(self, parent=None, useOpenGL=True): <NEW_LINE> <INDENT> self.closed = False <NEW_LINE> QtGui.QGraphicsView.__init__(self, parent) <NEW_LINE> if 'linux' in sys.platform: <NEW_LINE> <INDENT> useOpenGL = False <NEW_LINE> <DEDENT> self.useOpenGL(useOpenGL) <NEW_LINE> palette = QtGui.QPalette() <NEW_LINE> brush... | Re-implementation of QGraphicsView that removes scrollbars and allows unambiguous control of the
viewed coordinate range. Also automatically creates a QGraphicsScene and a central QGraphicsWidget
that is automatically scaled to the full view geometry.
By default, the view coordinate system matches the widget's pixel ... | 625941bb4a966d76dd550ec0 |
def set_path(self, name, path, **kwargs): <NEW_LINE> <INDENT> self.__getattr__(name).path=self._fix_path(path) <NEW_LINE> self.__dict__[name].set(**kwargs) <NEW_LINE> return(self) | Adds a new path attribute with name name.
name: name of the attribute.
path: path string.
kwargs: passed to Info.set(). | 625941bb090684286d50eb95 |
def cmdline_params(self, file1_name, file2_name): <NEW_LINE> <INDENT> parameters = [] <NEW_LINE> pm_dict = self.get_dict() <NEW_LINE> for k in pm_dict.keys(): <NEW_LINE> <INDENT> if pm_dict[k]: <NEW_LINE> <INDENT> parameters += ['--' + k] <NEW_LINE> <DEDENT> <DEDENT> parameters += [file1_name, file2_name] <NEW_LINE> re... | Synthesize command line parameters.
e.g. [ '--ignore-case', 'filename1', 'filename2']
:param file_name1: Name of first file
:param type file_name1: str
:param file_name2: Name of second file
:param type file_name2: str | 625941bb55399d3f05588567 |
def predict_cumulative_hazard_function(self, X): <NEW_LINE> <INDENT> risk_score = numpy.exp(self.predict(X)) <NEW_LINE> n_samples = risk_score.shape[0] <NEW_LINE> funcs = numpy.empty(n_samples, dtype=numpy.object_) <NEW_LINE> for i in range(n_samples): <NEW_LINE> <INDENT> funcs[i] = StepFunction(x=self.cum_baseline_haz... | Predict cumulative hazard function.
The cumulative hazard function for an individual
with feature vector :math:`x` is defined as
.. math::
H(t \mid x) = \exp(x^\top \beta) H_0(t) ,
where :math:`H_0(t)` is the baseline hazard function,
estimated by Breslow's estimator.
Parameters
----------
X : array-like, shap... | 625941bb4c3428357757c1de |
def ListGroups(opts, args): <NEW_LINE> <INDENT> desired_fields = ParseFields(opts.output, _LIST_DEF_FIELDS) <NEW_LINE> fmtoverride = { "node_list": (",".join, False), "pinst_list": (",".join, False), "ndparams": (_FmtDict, False), } <NEW_LINE> cl = GetClient(query=True) <NEW_LINE> return GenericList(constants.QR_GROUP,... | List node groups and their properties.
@param opts: the command line options selected by the user
@type args: list
@param args: groups to list, or empty for all
@rtype: int
@return: the desired exit code | 625941bb8e71fb1e9831d661 |
def get_capability(capability: Capability) -> bool: <NEW_LINE> <INDENT> return capability in get_capabilities() | Returns the status for a specific capability. | 625941bb97e22403b379ce4d |
def _plot3d_options(self, options=None): <NEW_LINE> <INDENT> if options is None: <NEW_LINE> <INDENT> options = self.options() <NEW_LINE> <DEDENT> options_3d = {} <NEW_LINE> if 'rgbcolor' in options: <NEW_LINE> <INDENT> options_3d['rgbcolor'] = options['rgbcolor'] <NEW_LINE> del options['rgbcolor'] <NEW_LINE> <DEDENT> i... | Translate 2D plot options into 3D plot options.
EXAMPLES::
sage: P = line([(-1,-2), (3,5)], alpha=.5, thickness=4)
sage: p = P[0]; p
Line defined by 2 points
sage: q=p.plot3d()
sage: q.thickness
4
sage: q.texture.opacity
0.500000000000000 | 625941bb7cff6e4e81117839 |
def normalize_data(raw_data): <NEW_LINE> <INDENT> data = [0, 0, 0] <NEW_LINE> data[0] = (raw_data[0] << 4) + (raw_data[1] >> 4) <NEW_LINE> data[1] = (raw_data[2] << 4) + (raw_data[3] >> 4) <NEW_LINE> data[2] = (raw_data[4] << 4) + (raw_data[5] >> 4) <NEW_LINE> for i in range(3): <NEW_LINE> <INDENT> if data[i] >> 11 == ... | Converts raw accelerometer data to normalized values. | 625941bb0a50d4780f666d43 |
def example_integrand(xarr, weight=None): <NEW_LINE> <INDENT> n_dim = xarr.shape[-1] <NEW_LINE> a = tf.constant(0.1, dtype=DTYPE) <NEW_LINE> n100 = tf.cast(100 * n_dim, dtype=DTYPE) <NEW_LINE> pref = tf.pow(1.0 / a / np.sqrt(np.pi), n_dim) <NEW_LINE> coef = tf.reduce_sum(tf.range(n100 + 1)) <NEW_LINE> coef += tf.reduce... | Example function that integrates to 1 | 625941bb1b99ca400220a965 |
def line_counts_as_uncovered(line: str, is_from_cover_annotation_file: bool) -> bool: <NEW_LINE> <INDENT> if is_from_cover_annotation_file: <NEW_LINE> <INDENT> if not line.startswith('! '): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> content = line[2:] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> content = li... | Args:
line: The line of code (including coverage annotation).
is_from_cover_annotation_file: Whether this line has been annotated.
Returns:
Does the line count as uncovered? | 625941bbd8ef3951e32433f1 |
def itemset(self, *args): <NEW_LINE> <INDENT> item = args[-1] <NEW_LINE> args = args[:-1] <NEW_LINE> self[args] = item | Set Python scalar into array | 625941bb656771135c3eb725 |
def GetLoadConstructDataString(ode_name): <NEW_LINE> <INDENT> save_load_data_string = (translator.GetBlockCommentDefinition(0, "De-serialize constructor parameters and intiialise a " + ode_name + ".", True) + "template<class Archive>\n" + "inline void load_construct_data(\n" + translator.AddTabs(1) + "Archive & ar, " +... | Get the string describing the de-serialization of the constructor and initialisation of the ODE system. | 625941bba8370b7717052754 |
def Puff_model(x, y, z, current_time, leak, atm, time, wind, angle): <NEW_LINE> <INDENT> X, Y, Z = np.meshgrid(x,y,z) <NEW_LINE> H = leak.height <NEW_LINE> Q = leak.size <NEW_LINE> Ffactor = leak.factors <NEW_LINE> u = wind <NEW_LINE> theta = angle <NEW_LINE> X2 = X*np.cos(theta) + Y*np.sin(theta) <NEW_LINE> Y2 = -X*np... | Puff model that calculates spatial concentration of a given leak at each timestep
Inputs:
x,y,z: 1-D of spatial coordinates where concentration is calculated
current_time: current time-step in the simulation
leak: leak size
atm: Object containing atmospheric parameters l... | 625941bb293b9510aa2c314c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.