code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def is_challenge_response(self, passw, user, options=None, challenges=None): <NEW_LINE> <INDENT> challenge_response = False <NEW_LINE> if options and ("state" in options or "transactionid" in options): <NEW_LINE> <INDENT> challenge_response = True <NEW_LINE> <DEDENT> elif not self.is_challenge_request(passw, user, opti...
Checks if the request is a challenge response. With the e-mail token every request has to be either a challenge request or a challenge response. Normally the client is unable to generate OTP values for this token himself (because the seed is generated on the server and not published) and has to wait to get it by e-ma...
625941e6d58c6744b42580a8
def back_to_menu(update, context): <NEW_LINE> <INDENT> context.user_data[START_OVER] = True <NEW_LINE> start(update, context) <NEW_LINE> return END
Return to top level conversation.
625941e657b8e32f524838e8
def _out(self, msg): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> output = self.output <NEW_LINE> if not output: <NEW_LINE> <INDENT> if _ipython_write: <NEW_LINE> <INDENT> _ipython_write(msg) <NEW_LINE> return <NEW_LINE> <DEDENT> output = sys.stderr <NEW_LINE> <DEDENT> output.write(msg) <NEW_LINE> if hasattr(output, 'f...
Writes msg to output (or error output if not output) If running in IPython, then use ``get_ipython().write_err()`` so that logging comes out in the cell as an error. Otherwise, use stderr. If an error occurs, output is reset to None. Args: output (file): where to write msg (str): what to write
625941e6a4f1c619b28b0479
def __virtual__(): <NEW_LINE> <INDENT> if "locale.get_locale" in __salt__: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return (False, __salt__.missing_fun_string("locale.get_locale"))
Only load if the locale module is available in __salt__
625941e67047854f462a184f
def main(): <NEW_LINE> <INDENT> print("Enter main()") <NEW_LINE> X_features, y_labels = make_blobs( n_samples = 500, n_features = 2, centers = 5, cluster_std = 0.5, shuffle = True, random_state = 0 ) <NEW_LINE> kmeans = KMeans( n_clusters = 5, init = 'random', n_init = 10, max_iter = 300, tol = 1e-04, random_state = 0,...
クラスター分析. k-mean 法によるクラスタリング
625941e67b25080760e398a0
def combine_dataframes(dfs: [pd.DataFrame]) -> pd.DataFrame: <NEW_LINE> <INDENT> df = pd.concat(dfs, sort=False) <NEW_LINE> return df
Receives a list of DataFrames and concatenates them. They must all have the same header. :param dfs: List of DataFrames :return: Single concatenated DataFrame
625941e6460517430c3945c4
def conjgrad(A, Y, sigma, X0=None, maxiters=None, tol=1e-2): <NEW_LINE> <INDENT> Y, m, n, d, matrix_in = _format_system(A, Y) <NEW_LINE> damp = m * sigma**2 <NEW_LINE> rtol = tol * np.sqrt(m) <NEW_LINE> G = lambda x: np.dot(A.T, np.dot(A, x)) + damp * x <NEW_LINE> B = np.dot(A.T, Y) <NEW_LINE> X = np.zeros((n, d)) if X...
Solve the least-squares system using conjugate gradient.
625941e65166f23b2e1a55a3
def get_data(url_request: str, full_url: bool = False) -> dict: <NEW_LINE> <INDENT> url = _set_url(url_request, full_url) <NEW_LINE> return requests.get(url).json()
Sends a request to the SWAPI API and returns the received response.
625941e6925a0f43d254a2c5
def filter_elements(): <NEW_LINE> <INDENT> n = int(input('Введіть n: ')) <NEW_LINE> b = [input('a[{}]: '.format(i + 1)) for i in range(n)][::3] <NEW_LINE> print('len(b): {} b: {}'.format(len(b), ' '.join(b)))
#2
625941e656b00c62f0f14aa6
def lambda_handler(event, context): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> logger.info('Fetching event data from previous step') <NEW_LINE> processed_keys = event['body']['processedKeys'] <NEW_LINE> team = event['body']['team'] <NEW_LINE> pipeline = event['body']['pipeline'] <NEW_LINE> stage = event['body']['pipe...
Updates the S3 objects metadata catalog Arguments: event {dict} -- Dictionary with details on previous processing step context {dict} -- Dictionary with details on Lambda context Returns: {dict} -- Dictionary with outcome of the process
625941e6009cb60464c637f8
def test_predict_topk(self): <NEW_LINE> <INDENT> model = self.model <NEW_LINE> for output_type in ["rank", "probability"]: <NEW_LINE> <INDENT> preds = model.predict_topk( self.data, output_type=output_type, output_frequency="per_window" ) <NEW_LINE> expected_len = self._calc_expected_predictions_length(self.data, top_k...
Check the predict_topk function.
625941e655399d3f05588b01
@callback <NEW_LINE> def async_add_entities_config(hass, config, async_add_entities): <NEW_LINE> <INDENT> import xknx <NEW_LINE> light = xknx.devices.Light( hass.data[DATA_KNX].xknx, name=config.get(CONF_NAME), group_address_switch=config.get(CONF_ADDRESS), group_address_switch_state=config.get(CONF_STATE_ADDRESS), gro...
Set up light for KNX platform configured within platform.
625941e65fdd1c0f98dc067f
def setAttrNS(self, namespace, localpart, value): <NEW_LINE> <INDENT> allowed_attrs = self.allowed_attributes() <NEW_LINE> prefix = self.get_nsprefix(namespace) <NEW_LINE> c = AttrConverters() <NEW_LINE> self.attributes[(namespace, localpart)] = c.convert( (namespace, localpart), value, self )
Add an attribute to the element In case you need to add an attribute the library doesn't know about then you must provide the full qualified name It will not check that the attribute is legal according to the schema. Must overwrite, If attribute already exists.
625941e691af0d3eaac9be67
def box_mask(self, box): <NEW_LINE> <INDENT> if not isinstance(box, Box): <NEW_LINE> <INDENT> raise ValueError("Must provide Box object") <NEW_LINE> <DEDENT> if box.frame != self.frame: <NEW_LINE> <INDENT> raise ValueError("Box must be in same frame as PointCloud") <NEW_LINE> <DEDENT> all_points = self.data.T <NEW_LINE...
Return a PointCloud containing only points within the given Box. Parameters ---------- box : :obj:`Box` A box whose boundaries are used to filter points. Returns ------- :obj:`PointCloud` A filtered PointCloud whose points are all in the given box. :obj:`numpy.ndarray` Array of indices of the segmented po...
625941e69f2886367277acd4
def run(self): <NEW_LINE> <INDENT> for plugin in self.plugins: <NEW_LINE> <INDENT> plugin.run()
runs, in order, all steps included in the analysis input option
625941e63cc13d1c6d3c77c2
def move_node(self, node, target, position='last-child'): <NEW_LINE> <INDENT> self._move_node(node, target, position=position)
Moves ``node`` relative to a given ``target`` node as specified by ``position`` (when appropriate), by examining both nodes and calling the appropriate method to perform the move. A ``target`` of ``None`` indicates that ``node`` should be turned into a root node. Valid values for ``position`` are ``'first-child'``, `...
625941e6e5267d203edce0e1
def run(func): <NEW_LINE> <INDENT> def func_wrapper(*args,**kwargs): <NEW_LINE> <INDENT> return func(*args,**kwargs) <NEW_LINE> <DEDENT> out = func_wrapper() <NEW_LINE> if hasattr(out, 'start'): <NEW_LINE> <INDENT> out.start() <NEW_LINE> <DEDENT> return out
A decorator for running functions. What kind of god could allow a thing such as this?
625941e61d351010ab855f65
def test_service_factory(): <NEW_LINE> <INDENT> app = [lambda x: x] <NEW_LINE> class TestProvider(object): <NEW_LINE> <INDENT> def __init__(self, service, host, port, report_message=''): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def serve_forever(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> <DEDENT> service_f...
Check service_factory will run given provider.
625941e61f5feb6acb0c4f94
def predictions(self, sess, input): <NEW_LINE> <INDENT> fd = { self.input: input, self.keep_prob: 1.0, self.gaussian_prob: 0.0, self.sap_prob: 0.0, } <NEW_LINE> predictions = sess.run((self.reconstruction), feed_dict=fd) <NEW_LINE> return predictions
Make predictions without back-propagation.
625941e6d268445f265b52b9
def main(): <NEW_LINE> <INDENT> print("What do you want to do?\n") <NEW_LINE> choice = int(input("1.) Create a secret code\n2.) Decipher an ecrypted message\n3.) Create a new key\n\n> ")) <NEW_LINE> if choice == 1: <NEW_LINE> <INDENT> print(create_code().ciphertext) <NEW_LINE> <DEDENT> elif choice == 2: <NEW_LINE> <IND...
Basic GUI controlling the encyption and decryption process
625941e6cb5e8a47e48b7eee
def create_car_body(self): <NEW_LINE> <INDENT> self.cost += costs.car_body['Suzuki'] <NEW_LINE> print("Suzuki body is added to the Suzuki car!")
Creates the Suzuki car body.
625941e6566aa707497f49ad
def svn_config_read3(*args): <NEW_LINE> <INDENT> return _core.svn_config_read3(*args)
svn_config_read3(char file, svn_boolean_t must_exist, svn_boolean_t section_names_case_sensitive, svn_boolean_t option_names_case_sensitive, apr_pool_t result_pool) -> svn_error_t
625941e6ac7a0e7691ed450e
def get_singular_values(M, k): <NEW_LINE> <INDENT> singular_values = None <NEW_LINE> _, s, _ = svd(M) <NEW_LINE> singular_values = s[:k] <NEW_LINE> return singular_values
Return top n singular values of matrix. (optional): Use the `svd(M)` function you wrote above as a helper function. Args: M: numpy matrix of shape (m, n). k: number of singular values to output. Returns: singular_values: array of shape (k)
625941e67b180e01f3dc4c3f
def test_http_success_with_zip(self, tmpdir, app): <NEW_LINE> <INDENT> import zipfile <NEW_LINE> zip_file = tmpdir.join('bundle.zip') <NEW_LINE> with zipfile.ZipFile(zip_file, 'w') as zip_fp: <NEW_LINE> <INDENT> zip_fp.writestr('assets/styles/main.css', 'body { font-family: sans; }') <NEW_LINE> zip_fp.writestr('index.h...
It should be able to process a template bundle ZIP
625941e6ac7a0e7691ed450f
def create_app(): <NEW_LINE> <INDENT> structured_log(level='info', msg="Starting beesly...") <NEW_LINE> try: <NEW_LINE> <INDENT> settings = initialize_config() <NEW_LINE> <DEDENT> except ConfigError: <NEW_LINE> <INDENT> structured_log(level='critical', msg="Failed to load configuration. Exiting...") <NEW_LINE> sys.exit...
Initializes the Flask application.
625941e699fddb7c1c9de7d9
def ensureUtf(self, s): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if type(s) == unicode: <NEW_LINE> <INDENT> return s.encode('utf8', 'ignore') <NEW_LINE> <DEDENT> <DEDENT> except: <NEW_LINE> <INDENT> return str(s)
S'assure que le paramètre passé est bien encodé en utf-8.
625941e6fbf16365ca6f6617
def max3V2(a,b,c): <NEW_LINE> <INDENT> if a > b and a > c: <NEW_LINE> <INDENT> res = a <NEW_LINE> <DEDENT> elif b > a and b > c: <NEW_LINE> <INDENT> res = b <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> res = c <NEW_LINE> <DEDENT> return res
WARNING: This code is deliberately broken!
625941e6046cf37aa974d18e
def _set_pythonpath(): <NEW_LINE> <INDENT> os.environ['PYTHONPATH'] = '/'
Temporarily reset PYTHONPATH to prevent home dir = python module home
625941e623e79379d52ee9a9
def frames_to_msec(frames, fps=FPS): <NEW_LINE> <INDENT> return 1000.0 * frames / fps
Преобразование кадров в миллисекунды с указанной частотой кадров. Аргументы: frames: сколько кадров преобразовать в миллисекунды. fps: частота кадров, используемая для преобразования. По умолчанию: FPS.
625941e62c8b7c6e89b35c08
def prikazi_seq(self): <NEW_LINE> <INDENT> self.seq_active = True <NEW_LINE> self.resetuj_btn() <NEW_LINE> time.sleep(0.1) <NEW_LINE> for x in self.sequence: <NEW_LINE> <INDENT> if x == "1": <NEW_LINE> <INDENT> self.bttn1["bg"] = "red" <NEW_LINE> <DEDENT> elif x == "2": <NEW_LINE> <INDENT> self.bttn2["bg"] = "red" <NEW...
Pokazuje sekvencu tako sto boji kocke u crveno
625941e6b830903b967e9d51
def get_primary_array_name(self): <NEW_LINE> <INDENT> return 'dq'
Returns the name "primary" array for this model.
625941e629b78933be1e5af1
def insertWord(self, move, player): <NEW_LINE> <INDENT> lin = move.pos[0]; <NEW_LINE> col = move.pos[1]; <NEW_LINE> index = 0; <NEW_LINE> for l in move.word: <NEW_LINE> <INDENT> if(self.getSquare(lin, col).isEmpty()): <NEW_LINE> <INDENT> if(index in move.brancos): <NEW_LINE> <INDENT> player.hand['#'].quantity -= 1; <NE...
Insere uma jogada valida no tabuleiro.
625941e6cdde0d52a9e53480
def CASE6(self,main) : <NEW_LINE> <INDENT> import time <NEW_LINE> main.log.report("Deleting and adding flows") <NEW_LINE> main.case("Taking care of these flows!") <NEW_LINE> main.step("Cleaning out any leftover flows...") <NEW_LINE> main.log.info("deleting...") <NEW_LINE> main.ONOS1.delete_flow("all") <NEW_LINE> main.l...
This Test case: - Clears out any leftover flows - Adds new flows into ONOS - Checks flows up to 10 times waiting for each flow to be caluculated and no "NOT" statements inte get_flow
625941e6ab23a570cc2505d0
def enhancements(self, enhancement): <NEW_LINE> <INDENT> enhancer = ImageEnhance.Contrast(self.image) <NEW_LINE> self.image = enhancer.enhance(enhancement['contrast']) <NEW_LINE> enhancer = ImageEnhance.Brightness(self.image) <NEW_LINE> self.image = enhancer.enhance(enhancement['brightness']) <NEW_LINE> enhancer = Imag...
Perform enhancements from the ImageEnhance class. Each method returns the url for the edited image
625941e682261d6c526ab8f1
@to_marc21.over('072', '^subject_category_code$') <NEW_LINE> @utils.reverse_for_each_value <NEW_LINE> @utils.filter_values <NEW_LINE> def reverse_subject_category_code(self, key, value): <NEW_LINE> <INDENT> indicator_map2 = { 'NAL subject category code list ': '0', 'Source specified in subfield $2': '7', } <NEW_LINE> f...
Reverse - Subject Category Code.
625941e64c3428357757c770
def test_update_asset_category_with_one_wrong_input_controls( self, client, init_db, auth_header): <NEW_LINE> <INDENT> asset_category = AssetCategory(name="TestLaptop b2") <NEW_LINE> asset_category.save() <NEW_LINE> data = json.dumps(asset_category_with_one_wrong_input_control) <NEW_LINE> response = client.patch( f'{ap...
Test to Update an asset category without choices with one wrong input controls
625941e6be7bc26dc91cda42
def export(model, args, f, export_params=True, verbose=False, training=False): <NEW_LINE> <INDENT> _export(model, args, f, export_params, verbose, training)
将一个模型导出成 ONNX 格式.这个导出器为了得到模型运行的轨迹,会运行一次你的模型.同时,它不支持动态模型(如 RNN.) 也可参考: :ref:`onnx-export` 参数: model (torch.nn.Module): 将被导出模型. args (tuple of arguments): 模型的输入, ``model(*args)`` 必须是对模型的有效调用.任何非变量参数将被硬编码到导出的模型中.任何变量参数都将按照它们在参数中出现的顺序,成为输出模型的输入.如果 args 是一个变量,相当于用该变量的一个元组来调用它.(注意:目前还不支持将关键参数传递给模型,如果需要,请联系我们.) ...
625941e65fdd1c0f98dc0680
def validate_string(req, errors, param_name, desc, max_len=None, allowed_values=None, required=True): <NEW_LINE> <INDENT> v = req.get(param_name) <NEW_LINE> if not v: <NEW_LINE> <INDENT> if not required: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> errors[param_name] = 'You must specify a %s.' % desc <NEW_LINE> ...
Gets the specified query parameter and makes sure it exists and isn't too long and then returns it after HTML escaping it. errors is updated and None is returned if an error occurs.
625941e673bcbd0ca4b2c4c0
def unsatisfied(self, context: 'interfaces.context.ContextInterface', config_path: str) -> Dict[str, RequirementInterface]: <NEW_LINE> <INDENT> config_path = path_join(config_path, self.name) <NEW_LINE> value = self.config_value(context, config_path, None) <NEW_LINE> self._cls = None <NEW_LINE> if value is not None and...
Checks to see if a class can be recovered.
625941e666656f66f7cbc5f7
def build_dueup_batters_line(game_pk, inning_half): <NEW_LINE> <INDENT> global HOME_CURRENT_BATTER_IDX <NEW_LINE> global AWAY_CURRENT_BATTER_IDX <NEW_LINE> due_up_batters = ['', '', ''] <NEW_LINE> fields = '?fields=teams,away,home,battingOrder' <NEW_LINE> batting_order = get_data(API_BOXSCORE_URL.format(game_pk) + fiel...
Return a string containing the names and averages of the next three due up hitters. Only shown during inning breaks. :param game_pk: :param inning_half: :return:
625941e6b5575c28eb68e44e
def set_anchor_type(self, anchor_type, page_number=None): <NEW_LINE> <INDENT> self.set_attribute('text:anchor-type', anchor_type) <NEW_LINE> if anchor_type == 'page' and page_number: <NEW_LINE> <INDENT> self.set_page_number(page_number)
Set how the frame is attached to its environment. When the type is 'page', you can give the number of the page where to attach. Arguments: anchor_type -- 'page', 'frame', 'paragraph', 'char' or 'as-char' page_number -- int (when anchor_type == 'page')
625941e67c178a314d6ef8b1
@login_required <NEW_LINE> def delete(request, question_id): <NEW_LINE> <INDENT> question = get_object_or_404(Question, pk=question_id) <NEW_LINE> category_id = request.GET.get("category_id", None) <NEW_LINE> if request.method == "POST": <NEW_LINE> <INDENT> if question: <NEW_LINE> <INDENT> question.delete() <NEW_LINE> ...
Deletes a single question from the list
625941e6d10714528d600132
def __mul__(self, other): <NEW_LINE> <INDENT> other = self._CastOrFail_(other) <NEW_LINE> return FXnum(family=self.family, scaled_value=((self.scaledval * other.scaledval) // self.family.scale))
Multiply by another number
625941e697e22403b379d3e6
def test_channel_member_types(self): <NEW_LINE> <INDENT> channel = self.cp.channels[self.channel_key] <NEW_LINE> self.assertIsInstance( channel[ 'callback' ], type( lambda x: x ) ) <NEW_LINE> self.assertIsInstance( channel[ 'queue' ], pika.frame.Method ) <NEW_LINE> self.assertIsInstance( channel[ 'channel' ], pika.adap...
Channel propperties values are of the right type
625941e69b70327d1c4e1222
def run_vm(args): <NEW_LINE> <INDENT> vm_name = args.vm_name <NEW_LINE> if args.tap_interface: <NEW_LINE> <INDENT> mac = '52:54:00:12:34:5{}'.format(6+int(args.tap_interface)) <NEW_LINE> tap = "tap,id=network{},ifname=tap{},script=no,downscript=no" <NEW_LINE> tap = tap.format(args.tap_interface, args.tap_interface) <NE...
Launch storage volume
625941e63c8af77a43ae3bf0
def to_markdown(self): <NEW_LINE> <INDENT> lines = "" <NEW_LINE> data = [] <NEW_LINE> for name, description, typed, default in self.data: <NEW_LINE> <INDENT> types = [] <NEW_LINE> for tpy in typed: <NEW_LINE> <INDENT> if isinstance(tpy, list): <NEW_LINE> <INDENT> types.append(tpy.to_markdown()) <NEW_LINE> <DEDENT> elif...
Output prepared for in markdown format.
625941e66aa9bd52df0371f2
def set_vega_conversion(self, vega): <NEW_LINE> <INDENT> if type(vega) != type(np.array([])) or vega.size == 0: raise ValueError('Pass a numpy array with the vega spectrum to calculate vega conversion!') <NEW_LINE> if self.vs.min() < vega[:,0].min() or self.vs.max() > vega[:,0].max(): return False <NEW_LINE> self.to_ve...
ezgal.astro_filter.set_vega_conversion(vega) Pass a numpy array with the vega spectrum. Array should have two columns: frequency (hertz) flux (ergs/s/cm^2/Hz)
625941e64f88993c3716c4ae
def feed_batch(self, batch, learning_rate): <NEW_LINE> <INDENT> grad_w = [np.zeros(w.shape) for w in self.weights] <NEW_LINE> grad_b = [np.zeros(b.shape) for b in self.biases] <NEW_LINE> for x, y in batch: <NEW_LINE> <INDENT> delta_grad_w, delta_grad_b = self.backpropagation(x, y) <NEW_LINE> grad_w = [new_w + delta_new...
Update the weights and biases according to the gradient descent using back propagation, given a batch and a learning rate.
625941e6851cf427c661a956
def p_elem(self, p): <NEW_LINE> <INDENT> if len(p) == 2: <NEW_LINE> <INDENT> p[0] = (p[1],[]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> p[0] = (p[1],p[3]) <NEW_LINE> <DEDENT> self.element.vars = self.element.all_vars
elem : elem_head | elem_head COND weighted_body_set
625941e6507cdc57c6307130
def fn_get_source(callable): <NEW_LINE> <INDENT> fn = get_fn(callable) <NEW_LINE> return fix_indentation(_inspect.getsource(fn))
Attempts to find the source of the provided callable. Indentation is fixed using fix_indentation before returning. .. WARNING:: Functions defined on the iPython command line do not have their source saved. A bug has been filed: http://github.com/ipython/ipython/issues/issue/120
625941e650812a4eaa59c768
def test_input_field_with_range(): <NEW_LINE> <INDENT> input_file = "[__ placeholder __] (1 - 999)" <NEW_LINE> lexer = AntwortLexer(input_file) <NEW_LINE> parser = AntwortParser(lexer, 2) <NEW_LINE> expression = parser.input_field() <NEW_LINE> assert_equal(expression.type, 'number') <NEW_LINE> assert_equal(expression.r...
Matches a field with range: [__test__] (1 - 5)
625941e6d99f1b3c44c679d2
def log_likelihood(P, pi, eps=1e-6): <NEW_LINE> <INDENT> sum_over_k = torch.sum(pi.unsqueeze(1) * P, dim=0) <NEW_LINE> sum_over_m = torch.sum(torch.log(sum_over_k + eps)) <NEW_LINE> return - sum_over_m / P.size(1)
Get the log-likelihood of the data points under the given distribution. :param P: likelihoods / densities under the distributions. (K, examples) :param pi: priors (K)
625941e656b00c62f0f14aa7
def node(self, node, index=None, wait=None, consistency=None, dc=None, token=None): <NEW_LINE> <INDENT> params = {} <NEW_LINE> dc = dc or self.agent.dc <NEW_LINE> if dc: <NEW_LINE> <INDENT> params['dc'] = dc <NEW_LINE> <DEDENT> if index: <NEW_LINE> <INDENT> params['index'] = index <NEW_LINE> if wait: <NEW_LINE> <INDENT...
Returns a tuple of (*index*, *services*) of all services provided by *node*. *index* is the current Consul index, suitable for making subsequent calls to wait for changes since this query was last run. *wait* the maximum duration to wait (e.g. '10s') to retrieve a given index. this parameter is only applied if *index...
625941e6596a897236089f06
def test_sftp_store_data(self): <NEW_LINE> <INDENT> config = Config() <NEW_LINE> metadata_bucket = config.config.get("metadata", "bucket") <NEW_LINE> data_bucket = config.config.get("data", "bucket") <NEW_LINE> metadata_provider = sftp.Sftp(config, metadata_bucket).connect() <NEW_LINE> provider = sftp.Sftp(config, data...
Test storing data to filesystem, both to metadata and data buckets.
625941e68c0ade5d55d3ee09
def before_all(context): <NEW_LINE> <INDENT> context.main_test_dir = tempfile.mkdtemp(prefix='zonkylla_behave-') <NEW_LINE> context.base_wd = os.getcwd() <NEW_LINE> context.base_config_file = os.path.join(context.base_wd, 'zonkylla.conf') <NEW_LINE> context.cli_options = ''
Setup environemnt before all behaves
625941e6f8510a7c17cf9b4a
def drop_duplicates(self): <NEW_LINE> <INDENT> return self.__class__(self.df.drop_duplicates(['CodeRoute', 'Latitude', 'Longitude']))
Drop points of the same track with the same Latitude and Longitude.
625941e623849d37ff7b34d6
def __init__(self, order, cache=None, category=None): <NEW_LINE> <INDENT> order = ZZ(order) <NEW_LINE> if order <= 0: <NEW_LINE> <INDENT> raise ZeroDivisionError("order must be positive") <NEW_LINE> <DEDENT> self.__order = order <NEW_LINE> self._pyx_order = integer_mod.NativeIntStruct(order) <NEW_LINE> global default_c...
Create with the command ``IntegerModRing(order)``. TESTS:: sage: FF = IntegerModRing(29) sage: TestSuite(FF).run() sage: F19 = IntegerModRing(19, is_field=True) sage: TestSuite(F19).run() sage: F23 = IntegerModRing(23) sage: F23 in Fields() True sage: TestSuite(F23).run() sage: Z16...
625941e6d58c6744b42580a9
def quicksort(array): <NEW_LINE> <INDENT> if len(array) <= 1: <NEW_LINE> <INDENT> return array <NEW_LINE> <DEDENT> pivot_index = randint(0, len(array)-1) <NEW_LINE> pivot = array.pop(pivot_index) <NEW_LINE> less, greater = [], [] <NEW_LINE> for element in array: <NEW_LINE> <INDENT> if element <= pivot: <NEW_LINE> <INDE...
Quicksort (partition-exchange sort) ---------- Advantages: - Fast for large data sets Disadvantages: - Not stable Time complexity: - worst: O(n^2) - average: O(n*log(n)) - best: O(n*log(n)) Space complexity: - Ideally O(log n) - This implementation O(n)
625941e6498bea3a759b9ef9
def search(self, body, index=None, routing=None, doc_type=None, size=0): <NEW_LINE> <INDENT> if index is None: <NEW_LINE> <INDENT> index = self.index <NEW_LINE> <DEDENT> params = {} <NEW_LINE> if routing is not None: <NEW_LINE> <INDENT> params['routing'] = routing <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> return sel...
Send search query to Elasticsearch
625941e6d6c5a10208144499
def exporttiles (X, h, w, filename, x=None, y=None): <NEW_LINE> <INDENT> if x is None: <NEW_LINE> <INDENT> X = numpy.reshape(X, (1, h*w)) <NEW_LINE> x, y, = 1, 1 <NEW_LINE> frame = 0 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> frame = 1 <NEW_LINE> <DEDENT> xy, hw = numpy.shape(X) <NEW_LINE> if (xy != x*y) or (hw != ...
If all arguments given: displays a weight matrix X of output-dimension x*y (number of rows) and input-dimension h*w (number of columns) by writing into filename as a pgm file. If last two arguments missing: displays activation vector X with dimension h*w (height, width) by writing into filename as a pgm f...
625941e631939e2706e4d2af
def _splitGeneric(self, splitter, partitions, relativeCoords): <NEW_LINE> <INDENT> rank0_fiber_group = [] <NEW_LINE> rank0_fiber_coords = [] <NEW_LINE> rank0_fiber_payloads = [] <NEW_LINE> rank1_fiber_coords = [] <NEW_LINE> rank1_fiber_payloads = [] <NEW_LINE> for i in range(partitions): <NEW_LINE> <INDENT> rank1_fiber...
_splitGeneric Takes the current fiber and splits it according to the boundaries defined by splitter(). The result is a new rank (for paritions = 1) or two new ranks (for partitions > 1). rank2 - uppermost rank with one coordinate per partition only exists for partitions > 1 rank1 - middle rank with one coord...
625941e615baa723493c43c4
def save_message(self, sender, receiver, message): <NEW_LINE> <INDENT> key = self.get_message_key(sender, receiver, message) <NEW_LINE> self.instance.set(key, None, ex=5)
Store a key with ttl 5 seconds to check if duplicates are there :param sender: :param receiver:
625941e68da39b475bd653c4
def files_in_cmd_inject(self, step_cmd): <NEW_LINE> <INDENT> new_cmd_string = step_cmd <NEW_LINE> if self.check_pattern(step_cmd): <NEW_LINE> <INDENT> for obj in self.job['job']['files']['names']: <NEW_LINE> <INDENT> rep_str = '*{}*'.format(obj) <NEW_LINE> new_cmd_string = new_cmd_string.replace(rep_str, self.job_files...
Вставляет в строку cmd пути до файлов :param step_cmd: строка cmd :return: новую строку cmd
625941e60a50d4780f6672e1
def test_available_methods(app): <NEW_LINE> <INDENT> with app.test_client() as client: <NEW_LINE> <INDENT> res = client.get("/api/text/") <NEW_LINE> data = json.loads(res.data) <NEW_LINE> assert data['phonetic_blocks'] <NEW_LINE> assert res.status_code == 200
Check if the documentation is available.
625941e610dbd63aa1bd2fed
def get_app_tasks(self, app): <NEW_LINE> <INDENT> a1 = self.__mt.get_app(app) <NEW_LINE> return a1.tasks
Get a list of tasks for the apps
625941e656ac1b37e6264612
def argChecker(arg): <NEW_LINE> <INDENT> if isinstance(arg, unicode): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> arg = arg.encode(defaultEncoding) <NEW_LINE> <DEDENT> except UnicodeEncodeError: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> warnings.warn( "Argument strings and environment keys/values passed to "...
Return either a str or None. If the given value is not allowable for some reason, None is returned. Otherwise, a possibly different object which should be used in place of arg is returned. This forces unicode encoding to happen now, rather than implicitly later.
625941e6d53ae8145f87a6b3
def _merge_with_filt(self, m: Mapping) -> dict: <NEW_LINE> <INDENT> return {'$and': [self.filter, m]}
:param args: dictionaries that are valid mongo queries :return: >>> class Mock(MongoCollectionCollection): ... def __init__(self, filter): ... self.filter = filter >>> s = Mock(filter={'a': 3, 'b': {'$in': [1, 2, 3]}}) >>> s._merge_with_filt({'c': 'me'}) {'$and': [{'a': 3, 'b': {'$in': [1, 2, 3]}}, {'c': '...
625941e666673b3332b924dd
def __unicode__(self): <NEW_LINE> <INDENT> return unicode(self.__str__())
Gets unicode encoding of object.
625941e6091ae356686673a2
def newReferenceState(parent,name=CK.ReferenceState_s): <NEW_LINE> <INDENT> if (parent): CU.checkNode(parent) <NEW_LINE> node=CU.hasChildName(parent,name) <NEW_LINE> if (node is None): <NEW_LINE> <INDENT> CU.checkDuplicatedName(parent,name) <NEW_LINE> node=CU.newNode(name,None,[],CK.ReferenceState_ts,parent) <NEW_LINE>...
-ReferenceState node creation -ReferenceState 'newNode:N='*newReferenceState*'(parent:N,name:S)' Returns a new <node> representing a ReferenceState_t sub-tree. If a parent is given, the new <node> is added to the parent children list. chapter 12.1
625941e6baa26c4b54cb1567
def set_item_at(self, i, val): <NEW_LINE> <INDENT> self.DATA[i] = val
Set the i-th element of the data to the value 'val'
625941e6d4950a0f3b08c794
def show_summary(input_list=None): <NEW_LINE> <INDENT> global database_handler <NEW_LINE> length = database_handler.get_number_of_records() <NEW_LINE> data_summary = [] <NEW_LINE> if (input_list == None): <NEW_LINE> <INDENT> if (length == 0): <NEW_LINE> <INDENT> print() <NEW_LINE> print(text_debug("No records found")) ...
Display a summary of the entries in the database
625941e6566aa707497f49ae
def getDeviceInputBaseName(self, deviceInput): <NEW_LINE> <INDENT> base_name = ":".join(deviceInput.digital_device.name.split(":")[:3]) <NEW_LINE> return base_name
Builds the PV base name for the specified DeviceInput. The PV name of the DeviceInput is composed of <DeviceType.name> : <Device.area> : <Device.position> Example: PROF:GUNB:753 The full PV name for the DeviceInput requires the fourth field, which is given by the Channel associated with the DeviceInput. :type dev...
625941e65f7d997b87174ee7
def slateblue(self): <NEW_LINE> <INDENT> pass
Sets the color to be slateblue Example: slateblue = ptColor().slateblue()
625941e6b57a9660fec33cd6
def application(environ, start_response): <NEW_LINE> <INDENT> path = environ.get('PATH_INFO', '').lstrip('/') <NEW_LINE> for regex, callback in urls: <NEW_LINE> <INDENT> match = re.search(regex, path) <NEW_LINE> if match is not None: <NEW_LINE> <INDENT> environ['myapp.url_args'] = match.groups() <NEW_LINE> return callb...
The main WSGI application. Dispatch the current request to the functions from above and store the regular expression captures in the WSGI environment as `myapp.url_args` so that the functions from above can access the url placeholders. If nothing matches call the `not_found` function.
625941e65510c4643540f825
@pytest.fixture <NEW_LINE> def graph_cases(selenium, host): <NEW_LINE> <INDENT> return GraphCaseFactory(selenium=selenium, host=host)
Factory method that allows to draw preconfigured graphs and manipulate them with a series of helpful methods. :type selenium: selenium.webdriver.remote.webdriver.WebDriver :type host: qmxgraph.server.Host :rtype: GraphCaseFactory :return: Factory able to create cases.
625941e6287bf620b61d3ead
def __repr__(self) -> str: <NEW_LINE> <INDENT> return self._java_model.toString()
summary of model.
625941e6167d2b6e31218fe1
def get_channels(self, channelID='all'): <NEW_LINE> <INDENT> if str(channelID) == 'all': <NEW_LINE> <INDENT> channelID = np.arange(self._ND) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> channelID = np.array(channelID) <NEW_LINE> <DEDENT> if not self._parallel: <NEW_LINE> <INDENT> return [self._channels[i] for i in cha...
Detailed information for all/chosen channels
625941e610dbd63aa1bd2fee
def get_object(self): <NEW_LINE> <INDENT> pk = self.kwargs['pk'] <NEW_LINE> container = Container.objects.get(pk=pk) <NEW_LINE> return container
Return the specific chemical by its primary key ('pk').
625941e630c21e258bdfa8ed
def get_shabbos_times(self, zip: str = "07631", date: datetime.date = datetime.date.today()): <NEW_LINE> <INDENT> params = { "cfg": "json", "m": 42, "b": 18, "a": "on", "s":"on", "leyning": "off", "geo": "zip", "zip": zip, "gy": date.year, "gm": date.month, "gd": date.day, } <NEW_LINE> url = ENDPOINTS["shabbat"] <NEW_L...
Get shabbos times
625941e60c0af96317bb8633
def set_main_cats(category_dummies, main_cats): <NEW_LINE> <INDENT> sub_cats = set([y for _, x in main_cats.items() for y in x]) <NEW_LINE> sub_mask = category_dummies[sub_cats].any(axis=1) <NEW_LINE> sub = category_dummies[sub_mask] <NEW_LINE> for main_cat, sub_cats in main_cats.items(): <NEW_LINE> <INDENT> sub[main_c...
Add main categories to hierarchy dummies and return
625941e6fb3f5b602dac3ae3
def setup(self): <NEW_LINE> <INDENT> print("setup class:TestStuff")
Function setup
625941e6ad47b63b2c50a3cb
def read(self): <NEW_LINE> <INDENT> data = b'' <NEW_LINE> try: <NEW_LINE> <INDENT> read_ready, _, _ = select.select([self._device.fileno()], [], [], 0.5) <NEW_LINE> if len(read_ready) != 0: <NEW_LINE> <INDENT> data = filter_ad2prot_byte(self._device.read(1)) <NEW_LINE> <DEDENT> <DEDENT> except serial.SerialException as...
Reads a single character from the device. :returns: character read from the device :raises: :py:class:`~alarmdecoder.util.CommError`
625941e68e05c05ec3eea7c4
@register.assignment_tag <NEW_LINE> def get_resource(pk_or_path): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> filters = dict(pk=int(pk_or_path)) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> filters = dict(uri_path=pk_or_path) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> resource = Resource.objects.get_fr...
Get a resource from it's ID or path.
625941e66e29344779a62a5c
def neutralize_v4(mol): <NEW_LINE> <INDENT> match_found = pat_v3.Match(mol, matchvector_v4) <NEW_LINE> if match_found: <NEW_LINE> <INDENT> for match in matchvector_v4: <NEW_LINE> <INDENT> atom = mol.GetAtom(match[0]) <NEW_LINE> chg = atom.GetFormalCharge() <NEW_LINE> hcount = atom.GetImplicitHCount() <NEW_LINE> atom.Se...
Neutralize charges of +1 or -1
625941e6d58c6744b42580aa
def run(self, features): <NEW_LINE> <INDENT> hidden_inputs = features <NEW_LINE> hidden_outputs = self.activation_function(np.dot(hidden_inputs, self.weights_input_to_hidden)) <NEW_LINE> final_inputs = hidden_outputs <NEW_LINE> final_outputs = np.dot(final_inputs, self.weights_hidden_to_output) <NEW_LINE> return final...
Run a forward pass through the network with input features Arguments --------- features: 1D array of feature values
625941e6a4f1c619b28b047b
def align_transcriptome(fastq_file, pair_file, ref_file, data): <NEW_LINE> <INDENT> work_bam = dd.get_work_bam(data) <NEW_LINE> base, ext = os.path.splitext(work_bam) <NEW_LINE> out_file = base + ".transcriptome" + ext <NEW_LINE> if utils.file_exists(out_file): <NEW_LINE> <INDENT> data = dd.set_transcriptome_bam(data, ...
bwa mem with settings for aligning to the transcriptome for eXpress/RSEM/etc
625941e630c21e258bdfa8ee
def AddEdgeCurve(self,curve): <NEW_LINE> <INDENT> pass
AddEdgeCurve(self: Brep,curve: Curve) -> int Add a 3d curve used by the brep edges Returns: Index used to reference this geometry in the edge curve list
625941e6091ae356686673a3
@view_config(route_name="default", renderer="string") <NEW_LINE> def default(request): <NEW_LINE> <INDENT> print("unknown request,", request.method, request.url) <NEW_LINE> print(request.matchdict) <NEW_LINE> return
Debug function for dumping information about unknown requests
625941e655399d3f05588b03
def sortArrayByParity(self, A): <NEW_LINE> <INDENT> even_list = [] <NEW_LINE> odd_list = [] <NEW_LINE> for x in A: <NEW_LINE> <INDENT> if x % 2 == 0: <NEW_LINE> <INDENT> even_list.append(x) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> odd_list.append(x) <NEW_LINE> <DEDENT> <DEDENT> return even_list + odd_list
:type A: List[int] :rtype: List[int]
625941e66fece00bbac2db90
def showDialog(self, parent, wrap=2, section_wrap=2, style=None): <NEW_LINE> <INDENT> dialog, self.widgets = dialogFromOptions(parent, self.opts, self.groups, wrap=wrap, section_wrap=section_wrap, style=style) <NEW_LINE> return dialog
Auto create widgets for corresponding options and and return the dialog. Args: parent: parent frame wrap: wrap for internal widgets
625941e676d4e153a657ef7e
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, ODMcomplexTypeDefinitionProtocol): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.to_dict() == other.to_dict()
Returns true if both objects are equal
625941e62ae34c7f2600d57d
def serialize_to_dic(self): <NEW_LINE> <INDENT> dic = {} <NEW_LINE> dic['Packages'] = [self._pkg] <NEW_LINE> if self.icon: <NEW_LINE> <INDENT> ext_allowed = ('.png', '.svg', '.ico', '.xcf', '.gif', '.svgz') <NEW_LINE> if self.icon.endswith(ext_allowed): <NEW_LINE> <INDENT> dic['Icon'] = {'cached': self.icon} <NEW_LINE>...
Return a dic with all the properties
625941e621bff66bcd684d9a
def load_button_clicked(self): <NEW_LINE> <INDENT> options = QFileDialog.Options() <NEW_LINE> options |= QFileDialog.DontUseNativeDialog <NEW_LINE> fileName, _ = QFileDialog.getOpenFileName(self, "QFileDialog.getOpenFileName()", "", "All Files (*)", options=options) <NEW_LINE> self.canvas.show() <NEW_LINE> Events.data_...
Load button click event handler
625941e68a43f66fc4b544ad
def p_expression_number(t): <NEW_LINE> <INDENT> t[0] = t[1]
expression : NUMBER | FLOAT
625941e60383005118ecfa2d
def get_user_privileges(self, username): <NEW_LINE> <INDENT> params = { "f" : "json", "username" : username } <NEW_LINE> url = self._url + "/users/getPrivilege" <NEW_LINE> return self._con.post(path=url, postdata=params)
Returns the privilege associated with a user Input: username - name of the user Output: JSON message as dictionary
625941e630bbd722463cc214
def test_restore_compressed_disk_to(self, get_compressed_complete_backup, tmpdir): <NEW_LINE> <INDENT> backup = get_compressed_complete_backup <NEW_LINE> extract_dir = tmpdir.mkdir("extract") <NEW_LINE> dst_img = os.path.join(str(extract_dir), backup.disks["vda"]) <NEW_LINE> backup.restore_disk_to("vda", dst_img) <NEW_...
Test with a compressed backup
625941e63cc13d1c6d3c77c4
def test_create_basic_recipe(self): <NEW_LINE> <INDENT> payload = { 'title': 'Pizza', 'time_minutes': 10, 'price': 5.00 } <NEW_LINE> res = self.client.post(RECIPES_URL, payload) <NEW_LINE> self.assertEqual(res.status_code, status.HTTP_201_CREATED) <NEW_LINE> recipe = Recipe.objects.get(id=res.data['id']) <NEW_LINE> for...
Test creating recipe
625941e60fa83653e4657405
def is_full(self, row): <NEW_LINE> <INDENT> return all(item == '*' for item in row)
Returns whether or not a row is full
625941e6a8ecb033257d3518
def section_interface(buf, m, emit_printer): <NEW_LINE> <INDENT> check_kind(m, {"Machine"}) <NEW_LINE> section_interface_init(buf, m) <NEW_LINE> for op in operations(m): <NEW_LINE> <INDENT> section_interface_op(buf, m, op) <NEW_LINE> <DEDENT> if emit_printer: <NEW_LINE> <INDENT> buf.trace.out("Declaration of function r...
Generates the declaration of all externally visible elements of machine n: reference type, initialisation function, operation function. Input: - buf: a CodeBuffer object where the generated code is stored - n: AST root node of a machine - emit_printer: flag indicating if printing functions shall be produced Ext...
625941e6e5267d203edce0e3
def transform(self, trans): <NEW_LINE> <INDENT> clone = deepcopy(self) <NEW_LINE> for n in clone.iter_sections(): <NEW_LINE> <INDENT> n.points[:, 0:3] = trans(n.points[:, 0:3]) <NEW_LINE> <DEDENT> return clone
Return a copy of this neurite with a 3D transformation applied
625941e61f5feb6acb0c4f96