code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def parseArgs( self ): <NEW_LINE> <INDENT> def addDictOption(opts, choicesDict, default, name, **kwargs): <NEW_LINE> <INDENT> helpStr = ('|'.join(sorted(choicesDict.keys())) + '[,param=value...]') <NEW_LINE> helpList = ['%s=%s' % (k, v.__name__) for k, v in choicesDict.items()] <NEW_LINE> helpStr += ' ' + (' '.join(hel... | Parse command-line args and return options object.
returns: opts parse options dict | 625941f00a50d4780f66741e |
def is_empty(self): <NEW_LINE> <INDENT> return len(self.members) == 0 | Indicates whether or not the stack is empty. Returns a boolean. | 625941f0796e427e537b0b51 |
def find_ardublockly_dir(search_path): <NEW_LINE> <INDENT> path_to_navigate = os.path.normpath(search_path) <NEW_LINE> while path_to_navigate: <NEW_LINE> <INDENT> if os.path.isfile( os.path.join(path_to_navigate, 'ardublockly', 'index.html')): <NEW_LINE> <INDENT> return path_to_navigate <NEW_LINE> <DEDENT> path_to_navi... | Find the Ardublockly project directory absolute path.
Navigates within each node of given path and tries to find the Ardublockly
project root directory. Assumes that the project root will have an folder
name ardublockly with an index.html file inside.
This function is required because this script can end up in executa... | 625941f007d97122c4178e20 |
def send_message(self, subject, message, attachments=None): <NEW_LINE> <INDENT> mime_msg = MIMEMultipart() <NEW_LINE> mime_msg['From'] = self.config.mail_from <NEW_LINE> mime_msg['To'] = self.value <NEW_LINE> mime_msg['Subject'] = subject <NEW_LINE> body = message <NEW_LINE> mime_msg.attach(MIMEText(body, 'plain')) <NE... | Sends an alert message | 625941f0aad79263cf390fd0 |
def getBorderTile(self, position): <NEW_LINE> <INDENT> borderPosition = (position[0]%2, position[1]%2) <NEW_LINE> if borderPosition == (0,0): <NEW_LINE> <INDENT> return self.borderTiles[BD_NW] <NEW_LINE> <DEDENT> elif borderPosition == (1,0): <NEW_LINE> <INDENT> return self.borderTiles[BD_NE] <NEW_LINE> <DEDENT> elif b... | Return the index of the border tile at a position.
position - the position of the tile on the map | 625941f03617ad0b5ed6847d |
def testIbeam(self): <NEW_LINE> <INDENT> s = Workplane(Plane.XY()) <NEW_LINE> L = 100.0 <NEW_LINE> H = 20.0 <NEW_LINE> W = 20.0 <NEW_LINE> t = 1.0 <NEW_LINE> pts = [ (0, H/2.0), (W/2.0, H/2.0), (W/2.0, (H/2.0 - t)), (t/2.0, (H/2.0-t)), (t/2.0, (t - H/2.0)), (W/2.0, (t - H/2.0)), (W/2.0, H / -2.0), (0, H/-2.0) ] <NEW_LI... | Make an ibeam. demonstrates fancy mirroring | 625941f0462c4b4f79d1dc56 |
def permute(self, order): <NEW_LINE> <INDENT> data, dims, shape = _permute(self, order) <NEW_LINE> return Qobj(data, dims=dims, shape=shape) | Permutes a composite quantum object in the given order.
Parameters
----------
order : list/array
List specifying new tensor order.
Returns
-------
P : qobj
Permuted quantum object. | 625941f026238365f5f0f3fc |
def transfer(self, other: 'Queue', timeout: int=0) -> bytes: <NEW_LINE> <INDENT> return self.client.brpoplpush(self.name, other.name, timeout) | Transfer one element to the other | 625941f07d847024c06be848 |
def normalised_confusion_matrix(label:np.ndarray, image:np.ndarray): <NEW_LINE> <INDENT> cm = confusion_matrix(label.flatten(), image.flatten()) <NEW_LINE> cm_normalised = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] <NEW_LINE> return cm_normalised | Create a normalised confusion matrix for a label and image in the same format.
| 625941f021bff66bcd684ed4 |
@contextlib.contextmanager <NEW_LINE> def pushd_popd(target_dir): <NEW_LINE> <INDENT> save_cwd = os.getcwd() <NEW_LINE> try: <NEW_LINE> <INDENT> os.chdir(target_dir) <NEW_LINE> yield target_dir <NEW_LINE> <DEDENT> finally: <NEW_LINE> <INDENT> os.chdir(save_cwd) | Temporary change to the specified directory, restoring current directory on context exit. | 625941f055399d3f05588c3f |
def get_operator(column, op_name, value, serializer): <NEW_LINE> <INDENT> if not op_name: <NEW_LINE> <INDENT> return column.operate(operator.eq, parse_value(value, serializer)) <NEW_LINE> <DEDENT> elif op_name in SQLA_OPERATORS: <NEW_LINE> <INDENT> op = SQLA_OPERATORS.get(op_name) <NEW_LINE> if op == "between": <NEW_LI... | :param column:
SQLAlchemy ColumnElement
:param op_name:
Key of OPERATORS or COMPARE_OPERATORS
:param value:
value to be applied to the operator
:rtype: ColumnOperators
:return:
returns a boolean, comparison, and other operators for ColumnElement expressions.
ref: http://docs.sqlalchemy.org/en/la... | 625941f045492302aab5e850 |
def current_hunt_info(request): <NEW_LINE> <INDENT> curr_hunt = Hunt.objects.get(is_current_hunt=True) <NEW_LINE> return render(request, "hunt_info.html", {'curr_hunt': curr_hunt}) | Information about the current hunt, mostly static with the exception of hunt info | 625941f0d7e4931a7ee9e4a6 |
def sortFunction1(x): <NEW_LINE> <INDENT> return x[1] | KEY FUNCTION FOR inbuild sorted func
returns the 2nd value from the tuple
Parameters
----------
x : tuple
Returns
-------
float
2nd value of the tuple input | 625941f0711fe17d825428e5 |
def __init__(self, value=None, freq=None, ordinal=None, year=None, month=1, quarter=None, day=1, hour=0, minute=0, second=0): <NEW_LINE> <INDENT> self.freq = None <NEW_LINE> self.ordinal = None <NEW_LINE> if ordinal is not None and value is not None: <NEW_LINE> <INDENT> raise ValueError(("Only value or ordinal but not ... | Represents an period of time
Parameters
----------
value : Period or basestring, default None
The time period represented (e.g., '4Q2005')
freq : str, default None
e.g., 'B' for businessday, ('T', 5) or '5T' for 5 minutes
year : int, default None
month : int, default 1
quarter : int, default None
day : int, de... | 625941f0627d3e7fe0d693d9 |
def __init__(self, fluid): <NEW_LINE> <INDENT> super(LeeKesler, self).__init__(fluid) <NEW_LINE> self.acentric = fluid.acentric <NEW_LINE> self.p_crit = fluid.p_crit <NEW_LINE> self.T_crit = fluid.T_crit | Lee-Kesler equation of state
For details see: Chemical Engineering Thermodynamics, Y.V.C. Rao, 1997, University Press (India), pp.79
https://books.google.co.in/books?id=GjlO9MA9edUC&pg=PA79&dq=lee+kesler+method
Parameters
----------
fluid - A Fluid class object
Returns
-------
An equation of state object | 625941f026238365f5f0f3fd |
def actor(intent, session): <NEW_LINE> <INDENT> card_title = intent['slots']['actor']['name'] <NEW_LINE> session_attributes = {} <NEW_LINE> should_end_session = True <NEW_LINE> speech_output = "I recommend The Godfather if you want a sad movie" <NEW_LINE> return build_response(session_attributes, build_speechlet_respon... | Sets the actor in the session and prepares the speech to reply to the
user. | 625941f023e79379d52eeae3 |
def genfcurrent(current): <NEW_LINE> <INDENT> return current / q | Return generation (eh pairs/s) given current (amps)
| 625941f0e76e3b2f99f3ad89 |
def channel_shuffle(x, groups): <NEW_LINE> <INDENT> return x.reshape((0, -4, groups, -1, -2)).swapaxes(1, 2).reshape((0, -3, -2)) | Channel shuffle operation from 'ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices,'
https://arxiv.org/abs/1707.01083.
Parameters:
----------
x : Symbol or NDArray
Input tensor.
groups : int
Number of groups.
Returns:
-------
Symbol or NDArray
Resulted tensor. | 625941f0d58c6744b42581e5 |
def test_has_decl_0(self): <NEW_LINE> <INDENT> self.assertFalse(SConsArguments.Declaration._ArgumentDeclaration().has_decl(SConsArguments.ENV)) <NEW_LINE> self.assertFalse(SConsArguments.Declaration._ArgumentDeclaration().has_decl(SConsArguments.VAR)) <NEW_LINE> self.assertFalse(SConsArguments.Declaration._ArgumentDecl... | _ArgumentDeclaration().has_decl(...) should always return False | 625941f07b180e01f3dc4d78 |
def toggleBbox(self): <NEW_LINE> <INDENT> checked = not self.toolbar.btn_bbox.isChecked() <NEW_LINE> if not checked: <NEW_LINE> <INDENT> self.plotter.remove_bounds_axes() <NEW_LINE> self.plotter.remove_bounding_box() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> _ = self.plotter.show_bounds( all_edges=True, minor_ticks... | Toggle the visibility of the axis grid surrounding the model. | 625941f032920d7e50b2875c |
def __init__(self, anchor, match_threshold=0.7, unmatched_threshold=0.3, rpn_batch_size_per_im=256, rpn_fg_fraction=0.5, has_centerness=False, center_match_iou_threshold=0.3, center_unmatched_iou_threshold=0.1, num_center_samples_per_im=256): <NEW_LINE> <INDENT> super(OlnAnchorLabeler, self).__init__( anchor, match_thr... | Constructs rpn anchor labeler to assign labels and centerness to anchors.
Args:
anchor: an instance of class Anchors.
match_threshold: a float number between 0 and 1 representing the
lower-bound threshold to assign positive labels for anchors. An anchor
with a score over the threshold is labeled positive.
... | 625941f0d7e4931a7ee9e4a7 |
def _to_ast_array(self, args): <NEW_LINE> <INDENT> sz = len(args) <NEW_LINE> _args = (z3.Ast * sz)() <NEW_LINE> for i, arg in enumerate(args): <NEW_LINE> <INDENT> _args[i] = arg <NEW_LINE> <DEDENT> return _args, sz | Convert a list of arguments into an z3.AST vector. | 625941f0e64d504609d74dc7 |
def get_status_json(self): <NEW_LINE> <INDENT> return self._statusobj.as_json() | "RPC method
Returns the last updated status from the object with the context.
The minimum output from the status would be:
{
"status": "GOOD",
"context": None,
"utc_last_update": "2016-03-31T15:40:32.685138+0000"
} | 625941f0091ae356686674dc |
def get_vector(self, tweet, cleaned=False, return_tensor=False): <NEW_LINE> <INDENT> if(cleaned==False): <NEW_LINE> <INDENT> tweet = self.clean_string(tweet) <NEW_LINE> <DEDENT> word_vectors = self.get_word_vectors(tweet) <NEW_LINE> return self.sent_emb_to_vect([word_vectors], return_tensor)[0] | Get vectors of tweet | 625941f03539df3088e2e8d3 |
def _solve_triangular_left(a, b, left_side, lower, trans_a): <NEW_LINE> <INDENT> assert a.bs == b.bs == 1 <NEW_LINE> n = a.shape[-1] <NEW_LINE> if n == 1: <NEW_LINE> <INDENT> return b / a <NEW_LINE> <DEDENT> out = full_like(b, 0) <NEW_LINE> if lower == trans_a: <NEW_LINE> <INDENT> if left_side: <NEW_LINE> <INDENT> out[... | An unrolled left-looking triangular solve on *unblocked* LapaxMatrices. | 625941f09c8ee82313fbbcff |
def _newheader(zobj, header=None): <NEW_LINE> <INDENT> header = header or zobj.header.copy() <NEW_LINE> header['COMMENT'] = 'These data have been ZAPped!' <NEW_LINE> header.append(('ZAPvers', __version__, 'ZAP version'), end=True) <NEW_LINE> header.append(('ZAPzlvl', zobj.run_zlevel, 'ZAP zero level correction')) <NEW_... | Put the pertinent zap parameters into the header | 625941f0236d856c2ad44d6a |
def test_qstar_low_q_power_law(self): <NEW_LINE> <INDENT> inv = invariant.InvariantCalculator(self.data) <NEW_LINE> _qstar = inv.get_qstar() <NEW_LINE> qstar, dqstar = inv.get_qstar_with_error() <NEW_LINE> self.assertEqual(qstar, _qstar) <NEW_LINE> inv.set_extrapolation('low', npts=10, function='power_law') <NEW_LINE> ... | Test low-q extrapolation with a power law | 625941f0d164cc61757832d7 |
def images_are_identical(image_name, temp_dir, dpi=None): <NEW_LINE> <INDENT> image_name += os.path.extsep + "png" <NEW_LINE> expected = os.path.join(IMAGE_DIR, image_name) <NEW_LINE> actual = os.path.join(temp_dir, image_name) <NEW_LINE> if dpi: <NEW_LINE> <INDENT> plt.savefig(actual, dpi=dpi) <NEW_LINE> <DEDENT> else... | Partially copied from ObsPy. Used to check images for equality. | 625941f05fcc89381b1e1c4b |
def _attr(obj: object, attr: str) -> object: <NEW_LINE> <INDENT> n = obj <NEW_LINE> for p in attr.split('.'): <NEW_LINE> <INDENT> n = getattr(n, p, None) <NEW_LINE> if n is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> <DEDENT> return n | Nest `getattr` function. | 625941f04f6381625f114fc2 |
def __init__(self): <NEW_LINE> <INDENT> self._FEATURE_INDEX = -1 | Set the feature universal index
INPUT:: | 625941f010dbd63aa1bd312a |
def load(self, sess): <NEW_LINE> <INDENT> self.saver.restore(sess, self.model_path) <NEW_LINE> return 0 | 反序列化模型 | 625941f06e29344779a62b98 |
def decide(self, observation: np.ndarray) -> int: <NEW_LINE> <INDENT> return 0 | Returns the fixed action, which is the only one available.
See :meth:`hdeeprm.agent.Agent.decide`.
| 625941f0d18da76e23532a65 |
@pytest.mark.wig <NEW_LINE> def test_wig_indexer(): <NEW_LINE> <INDENT> resource_path = os.path.join(os.path.dirname(__file__), "data/") <NEW_LINE> f_check = h5py.File(resource_path + "file_index.hdf5", "a") <NEW_LINE> f_check.close() <NEW_LINE> input_files = { "wig": resource_path + "sample.wig", "chrom_file": resourc... | Function to test Kallisto indexer | 625941f03cc13d1c6d3c78ff |
def process_resources(tenants): <NEW_LINE> <INDENT> update_database(tenants) <NEW_LINE> migrate_requests(tenants) <NEW_LINE> cancel_unmigrated_requests(tenants) <NEW_LINE> cancel_unnecessary_requests(tenants) | This should manage all of the existing aws resources and requests. | 625941f08e05c05ec3eea901 |
def _get_titles_dependencies_for_question(schema, question): <NEW_LINE> <INDENT> dependencies = AnswerDependencies() <NEW_LINE> answer_ids = schema.get_answer_ids_for_question(question['id']) <NEW_LINE> when_clauses = [title.get('when')[0] for title in question.get('titles', []) if title.get('when')] <NEW_LINE> for whe... | gets the unique ids of any answers on a question as dependents
of any when id associated with a questions titles
:param schema: the json schema to use
:param question: the id of a question | 625941f0b830903b967e9e8c |
def _get_objects(self, filters): <NEW_LINE> <INDENT> return Diagnosis.objects.filter(**filters) | Get all objects. | 625941f096565a6dacc8fc51 |
def basis_labels(self, subspace='gef', braket=False): <NEW_LINE> <INDENT> elec_labels = self.electronic.basis_labels(subspace) <NEW_LINE> vib_labels = self.vib_basis_labels() <NEW_LINE> labels = [(e, v) for e in elec_labels for v in vib_labels] <NEW_LINE> return add_braket(labels) if braket else labels | If double excitations are requested, then default to using the Fock basis
If custom labels are used but the ground state is included, then the
label "gs" is prepended.
Vibronic basis labels are returned as a list of tuples:
[(elec_basis_label, vib_basis_label), ] | 625941f094891a1f4081c034 |
def touch(path): <NEW_LINE> <INDENT> with open(path, 'a'): <NEW_LINE> <INDENT> os.utime(path, None) | Create empty file | 625941f0cc40096d61595ed6 |
def add_arguments(self): <NEW_LINE> <INDENT> self._parser.add_argument( '-v', '--verbose', action='store_true', help='make zorn talk more to you' ) <NEW_LINE> self._parser.add_argument( '-s', '--silent', action='store_true', help='(try to) silence zorn' ) | Register arguments to the parser | 625941f091f36d47f21aca81 |
def searchMatrix(matrix, target): <NEW_LINE> <INDENT> numrows = len(matrix) <NEW_LINE> if numrows == 0: <NEW_LINE> <INDENT> return(False) <NEW_LINE> <DEDENT> elif len(matrix[0]) == 0: <NEW_LINE> <INDENT> return(False) <NEW_LINE> <DEDENT> elif matrix[0][0] > target: <NEW_LINE> <INDENT> return(False) <NEW_LINE> <DEDENT> ... | :type matrix: List[List[int]]
:type target: int
:rtype: bool | 625941f060cbc95b062c6acb |
def parse_args(): <NEW_LINE> <INDENT> parser = ArgumentParser() <NEW_LINE> parser.add_argument('mountpoint', type=str, help='Where to mount the file system') <NEW_LINE> parser.add_argument('--base-url', type=str, help='Base URL under which all file names will be found.') <NEW_LINE> parser.add_argument('--block-size', t... | Parse command line.
| 625941f0656771135c3ebdfe |
def report_due_date(self): <NEW_LINE> <INDENT> date = self.end_datetime() + timedelta(1) <NEW_LINE> while date.weekday() != 0: <NEW_LINE> <INDENT> date += timedelta(1) <NEW_LINE> <DEDENT> return date | Return the due date of the report, which is every Monday. | 625941f0099cdd3c635f11e0 |
def get_task(self, task_id): <NEW_LINE> <INDENT> task_info = self.get_task_info(task_id) <NEW_LINE> if task_info: <NEW_LINE> <INDENT> return TaskInfo(**task_info) <NEW_LINE> <DEDENT> return None | Get the task with the given task_id and return it as TaskInfo.
| 625941f06fece00bbac2dccd |
def get_tally_res(lines, tnum): <NEW_LINE> <INDENT> term_line = find_line(" run terminated when", lines, 25) <NEW_LINE> lines = lines[term_line:] <NEW_LINE> res_start_line = find_line("1tally " + tnum, lines, 15) <NEW_LINE> particle_type = lines[res_start_line+2][24:33] <NEW_LINE> nps_value = lines[res_start... | reads the lines and extracts the final tally results | 625941f0462c4b4f79d1dc57 |
def getPending(self): <NEW_LINE> <INDENT> return self.pending | Get list of players pending to join the game
@return: List of players still pending to re-join a paused game | 625941f067a9b606de4a843e |
def sigint_handler(signum, frame): <NEW_LINE> <INDENT> global _handled_int <NEW_LINE> if not _handled_int: <NEW_LINE> <INDENT> _handled_int = True <NEW_LINE> if not _env_var_true("_REZ_QUIET_ON_SIG"): <NEW_LINE> <INDENT> print("Interrupted by user", file=sys.stderr) <NEW_LINE> <DEDENT> sigbase_handler(signum, frame) | Exit gracefully on ctrl-C. | 625941f01b99ca400220b03c |
def set_interrupt_polarity(self, value): <NEW_LINE> <INDENT> __ioconfig = self.__bus.read_byte_data(self.__address, self.IOCON) <NEW_LINE> __ioconfig = self.__updatebyte(__ioconfig, 1, value) <NEW_LINE> self.__bus.write_byte_data(self.__address, self.IOCON, __ioconfig) <NEW_LINE> return | This sets the polarity of the INT output pins
1 = Active-high.
0 = Active-low. | 625941f0ff9c53063f47c778 |
def clustmmr_mix(d, ncr=(1, 5)): <NEW_LINE> <INDENT> pass | Like clustmmr_med, but uses mixture-model based clusters. These clusters
assume that all spikes occur independently and thus model a 1-dimensional
distribution of spikes (in time) | 625941f0377c676e9127272e |
def __basic_authentication( self, environ, username, password ): <NEW_LINE> <INDENT> if asbool( self.config.get( 'use_remote_user', False ) ): <NEW_LINE> <INDENT> assert "HTTP_REMOTE_USER" in environ, "use_remote_user is set but no HTTP_REMOTE_USER variable" <NEW_LINE> return self.__authenticate_remote_user( environ, u... | The environ parameter is needed in basic authentication. We also check it if use_remote_user is true. | 625941f0cc0a2c11143dd41a |
def mnasnet_d1(depth_multiplier=None): <NEW_LINE> <INDENT> blocks_args = [ 'r1_k3_s11_e9_i32_o24', 'r3_k3_s22_e9_i24_o36', 'r5_k3_s22_e9_i36_o48', 'r4_k5_s22_e9_i48_o96', 'r5_k7_s11_e3_i96_o96', 'r3_k3_s22_e9_i96_o80', 'r1_k7_s11_e6_i80_o320_noskip' ] <NEW_LINE> global_params = mnasnet_model.GlobalParams( batch_norm_mo... | Creates a jointly searched mnasnet backbone for mnas-fpn.
Args:
depth_multiplier: multiplier to number of filters per layer.
Returns:
blocks_args: a list of BlocksArgs for internal MnasNet blocks.
global_params: GlobalParams, global parameters for the model. | 625941f082261d6c526aba30 |
def test_calculate_signed_r_square(self): <NEW_LINE> <INDENT> dat = calculate_signed_r_square(self.dat) <NEW_LINE> self.assertEqual(dat.ndim + 1, self.dat.data.ndim) <NEW_LINE> dat = dat.mean(axis=1) <NEW_LINE> self.assertTrue(all(dat[0:20] < .2)) <NEW_LINE> self.assertTrue(all(dat[20:40] > .5)) <NEW_LINE> self.assertT... | Calculating signed r**2. | 625941f05166f23b2e1a56e1 |
def p_re_char(p): <NEW_LINE> <INDENT> set_parse_globals(p) <NEW_LINE> p[0] = p[1] | re_char : re_non_term_restrict2
| re_backlash_seq
| re_expr_class | 625941f04e696a04525c99d6 |
def middle_east_countries(): <NEW_LINE> <INDENT> middle_east_data = [] <NEW_LINE> years = [] <NEW_LINE> medians = [] <NEW_LINE> lst = [] <NEW_LINE> for idx in range(1960, 2016): <NEW_LINE> <INDENT> years.append(idx) <NEW_LINE> <DEDENT> for idx in middle_east: <NEW_LINE> <INDENT> middle_east_data.append(life_expectancy_... | returns a list of medians of life expectancies of a list of countries under Middle East region from 1960 to
2015
:return: a list of medians | 625941f0ab23a570cc25070f |
def emit(self, record): <NEW_LINE> <INDENT> level = record.levelname <NEW_LINE> if level not in self.level_to_count: <NEW_LINE> <INDENT> self.level_to_count[level] = 0 <NEW_LINE> <DEDENT> self.level_to_count[level] += 1 | Override for the emit method called when logging.
@param logging.record record | 625941f0442bda511e8be998 |
def df_numerical_summary(df): <NEW_LINE> <INDENT> ndf = df.select_dtypes(include=[np.number]) <NEW_LINE> dft = ndf.describe().T <NEW_LINE> nunique = [n for n in ndf.apply(pd.Series.nunique)] <NEW_LINE> nzeros = [((ndf[col] == 0).sum()) for col in ndf] <NEW_LINE> kurt = [x for x in ndf.kurtosis()] <NEW_LINE> skewness = ... | automatically selects all the numeric columns in a dataframe and provides their summary statistics
Parameters:
___________
df:
Dataframe
Returns:
________
Dataframe | 625941f0dd821e528d63b72c |
def validate(self): <NEW_LINE> <INDENT> initial_validation = super(CandidateForm, self).validate() <NEW_LINE> if not initial_validation: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> candidate = Candidate.query.filter_by( identification=self.identification.data ).first() <NEW_LINE> if candidate: <NEW_LINE> <INDE... | Validate the form. | 625941f060cbc95b062c6acc |
def pilot_names_s(self): <NEW_LINE> <INDENT> return self._pilot_names(self._STAR_SHIPS) | Returns the fastest pilot names driving StarShips | 625941f071ff763f4b549c1e |
def rest_verify_tenant_rx_rates(self, tenant, frame_rate, vrange=100): <NEW_LINE> <INDENT> t = test.Test() <NEW_LINE> c = t.controller('master') <NEW_LINE> frame_rate = int(frame_rate) <NEW_LINE> vrange = int(vrange) <NEW_LINE> url = '/api/v1/data/controller/applications/bcf/info/statistic/tenant-rate[name="%s"]' % (te... | Function to verify the Tenant Tx stats
Input: Tenant name , matching frame count , if required user can provide range as well for the frame count match
Output: given Tenant counters will be showed and matched aginst the value | 625941f0fb3f5b602dac3c21 |
def get_objects(self, oid=None, since=None, until=None, last=None, first=None): <NEW_LINE> <INDENT> resource = self.kvpath('registry/objects', ('int', oid), since=('isobasic', absdatetime(since)), until=('isobasic', absdatetime(until)), first=('int', first), last=('int', last)) <NEW_LINE> return self.request('get', res... | FETCHES a filtered collection of objects created by the authenticated
user.
:type oid: ``bigint``
:param oid:
Object ID
:type since: ``datetime``/``dict``
:param since:
Object has to be newer than this timestamp (absolute ``datetime``,
or relative ``dict``). Valid keys for relative `since` timestamp
di... | 625941f0be8e80087fb211c2 |
def gui2(self, ): <NEW_LINE> <INDENT> self.listView.delete(0, END) <NEW_LINE> d = 0 <NEW_LINE> for i in self.listaCalcule: <NEW_LINE> <INDENT> self.listView.insert(END, "x" + str(d) + "= " + str(i)) <NEW_LINE> d += 1 <NEW_LINE> <DEDENT> self.listView.pack(fill="both", expand=YES) | genereaza primii n termeni | 625941f007d97122c4178e21 |
def __init__(self, response): <NEW_LINE> <INDENT> self.__item = Script(response['item']) if 'item' in response.keys() and response['item'] is not None else None | コンストラクタ
:type response: レスポンスボディ
:type response: dict | 625941f0a219f33f34628eea |
def batch_over_test(self, batch_size: int = 32) -> Iterator[np.recarray]: <NEW_LINE> <INDENT> yield from self._batch_over(self._test_split, batch_size=batch_size) | Generates batches of test split data
Performs non-shuffled, non-stratified iteration over test split.
Parameters
----------
batch_size : int
targe size of batches, defaults to 32
Yields
-------
np.recarray
batches as record arrays with .X (examples), .y (labels)
and .id (example hash) fields | 625941f076d4e153a657f0ba |
def test_get_all_calendar_empty_db(self): <NEW_LINE> <INDENT> obj = model.Calendar.get_all(self.session) <NEW_LINE> self.assertNotEqual(obj, None) <NEW_LINE> self.assertEqual(len(obj), 0) <NEW_LINE> self.assertEqual(obj, []) | Test the Calendar get_all function when the DB is empty. | 625941f0d268445f265b53f7 |
def load(self, *args, **kwargs): <NEW_LINE> <INDENT> options = self.options <NEW_LINE> if 'options' in kwargs: <NEW_LINE> <INDENT> if type(kwargs['options']) == dict: <NEW_LINE> <INDENT> options.update(kwargs['options']) <NEW_LINE> <DEDENT> <DEDENT> if not options['silent']: <NEW_LINE> <INDENT> print('Loading', self.da... | Loading method called by child classes.
Called by child class load methods, stops from loading non-extant file.
Args:
options :obj:`dict`, optional Options settings found at respective keywords
Raises:
Exception: If nothing exists at path | 625941f0b7558d58953c5490 |
def deserialize_numpy(self, str, numpy): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self.header is None: <NEW_LINE> <INDENT> self.header = std_msgs.msg.Header() <NEW_LINE> <DEDENT> end = 0 <NEW_LINE> _x = self <NEW_LINE> start = end <NEW_LINE> end += 12 <NEW_LINE> (_x.header.seq, _x.header.stamp.secs, _x.header.st... | unpack serialized message in str into this message instance using numpy for array types
:param str: byte array of serialized message, ``str``
:param numpy: numpy python module | 625941f021a7993f00bc8283 |
def get_source_by_id(id): <NEW_LINE> <INDENT> connector = get_connector() <NEW_LINE> data = connector.get(id) <NEW_LINE> if data is None: <NEW_LINE> <INDENT> return problem(404, "Not found", "Source %s does not exist." % id) <NEW_LINE> <DEDENT> return data | Return source object with id `id` or raise a 404 error. | 625941f07b180e01f3dc4d79 |
def pc_nproduced_var(self): <NEW_LINE> <INDENT> return _analog_swig.noise_source_s_sptr_pc_nproduced_var(self) | pc_nproduced_var(noise_source_s_sptr self) -> float | 625941f0e1aae11d1e74a245 |
def add_ipaddrs_ipmi(self, ipaddrs): <NEW_LINE> <INDENT> self._add_ipaddrs(ipaddrs, self.InvKey.IPMI) <NEW_LINE> self.dbase.dump_inventory(self.inv) | Add IPMI IP addresses
Args:
ipaddrs (dict of str): MAC{IP} | 625941f0cb5e8a47e48b8029 |
def main(): <NEW_LINE> <INDENT> app_name = 'Bing Desktop Wallpaper' <NEW_LINE> Notify.init(app_name) <NEW_LINE> exit_status = 0 <NEW_LINE> try: <NEW_LINE> <INDENT> image_metadata = get_image_metadata() <NEW_LINE> image_name = image_metadata.find("startdate").text + ".jpg" <NEW_LINE> image_url = get_image_url(image_meta... | Main application entry point. | 625941f029b78933be1e5c2d |
def setUp(self): <NEW_LINE> <INDENT> self.app = create_app('testing') <NEW_LINE> self.client = self.app.test_client() <NEW_LINE> with self.app.app_context(): <NEW_LINE> <INDENT> db.create_all() <NEW_LINE> <DEDENT> self.user_details = { "name": "Jane Doe", "user_id": 123456, "username": "JD", "password": "qwerty", "emai... | et up testing environment variables. | 625941f0d268445f265b53f8 |
def deserialize_numpy(self, str, numpy): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self.orientation is None: <NEW_LINE> <INDENT> self.orientation = geometry_msgs.msg.Quaternion() <NEW_LINE> <DEDENT> end = 0 <NEW_LINE> _x = self <NEW_LINE> start = end <NEW_LINE> end += 36 <NEW_LINE> (_x.orientation.x, _x.orientati... | unpack serialized message in str into this message instance using numpy for array types
:param str: byte array of serialized message, ``str``
:param numpy: numpy python module | 625941f0d10714528d600272 |
def _update_positions(self): <NEW_LINE> <INDENT> if (not self.is_gameover) and (not self.pause_button.is_pause): <NEW_LINE> <INDENT> self.my_plane.update() <NEW_LINE> self.bullet_group.update() <NEW_LINE> self.double_bullet_group.update() <NEW_LINE> self.bullet_supply_group.update() <NEW_LINE> self.bomb_supply_group.up... | 更新窗口中所有画面元素的位置 | 625941f0851cf427c661aa92 |
def _parse_json_file(self, namespace, file_path, class_name=None): <NEW_LINE> <INDENT> with open(file_path, 'r') as stream: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> class_data = json.load(stream) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> logging.warning("%s: decoding JSON has failed", file_path) <N... | Parse and validate JSON file | 625941f0e64d504609d74dc8 |
def _checkarguments(self): <NEW_LINE> <INDENT> input = self._parser._getinput() <NEW_LINE> i = 0 <NEW_LINE> while i < len(input): <NEW_LINE> <INDENT> opt = input[i] <NEW_LINE> if shared.lookslikeopt(opt) and self._parser._command.getopt(opt).params(): <NEW_LINE> <INDENT> types = self._parser._command.getopt(opt).params... | Checks if arguments given to options which require them are valid.
**Notice:** if you want to pass option-like argument wrap it in `"` or `'` and
escape first hyphen or double-escape first hyphen. | 625941f0eab8aa0e5d26e0e3 |
def GetFeedUri(self, kind='contacts', contact_list=None, projection='full', scheme=None): <NEW_LINE> <INDENT> contact_list = contact_list or self.contact_list <NEW_LINE> if kind == 'profiles': <NEW_LINE> <INDENT> contact_list = 'domain/%s' % contact_list <NEW_LINE> <DEDENT> prefix = scheme and '%s://%s' % (scheme, self... | Builds a feed URI.
Args:
kind: The type of feed to return, typically 'groups' or 'contacts'.
Default value: 'contacts'.
contact_list: The contact list to return a feed for.
Default value: self.contact_list.
projection: The projection to apply to the feed contents, for example
'full', 'base', 'base/12... | 625941f0cdde0d52a9e535c0 |
def create_or_update_release_and_upload_directory( user, repo, tag_name, token, directory, retry_limit=10, description=None, ): <NEW_LINE> <INDENT> release_homepage_url = f"https://github.com/{user}/{repo}/releases/{tag_name}" <NEW_LINE> urls_by_filename = { os.path.basename(l): l for l in utils_thirdparty.get_paths_or... | Create or update a GitHub release at https://github.com/<user>/<repo> for
`tag_name` tag using the optional `description` for this release.
Use the provided `token` as a GitHub token for API calls authentication.
Upload all files found in the `directory` tree to that GitHub release.
Retry API calls up to `retry_limit` ... | 625941f0f7d966606f6aa593 |
def flatten_dict(d, separtor='.'): <NEW_LINE> <INDENT> result = [] <NEW_LINE> if not (d and isinstance(d, dict)): <NEW_LINE> <INDENT> return result <NEW_LINE> <DEDENT> node_stack = [([k], v) for k, v in d.iteritems()] <NEW_LINE> while node_stack: <NEW_LINE> <INDENT> path, item = node_stack.pop() <NEW_LINE> if item and ... | flatten_dict
Return plain list of tuples with concatinated paths to leafs. | 625941f0ac7a0e7691ed464a |
def index(request): <NEW_LINE> <INDENT> example = reverse('placeholder', kwargs={'width': 50, 'height':50}) <NEW_LINE> context = { 'example': request.build_absolute_uri(example) } <NEW_LINE> return render(request, 'home.html', context) | 主页视图 | 625941f0b5575c28eb68e58e |
def main(): <NEW_LINE> <INDENT> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_background_job.settings') <NEW_LINE> try: <NEW_LINE> <INDENT> from django.core.management import execute_from_command_line <NEW_LINE> <DEDENT> except ImportError as exc: <NEW_LINE> <INDENT> raise ImportError( "Couldn't import Django... | Run administrative tasks. | 625941f0f7d966606f6aa594 |
def _plotRunningTime(self, reportRequest, plotInfo, filename): <NEW_LINE> <INDENT> return self.__plotAllResources(reportRequest, plotInfo, filename, 'Running time') | It creates the plot.
:param dict reportRequest: plot attributes
:param dict plotInfo: contains all the data which are used to create the plot
:param str filename:
:return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE | 625941f0bf627c535bc13758 |
def assertCategoryFilteredProducts(self, num_products): <NEW_LINE> <INDENT> products = Product.objects.filter(self._category.filters()) <NEW_LINE> self.assertEqual(products.distinct().count(), num_products) | Tests the number of products returned by the category's
current filters. | 625941f0b545ff76a891439e |
def add_states(self, *args, **kwargs): <NEW_LINE> <INDENT> return _cmf_core.Integrator_add_states(self, *args, **kwargs) | add_states(Integrator self, StateVariableOwner stateOwner)
virtual
void add_states(cmf::math::StateVariableOwner &stateOwner)
Add state variables from a StateVariableOwner. | 625941f0c432627299f051d3 |
def find_games(self, sport='Soccer', league='', period_description=''): <NEW_LINE> <INDENT> games_url = BASE_URL + 'php/query/findgames.php' <NEW_LINE> payload = {'sport' : sport, 'league' : league, 'period_description': period_description} <NEW_LINE> req = self.session.post(games_url, data=payload, verify=False) <NEW_... | Request games for the given sport and league | 625941f03eb6a72ae02eca76 |
def parse_QA(data, image_map): <NEW_LINE> <INDENT> qas = [] <NEW_LINE> for info in data: <NEW_LINE> <INDENT> qos = [] <NEW_LINE> aos = [] <NEW_LINE> if 'question_objects' in info: <NEW_LINE> <INDENT> for qo in info['question_objects']: <NEW_LINE> <INDENT> synset = Synset(qo['synset_name'], qo['synset_definition']) <NEW... | Helper to parse a list of question answers. | 625941f05f7d997b87175025 |
def dot(self, vector_2): <NEW_LINE> <INDENT> dot_product = 0 <NEW_LINE> i = 0 <NEW_LINE> for value in self.coordinates: <NEW_LINE> <INDENT> product = value * vector_2.coordinates[i] <NEW_LINE> dot_product += product <NEW_LINE> i += 1 <NEW_LINE> <DEDENT> return dot_product | Calculates the dot product of this vector and another vector | 625941f023849d37ff7b3613 |
def __init__(self, pos_dict: Dict[str, Position], u_bid: float, u_ask: float, ticker: str, mcs: MonteCarloSimulator): <NEW_LINE> <INDENT> self.pos_dict = pos_dict <NEW_LINE> self.coverage_dict = dict() <NEW_LINE> self.u_bid = u_bid <NEW_LINE> self.u_ask = u_ask <NEW_LINE> self.u_mid = (self.u_bid + self.u_ask) / 2 <NEW... | :param pos_dict: (option symbol/stock ticker): position | 625941f029b78933be1e5c2e |
def test_1_3_1(self): <NEW_LINE> <INDENT> nn, weights, biases = make_1_3_1() <NEW_LINE> xv = np.array([0.2]) <NEW_LINE> av = NeuralNetwork.sigmoid(np.array([0.0955163])) <NEW_LINE> y = 0 <NEW_LINE> np.testing.assert_allclose(nn.feedforward(xv)[-1], av, atol=1e-8, err_msg='feedforward() incorrect') <NEW_LINE> self.asser... | Test results of feedforward() and classify() on 1 input, layer of 3,
and 1 output. | 625941f0460517430c3946fe |
def build_sample_db(): <NEW_LINE> <INDENT> import string <NEW_LINE> db.create_all() <NEW_LINE> with app.app_context(): <NEW_LINE> <INDENT> read_role = Role(name='read') <NEW_LINE> user_role = Role(name='user') <NEW_LINE> super_user_role = Role(name='adminrole') <NEW_LINE> db.session.add(user_role) <NEW_LINE> db.session... | Populate a small db with some example entries. | 625941f0796e427e537b0b53 |
def test_setup_scheduled_tasks(self): <NEW_LINE> <INDENT> call_command('setup_periodic_tasks') <NEW_LINE> assert Schedule.objects.all().count() == 6 <NEW_LINE> call_command('setup_periodic_tasks') <NEW_LINE> assert Schedule.objects.all().count() == 6 | Test setup of perdiodic tasks and ensure function is idempotent. | 625941f05e10d32532c5f4ae |
def check_existence(self): <NEW_LINE> <INDENT> if self.erroneous(): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> old_file = None <NEW_LINE> if not opts.name_template: <NEW_LINE> <INDENT> if not self.name: <NEW_LINE> <INDENT> old_file = exists(self.id) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> if self.nam... | Test if the coub already exists or is present in the archive. | 625941f0fbf16365ca6f6759 |
def _accept_method(self, *args): <NEW_LINE> <INDENT> if self.state in ('stopping', 'idle', 'crashed'): <NEW_LINE> <INDENT> if isinstance(self, (ThreadedServer, ThreadPoolServer)): <NEW_LINE> <INDENT> sock = args[0] <NEW_LINE> sock.close() <NEW_LINE> <DEDENT> elif isinstance(self, AsyncIOServer): <NEW_LINE> <INDENT> wri... | Overridden class method for pre-connection checks. While authentication should be handled
by RPyC's :function:_authenticate_and_serve_client:, we save opening another thread by intercepting
a connection at this point if certain daemon states should not allow any further connection. | 625941f08e7ae83300e4b557 |
def _parsing_covering_helper( groundtruth_category_array, groundtruth_instance_array, predicted_category_array, predicted_instance_array, num_classes, max_instances_per_category, ignored_label, offset, normalize_by_image_size): <NEW_LINE> <INDENT> pc = parsing_covering.ParsingCovering(num_classes, ignored_label, max_in... | Helper function to compute parsing covering. | 625941f0a05bb46b383ecda5 |
def set_magnet_inductance_display(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if 'IPS' in self.identity: <NEW_LINE> <INDENT> self.instrument.query(self.buffer_radix + 'F24')[1:] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise Errors.IncorrectInstrumentError <NEW_LINE> <DEDENT> <DEDENT> except Errors.Incorre... | Function used to read the calibrated magnet inductance. | 625941f0462c4b4f79d1dc58 |
def reverseList(self, head): <NEW_LINE> <INDENT> if head is None or head.next is None: <NEW_LINE> <INDENT> return head <NEW_LINE> <DEDENT> pre = head <NEW_LINE> mid = head.next <NEW_LINE> last = head.next.next <NEW_LINE> mid.next = pre <NEW_LINE> pre.next = None <NEW_LINE> pre = mid <NEW_LINE> mid = last <NEW_LINE> whi... | :type head: ListNode
:rtype: ListNode | 625941f05166f23b2e1a56e2 |
def flask(self, in_headers=True, headers=None, outformat='json-ld', **kwargs): <NEW_LINE> <INDENT> headers = headers or {} <NEW_LINE> kwargs["with_context"] = not in_headers <NEW_LINE> content, mimetype = self.serialize(format=outformat, with_mime=True, **kwargs) <NEW_LINE> if outformat == 'json-ld' and in_headers: <NE... | Return the values and error to be used in flask.
So far, it returns a fixed context. We should store/generate different
contexts if the plugin adds more aliases. | 625941f0627d3e7fe0d693da |
def is_valid(self, command_name): <NEW_LINE> <INDENT> if command_name == CommandField.LOAD_TOURNAMENTS: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | Return if user input matches the command name from config file. | 625941f0b7558d58953c5491 |
def create_table(table_name, table_schema): <NEW_LINE> <INDENT> conn = sqlite3.connect(helper.DB_PATH) <NEW_LINE> with conn: <NEW_LINE> <INDENT> c = conn.cursor() <NEW_LINE> c.execute("CREATE TABLE IF NOT EXISTS " + table_name + " (" + table_schema + ")") <NEW_LINE> conn.commit() | Create a table in the db using the args provided. | 625941f015fb5d323cde10a1 |
def warning(msg): <NEW_LINE> <INDENT> logging.getLogger('mesk').warning(msg) | Log a warning message. | 625941f0f548e778e58cdb09 |
def raw_trigram_probability(self,trigram): <NEW_LINE> <INDENT> trigram_list = list(trigram) <NEW_LINE> trigram_list.pop(-1) <NEW_LINE> bigram = tuple(trigram_list) <NEW_LINE> trigram_count = self.trigramcounts[trigram] <NEW_LINE> bigram_count = self.bigramcounts[bigram] <NEW_LINE> try: <NEW_LINE> <INDENT> prob = trigra... | COMPLETE THIS METHOD (PART 3)
Returns the raw (unsmoothed) trigram probability | 625941f099fddb7c1c9de917 |
def setCooldown(self,chatId,cooldown): <NEW_LINE> <INDENT> conn = sqlite3.connect("RedditBot.db") <NEW_LINE> curs = conn.cursor() <NEW_LINE> curs.execute("INSERT OR IGNORE INTO cooldown(chatId,cooldown,lastCall) VALUES (?,?,?)",[chatId,cooldown,0]) <NEW_LINE> curs.execute("UPDATE cooldown SET cooldown=? WHERE chatId=?"... | Eneable to set a new cooldown | 625941f0d4950a0f3b08c8d0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.