code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def list_sheet_names(self): <NEW_LINE> <INDENT> return self.book.sheet_names() | List all sheet names. | 625941e357b8e32f52483885 |
def inbox(request, template_name='django_messages/inbox.html'): <NEW_LINE> <INDENT> message_list = Message.objects.inbox_for(request.user) <NEW_LINE> return render_to_response(template_name, { 'message_list': message_list, }, context_instance=RequestContext(request)) | Displays a list of received messages for the current user.
Optional Arguments:
``template_name``: name of the template to use. | 625941e34e696a04525c9835 |
def register(cls, admin_cls): <NEW_LINE> <INDENT> GENDER_CHOICES = ( (1, _('Male')), (2, _('Female')), (3, _('Unknown')), ) <NEW_LINE> cls.add_to_class( 'gender', models.PositiveSmallIntegerField( _('Gender'), blank=True, default=3, choices=GENDER_CHOICES, ) ) <NEW_LINE> cls.add_to_class( 'birthday', models.DateField( ... | User portifolio. | 625941e35510c4643540f7c2 |
def TaskBarHandle(): <NEW_LINE> <INDENT> return findwindows.find_elements(class_name = "Shell_TrayWnd")[0].handle | Return the first window that has a class name 'Shell_TrayWnd' | 625941e37d43ff24873a308b |
def update(val): <NEW_LINE> <INDENT> ax.clear() <NEW_LINE> zlow_val = slide_z_low.val <NEW_LINE> zhigh_val = slide_z_high.val <NEW_LINE> xlow_val = slide_x_low.val <NEW_LINE> xhigh_val = slide_x_high.val <NEW_LINE> ylow_val = slide_y_low.val <NEW_LINE> yhigh_val = slide_y_high.val <NEW_LINE> build_surface(data_high, xl... | Update surfaces to slice data along coordinates specified by user.
Takes in upper and lower X, Y, and Z limits specified by user to
update the displayed surfaces.
Args:
val (float) -- Value from slider bar.
Returns:
zlow_val (float) -- Lower value to slice data along the Z axis.
zhigh_val (float) -- Uppe... | 625941e3d18da76e235328c2 |
def slices(s, slicing): <NEW_LINE> <INDENT> position = 0 <NEW_LINE> out = [] <NEW_LINE> for length in slicing: <NEW_LINE> <INDENT> out.append(s[position:position + length]) <NEW_LINE> position += length <NEW_LINE> <DEDENT> return out | Slice object into segments of given length.
e.g. slices("001007",[1,2,3]) => ["0","01","007"] | 625941e3566aa707497f494b |
def update_data(self): <NEW_LINE> <INDENT> self.data_changed = True | Override this method to do what is necessary when upstream
data changes.
This method is invoked (automatically) when any of the inputs
sends a `data_changed` event. | 625941e3bf627c535bc135b7 |
def encoding_character(english_character): <NEW_LINE> <INDENT> morse_code_dict = get_morse_code_dict() <NEW_LINE> morse_by_alphabet = morse_code_dict[english_character.upper()] <NEW_LINE> return morse_by_alphabet | Input:
- english_character : 문자열값으로 알파벳 한 글자의 입력이 보장됨
Output:
- get_morse_code_dict 함수의 반환 값으로 인해 변환된 모스부호 문자열값
Examples:
>>> import morsecode as mc
>>> mc.encoding_character("G")
'--.'
>>> mc.encoding_character("A")
'.-'
>>> mc.encoding_character("C")
'-.-.'
>>> mc.encoding_char... | 625941e33eb6a72ae02ec8cf |
def execute_periodic_hook(self, context, periodic_hook_data, *args, **kwargs): <NEW_LINE> <INDENT> if not self.periodic_hooks_enabled: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> LOG.debug("Running 'periodic hook'.") <NEW_LINE> context = context or ctxt.get_admin_context() <NEW_LINE> return self._execute_periodic_ho... | Hook called on periodic basis. | 625941e38e7ae83300e4b3b5 |
def num_unique_letters(secret_word): <NEW_LINE> <INDENT> unique_letters = '' <NEW_LINE> for c in secret_word: <NEW_LINE> <INDENT> if not c in unique_letters: <NEW_LINE> <INDENT> unique_letters += c <NEW_LINE> <DEDENT> <DEDENT> return len(unique_letters) | secret_word: string, the word the user is guessing; assumes all letters are lowercase
returns: integer, the number of unique letters in secret_word | 625941e3236d856c2ad44bc7 |
def get_user_id(self, details, response): <NEW_LINE> <INDENT> return response['account'].get('uuid') | Return user unique id provided by service | 625941e3293b9510aa2c367a |
def check(self, config): <NEW_LINE> <INDENT> self.reset() <NEW_LINE> output = utils.run_command(self._cmd) <NEW_LINE> if not output: <NEW_LINE> <INDENT> self.set_object_not_ok('UserDefine', str(self), 'Failed to get output of command \"{}\"'.format(self._cmd)) <NEW_LINE> return <NEW_LINE> <DEDENT> output = output.strip... | Execute the user defined command and parse the output.
:param config: Health checker configuration.
:return: | 625941e373bcbd0ca4b2c45d |
def refresh_campaigns(self): <NEW_LINE> <INDENT> if not self.vtol_sync.vtolvrmissions_online: <NEW_LINE> <INDENT> self.display_message("VTOLVRMissions.com Offline", "VTOLVRMissions.com is currently offline, we will only show local resources. Try refreshing data later.") <NEW_LINE> <DEDENT> if not self.refresh_campaigns... | Runs the refresh_campaigns_thread in another thread. | 625941e3eab8aa0e5d26df42 |
@user.route('/userarticles/edit/<int:id>', methods=['GET', 'POST']) <NEW_LINE> @login_required <NEW_LINE> def edit_userarticle(id): <NEW_LINE> <INDENT> add_userarticle = False <NEW_LINE> try: <NEW_LINE> <INDENT> userarticle = UserArticle.query.get_or_404(id) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> userarticle =... | Edit a userarticle | 625941e36aa9bd52df03718e |
def parse_color(color_string: str) -> Color: <NEW_LINE> <INDENT> if color_string.startswith('%') and len(color_string) == 4: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> r, g, b = map(int, color_string[1:]) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if ... | Parses a color string of one of the following formats and returns a
corresponding #SgrColor, #LutColor or #TrueColor.
* `<color_name>`, `BRIGHT_<color_name>`: #SgrColor
* `%rgb`, `$xxx`: #LutColor
* `#cef`, `#cceeff`: #TrueColor | 625941e3f9cc0f698b1409e0 |
def updateQ(d, Q): <NEW_LINE> <INDENT> for sub_list in d.values(): <NEW_LINE> <INDENT> Q.update(sub_list) | type(d) = dict(string, list(string))
type(Q) = set(string) | 625941e33cc13d1c6d3c7760 |
def middle_vector(vector1, vector2): <NEW_LINE> <INDENT> x1 = vector1[0] <NEW_LINE> x2 = vector2[0] <NEW_LINE> y1 = vector1[1] <NEW_LINE> y2 = vector2[1] <NEW_LINE> x_medio = round((x1+x2)*0.5, 2) <NEW_LINE> y_medio = round((y1+y2)*0.5, 2) <NEW_LINE> middle_vector = (x_medio, y_medio) <NEW_LINE> return middle_vector | input: vector_1: (x1,y1); vector_2: (x2,y2)
returns the middle vector (x,y) | 625941e344b2445a3393247b |
def transpose(self, *args, **kwargs): <NEW_LINE> <INDENT> return DataFrameDefault.register(pandas.DataFrame.transpose)( self, *args, **kwargs ) | Transpose this QueryCompiler.
Parameters
----------
copy : bool
Whether to copy the data after transposing.
*args : iterable
Serves the compatibility purpose. Does not affect the result.
**kwargs : dict
Serves the compatibility purpose. Does not affect the result.
Returns
-------
BaseQueryCompiler
Tra... | 625941e3baa26c4b54cb1504 |
def _is_out_port(self): <NEW_LINE> <INDENT> return self.atom[-1] is 'o' | returns boolean | 625941e307d97122c4178c7c |
def save(self, path): <NEW_LINE> <INDENT> values = [(key, value) for (key, value) in self.__dict__.iteritems() if not key.startswith("_")] <NEW_LINE> json.dump(values, file(path, "w"), ensure_ascii=False, indent=1) | save to a config file | 625941e3090684286d50f0d3 |
def ImageToDisplayPos(self, *args): <NEW_LINE> <INDENT> return self.send({'cmd': 'ImageToDisplayPos', 'args': args}) | Get the display coordinates from the image coordinates
call:
dpos = ImageToDisplayPos(ipos)
where:
- ipos: image position object containing x and y image coordinate
values
returns:
- dpos: display position object containing x and y display
coordinate values
Get display (screen) coordinates from image co... | 625941e36e29344779a629f8 |
def plot_confusion_matrix(cm, labels, normalize=True, title='Confusion Matrix (Validation Set)', cmap=plt.cm.Blues): <NEW_LINE> <INDENT> if normalize: <NEW_LINE> <INDENT> cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> plt.imshow(cm, interpo... | This function prints and plots the confusion matrix.
Normalization can be applied by setting `normalize=True`. | 625941e3c432627299f05031 |
def copy(self, **kwargs): <NEW_LINE> <INDENT> return MixedMeasuredBlockState(**dict(self.__getstate__(), **kwargs)) | Return a copy of the state. | 625941e376d4e153a657ef1a |
def _update_curr_pos(curr_pos, cmd, start_of_path): <NEW_LINE> <INDENT> if cmd[0] in 'ml': <NEW_LINE> <INDENT> curr_pos = [curr_pos[0] + float(cmd[1]), curr_pos[1] + float(cmd[2])] <NEW_LINE> if cmd[0] == 'm': <NEW_LINE> <INDENT> start_of_path = curr_pos <NEW_LINE> <DEDENT> <DEDENT> elif cmd[0] in 'z': <NEW_LINE> <INDE... | Calculate the position of the pen after cmd is applied. | 625941e35fc7496912cc3d66 |
def assignment_by_sum(x, values, indices, axis=0): <NEW_LINE> <INDENT> return _assignment(x, values, indices, "sum", axis) | Add values at given indices of an array.
Parameters
----------
x: array-like, shape=[dim]
Initial array.
values: {float, list(float)}
Value or list of values to be assigned.
indices: {
int, tuple(int), array-like({int, tuple, boolean})
Single index or array of indices where values are assigned.
If the ... | 625941e3bf627c535bc135b8 |
@app.route('/api/v1/business/<business_id>', methods=['PUT']) <NEW_LINE> def update_business(business_id): <NEW_LINE> <INDENT> if session.get('username') is not None: <NEW_LINE> <INDENT> if request.method == "PUT": <NEW_LINE> <INDENT> user = session["username"] <NEW_LINE> business = business_object.get_business(busines... | update business item | 625941e38e7ae83300e4b3b6 |
def recurse(phrases, i, text, phrase_start, phrase_xml, elements) -> ([Characters.Phrase], int, str, int): <NEW_LINE> <INDENT> for el in elements: <NEW_LINE> <INDENT> tag = el.tag <NEW_LINE> log.debug("Tag: {}".format(tag)) <NEW_LINE> if tag == 'phrasestart': <NEW_LINE> <INDENT> phrase_start = i <NEW_LINE> phrases, i, ... | Evaluates the tags of a paragraph element.
Recurses on if-statements if the required conditional is met.
:param phrases: A list of Phrases.
:param i: The current index in the paragraph.
:param text: The current text in the paragraph.
:param phrase_start: The index that the current phrase starts at.
:param phrase_xml: T... | 625941e3507cdc57c63070cc |
def _setup_sqs_queue(self): <NEW_LINE> <INDENT> sqs_conn = boto.sqs.connect_to_region(self.aws_region) <NEW_LINE> self.sqs_queue = sqs_conn.get_queue( self.queue_name, owner_acct_id=self.owner_account_id) <NEW_LINE> if not self.sqs_queue: <NEW_LINE> <INDENT> raise SqsQueueNotFoundException(self.queue_name) <NEW_LINE> <... | Sets up S3 event notifications' queue connection.
| 625941e37b180e01f3dc4bde |
def get_response(self, results): <NEW_LINE> <INDENT> response = HttpResponse(mimetype=self.get_mimetype()) <NEW_LINE> response.write(self.serialize_results(results)) <NEW_LINE> return response | Get the response object for the query. | 625941e3b7558d58953c52f4 |
def add_from_names_to_locals(self, node): <NEW_LINE> <INDENT> _key_func = lambda node: node.fromlineno <NEW_LINE> def sort_locals(my_list): <NEW_LINE> <INDENT> my_list.sort(key=_key_func) <NEW_LINE> <DEDENT> for (name, asname) in node.names: <NEW_LINE> <INDENT> if name == '*': <NEW_LINE> <INDENT> try: <NEW_LINE> <INDEN... | store imported names to the locals;
resort the locals if coming from a delayed node | 625941e3e5267d203edce080 |
def required2_default3(self, one, two, three=3, four=4, five=5): <NEW_LINE> <INDENT> pass | ['one','two','three','four','five'], [3,4,5], None, None | 625941e3fbf16365ca6f65b4 |
def name_file_from_time_approx(path_dir, t_approx=None): <NEW_LINE> <INDENT> path_files = _glob.glob(path_dir+'/state_phys_t=*') <NEW_LINE> nb_files = len(path_files) <NEW_LINE> if nb_files == 0 and mpi.rank == 0: <NEW_LINE> <INDENT> raise ValueError('No state file in the dir\n'+path_dir) <NEW_LINE> <DEDENT> times = _n... | Return the file name whose time is the closest to the given time.
| 625941e34c3428357757c70e |
def get_csvs_in_store(self): <NEW_LINE> <INDENT> csvs = list() <NEW_LINE> for f in os.listdir(self.csvstore): <NEW_LINE> <INDENT> if f.endswith(".csv") or f.endswith("csv.zip"): <NEW_LINE> <INDENT> csvs.append(os.path.join(self.csvstore, f)) <NEW_LINE> <DEDENT> <DEDENT> return csvs | Assuming that all csvs in store will be at the top level
directory. If there is directory hierarchy in the store,
the code will ignore the subdirectories and csv files
inside subdirectories. | 625941e3b830903b967e9cef |
def wjs_save_rates(self, end_job_id, action_job_id): <NEW_LINE> <INDENT> rates = collections.OrderedDict() <NEW_LINE> for job_id in self.wjs_jobs: <NEW_LINE> <INDENT> job = self.wjs_jobs[job_id] <NEW_LINE> rates[job_id] = job.wj_rate <NEW_LINE> if job_id == end_job_id: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> <DED... | Save the rates before a job_id | 625941e3442bda511e8be7fb |
def get_content_type(mimetype, charset): <NEW_LINE> <INDENT> if mimetype.startswith('text/') or mimetype == 'application/xml' or (mimetype.startswith('application/') and mimetype.endswith('+xml')): <NEW_LINE> <INDENT> mimetype += '; charset=' + charset <NEW_LINE> <DEDENT> return mimetype | Return the full content type string with charset for a mimetype.
If the mimetype represents text the charset will be appended as charset
parameter, otherwise the mimetype is returned unchanged.
:param mimetype: the mimetype to be used as content type.
:param charset: the charset to be appended in case it was a text m... | 625941e3d8ef3951e3243926 |
def __init__(self, resolver_context, path_spec): <NEW_LINE> <INDENT> super(TSKPartitionFile, self).__init__(resolver_context, path_spec) <NEW_LINE> self._file_system = None | Initializes a file input/output (IO) object.
Args:
resolver_context (Context): resolver context.
path_spec (PathSpec): a path specification. | 625941e392d797404e304574 |
def subtonic(key): <NEW_LINE> <INDENT> return triads(key)[6] | Returns the subtonic in key.
Example:
{{{
>>> subtonic("C")
['B', 'D', 'F']
}}} | 625941e391af0d3eaac9be05 |
def create_namespaced_service(self, body, namespace, **kwargs): <NEW_LINE> <INDENT> all_params = ['body', 'namespace', 'pretty'] <NEW_LINE> all_params.append('callback') <NEW_LINE> params = locals() <NEW_LINE> for key, val in iteritems(params['kwargs']): <NEW_LINE> <INDENT> if key not in all_params: <NEW_LINE> <INDENT>... | create a Service
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.create_namespaced_service(body, namespace, c... | 625941e3e8904600ed9f231b |
def get_base_path(): <NEW_LINE> <INDENT> path = __file__ <NEW_LINE> common_path = os.path.split(path)[0] <NEW_LINE> return os.path.split(common_path)[0] | Return the path to the spikepy source directory. | 625941e32ae34c7f2600d519 |
def relock_squid(rp, array_max=0.05, delay=0.1): <NEW_LINE> <INDENT> import time <NEW_LINE> import msvcrt <NEW_LINE> def get_keypress(): <NEW_LINE> <INDENT> return ord(msvcrt.getch()) if msvcrt.kbhit() else 0 <NEW_LINE> <DEDENT> msg0 = 'GUI disabled while relock loop is running.\n' <NEW_LINE> msg1 = 'Current lock point... | Attempts to detect if the SQUID is unlocked and relock if necessary. Windows only.
Inputs:
- rp: Red Pitaya object as defined by rp = p.rp, where p = Pyrpl('squid_lockbox')
- array_max: threshold for the absolute value of array voltage to detect unlocking
- delay: time delay in seconds between subsequent lo... | 625941e38a349b6b435e855b |
def ensure_firewall_rule_exists(args, gcloud_compute): <NEW_LINE> <INDENT> get_cmd = [ 'firewall-rules', 'describe', _DATALAB_FIREWALL_RULE, '--format', 'value(name)'] <NEW_LINE> try: <NEW_LINE> <INDENT> utils.call_gcloud_quietly( args, gcloud_compute, get_cmd, report_errors=False) <NEW_LINE> <DEDENT> except subprocess... | Create the `datalab-network-allow-ssh` firewall rule if it necessary.
Args:
args: The Namespace returned by argparse
gcloud_compute: Function that can be used for invoking `gcloud compute`
Raises:
subprocess.CalledProcessError: If the `gcloud` command fails | 625941e36fb2d068a760f48c |
def read_stop_words(stop_word_path): <NEW_LINE> <INDENT> with open(stop_word_path, encoding='utf-8') as f: <NEW_LINE> <INDENT> return [word.strip() for word in f.readlines()] | 读取停用词表
:param stop_word_path: 停用词表的路径
:return: ->list | 625941e3046cf37aa974d12c |
def getError(self): <NEW_LINE> <INDENT> error = self.procAndGet(self.error, 'ERROR') <NEW_LINE> text = self.error.PV('ERROR:TEXT').get(use_monitor=False) <NEW_LINE> return error, text | Helper method to pop the last error from the device error queue. | 625941e35166f23b2e1a5541 |
def get_feature_debug2(nn,input_q, input_a, att_W,weight_dict): <NEW_LINE> <INDENT> h_q, w = int(input_q.get_shape()[1]), int(input_q.get_shape()[2]) <NEW_LINE> nn._debug_h_q = h_q <NEW_LINE> nn._debug_w = w <NEW_LINE> h_a = int(input_a.get_shape()[1]) <NEW_LINE> nn._debug_h_a = h_a <NEW_LINE> nn._debug_input_q = input... | weight_array = [ 'Wam','Wqm','Wms']
步骤4中,计算Attention权值。这里对问题特征进行max-pooling计算最大特征,
然后用这个特征去和答案特征计算Attention权值,然后将Attention权值应用在答案特征之上,
最后再取max-pooling。
:param input_q:
:param input_a:
:param att_W:
:return: | 625941e3d18da76e235328c3 |
def money_given(self, player, amount): <NEW_LINE> <INDENT> if player.name != self.get_name(): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if self.amount_to_raise > 0: <NEW_LINE> <INDENT> self.amount_to_raise -= amount <NEW_LINE> if self.amount_to_raise < 0: <NEW_LINE> <INDENT> self.amount_to_raise = 0 <NEW_LINE> <DE... | Called when money has been given to the player.
No response is required. | 625941e31d351010ab855f03 |
def read(self, size=1): <NEW_LINE> <INDENT> if not self._isOpen: raise PortNotOpenError() <NEW_LINE> data = '123' <NEW_LINE> return bytes(data) | Read size bytes from the serial port. If a timeout is set it may
return less characters as requested. With no timeout it will block
until the requested number of bytes is read. | 625941e38da39b475bd65361 |
def login(context, request): <NEW_LINE> <INDENT> if request.method != 'POST': <NEW_LINE> <INDENT> return {'error': ''} <NEW_LINE> <DEDENT> if 'username' not in request.params: <NEW_LINE> <INDENT> return {'error': 'Username is required.'} <NEW_LINE> <DEDENT> if 'password' not in request.params: <NEW_LINE> <INDENT> retur... | Display a login prompt. | 625941e3fff4ab517eb2f827 |
def __iter__(self): <NEW_LINE> <INDENT> for key in self.stock_dict: <NEW_LINE> <INDENT> yield self.stock_dict[key] | 通过代理stock_dict的跌倒,yield元素
:return: | 625941e321a7993f00bc80df |
def getBeatProgress(self, qLenPos): <NEW_LINE> <INDENT> beatIndex = self.beatSequence.offsetToIndex(qLenPos) <NEW_LINE> start, unused_end = self.beatSequence.offsetToSpan(qLenPos) <NEW_LINE> return beatIndex + 1, qLenPos - start | Given a quarterLength position, get the beat,
where beats count from 1, and return the the
amount of qLen into this beat the supplied qLenPos
is.
>>> a = meter.TimeSignature('3/4', 3)
>>> a.getBeatProgress(0)
(1, 0)
>>> a.getBeatProgress(0.75)
(1, 0.75)
>>> a.getBeatProgress(1.0)
(2, 0.0)
>>> a.getBeatProgress(2.5)
(3... | 625941e30fa83653e46573a1 |
def __init__(self, data, pointer=None): <NEW_LINE> <INDENT> self.data = data <NEW_LINE> self.pointer = pointer | Initialise the node. | 625941e3283ffb24f3c55ce6 |
def code_html(filename_clean): <NEW_LINE> <INDENT> with open("candidats2.json") as f: <NEW_LINE> <INDENT> data = json.load(f) <NEW_LINE> <DEDENT> f2 = open(filename_clean,"w") <NEW_LINE> out = "" <NEW_LINE> f2.write("<table>\n <thead>\n <tr>\n <th>Nom</th>\n <th>Prenom</th>\n <th>Page dediee<... | ce programme prend des tweets en fichier json mal "indentés" localisé en filename et rajoute l'indentation
pour avoir des "bons fichiers" json sur file_nameclean" | 625941e363d6d428bbe448d9 |
def searchInsert(self, nums, target): <NEW_LINE> <INDENT> if not nums: return 0 <NEW_LINE> if target < nums[0]: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> l = 0 <NEW_LINE> r = len(nums) <NEW_LINE> while r-l > 1: <NEW_LINE> <INDENT> mid = l + (r-l)//2 <NEW_LINE> if nums[mid] <= target: <NEW_LINE> <INDENT> l = mid ... | :type nums: List[int]
:type target: int
:rtype: int | 625941e30c0af96317bb85d0 |
def assert_instance_matches_schema(self, instance, schema, validator=None): <NEW_LINE> <INDENT> if validator is None: <NEW_LINE> <INDENT> validator = self.RemoteSchemaValidator( self._topchef_url, self._http_library ) <NEW_LINE> <DEDENT> result = validator.does_instance_match_schema(instance, schema) <NEW_LINE> if not ... | :param dict instance: The instance to validate
:param dict schema: The schema against which the instance is to be
validated
:param AbstractValidator validator: The validator to use. If this is
None, a RemoteSchemaValidator will be constructed
:return: True if the instance matches the schema
:raises: NetworkErro... | 625941e3596a897236089ea4 |
def escalate_tickets(queues, verbose): <NEW_LINE> <INDENT> queryset = Queue.objects.filter(escalate_days__isnull=False).exclude(escalate_days=0) <NEW_LINE> if queues: <NEW_LINE> <INDENT> queryset = queryset.filter(slug__in=queues) <NEW_LINE> <DEDENT> for q in queryset: <NEW_LINE> <INDENT> last = date.today() - timedelt... | Only include queues with escalation configured | 625941e35166f23b2e1a5542 |
@torch.jit.script <NEW_LINE> def encode_boxes(reference_boxes, proposals, weights): <NEW_LINE> <INDENT> wx = weights[0] <NEW_LINE> wy = weights[1] <NEW_LINE> ww = weights[2] <NEW_LINE> wh = weights[3] <NEW_LINE> proposals_x1 = proposals[:, 0].unsqueeze(1) <NEW_LINE> proposals_y1 = proposals[:, 1].unsqueeze(1) <NEW_LINE... | Encode a set of proposals with respect to some
reference boxes
Arguments:
reference_boxes (Tensor): reference boxes
proposals (Tensor): boxes to be encoded | 625941e350812a4eaa59c707 |
def test_if_public_is_false(self): <NEW_LINE> <INDENT> self.assertFalse(self.picture.public) | Public must be False as default | 625941e321bff66bcd684d37 |
def delete_expired_users(self): <NEW_LINE> <INDENT> pass | Remove expired instances of ``RegistrationProfile`` and their
associated ``User``s.
Accounts to be deleted are identified by searching for
instances of ``RegistrationProfile`` with expired activation
keys, and then checking to see if their associated ``User``
instances have the field ``is_active`` set to ``False``; any... | 625941e315baa723493c4361 |
def _traverse_internal(root, visit, stack, path): <NEW_LINE> <INDENT> if not tf_inspect.isclass(root) and not tf_inspect.ismodule(root): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> children = tf_inspect.getmembers(root) <NEW_LINE> if tf_inspect.isclass(root) and issubclass(root, enum.Enum): ... | Internal helper for traverse. | 625941e367a9b606de4a82a0 |
def OnRspQryInvestorPosition(self, pInvestorPosition, pRspInfo, nRequestID, bIsLast): <NEW_LINE> <INDENT> pass | 请求查询投资者持仓响应 | 625941e396565a6dacc8fab3 |
def find_textboxes_recursively(layout_obj): <NEW_LINE> <INDENT> if isinstance(layout_obj, LTTextBox): <NEW_LINE> <INDENT> return [layout_obj] <NEW_LINE> <DEDENT> if isinstance(layout_obj,LTContainer): <NEW_LINE> <INDENT> boxes=[] <NEW_LINE> for child in layout_obj: <NEW_LINE> <INDENT> boxes.extend(find_textboxes_recurs... | 재귀적으로 텍스트 박스(LTTextBox)를 찾고
텍스트 박스들을 리스트로 반화한다. | 625941e371ff763f4b549a7b |
def set_Type(self, value): <NEW_LINE> <INDENT> super(SegmentationDataInputSet, self)._set_input('Type', value) | Set the value of the Type input for this Choreo. ((optional, string) The analysis type you would like to get data for. Valid values are: general, unique, or average) | 625941e34527f215b584c83c |
def updateMatrix(self, matrix): <NEW_LINE> <INDENT> dir_ =[(0,-1), (0,1), (-1,0), (1,0)] <NEW_LINE> rows = len(matrix) <NEW_LINE> cols = len(matrix[0]) <NEW_LINE> q = deque() <NEW_LINE> res =[[sys.maxint for j in range(cols)] for i in range(rows)] <NEW_LINE> for i in range(rows): <NEW_LINE> <INDENT> for j in range ( co... | :type matrix: List[List[int]]
:rtype: List[List[int]] | 625941e34f6381625f114e24 |
def evaluate(self, yaql_expression): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> parsed_exp = self.yaql_engine(yaql_expression) <NEW_LINE> self.logger.debug('parsed exp is: %s', parsed_exp) <NEW_LINE> res = parsed_exp.evaluate(data=self.context['$%new'], context=self.context) <NEW_LINE> self.logger.debug('Evaluation r... | Evaluate given YAQL expression
:param yaql_expression: YAQL expression which needed to be evaluated
:type yaql_expression: str
:return: result of evaluation as a string | 625941e307d97122c4178c7d |
def _get_environment(self): <NEW_LINE> <INDENT> return self.__environment | Getter method for environment, mapped from YANG variable /environment (container)
YANG Description: The environment settings of a VNF-BR. | 625941e35f7d997b87174e84 |
def read_bytestring(self, data, offset): <NEW_LINE> <INDENT> self._sdp_header = SDPHeader.from_bytestring(data, offset) <NEW_LINE> self._scp_response_header = SCPResponseHeader.from_bytestring( data, _SCP_HEADER_OFFSET + offset) <NEW_LINE> self.read_data_bytestring(data, _SCP_DATA_OFFSET + offset) | Reads a packet from a bytestring of data
:param data: The data to be read
:type data: bytestring
:param offset: The offset in the data from which the response should be read
:type offset: int | 625941e34f6381625f114e25 |
def __init__(self, api_version=None, groups=None, kind=None, local_vars_configuration=None): <NEW_LINE> <INDENT> if local_vars_configuration is None: <NEW_LINE> <INDENT> local_vars_configuration = Configuration.get_default_copy() <NEW_LINE> <DEDENT> self.local_vars_configuration = local_vars_configuration <NEW_LINE> se... | V1APIGroupList - a model defined in OpenAPI | 625941e3be8e80087fb21026 |
@app.after_request <NEW_LINE> def add_header(r): <NEW_LINE> <INDENT> r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" <NEW_LINE> r.headers["Pragma"] = "no-cache" <NEW_LINE> r.headers["Expires"] = "0" <NEW_LINE> r.headers['Cache-Control'] = 'public, max-age=0' <NEW_LINE> return r | Add headers to both force latest IE rendering engine or Chrome Frame,
and also to cache the rendered page for 10 minutes. | 625941e32c8b7c6e89b35ba7 |
def _wikipedia_example(): <NEW_LINE> <INDENT> import string <NEW_LINE> candidates = {k: v for k, v in enumerate(string.ascii_lowercase[:5])} <NEW_LINE> a = 0 <NEW_LINE> b = 1 <NEW_LINE> c = 2 <NEW_LINE> d = 3 <NEW_LINE> e = 4 <NEW_LINE> pairs = { (a, b): 20, (a, c): 26, (a, d): 30, (a, e): 22, (b, a): 25, (b, c): ... | Wikipedia example schulz method example
https://en.wikipedia.org/wiki/Schulze_method#Example | 625941e37cff6e4e81117d6e |
def build_append_value (self, cpv, oneshot = False, update = False, downgrade = False, version = None, useChange = []): <NEW_LINE> <INDENT> string = "" <NEW_LINE> if oneshot: <NEW_LINE> <INDENT> string += "<i>%s</i>" % _("oneshot") <NEW_LINE> <DEDENT> if update: <NEW_LINE> <INDENT> if oneshot: string += "; " <NEW_LINE>... | Builds the list, which is going to be passed to append.
@param cpv: the cpv
@type cpv: string (cpv)
@param oneshot: True if oneshot
@type oneshot: boolean
@param update: True if this is an update
@type update: boolean
@param downgrade: True if this is a downgrade
@type downgrade: boolean
@param version: the version w... | 625941e34a966d76dd5513fc |
def test_specific_plugin_not_installed(self): <NEW_LINE> <INDENT> self._add_plugin(self.jigconfig, 'plugin01') <NEW_LINE> set_jigconfig(self.gitrepodir, config=self.jigconfig) <NEW_LINE> self.commit(self.gitrepodir, 'a.txt', 'a') <NEW_LINE> self.stage(self.gitrepodir, 'b.txt', 'b') <NEW_LINE> with nested( patch('jig.ru... | A specific plugin can be ran but it's not installed. | 625941e324f1403a92600f4c |
@plugin_function("group_replication.stopChannel") <NEW_LINE> def stopChannel(channel_name, session=None): <NEW_LINE> <INDENT> if session is None: <NEW_LINE> <INDENT> session = shell.get_session() <NEW_LINE> if session is None: <NEW_LINE> <INDENT> print("No session specified. Either pass a session object to this " "func... | Stop Replication Channel
This function stops the replication channel
Args:
channel_name (string): The replication channel's name.
session (object): The optional session object used to query the
database. If omitted the MySQL Shell's current session will be used. | 625941e363b5f9789fde74cf |
def save(self) -> MyHighlights: <NEW_LINE> <INDENT> Utilities.click_option(self.driver, element=self.save_button) <NEW_LINE> return self.page | Click the save note button.
:return: the My Highlights and Notes modal
:rtype: :py:class:`~MyHighlights` | 625941e37d847024c06be6a8 |
def generate_context(self, article): <NEW_LINE> <INDENT> template = self.get_template('article') <NEW_LINE> html = template.render(article = article) <NEW_LINE> return html | 生成 article
根据 jinja2 模板生成 html, 返回 html 数据, 由 Writer 类写入
Args:
article: dict 类型, 包含文章所有信息
Return:
html: str | 625941e3be383301e01b5867 |
def search(self, data): <NEW_LINE> <INDENT> current = self.head <NEW_LINE> while current: <NEW_LINE> <INDENT> if current.data == data: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> current = current.next <NEW_LINE> <DEDENT> return False | find and item in a linked list
>>> ll = LinkedList()
>>> ll.insert(1)
>>> ll.insert(2)
>>> ll.insert(3)
>>> ll.insert(4)
>>> ll.search(3)
True | 625941e38c0ade5d55d3eda7 |
def get_restoring_decisions(self): <NEW_LINE> <INDENT> for state in self.states[:-1]: <NEW_LINE> <INDENT> self.restoring_decisions.enqueue(state.last_decision) <NEW_LINE> <DEDENT> self.restoring_decisions.enqueue(False) | Get decisions to restore a state and begin down right path (False). | 625941e3656771135c3ebc5c |
def __init__(self, op, index): <NEW_LINE> <INDENT> self.__op = op <NEW_LINE> self.__slots = {} <NEW_LINE> self.__innerOp = None <NEW_LINE> self.inputs = InputDict(self) <NEW_LINE> for slot in op.inputs.values(): <NEW_LINE> <INDENT> if slot.level >= 1 and not slot.nonlane: <NEW_LINE> <INDENT> self.inputs[slot.name] = sl... | Constructor. Creates a view of the given operator for the specified index.
:param op: The operator to view.
:param index: The index of this subview. All multislots of the original
operator will be replaced with the corresponding subslot at this index. | 625941e3a8370b7717052c86 |
def IFlat(R,vR,vT,vc=1.,ro=1.,rap=None,rperi=None,**kwargs): <NEW_LINE> <INDENT> if rap == None or rperi == None: <NEW_LINE> <INDENT> (rperi,rap)= calcRapRperiFlat(R,vR,vT,vc=vc,ro=ro) <NEW_LINE> <DEDENT> Rmean= m.exp((m.log(rperi)+m.log(rap))/2.) <NEW_LINE> if rap == rperi: <NEW_LINE> <INDENT> e= 10.**-6. <NEW_LINE> r... | NAME:
IFlat
PURPOSE:
Calculate I, the 'ratio' between the radial and azimutha period,
for a flat rotation curve
INPUT:
R - Galactocentric radius (/ro)
vR - radial part of the velocity (/vc)
vT - azimuthal part of the velocity (/vc)
vc - circular velocity
ro - reference radius
+scipy.integrat... | 625941e3cb5e8a47e48b7e8d |
def is_repo_package(self, path): <NEW_LINE> <INDENT> return (os.path.isdir(path) and os.path.isfile( wayround_i2p.utils.path.join(path, '.package') ) ) | Check whatever path is [aipsetup package index] package | 625941e3cb5e8a47e48b7e8e |
def clean_message(msg): <NEW_LINE> <INDENT> n = re.search("<n(.*?)/>", msg) <NEW_LINE> if n: n = n.group(1) <NEW_LINE> f = re.search("<f(.*?)>", msg) <NEW_LINE> if f: f = f.group(1) <NEW_LINE> msg = re.sub("<n.*?/>", "", msg) <NEW_LINE> msg = re.sub("<f.*?>", "", msg) <NEW_LINE> msg = strip_html(msg[1:]) <NEW_LINE> msg... | Clean a message and return the message, n tag and f tag.
@type msg: str
@param msg: the message
@rtype: str, str, str
@returns: cleaned message, n tag contents, f tag contents | 625941e3ac7a0e7691ed44ae |
def to_json(self): <NEW_LINE> <INDENT> json = {} <NEW_LINE> if len(self._global) > 0: <NEW_LINE> <INDENT> e = [] <NEW_LINE> for i in self._global: <NEW_LINE> <INDENT> e.append(i.to_json()) <NEW_LINE> <DEDENT> json["global"] = e <NEW_LINE> <DEDENT> if len(self._per_message) > 0: <NEW_LINE> <INDENT> e = [] <NEW_LINE> for... | build json dict for MergeDataJson
:return the json dictionary
:rtype dict | 625941e3099cdd3c635f1042 |
def add_dt_entries(self, dt_entries): <NEW_LINE> <INDENT> if not dt_entries: <NEW_LINE> <INDENT> raise ValueError('Attempted to add empty list of DT entries') <NEW_LINE> <DEDENT> if self.__dt_entries: <NEW_LINE> <INDENT> raise ValueError('DTBO DT entries can be added only once') <NEW_LINE> <DEDENT> dt_entry_count = len... | Adds DT image files to the DTBO object.
Adds a list of Dtentry Objects to the DTBO image. The changes are not
committed to the output file until commit() is called.
Args:
dt_entries: List of DtEntry object to be added.
Returns:
A buffer containing all DT entries.
Raises:
ValueError: if the list of DT en... | 625941e3b545ff76a89141fe |
def get_file_ext_from_mime_type(self, mime_type): <NEW_LINE> <INDENT> if mime_type.lower() == 'image/jpeg': <NEW_LINE> <INDENT> return 'jpeg' <NEW_LINE> <DEDENT> if mime_type.lower() == 'image/png': <NEW_LINE> <INDENT> return 'png' <NEW_LINE> <DEDENT> if mime_type.lower() == 'image/gif': <NEW_LINE> <INDENT> return 'gif... | Gets the file extension associated with a mime type.
Parameters
----------
mime_type:
The MIME type to get the file extension for. | 625941e38e71fb1e9831db91 |
def connect(self): <NEW_LINE> <INDENT> if self.success: <NEW_LINE> <INDENT> return True, None <NEW_LINE> <DEDENT> return False, "Error message" | Function: connect
Description: Stub holder for Mongo.Coll.connect method.
Arguments: | 625941e37cff6e4e81117d6f |
def buildNoiseMap(self, e_adu, std_deviation): <NEW_LINE> <INDENT> self.noiseMap = np.sqrt(np.abs(self.array) / e_adu + std_deviation ** 2) | Building of the noise map (photon noise in each pixel) where
e_adu is the gain of the CCD camera | 625941e3ec188e330fd5ab81 |
def createStatusBar(self): <NEW_LINE> <INDENT> statusBar = self.statusBar() <NEW_LINE> self._sbLabelName = self.createStatusBarLabel(1) <NEW_LINE> self._sbLabelSize = self.createStatusBarLabel() <NEW_LINE> self._sbLabelDimensions = self.createStatusBarLabel() <NEW_LINE> self._sbLabelDate = self.createStatusBarLabel() <... | Create status bar. | 625941e3a8370b7717052c87 |
def height(self, node): <NEW_LINE> <INDENT> if node is None: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> elif node.left is None and node.right is None: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return 1 + max(self.height(node.left), self.height(node.right)) | Height of the tree
:param node: starting node
:return: height of the tree | 625941e3d53ae8145f87a652 |
def questionnaire_export(self, report_id, REQUEST, answers=None, type='excel'): <NEW_LINE> <INDENT> report = self.getReport(report_id) <NEW_LINE> if not report: <NEW_LINE> <INDENT> raise NotFound('Report %s' % (report_id,)) <NEW_LINE> <DEDENT> if answers is None: <NEW_LINE> <INDENT> answers = self.getAnswers() <NEW_LIN... | Exports the report in excel or pdf format | 625941e37d43ff24873a308c |
def petla_spacerow(liczba_spacerow, zakres_dlugosci_spacerow, limit_dystansu): <NEW_LINE> <INDENT> for walk_length in range(1, zakres_dlugosci_spacerow + 1): <NEW_LINE> <INDENT> brak_transportu = 0 <NEW_LINE> for i in range(liczba_spacerow): <NEW_LINE> <INDENT> (x, y) = losowy_spacer(walk_length) <NEW_LINE> dystans = a... | Determinuje jak często potrzebny będzie transport ze spaceru,
będzie potrzebny zawsze gdy absolutna długość spaceru jest większa od limit_dystansu | 625941e34e696a04525c9836 |
def setUp(self): <NEW_LINE> <INDENT> self.player_1 = PlayerControl(Player("Foo", chess.WHITE, human=True)) <NEW_LINE> self.player_2 = PlayerControl(Player("Bar", chess.BLACK)) <NEW_LINE> self.game_control = GameControl(self.player_1, self.player_2) <NEW_LINE> self.temp_stdout = StringIO() | Init tests. | 625941e3d486a94d0b98e530 |
def commandTags(self): <NEW_LINE> <INDENT> return ["concatenate", "concatenate arrays", "combine arrays"] | Tags to identify the concatenate | 625941e3293b9510aa2c367b |
@webtest <NEW_LINE> def static_get3(): <NEW_LINE> <INDENT> status, data = get('/static/hello.json') <NEW_LINE> assert status == 200, 'GET /static/hello.json returned %d, not 200' % status <NEW_LINE> assert data.hello == 'world', 'GET /static/hello.json returned %s' % str(data) | GET resource and verify that later specified source directory takes
precedence | 625941e35fcc89381b1e1aab |
def test_end(suffix): <NEW_LINE> <INDENT> return lambda topic, matched: topic.endswith(suffix) | Return a test function to match the end of a topic. | 625941e3cad5886f8bd273c2 |
def cmvn(features, label=None, global_mean=None, global_std=None): <NEW_LINE> <INDENT> if label is None: <NEW_LINE> <INDENT> label = numpy.ones(features.shape[0]).astype(bool) <NEW_LINE> <DEDENT> if global_mean is not None and global_std is not None: <NEW_LINE> <INDENT> mu = global_mean <NEW_LINE> stdev = global_std <N... | Performs mean and variance normalization
:param features: a feature stream of dimension dim x nframes
where dim is the dimension of the acoustic features and nframes the
number of frames in the stream
:param global_mean: pre-computed mean to use for feature normalization if given
:param global_std: pre-compu... | 625941e3cad5886f8bd273c3 |
def ftp_push(info): <NEW_LINE> <INDENT> params = {} <NEW_LINE> params["id"] = info["objectid"] <NEW_LINE> params["rule_name"] = info["rule"]["rule_name"] <NEW_LINE> params["username"] = info["rule"]["username"] <NEW_LINE> kwargs = json.loads(info["rule"]["kwargs"]) <NEW_LINE> params["ftp_url"] = kwargs["ftp_url"] <NEW_... | Create job json for FTP push.
Example:
job = {
'type': 'ftp_push',
'name': 'action-ftp_push-CSKS4_RAW_B_HI_11_HH_RD_20131004020329_20131004020336',
'tag': 'FTP Push CSK Calimap',
'username': 'ops',
'params': {
'id': 'CSKS4_RAW_B_HI_11_HH_RD_20131004020329_2013100402... | 625941e3167d2b6e31218f7f |
def __init__(__self__, *, acm: Optional[pulumi.Input['VirtualGatewaySpecBackendDefaultsClientPolicyTlsValidationTrustAcmArgs']] = None, file: Optional[pulumi.Input['VirtualGatewaySpecBackendDefaultsClientPolicyTlsValidationTrustFileArgs']] = None, sds: Optional[pulumi.Input['VirtualGatewaySpecBackendDefaultsClientPolic... | :param pulumi.Input['VirtualGatewaySpecBackendDefaultsClientPolicyTlsValidationTrustAcmArgs'] acm: The TLS validation context trust for an AWS Certificate Manager (ACM) certificate.
:param pulumi.Input['VirtualGatewaySpecBackendDefaultsClientPolicyTlsValidationTrustFileArgs'] file: The TLS validation context trust for ... | 625941e33c8af77a43ae3b8e |
def to_dot(word :str, tree :GraphWithEdgeContent) -> str: <NEW_LINE> <INDENT> s = "digraph G { %s" % default_graphviz_style() <NEW_LINE> adjacencies = tree.__adjacencies__ <NEW_LINE> print(adjacencies) <NEW_LINE> for u, d in enumerate(adjacencies): <NEW_LINE> <INDENT> if u == tree.root: <NEW_LINE> <INDENT> s += " %s [... | Graphviz export.
Args:
word: A string containing the word used to build the suffix tree.
tree: The GraphWithEdgeContent representing the suffix tree.
Returns:
The string in the graphviz format representing the suffix tree. | 625941e3d10714528d6000d1 |
def create_app(object_name): <NEW_LINE> <INDENT> app = Flask(__name__) <NEW_LINE> app.config.from_object(object_name) <NEW_LINE> db.init_app(app) <NEW_LINE> migrate.init_app(app, db) <NEW_LINE> from .auth import create_module as auth_create_module <NEW_LINE> from .blog import create_module as blog_create_module <NEW_LI... | An flask application factory, as explained here:
http://flask.pocoo.org/docs/patterns/appfactories/
Arguments:
object_name: the python path of the config object,
e.g. project.config.ProdConfig | 625941e321a7993f00bc80e0 |
def newPeriodicTimer( self, interval, callback ): <NEW_LINE> <INDENT> timer = QtCore.QTimer() <NEW_LINE> timer.start(int(interval) ) <NEW_LINE> timer.timeout.connect(callback) <NEW_LINE> return timer | Convenience function to create a periodic timer which calls a function at the
given interval.
:param interval: interval in milliseconds
:param callback: no-argument function callback() to be called at intervals
:return: the underlying QTimer object | 625941e38e7ae83300e4b3b7 |
def __getattr__(self, attr): <NEW_LINE> <INDENT> if attr == "__setstate__": <NEW_LINE> <INDENT> raise AttributeError() <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> return self[attr] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> errmsg = "'{}' object has no attribute '{}'".format(self.__class__.__name__, attr... | Read a key as an attribute. Raise AttributeError on missing key.
Called only for attributes that do not exist. | 625941e3cdde0d52a9e5341f |
def test_account_manager_create_user(self): <NEW_LINE> <INDENT> new_account = Account.objects.create_user(email='normal2@test.com', confirm_password='norm', username='normal2', password='norm', first_name='Norman') <NEW_LINE> self.assertEqual(Account.objects.filter(email='normal2@test.com').count(), 1, msg='Test that u... | Ensure we create a new account | 625941e30383005118ecf9cb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.