code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def PColor(red, green, blue, white = 0): <NEW_LINE> <INDENT> return (white << 24) | (blue << 16)| (green << 8) | red | Convert the provided red, green, blue color to a 24-bit color value.
Each color component should be a value 0-255 where 0 is the lowest intensity
and 255 is the highest intensity. | 625941d8d58c6744b4257ec9 |
def clearSubarray(temp, x0, x1, y0, y1, dx, dy, x_offset): <NEW_LINE> <INDENT> (ny, nx) = temp.shape <NEW_LINE> x0 += x_offset <NEW_LINE> x0 -= dx <NEW_LINE> y0 -= dy <NEW_LINE> x1 += x_offset <NEW_LINE> x1 -= dx <NEW_LINE> y1 -= dy <NEW_LINE> x0 = max(x0, 0) <NEW_LINE> y0 = max(y0, 0) <NEW_LINE> x1 = min(x1, nx) <NEW_... | Set the subarray to zero in temp. | 625941d8b7558d58953c517b |
def postparse_hook_emptystatement(self, data: cmd2.plugin.PostparsingData) -> cmd2.plugin.PostparsingData: <NEW_LINE> <INDENT> self.called_postparsing += 1 <NEW_LINE> raise exceptions.EmptyStatement | A postparsing hook with raises an EmptyStatement exception | 625941d8460517430c3943eb |
def isPowerOfThree(self, n): <NEW_LINE> <INDENT> if n == 1 or n == 3: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if n % 3 != 0 or n == 0: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.isPowerOfThree(n/3) | :type n: int
:rtype: bool | 625941d8e76e3b2f99f3aa73 |
def equal(obj1, obj2): <NEW_LINE> <INDENT> if isinstance(obj1, int) and isinstance(obj2, int): <NEW_LINE> <INDENT> return obj1 == obj2 <NEW_LINE> <DEDENT> elif isinstance(obj1, int) and not isinstance(obj2, int): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> elif not isinstance(obj1, int) and isinstance(obj2, i... | Return whether two nested lists are equal, i.e., have the same value.
Note: order matters.
@type obj1: int | list
@type obj2: int | list
@rtype: bool
>>> equal(17, [1, 2, 3])
False
>>> equal([1, 2, [1, 2], 4], [1, 2, [1, 2], 4])
True
>>> equal([1, 2, [1, 2], 4], [4, 2, [2, 1], 3])
False | 625941d87cff6e4e81117bf0 |
def p_name_and_number_form_1 (t): <NEW_LINE> <INDENT> t[0] = Node ('name_and_number', ident = t[1], number = t[3]) | name_and_number_form : identifier LPAREN number_form RPAREN
| type_ref LPAREN number_form RPAREN | 625941d8b830903b967e9b74 |
def _preTeardown(self, **kwargs): <NEW_LINE> <INDENT> if not self.exists: <NEW_LINE> <INDENT> raise DeviceFormatError("format has not been created") <NEW_LINE> <DEDENT> return self.status | Return True if teardown should proceed. | 625941d83c8af77a43ae3a0d |
def SetForegroundColour(self, colour): <NEW_LINE> <INDENT> if not self._main_win: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self._main_win.SetForegroundColour(colour) | Changes the foreground colour of :class:`HyperTreeList`.
:param `colour`: the colour to be used as the foreground colour, pass
:class:`NullColour` to reset to the default colour.
:note: Overridden from :class:`wx.Control`. | 625941d807d97122c4178afa |
def __init__(self): <NEW_LINE> <INDENT> self.ClusterId = None <NEW_LINE> self.TableGroupId = None | :param ClusterId: ID of the cluster where a table group resides
:type ClusterId: str
:param TableGroupId: Table group ID
:type TableGroupId: str | 625941d850485f2cf553d006 |
def object_class(type): <NEW_LINE> <INDENT> return _TYPE_MAP.get(type, None) | Get the object class corresponding to the given type.
:param type: Either a type name string or a numeric type.
:return: The ShaFile subclass corresponding to the given type, or None if
type is not a valid type name/number. | 625941d823e79379d52ee7cc |
def checkMethod(self, method): <NEW_LINE> <INDENT> return (method in ['diff', 'standard', 'svd']) | Checks if the specified Tikhonov method is valid. | 625941d863f4b57ef000137f |
def getEquipments(self): <NEW_LINE> <INDENT> return self._equipments | Get the Equipments object of the current game
Args:
self: the Game object
Returns:
The Equipments object
Raises:
None | 625941d824f1403a92600dd0 |
def test_numerically(f, g, z=None, tol=1.0e-6, a=2, b=-1, c=3, d=1): <NEW_LINE> <INDENT> f, g, z = Tuple(f, g, z) <NEW_LINE> z = [z] if isinstance(z, Symbol) else (f.free_symbols | g.free_symbols) <NEW_LINE> reps = zip(z, [random_complex_number(a, b, c, d) for zi in z]) <NEW_LINE> z1 = f.subs(reps).n() <NEW_LINE> z2 = ... | Test numerically that f and g agree when evaluated in the argument z.
If z is None, all symbols will be tested. This routine does not test
whether there are Floats present with precision higher than 15 digits
so if there are, your results may not be what you expect due to round-
off errors.
Examples
========
>>> fro... | 625941d80fa83653e4657225 |
def p_expr_NOT(t): <NEW_LINE> <INDENT> def logical_not(expr): <NEW_LINE> <INDENT> if type(expr) is not tuple: <NEW_LINE> <INDENT> return expr <NEW_LINE> <DEDENT> left, op, right = expr <NEW_LINE> return logical_not(left), op_not[op], logical_not(right) <NEW_LINE> <DEDENT> t[0] = logical_not(t[2]) | expr : NOT expr | 625941d838b623060ff0b059 |
def dict_to_square_matrix(dictionary, n=None): <NEW_LINE> <INDENT> if n is None: <NEW_LINE> <INDENT> n = np.sqrt(len(dictionary)) <NEW_LINE> if not isinstance(n, int) or n < 1: <NEW_LINE> <INDENT> raise Exception("Dictionary has a non-integer square root.") <NEW_LINE> <DEDENT> <DEDENT> return dict_to_matrix(dictionary,... | Converts a dictionary to a 2-dimensional square numpy ndarray
Creates a numpy ndarray with specified number of rows and columns. If no
number of rows and columns is provided, this number will be set to the
square root of the number of entries in the dictionary (unless this is not
an integer, in which case an :obj:`Exc... | 625941d83cc13d1c6d3c75e5 |
def get_percona_service_entry(self, memory_constraint=None): <NEW_LINE> <INDENT> memory_constraint = memory_constraint or '3072M' <NEW_LINE> svc_entry = { 'name': 'percona-cluster', 'constraints': {'mem': memory_constraint}} <NEW_LINE> if self._get_openstack_release() <= self.trusty_mitaka: <NEW_LINE> <INDENT> svc_entr... | Return a amulet service entry for percona cluster.
:param memory_constraint: Override the default memory constraint
in the service entry.
:type memory_constraint: str
:returns: Amulet service entry.
:rtype: dict | 625941d85fc7496912cc3be9 |
def predict_proba(self, X: np.array) -> np.array: <NEW_LINE> <INDENT> assert self.model <NEW_LINE> return self.model.PredictProba(X) | Predict class probabilities for X.
Args:
X (np.array): The dataset for which to predict values.
Returns:
np.array: The class probabilities of the input samples. | 625941d8d486a94d0b98e3b2 |
def _fetch_bbob_fcts(self): <NEW_LINE> <INDENT> bbob_version, fname = '15.03', 'bbobpproc.tar.gz' <NEW_LINE> url = 'http://coco.lri.fr/downloads/download'+bbob_version+'/'+fname <NEW_LINE> print('downloading %s ...' % url, end=''); sys.stdout.flush() <NEW_LINE> utils.download_file(url) <NEW_LINE> print(' done downloadi... | Fetch GECCO BBOB 2009 functions from WWW and set as `self.BBOB`.
Side effects in the current folder: two files are added and folder
"._tmp_" is removed. | 625941d8377c676e91272413 |
def _perform_local_deletions(self, content_to_delete_locally): <NEW_LINE> <INDENT> roots = {} <NEW_LINE> for pathname in reversed(content_to_delete_locally): <NEW_LINE> <INDENT> found_ancestor = False <NEW_LINE> for root in roots: <NEW_LINE> <INDENT> if pathname.startswith(root): <NEW_LINE> <INDENT> found_ancestor = Tr... | Deletes from the filesystem pathnames that have been remotely
deleted from the storage.
Note: This is an ugly hack, since this kind of actions should be
performed by some type of Worker. I choose to do so since I
already had to for local renames, which haven't a representation
as pathname states in the state machine (... | 625941d873bcbd0ca4b2c2e1 |
def write(self, name=None): <NEW_LINE> <INDENT> if name is None: <NEW_LINE> <INDENT> name = self.name <NEW_LINE> <DEDENT> if not exists(dirname(self.name)): <NEW_LINE> <INDENT> makedirs(dirname(self.name)) <NEW_LINE> <DEDENT> with open(name, 'w') as f: <NEW_LINE> <INDENT> f.write(str(self)) | Write the inputs to the file. | 625941d8d58c6744b4257eca |
def _serialize_history( self, trans, history: model.History, serialization_params: SerializationParams, default_view: str = "detailed", ) -> Union[HistoryBeta, HistoryDetailed, HistorySummary]: <NEW_LINE> <INDENT> serialization_params["default_view"] = default_view <NEW_LINE> serialized_history = self.serializer.serial... | Returns a dictionary with the corresponding values depending on the
serialization parameters provided. | 625941d85e10d32532c5f192 |
def hasattr(): <NEW_LINE> <INDENT> pass | 625941d807d97122c4178afb | |
def example10(): <NEW_LINE> <INDENT> schema = Schema(name=TEXT(stored=True), height=NUMERIC(float, stored=True)) <NEW_LINE> ix = create_in("indexdir", schema) <NEW_LINE> writer = ix.writer() <NEW_LINE> writer.add_document(name = "Jack", height=180.5) <NEW_LINE> writer.commit() <NEW_LINE> with ix.searcher() as searcher:... | 根据多个字段进行全文搜索
| 625941d89c8ee82313fbb9e1 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, Pet): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941d8097d151d1a2230c4 |
def GroupNames(): <NEW_LINE> <INDENT> names = scriptcontext.doc.Groups.GroupNames(True) <NEW_LINE> if names is None: return None <NEW_LINE> return list(names) | Returns the names of all the groups in the document
None if no names exist in the document | 625941d8566aa707497f47d1 |
def test_get_short_ns(self): <NEW_LINE> <INDENT> test_uri = 'http://www.w3.org/2001/XMLSchema-instance' <NEW_LINE> ret = rtcprofile.get_short_ns(test_uri) <NEW_LINE> self.assertEqual(ret, 'xsi') <NEW_LINE> test_uri = 'aaaa' <NEW_LINE> ret = rtcprofile.get_short_ns(test_uri) <NEW_LINE> self.assertEqual(ret, None) | test for get_short_ns | 625941d8435de62698dfdeb8 |
def __str__(self): <NEW_LINE> <INDENT> return str(self.get_state()) | String reprezentation of the state.
Returns
-------
mixed
State of the machine. | 625941d84e4d5625662d4641 |
def _log_fatal(self, request, error): <NEW_LINE> <INDENT> if self.app.cfg['error/logging_enabled'] and self.app.cfg['error/log_5xx']: <NEW_LINE> <INDENT> self.log.error(self._format_fatal(request, error)) | Log fatal errors. | 625941d830dc7b7665901bd0 |
def request_data(self, url: str, get_chapters: bool=False, **params: dict) -> Response: <NEW_LINE> <INDENT> if get_chapters: <NEW_LINE> <INDENT> if self.model.download_type in ('group', 'user'): <NEW_LINE> <INDENT> url = self.model.chapter_api_url <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> url = f'{url}/feed' <NEW_L... | Connect to the API and get the response.
Args:
url (str): Download url.
get_chapters (bool, optional): If the download is to get the chapters. Defaults to False.
Returns:
Response: The response of the resquest. | 625941d87c178a314d6ef6ce |
def testLFNParser(self): <NEW_LINE> <INDENT> lfnA = '/store/temp/acquisition_10-A/MuElectron-10_100/RAW-RECO/vX-1/1000/a_X-2.root' <NEW_LINE> result = parseLFN(lfnA) <NEW_LINE> self.assertEqual(result['baseLocation'], '/store/temp') <NEW_LINE> self.assertEqual(result['acquisitionEra'], 'acquisition_10-A') <NEW_LINE> se... | _testLFNParser_
Check and make sure that we parse LFNs correctly | 625941d83539df3088e2e5b6 |
def form_valid(self, form): <NEW_LINE> <INDENT> form.instance.user.email = form.data['email'] <NEW_LINE> form.instance.user.email = form.data['first_name'] <NEW_LINE> form.instance.user.email = form.data['last_name'] <NEW_LINE> form.instance.user.save() <NEW_LINE> return super().form_valid(form) | Validate form data. | 625941d8a79ad161976cc3b1 |
def get_config(): <NEW_LINE> <INDENT> cfg = VersioneerConfig() <NEW_LINE> cfg.VCS = "git" <NEW_LINE> cfg.style = "pep440" <NEW_LINE> cfg.tag_prefix = "" <NEW_LINE> cfg.parentdir_prefix = "None" <NEW_LINE> cfg.versionfile_source = "src/leap/soledad/client/_version.py" <NEW_LINE> cfg.verbose = False <NEW_LINE> return cfg | Create, populate and return the VersioneerConfig() object. | 625941d816aa5153ce3626e3 |
def test_no_user_message(self): <NEW_LINE> <INDENT> self.assertEqual( parse_message(NO_USER_MESSAGE), INCORRECT_RESPONSE_400 ) | testing of function parse_message with incorrect argument
:return: | 625941d8f9cc0f698b140865 |
def train_step_meta(self, loss_func, additional_loss_func=None, additional_loss_scale=None): <NEW_LINE> <INDENT> a_loss_scale = additional_loss_scale or self._additional_loss_scale <NEW_LINE> with tf.name_scope(self._scope+'/meta_loss'): <NEW_LINE> <INDENT> meta_loss = self._meta_loss(loss_func) <NEW_LINE> <DEDENT> if ... | Return a tf operation which updates the meta optimizer's variables.
Does not update Gatenet's (optimizee) variables.
Args:
loss_func: (Double?) Callable loss function which returns the loss
for Gatenet (optimizee) on current task's test data.
additional_loss_func: (Double?) Callable loss functio... | 625941d8d6c5a102081442b8 |
def handle_keyrelease(self, event): <NEW_LINE> <INDENT> if event.keysym == "BackSpace": <NEW_LINE> <INDENT> self.delete(self.index(Tkinter.INSERT), Tkinter.END) <NEW_LINE> self.position = self.index(Tkinter.END) <NEW_LINE> <DEDENT> if event.keysym == "Left": <NEW_LINE> <INDENT> if self.position < self.index(Tkinter.END... | event handler for the keyrelease event on this widget | 625941d81b99ca400220ad1e |
def test_confirm(self): <NEW_LINE> <INDENT> d, cp = dbg_setup() <NEW_LINE> u = Muser.UserInterface() <NEW_LINE> for s in ['y', 'Y', 'Yes', ' YES ']: <NEW_LINE> <INDENT> u.input.readline = lambda prompt=None: self.readline(s) <NEW_LINE> self.assertTrue(u.confirm('Testing', True)) <NEW_LINE> pass <NEW_LINE> <DEDENT> fo... | Test interface.user.UserInterface.confirm() | 625941d8a4f1c619b28b02a0 |
def _floating_ip_pool_exists(self, context, name): <NEW_LINE> <INDENT> pools = [pool.get('name') for pool in self.get_floating_ip_pools(context)] <NEW_LINE> if name in pools: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False | Returns true if the specified floating ip pool exists. Otherwise,
returns false. | 625941d8379a373c97cfadb2 |
def is_number(inpt): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> float(inpt) <NEW_LINE> return True <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> return False | The function checks whether an input is a float
:param inpt: The input that is being checked
:return: a bool - True if input is a float and False if otherwise | 625941d832920d7e50b2843e |
def mkdir(directory): <NEW_LINE> <INDENT> if not os.path.exists(directory): <NEW_LINE> <INDENT> os.makedirs(directory) <NEW_LINE> <DEDENT> return os.path.abspath(directory) | Creates a directory if it does not exist, otherwise it does nothing.
It always returns the absolute path to the directory. | 625941d815baa723493c41e3 |
def tdc_get_bound_index(val, array): <NEW_LINE> <INDENT> if val >= array[-1]: <NEW_LINE> <INDENT> idx = len(array)-1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> idx = ( idx for idx,entry in enumerate(array) if entry>val ).next()-1 <NEW_LINE> <DEDENT> return max(0,idx) | return largest index idx of the element in array
such that array[idx] <= val
---> if val<array[0] => idx=0 | 625941d88e71fb1e9831da14 |
def get_infinite(self): <NEW_LINE> <INDENT> result = np.zeros(self.N) <NEW_LINE> for i in range(self.N): <NEW_LINE> <INDENT> N = i <NEW_LINE> lime = (gamma(self.a + self.b)/gamma(self.b)) * (gamma(N + self.b + 1)/(gamma(self.a + self.b + N +1))) <NEW_LINE> cherry = (gamma(self.a + self.b)/(gamma(self.a)*gamma(self.b)))... | compute posterior with beta prior
:return: estimates for diff. values of lime; shape:(N,) | 625941d8e5267d203edcdf06 |
def p_execCont(p): <NEW_LINE> <INDENT> p[0] = p[1] | execCont : activate
| deactivate
| advance
| conditional
| while
| program | 625941d82c8b7c6e89b35a2c |
def pop(self): <NEW_LINE> <INDENT> for _ in range(self.size - 1): <NEW_LINE> <INDENT> head = self.q.pop(0) <NEW_LINE> self._top = head <NEW_LINE> self.q.append(head) <NEW_LINE> <DEDENT> self.q.pop(0) <NEW_LINE> self.size -= 1 | :rtype: nothing | 625941d85fc7496912cc3bea |
def test_new_file_diff(self): <NEW_LINE> <INDENT> diff = self._read_fixture('git_newfile.diff') <NEW_LINE> file = self._get_file_in_diff(diff) <NEW_LINE> self.assertEqual(file.origFile, 'IAMNEW') <NEW_LINE> self.assertEqual(file.newFile, 'IAMNEW') <NEW_LINE> self.assertEqual(file.origInfo, PRE_CREATION) <NEW_LINE> self... | Testing parsing Git diff with new file | 625941d80fa83653e4657226 |
def __str__(self): <NEW_LINE> <INDENT> return self.invariant_path() | Define the behavior of print(vobject)
| 625941d8adb09d7d5db6c9fa |
def _new_trial(self, **kwargs): <NEW_LINE> <INDENT> trial = {'ground_truth': self.rng.choice(self.choices)} <NEW_LINE> trial.update(kwargs) <NEW_LINE> ground_truth = trial['ground_truth'] <NEW_LINE> self.add_period(['fixation', 'stimulus', 'delay', 'decision']) <NEW_LINE> self.add_ob(1, where='fixation') <NEW_LINE> sel... | self._new_trial() is called internally to generate a next trial.
Typically, you need to
set trial: a dictionary of trial information
run self.add_period():
will add time periods to the trial
accesible through dict self.start_t and self.end_t
run self.add_ob():
will add observation t... | 625941d87d847024c06be52a |
def get_client_enrichment_details(self, headers=None, **request_parameters): <NEW_LINE> <INDENT> check_type(headers, dict) <NEW_LINE> if headers is not None: <NEW_LINE> <INDENT> if 'entity_type' in headers: <NEW_LINE> <INDENT> check_type(headers.get('entity_type'), basestring, may_be_none=False) <NEW_LINE> <DEDENT> if ... | Enriches a given network End User context (a network user-id or
end user’s device Mac Address) with details about the
user, the devices that the user is connected to and the
assurance issues that the user is impacted by.
Args:
headers(dict): Dictionary of HTTP Headers to send with the Request
.
**reque... | 625941d8956e5f7376d710d8 |
def test_avgtrial(): <NEW_LINE> <INDENT> c3ds = sessionutils.get_c3ds(sessiondir_abs, trial_type='dynamic') <NEW_LINE> atrial = stats.AvgTrial.from_trials( c3ds, sessionpath=sessiondir_abs, reject_outliers=1e-3, ) <NEW_LINE> assert atrial.sessionpath == sessiondir_abs <NEW_LINE> assert atrial.trialname <NEW_LINE> asser... | Test the AvgTrial class | 625941d8283ffb24f3c55b6b |
def __init__(self, sendNumber=None, replyContent=None, replyTime=None): <NEW_LINE> <INDENT> self.sendNumber = sendNumber <NEW_LINE> self.replyContent = replyContent <NEW_LINE> self.replyTime = replyTime | :param sendNumber: (Optional) 手机号码
:param replyContent: (Optional) 回复内容
:param replyTime: (Optional) 回复时间 | 625941d80c0af96317bb8454 |
def get_monitors(self, response_times=0, logs=0, uptime_ratio=30): <NEW_LINE> <INDENT> url = self.base_url <NEW_LINE> url += 'getMonitors?apiKey={0}'.format(self.api_key) <NEW_LINE> url += '&noJsonCallback=1&format=json' <NEW_LINE> url += '&responseTimes={0}'.format(response_times) <NEW_LINE> url += '&logs={0}'.format(... | Returns status and response payload for all known monitors. | 625941d850812a4eaa59c58c |
def __init__(self, rootGroup, fnString, sliceSpecs, ignoreCoords=False): <NEW_LINE> <INDENT> m = re.match('(\w+)\(([\w,]+)\)',fnString) <NEW_LINE> self.function = m.group(1) <NEW_LINE> varNetcdfSlices = [] <NEW_LINE> for v in m.group(2).split(','): <NEW_LINE> <INDENT> varNetcdfSlices.append( NetcdfSlice(rootGroup, v, s... | Interpret F(x,y,...), assaciate a NetcdfSlice for each of x,y,... and
apply F() when getting data. | 625941d8f9cc0f698b140866 |
def SetInput2(self, *args): <NEW_LINE> <INDENT> return _itkHausdorffDistanceImageFilterPython.itkHausdorffDistanceImageFilterIUS2IUS2_SetInput2(self, *args) | SetInput2(self, itkImageUS2 image) | 625941d8091ae356686671c7 |
def add_event(te_event, session) : <NEW_LINE> <INDENT> te_begin = te_event['datetime']['startdatetime'] <NEW_LINE> te_event['datetime'].pop('startdatetime', None) <NEW_LINE> te_event['datetime'].pop('date', None) <NEW_LINE> if 'result' in te_event: <NEW_LINE> <INDENT> te_result = te_event['result'] <NEW_LINE> <DEDENT>... | add an event based on tennis explorer data
Args:
te_event (dict): event object
session : db session
Returns:
id: event id | 625941d84d74a7450ccd442f |
def search(self, e): <NEW_LINE> <INDENT> tag = self.tag == "*" or self.tag <NEW_LINE> i = lambda s: re.compile(r"\b%s(?=$|\s)" % s, re.I) <NEW_LINE> a = {"id": i(self.id)} if self.id else {} <NEW_LINE> a.update(map(lambda kv: (kv[0], kv[1]), self.attributes.items())) <NEW_LINE> if not isinstance(e, Element): <NEW_LINE>... | Returns the nested elements that match the simple CSS selector. | 625941d807f4c71912b116f0 |
def setServiceCode(self, serviceCode): <NEW_LINE> <INDENT> self.serviceCode = serviceCode | :param serviceCode: (Optional) 资源的类型,取值vm, lb, ip, database 等,<a href="https://docs.jdcloud.com/cn/monitoring/api/describeservices?content=API&SOP=JDCloud">describeServices</a>:查询己接入云监控的产品线列表 | 625941d8a79ad161976cc3b2 |
def initUI(self): <NEW_LINE> <INDENT> newAction = QtGui.QAction('New', self) <NEW_LINE> newAction.setShortcut('Ctrl+N') <NEW_LINE> newAction.setStatusTip('Create new file') <NEW_LINE> newAction.triggered.connect(self.newFile) <NEW_LINE> saveAction = QtGui.QAction('Save', self) <NEW_LINE> saveAction.setShortcut('Ctrl+S'... | Creates the gui and associates the shortcuts
with their default actions | 625941d84d74a7450ccd4430 |
def WriteMessageResourceFile( self, event_log_provider, message_resource_file, message_filename, message_file_type): <NEW_LINE> <INDENT> database_filename = message_resource_file.windows_path <NEW_LINE> _, _, database_filename = database_filename.rpartition('\\') <NEW_LINE> database_filename = '{0:s}.db'.format(databas... | Writes the Windows Message Resource file.
Args:
event_log_provider (EventLogProvider): Event Log provider.
message_resource_file (MessageResourceFile): message resource file.
message_filename (str): message filename.
message_file_type (str): message file type. | 625941d8c432627299f04eb4 |
def hunt_choices(self, round_number, my_food, my_reputation, m, reps): <NEW_LINE> <INDENT> self.n_players.append(len(reps)) <NEW_LINE> self.g_rep.append(global_rep(reps)) <NEW_LINE> actions = [ 's' for r in reps ] <NEW_LINE> self.actions.append(actions) <NEW_LINE> return actions | Called to get our agent's decision on a new round.
round_number: integer, the number round you are in.
my_food: integer, the amount of food you have.
my_reputation: float (python's representation of real numbers), your
current reputation.
m: integer, the thres... | 625941d8e76e3b2f99f3aa74 |
def plot_highres_map_edgeon(self): <NEW_LINE> <INDENT> self.plot_heating_fraction_map(self.highres_frame_edgeon_interpolated, path=self.highres_map_edgeon_plot_path) | This function ...
:return: | 625941d8627d3e7fe0d690bd |
def get_edge_neighbors_by_coord(self, row, col): <NEW_LINE> <INDENT> cell = self.get_cell_by_grid_coords(row, col) <NEW_LINE> if cell is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> l = None <NEW_LINE> m = None <NEW_LINE> r = None <NEW_LINE> if cell.is_up(): <NEW_LINE> <INDENT> l ... | returned in a tuple of (left neighbor, middle neighbor, right neighbor) | 625941d8f548e778e58cd7eb |
def sniff(self, filename): <NEW_LINE> <INDENT> with open(filename, "r") as fio: <NEW_LINE> <INDENT> if not self.header_check(fio): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> for lcount, line in enumerate(fio): <NEW_LINE> <INDENT> if lcount > self.max_lines: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> ... | >>> classname = MarkerMap
>>> from galaxy.datatypes.sniff import get_test_fname
>>> extn_true = classname().file_ext
>>> file_true = get_test_fname("linkstudies." + extn_true)
>>> classname().sniff(file_true)
True
>>> false_files = list(LinkageStudies.test_files)
>>> false_files.remove("linkstudies." + extn_true)
>>> ... | 625941d8287bf620b61d3ccf |
def dms(self,dd): <NEW_LINE> <INDENT> dd = m.degrees(dd) <NEW_LINE> mnt,sec = divmod(dd*3600,60) <NEW_LINE> deg,mnt = divmod(mnt,60) <NEW_LINE> return deg,mnt,sec | Takes in angle in radians
returns andgle in degree, minute, second | 625941d8cdde0d52a9e532a1 |
def process_event(self, data): <NEW_LINE> <INDENT> do_publish_new_message = self.db.process_new_message(data) <NEW_LINE> if do_publish_new_message: <NEW_LINE> <INDENT> self.publish_event(('event', data)) <NEW_LINE> <DEDENT> for type_, event in self.db.generate_suppresed_events_for_source(data): <NEW_LINE> <INDENT> if e... | Processes the event aggregation.
Each event also triggers additional suppressed events based
on time of the given source. | 625941d86fece00bbac2d9ad |
def move_up(self): <NEW_LINE> <INDENT> if self.index > 0: <NEW_LINE> <INDENT> self.index -= 1 <NEW_LINE> if self.current_line_index == 0: <NEW_LINE> <INDENT> number_option_to_draw = self.drawer.get_max_y() - 3 <NEW_LINE> self.option_to_draw = self.options[self.index:self.index+number_option_to_draw] <NEW_LINE> <DEDENT>... | if it is not already on the first line move up
:return: | 625941d8f7d966606f6aa273 |
def test_multipolygons(self): <NEW_LINE> <INDENT> fromstr('POINT (0 0)') <NEW_LINE> for mp in self.geometries.multipolygons: <NEW_LINE> <INDENT> mpoly = fromstr(mp.wkt) <NEW_LINE> self.assertEqual(mpoly.geom_type, 'MultiPolygon') <NEW_LINE> self.assertEqual(mpoly.geom_typeid, 6) <NEW_LINE> self.assertEqual(mpoly.dims, ... | Testing MultiPolygon objects. | 625941d891f36d47f21ac761 |
def ask_is_top(self, name): <NEW_LINE> <INDENT> pass | Connect this at a higher level to test parenthood. | 625941d830bbd722463cc034 |
def test_subsequent_signup_with_language(db): <NEW_LINE> <INDENT> phone = '+13216430987' <NEW_LINE> signup = factories.TextSignupFactory.create( family__phone=phone, family__lang_code='en', state=model.TextSignup.STATE.done, student=factories.ProfileFactory.create(), ) <NEW_LINE> factories.RelationshipFactory.create( f... | A parent can update their language with their second code. | 625941d8442bda511e8be682 |
def redireccionar(direccion): <NEW_LINE> <INDENT> return HttpResponseRedirect(direccion) | Redirecciona a otra pagina web | 625941d8627d3e7fe0d690be |
@app.route('/square', methods=['POST']) <NEW_LINE> @requires_auth <NEW_LINE> def squareAPI(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> number = request.get_json()['number'] <NEW_LINE> number = float(number) <NEW_LINE> Result = squared(number) <NEW_LINE> Result = [{'Result':Result}] <NEW_LINE> print(Result) <NEW_LIN... | Example API call:
Curl:
curl -X POST -H "Content-Type: application/json" -u "user:pass" -d '{
"number": ".5"
}' http://localhost:8000/square
Python:
import requests
headers = {
'Content-Type': 'application/json',
}
data = '{"number": "5"}'
response = requests.p... | 625941d815baa723493c41e4 |
def increase(k_date): <NEW_LINE> <INDENT> k_date = datetime.strptime(k_date, "%Y/%m/%d") <NEW_LINE> dayOfWeek = k_date.isoweekday() <NEW_LINE> num = dayOfWeek + 7 <NEW_LINE> temp = [] <NEW_LINE> for i in range(num-1 ,-1 ,-1): <NEW_LINE> <INDENT> d = k_date + timedelta(days = -i) <NEW_LINE> keliu_data = str(d.date()).re... | :param k_date: 日期
:return: 三个列表,分别为本周7天、上周7天、本周与上周的客流增幅数据 | 625941d8d7e4931a7ee9e18a |
def have_some_units(*args): <NEW_LINE> <INDENT> for arg in args: <NEW_LINE> <INDENT> if isinstance(arg, UnitArray): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> return False | Returns True if any of the arguments have units attached to them.
This is a bit of a hack specifically for has_units and tied to the
conventions of convert_units(). | 625941d87b180e01f3dc4a66 |
def checkout(self, version): <NEW_LINE> <INDENT> LOG.info("Switching verifier repo to the '%s' version." % version) <NEW_LINE> utils.check_output(["git", "checkout", "master"], cwd=self.repo_dir) <NEW_LINE> utils.check_output(["git", "remote", "update"], cwd=self.repo_dir) <NEW_LINE> utils.check_output(["git", "pull"],... | Switch a verifier repo. | 625941d8fbf16365ca6f6433 |
def validateTestSuite(xmlOutput): <NEW_LINE> <INDENT> tree = ET.parse(xmlOutput) <NEW_LINE> root = tree.getroot() <NEW_LINE> testSuite = root[0] <NEW_LINE> testSuiteAttributes = testSuite.attrib <NEW_LINE> tests = testSuiteAttributes['tests'] <NEW_LINE> success = True <NEW_LINE> for testcase in testSuite: <NEW_LINE> <I... | Parse the output XML file to validate that all tests passed.
Assume that the XML file contains only one testsuite.
(which is true when generate by catch2) | 625941d892d797404e3043f7 |
def mainloop(self, *args, **kwargs): <NEW_LINE> <INDENT> self._received = time.strftime('%Y-%m-%d') <NEW_LINE> self.get_packets() <NEW_LINE> time.sleep(.05) | Overwrite this if you want to do stuff during the main program loop. | 625941d8e8904600ed9f219c |
def updateData(self): <NEW_LINE> <INDENT> ver_data = None <NEW_LINE> try: <NEW_LINE> <INDENT> ver_data = self._fetchURL(self.ver_url) <NEW_LINE> if os.path.exists(self.cache_file_name): <NEW_LINE> <INDENT> cache_file = open(self.cache_file_name,'rb') <NEW_LINE> data = pickle.load(cache_file) <NEW_LINE> if data['version... | Check whether data is out-of-date | 625941d8711fe17d825425d3 |
def testData74(self): <NEW_LINE> <INDENT> pass | Test Data74 | 625941d8b57a9660fec33af4 |
def nacm_cmd_exec_default(self, **kwargs): <NEW_LINE> <INDENT> config = ET.Element("config") <NEW_LINE> nacm = ET.SubElement(config, "nacm", xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm") <NEW_LINE> cmd_exec_default = ET.SubElement(nacm, "cmd-exec-default", xmlns="http://tail-f.com/yang/acm") <NEW_LINE> cmd_exec... | Auto Generated Code
| 625941d8e64d504609d74aad |
def domains_id_delete_with_http_info(self, id, **kwargs): <NEW_LINE> <INDENT> all_params = ['id'] <NEW_LINE> all_params.append('async_req') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE> all_params.append('_request_timeout') <NEW_LINE> params = locals(... | Remove a single domain # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.domains_id_delete_with_http_info(id, async_req=True)
>>> result = thread.get()
:param async_req bool
:param int id: (required)
:return: ApiRes... | 625941d80a50d4780f667101 |
def _https_referer_replace(self, request): <NEW_LINE> <INDENT> origin = request.META.get("HTTP_ORIGIN") <NEW_LINE> if ( request.is_secure() and origin and "ORIGINAL_HTTP_REFERER" not in request.META ): <NEW_LINE> <INDENT> url = urlparse(origin) <NEW_LINE> if not conf.CORS_ORIGIN_ALLOW_ALL and not self.origin_found_in_w... | When https is enabled, django CSRF checking includes referer checking
which breaks when using CORS. This function updates the HTTP_REFERER
header to make sure it matches HTTP_HOST, provided that our cors logic
succeeds | 625941d856ac1b37e6264439 |
def inline_button(self, callback_name: str): <NEW_LINE> <INDENT> def decorator(func): <NEW_LINE> <INDENT> self.inline_buttons[callback_name] = func <NEW_LINE> <DEDENT> LOGGER.debug("Added inline button \"%s\" to plugin %s", callback_name, self.name) <NEW_LINE> return decorator | Pass the text your callback name starts with | 625941d87047854f462a1674 |
def sqlcmd(server, database, command, username=None, password=None): <NEW_LINE> <INDENT> if not username or not password: <NEW_LINE> <INDENT> auth = ['-E'] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> auth = ['-U', username, '-P', password] <NEW_LINE> <DEDENT> command = 'set nocount on;' + command <NEW_LINE> sqlcmd_co... | Runs the input command against the database and returns the output if it
is a table.
Leave username and password to None if you intend to use
Kerberos integrated authentication
:param server: SQL Server
:type server: str
:param database: Name of the default database for the script
:type database: str
:param command: S... | 625941d8bde94217f368305c |
def insert(intervals, new_interval): <NEW_LINE> <INDENT> return mergeOverlapping(intervals + [new_interval]) | Insert new_interval into intervals and merge the results if possible. Original intervals are not modified afterwards.
Args:
intervals (list): A list of intervals to be inserted.
new_intervals (Interval): New interval to insert.
Returns:
list: Resulting list of intervals sorted by their lower bounds.
Exam... | 625941d8b830903b967e9b76 |
def output(t, x, y, z, vx, vy, vz): <NEW_LINE> <INDENT> f = open('baseball.out', 'w') <NEW_LINE> for i in range(len(t)): <NEW_LINE> <INDENT> f.write(str(t[i])+', '+str(x[i])+', '+str(y[i])+', '+str(z[i])+','+str(vx[i])+', '+str(vy[i])+', '+str(vz[i])+'\n') <NEW_LINE> <DEDENT> f.close() | Output results to a file. | 625941d8b7558d58953c517e |
def missing(self, installed=False): <NEW_LINE> <INDENT> packages = set() <NEW_LINE> for lang in self.available_languages(): <NEW_LINE> <INDENT> packages.update(self.by_locale(lang, installed)) <NEW_LINE> <DEDENT> return packages | Get language support packages for current system.
Return all packages which need to be installed in order to provide
language support all system locales for all already installed
packages. This should be called after installing the system without
language support packages (perhaps because there was no network
availabl... | 625941d8cb5e8a47e48b7d14 |
def numberOfSteps (self, num): <NEW_LINE> <INDENT> steps = 0 <NEW_LINE> while num != 0: <NEW_LINE> <INDENT> if num % 2 == 0: <NEW_LINE> <INDENT> num /= 2 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> num -= 1 <NEW_LINE> <DEDENT> steps += 1 <NEW_LINE> <DEDENT> return steps | :type num: int
:rtype: int | 625941d850485f2cf553d008 |
@csrf_exempt <NEW_LINE> @login_required <NEW_LINE> def menu_dish_rate(request): <NEW_LINE> <INDENT> data = {} <NEW_LINE> u = request.user <NEW_LINE> return JSONHttpResponse(data) | Returns the top menu of a location if the location is a
valid eating place
:url: /m/menu/dish/rate/
:param POST['dish_id']: The dish id
:param POST['thumbs']: 1 for thumbs up, -1 for thumbs down,
thumbs up or down indicating quick review or recommendation
:param POST['lat']:
:param POST['lon']: | 625941d84c3428357757c594 |
def snapshot_XYZ(N, x0, dx): <NEW_LINE> <INDENT> X = np.array([x0[0] + dx[0] * i for i in range(N[0])]) <NEW_LINE> Y = np.array([x0[1] + dx[1] * i for i in range(N[1])]) <NEW_LINE> Z = np.array([x0[2] + dx[2] * i for i in range(N[2])]) <NEW_LINE> return X, Y, Z | Creates the X, Y and Z axis arrays from the output parameters from read_snapshot_params().
X = arange(x0[0], x0[0]+dx[0]*N[0], dx[0])
Y = arange(x0[1], x0[1]+dx[1]*N[1], dx[1])
Z = arange(x0[2], x0[2]+dx[2]*N[2], dx[2])
Inputs
------
N: tuple, np.array
(Nx, Ny, Nz) number of elements along each axis.
x0: tuple, n... | 625941d8d53ae8145f87a4d9 |
def test_qr_library_equivalence(self): <NEW_LINE> <INDENT> macro_qr = MacroQRCode() <NEW_LINE> macro_qr.add_data('uQR rocks!') <NEW_LINE> macro_matrix = macro_qr.get_matrix() <NEW_LINE> micro_qr = MicroQRCode() <NEW_LINE> micro_qr.add_data('uQR rocks!') <NEW_LINE> micro_matrix = micro_qr.get_matrix() <NEW_LINE> self.as... | The `get_matrix` method of the uQR library should produce
identical output to that of the QRCode library. | 625941d8091ae356686671c8 |
def alphorder(s): <NEW_LINE> <INDENT> f = [(a <= b, a >= b) for a,b in zip(s,s[1:])] <NEW_LINE> return inOrder if all(g[0] for g in f) else revOrder if all(g[1] for g in f) else noOrder | Create tuple list with single list comprehension. | 625941d821bff66bcd684bbe |
def test_get_compensation_details(self): <NEW_LINE> <INDENT> obj = None <NEW_LINE> try: <NEW_LINE> <INDENT> obj = self.init.get_compensation_details("1337") <NEW_LINE> <DEDENT> except ShibaParameterError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> self.assertIsNone(obj) | get_compensation_details test, must fail | 625941d8d53ae8145f87a4da |
def attack(atk_pkmn, def_pkmn): <NEW_LINE> <INDENT> move_no = move_select(atk_pkmn) <NEW_LINE> selected_move = atk_pkmn.moves[move_no - 1] <NEW_LINE> if isinstance(selected_move, moves.Move): <NEW_LINE> <INDENT> damage_formula_num = ( ((((2 * atk_pkmn.level) / 5) + 2) * selected_move.power) * (atk_pkmn.attack / def_pkm... | Function which allows one Pokémon to attack another. | 625941d832920d7e50b2843f |
def copy_log_to_local(self, device): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with SCP(device) as scp: <NEW_LINE> <INDENT> scp.get(self.remote_file_path, self.local_file_path) <NEW_LINE> <DEDENT> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> logger.exception(e) <NEW_LINE> raise | Copies a remote file to the local device via SCP | 625941d8b545ff76a8914082 |
def main(global_config, **settings): <NEW_LINE> <INDENT> if 'DATABASE_URL' in os.environ: <NEW_LINE> <INDENT> settings['sqlalchemy.url'] = os.environ['DATABASE_URL'] <NEW_LINE> <DEDENT> engine = engine_from_config(settings, 'sqlalchemy.') <NEW_LINE> DBSession.configure(bind=engine) <NEW_LINE> Base.metadata.bind = engin... | This function returns a Pyramid WSGI application.
| 625941d844b2445a33932302 |
def invert(A): <NEW_LINE> <INDENT> rows, cols = len(A), len(A[0]) <NEW_LINE> identity = [[float(i == j) for i in range(cols)] for j in range(rows)] <NEW_LINE> X = [A[i] + identity[i] for i in range(rows)] <NEW_LINE> for n in range(cols): <NEW_LINE> <INDENT> is_zeros, first_non_zero = check_for_all_zeros(X, n) <NEW_LINE... | invert a square matrix A according to gauss-jordan elimination | 625941d873bcbd0ca4b2c2e3 |
def update_items(lib, query, album, move, pretend): <NEW_LINE> <INDENT> with lib.transaction(): <NEW_LINE> <INDENT> items, _ = _do_query(lib, query, album) <NEW_LINE> affected_albums = set() <NEW_LINE> for item in items: <NEW_LINE> <INDENT> if not os.path.exists(syspath(item.path)): <NEW_LINE> <INDENT> ui.print_(format... | For all the items matched by the query, update the library to
reflect the item's embedded tags. | 625941d84527f215b584c6c2 |
def predict( self, overwrite_predictions=False, predict_on_train=False, verbose=False ): <NEW_LINE> <INDENT> raise NotImplementedError( "Predicting from saved fitted strategies is not implemented yet" ) | Predict from saved fitted strategies. | 625941d8566aa707497f47d3 |
def config_subset_tostring(self): <NEW_LINE> <INDENT> root = copy.deepcopy(self).getroot() <NEW_LINE> for child in list(root): <NEW_LINE> <INDENT> if child.tag not in ('pipelines', 'templates', 'environments'): <NEW_LINE> <INDENT> root.remove(child) <NEW_LINE> <DEDENT> <DEDENT> self.indent(root) <NEW_LINE> return Eleme... | See GoProxy.set_test_settings_xml() | 625941d8d268445f265b50dc |
def gradients(train, item_features, user_features, nz_train, lambda_user=0, lambda_item=0): <NEW_LINE> <INDENT> D = item_features.shape[1] <NEW_LINE> N = user_features.shape[1] <NEW_LINE> num_features = item_features.shape[0] <NEW_LINE> X = np.dot(item_features.T, user_features) <NEW_LINE> grad_item = np.zeros((D, num_... | compute gradient for SGD.
input: train -data matrix (D x N)
item_features -movie features matrix (K x D)
user_features -user features matrix (K x N)
nz_train -list of nonzero indices in train
lambda_user -regularization parameter for users
lambda... | 625941d8d10714528d5fff53 |
def setup_databases(self, **kwargs): <NEW_LINE> <INDENT> old_names, mirrors = super(TestRunner, self).setup_databases(**kwargs) <NEW_LINE> cursor = connection.cursor() <NEW_LINE> cursor.execute("CREATE EXTENSION IF NOT EXISTS hstore;") <NEW_LINE> return old_names, mirrors | Override the setup to install some extensions
:param kwargs:
:return: | 625941d8656771135c3ebade |
def __next__(self): <NEW_LINE> <INDENT> if self.next is None: <NEW_LINE> <INDENT> raise StopIteration <NEW_LINE> <DEDENT> to_return = self.next <NEW_LINE> self.next = self.next.next <NEW_LINE> return to_return | Return next item in linked list. | 625941d84e4d5625662d4643 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.