code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def draw(self, x, y, dc, styler): <NEW_LINE> <INDENT> device = self.device <NEW_LINE> for j1, j2, x1, y1, child in self.iter_boxes(0, x, y): <NEW_LINE> <INDENT> r = Rect(x1, y1, x1+child.width, y1+child.height) <NEW_LINE> if device.intersects(dc, r): <NEW_LINE> <INDENT> child.draw(x1, y1, dc, styler) | Draws box and all child boxes at origin (x, y). | 625941bc71ff763f4b54955d |
def has_attribute(self, key): <NEW_LINE> <INDENT> return self.get_attribute(key) is not None | True if self.attributes includes key. | 625941bc3317a56b86939b3f |
def checkcohrand(sts,sta): <NEW_LINE> <INDENT> Cp=[] <NEW_LINE> stsi=sts.copy() <NEW_LINE> for k in range(0,100): <NEW_LINE> <INDENT> for tr in stsi: <NEW_LINE> <INDENT> tr.data=np.random.randn(tr.data.size) <NEW_LINE> <DEDENT> stsi.filter('bandpass',freqmin=2,freqmax=30.) <NEW_LINE> vl = checkcoh(stsi,sta) <NEW_LINE> ... | :param sts: data
:param sta: templates | 625941bc3eb6a72ae02ec3ab |
def sign_body(body, apikey="12345678"): <NEW_LINE> <INDENT> a = ["".join(i) for i in body.items() if i[1] and i[0] != "sign"] <NEW_LINE> strA = "".join(sorted(a)) <NEW_LINE> strsigntemp = strA + apikey <NEW_LINE> def jiamimd5(src): <NEW_LINE> <INDENT> m = hashlib.md5() <NEW_LINE> m.update(src.encode('utf-8')) <NEW_LINE... | 请求body sign签名 | 625941bc9b70327d1c4e0caa |
def render_html_form(action_url, selections1, selections2, time_group='days', select1=None, select2=None): <NEW_LINE> <INDENT> return get_lookup().get_template('form_data.mako').render( selections1=selections1, selections2=selections2, time_group=time_group, select1=select1, select2=select2, action_url=action_url ) | Render a HTML form that can be used to query the data in bitmapist.
:param :action_url The action URL of the <form> element. The form will always to a GET request.
:param :selections1 A list of selections that the user can filter by, example `[ ('Are Active', 'active'), ]`
:param :selections2 A list of selections that... | 625941bc85dfad0860c3ad30 |
def parse_sensor_list (sensors, convert_reading, convert_number, sensor_type): <NEW_LINE> <INDENT> status_key = sensor_type + "_Status" <NEW_LINE> number_key = sensor_type + "_Number" <NEW_LINE> reading_key = sensor_type + "_Reading" <NEW_LINE> parsed = [None] * len (sensors) <NEW_LINE> for i, sensor in sensors.items (... | Parse the dictionary list of sensor data and convert it into an array used by the REST template.
:param sensors: The dictionary list of sensor data to parse. As the sensor data is parsed, the
information will be removed from this dictionary.
:param convert_reading: A flag indicating if the sensor reading should be co... | 625941bcc4546d3d9de72908 |
def test_get_artists_fail(self): <NEW_LINE> <INDENT> artists = self.handle.get_artists(None) <NEW_LINE> self.assertIsNone(artists) | Try to get artists when no tablatures has been added. | 625941bcfbf16365ca6f6094 |
def dispatch(self, *args, **kwargs): <NEW_LINE> <INDENT> self.object = self.get_object() <NEW_LINE> if getattr(perms, self.object.__class__.__name__.lower())(self.request.user, getattr(self, 'permission', 'view'), self.object): <NEW_LINE> <INDENT> return super(ProblemMixin, self).dispatch(*args, **kwargs) <NEW_LINE> <D... | Problem permission check. | 625941bc16aa5153ce36234f |
@app.route('/add', methods=['GET', 'POST']) <NEW_LINE> def add_item(): <NEW_LINE> <INDENT> if logged_in_user() is None: <NEW_LINE> <INDENT> return redirect(url_for('login')) <NEW_LINE> <DEDENT> if request.method == 'POST': <NEW_LINE> <INDENT> title = request.form['item_name'] <NEW_LINE> description = request.form['desc... | Shows the 'add item' form and processes/saves submissions.
:return: A Flask view | 625941bc7d847024c06be190 |
def __init__(self, *args): <NEW_LINE> <INDENT> _itkVectorContainerPython.vectoritkPointD3_swiginit(self,_itkVectorContainerPython.new_vectoritkPointD3(*args)) | __init__(self) -> vectoritkPointD3
__init__(self, vectoritkPointD3 arg0) -> vectoritkPointD3
__init__(self, size_type size) -> vectoritkPointD3
__init__(self, size_type size, value_type value) -> vectoritkPointD3 | 625941bc091ae35668666e3b |
def set_station(self, station, signal): <NEW_LINE> <INDENT> self.station_status[station] = signal | Sets station [0,..., 7] to True or False (On | Off) in memory.
Use set_shift_register_values() to activate GPIO | 625941bc9c8ee82313fbb64b |
def error(update:Update, context: CallbackContext): <NEW_LINE> <INDENT> logger.warning('Update "%s" caused error "%s"', update, context.error) <NEW_LINE> with open('errorLog.txt','a') as outfile: <NEW_LINE> <INDENT> outfile.write('Update: '+str(update)+' caused error '+str(context.error)+ '\n') | Log Errors caused by Updates. | 625941bc6fb2d068a760ef71 |
def regen_keys(): <NEW_LINE> <INDENT> for fn_ in os.listdir(__opts__['pki_dir']): <NEW_LINE> <INDENT> path = os.path.join(__opts__['pki_dir'], fn_) <NEW_LINE> try: <NEW_LINE> <INDENT> os.remove(path) <NEW_LINE> <DEDENT> except os.error: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> <DEDENT> with salt.transport.client.Re... | Used to regenerate the minion keys.
CLI Example:
.. code-block:: bash
salt '*' saltutil.regen_keys | 625941bc24f1403a92600a40 |
def calculate_test_score_only(student_answers, model_answers): <NEW_LINE> <INDENT> correct_answers = 0 <NEW_LINE> for question in student_answers['question_id']: <NEW_LINE> <INDENT> student_answer_to_question = student_answers[student_answers['question_id'] == question] <NEW_LINE> model_answers_to_question =... | TODO
:param student_answers:
:param model_answers:
:return: | 625941bcb5575c28eb68ded5 |
def _wait_for_env_operation_finish(self, eb_client, env_name, original_request_id, pending_status, expected_health, operation_name, action_name, wait_timeout, poll_delay, include_deleted = 'false', initial_delay = 0, ): <NEW_LINE> <INDENT> if pending_status is None and expected_health is None: <NEW_LINE> <INDENT> retur... | Loop polling environment status while it is in specified pending_status
and/or health state, until status changes and/or health state meet expectation,
or reach wait_timeout threshold. While polling retrieve events related to
specified request_id or all recent events if not specified. | 625941bcd164cc6175782c24 |
def test_cleanme(self): <NEW_LINE> <INDENT> temp_dir = self.mkdir(self.tmpdir, 'temp') <NEW_LINE> bin_dir = self.mkdir(self.tmpdir, 'bin') <NEW_LINE> source_dir = self.mkdir(self.tmpdir, 'source') <NEW_LINE> build_rules_py = os.path.join(self.tmpdir, 'build_rules.py') <NEW_LINE> save_text_file(build_rules_py, [ _IMPORT... | Test to see if cleanme loads build_rules.py. | 625941bcdc8b845886cb540b |
def get_log_conditional_probability_gradient(self, node, value=None): <NEW_LINE> <INDENT> node = self.get_node(node) <NEW_LINE> gradient = node.zeros() <NEW_LINE> print_debug(" summing over dependencies: ") <NEW_LINE> for dependence in self.get_node_dependencies(node): <NEW_LINE> <INDENT> print_debug(" - dependence: ... | Returns the gradient of the log of the conditional probability of the given node. | 625941bc627d3e7fe0d68d25 |
@contextlib.contextmanager <NEW_LINE> def no_internet(verbose=False): <NEW_LINE> <INDENT> already_disabled = INTERNET_OFF <NEW_LINE> turn_off_internet(verbose=verbose) <NEW_LINE> try: <NEW_LINE> <INDENT> yield <NEW_LINE> <DEDENT> finally: <NEW_LINE> <INDENT> if not already_disabled: <NEW_LINE> <INDENT> turn_on_internet... | Context manager to temporarily disable internet access (if not already
disabled). If it was already disabled before entering the context manager
(i.e. `turn_off_internet` was called previously) then this is a no-op and
leaves internet access disabled until a manual call to `turn_on_internet`. | 625941bc5166f23b2e1a5030 |
def make_sigma(S_R, S_Rprime): <NEW_LINE> <INDENT> sigma_redundant = [] <NEW_LINE> for b1 in S_R: <NEW_LINE> <INDENT> for b2 in S_Rprime: <NEW_LINE> <INDENT> if b1[0] in b2: <NEW_LINE> <INDENT> sigma_redundant.append((b1, b2)) <NEW_LINE> break <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> sigma = remove_redundant_items(sigma_r... | Given quotient set of refining relation and quotient set of relation that is refined, make mapping sigma between them | 625941bc7b25080760e39332 |
def get_sig_coverage(af_ip, af_api_key, sample_data, hash_counters): <NEW_LINE> <INDENT> print('Searching Autofocus for current signature coverage...') <NEW_LINE> search_values = {"apiKey": af_api_key, "coverage": 'true', "sections": ["coverage"], } <NEW_LINE> headers = {"Content-Type": "application/json"} <NEW_LINE> h... | for sample hits, second query to find signature coverage in sample analysis | 625941bc30c21e258bdfa372 |
def create_constraint_str(self, param_prefix=""): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return "{0:f} < {1} < {2:f}".format(self.width[0], param_prefix + "Width", self.width[2]) <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> return "" | Returns a constraints string for the Fit algorithm
:param param_prefix: An optional prefix for the parameter name | 625941bcab23a570cc250057 |
def Bar(xs, ys, **options): <NEW_LINE> <INDENT> options = _UnderrideColor(options) <NEW_LINE> options = _Underride(options, linewidth=0, alpha=0.6) <NEW_LINE> pyplot.bar(xs, ys, **options) | Plots a line.
:param xs: sequence of x value
:param ys: sequence of y value
:param options: keyword args passed to pyplot.bar | 625941bc99cbb53fe6792abe |
def test_06_degressive_limit(self): <NEW_LINE> <INDENT> asset = self.asset_model.create({ 'name': 'test asset', 'profile_id': self.ref('account_asset_management.' 'account_asset_profile_car_5Y'), 'purchase_value': 1000, 'salvage_value': 100, 'date_start': time.strftime('%Y-07-07'), 'method_time': 'year', 'method': 'deg... | Degressive with annual depreciation. | 625941bcff9c53063f47c0cd |
def list_clusters(self) -> List[license_proto.ClusterStatus]: <NEW_LINE> <INDENT> return self._req(Service.LICENSE, "ListClusters").clusters | List clusters registered with the license service.
Returns
-------
List[license_proto.ClusterStatus]
A list of protobuf objects that return info on a cluster. | 625941bc3c8af77a43ae3675 |
def get_activation(name_list): <NEW_LINE> <INDENT> activation = [] <NEW_LINE> for n_ in name_list: <NEW_LINE> <INDENT> if n_ is None: <NEW_LINE> <INDENT> activation.append(None) <NEW_LINE> <DEDENT> elif n_ == 'relu': <NEW_LINE> <INDENT> activation.append(tf.nn.relu) <NEW_LINE> <DEDENT> elif n_ == 'leaky_relu': <NEW_LIN... | Converts list of activation names into tf activation function
Args:
name_list: list of string format names for the activation function
Returns:
activation: list of tf activation functions | 625941bcc432627299f04b1b |
def setUp(self): <NEW_LINE> <INDENT> super().setUp() <NEW_LINE> submission = sub_api.create_submission(STUDENT_ITEM, ANSWER) <NEW_LINE> training_api.on_start(submission['uuid']) <NEW_LINE> self.submission_uuid = submission['uuid'] | Create a submission. | 625941bc0fa83653e4656e94 |
def icc(graph, message): <NEW_LINE> <INDENT> m = len(message) <NEW_LINE> if graph.num < m: <NEW_LINE> <INDENT> sys.exit() <NEW_LINE> <DEDENT> g = gc(Graph(graph.num, graph.edge)) <NEW_LINE> for i in range(m, g.num): <NEW_LINE> <INDENT> message.append(0) <NEW_LINE> <DEDENT> for i in range(g.num): <NEW_LINE> <INDENT> if ... | ICC Algorithm.
| 625941bca17c0f6771cbdf2a |
def is_in_place(place): <NEW_LINE> <INDENT> return is_link(Is_in) & link_predicate(lambda link: link.where == place) | Return a link predicate that selects Is_in nodes for a given place.
| 625941bcad47b63b2c509e57 |
def Stop(self): <NEW_LINE> <INDENT> if self._running: <NEW_LINE> <INDENT> self.after_cancel(self._timer) <NEW_LINE> self._elapsedtime = time.time() - self._start <NEW_LINE> self._setTime(self._elapsedtime) <NEW_LINE> self._running = 0 | Stop the timer, ignore if stopped. | 625941bcde87d2750b85fc66 |
@singledispatch <NEW_LINE> def stationize(df, aggr='prom'): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> df = df.xs(aggr, 1, 'aggr') <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> stations = df.columns.get_level_values('station') <NEW_LINE> if len(stations.get_duplicates()) > 0: <NEW_... | Return a copy of a DataFrame with only station codes as column labels. If the resulting set of column lables is not unique (more than one sensor for the same variable at the same station), the returned copy has the ``sensor_code`` as column labels.
:param df: Input DataFrame with :class:`pandas.MultiIndex` in columns.... | 625941bc377c676e91272082 |
def find_test_class(self, test_file_content): <NEW_LINE> <INDENT> match_classes = [ (m.group(1), m.end()) for m in re.finditer(r'\s?class\s+(\w+)\s?\(', test_file_content)] <NEW_LINE> if match_classes: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return [ (c, p) for (c, p) in match_classes if "Test" in c or "test" in c... | Try to find the test class, return None if can't be found
| 625941bcbf627c535bc130ad |
def test_invalid_checksum(self): <NEW_LINE> <INDENT> for test in INVALID_CHECKSUM: <NEW_LINE> <INDENT> self.assertRaises(ValueError, b32decode, test) | Test validation (failure) of invalid checksums. | 625941bc01c39578d7e74d13 |
def find_checked_path(): <NEW_LINE> <INDENT> checked_path_cmd = "find " + os.path.join(ASCEND_ROOT_PATH, "ascenddk") + " -maxdepth 1 -mindepth 1 -type d -print" <NEW_LINE> ret = util.execute(checked_path_cmd, print_output_flag=True) <NEW_LINE> if ret[0] is False: <NEW_LINE> <INDENT> return False, [] <NEW... | find static check base path | 625941bca4f1c619b28aff17 |
def set_lights_rgb(hass, lights, rgb): <NEW_LINE> <INDENT> for light in lights: <NEW_LINE> <INDENT> if is_on(hass, light): <NEW_LINE> <INDENT> turn_on(hass, light, rgb_color=rgb, transition=30) | Set color of array of lights. | 625941bcb7558d58953c4df1 |
def DescribeComputeEnvCreateInfo(self, request): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> params = request._serialize() <NEW_LINE> body = self.call("DescribeComputeEnvCreateInfo", params) <NEW_LINE> response = json.loads(body) <NEW_LINE> if "Error" not in response["Response"]: <NEW_LINE> <INDENT> model = models.Des... | Views compute environment creation information.
:param request: Request instance for DescribeComputeEnvCreateInfo.
:type request: :class:`tencentcloud.batch.v20170312.models.DescribeComputeEnvCreateInfoRequest`
:rtype: :class:`tencentcloud.batch.v20170312.models.DescribeComputeEnvCreateInfoResponse` | 625941bc50485f2cf553cc70 |
def check(path): <NEW_LINE> <INDENT> error_message = '`%s` does not appear to be a template repo.' <NEW_LINE> cwd = os.getcwd() <NEW_LINE> template_attr = path <NEW_LINE> if template_attr: <NEW_LINE> <INDENT> if not os.path.isdir(os.path.join(cwd, '.git')): <NEW_LINE> <INDENT> sys.exit(error_message % cwd) <NEW_LINE> <... | Determine if a command that expects to execute inside a template
repo can continue. Checks for a .git directory and subsequently for
a template.yaml file either in the working directory or the
directory specified by the --template argument. If check passes,
returns path to template repo. | 625941bc4a966d76dd550ee4 |
def check_set_attr(self, attr): <NEW_LINE> <INDENT> self.try_set_attr(attr) <NEW_LINE> return self.is_set_attr(attr) | Run try_set_attr() and return the result of is_set_attr(), i.e. True
or False. Most important shortcut method.
Examples
--------
::
def get_foo(self):
if self.check_set_attr('bar'):
return self.bar * 2
else:
return None
which is the same as ::
def get_foo(self):
... | 625941bc3d592f4c4ed1cf53 |
def textInteractionFlags(self): <NEW_LINE> <INDENT> pass | QGraphicsTextItem.textInteractionFlags() -> Qt.TextInteractionFlags | 625941bc0383005118ecf4bc |
def get_release_date(self): <NEW_LINE> <INDENT> return information.RELEASE_DATE | Retrieves the current base (plugin manager) release date.
@rtype: String
@return: The current base (plugin manager) release date. | 625941bc097d151d1a222d33 |
def toDFA(self): <NEW_LINE> <INDENT> s0 = self.start <NEW_LINE> e_s0 = tuple(self.epsilon_closure(s0)) <NEW_LINE> stack = [e_s0] <NEW_LINE> tranistion = {} <NEW_LINE> alphabet = self.alphabet <NEW_LINE> label = [e_s0] <NEW_LINE> while len(stack) != 0: <NEW_LINE> <INDENT> s = stack.pop() <NEW_LINE> label_s = label.inde... | 子集构造算法 | 625941bc97e22403b379ce70 |
def test_05_run(self): <NEW_LINE> <INDENT> output = self.p.run() <NEW_LINE> self.assertEqual(output, u'<span class="b1" style="font-weight: bold">Bold</span><span class="b2 c" style="color: red; font-weight: bold">Bold Red</span>') | Test 'run' method | 625941bc15baa723493c3e4b |
def stackSize(self): <NEW_LINE> <INDENT> return 0 | QThread.stackSize() -> int | 625941bc7d43ff24873a2b75 |
def inorderTraversal(self, root): <NEW_LINE> <INDENT> self.res = [] <NEW_LINE> self.fun(root) <NEW_LINE> return self.res | :type root: TreeNode
:rtype: List[int] | 625941bc92d797404e304061 |
def get_hashpipe_key_value_str_ensured(key, instance=0, interval_sec=0.01, re_get=5): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> consistent = True <NEW_LINE> ret = get_hashpipe_key_value(key, instance=instance) <NEW_LINE> val = ret.decode().strip() <NEW_LINE> for i in range(re_get-1): <NEW_LINE> <INDENT> ret = get_ha... | Returns the value of a key in the hashpipe's status, parsed as a string.
Calls get_hashpipe_key_value 5 times.
Parameters
----------
key: str
The key to get the value of
instance: int
The enumeration of the hashpipe instance whose status is consulted
Returns
-------
str/bytearray/None: The value of the key | 625941bc8da39b475bd64e48 |
def CalculateNNSfrac(wt): <NEW_LINE> <INDENT> nts = ['A', 'C', 'T', 'G'] <NEW_LINE> nt_counts = {} <NEW_LINE> for nt in nts: <NEW_LINE> <INDENT> nt_counts[nt] = wt.count(nt) <NEW_LINE> <DEDENT> AorT = ( nt_counts['A'] + nt_counts['T'] ) / len(wt) <NEW_LINE> CorG = ( nt_counts['C'] + nt_counts['G'] ) / len(wt) <NEW_LINE... | Calculates the expected fraction of mutations when NNS mutagenesis is used.
wt is the nucleotide sequence of the mutagenized gene. | 625941bcbe383301e01b5364 |
def GetBackgroundBrush(self, dc): <NEW_LINE> <INDENT> if wx.Platform == '__WXMAC__' : <NEW_LINE> <INDENT> return wx.TRANSPARENT_BRUSH <NEW_LINE> <DEDENT> bkgrd = self.GetBackgroundColour() <NEW_LINE> with wx4c.set_brush_style(wx.BRUSHSTYLE_SOLID) as bstyle: <NEW_LINE> <INDENT> brush = wx.Brush(bkgrd, bstyle) <NEW_LINE>... | Get the brush for drawing the background of the button
@return: wx.Brush
@note: used internally when on gtk | 625941bc596a8972360899a1 |
def pc_nproduced_var(self): <NEW_LINE> <INDENT> return _blocks_swig5.threshold_ff_sptr_pc_nproduced_var(self) | pc_nproduced_var(threshold_ff_sptr self) -> float | 625941bc30bbd722463cbc9b |
def mutate(self, record): <NEW_LINE> <INDENT> mutator = self._generator.choice( a=self._mutators, p=self._weights, ) <NEW_LINE> return mutator.mutate(record) | Return a mutant of `record`.
Parameters
----------
record : :class:`.MoleculeRecord`
The molecule to be mutated.
Returns
-------
:class:`.MutationRecord`
A record of the mutation. The exact subclass of
:class:`.MutationRecord` depends on which mutator was
used.
None : :class:`NoneType`
If `record... | 625941bc73bcbd0ca4b2bf55 |
def calcSaleProfit(self): <NEW_LINE> <INDENT> if self.saleDate != None: <NEW_LINE> <INDENT> result = (self.salePrice - self.purchasePrice) * self.volume <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> result = None <NEW_LINE> <DEDENT> return result | Calculates the sale profit based on the sale value minus the acquistion value of the asset
Return :
- (float) profit of the sale of the asset. If the asset has not been sold the result is -1 | 625941bc60cbc95b062c6421 |
def perform_create(self, serializer): <NEW_LINE> <INDENT> serializer.validated_data['user'] = self.request.user <NEW_LINE> try: <NEW_LINE> <INDENT> source = Source.objects.get( id=serializer.validated_data['source_id'], organisation=self.request.organisation) <NEW_LINE> <DEDENT> except Source.DoesNotExist: <NEW_LINE> <... | Set current user. | 625941bc32920d7e50b280a5 |
def combine_output(out, sep=''): <NEW_LINE> <INDENT> output = sep.join((decode(out[0]), decode(out[1]))) <NEW_LINE> return ANSI_COLOR_RE.sub('', output) | Return stdout and/or stderr combined into a string, stripped of ANSI colors. | 625941bc4e696a04525c9324 |
def importx(self): <NEW_LINE> <INDENT> filenames = tkFileDialog.askopenfilenames() <NEW_LINE> self.filepath = filenames.lstrip('{').rstrip('}').split('} {') | Get input files route | 625941bc099cdd3c635f0b34 |
def load_obj(objname): <NEW_LINE> <INDENT> if not os.path.exists('tmp/%s.pickle' % objname): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> obj = None <NEW_LINE> with open('tmp/%s.pickle' % objname, 'rb') as f: <NEW_LINE> <INDENT> obj = pickle.load(f) <NEW_LINE> <DEDENT> return obj | Load python object from pickle file.
Args:
objname: name of the object
Returns:
Loaded object, None if no such object. | 625941bcf7d966606f6a9ed9 |
def changelist_view(self,request): <NEW_LINE> <INDENT> param_dict=QueryDict(mutable=True) <NEW_LINE> if request.GET: <NEW_LINE> <INDENT> param_dict['_changlistfilter']=request.GET.urlencode() <NEW_LINE> <DEDENT> base_add_url = reverse("{2}:{0}_{1}_add".format(self.app_label, self.model_name, self.site.namespace)) <NEW_... | 查看列表
:param requset:
:return: | 625941bcd268445f265b4d46 |
def create(self): <NEW_LINE> <INDENT> adscan.fs.makedirs(self.dirname) <NEW_LINE> for i in xrange(0, self.browser_space_size): <NEW_LINE> <INDENT> dirname = '%s/%d' % (self.dirname, i) <NEW_LINE> adscan.fs.makedirs(dirname) | Create the browser workspace. | 625941bc462c4b4f79d1d5a8 |
def isWordGuessed(secretWord, lettersGuessed): <NEW_LINE> <INDENT> if len(set(secretWord).intersection(set(lettersGuessed))) == len(set(secretWord)): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | secretWord: string, the random word the user is trying to guess. This is selected on line 9.
lettersGuessed: list of letters that have been guessed so far.
returns: boolean, True only if all the letters of secretWord are in lettersGuessed;
False otherwise | 625941bca219f33f34628847 |
def search_from_start_to_end(self): <NEW_LINE> <INDENT> epoch = 0 <NEW_LINE> points = [self.start_url] <NEW_LINE> results = [] <NEW_LINE> [self.point_list.append(i) for i in points] <NEW_LINE> while self.end_url not in results: <NEW_LINE> <INDENT> print("Epoh", epoch) <NEW_LINE> loop = asyncio.new_event_loop() <NEW_LIN... | Function start epoch from first url and search via all directions
1 processed all available and not visited urls its one epoch | 625941bc4527f215b584c332 |
def _get_all_items_annotated(self): <NEW_LINE> <INDENT> items = [] <NEW_LINE> def collect(x, parent_collapsed): <NEW_LINE> <INDENT> visible = x.visible and not parent_collapsed <NEW_LINE> items.append((visible, x)) <NEW_LINE> for i in x.children: <NEW_LINE> <INDENT> if i: <NEW_LINE> <INDENT> collect(i, parent_collapsed... | Get a flat list of all TreeItem instances in this Tree,
including visibility information due to collapsed parents. | 625941bc56ac1b37e62640ad |
@app.route('/profile/<userid>') <NEW_LINE> def profile_userid(userid): <NEW_LINE> <INDENT> user = FormData.query.filter_by(userid=userid).first() <NEW_LINE> return render_template('profile_user.html', user=user) | Render the website's profile/<userid> page. | 625941bc85dfad0860c3ad31 |
def kresli(neuspesny_pokus): <NEW_LINE> <INDENT> if neuspesny_pokus == 0: <NEW_LINE> <INDENT> with open('pokus0.txt', encoding='utf-8') as subor: <NEW_LINE> <INDENT> obsah = subor.read() <NEW_LINE> return obsah <NEW_LINE> <DEDENT> <DEDENT> elif neuspesny_pokus == 1: <NEW_LINE> <INDENT> with open('pokus1.txt', encoding=... | Kresli sibenicu | 625941bccc0a2c11143dcd68 |
def convert_item(self, item): <NEW_LINE> <INDENT> command, label, type, container = self.read_item(item) <NEW_LINE> if container: <NEW_LINE> <INDENT> command, label, type, container = self.read_item(item) <NEW_LINE> c = Container(label, "") <NEW_LINE> children = c.children <NEW_LINE> for i in range(container.getCount()... | Convert entry to bookmarks item in new format. | 625941bca8ecb033257d2fae |
def meas_profile_scatterfig(df, sitename, var, ylabel, ylimit=[-155,0]): <NEW_LINE> <INDENT> measdict = dtool.measurement_h_v_dict(df.columns, var) <NEW_LINE> nplots = len(measdict.keys()) <NEW_LINE> fig, ax = plt.subplots(1, nplots, figsize=(7, 5), sharey=True) <NEW_LINE> if nplots==1: ax = [ax] <NEW_LINE> fig.canvas.... | Make a scatterplot for sensors in a measurement profile | 625941bc23849d37ff7b2f69 |
def _GetCodegenFromFlags(args): <NEW_LINE> <INDENT> discovery_doc = _GetDiscoveryDocFromFlags(args) <NEW_LINE> names = util.Names( args.strip_prefix, args.experimental_name_convention, args.experimental_capitalize_enums) <NEW_LINE> if args.client_json: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open(args.client_... | Create a codegen object from flags. | 625941bc5fdd1c0f98dc010a |
def calc_grav(self): <NEW_LINE> <INDENT> self.change_y += self.y_velocity_multiplier <NEW_LINE> if self.rect.y >= SCREEN_HEIGHT - self.rect.height and self.change_y >= 0: <NEW_LINE> <INDENT> self.change_y = 0 <NEW_LINE> self.change_x = 0 <NEW_LINE> self.rect.y = SCREEN_HEIGHT - self.rect.height <NEW_LINE> self.on_groun... | Calculate effect of gravity. | 625941bc3cc13d1c6d3c7255 |
def test_code_formatting(): <NEW_LINE> <INDENT> if flake8.__version__ <= "2": <NEW_LINE> <INDENT> msg = ("Module was designed to be tested with flake8 >= 2.0. " "Please update.") <NEW_LINE> warnings.warn(msg) <NEW_LINE> <DEDENT> test_dir = os.path.dirname(os.path.abspath(inspect.getfile( inspect.currentframe()))) <NEW_... | Tests the formatting and other things with flake8. | 625941bc97e22403b379ce71 |
def newcomments(self): <NEW_LINE> <INDENT> return self.make_request('newcomments') | Retrieve Newly Submitted Comments | 625941bcbaa26c4b54cb0ffb |
def __centerOnScreen (self): <NEW_LINE> <INDENT> resolution = QtGui.QDesktopWidget().screenGeometry() <NEW_LINE> self.move((resolution.width() / 2) - (self.frameSize().width() / 2), (resolution.height() / 2) - (self.frameSize().height() / 2)) | Centers the window on the screen. | 625941bcab23a570cc250058 |
def main(): <NEW_LINE> <INDENT> import sys <NEW_LINE> n = int(sys.argv[1]) <NEW_LINE> ans = is_prime(n) <NEW_LINE> if ans: <NEW_LINE> <INDENT> print("{0} is Prime Number".format(n)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print("{0} is Composite Number".format(n)) | Main function | 625941bc5f7d997b87174973 |
def is_in_dict(phrases, word_freq): <NEW_LINE> <INDENT> return set(phrase for phrase in phrases if phrase in word_freq) | Judge if the phrase in phrases list are noticed in the given dictionary word_freq | 625941bc91f36d47f21ac3c8 |
def to_array(x, y, z, resize_hist=True, **kwargs): <NEW_LINE> <INDENT> binstat_pars = inspect.signature(binned_statistic_2d).parameters.values() <NEW_LINE> binstat_adict = {par.name:par.default for par in binstat_pars} <NEW_LINE> binstat_adict.update({ 'x': x, 'y': y, 'values': z, 'range': [[0, xsize], [0, ysize]] }) <... | given a set of points, create a 2d array of desired dimensions
by first binning it and the resizing. | 625941bc21a7993f00bc7bc3 |
def compile(self, seed=42): <NEW_LINE> <INDENT> ops.reset_default_graph() <NEW_LINE> self._log_params() <NEW_LINE> with tf.device("/gpu:0"): <NEW_LINE> <INDENT> logger.info("Building graph...") <NEW_LINE> tf.set_random_seed(seed) <NEW_LINE> self.global_step = tf.get_variable(name="global_step", shape=[], dtype='int32',... | Build the graph, ostensibly by setting up the placeholders and then
creating/compiling the forward pass.
Note: Clear the previous tensorflow graph definitions
:param seed: int, optional (default=0)
The graph-level seed to use when building the graph. | 625941bcadb09d7d5db6c66a |
def noOfNodesUsed (self, noOfNodesMax) : <NEW_LINE> <INDENT> if not self.isMalleable or self.scaleCurveFlag == 0 : <NEW_LINE> <INDENT> return noOfNodesMax <NEW_LINE> <DEDENT> elif self.scaleCurveFlag == 1 : <NEW_LINE> <INDENT> noOfNodesOptimal = noOfNodesMax <NEW_LINE> while noOfNodesOptimal >= 2 and self.sc... | Function that returns the no. of nodes used if N nodes are available.
No. of nodes depend on the scheduling algorithm.
If application is not malleable, it will return noOfNodesMax. | 625941bcd10714528d5ffbb9 |
def list_nodes_full(call=None): <NEW_LINE> <INDENT> if call == "action": <NEW_LINE> <INDENT> raise SaltCloudSystemExit( "list_nodes_full must be called with -f or --function" ) <NEW_LINE> <DEDENT> items = query(method="servers") <NEW_LINE> ret = {} <NEW_LINE> for node in items["servers"]: <NEW_LINE> <INDENT> ret[node["... | Return a list of the BareMetal servers that are on the provider. | 625941bc66673b3332b91f69 |
@receiver(post_migrate, sender=Gymnasium) <NEW_LINE> def create_new_group(sender, **kwargs): <NEW_LINE> <INDENT> groups_permissions = { "gymnasium_staff": [ 'Can add gymnasium', 'Can change gymnasium', 'Can delete gymnasium', ] } <NEW_LINE> for key, value in groups_permissions.items(): <NEW_LINE> <INDENT> group, create... | Create new group to handle the gymnasium. | 625941bc23e79379d52ee43f |
def _newline_after(func): <NEW_LINE> <INDENT> @wraps(func) <NEW_LINE> def decorated(self, *args, **kwargs): <NEW_LINE> <INDENT> func(self, *args, **kwargs) <NEW_LINE> self._newline() <NEW_LINE> <DEDENT> return decorated | Decorator to append a newline after the function | 625941bc3c8af77a43ae3676 |
def test_custom_reserved_names(self): <NEW_LINE> <INDENT> custom_reserved_names = ['foo', 'bar', 'eggs', 'spam'] <NEW_LINE> class CustomReservedNamesForm(forms.RegistrationForm): <NEW_LINE> <INDENT> reserved_names = custom_reserved_names <NEW_LINE> <DEDENT> for reserved_name in custom_reserved_names: <NEW_LINE> <INDENT... | Reserved names can be overridden by an attribute. | 625941bc9b70327d1c4e0cac |
def _check(self): <NEW_LINE> <INDENT> if not os.path.isdir(self.deps_directory): <NEW_LINE> <INDENT> log.debug('Initializing the vmcloak-deps repository.') <NEW_LINE> self.init() <NEW_LINE> return False <NEW_LINE> <DEDENT> return True | Checks whether the dependency repository has been initialized. | 625941bcd486a94d0b98e01e |
def select2_meta_factory(model, meta_fields=None, widgets=None, attrs=None): <NEW_LINE> <INDENT> widgets = widgets or {} <NEW_LINE> meta_fields = meta_fields or {} <NEW_LINE> for field in model._meta.fields: <NEW_LINE> <INDENT> if isinstance(field, ForeignKey) or field.choices: <NEW_LINE> <INDENT> widgets.update({field... | Returns `Meta` class with Select2-enabled widgets for fields
with choices (e.g. ForeignKey, CharField, etc) for use with
ModelForm.
Attrs argument is select2 widget attributes (width, for example). | 625941bcd18da76e235323ac |
def save(self, *args, **kwargs): <NEW_LINE> <INDENT> if not self.id and not self.added_on: <NEW_LINE> <INDENT> self.added_on = datetime.datetime.today() <NEW_LINE> <DEDENT> return super(Movie, self).save(*args, **kwargs) | Update timestamps. | 625941bc6e29344779a624ed |
def integrate_RK4(self): <NEW_LINE> <INDENT> func=self.dR <NEW_LINE> t=self.t; t.append(self.t_start) <NEW_LINE> w=self.R; w.append(array([self.R_start, self.dR_start])) <NEW_LINE> self.Pg.append(self.calculate_Pgas(self.R_start)) <NEW_LINE> while t[-1]<self.t_start+self.t_run: <NEW_LINE> <INDENT> if w[-1][0]<0.6*self.... | fourth order Runge-Kutta scheme for time-integration | 625941bccc0a2c11143dcd69 |
def get_restaurants(self, tab): <NEW_LINE> <INDENT> data = self.http_get(RestUrl.restaurants(tab)) <NEW_LINE> return get_restaurants(tab, data) | :type tab: meican.models.Tab
:rtype: list[meican.models.Restaurant] | 625941bcb5575c28eb68ded7 |
def get_credentials(self): <NEW_LINE> <INDENT> credential_path = 'annette/data/gmail-credentials.json' <NEW_LINE> store = Storage(credential_path) <NEW_LINE> credentials = store.get() <NEW_LINE> flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args() <NEW_LINE> if not credentials or credentials.invalid:... | Gets user credentials from storage.
If credentials not found or invalid, the OAuth2 flow is completed to obtain the new
credentials.
:return: Gmail Service object | 625941bc63d6d428bbe443c8 |
def test_multipleOrigins(self): <NEW_LINE> <INDENT> origin = Origin() <NEW_LINE> origin.public_id = 'smi:ch.ethz.sed/origin/37465' <NEW_LINE> origin.time = UTCDateTime(0) <NEW_LINE> origin.latitude = 12 <NEW_LINE> origin.latitude_errors.confidence_level = 95 <NEW_LINE> origin.longitude = 42 <NEW_LINE> origin.depth_type... | Parameters of multiple origins should not interfere with each other. | 625941bc1f5feb6acb0c4a2d |
def test_reading_alignments_cath3(self): <NEW_LINE> <INDENT> path = "Stockholm/cath3.sth" <NEW_LINE> alignments = stockholm.AlignmentIterator(path) <NEW_LINE> alignment = next(alignments) <NEW_LINE> self.assertRaises(StopIteration, next, alignments) <NEW_LINE> self.check_alignment_cath3(alignment) <NEW_LINE> stream = S... | Test parsing CATH record 1.10.275.10/FF/000026. | 625941bca05bb46b383ec6fd |
def search(self, subject=None, predicate=None, object=None, gid=None, **kwargs): <NEW_LINE> <INDENT> q = super(TripleManager, self).get_query_set() <NEW_LINE> if subject: <NEW_LINE> <INDENT> if isinstance(subject, models.Model): <NEW_LINE> <INDENT> q = q.filter(_subject_id=subject.id, _subject_type=ContentType.objects.... | Queries fact objects matching the given criteria. | 625941bc91af0d3eaac9b8ee |
def testCombined(self): <NEW_LINE> <INDENT> for phase in (constants.HOOKS_PHASE_PRE, constants.HOOKS_PHASE_POST): <NEW_LINE> <INDENT> expect = [] <NEW_LINE> for fbase, ecode, rs in [("00succ", 0, HKR_SUCCESS), ("10fail", 1, HKR_FAIL), ("20inv.", 0, HKR_SKIP), ]: <NEW_LINE> <INDENT> fname = "%s/%s" % (self.ph_dirs[phase... | Test success, failure and skip all in one test | 625941bc442bda511e8be2f6 |
def __init__(self, engine_name, cwd=None): <NEW_LINE> <INDENT> super(Engine, self).__init__(engine_name) <NEW_LINE> self._engine_name = engine_name <NEW_LINE> self._cwd = cwd | Returns an ENVI Py Engine object based on the engine_name.
:param engine_name: A String specifying the name of the requested engine.
:return: None | 625941bccad5886f8bd26ebb |
def _get_query_string(self): <NEW_LINE> <INDENT> query_args = {'Query':self.search_terms, '$top':self.top, '$skip':self.skip, '$format':self.frmt, 'Adult':self.adult, 'Market':self.market} <NEW_LINE> return '?'+urllib.urlencode(query_args) | Return URL safe query string | 625941bca79ad161976cc01e |
def run(self, exposure, referenceLines, detectorMap, pfsConfig, fiberTraces=None) -> Struct: <NEW_LINE> <INDENT> if self.config.doSubtractContinuum: <NEW_LINE> <INDENT> if fiberTraces is None: <NEW_LINE> <INDENT> raise RuntimeError("No fiberTraces provided for continuum subtraction") <NEW_LINE> <DEDENT> with self.conti... | Photometer lines on an arc
We perform a simultaneous fit of PSFs to each of the lines.
This method optionally performs continuum subtraction before handing
off to the ``photometerLines`` method to do the actual photometry.
Parameters
----------
exposure : `lsst.afw.image.Exposure`
Arc exposure on which to centro... | 625941bc45492302aab5e199 |
def write_stderr(s): <NEW_LINE> <INDENT> sys.stderr.write(s) <NEW_LINE> sys.stderr.flush() | Write and flush immediately to stderr, as per Supervisor requirement. | 625941bcbe8e80087fb20b20 |
def initcurvature(img): <NEW_LINE> <INDENT> global runningcur <NEW_LINE> global smoothcurvature <NEW_LINE> warped = roadPerspectiveTransFormation(pfile_cb, img, hood_pixels=0) <NEW_LINE> lrlanes = lane_detection_pipeline(warped, pfile_cb, kernels = 5,hood_pixels=0) <NEW_LINE> lrlanes = remove_noise(lrlanes, threshold =... | Determine curvature in video frame at time t = 0
:param img: image at time t = 0 in video stream
:return:
List of running average values
| 625941bc287bf620b61d3946 |
def test_orbeon_search_read_with_unknown_ERP_fieds(self): <NEW_LINE> <INDENT> domain = [('id', '=', self.runner_form_c_erp_fields_v1.id)] <NEW_LINE> rec = self.runner_model.orbeon_search_read_data(domain, ['xml']) <NEW_LINE> root = self.assertXmlDocument(rec['xml']) <NEW_LINE> unknown_erp_field = runner_xml_parser.xml_... | Test reading a runner form with unknown ERP-fields (model-object). | 625941bc31939e2706e4cd47 |
def __init__(self, tag=None, value=None, last=False): <NEW_LINE> <INDENT> super(Event, self).__setattr__('_Event__event', { 'tag': tag, 'value': value, 'last': last}) | Construct an immutable event from a tag and a value.
TODO: Could we also allow initialization from a dict?
@param tag
@param value
@param last: true if this is the last event in a signal | 625941bc8e05c05ec3eea24b |
def test_as_array2d(self): <NEW_LINE> <INDENT> test_arrays = self._test_arrays('BaseArrayDouble2d') <NEW_LINE> original_arrays = self._test_arrays('BaseArrayDouble2d') <NEW_LINE> for test_array, original_array in zip(test_arrays, original_arrays): <NEW_LINE> <INDENT> self.assertEqual(test_array.sum(), test.test_as_arra... | ...Test behavior of as_array2d method | 625941bc92d797404e304062 |
def __init__(self, mdp, discount = 0.9, iterations = 100): <NEW_LINE> <INDENT> self.mdp = mdp <NEW_LINE> self.discount = discount <NEW_LINE> self.iterations = iterations <NEW_LINE> self.values = util.Counter() <NEW_LINE> states = self.mdp.getStates() <NEW_LINE> for i in range(iterations): <NEW_LINE> <INDENT> temp = uti... | Your value iteration agent should take an mdp on
construction, run the indicated number of iterations
and then act according to the resulting policy.
Some useful mdp methods you will use:
mdp.getStates()
mdp.getPossibleActions(state)
mdp.getTransitionStatesAndProbs(state, action)
mdp.getReward(state, a... | 625941bc8c0ade5d55d3e898 |
@blueprint.route('/json', methods=['POST']) <NEW_LINE> @blueprint.route('', methods=['POST'], strict_slashes=False) <NEW_LINE> @utils.auth.requires_login(redirect=False) <NEW_LINE> def create(): <NEW_LINE> <INDENT> form = GenericImageDatasetForm() <NEW_LINE> fill_form_if_cloned(form) <NEW_LINE> if not form.validate_on_... | Creates a new GenericImageDatasetJob
Returns JSON when requested: {job_id,name,status} or {errors:[]} | 625941bc30dc7b7665901843 |
def get_default_val(self): <NEW_LINE> <INDENT> val = self.default <NEW_LINE> while callable(val): <NEW_LINE> <INDENT> val = val() <NEW_LINE> <DEDENT> return val | Helper to expand default value (support callables) | 625941bca05bb46b383ec6fe |
def _get(self, object='user', path=None, params=None): <NEW_LINE> <INDENT> if params is None: <NEW_LINE> <INDENT> params = {} <NEW_LINE> <DEDENT> result = self.client.get(object=object, path=path, params=params) <NEW_LINE> return result | GET requests for the User object. | 625941bc31939e2706e4cd48 |
def psetex(self, key, milliseconds, value): <NEW_LINE> <INDENT> return self._execute( [b'PSETEX', key, ascii(milliseconds), value], b'OK') | :meth:`~tredis.RedisClient.psetex` works exactly like
:meth:`~tredis.RedisClient.psetex` with the sole difference that the
expire time is specified in milliseconds instead of seconds.
.. versionadded:: 0.2.0
.. note:: **Time complexity**: ``O(1)``
:param key: The key to set
:type key: :class:`str`, :class:`bytes`
:p... | 625941bc2c8b7c6e89b3569c |
def get_msg(bot): <NEW_LINE> <INDENT> response = bot.method("messages.get", {"count": 1}) <NEW_LINE> if response["items"][0] and response["items"][0]["read_state"] == 0: <NEW_LINE> <INDENT> print(response) <NEW_LINE> bot.method("messages.markAsRead", {"message_ids": response["items"][0]["id"]}) <NEW_LINE> return respon... | получает обновления сообщний | 625941bc566aa707497f4451 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.