code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def getCmsswBase(self): <NEW_LINE> <INDENT> return self["CMSSW_BASE"]
Determine the CMSSW base (user) directory
625941d1099cdd3c635f0de3
def naked_twins(values): <NEW_LINE> <INDENT> naked_twins_values = dict() <NEW_LINE> for unit in unitlist: <NEW_LINE> <INDENT> unit_value_dict = dict() <NEW_LINE> for box in unit: <NEW_LINE> <INDENT> box_value = values[box] <NEW_LINE> if box_value in unit_value_dict.keys(): <NEW_LINE> <INDENT> unit_value_dict[box_value]...
Eliminate values using the naked twins strategy. Args: values(dict): a dictionary of the form {'box_name': '123456789', ...} Returns: the values dictionary with the naked twins eliminated from peers.
625941d1be8e80087fb20dca
def generate_resource_response(self, request, uri, headers): <NEW_LINE> <INDENT> headers["content-type"] = "application/json" <NEW_LINE> path = filter(lambda x: x not in ["api", ""], request.path.split('/')) <NEW_LINE> resource = path[0] <NEW_LINE> if request.method == "GET": <NEW_LINE> <INDENT> _items = self.get_resou...
Generate a response for a resource, support all methods, except HEAD.
625941d1925a0f43d254a000
def test_separators(self, driver, focus_click: bool): <NEW_LINE> <INDENT> SEPARATOR_KEYS = ["DECIMAL", "SEPARATOR"] <NEW_LINE> SEPARATORS = ".," <NEW_LINE> if focus_click == True: <NEW_LINE> <INDENT> self.form_field.click() <NEW_LINE> <DEDENT> for key in SEPARATOR_KEYS: <NEW_LINE> <INDENT> getattr(driver.press, key)() ...
" Template function for testing separator key presses.
625941d1f8510a7c17cf9884
def bmcReset(host, args, session): <NEW_LINE> <INDENT> if checkFWactivation(host, args, session): <NEW_LINE> <INDENT> return ("BMC reset control disabled during firmware activation") <NEW_LINE> <DEDENT> if(args.type == "warm"): <NEW_LINE> <INDENT> print("\nAttempting to reboot the BMC...:") <NEW_LINE> url="https://"+ho...
controls resetting the bmc. warm reset reboots the bmc, cold reset removes the configuration and reboots. @param host: string, the hostname or IP address of the bmc @param args: contains additional arguments used by the bmcReset sub command @param session: the active session to use @param args.json: boolean, if this f...
625941d1d6c5a102081441d4
def test_single_event(self, sample): <NEW_LINE> <INDENT> original_event = copy.deepcopy(sample) <NEW_LINE> if self.local_or_api == 'local': <NEW_LINE> <INDENT> transformed_event = self.code_package.transform(sample) <NEW_LINE> <DEDENT> elif self.local_or_api == 'api': <NEW_LINE> <INDENT> output = self.api.test_code_eng...
Tests a single event using the local code and pretty prints the before and after dictionaries to the console :param sample: A single sample event dictionary :return: The output dictionary
625941d110dbd63aa1bd2d2c
def insert_snp500_symbols(db, symbols): <NEW_LINE> <INDENT> column_str = "ticker, instrument, name, sector, currency, created_date, last_updated_date" <NEW_LINE> insert_str = ("%s, " * 7)[:-2] <NEW_LINE> final_str = "INSERT INTO symbol (%s) VALUES (%s)" % (column_str, insert_str) <NEW_LINE> print (final_str, len(symbol...
Insert the S&P500 symbols into the MySQL database.
625941d156ac1b37e6264355
def apply_replacements_list(string_buffer, replacements_list): <NEW_LINE> <INDENT> for replacement in replacements_list: <NEW_LINE> <INDENT> replacement_from, replacement_to = replacement <NEW_LINE> replacement_from = legacy.bytes(replacement_from) <NEW_LINE> replacement_to = legacy.bytes(replacement_to) <NEW_LINE> str...
Applies a list of replacements to the provided string buffer. :type string_buffer: String :param string_buffer: The string to which the replacements are to be applied to. :type replacements_list: List :param replacements_list: The list of replacements to apply.
625941d107f4c71912b1160b
def run(self, test_verbosity=0, expand_verbosity=0, tracevar=None, timeit=False): <NEW_LINE> <INDENT> if self.csp.report: <NEW_LINE> <INDENT> print('Running solver for {}'.format(self.csp)) <NEW_LINE> <DEDENT> if timeit: <NEW_LINE> <INDENT> t1 = time.time() <NEW_LINE> <DEDENT> sol_generator = self.make_gen(test_verbosi...
Return all solutions.
625941d15fdd1c0f98dc03bc
@blueprint.route('/<int:recipe_id>/ingredients/') <NEW_LINE> def recipe_ingredients_get(recipe_id): <NEW_LINE> <INDENT> get_recipe(recipe_id) <NEW_LINE> ingredients_query = ( models.RecipeIngredients .select( models.RecipeIngredients.quantity, models.RecipeIngredients.measurement, models.Ingredient ) .join(models.Ingre...
List all the ingredients for recipe_id
625941d1bde94217f3682f78
def send(self): <NEW_LINE> <INDENT> success = False <NEW_LINE> response = None <NEW_LINE> if self._data: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> request_kwargs = self._prepare_request_kwargs() <NEW_LINE> request_kwargs.get("headers").update( self._hook.settings.get("custom_headers", {})) <NEW_LINE> public_domain =...
Sends data to external endpoint :return: bool
625941d1d8ef3951e32436c5
def name(self): <NEW_LINE> <INDENT> return _blocks_swig5.uchar_to_float_sptr_name(self)
name(uchar_to_float_sptr self) -> std::string
625941d1167d2b6e31218d1e
def init( environment: typing.Optional[Environment] = None, db_path: typing.Union[str, pathlib.Path, None] = None, color_logs: bool = True, create_database_if_missing: bool = True, reinit: bool = False, ) -> None: <NEW_LINE> <INDENT> global _init <NEW_LINE> if _init and not reinit: <NEW_LINE> <INDENT> logger.warning("i...
Initialize the environment by specifying whether you're operating in production or the sandbox. This prepares (but doesn't instantiate) the AWS MTurk client and specifies the database to use.
625941d19f2886367277aa15
def is_symm(state): <NEW_LINE> <INDENT> for i in range(1, len(state)): <NEW_LINE> <INDENT> if state[i][1] != state[i-1][1]: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> return True
check if the current state is vertically aligned
625941d13cc13d1c6d3c7502
def lambda_handler(event, context): <NEW_LINE> <INDENT> LOGGER.debug('Function ARN: %s', context.invoked_function_arn) <NEW_LINE> msgtext = None <NEW_LINE> try: <NEW_LINE> <INDENT> payload = decode_urlencoded(event['body']) <NEW_LINE> if 'token' not in payload or (payload['token'] != SLACK_VERIFICATION_TOKEN): <NEW_LIN...
Entry point for API Gateway
625941d1566aa707497f46ef
def test_resourceType_form(self): <NEW_LINE> <INDENT> form = ResourceTypeForm(data={}) <NEW_LINE> self.assertFalse(form.is_valid()) <NEW_LINE> form = ResourceTypeForm(data={'name': 'foo'}) <NEW_LINE> self.assertTrue(form.is_valid()) <NEW_LINE> form.save() <NEW_LINE> resourceType = ResourceType.objects.get() <NEW_LINE> ...
Test adding and editing resourceType form
625941d1a219f33f34628af1
def _spatial_setup(self, att, aggregate=False, desc=None, field_name=None, geo_field_type=None): <NEW_LINE> <INDENT> func = getattr(SpatialBackend, att, False) <NEW_LINE> if desc is None: desc = att <NEW_LINE> if not func: raise ImproperlyConfigured('%s stored procedure not available.' % desc) <NEW_LINE> procedure_args...
Performs set up for executing the spatial function.
625941d1009cb60464c63539
def get_absolute_url(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return reverse('finance_asset_view', args=[self.id]) <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> return ""
Returns absolute URL
625941d11f5feb6acb0c4cd8
def test_unwatch_GET_405(self): <NEW_LINE> <INDENT> self.client.login(username='rrosario', password='testpass') <NEW_LINE> response = get(self.client, 'questions.unwatch', args=[self.question.id]) <NEW_LINE> eq_(405, response.status_code)
Unwatch replies with HTTP GET results in 405.
625941d1d10714528d5ffe6c
def test_umount_image(self): <NEW_LINE> <INDENT> mock = MagicMock(return_value='A') <NEW_LINE> with patch.dict(img.__salt__, {'qemu_nbd.clear': mock}): <NEW_LINE> <INDENT> mock = MagicMock(return_value='B') <NEW_LINE> with patch.dict(img.__context__, {'img.mnt_mnt': mock}): <NEW_LINE> <INDENT> self.assertEqual(img.umou...
Test for Unmount an image mountpoint
625941d107d97122c4178a15
@pytest.mark.parametrize("t1", [0.6 + 0.5j, 0.0 + 1j, 2]) <NEW_LINE> @pytest.mark.parametrize("t2", [0.2j, 1.5]) <NEW_LINE> @pytest.mark.parametrize("onsite", [(1.2, -0.6), (3.5, 2)]) <NEW_LINE> @pytest.mark.parametrize("cutoff", [-1, 0.4, 1, 3, 10]) <NEW_LINE> def test_simple(t1, t2, onsite, cutoff, get_model, models_...
Check that cutting a small hopping produced the same model as constructing the model without that hopping.
625941d1f9cc0f698b140783
def __init__(self,user=None,passwd=None,db_name=None,table_name='',host='localhost',port=3306,charset='utf8'): <NEW_LINE> <INDENT> if user is None: <NEW_LINE> <INDENT> user,passwd,db_name,table_name,host,myport=self.readconfig_db() <NEW_LINE> <DEDENT> self.addnum=0 <NEW_LINE> self.modifynum=0 <NEW_LINE> self.col_index=...
初始化数据库,创建数据库对象,游标对象
625941d160cbc95b062c66cc
def __col_sel(self, pipeline, col): <NEW_LINE> <INDENT> if not pipeline: <NEW_LINE> <INDENT> return pipeline <NEW_LINE> <DEDENT> select_step = [('{}_select'.format(col), ColSelector(column=col))] <NEW_LINE> pipeline_steps = [('{}_{}'.format(col, name), step) for name, step in copy.deepcopy(pipeline.steps)] <NEW_LINE> r...
Prepends a column selector transform to a pipeline. :param pipeline: the pipeline to prepend to :param col: the column to select first :return: the modified pipeline object.
625941d1796e427e537b074f
def refresh_conf_rel(): <NEW_LINE> <INDENT> Config().configure() <NEW_LINE> Relaties().configure()
simpele functie om configuratie en relatie bestand opnieuw in te laden
625941d1046cf37aa974cecf
def making_tables_of_each_sub_and_hem(all_probs, subject_ids, hemispheres): <NEW_LINE> <INDENT> subjects = {} <NEW_LINE> for subject in subject_ids: <NEW_LINE> <INDENT> hemisphere = {} <NEW_LINE> for hem in hemispheres: <NEW_LINE> <INDENT> sub_and_hem = all_probs.loc[(hem, slice(None), slice(None), subject)] <NEW_LINE>...
Input: pandas dataframe table of all subjects sulcal relations, both hemispheres Retrieves information of each subject's and each hemisphere's probabilities, and creates a dataframe table per subject per hemisphere
625941d18a43f66fc4b541ed
def end_match(self, match_number, result): <NEW_LINE> <INDENT> connection = sqlite3.connect(self.db) <NEW_LINE> cur = connection.cursor() <NEW_LINE> match = self.find_match(match_number) <NEW_LINE> if not match: <NEW_LINE> <INDENT> connection.close() <NEW_LINE> return False <NEW_LINE> <DEDENT> result_1, result_2 = resu...
Ends the match by writing the results and setting the winning team :param match_number: number of the match in question :param result: the result between the two teams :return: True if succeeded, else False
625941d191af0d3eaac9bba2
def simplify(self): <NEW_LINE> <INDENT> steps = [] <NEW_LINE> if self._num == 0: <NEW_LINE> <INDENT> steps.append(0) <NEW_LINE> return steps <NEW_LINE> <DEDENT> if self._denom < 0: <NEW_LINE> <INDENT> n_frac = Fraction(-self._num, -self._denom) <NEW_LINE> steps.append(n_frac) <NEW_LINE> <DEDENT> gcd_ = gcd(abs(self._nu...
Simplify the fraction :returns: steps to simplify the fraction or the fraction if there is nothing to do
625941d166673b3332b9221a
def _get_booster_layer_trees(model: "Booster") -> Tuple[int, int]: <NEW_LINE> <INDENT> config = json.loads(model.save_config()) <NEW_LINE> booster = config["learner"]["gradient_booster"]["name"] <NEW_LINE> if booster == "gblinear": <NEW_LINE> <INDENT> num_parallel_tree = 0 <NEW_LINE> <DEDENT> elif booster == "dart": <N...
Get number of trees added to booster per-iteration. This function will be removed once `best_ntree_limit` is dropped in favor of `best_iteration`. Returns `num_parallel_tree` and `num_groups`.
625941d126068e7796caee68
def accuracy(y_true: np.ndarray, y_pred: np.ndarray) -> float: <NEW_LINE> <INDENT> return sklearn.metrics.accuracy_score(y_true, y_pred)
Calculates the accuracy of a classification model.
625941d1fb3f5b602dac381c
def forward(self, z): <NEW_LINE> <INDENT> if self.generator_type == 'DCGAN': <NEW_LINE> <INDENT> z = z.unsqueeze(2).unsqueeze(2) <NEW_LINE> <DEDENT> x = self.gen(z) <NEW_LINE> if self.generator_type == 'MLP': <NEW_LINE> <INDENT> x = x.reshape(-1, self.img_shape[0], self.img_shape[1], self.img_shape[2]) <NEW_LINE> <DEDE...
:param z: A batch of latent space samples of shape (N, latent_dim). :return: A batch of generated images of shape (N,C,H,W) which should be the shape which the Discriminator accepts.
625941d1e5267d203edcde25
def __compute_neighbors(positions): <NEW_LINE> <INDENT> delaunay = scipy.spatial.Delaunay(positions) <NEW_LINE> slices, delaunay_neighbors = delaunay.vertex_neighbor_vertices <NEW_LINE> neighbors = [] <NEW_LINE> for node, pos in enumerate(positions): <NEW_LINE> <INDENT> neighbors.append(list(delaunay_neighbors[slices[n...
Return a list of the neighbors of every antenna.
625941d1956e5f7376d70ff5
@check_mlist_private <NEW_LINE> def overview_pop_threads(request, mlist_fqdn): <NEW_LINE> <INDENT> mlist = get_object_or_404(MailingList, name=mlist_fqdn) <NEW_LINE> return render(request, "hyperkitty/fragments/overview_threads.html", { 'mlist': mlist, 'threads': mlist.popular_threads, "empty": _('No vote has been cast...
Return the threads with the most votes.
625941d1c4546d3d9de72bbd
def to_rst(self): <NEW_LINE> <INDENT> raise NotImplementedError()
Tranforms the object into ReStructured text
625941d176d4e153a657ecba
def dip_slip_from_shortening(fault_dict, slip_class='mle', _abs=True, param_map=param_map): <NEW_LINE> <INDENT> short_rate = fetch_slip_rate(fault_dict, 'shortening_rate', slip_class=slip_class, param_map=param_map) <NEW_LINE> dips = get_dip(fault_dict, defaults=defaults, param_map=param_map) <NEW_LINE> if np.isscalar(...
Calculates the fault's dip slip rate given the fault's shortening rate, geometry and rake. :param fault_dict: Dictionary containing the fault attributes and geometry :type fault_dict: dict :param slip_class: Magnitude of the slip rate (and associated parameters) to be used in the calculations. Possib...
625941d1eab8aa0e5d26dce1
def _run_validator(self, input: str) -> Optional[str]: <NEW_LINE> <INDENT> if self.validator is None: <NEW_LINE> <INDENT> logger.debug(f'No validator provided for "{self.name}"') <NEW_LINE> return None <NEW_LINE> <DEDENT> if self.validation_error_text is not None: <NEW_LINE> <INDENT> err = self.validation_error_text.fo...
Run validator if one was provided, if successful return None. Return the formatted validation error string otherwise.
625941d116aa5153ce362600
def load_config(self, config, qos=None): <NEW_LINE> <INDENT> self.load_discovery_data(config, qos) <NEW_LINE> data = config.get("thermostat", None) <NEW_LINE> if not data: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self.ambient_temp.load_config(data, 'ambient_temp_topic', 'ambient_temp_payload', qos) <NEW_LINE> sel...
Load values from a configuration data object. Args: config (dict: The configuration dictionary to load from. The object config is stored in config['thermostat']. qos (int): The default quality of service level to use.
625941d1d164cc6175782ed7
def tactical_scan(stocks, lock, sleep_time=600): <NEW_LINE> <INDENT> while market_open(): <NEW_LINE> <INDENT> lock.acquire() <NEW_LINE> debug_logger.debug("Lock acquired by tactical_scan()") <NEW_LINE> for stock in stocks['potential']: <NEW_LINE> <INDENT> if not stock.open: <NEW_LINE> <INDENT> stock.get_tactical_potent...
Scan the tactical timeframe data of each stock for potential, discard the stock if it shows no potential, then populate the standby set or buy set
625941d14e696a04525c95d4
def cosh(*args, **kwargs): <NEW_LINE> <INDENT> pass
Return the hyperbolic cosine of z.
625941d1b7558d58953c509c
def get_formants_fast_track(self, ft_index, step_index): <NEW_LINE> <INDENT> if self.formant_list is None: <NEW_LINE> <INDENT> self.init_formant_f() <NEW_LINE> <DEDENT> formant_step_shift = self.formant_step_shift_list[ft_index] <NEW_LINE> formant_step_count = self.formant_step_count_list[ft_index] <NEW_LINE> if (step_...
Computes point formant values at the point specified by formant time step index for Fast Track formant computation.
625941d13346ee7daa2b2ef5
def authenticate_redirect(self, callback_uri=None, ax_attrs=["name","email","language","username"]): <NEW_LINE> <INDENT> callback_uri = callback_uri or self.request.path <NEW_LINE> args = self._openid_args(callback_uri, ax_attrs=ax_attrs) <NEW_LINE> self.redirect(self._OPENID_ENDPOINT + "?" + urllib.urlencode(args))
Returns the authentication URL for this service. After authentication, the service will redirect back to the given callback URI. We request the given attributes for the authenticated user by default (name, email, language, and username). If you don't need all those attributes for your app, you can request fewer with ...
625941d1498bea3a759b9c38
def zCalcWakeTime10(): <NEW_LINE> <INDENT> buff = readPCF2129(0x03,7) <NEW_LINE> Seconds = bcdToDec(ord(buff[0]) & 0x7F) <NEW_LINE> Minutes = bcdToDec(ord(buff[1]) & 0x7F) <NEW_LINE> Hours = bcdToDec(ord(buff[2]) & 0x3F) <NEW_LINE> Days = bcdToDec(ord(buff[3]) & 0x3F) <NEW_LINE> DOW = bcdToDec(ord(buff[4]) & 0x07) <NEW...
Set the RTC INT to triger at the next 10 minute interval
625941d176e4537e8c3517fc
def set_begin_date(self, begin_date): <NEW_LINE> <INDENT> self.set_value_into_input_field(self.begin_date_inputbox_locator, begin_date)
Implementing set begin date functionality :param begin_date: :return:
625941d130c21e258bdfa627
def resync_share_replica(self, replica_id, expected_result=202, version=LATEST_MICROVERSION): <NEW_LINE> <INDENT> uri = 'share-replicas/%s/action' % replica_id <NEW_LINE> post_body = { 'resync': None } <NEW_LINE> body = json.dumps(post_body) <NEW_LINE> resp, body = self.post(uri, body, headers=EXPERIMENTAL, extra_heade...
Force an immediate resync of the replica.
625941d16aa9bd52df036f2e
def vid_media_mount(self): <NEW_LINE> <INDENT> lib = self.gethprestchifhandle() <NEW_LINE> lib.vid_media_mount.argtypes = [] <NEW_LINE> lib.vid_media_mount.restype = POINTER(c_ubyte) <NEW_LINE> ptr = lib.vid_media_mount() <NEW_LINE> data = ptr[:lib.size_of_embeddedMediaRequest()] <NEW_LINE> data = bytearray(data) <NEW_...
Operation to mount the gaius media partition
625941d13317a56b86939de0
@cli.command("stats", short_help="Show the stats for pkg memory") <NEW_LINE> @pass_context <NEW_LINE> def pkg_stats(ctx): <NEW_LINE> <INDENT> command_ctl(ctx, "pkg.stats", [])
Show the stats for pkg memory 
625941d163d6d428bbe44678
def get_random_word(dictionary, min_word_length=3, max_word_length=8): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> word = choice(dictionary) <NEW_LINE> if len(word) >= min_word_length and len(word) <= max_word_length: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> <DEDENT> return word
Returns a random word from the dictionary
625941d182261d6c526ab629
def _initialize_tests(self): <NEW_LINE> <INDENT> self.keystone_sentry = self.d.sentry['keystone'][0] <NEW_LINE> self.openstack_dashboard_sentry = self.d.sentry['openstack-dashboard'][0] <NEW_LINE> u.log.debug('openstack release val: {}'.format( self._get_openstack_release())) <NEW_LINE> u.log.debug('openstac...
Perform final initialization before tests get run.
625941d1bf627c535bc13358
def close(self): <NEW_LINE> <INDENT> self.cur.close() <NEW_LINE> self.conn.close()
Close the cursor and connection
625941d1099cdd3c635f0de4
def conv_str2int(str1): <NEW_LINE> <INDENT> if not str1: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> aux_dict = {key: value for value in range(10) for key in '0123456789'[value]} <NEW_LINE> if str1[0] == '-': <NEW_LINE> <INDENT> sign = -1 <NEW_LINE> str1 = str1[1:] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ...
>>> conv_int2str(0) '0' >>> conv_int2str(1e5) '100000' >>> conv_int2str(367) '367' >>> conv_int2str(-10) '-10'
625941d1ec188e330fd5a927
def singleNumber(self, nums): <NEW_LINE> <INDENT> t = {} <NEW_LINE> for i in nums: <NEW_LINE> <INDENT> if i in t: <NEW_LINE> <INDENT> t[i] += 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> t[i] = 1 <NEW_LINE> <DEDENT> <DEDENT> return [k for k, v in t.items() if v == 1]
:type nums: List[int] :rtype: List[int]
625941d1b5575c28eb68e18a
def pick(self): <NEW_LINE> <INDENT> p = randint(0, self.M-1) <NEW_LINE> return self.map[p] if p in self.map else p
:rtype: int
625941d15fcc89381b1e1849
def __init__( self, **opts ): <NEW_LINE> <INDENT> super(FabricTopo, self).__init__(**opts) <NEW_LINE> host1 = self.addHost('h1', mac='62:02:1a:00:b7:11', ip='172.16.1.11/24', defaultRoute='via 172.16.1.1') <NEW_LINE> host2 = self.addHost('h2', mac='62:02:1a:00:b7:12', ip='172.16.1.12/24', defaultRoute='via 172.16.1.1')...
Create fabric topo.
625941d145492302aab5e44d
def __load_current_patient_frames_into_generator(self): <NEW_LINE> <INDENT> self.patient_id = self.cleared_patients[self.patient_index] <NEW_LINE> self.patient_record = self.manifest[self.patient_id] <NEW_LINE> self.patient_type = self.patient_record[0][TUMOR_TYPE_LABEL] <NEW_LINE> uncleared_patient_frames = self.manif...
Private method to update current patient information based on patient_index
625941d13617ad0b5ed68081
def fill_interval(self, x0, x1, y, index): <NEW_LINE> <INDENT> video.fill_interval(x0, x1, y, index) <NEW_LINE> self.clear_text_area(x0, y, x1, y)
Fill a scanline interval in a solid attribute.
625941d163b5f9789fde726f
def printBoard(self): <NEW_LINE> <INDENT> assert type(self._board) == list, "board is not a list" <NEW_LINE> for alist in self._board: <NEW_LINE> <INDENT> assert type(alist) == list, "board list does not contain lists" <NEW_LINE> <DEDENT> for row in range(self._size): <NEW_LINE> <INDENT> for col in range(len(self._boar...
Prints the tic tac board The board's structure is a 2D list such that each nested list is a row on the tic tac toe board. Time Complexity: O(n^2) Space Complexity: O(1) Example: [[' ', 'X', ' '], ['O', 'X', 'O'], [' ', ' ', ' ']] Is printed as: | X | ----------- O | X | O ----------- | | Parameter board: t...
625941d121bff66bcd684adb
def __iter__(self): <NEW_LINE> <INDENT> return iter(self._rules)
Iterates over rules parsed by the object.
625941d1091ae356686670e6
def test_already_member(self): <NEW_LINE> <INDENT> self.browser_do_login('admin', '') <NEW_LINE> self.browser.go(self.portal.absolute_url() + '/request_ig_access_html') <NEW_LINE> self.assertTrue('You are already a member of this interest group' in self.browser.get_html())
Admin is already a member of the portal so it doesn't require an ig access
625941d1c4546d3d9de72bbe
def get_file_name(self): <NEW_LINE> <INDENT> return self.file_name
Returns the name of the destination file
625941d1a934411ee375181d
def test_double_run(self): <NEW_LINE> <INDENT> hand = [Card(1, 0), Card(1, 0), Card(2, 0), Card(5, 0)] <NEW_LINE> cut = Card(3, 3) <NEW_LINE> game = Game(hand, cut) <NEW_LINE> game.score() <NEW_LINE> assert game.run_score == 6
Test cards can be part of two runs
625941d18e05c05ec3eea4ff
def main_menu_choice(): <NEW_LINE> <INDENT> user_choice = int(input("\n1: Send a Thank You\n" "2: Generate a Report\n" "3: Send Letters to Everyone\n" "4: Exit the Mailroom\n" "Please enter your selection from the options above >> ")) <NEW_LINE> return user_choice
Display main menu and collect user input
625941d1091ae356686670e7
def get_all_fields(self): <NEW_LINE> <INDENT> fields = [] <NEW_LINE> for f in self._meta.fields: <NEW_LINE> <INDENT> fname = f.name <NEW_LINE> get_choice = 'get_'+fname+'_display' <NEW_LINE> if hasattr(self, get_choice): <NEW_LINE> <INDENT> value = getattr(self, get_choice)() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDEN...
Returns a list of all field names on the instance.
625941d182261d6c526ab62a
def freqfluence_flist(direc,file_re = '.*Filter=\d+_Fluence=(.+?)_data.csv', file_groupnames = ['fluence'], direction_used = True): <NEW_LINE> <INDENT> folders = os.listdir(direc) <NEW_LINE> miarray = [] <NEW_LINE> if direction_used: <NEW_LINE> <INDENT> folder_re = '^(\d+\.\d+)GHz_(.+?)' <NEW_LINE> <DEDENT> else: <NEW_...
Creates a multindexed Series of filepaths from a frequency fluence sweep folder
625941d1fbf16365ca6f6350
def ldosr_generator(h,rs=0.2,es=np.linspace(-1.,1.,100), delta=3e-2,nn=20,sector="electron",**kwargs): <NEW_LINE> <INDENT> (evals,vs) = h.get_eigenvectors(**kwargs,kpoints=False) <NEW_LINE> ds = np.array([(np.conjugate(v)*v).real for v in vs]) <NEW_LINE> del vs <NEW_LINE> g = h.geometry <NEW_LINE> def fun(r): <NEW_LINE...
Return a function that computes the LDOS as a function of the position
625941d1cdde0d52a9e531be
def test_recipe_radiation_gridbased_post(self): <NEW_LINE> <INDENT> pass
Test case for recipe_radiation_gridbased_post Create a new radiation object # noqa: E501
625941d1656771135c3eb9f9
def test_add_comment_enabled_when_not_mergeable(self): <NEW_LINE> <INDENT> bmp = self.factory.makeBranchMergeProposal( set_state=BranchMergeProposalStatus.REJECTED) <NEW_LINE> login_person(bmp.registrant) <NEW_LINE> menu = BranchMergeProposalContextMenu(bmp) <NEW_LINE> self.assertTrue(menu.add_comment().enabled)
It should be possible to comment on an unmergeable proposal.
625941d15166f23b2e1a52e3
@command('reopen') <NEW_LINE> def reopen(): <NEW_LINE> <INDENT> assert_operation('reopen') <NEW_LINE> with editor.maybe_writing('Add a comment?') as text: <NEW_LINE> <INDENT> params = text.get_params_for_comment() if text else {} <NEW_LINE> CURRENT_CASE.reopen(**params) <NEW_LINE> refresh()
Reopen the current ticket.
625941d191af0d3eaac9bba3
def supportedInterfases(self): <NEW_LINE> <INDENT> return STRING
Obligatory method that must be defined in Output Connector class. Informs Writer about kind of interface this connector implements. Connector should return one or combination of flags: STRING, OBJECT, LIST, ITERABLE. If is called by Writer before it pass any data to connector.
625941d17d847024c06be446
def random_sample(population, k): <NEW_LINE> <INDENT> assert 0 <= k <= len(population) <NEW_LINE> population_copy = population[:] <NEW_LINE> np.random.shuffle(population_copy) <NEW_LINE> return population_copy[0:k]
Return a k length list of the elements chosen from the population sequence.
625941d1e1aae11d1e749e41
def get_accounts_azure_cloud(self, cloud_account_features="CLOUD_NATIVE_PROTECTION"): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> query_name = "accounts_azure_cloud" <NEW_LINE> variables = { "cloud_account_features": cloud_account_features } <NEW_LINE> return self._query(query_name, variables) <NEW_LINE> <DEDENT> exce...
Retrieves Azure cloud account information from Polaris Args: cloud_account_features (str): Feature string to filter results Returns: dict: Details of Azure cloud accounts in Polaris Raises: RequestException: If the query to Polaris returned an error
625941d1adb09d7d5db6c919
def handle_vlans(self, command): <NEW_LINE> <INDENT> for vlan, cfg in command.items(): <NEW_LINE> <INDENT> vlan_cmd = { 'type': 'vlan', 'name': vlan, 'vlan_id': cfg.get('id'), 'vlan_link': cfg.get('link'), } <NEW_LINE> if 'mtu' in cfg: <NEW_LINE> <INDENT> vlan_cmd['mtu'] = cfg['mtu'] <NEW_LINE> <DEDENT> subnets = self....
v2_vlans = { 'eth0.123': { 'id': 123, 'link': 'eth0', 'dhcp4': True, } } v1_command = { 'type': 'vlan', 'name': 'eth0.123', 'vlan_link': 'eth0', 'vlan_id': 123, 'subnets': [{'type': 'dhcp4'}], }
625941d123e79379d52ee6ed
def testAvgReqLatency(looper, tconf, txnPoolNodeSet, sdk_wallet_client, sdk_pool_handle): <NEW_LINE> <INDENT> _, wallet_did = sdk_wallet_client <NEW_LINE> for i in range(5): <NEW_LINE> <INDENT> sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle, sdk_wallet_client, 1) <NEW_LINE> <DEDENT> for node in txnPo...
Checking if average latency is being set
625941d194891a1f4081bc34
def t400180_x0(actionbutton1=6180, flag10=1135, flag11=6000, flag12=6000, flag13=6000, flag14=6000): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> assert (not GetOneLineHelpStatus() and not IsTalkingToSomeoneElse() and not IsClientPlayer() and not IsPlayerDead() and not IsCharacterDisabled()) <NEW_LINE> assert (G...
State 0
625941d1627d3e7fe0d68fda
def test_throttle_multiple_threads(self): <NEW_LINE> <INDENT> throttle = ThrottleTest() <NEW_LINE> def test(): <NEW_LINE> <INDENT> with ThreadPool(4) as pool: <NEW_LINE> <INDENT> objs = (pool.apply_async(throttle.test_throttle) for x in range(4)) <NEW_LINE> return [obj.get() for obj in objs] <NEW_LINE> <DEDENT> <DEDENT...
Throttling works across threads
625941d1462c4b4f79d1d85b
def test_values_quadratic_basis(): <NEW_LINE> <INDENT> X, Y = sy.symbols('X Y') <NEW_LINE> triangle = np.array([ [0, 0], [1, 0], [0, 1] ]) <NEW_LINE> S = SplineSpace(triangle, 2) <NEW_LINE> for basis_num in range(12): <NEW_LINE> <INDENT> b_num = S.basis()[basis_num] <NEW_LINE> b_sym = polynomial_pieces(triangle, KNOT_M...
tests that the polynomial pieces and the numerical splines evaluate to the same value over all the subtriangles.
625941d1baa26c4b54cb12a8
def contact(request): <NEW_LINE> <INDENT> return render(request, template_name='adverts/contact.html')
Brand contact page
625941d1925a0f43d254a002
def _fix_global_ids(html): <NEW_LINE> <INDENT> html = re.sub('id="\d+"', 'id="###"', html) <NEW_LINE> global_id = 1 <NEW_LINE> while len(re.findall('id="###"', html)) > 0: <NEW_LINE> <INDENT> html = re.sub('id="###"', 'id="%s"' % global_id, html, count=1) <NEW_LINE> global_id += 1 <NEW_LINE> <DEDENT> return html
Auxiliary function for fixing the global_ids after reordering in _render_toc().
625941d1d6c5a102081441d6
def test_check_strategy(self, capsys): <NEW_LINE> <INDENT> strategy = CheckStrategy() <NEW_LINE> strategy.result('test_server_one', True, check='wal_level') <NEW_LINE> strategy.result('test_server_one', True, check='archive_mode') <NEW_LINE> assert ('', '') == capsys.readouterr() <NEW_LINE> assert strategy.has_error is...
Test correct values result :type capsys: pytest
625941d1d58c6744b4257dea
def get_all_subject_id_name_pairs(self): <NEW_LINE> <INDENT> subject_id_name_pairs_dict = {} <NEW_LINE> get_all_subject_ids_names_sql = "SELECT SubjectID,Subject FROM SubjectsDB " <NEW_LINE> self.cursor.execute(get_all_subject_ids_names_sql) <NEW_LINE> results = self.cursor.fetchall() <NEW_LINE> for row in results: <NE...
:return: a dict of all SubjectID:Subject pairs present in the SubjectsDB table (all the subjects in the db)
625941d176d4e153a657ecbb
def __init__(self, importer): <NEW_LINE> <INDENT> self.zip_pre = importer.archive + os.sep <NEW_LINE> self.loader = importer <NEW_LINE> if importer.prefix: <NEW_LINE> <INDENT> self.module_path = os.path.join(importer.archive, importer.prefix) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.module_path = importer.arc...
Create a metadata provider from a zipimporter
625941d110dbd63aa1bd2d2e
def __init__(self, name, interfaces, segmentation_types, agent_type=None, can_trunk_bound_port=False): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> self.interfaces = interfaces <NEW_LINE> self.segmentation_types = segmentation_types <NEW_LINE> self.agent_type = agent_type <NEW_LINE> self.can_trunk_bound_port = can_t...
Instantiate a trunk driver. :param name: driver name. :param interfaces: list of interfaces supported. :param segmentation_types: list of segmentation types supported. :param agent_type: agent type for the driver, None if agentless. :param can_trunk_bound_port: True if trunk creation is allowed for a bound parent por...
625941d16e29344779a6279b
def measure_under_midline( fl: xr.DataArray, mid: Polynomial, n_points: int = 100, thickness: float = 0.0, order=1, norm_scale=1, flatten=True, ) -> np.ndarray: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if thickness == 0: <NEW_LINE> <INDENT> xs, ys = mid.linspace(n=n_points) <NEW_LINE> fl = np.asarray(fl) <NEW_LINE>...
Measure the intensity profile of the given image under the given midline at the given x-coordinates. Parameters ---------- flatten norm_scale order the interpolation order fl The fluorescence image to measure mid The midline under which to measure n_points The number of points to measure under thicknes...
625941d1a4f1c619b28b01c1
def findDuplicates(self, nums): <NEW_LINE> <INDENT> res = [] <NEW_LINE> for num in nums: <NEW_LINE> <INDENT> index = abs(num) - 1 <NEW_LINE> if nums[index] < 0: <NEW_LINE> <INDENT> res.append(index + 1) <NEW_LINE> <DEDENT> nums[index] = -nums[index] <NEW_LINE> <DEDENT> return res
:type nums: List[int] :rtype: List[int]
625941d1baa26c4b54cb12a9
def p_newObjType(p): <NEW_LINE> <INDENT> global worldInstBool <NEW_LINE> global newWorld <NEW_LINE> id = p[2] <NEW_LINE> if procedures.findObj(id, programBlock): <NEW_LINE> <INDENT> data_error = { "type": "Objeto " + id + " contiene nombre de un World o Task", "line": p.lineno(2), "column": p.lexpos(2) + 1, } <NEW_LINE...
newObjType : TkObjType ids TkOf TkColor colors
625941d1eab8aa0e5d26dce2
def minCostClimbingStairs(self, cost): <NEW_LINE> <INDENT> result = [0] * (len(cost) + 1) <NEW_LINE> if len(cost) == 1: <NEW_LINE> <INDENT> return cost[0] <NEW_LINE> <DEDENT> if len(cost) == 2: <NEW_LINE> <INDENT> return cost[1] <NEW_LINE> <DEDENT> result[1] = cost[0] <NEW_LINE> result[2] = cost[1] <NEW_LINE> for i in ...
:type cost: List[int] :rtype: int
625941d131939e2706e4cff3
def intersection_tad(exon, list_tad): <NEW_LINE> <INDENT> exon_start = exon[1] <NEW_LINE> exon_stop = exon[2] <NEW_LINE> if exon_stop <= exon_start: <NEW_LINE> <INDENT> raise ValueError("The size of the exon %s if negative or nul" % exon[3]) <NEW_LINE> <DEDENT> res = [] <NEW_LINE> for line in list_tad: <NEW_LINE> <INDE...
Get the regions intersecting the current exons. :param exon: (list of data) list of data corresponding to an exon in a bed order. :param list_tad: (list of list of data) alist of line in a bed file containing tad :return: (list of str) list of intersecting region
625941d1be383301e01b560e
def test_population_db(self): <NEW_LINE> <INDENT> call_command('populate_db') <NEW_LINE> alias = Alias.objects.all() <NEW_LINE> self.assertIsNotNone(alias) <NEW_LINE> self.assertEqual(3, len(alias)) <NEW_LINE> self.assertIsNotNone(alias[0].alias)
Testing population db command
625941d1d8ef3951e32436c8
def as_dict(self): <NEW_LINE> <INDENT> sections = dict(self._sections) <NEW_LINE> for key in sections: <NEW_LINE> <INDENT> sections[key] = dict(self._defaults, **sections[key]) <NEW_LINE> sections[key].pop('__name__', None) <NEW_LINE> <DEDENT> return sections
Generate and return the configuration as a dictionary object
625941d14f88993c3716c1f1
def _get_dirty(self): <NEW_LINE> <INDENT> return self.obj == '' or self._last_save != self.ui.history.now
Whether or not the editor is matches saved data. This is True if there is no file path, or history is not at last save point.
625941d19f2886367277aa17
def conv3x3(in_planes, out_planes, stride=1): <NEW_LINE> <INDENT> return MetaConv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False)
3x3 convolution with padding
625941d1ac7a0e7691ed4255
def get_device(hass, values, **kwargs): <NEW_LINE> <INDENT> temp_unit = hass.config.units.temperature_unit <NEW_LINE> return ZWaveClimate(values, temp_unit)
Create Z-Wave entity device.
625941d1d10714528d5ffe6e
def test_baking_job_get(self): <NEW_LINE> <INDENT> url = reverse('baking') <NEW_LINE> response = self.client.get(url, {'job': 'aaa'}) <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_LINE> self.assertContains(response, '<h1>Baking Chapters</h1>') <NEW_LINE> self.assertContains(response, '<p id="user-count">C...
'job' GET request of the baking page should get the job status check page
625941d11f5feb6acb0c4cda
def method_overloads_by_name(methods): <NEW_LINE> <INDENT> method_counts = Counter(method['name'] for method in methods) <NEW_LINE> overloaded_method_names = set(name for name, count in method_counts.items() if count > 1) <NEW_LINE> overloaded_methods = [method for method in methods if method['name'] in overloaded_meth...
Returns generator of overloaded methods by name: [name, [method]]
625941d129b78933be1e5835
def __writeHeader(fd): <NEW_LINE> <INDENT> print( "<!DOCTYPE html>", "<html>", " <head>", " <title>Super Tableau 3000</title>", " <meta charset='utf-8' />", " <style>", " table { border-collapse: collapse; }", " td { border: solid; }", " h4, li { font-size:10px; }", " .empty { border: 0px; }", " </styl...
Write html header
625941d1b7558d58953c509d
def draw_lines(img: np.ndarray, lines: list): <NEW_LINE> <INDENT> height = img.shape[0] <NEW_LINE> if lines is not None: <NEW_LINE> <INDENT> for line in lines: <NEW_LINE> <INDENT> a = angle(line, height) <NEW_LINE> if 60 < a < 160: <NEW_LINE> <INDENT> x1, y1, x2, y2 = line <NEW_LINE> cv2.line(img, (x1, y1), (x2, y2), (...
Draw lines on image Args: img: image as numpy array lines: list of line coords Returns: image
625941d196565a6dacc8f855
def __init__(self, evnid): <NEW_LINE> <INDENT> self.id = evnid <NEW_LINE> self.name = evnid <NEW_LINE> self.source_code = None <NEW_LINE> try: <NEW_LINE> <INDENT> self._read() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self._create() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> raise
Constructor @param evnid: event id
625941d121a7993f00bc7e7b
def scroll_sel(self, sel): <NEW_LINE> <INDENT> perf = self._get_perf('scroll_sel', sel) <NEW_LINE> loc = self._get_element(sel).location_once_scrolled_into_view <NEW_LINE> self._executeJS('scroll.js', loc['x'], loc['y']) <NEW_LINE> perf.end()
Execute a selector scroll statement.
625941d163f4b57ef00012a1
def get_stp_brief_info_output_spanning_tree_info_spanning_tree_mode_stp_stp_root_bridge_hello_time(self, **kwargs): <NEW_LINE> <INDENT> config = ET.Element("config") <NEW_LINE> get_stp_brief_info = ET.Element("get_stp_brief_info") <NEW_LINE> config = get_stp_brief_info <NEW_LINE> output = ET.SubElement(get_stp_brief_in...
Auto Generated Code
625941d1566aa707497f46f2
def manage_existing(self, share, driver_options): <NEW_LINE> <INDENT> share_proto = share['share_proto'] <NEW_LINE> share_name = share['name'] <NEW_LINE> old_export_location = share['export_locations'][0]['path'] <NEW_LINE> pool_name = share_utils.extract_host(share['host'], level='pool') <NEW_LINE> share_url_type = se...
Manage existing share.
625941d1f548e778e58cd708
def _plot_distribution(z, lat, lev, fig, ax, figpath, titlestr, xstr, xl=None, xu=None, bins=None): <NEW_LINE> <INDENT> num_bins = 100 <NEW_LINE> if bins is None: <NEW_LINE> <INDENT> bins = np.linspace(np.percentile(z, .02), np.percentile(z, 99.98), num_bins+1) <NEW_LINE> <DEDENT> n = np.zeros((num_bins, lev.size)) <NE...
Plots a stack of histograms of log10(data) at all levels
625941d160cbc95b062c66ce
@app.route("/checkcode/<number>/<code>") <NEW_LINE> def checkCode(number, code): <NEW_LINE> <INDENT> originalCode = r.get("number:%s:code" % number) <NEW_LINE> if originalCode: <NEW_LINE> <INDENT> if originalCode == code: <NEW_LINE> <INDENT> r.delete("number:%s:code" % number) <NEW_LINE> return jsonify({"status": "suc...
checkCode(number, code) accepts a number and the code entered by the user and tells if the code entered for that number is correct or not
625941d18e05c05ec3eea500