code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def index(request): <NEW_LINE> <INDENT> logger.debug(request) <NEW_LINE> link_latest_list = Link.objects.order_by('-updated_at').all() <NEW_LINE> context = {'link_latest_list': link_latest_list} <NEW_LINE> return render(request, "link/index.html", context, status=200) | view link's list page | 625941bc92d797404e304056 |
def test_api__get_workspaces__ok_200__nominal_case(self): <NEW_LINE> <INDENT> dbsession = get_tm_session(self.session_factory, transaction.manager) <NEW_LINE> admin = dbsession.query(models.User) .filter(models.User.email == '[email protected]') .one() <NEW_LINE> workspace_api = WorkspaceApi( sess... | Check obtain all workspaces reachables for user with user auth. | 625941bcfff4ab517eb2f307 |
@curry <NEW_LINE> def get_by_uuid(uuid, path='.'): <NEW_LINE> <INDENT> return pipe( path, dtr.discover, list, filter(lambda x: uuid in x.uuid), list, get(0, default=None) ) | Get a Treant by short ID
Args:
uuid: a portion of the uuid
path: the search path for Treants
Returns:
a Treant | 625941bc711fe17d8254223e |
def test_binary_small(self): <NEW_LINE> <INDENT> input_data = "101b" <NEW_LINE> exp_data = 0b101 <NEW_LINE> exp_tokens = [ self.lex_token('binaryValue', exp_data, 1, 0), ] <NEW_LINE> self.run_assert_lexer(input_data, exp_tokens) | Test a small binary number. | 625941bc3539df3088e2e218 |
def client_status(self, mac): <NEW_LINE> <INDENT> for client in self._client(SERVER_GETSTATUS, mac)['clients']: <NEW_LINE> <INDENT> if client.get('host').get('mac') == mac: <NEW_LINE> <INDENT> return client <NEW_LINE> <DEDENT> <DEDENT> raise ValueError('No client at given mac') | Client status.
'System.GetStatus' with a 'client' parameter
should probably just return the client record,
but instead we get a full system status, so we
have to extract just the relevant client record. | 625941bc56ac1b37e62640a2 |
def _text_set ( self ): <NEW_LINE> <INDENT> self._refresh() | Handles the 'text' facet being changed.
| 625941bcbf627c535bc130a3 |
def __ne__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, TextAvailableSource): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return self.to_dict() != other.to_dict() | Returns true if both objects are not equal | 625941bc15baa723493c3e40 |
def initialize(self, *args, **kwargs): <NEW_LINE> <INDENT> app = QApplication.instance() <NEW_LINE> if app is None: <NEW_LINE> <INDENT> if not args: <NEW_LINE> <INDENT> args = ([''],) <NEW_LINE> <DEDENT> app = QApplication(*args, **kwargs) <NEW_LINE> <DEDENT> self._qt_app = app | Initializes the underlying QApplication object. It does
*not* start the event loop. If the application object is already
created, it is a no-op. | 625941bc30c21e258bdfa369 |
def __init__(self, vertices=None, edges=None, adjacency_matrix=None): <NEW_LINE> <INDENT> super(WeightedDigraph).__init__(vertices, edges, adjacency_matrix) <NEW_LINE> self._vertices = None <NEW_LINE> self._edges = None <NEW_LINE> self._adjacency_matrix = None <NEW_LINE> self.vertices = vertices <NEW_LINE> self.edges =... | Constructor
:param vertices: Set of vertices
:param edges: Set of tuple entries (vertex1, vertex2, weight)
:param adjacency_matrix:
:type vertices: set(Vertex)
:type edges: set(Weighted | 625941bcfbf16365ca6f608b |
def target_sound_quality(target, distortion_factor_target=0.2, distortion_factor_noise=0.99, lowpass_cutoff_target=3500, lowpass_cutoff_noise=3500, num_points=2048, window_type='hann', sample_rate=None): <NEW_LINE> <INDENT> if not isinstance(target, audio.Wave): <NEW_LINE> <INDENT> target = audio.Wave(target, sample_ra... | Generates a target sound quality anchor, defined as the sum of the
distorted target and an artefacts signal, both equally loud.
Default parameters based on [3].
Parameters
----------
target : np.ndarray or Wave, shape=(num_samples, num_channels)
The true target source.
distortion_factor_target : float, optional
... | 625941bc4a966d76dd550eda |
def onClick(self, layer, pos5d, pos): <NEW_LINE> <INDENT> label = self.editor.brushingModel.drawnNumber <NEW_LINE> if label == self.editor.brushingModel.erasingNumber: <NEW_LINE> <INDENT> label = 0 <NEW_LINE> <DEDENT> topLevelOp = self.topLevelOperatorView.viewed_operator() <NEW_LINE> imageIndex = topLevelOp.LabelInput... | Extracts the object index that was clicked on and updates
that object's label. | 625941bc63d6d428bbe443bd |
@tf_export('profiler.experimental.client.monitor', v1=[]) <NEW_LINE> def monitor(service_addr, duration_ms, level=1): <NEW_LINE> <INDENT> return _pywrap_profiler.monitor( _strip_prefix(service_addr, _GRPC_PREFIX), duration_ms, level, True) | Sends grpc requests to profiler server to perform on-demand monitoring.
The monitoring result is a light weight performance summary of your model
execution. This method will block the caller thread until it receives the
monitoring result. This method currently supports Cloud TPU only.
Args:
service_addr: gRPC addre... | 625941bc498bea3a759b997e |
def list_tab(user): <NEW_LINE> <INDENT> data = raw_cron(user) <NEW_LINE> ret = {'crons': [], 'special': []} <NEW_LINE> for line in data.split('\n'): <NEW_LINE> <INDENT> if line.startswith('@'): <NEW_LINE> <INDENT> dat = {} <NEW_LINE> comps = line.split() <NEW_LINE> if len(comps) < 2: <NEW_LINE> <INDENT> continue <NEW_L... | Return the contents of the specified user's crontab
CLI Example:
salt '*' cron.list_tab root | 625941bc26068e7796caeba7 |
def _gap_init_(self): <NEW_LINE> <INDENT> if not self.is_absolute(): <NEW_LINE> <INDENT> raise NotImplementedError("Currently, only simple algebraic extensions are implemented in gap") <NEW_LINE> <DEDENT> G = sage.interfaces.gap.gap <NEW_LINE> q = self.polynomial() <NEW_LINE> if q.variable_name()!='E': <NEW_LINE> <INDE... | Create a gap object representing self and return its name
EXAMPLE::
sage: z = QQ['z'].0
sage: K.<zeta> = NumberField(z^2 - 2)
sage: K._gap_init_() # the following variable name $sage1 represents the F.base_ring() in gap and is somehow random
'CallFuncList(function() local z,E; z:=Indeterminate($sage1,... | 625941bcfb3f5b602dac355e |
def decode_spike(cam_res, key): <NEW_LINE> <INDENT> data_shift = np.uint8(np.log2(cam_res)) <NEW_LINE> col = key >> (data_shift + 1) <NEW_LINE> row = (key >> 1) & ((0b1 << data_shift) -1) <NEW_LINE> polarity = key & 1 <NEW_LINE> return row, col, polarity | Decode DVS emulator output | 625941bc5fdd1c0f98dc00ff |
def can_run_now(self): <NEW_LINE> <INDENT> for preq in self.prerequisites: <NEW_LINE> <INDENT> if preq.is_done(): <NEW_LINE> <INDENT> if preq.was_invalidated and not preq.was_run and not preq.is_loadable(): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> elif preq._pruned: <NEW_LINE> <INDENT> pass <NEW_LI... | Can this job run right now? | 625941bcaad79263cf39090a |
def discounnect(self): <NEW_LINE> <INDENT> self.connection.close() | Close connection ton APNS server | 625941bc2ae34c7f2600cfff |
def update(self, dets): <NEW_LINE> <INDENT> self.frame_count += 1 <NEW_LINE> trks = np.zeros((len(self.trackers), 5)) <NEW_LINE> to_del = [] <NEW_LINE> ret = [] <NEW_LINE> for t, trk in enumerate(trks): <NEW_LINE> <INDENT> pos = self.trackers[t].predict()[0] <NEW_LINE> trk[:] = [pos[0], pos[1], pos[2], pos[3], 0] <NEW_... | Params:
dets - a numpy array of detections in the format [[x1,y1,x2,y2,score],[x1,y1,x2,y2,score],...]
Requires: this method must be called once for each frame even with empty detections.
Returns the a similar array, where the last column is the object ID.
NOTE: The number of objects returned may differ from the num... | 625941bc45492302aab5e18e |
def createDatabase(self): <NEW_LINE> <INDENT> conn=self.connectMysql() <NEW_LINE> print("1212121"+self.db) <NEW_LINE> sql="create database if not exists "+self.db <NEW_LINE> cur=conn.cursor() <NEW_LINE> cur.execute(sql) <NEW_LINE> cur.close() <NEW_LINE> conn.close() | 因为创建数据库直接修改settings中的配置MYSQL_DBNAME即可,所以就不要传sql语句了 | 625941bc07f4c71912b11355 |
def MsgPop(self): <NEW_LINE> <INDENT> if (self.msgIndentLevel>0): self.msgIndentLevel -= 1 | Decrement the message-nesting level (see ''MsgPush'').
| 625941bc9f2886367277a75e |
def feature_layer(cfg): <NEW_LINE> <INDENT> layers = [] <NEW_LINE> for i in range(len(cfg)): <NEW_LINE> <INDENT> layers.append([]) <NEW_LINE> for j in range(len(cfg[i]) - 1): <NEW_LINE> <INDENT> layers[i].append(nn.Conv1d(cfg[i][j], cfg[i][j+1], kernel_size=3, stride = (2, 1)[i % 2== 1], padding =1)) <NEW_LINE> <DEDENT... | Args:
cfg:输入的配置文件
Returns:
特征提取网络 | 625941bc4d74a7450ccd4090 |
def test_post_request_viewed(self): <NEW_LINE> <INDENT> self.create_request_data() <NEW_LINE> self.client.post( '/requests/requestsData/', {'data': json.dumps([{'request_id': 1, 'viewed': False}, {'request_id': 2, 'viewed': True}])}, HTTP_X_REQUESTED_WITH='XMLHttpRequest', ) <NEW_LINE> self.assertEqual(RequestData.obje... | Checked post requests data
:return: | 625941bc73bcbd0ca4b2bf4b |
def handle(self, args): <NEW_LINE> <INDENT> from lifoid.config import settings <NEW_LINE> try: <NEW_LINE> <INDENT> app_settings_module = import_module( settings.lifoid_settings_module ) <NEW_LINE> <DEDENT> except ModuleNotFoundError: <NEW_LINE> <INDENT> color.format("No settings module found. Have you initialized your ... | CLI to run the lifoid HTTP API server application. | 625941bc92d797404e304057 |
def grando_transform_shift(image, shift): <NEW_LINE> <INDENT> return scipy.ndimage.shift(image, shift) | input: macierz (ndarray), shift (float) odpowiedzialny jest za jednakowe przesunięcie figury wzdłoż osi OX i OY;
output: macierz (ndarray) | 625941bce1aae11d1e749b82 |
def parse_tuple( self, simplified=False, with_condexpr=True, extra_end_rules=None, explicit_parentheses=False, ): <NEW_LINE> <INDENT> lineno = self.stream.current.lineno <NEW_LINE> if simplified: <NEW_LINE> <INDENT> parse = self.parse_primary <NEW_LINE> <DEDENT> elif with_condexpr: <NEW_LINE> <INDENT> parse = self.pars... | Works like `parse_expression` but if multiple expressions are
delimited by a comma a :class:`~jinja2.nodes.Tuple` node is created.
This method could also return a regular expression instead of a tuple
if no commas where found.
The default parsing mode is a full tuple. If `simplified` is `True`
only names and literals... | 625941bc32920d7e50b2809b |
def _get_affinity_matrix(self, X, Y=None): <NEW_LINE> <INDENT> if self.affinity == 'precomputed': <NEW_LINE> <INDENT> self.affinity_matrix_ = X <NEW_LINE> return self.affinity_matrix_ <NEW_LINE> <DEDENT> if self.affinity == 'nearest_neighbors': <NEW_LINE> <INDENT> if sparse.issparse(X): <NEW_LINE> <INDENT> warnings.war... | Calculate the affinity matrix from data
Parameters
----------
X : array-like, shape (n_samples, n_features)
Training vector, where n_samples is the number of samples
and n_features is the number of features.
If affinity is "precomputed"
X : array-like, shape (n_samples, n_samples),
Interpret X as p... | 625941bc099cdd3c635f0b2a |
def test_parser_output_input(): <NEW_LINE> <INDENT> inputfile = 'inputfile' <NEW_LINE> outputfile = 'outputfile' <NEW_LINE> args = standardcitations.parse_args(['-o', outputfile, '-i', inputfile]) <NEW_LINE> assert args.input == inputfile <NEW_LINE> assert args.output == outputfile <NEW_LINE> assert not args.xelatex | Assert that the input and output filenames are read correctly,
when the order is flipped and that the XeLaTeX flag is not set. | 625941bc4f6381625f11490b |
def GetCommandLineFiles(command_line_file_list, recursive): <NEW_LINE> <INDENT> return _FindFiles(command_line_file_list, recursive) | Return the list of files specified on the command line. | 625941bc7d847024c06be187 |
def save_occurs(self,outfile,format='mm'): <NEW_LINE> <INDENT> if format == 'mm': <NEW_LINE> <INDENT> mmwrite(outfile,self.occurs) <NEW_LINE> <DEDENT> elif format == 'graphlab': <NEW_LINE> <INDENT> f = open(outfile,'w') <NEW_LINE> occurs = self.occurs.tocoo() <NEW_LINE> for i in range(occurs.row.shape[0]): <NEW_LINE> <... | save the occurs to disk | 625941bc6fece00bbac2d60a |
def public_ticker(self, market_symbol): <NEW_LINE> <INDENT> return self.get(f'markets/{market_symbol}/ticker') | Get the current tick values for a market.
Args:
market_symbol (str):
String literal (ie. BTC-LTC).
Returns:
list
.. seealso:: https://bittrex.github.io/api/v3#/definitions/Ticker | 625941bc8a43f66fc4b53f36 |
def private_task(job_id): <NEW_LINE> <INDENT> if job_id == 'register': <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> job = qdb.processing_job.ProcessingJob(job_id) <NEW_LINE> job.update_heartbeat_state() <NEW_LINE> task_name = job.command.name <NEW_LINE> try: <NEW_LINE> <INDENT> TASK_DICT[task_name](job) <NEW_LINE> <D... | Completes a Qiita private task
Parameters
----------
job_id : str
The job id | 625941bc293b9510aa2c3167 |
def find_sums(self,lst_sqrs,x_arr,y_arr,sigmas,fit_type): <NEW_LINE> <INDENT> sigma_nonzero = np.nonzero(sigmas) <NEW_LINE> x_arr = x_arr[sigma_nonzero] <NEW_LINE> y_arr = y_arr[sigma_nonzero] <NEW_LINE> sigmas = sigmas[sigma_nonzero] <NEW_LINE> sigma_2 = sigmas**2 <NEW_LINE> if fit_type == 'linear': <NEW_LINE> <INDENT... | Computes the sums needed for linear least squares equations
:param lst_sqrs: LeastSquaresValues object to fill
:param x_arr: array with x-axis data
:param y_arr: array with y-axis data
:param sigmas: weighting for y-axis data
:param fit_type: selects between 'linear' and 'quadratic' fits | 625941bc187af65679ca4fec |
def obj(*components): <NEW_LINE> <INDENT> return build('obj/', *components) | Given components for a project source path relative to `B8_PROJDIR`,
return the corresponding object path, which is the same path under
``.build/obj/``. | 625941bc2ae34c7f2600d000 |
def apply_mechanisms(self, cell): <NEW_LINE> <INDENT> modified = False <NEW_LINE> for i in range(len(self.mechanisms)): <NEW_LINE> <INDENT> modified = True <NEW_LINE> if self.mechanisms[i] == "imprinting": <NEW_LINE> <INDENT> self.imprinting_mechanism(cell, self.epi_probs[i]) <NEW_LINE> <DEDENT> elif self.mechanisms[i]... | This function applies the epigenetic mechanisms to a given cell
with some probability.
Already implemented mechanisms:
- ...
Possible future implemented mechanisms:
- "imprinting"
- "reprogramming"
- "paramutation"
- "position"
- "inactivation"
- "bookmarking"
- "silencing"
Inputs:
-... | 625941bca8ecb033257d2fa4 |
def __init__(self, fee, _error_use_class_method=True): <NEW_LINE> <INDENT> if _error_use_class_method: <NEW_LINE> <INDENT> raise TypeError("Please use SecondSignature.generate(args) or SecondSignature.from_dict(args) to construct me.") <NEW_LINE> <DEDENT> super().__init__(TRANSACTION_TYPE.SECOND_SIGNATURE, fee) | Creates a Second Signature transaction
:param fee: fee for transaction
:param _error_use_class_method: boolean flag, used to indicate if the transaction
was created from generate or from_dict | 625941bccb5e8a47e48b797c |
@app.task(base=CollectionDunyaTask) <NEW_LINE> def load_musicbrainz_collection(collectionid): <NEW_LINE> <INDENT> coll = models.Collection.objects.get(collectionid=collectionid) <NEW_LINE> coll.set_state_scanning() <NEW_LINE> coll.add_log_message("Starting collection scan") <NEW_LINE> update_collection(collectionid) <N... | Load a musicbrainz collection into the dashboard database
and scan collection root to match directories to releases. | 625941bc7cff6e4e81117854 |
def onConnect(self): <NEW_LINE> <INDENT> print('onConnect') | 连接回调 | 625941bc4c3428357757c1f8 |
def bootstrap_pair_counts(self, N_trials): <NEW_LINE> <INDENT> Nfld = self.N_fields <NEW_LINE> resample = np.random.randint( 0, Nfld, N_trials*Nfld ).reshape(N_trials, Nfld) <NEW_LINE> hists = np.apply_along_axis(np.bincount, 1, resample, minlength=Nfld) <NEW_LINE> matrix = lambda x: np.multiply(*np.meshgrid(x, x)) <NE... | Perform bootstrap resampling on the results, and return the
estimator value.
Parameters
----------
N_trials (int): The number of resamples to perform.
Returns
-------
A 2D numpy array of shape (R, N_trials) where R is the number of radii
bins, i.e. the number of radii values minus one. | 625941bc21bff66bcd684823 |
def analyse_maps(self): <NEW_LINE> <INDENT> log.info("Analysing the maps ...") | This function ...
:return: | 625941bcd53ae8145f87a143 |
def scale_ma(ori_score=0, pro_score=0, pro_score_add_k=0): <NEW_LINE> <INDENT> temp_t = [11, 13, 21, 22, 59, 64, 73, 97, 100, 109, 127, 134, 143, 156, 157, 167, 181, 194, 212, 222, 226, 228, 232, 233, 238, 240, 250, 251, 263, 266, 268, 271, 277, 279, 298] <NEW_LINE> temp_f = [101, 105, 111, 119, 120, 148, 166, 171, 180... | 临床量表-9 轻躁狂 Ma
the score of Ma (hypomania) scale
:param ori_score: original score
:param pro_score: processing score
:param pro_score_add_k: processing score added 0.2K
:return: ori_score, pro_score, pro_score_add_k
:rtype: int, int, int | 625941bc0c0af96317bb80b7 |
def do_lock(verbose=False): <NEW_LINE> <INDENT> click.echo(crayons.yellow('Locking {0} dependencies...'.format( crayons.red('[dev-packages]')) ), err=True) <NEW_LINE> lockfile = project._lockfile <NEW_LINE> for section in ('default', 'develop'): <NEW_LINE> <INDENT> for k, v in lockfile[section].copy().items(): <NEW_LIN... | Executes the freeze functionality. | 625941bc8a43f66fc4b53f37 |
def start_oekaki(self): <NEW_LINE> <INDENT> self.start = True | お絵描きをスタートします。
Start oekaki. | 625941bcec188e330fd5a673 |
def __init__(self, n_actions, hidden=1024, learning_rate=0.00001, frame_height=84, frame_width=84, agent_history_length=4): <NEW_LINE> <INDENT> self.n_actions = n_actions <NEW_LINE> self.hidden = hidden <NEW_LINE> self.learning_rate = learning_rate <NEW_LINE> self.frame_height = frame_height <NEW_LINE> self.frame_width... | Args:
n_actions: Integer, number of possible actions
hidden: Integer, Number of filters in the final convolutional layer.
This is different from the DeepMind implementation
learning_rate: Float, Learning rate for the Adam optimizer
frame_height: Integer, Height of a frame of an Atari game
... | 625941bc5f7d997b8717496a |
def test_meal_post_incorrect_params(self): <NEW_LINE> <INDENT> count = Meal.objects.all().count() <NEW_LINE> response = self.client.post(reverse('meal'), {'meal_type_id': 'kanapka'}) <NEW_LINE> assert response.status_code == 400 <NEW_LINE> assert count == Meal.objects.all().count() <NEW_LINE> assert response.json() == ... | Testing POST meal view with incorrect params | 625941bc0a366e3fb873e6e6 |
def mark_as_hit(self): <NEW_LINE> <INDENT> self.char = 'X' <NEW_LINE> self.was_shot = True | Method to mark obj on board as hit by changing char attribute | 625941bc925a0f43d2549d43 |
def export(filename): <NEW_LINE> <INDENT> tree = lxml.etree.parse(open(filename, encoding='utf=8')) <NEW_LINE> print('<dl>') <NEW_LINE> for template in tree.findall('.//template'): <NEW_LINE> <INDENT> print('<dt>%s</dt>' % (html.escape(template.get('name')))) <NEW_LINE> print('<dd>%s\n<pre class="prettyprint">%s\n</pre... | https://github.com/hoffmann/PyCharm-Python-Templates | 625941bc5fcc89381b1e158b |
def log_likelihood(self): <NEW_LINE> <INDENT> if self._log_likelihood is None: <NEW_LINE> <INDENT> self._log_likelihood = logpdf(x=self.y, cov=self.S) <NEW_LINE> <DEDENT> return self._log_likelihood | log-likelihood of the last measurement. | 625941bca934411ee3751569 |
def execute(self): <NEW_LINE> <INDENT> stories = self.pt.get_backlog(self.project) <NEW_LINE> output = StringIO() <NEW_LINE> for story in stories: <NEW_LINE> <INDENT> if story.state in [Story.STATE_UNSCHEDULED, Story.STATE_UNSTARTED] and (self.namespace.mywork is False or self.owner in story.owners): <NEW_LINE> <INDENT... | Execute this backlog command.
| 625941bcdc8b845886cb5402 |
def parse_args(): <NEW_LINE> <INDENT> parser = argparse.ArgumentParser(description='Tensorflow Faster R-CNN demo') <NEW_LINE> parser.add_argument('--train_proto','-tp', dest='train_proto',type=str, help='JPEGImages path to read', default='None') <NEW_LINE> parser.add_argument('--train_model','-tm', dest='train_model',t... | Parse input arguments. | 625941bc1f037a2d8b9460cd |
def getNumberOfTuples(self, *args): <NEW_LINE> <INDENT> return _MEDCalculator.MEDCouplingFieldDiscretizationP0_getNumberOfTuples(self, *args) | getNumberOfTuples(self, MEDCouplingMesh mesh) -> int
1 | 625941bc7d43ff24873a2b6c |
def getDefaultValue(self): <NEW_LINE> <INDENT> pass | Returns the media storage property's default value. | 625941bc9b70327d1c4e0ca2 |
def get_token_summary(tok): <NEW_LINE> <INDENT> return '('+str(tok.pos)+')' + tok.type + '_' | Diese Funktion gibt für ein Token einen formatieren String aus.:
Der ausgebene String hat folgende Form:
::
(pos)TokenType_
Diese Art String wird von der Klasse :class:`~MethodSearch`
vorrausgesetzt.
Args:
tok ([Token]): Das Token welches abgefragt werden soll
Returns:
[String]: String der Form :code:`(po... | 625941bc3c8af77a43ae366c |
def test_clear_user_api_key(self): <NEW_LINE> <INDENT> user = self.login() <NEW_LINE> user.generate_api_key() <NEW_LINE> user.save() <NEW_LINE> self.assertIsNotNone(user.apikey) <NEW_LINE> response = self.post(url_for('users.apikey_settings', user=self.user), {'action': 'clear'}) <NEW_LINE> self.assert200(response) <NE... | It should clear the API Key | 625941bc7d847024c06be188 |
def isValidSerialization(self, preorder): <NEW_LINE> <INDENT> stack = [] <NEW_LINE> index = -1 <NEW_LINE> preorder = preorder.split(",") <NEW_LINE> for s in preorder: <NEW_LINE> <INDENT> stack.append(s) <NEW_LINE> index += 1 <NEW_LINE> while self.endsWithTwoPoundSign(stack, index): <NEW_LINE> <INDENT> stack.pop() <NEW_... | :type preorder: str
:rtype: bool | 625941bc76e4537e8c351546 |
def scale_spreading_data(data, tau=1., R=1.): <NEW_LINE> <INDENT> def scale_series(view, tau, R): <NEW_LINE> <INDENT> new = view().copy() <NEW_LINE> new.index /= tau <NEW_LINE> new /= R <NEW_LINE> return new <NEW_LINE> <DEDENT> view = [d.view for d in data] <NEW_LINE> try: <NEW_LINE> <INDENT> bc = np.broadcast(view, ta... | Scale spreading times and radii.
The data is scaled by dividing with the input factors, ie. t* = t/tau
where t is the non-scaled times, tau the scaling factor and t* the
scaled times of the returned data.
Input scaling factors are broadcasted to the data. This means that
the input factors must be either a single fact... | 625941bcfbf16365ca6f608c |
def err( self, msg ): <NEW_LINE> <INDENT> if self.lock: <NEW_LINE> <INDENT> self.DispLock.acquire() <NEW_LINE> <DEDENT> self.set_color( 'Red' ) <NEW_LINE> sys.stderr.write( "ERROR: " + msg ) <NEW_LINE> sys.stderr.flush() <NEW_LINE> self.set_color( 'SwitchOffAttributes' ) <NEW_LINE> if self.lock: <NEW_LINE> <INDENT> sel... | Print messages with an error. If locking is available use them. | 625941bcd6c5a10208143f17 |
def send_and_receive(self, receiver, message: bytes) -> bytes: <NEW_LINE> <INDENT> key = DHEntity.session_key_to_16_aes_bytes( self._session_key ) <NEW_LINE> ciphertext, iv = matasano.blocks.aes_cbc( key=key, b=message, random_iv=True ) <NEW_LINE> ciphertext = receiver.receive_and_send_back(ciphertext + iv) <NEW_LINE> ... | Send an encrypted message as follows:
- key = SHA1(session_key)[:16]
- iv = random IV
- message
send: AES_CBC(message) || iv
:param receiver: The receiver.
:param message: The message to be sent.
:return: The received answer (if any). | 625941bc507cdc57c6306ba3 |
def get_sharpe( nav_data, benchmark_nav_data, risk_free_rate=None, window=250 * 3, annualiser=250, tail=True, ): <NEW_LINE> <INDENT> nav_dataframe = _transform_df(nav_data) <NEW_LINE> benchmark_nav_dataframe = _transform_df(benchmark_nav_data) <NEW_LINE> df = RatioCalculator( nav_dataframe, benchmark_nav_dataframe=benc... | The Sharpe ratio was developed by Nobel laureate William F. Sharpe and is used to help
investors understand the return of an investment compared to its risk. The ratio is the
average return earned in excess of the risk-free rate per unit of volatility or total risk.
Volatility is a measure of the price fluctuations of... | 625941bcd7e4931a7ee9ddeb |
def test_brk_will_load_the_program_counter_from_the_interrupt_vector(cpu): <NEW_LINE> <INDENT> cpu.reset_to(0xFF00) <NEW_LINE> cpu.Memory[0xFF00] = OpCodes.INS_BRK <NEW_LINE> cpu.Memory[0xFFFE] = 0x00 <NEW_LINE> cpu.Memory[0xFFFF] = 0x80 <NEW_LINE> expected_cycles = 7 <NEW_LINE> cycles_used = cpu.execute(expected_cycle... | BRKWillLoadTheProgramCounterFromTheInterruptVector | 625941bc656771135c3eb73a |
def cross_validation(x, y, inputs, model, folds=5): <NEW_LINE> <INDENT> out = [] <NEW_LINE> mode = inputs['prediction_type'] <NEW_LINE> kx, ky = kfold(x, y, folds, True) <NEW_LINE> for i in range(folds): <NEW_LINE> <INDENT> model._make_predict_function() <NEW_LINE> y_pred = model.predict(kx[i], verbose=0) <NEW_LINE> if... | Performs cross_validation for n folds | 625941bc24f1403a92600a38 |
def set_properties(self): <NEW_LINE> <INDENT> self.exh.rho_array = np.empty(np.size(self.exh.T_array)) <NEW_LINE> self.exh.mu_array = np.empty(np.size(self.exh.T_array)) <NEW_LINE> for i in range(np.size(self.exh.T_array)): <NEW_LINE> <INDENT> self.exh.T = self.exh.T_array[i] <NEW_LINE> self.exh.set_TempPres_dependents... | Sets array of temperature and pressure dependent properties
based on average temperature in HX. | 625941bc1f037a2d8b9460ce |
def k_dom_by_point(p, kValue, aSkyline): <NEW_LINE> <INDENT> numWorstDim = 0 <NEW_LINE> numQualifyDim = 0 <NEW_LINE> isKDom = False <NEW_LINE> domSK = None <NEW_LINE> for d in range(len(p)): <NEW_LINE> <INDENT> if p[d] >= aSkyline[d]: <NEW_LINE> <INDENT> numQualifyDim = numQualifyDim + 1 <NEW_LINE> <DEDENT> if p[d] > a... | Test whether point p is k-dominated by point aSkyline
return True if p is k-dominated by aSkyline; otherwise false | 625941bc5e10d32532c5edf6 |
def raise_exists(*_args, **_kwargs): <NEW_LINE> <INDENT> raise kazoo.client.NodeExistsError() | zk.create side effect, raising appropriate exception. | 625941bc6fb2d068a760ef69 |
def get_session(self): <NEW_LINE> <INDENT> headers = { 'Authorization': 'GatewayLogin token="{}"'.format(self.token), } <NEW_LINE> session = requests.Session() <NEW_LINE> session.headers.update(headers) <NEW_LINE> return session | Returns a session object to make authenticated requests | 625941bc29b78933be1e5587 |
def prepare_ligand_zmat(complex_pdb_data, ligand_resname, MCPRO_path, BOSS_path): <NEW_LINE> <INDENT> print('Preparing Ligand Z matrix') <NEW_LINE> ligand_pdb_filename, ligand_resnumber, ligand_original_resnumber = generate_ligand_pdb(complex_pdb_data, ligand_resname) <NEW_LINE> protonated_ligand_pdb_filename = p... | Prepares the ligand zmat, starting from the complex pdb
The process involves extracting the ligand pdb info from the complex pdb,
then protonating it and converting it to a z-matrix. Lastly, it's optimized.
Args:
complex_pdb_data: List. Data from the complex pdb file
ligand_resname: String. Residue name of de... | 625941bcbe8e80087fb20b17 |
def _clean_token(self, token): <NEW_LINE> <INDENT> token = re.sub(r"[^a-z\s]", '', token.lower()) <NEW_LINE> token = re.sub(r"[']+", ' ', token) <NEW_LINE> return token | Remove everything but whitespace, the alphabet. Separate apostrophes for stopwords | 625941bc50812a4eaa59c1f3 |
def __init__(self, start, end, string): <NEW_LINE> <INDENT> self.start = start <NEW_LINE> self.end = end <NEW_LINE> self.string = string | Parameters
----------
start
end
string | 625941bca79ad161976cc014 |
def data_type(val): <NEW_LINE> <INDENT> for json_type, py_types in _type_map.items(): <NEW_LINE> <INDENT> if type(val) in py_types: <NEW_LINE> <INDENT> return json_type <NEW_LINE> <DEDENT> <DEDENT> raise ValueError('{} not a valid type (int, float, ndarray, str)'.format(val)) | Determine data-type of val.
Returns:
-----------
str
One of ('number', 'array', 'string'), else raises ValueError | 625941bc31939e2706e4cd3d |
def get_utility_combinations(agents, singleton_utilities, sum_utils): <NEW_LINE> <INDENT> utility_values = list(singleton_utilities.values()) <NEW_LINE> n = len(agents) <NEW_LINE> all_utility_combinations = [] <NEW_LINE> for i in range(sum_utils + 1): <NEW_LINE> <INDENT> for j in range(sum_utils + 1 - i): <NEW_LINE> <I... | powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3) | 625941bc4e696a04525c931b |
def vcs_virtual_fabric_vfab_enable(self, **kwargs): <NEW_LINE> <INDENT> config = ET.Element("config") <NEW_LINE> vcs = ET.SubElement(config, "vcs", xmlns="urn:brocade.com:mgmt:brocade-vcs") <NEW_LINE> virtual_fabric = ET.SubElement(vcs, "virtual-fabric") <NEW_LINE> vfab_enable = ET.SubElement(virtual_fabric, "vfab-enab... | Auto Generated Code
| 625941bc7b25080760e3932a |
def annot_max_min(x, y, ax=None): <NEW_LINE> <INDENT> xmax = x[np.argmax(y)] <NEW_LINE> ymax = y.max() <NEW_LINE> xmin = x[np.argmin(y)] <NEW_LINE> ymin = y.min() <NEW_LINE> textmax = "x={:.2f}, y={:.8f}".format(xmax, ymax) <NEW_LINE> textmin = "x={:.2f}, y={:.13f}".format(xmin, ymin) <NEW_LINE> if not ax: <NEW_LINE> <... | Mark max and min point on the plot.
| 625941bc55399d3f05588582 |
def get_basis_functions(self, reshape=True, symbolic=True, use_tensor_factorisation=False): <NEW_LINE> <INDENT> raise NotImplementedError() | Get the basis functions of the element. | 625941bc3c8af77a43ae366d |
def nextDay(year, month, day): <NEW_LINE> <INDENT> day=day+1 <NEW_LINE> if day > 30 : <NEW_LINE> <INDENT> month=month+1 <NEW_LINE> day=day-30 <NEW_LINE> <DEDENT> if month > 12 : <NEW_LINE> <INDENT> year=year+1 <NEW_LINE> month=month-12 <NEW_LINE> <DEDENT> else : <NEW_LINE> <INDENT> day <NEW_LINE> <DEDENT> return year,... | Returns the year, month, day of the next day.
Simple version: assume every month has 30 days. | 625941bcac7a0e7691ed3fa8 |
def test_publish_db(self): <NEW_LINE> <INDENT> (out, err) = self.call(['-c', self.config_dir, '-a', '/dev/zero', '-d', os.path.join(self.workdir, 'dup.db'), '-vl', self.lock_file, '--publish-db', os.path.join(self.workdir, 'dupdb')]) <NEW_LINE> self.assertEqual(err, '', 'no error messages:\n' + err) <NEW_LINE> self.ass... | Duplicate database publishing | 625941bc711fe17d82542240 |
def dumpstruct(id0, node,structs): <NEW_LINE> <INDENT> name = id0.name(node) <NEW_LINE> packed = id0.blob(node, 'M') <NEW_LINE> spec = idblib.idaunpack(packed) <NEW_LINE> entsize = 5 if id0.wordsize == 4 else 8 <NEW_LINE> k=[] <NEW_LINE> for i in range(spec[1]): <NEW_LINE> <INDENT> member=dumpstructmember(id0, spec[ent... | dump all info for the struct defined by `node` | 625941bc8e7ae83300e4ae9b |
def __repr__(self) -> str: <NEW_LINE> <INDENT> return self.__str__() | Return a string representation of the Some(). | 625941bc9b70327d1c4e0ca3 |
def clientConnectionFailed(self, connector, reason): <NEW_LINE> <INDENT> moduleCoordinator.ModuleCoordinator().putError("Error connecting to " + self.config['botnet'], self.module) | Called on failed connection to server | 625941bcb7558d58953c4de9 |
def normalization_function(x, mean, std): <NEW_LINE> <INDENT> assert len(mean) == 3, 'Custom norm function is for 3 channel images. Expected 3 elements for mean, got {}'.format(len(mean)) <NEW_LINE> assert len(std) == 3, 'Custom norm function is for 3 channel images. Expected 3 elements for std, got {}'.format(len(std)... | Normalizes input variable with a mean and std.
output = (input-mean)/std
:param x: input data, a 3-channel image
:param mean: mean of all the input channels, a list of 3 floats
:param std: standard deviation of all the input channels, a list of 3 floats | 625941bc99fddb7c1c9de262 |
def get_style_defs(self, arg=""): <NEW_LINE> <INDENT> return self.tktags | Called by the client (a Tk Text object) to learn what styles to use. | 625941bce64d504609d7470f |
@register.filter(is_safe=True) <NEW_LINE> def escape_commas(text): <NEW_LINE> <INDENT> return mark_safe(text.replace(',', '\,')) | Escapes all commas with a backslash. | 625941bc3d592f4c4ed1cf4d |
def expand_path(self, path, role='File'): <NEW_LINE> <INDENT> if not os.path.isabs(path): <NEW_LINE> <INDENT> ret = os.path.abspath(path) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ret = os.path.normpath(path) <NEW_LINE> <DEDENT> if not ret.startswith(self.root): <NEW_LINE> <INDENT> raise FileOutOfProject(ret, self.... | Return full path.
normalized path if path is absolute
user expanded path if path starts with ~ or ~user
project expanded path if path starts with @
current dir expanded path otherwise | 625941bc090684286d50ebb1 |
def _setV(self, V): <NEW_LINE> <INDENT> self.V = V <NEW_LINE> self.Vhist.append(V) | Pre-allocating a numpy array for histories would be good,
but then we'd have to keep track of our current index in that array,
and we'd still have to extend it if we integrated past our expected
maximum time. Still, this remains a potential source of speedup if
any is later needed. | 625941bcfbf16365ca6f608d |
def render_authkeys(authkeys, config, key_type=None, key_value=None): <NEW_LINE> <INDENT> output = [] <NEW_LINE> ssh_key_attr = config['ldap']['attributes']['ssh_key'] <NEW_LINE> for username in authkeys.keys(): <NEW_LINE> <INDENT> user_entry = authkeys[username] <NEW_LINE> for k in user_entry[ssh_key_attr]: <NEW_LINE>... | Render a hash of authorized keys that came either from a YAML cache file or
fetch_ldap_authkeys(). Returns a string. | 625941bc63d6d428bbe443bf |
def handle(self, *args, **options): <NEW_LINE> <INDENT> if len(args) != 1: <NEW_LINE> <INDENT> raise CommandError('Please specify JSON file to import!') <NEW_LINE> <DEDENT> data = json.load(open(args[0])) <NEW_LINE> for line in data: <NEW_LINE> <INDENT> if 'fields' in line: <NEW_LINE> <INDENT> line = line['fields'] <NE... | Creates default set of groups and optionally updates them and moves
users around to default group. | 625941bc32920d7e50b2809c |
def _get_background(self, empty_ws, cadmium_ws, transmission_ws, transmission_corr, max_empty_entry, max_cadmium_entry, entry_no, tof_background=""): <NEW_LINE> <INDENT> background_ws = "background_ws" <NEW_LINE> nMeasurements = self._data_structure_helper() <NEW_LINE> measurement_technique = self.getPropertyValue('Mea... | Provides the background to be subtracted from currently reduced sample. This method takes into account
whether empty container, and cadmium are provided, and whether the measurement method is TOF or powder/single
crystal. | 625941bcaad79263cf39090c |
def import_binary(file_name: str, data_width: int, supersample: int) -> np.array(int): <NEW_LINE> <INDENT> with open(file_name, "r") as text_file: <NEW_LINE> <INDENT> data = [] <NEW_LINE> lines = text_file.readlines() <NEW_LINE> for line in lines: <NEW_LINE> <INDENT> r_line = line.strip() <NEW_LINE> for i in range(supe... | import data from the output of hdl simulation, change it to np.array
Parameters
----------
file_name : str
name of target file.
data_width : int
width of the each std_logic_vector in the output file
supersample : int
data supersample.
Returns
-------
data : np.array(int). | 625941bc30bbd722463cbc92 |
def test_intersection(): <NEW_LINE> <INDENT> result = [["Number", "Surname", "Age"], [7432, "O'Malley", 39], [9824, "Darkes", 38]] <NEW_LINE> assert is_equal(result, intersection(GRADUATES, MANAGERS)) | Test intersection operation. | 625941bc99cbb53fe6792ab7 |
def logical_cpu_cores(): <NEW_LINE> <INDENT> return psutil.cpu_count() | :return: The number of logical CPU cores. | 625941bc73bcbd0ca4b2bf4d |
def AllValues(self, list_unset=False, include_hidden=False, properties_file=None, only_file_contents=False): <NEW_LINE> <INDENT> properties_file = properties_file or PropertiesFile.Load() <NEW_LINE> result = {} <NEW_LINE> for prop in self: <NEW_LINE> <INDENT> if (prop.is_hidden and not include_hidden and _GetPropertyWi... | Gets all the properties and their values for this section.
Args:
list_unset: bool, If True, include unset properties in the result.
include_hidden: bool, True to include hidden properties in the result.
If a property has a value set but is hidden, it will be included
regardless of this setting.
propertie... | 625941bc32920d7e50b2809d |
def white_elephant(gifts): <NEW_LINE> <INDENT> gift_list = [gift for gift in gifts.values()] <NEW_LINE> new_gifts = {person: None for person in gifts.keys()} <NEW_LINE> for person, gift in new_gifts.items(): <NEW_LINE> <INDENT> new_gift = choice(gift_list) <NEW_LINE> gift_list.remove(new_gift) <NEW_LINE> new_gifts[pers... | Plays a white elephant game with a given dictionary of guests and gifts
>>> white_elephant({})
{}
>>> white_elephant({'Leslie': 'stuffed dog'})
{'Leslie': 'stuffed dog'}
>>> len({'Leslie': 'stuffed dog', 'Joel': 'crossword puzzle', 'Meggie': 'candy', 'Bonnie': 'cat food', 'Katie': 'rubiks cube', 'Anges': 'starbucks... | 625941bccc40096d61595822 |
def update(self, data: "Observation") -> None: <NEW_LINE> <INDENT> old = self.Q[self.last_state][self.last_action] <NEW_LINE> if data.new_state.agent_location in self.Q: <NEW_LINE> <INDENT> new = ( self.gamma * self.Q[data.new_state.agent_location][ max(self.Q[data.new_state.agent_location], key=self.Q[data.new_state.a... | Updates learner with new state/Q values | 625941bcdd821e528d63b07a |
def setUp(self): <NEW_LINE> <INDENT> self.inst = MoransI() <NEW_LINE> self.morans_i_results_str1 = morans_i_results_str1.split('\n') <NEW_LINE> self.morans_i_results_str2 = morans_i_results_str2.split('\n') | Define some sample data that will be used by the tests. | 625941bc462c4b4f79d1d5a0 |
def __init__(self, file_name): <NEW_LINE> <INDENT> self.aut_stack = [] <NEW_LINE> self.aut_to_push = [] <NEW_LINE> self.operations = [] <NEW_LINE> self._read(file_name) | class initialization
:param file_name: name of file
with stack description | 625941bc4527f215b584c32a |
def a_mystery_function_2(binary_string): <NEW_LINE> <INDENT> binary_list=[int(i) for i in binary_string] <NEW_LINE> binary_list.reverse() <NEW_LINE> a,b=binary_list[0:2] <NEW_LINE> return a and not b | binary_string is a string that is at least 4 characters long with 1s and 0s with the rightmost character representing the 0th bit | 625941bcf7d966606f6a9ed1 |
def choose_rsnapshot_config(self): <NEW_LINE> <INDENT> fname = QFileDialog.getOpenFileName(self, self.translate( 'MainWindow', 'Open file'), os.path.expanduser('~')) <NEW_LINE> if fname[0]: <NEW_LINE> <INDENT> self.settings.setValue('rsnapshot_config_path', fname[0]) <NEW_LINE> if self.settings.value('rsnapshot_bin_pat... | dialog to choose rsnapshot conf file | 625941bc187af65679ca4fee |
def clean_dict(dct): <NEW_LINE> <INDENT> return dict((key, val) for key, val in dct.items() if val is not None) | Returns a dict where items with a None value are removed | 625941bce5267d203edcdb70 |
def init_extra(self): <NEW_LINE> <INDENT> pass | Initializing the extra_widget attribute which is a QWidget object
for displaying rig specific property (e.g. length, segment) | 625941bc2ae34c7f2600d002 |
def retrieve_output(self): <NEW_LINE> <INDENT> return self.result | Method for retrieving output after a model run | 625941bc4527f215b584c32b |
def _set_attr_reg(self): <NEW_LINE> <INDENT> tmos_v = self._meta_data['bigip']._meta_data['tmos_version'] <NEW_LINE> attributes = self._meta_data['attribute_registry'] <NEW_LINE> v12kind = 'tm:asm:policies:blocking-settings:blocking-settingcollectionstate' <NEW_LINE> v11kind = 'tm:asm:policies:blocking-settings' <NEW_L... | Helper method.
Appends correct attribute registry, depending on TMOS version | 625941bc94891a1f4081b978 |
def sliderplot2D(ZZZ, XX=None, YY=None, slidervals=None, *args, **kwargs): <NEW_LINE> <INDENT> if 'linewidth' and 'lw' not in kwargs.keys(): <NEW_LINE> <INDENT> kwargs['linewidth'] = 2 <NEW_LINE> <DEDENT> fig = plt.figure(figsize=FIGURE_SIZE, dpi=FIGURE_DPI) <NEW_LINE> ZZZ = np.asarray(ZZZ, dtype=np.float) <NEW_LINE> i... | Shortcut to creating an image plot with a slider to go through a third dimension
ZZZ = [nxmxo]: z axis data
XX = [nxm] or [n]: x axis data
YY = [nxm] or [m]: y axis data
slidervals = None or [o]: Values to give in the slider
if XX and/or YY have a single dimension, the 2D values are generated via meshgrid
E.G.
... | 625941bcd486a94d0b98e015 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.