code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def compute_loss(y, tx, w): <NEW_LINE> <INDENT> error = y - np.dot(tx, w) <NEW_LINE> return 0.5 * np.mean(error ** 2)
Calculate the loss. You can calculate the loss using mse or mae.
625941b3627d3e7fe0d68c0d
def int_to_list(n: int, base: int=10) -> List[int]: <NEW_LINE> <INDENT> digit_list = [] <NEW_LINE> while n: <NEW_LINE> <INDENT> digit_list += [n % base] <NEW_LINE> n //= base <NEW_LINE> <DEDENT> return list(reversed(digit_list))
Returns a list of the digits of N.
625941b38a43f66fc4b53e29
def open_temp_file(prefix): <NEW_LINE> <INDENT> (fd, filename) = mkstemp( dir=CFG_TMPSHAREDDIR, prefix='prefix_' + time.strftime("%Y%m%d_%H%M%S_", time.localtime()) ) <NEW_LINE> file_out = os.fdopen(fd, "w") <NEW_LINE> logger.debug("Created temporary file %s" % filename) <NEW_LINE> return (file_out, filename)
Create a temporary file to write MARC XML in
625941b3baa26c4b54cb0ee3
def teardown_method(self, method): <NEW_LINE> <INDENT> self.client.close()
Teardoen method.
625941b34e4d5625662d419d
def should_inv_be_displayed(self): <NEW_LINE> <INDENT> if self.collected: <NEW_LINE> <INDENT> self.display_inventory()
Check if an inventory tile should be displayed
625941b34428ac0f6e5ba5b8
def add_attributes(item, item_source): <NEW_LINE> <INDENT> for name, value in item_source.attrs.iteritems(): <NEW_LINE> <INDENT> item.attrs.modify(name, value)
Add all the attrs from item_source as attributes in item, where item_source can be a group or a dataset.
625941b3925a0f43d2549c32
def __repr__(self): <NEW_LINE> <INDENT> return self.__urepr__().encode("utf-8")
__repr__ *must* return a str, not a unicode.
625941b3fff4ab517eb2f1f8
def add(self, est): <NEW_LINE> <INDENT> if isinstance(est, EstimatorConfig): <NEW_LINE> <INDENT> self.est_configs.append(est.get_est_args()) <NEW_LINE> <DEDENT> elif isinstance(est, dict): <NEW_LINE> <INDENT> self.est_configs.append(est) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise ValueError("Unknown estimator ...
Add an estimator to the auto growing cascade layer. :param est: :return:
625941b3cdde0d52a9e52df3
def subtract(numbers): <NEW_LINE> <INDENT> return numbers[0] - numbers[1]
Subtracts the 1..Nth numbers from the 0th one
625941b34e4d5625662d419e
def __init__(self, links: List['ProfileLink']) -> None: <NEW_LINE> <INDENT> self.links = links
Initialize a ProfileLinkList object. :param List[ProfileLink] links: List of links to a trusted profile.
625941b324f1403a92600931
def __bootstrap__(): <NEW_LINE> <INDENT> import sys <NEW_LINE> import core <NEW_LINE> import os <NEW_LINE> in_test = 'unittest' in sys.modules <NEW_LINE> try: <NEW_LINE> <INDENT> num_threads = int(os.getenv('OMP_NUM_THREADS', '1')) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> num_threads = 1 <NEW_LINE> <D...
Enable reading gflags from environment variables. Returns: None
625941b3099cdd3c635f0a1c
def main(): <NEW_LINE> <INDENT> def convert_file(in_file_name): <NEW_LINE> <INDENT> def get_out_file_name(in_file_name): <NEW_LINE> <INDENT> return Config.out_file_infix.join(os.path.splitext(in_file_name)) <NEW_LINE> <DEDENT> def convert_data_line(line): <NEW_LINE> <INDENT> line[0] = convert_utc_to_local_time_zone(lin...
top level entry function
625941b315fb5d323cde08c7
def CHI(self) -> str: <NEW_LINE> <INDENT> return f'{self.firstName} {self.lastName}, "{self.title}," {self.publication}, last modified {self.date}, {self.url}.'
Returns a Chicago Citation
625941b371ff763f4b54944d
def __init__(self, tmx_tileset): <NEW_LINE> <INDENT> self.name = tmx_tileset.name <NEW_LINE> self.tile_width, self.tile_height = tmx_tileset.tile_size <NEW_LINE> image_file = tmx_tileset.image.source <NEW_LINE> self.tile_gfx = assets.getImageList(image_file, tmx_tileset.column_count, tmx_tileset.row_count, False) <NEW_...
A collection of tiles.
625941b315baa723493c3d31
def __init__(self, id=None, name=None, organization=None, date_created=None, created_by=None, workflow_step_net_schemes=None, rates=None): <NEW_LINE> <INDENT> self._id = None <NEW_LINE> self._name = None <NEW_LINE> self._organization = None <NEW_LINE> self._date_created = None <NEW_LINE> self._created_by = None <NEW_LI...
NetRateScheme - a model defined in Swagger
625941b3e8904600ed9f1ce9
def wait_for_button(pin): <NEW_LINE> <INDENT> global received_signal <NEW_LINE> global roof_opened <NEW_LINE> global roof_closed <NEW_LINE> global roof_opening <NEW_LINE> global roof_closing <NEW_LINE> global next_possible_green_button_action <NEW_LINE> time.sleep(1) <NEW_LINE> while True: <NEW_LINE> <INDENT> while wir...
wait green button or signal
625941b34e696a04525c9214
def topKFrequent(self, nums, k): <NEW_LINE> <INDENT> dic = dict() <NEW_LINE> for num in nums: <NEW_LINE> <INDENT> if num in dic: <NEW_LINE> <INDENT> dic[num] += 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> dic[num] = 1 <NEW_LINE> <DEDENT> <DEDENT> dic_sorted = sorted(dic.items(), key=lambda item: item[1], reverse=Tr...
:type nums: List[int] :type k: int :rtype: List[int]
625941b3b5575c28eb68ddbc
def var(): <NEW_LINE> <INDENT> return Parse.next_token().if_type(['VAR']).expect('var')
parser for a single variable. Accepts a single token that is a variable.
625941b3507cdc57c6306a91
def auth_delete(method): <NEW_LINE> <INDENT> def wrapper(self, *args, **kwargs): <NEW_LINE> <INDENT> if self.current_user: <NEW_LINE> <INDENT> if is_prived(self.userinfo.role, ROLE_CFG['delete']): <NEW_LINE> <INDENT> return method(self, *args, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> kwd = { 'info': 'No ...
role for delete.
625941b34d74a7450ccd3f83
def test_not_authenticated(self): <NEW_LINE> <INDENT> response = self.app.get(self.url) <NEW_LINE> self.assertRedirects(response, "/?next=/contributor/evaluation/%s/edit" % TESTING_EVALUATION_ID)
Asserts that an unauthorized user gets redirected to the login page.
625941b323849d37ff7b2e52
def read_cpy(f, scale=1.): <NEW_LINE> <INDENT> surfs = OrderedDict() <NEW_LINE> for line in f: <NEW_LINE> <INDENT> line = [field.strip() for field in line.split(",")] <NEW_LINE> if not line: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> cmd = line.pop(0) <NEW_LINE> if cmd == "#": <NEW_LINE> <INDENT> pass <NEW_LINE> ...
reads cpy text file and returns a dict {name: [(points, triangles), ...]} for each name, a list of surfaces consisting of a points array and a (n,3) triangles array with indices into points * only triangles are supported * origin (TrapCenter or Center Point) is ignored * the TRAPELECTRODE_ in name is stripped
625941b31d351010ab8558e5
def test_set_fields(self): <NEW_LINE> <INDENT> base = self.base.copy() <NEW_LINE> mbase = base.view(mrecarray) <NEW_LINE> mbase = mbase.copy() <NEW_LINE> mbase.fill_value = (999999,1e20,'N/A') <NEW_LINE> mbase.a._data[:] = 5 <NEW_LINE> assert_equal(mbase['a']._data, [5,5,5,5,5]) <NEW_LINE> assert_equal(mbase['a']._mask...
Tests setting fields.
625941b360cbc95b062c6309
def start(self): <NEW_LINE> <INDENT> with self.userLock: <NEW_LINE> <INDENT> self.say(self.sentences["startup"]) <NEW_LINE> <DEDENT> self.detector = decoder.HotwordDetector(root + "/" + self.model, sensitivity=0.4) <NEW_LINE> self.detector.start(detected_callback=self.hotword_has_been_detected, interrupt_check=self.int...
Wrapper around snowboy's detector() :return:
625941b32eb69b55b151c669
def switch_off(self): <NEW_LINE> <INDENT> if self._visible: <NEW_LINE> <INDENT> self._visible = False <NEW_LINE> turtle.up() <NEW_LINE> turtle.setpos(self._x, self._y - self._r) <NEW_LINE> turtle.down() <NEW_LINE> c = turtle.pencolor() <NEW_LINE> turtle.pencolor(turtle.bgcolor()) <NEW_LINE> turtle.circle(self._r) <NEW_...
Робить коло невидимим на екрані
625941b3167d2b6e3121895e
def start(self, xmlSubPanel, boardConfiguration): <NEW_LINE> <INDENT> self.xmlSubPanel = xmlSubPanel <NEW_LINE> self.boardConfiguration = boardConfiguration <NEW_LINE> if self.comm.isConnected() == True: <NEW_LINE> <INDENT> telemetry = self.xml.find(xmlSubPanel + "/Telemetry").text <NEW_LINE> if telemetry != None: <NEW...
This method starts a timer used for any long running loops in a subpanel
625941b363f4b57ef0000eea
def add(self, vec2): <NEW_LINE> <INDENT> self.x += vec2.x <NEW_LINE> self.y += vec2.y <NEW_LINE> return Vec2(self.x, self.y)
This method is destructive! <returns tears in non-functional approach>
625941b38e71fb1e9831d575
def _end_selection(self, accel_group, acceleratable, keyval, modifier): <NEW_LINE> <INDENT> self.ui.action_selection.set_active(False)
End of the selection mode
625941b3b545ff76a8913be1
def test_delete_server_wait_for_deleted(self): <NEW_LINE> <INDENT> server = fakes.make_fake_server('9999', 'wily', 'ACTIVE') <NEW_LINE> self.register_uris([ self.get_nova_discovery_mock_dict(), dict(method='GET', uri=self.get_mock_url( 'compute', 'public', append=['servers', 'detail']), json={'servers': [server]}), dic...
Test that delete_server waits for the server to be gone
625941b3baa26c4b54cb0ee4
def wait_for_repetition(m): <NEW_LINE> <INDENT> prevnumber = m + 1 <NEW_LINE> while True: <NEW_LINE> <INDENT> number = random.randrange(m) <NEW_LINE> print(number, end=' ') <NEW_LINE> if number == prevnumber: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> prevnumber = number <NEW_LINE> <DEDENT> print() <NEW_LINE> return...
Repeatedly generates random integers in the range [0, m). Stops generating random integers when one is generated that is the same as the previous one. Returns that last generated integer. For example, if the random integers generated are (in order): 37 23 13 50 32 32 then 32 is returned. Precondition: m is a ...
625941b376d4e153a657e8f0
def summarise(self, field, maxlen=600, hl=('<b>', '</b>'), query=None): <NEW_LINE> <INDENT> highlighter = highlight.Highlighter(language_code=self._get_language(field)) <NEW_LINE> field = self.data[field] <NEW_LINE> results = [] <NEW_LINE> text = '\n'.join(field) <NEW_LINE> if query is None: <NEW_LINE> <INDENT> query =...
Return a summarised version of the field specified. This will return a summary of the contents of the field stored in the search result, with words which match the query highlighted. The maximum length of the summary (in characters) may be set using the maxlen parameter. The return value will be a string holding the...
625941b36fece00bbac2d4fb
def h_setlevel(self): <NEW_LINE> <INDENT> def is_all_mutex(layer): <NEW_LINE> <INDENT> for subgoalA, subgoalB in combinations(self.goal, 2): <NEW_LINE> <INDENT> if subgoalA in layer and subgoalB in layer: <NEW_LINE> <INDENT> if layer.is_mutex(subgoalA, subgoalB): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DE...
Calculate the set level heuristic for the planning graph The set level of a planning graph is the first level where all goals appear such that no pair of goal literals are mutex in the last layer of the planning graph. Hints ----- - See the pseudocode folder for help on a simple implementation - You can implement...
625941b30c0af96317bb7fa9
def get_num_seeds_peers(self): <NEW_LINE> <INDENT> if not self.lt_status or self.get_status() not in [DLSTATUS_DOWNLOADING, DLSTATUS_SEEDING]: <NEW_LINE> <INDENT> return 0, 0 <NEW_LINE> <DEDENT> total = self.lt_status.list_peers <NEW_LINE> seeds = self.lt_status.list_seeds <NEW_LINE> return seeds, total - seeds
Returns the sum of the number of seeds and peers. @return A tuple (num seeds, num peers)
625941b3d99f1b3c44c67360
def on_aprs_status(self, origframe, source, payload, via=None): <NEW_LINE> <INDENT> pass
APRS status packet (data type: >)
625941b315fb5d323cde08c8
def __init__( self, workers: Optional[List[Dict]] = list(), managers: Optional[Dict] = None ): <NEW_LINE> <INDENT> self._workerspecs = {doc['name']: doc for doc in workers} <NEW_LINE> self._workers = dict() <NEW_LINE> self.managers = managers if managers is not None else dict()
Initialize the specifications for the workers that are managed by this worker pool and the optional list of task managers for individual workflow steps. Parameters ---------- workers: list, default=list List of worker specifications. managers: dict, default=None Mapping from workflow step identifier to worker ...
625941b3d18da76e23532290
@commands.command(r'clearcache') <NEW_LINE> def clearcache(): <NEW_LINE> <INDENT> g.pafs = {} <NEW_LINE> g.streams = {} <NEW_LINE> dbg("%scache cleared%s", c.p, c.w) <NEW_LINE> g.message = "cache cleared"
Clear cached items - for debugging use.
625941b3b7558d58953c4cdc
def buckets(resource): <NEW_LINE> <INDENT> all_buckets = [] <NEW_LINE> for bucket in resource.buckets.all(): <NEW_LINE> <INDENT> all_buckets.append(bucket) <NEW_LINE> <DEDENT> return all_buckets
Return all available buckets object.
625941b3aad79263cf3907fb
def make_lookup(self, results): <NEW_LINE> <INDENT> return {r['category'].lower(): r for r in results}
Convert Trading API category list into a lookup table. Parameters ---------- results : list of dicts a `parse` result Returns ------- Category lookup table : dict Examples -------- >>> trading = Trading(sandbox=True) >>> response = trading.get_categories() >>> results = trading.parse(response.CategoryArray.Categ...
625941b355399d3f05588474
def choose_new_tile(key, board): <NEW_LINE> <INDENT> if NEW_TILE_STRATEGY == 'random': <NEW_LINE> <INDENT> return random_tile(board) <NEW_LINE> <DEDENT> elif NEW_TILE_STRATEGY == 'always2': <NEW_LINE> <INDENT> return always2_tile(board) <NEW_LINE> <DEDENT> elif NEW_TILE_STRATEGY == 'minmax_worst': <NEW_LINE> <INDENT> r...
selectionne la strategie a utiliser pour placer les tuiles
625941b330dc7b766590172b
def _init_table_dict_list(self): <NEW_LINE> <INDENT> if not self._information_schema_columns: <NEW_LINE> <INDENT> self._init_information_schema_columns() <NEW_LINE> <DEDENT> sql = "SELECT TABLE_NAME FROM information_schema.`TABLES` WHERE TABLE_SCHEMA='%s'" % ( self._database) <NEW_LINE> table_tuple = self.execute_query...
初始化表字典对象
625941b3091ae35668666d27
def __str__(self): <NEW_LINE> <INDENT> raise NotImplementedError()
Debug string
625941b363d6d428bbe442b7
def stringMerge(rawInputs,gtfFile,genoFile): <NEW_LINE> <INDENT> print ("\n#### Generating list of lib-specific assemblies to merge") <NEW_LINE> assemblyFile = 'mergelist.txt' <NEW_LINE> assemblyOut = open(assemblyFile,'w') <NEW_LINE> for aninput in rawInputs: <NEW_LINE> <INDENT> lib,ext,nthreads = aninput <N...
merge all output for stringtie from pheno file; first generate a merge list and then supply that for merging https://github.com/griffithlab/rnaseq_tutorial/wiki/Transcript-Assembly-Merge
625941b323e79379d52ee32a
@operation <NEW_LINE> def group(group, present=True, system=False, gid=None, state=None, host=None): <NEW_LINE> <INDENT> groups = host.get_fact(Groups) <NEW_LINE> is_present = group in groups <NEW_LINE> if not present and is_present: <NEW_LINE> <INDENT> yield 'groupdel {0}'.format(group) <NEW_LINE> groups.remove(group)...
Add/remove system groups. + group: name of the group to ensure + present: whether the group should be present or not + system: whether to create a system group System users: System users don't exist on BSD, so the argument is ignored for BSD targets. Examples: .. code:: python server.group( name='C...
625941b3c432627299f04a04
def total_meet_medals(details=False): <NEW_LINE> <INDENT> medalsa = Division.objects.exclude(event_award_count__lte=3). aggregate( num_divisions_indiv_other_places=Count('name'), indiv_other_place_medals=(Sum(F('event_award_count') * 6) - (Count('name') * 3 * 6)), ) <NEW_LINE> medalsb = Division.objects.exclude(all_...
For individual medals, count the number of awards we are giving in each division and multiply by the number of events For all around medals, count the number of awards we are giving in each division and subtract 3 for each division, as 1st-3rd place get trophies
625941b391f36d47f21ac2b5
def test_account_info(self): <NEW_LINE> <INDENT> from invenio_oauthclient.client import oauth <NEW_LINE> self.client.get(url_for("oauthclient.login", remote_app='orcid')) <NEW_LINE> self.assertEqual( account_info(oauth.remote_apps['orcid'], self.example_data), dict(external_id="0000-0002-1825-0097", external_method="or...
Test account info extraction.
625941b3d164cc6175782b0e
def run_game(self): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> self._check_events() <NEW_LINE> self.mario.update() <NEW_LINE> self._update_bullets() <NEW_LINE> self._update_enemies() <NEW_LINE> self._update_screen()
Main loop
625941b3c432627299f04a05
def acceptedPercent(self, lower, upper=None, msg=None): <NEW_LINE> <INDENT> return AcceptedPercent(lower, upper, msg)
acceptedPercent(tolerance, /, msg=None) acceptedPercent(lower, upper, msg=None) Wrapper for :meth:`accepted.percent`.
625941b3498bea3a759b9872
def train(train_data, test_data, net, loss, trainer, ctx, num_epochs, print_batches=None): <NEW_LINE> <INDENT> print("Start training on ", ctx) <NEW_LINE> if isinstance(ctx, mx.Context): <NEW_LINE> <INDENT> ctx = [ctx] <NEW_LINE> <DEDENT> for epoch in range(num_epochs): <NEW_LINE> <INDENT> train_loss, train_acc, n, m =...
Train a network
625941b3d53ae8145f87a03b
def word_count(filename): <NEW_LINE> <INDENT> word_count_dict = {} <NEW_LINE> with open(filename, 'r') as f: <NEW_LINE> <INDENT> for line in f: <NEW_LINE> <INDENT> words = line.split() <NEW_LINE> for word in words: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return word_count_dict
A function that returns a dictionary with tokens as keys and counts of how many times each token appeared as values in the file with the given filename. Inputs: filename - the name of a plaintext file Outputs: A dictionary mapping tokens to counts.
625941b34d74a7450ccd3f84
def get_drmaa_imformation(): <NEW_LINE> <INDENT> with drmaa.Session() as s: <NEW_LINE> <INDENT> print('A DRMAA object was created') <NEW_LINE> print('Supported contact strings: %s' % s.contact) <NEW_LINE> print('Supported DRM systems: %s' % s.drmsInfo) <NEW_LINE> print('Supported DRMAA implementations: %s' % s.drmaaImp...
Query the system.
625941b323849d37ff7b2e53
@app.route('/video_feed') <NEW_LINE> def video_feed(): <NEW_LINE> <INDENT> return Response(gen(cv2.VideoCapture(2)), mimetype='multipart/x-mixed-replace; boundary=frame')
Video streaming route. Put this in the src attribute of an img tag.
625941b3925a0f43d2549c33
def delete(self, room_name): <NEW_LINE> <INDENT> if room_name is None: <NEW_LINE> <INDENT> Room.drop_collection() <NEW_LINE> return 'no content', 204 <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> Room.objects.get(name=room_name).delete() <NEW_LINE> return 'no content', 204 <NEW_LINE> <DEDENT> except db.DoesNotExist: <NE...
Delete specified room.
625941b31b99ca400220a871
def genNewParticles(self, num_particles=100): <NEW_LINE> <INDENT> particles = np.random.rand(num_particles,2) <NEW_LINE> particles[:,0] *= self.img.shape[0] <NEW_LINE> particles[:,1] *= self.img.shape[1] <NEW_LINE> return particles.astype(int).tolist()
Generate a new set particles :return (numpy.array): Array of new particles
625941b316aa5153ce362238
def get_cdrom_attach_config_spec(client_factory, datastore, file_path, cdrom_unit_number): <NEW_LINE> <INDENT> config_spec = client_factory.create('ns0:VirtualMachineConfigSpec') <NEW_LINE> device_config_spec = [] <NEW_LINE> controller_key = 200 <NEW_LINE> virtual_device_config_spec = create_virtual_cdrom_spec(client_f...
Builds and returns the cdrom attach config spec.
625941b332920d7e50b27f8e
def queryDataRows(self, **options): <NEW_LINE> <INDENT> from .datarow import DataRow <NEW_LINE> return self._api.newApiCursor(DataRow, self.getBaseApiPath() + "/rows", options)
Queries data rows associated with this contact (in any data table). Arguments: - time_created (UNIX timestamp) * Filter data rows by the time they were created * Allowed modifiers: time_created[ne], time_created[min], time_created[max] - vars (dict) * Filter data rows by value...
625941b3e64d504609d74601
def solve(n=50): <NEW_LINE> <INDENT> return triangle_count(n)
For this problem, there appears to be 2 fundamental cases. All triangles that are not fundamental cases can be found from fundamental cases by rotation. A fundamental case will either: 1. have it's 90 degree angle on the origin. In this case, there are 3 possible rotations (including not rotating at a...
625941b3956e5f7376d70c3d
def fasta_parser(self, target_file): <NEW_LINE> <INDENT> target_handle = open(target_file, 'r') <NEW_LINE> verified_ids = set() <NEW_LINE> for lines in target_handle: <NEW_LINE> <INDENT> if lines.startswith(">"): <NEW_LINE> <INDENT> seqid = re.match("([^\s]+)", lines).group(0)[1:] <NEW_LINE> verified_ids.add(seqid) <NE...
Parses a FASTA file and retruns a set of found Accession numbers
625941b316aa5153ce362239
def create_vm(self, vcpu, ram, disk, name, network_uuid, os_image_uuid, cloud_config): <NEW_LINE> <INDENT> data = { "name": name, "memory_mb": ram * 1024, "num_vcpus": vcpu, "description": "", "num_cores_per_vcpu": 1, "vm_disks": [ { "is_cdrom": True, "is_empty": True, "disk_address": { "device_bus": "ide" } }, { "is_c...
Create Virtual Machine with specified configuration. This method call asynchronous operation and wait for it to report success or failure. :param int vcpu: Number of vCPUs for Virtual Machine. :param int ram: Size of RAM (GB) for Virtual Machine. :param int disk: Size of Disk (GB) for Virtual Machine. :param str name:...
625941b3f548e778e58cd33c
def get_items_with_key_prefix(items, prefix, strip_prefix=True, processors=()): <NEW_LINE> <INDENT> include = lambda k, v: k.startswith(prefix) <NEW_LINE> if strip_prefix: <NEW_LINE> <INDENT> prefix_len = len(prefix) <NEW_LINE> processors = (lambda k, v: (k[prefix_len:], v),) + processors <NEW_LINE> <DEDENT> filtered =...
Filter ``items`` to those with a key that starts with ``prefix``. ``items`` is typically a dict but can also be a sequence. See :func:`filter_items` for more on that.
625941b396565a6dacc8f496
def delete(self, guid): <NEW_LINE> <INDENT> return super().delete(id=guid)
A method to delete an CloudAccounts object. :param guid: A string representing the object GUID. :return response json
625941b32ae34c7f2600cef3
def test_from_theta(self): <NEW_LINE> <INDENT> riskfree = .01 <NEW_LINE> mean_v = .5 <NEW_LINE> kappa = 1.5 <NEW_LINE> eta = .1 <NEW_LINE> lmbd = .01 <NEW_LINE> lmbd_v = .5 <NEW_LINE> rho = -.5 <NEW_LINE> theta = [riskfree, mean_v, kappa, eta, rho, lmbd, lmbd_v] <NEW_LINE> param = HestonParam.from_theta(theta, measure=...
Test from theta.
625941b30c0af96317bb7faa
def test_decode_nibbles_fixed_partial() -> None: <NEW_LINE> <INDENT> spec = copy.deepcopy(iso8583.specs.default) <NEW_LINE> spec["t"]["data_enc"] = "ascii" <NEW_LINE> spec["p"]["data_enc"] = "ascii" <NEW_LINE> spec["2"]["data_enc"] = "ascii" <NEW_LINE> spec["2"]["len_enc"] = "ascii" <NEW_LINE> spec["2"]["len_type"] = 0...
Fixed field is provided partially
625941b37b180e01f3dc45c9
def extract_func_typedata(typedata, table): <NEW_LINE> <INDENT> func_typedata_split = typedata.split("&&&") <NEW_LINE> param_segment = func_typedata_split[0] <NEW_LINE> parameters = param_segment.split("---")[1:] <NEW_LINE> default_values = [] <NEW_LINE> for seg in func_typedata_split[1:]: <NEW_LINE> <INDENT> default_v...
Extract typedata of function Params ====== typedata (string) = Typedata of function in format "function---param1---param2---...&&&default_val1&&&... table (SymbolTable) = Symbol table Returns ======= parameters (list) = Parameter names default_values (list) = Default values
625941b3ab23a570cc24ff48
def dls(td): <NEW_LINE> <INDENT> td2 = [] <NEW_LINE> dd = [] <NEW_LINE> for i in range(0, len(td)): <NEW_LINE> <INDENT> td2.append((0.25/td[i])) <NEW_LINE> dd.append(0.5*np.exp(-1.0*td2[i])) <NEW_LINE> <DEDENT> sd = 0.5*sp.special.expn(1,td2) <NEW_LINE> return sd, dd
THS_DLS - Dimensionless drawdown of the Theis model Syntax: sd,dd = hp.ths.dls(td) Description: Calculates the dimensionless drawdown sd and the dimensionless derivative dd for a given dimensionless reduced time td/rd^2 See also: ths_lap
625941b3baa26c4b54cb0ee5
def get_vthr(self): <NEW_LINE> <INDENT> if self.vthr > 0: <NEW_LINE> <INDENT> thr = self.vthr <NEW_LINE> self.vthr = [] <NEW_LINE> for roc in self.dut.rocs(): <NEW_LINE> <INDENT> self.vthr.append(thr) <NEW_LINE> <DEDENT> self.logger.info('Using min VthrComp %s from config' %self.vthr) <NEW_LINE> return <NEW_LINE> <DEDE...
Find minimal VthrComp threshold for each ROC with Vcal = self.vcal
625941b3fbf16365ca6f5f84
def gfaks89(): <NEW_LINE> <INDENT> return _loadnan('gfaks89.dat')
Return Surface elevation measured at Gullfaks C 24.12.1989 Data summary ------------ Size : 39000 X 2 Sampling Rate : 2.5 Hz Device : EMI laser Source : STATOIL Format : ascii, c1: time c2: surface elevation Description ------------ The wave data was measure...
625941b356ac1b37e6263fa3
def __init__(self, type=None, name=None): <NEW_LINE> <INDENT> self._type = None <NEW_LINE> self._name = None <NEW_LINE> self.discriminator = 'type' <NEW_LINE> self.type = type <NEW_LINE> self.name = name
QACheckDtoV2 - a model defined in Swagger
625941b391af0d3eaac9b7d4
def consecutiveNumbersSum_v2(self, N): <NEW_LINE> <INDENT> count = 0 <NEW_LINE> for d in range(1, N + 1): <NEW_LINE> <INDENT> dsum = d * (d - 1) / 2 <NEW_LINE> nd = N - dsum <NEW_LINE> if nd <= 0: break <NEW_LINE> if nd % d == 0: count += 1 <NEW_LINE> <DEDENT> return count
:type N: int :rtype: int
625941b3925a0f43d2549c34
def onBrowseFolder(self, event): <NEW_LINE> <INDENT> widget = event.GetEventObject() <NEW_LINE> name = widget.GetName() <NEW_LINE> if name == "InputFiles": <NEW_LINE> <INDENT> infomessage = "Choose a folder containing the data:" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> infomessage = "Choose an output folder for th...
Browse for folders
625941b33539df3088e2e10c
def applyEdits(self, addFeatures=[], updateFeatures=[], deleteFeatures=None, gdbVersion=None, rollbackOnFailure=True): <NEW_LINE> <INDENT> editURL = self._url + "/applyEdits" <NEW_LINE> params = {"f": "json", 'rollbackOnFailure' : rollbackOnFailure } <NEW_LINE> if not gdbVersion is None: <NEW_LINE> <INDENT> params['gdb...
This operation adds, updates, and deletes features to the associated feature layer or table in a single call. Inputs: addFeatures - The array of features to be added. These features should be common.general.Feature objects, or they should be a common.general.Featur...
625941b37c178a314d6ef219
def is_point_blocked(self, p): <NEW_LINE> <INDENT> for obs in self.obstacles: <NEW_LINE> <INDENT> if obs.point_inside(p): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> return False
Determines if the point is blocked or not. p: The point to check. returns: True if the point is blocked by an obstacle, False otherwise.
625941b3dc8b845886cb52f5
def actor(self): <NEW_LINE> <INDENT> return utils.lib.zproc_actor(self._p)
return internal actor, useful for the polling if process died
625941b326068e7796caea99
def retrieve_positions(position_file): <NEW_LINE> <INDENT> position_lines = open(position_file, 'r').readlines() <NEW_LINE> positions = [line.split() for line in position_lines] <NEW_LINE> return positions
This function returns a list of strings in the right format representing the positions that will be read out. [spatialfrequency,xi,xf,y]. Args: position_file (str): The path of the position file. Returns: positions (list,str): List representing the positions that will be read.
625941b3cc0a2c11143dcc5a
def SetMaximumNumberOfIterations(self, *args): <NEW_LINE> <INDENT> return _ITKOptimizersPython.itkSPSAOptimizer_SetMaximumNumberOfIterations(self, *args)
SetMaximumNumberOfIterations(self, unsigned long _arg)
625941b3d8ef3951e32432ff
def testCheckForAutoconnect(self): <NEW_LINE> <INDENT> args = mock.MagicMock() <NEW_LINE> args.autoconnect = True <NEW_LINE> args.no_prompt = False <NEW_LINE> self.Patch(utils, "InteractWithQuestion", return_value="Y") <NEW_LINE> self.Patch(utils, "FindExecutable", return_value=None) <NEW_LINE> self.Patch(os.environ, "...
Test CheckForAutoconnect.
625941b3a05bb46b383ec5ef
def save_image(filename, image, metadata): <NEW_LINE> <INDENT> path = os.path.dirname(filename) <NEW_LINE> assert path == "" or os.path.exists(path), ("Invalid directory name") <NEW_LINE> assert isinstance(image, np.ndarray), ("image must be a numpy.ndarray") <NEW_LINE> assert len(image.shape) == 3, ("image must be an ...
Save an image Saves an image as a GeoTiff. Args: image: a numpy `ndarray` with array shape (H,W,D) metadata: object of class `Metadata` filename: `string` a valid system path Returns: None Raises: AssertionError
625941b3097d151d1a222c25
def testProxyGetProductRatePlanCharge(self): <NEW_LINE> <INDENT> pass
Test ProxyGetProductRatePlanCharge
625941b30383005118ecf3a6
def psirt_query(token): <NEW_LINE> <INDENT> url = 'https://api.cisco.com/security/advisories/cvrf/latest/10' <NEW_LINE> headers = { 'Accept': 'application/json', 'Authorization': 'Bearer ' + token, } <NEW_LINE> last_10_vulns = requests.get(url, headers=headers) <NEW_LINE> logger.info('query response code = ' + str(last...
Send required information to PSIRT API and return true if vulnerable? {"access_token":"blablablablabla","token_type":"Bearer","expires_in":3599} TODO: Add exception handling :return: bool
625941b34a966d76dd550dcd
def registerPlayer(name): <NEW_LINE> <INDENT> DB = connect() <NEW_LINE> cur = DB.cursor() <NEW_LINE> safe_name = bleach.clean(name) <NEW_LINE> cur.execute("""insert into players(player_name) values(%s)""",(safe_name,)) <NEW_LINE> DB.commit() <NEW_LINE> DB.close()
Adds a player to the tournament database. The database assigns a unique serial id number for the player. (This should be handled by your SQL database schema, not in your Python code.) Args: name: the player's full name (need not be unique).
625941b3377c676e91271f70
def __init__(self): <NEW_LINE> <INDENT> rospy.init_node('red_depth_node') <NEW_LINE> self.image_pub = rospy.Publisher('red_marked_image', Image, queue_size=10) <NEW_LINE> self.marker_pub = rospy.Publisher('red_marker', Marker, queue_size=10) <NEW_LINE> self.cv_bridge = CvBridge() <NEW_LINE> img_sub = message_filters.Su...
Construct the red-pixel finder node.
625941b3507cdc57c6306a93
def _import_record(self, record): <NEW_LINE> <INDENT> raise NotImplementedError
Import a record directly or delay the import of the record
625941b38e05c05ec3eea132
def train(hps, server): <NEW_LINE> <INDENT> images, labels = input_fn(True, FLAGS.train_data_path, FLAGS.batch_size, FLAGS.num_epochs) <NEW_LINE> model = resnet_model.ResNet(hps, images, labels, FLAGS.mode) <NEW_LINE> model.build_graph() <NEW_LINE> truth = tf.argmax(model.labels, axis=1) <NEW_LINE> predictions = tf.arg...
Training loop.
625941b34d74a7450ccd3f85
def rec_replace(in_str, old, new): <NEW_LINE> <INDENT> if old == new: <NEW_LINE> <INDENT> return in_str <NEW_LINE> <DEDENT> if old not in in_str: <NEW_LINE> <INDENT> return in_str <NEW_LINE> <DEDENT> return rec_replace(in_str.replace(old, new), old, new)
Recursively replace a string in a string
625941b3a17c0f6771cbde16
def show_possible_nodes(self): <NEW_LINE> <INDENT> possible_core_nodes = np.logical_and( self.steep_nodes, self.aspect_close_nodes) <NEW_LINE> figure(1) <NEW_LINE> gridshow.imshow_grid_at_node(self.grid, self.elevs) <NEW_LINE> figure(2) <NEW_LINE> gridshow.imshow_grid_at_node(self.grid, self.slopes) <NEW_LINE> figure(3...
Once the subsets by aspect and slope have been set, call this function to see both the whole elevation map, and the subset of nodes that will be searched.
625941b34527f215b584c21e
def TransitiveSecondaryParents(self, interface, propagate_event_target): <NEW_LINE> <INDENT> def walk(parents): <NEW_LINE> <INDENT> for parent in parents: <NEW_LINE> <INDENT> parent_name = parent.type.id <NEW_LINE> if IsDartCollectionType(parent_name): <NEW_LINE> <INDENT> result.append(parent_name) <NEW_LINE> continue ...
Returns a list of all non-primary parents. The list contains the interface objects for interfaces defined in the database, and the name for undefined interfaces.
625941b3009cb60464c63180
def lit_pix(self): <NEW_LINE> <INDENT> lit = 0 <NEW_LINE> for i in range(len(s.screen)): <NEW_LINE> <INDENT> for j in range(len(s.screen[0])): <NEW_LINE> <INDENT> if s.screen[i][j] == '#': <NEW_LINE> <INDENT> lit += 1 <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return lit
Count the number of lit pixels
625941b331939e2706e4cc33
def strip_tags(self): <NEW_LINE> <INDENT> return lib.strip_tags(self.content)
return content field with no html tags included
625941b34527f215b584c21f
def fetchMany(critic, user_ids=None, names=None): <NEW_LINE> <INDENT> import api.impl <NEW_LINE> assert isinstance(critic, api.critic.Critic) <NEW_LINE> assert (user_ids is None) != (names is None) <NEW_LINE> users = api.impl.user.fetchMany(critic, user_ids, names) <NEW_LINE> return users
Fetch many User objects with given user ids or names Exactly one of the 'user_ids' and 'names' arguments can be used. If the value of the provided 'user_ids' or 'names' argument is a set, the return value is a also set of User objects, otherwise it is a list of User objects, in the same order as the argument sequence...
625941b36aa9bd52df036b64
def make_dict(cir_def,element): <NEW_LINE> <INDENT> e = element <NEW_LINE> volt_dict = {} <NEW_LINE> volt_names = [one_port_element(line).tokens[0] for line in cir_def if one_port_element(line).tokens[0][0].lower()== e] <NEW_LINE> for ind,name in enumerate(volt_names): <NEW_LINE> <INDENT> volt_dict[name] = ind <NEW_LIN...
Makes a dictionary for each component of the particular type of element
625941b3167d2b6e31218960
def __save_ro_album_artwork(self, data, album): <NEW_LINE> <INDENT> filename = self.get_album_cache_name(album) + ".jpg" <NEW_LINE> store_path = self._STORE_PATH + "/" + filename <NEW_LINE> self._save_pixbuf_from_data(store_path, data) <NEW_LINE> self.clean_album_cache(album) <NEW_LINE> GLib.idle_add(self.album_artwork...
Save artwork for a read only album @param data as bytes @param album as Album
625941b38e71fb1e9831d577
def __init__(self, directory, channels=None, defaultMode=None, systemRotateLength=1000000): <NEW_LINE> <INDENT> self._directory = directory <NEW_LINE> self._system_logger = logfile.LogFile( 'system.logs', directory, systemRotateLength, defaultMode) <NEW_LINE> self._channel_loggers = {} <NEW_LINE> for channel_name in ch...
Creates one L{DailyFileLogger} logger for each channel in the list, and one L{twisted.python.logfile.LogFile} (which rotates based on the length of the file) for system messages. @param directory: path where all the log files should go @type directory: C{str} @param channels: a list of channel names @type channels: C...
625941b3aad79263cf3907fc
def get_words_in_creator_names(df, creator_column): <NEW_LINE> <INDENT> creators = list(set(df[creator_column].tolist())) <NEW_LINE> words_in_creator_names = [str(creator).split(' ') for creator in creators] <NEW_LINE> words_in_creator_names = [item for sublist in words_in_creator_names for item in sublist] <NEW_LINE> ...
Filters out creator names from words --> see filter_title_words()
625941b321a7993f00bc7aaa
def main(): <NEW_LINE> <INDENT> logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') <NEW_LINE> if len(sys.argv) != 2: <NEW_LINE> <INDENT> logger.critical("Pass the script one directory") <NEW_LINE> sys.exit(1) <NEW_LINE> <DEDENT> basedir = sys.argv[1] <NEW_LINE> for filepath in datastore_filepa...
Main method, called when you run the script.
625941b394891a1f4081b869
def display(self, new_file = False, done_message = None): <NEW_LINE> <INDENT> if new_file: <NEW_LINE> <INDENT> self.output_labels() <NEW_LINE> self._stdout.write(self.ANSI_save_cursor_pos) <NEW_LINE> self._stdout.flush() <NEW_LINE> return <NEW_LINE> <DEDENT> if not (new_file or done_message) and not self._display_neede...
display(new_file = False[/True], done_message = None)
625941b3d164cc6175782b0f
def on_train_begin(self, logs=None, **kwargs): <NEW_LINE> <INDENT> logs = logs or {} <NEW_LINE> for logger in self.loggers: <NEW_LINE> <INDENT> logger.on_train_begin(logs, **kwargs)
At the start of training Args: logs: dictionary of logs
625941b36fece00bbac2d4fd
def test_api_challenge_get_flags_non_admin(): <NEW_LINE> <INDENT> app = create_kmactf() <NEW_LINE> with app.app_context(): <NEW_LINE> <INDENT> gen_challenge(app.db) <NEW_LINE> with app.test_client() as client: <NEW_LINE> <INDENT> r = client.get("/api/v1/challenges/1/flags", json="") <NEW_LINE> assert r.status_code == 4...
Can a user get /api/v1/challenges/<challenge_id>/flags if not admin
625941b35510c4643540f1bc
def contentor(generator): <NEW_LINE> <INDENT> for page in generator.pages: <NEW_LINE> <INDENT> if page.summary == page.content: <NEW_LINE> <INDENT> page.get_summary = lambda disable: '' <NEW_LINE> <DEDENT> if hasattr(page, 'image') and hasattr(page, 'type') and page.type.lower() == 'team': <NEW_LINE> <INDENT> image_des...
Suppress page summary, if none at all.
625941b32eb69b55b151c66c
def is_version_newer(semver1, semver2): <NEW_LINE> <INDENT> semver1 = tuple(map(int, (re.sub("[^0-9\.]", "", semver1).split(".")))) <NEW_LINE> semver2 = tuple(map(int, (re.sub("[^0-9\.]", "", semver2).split(".")))) <NEW_LINE> return semver1 >= semver2
Compares version strings and checks if the semver1 is newer than semver2. :returns: True if semver1 is latest or matches semver2, False otherwise.
625941b385dfad0860c3ac1b
def api_update(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> result = self._api_frontend.send(endpoint='Frontend/GetStatus', opts={'timeout': 1}) <NEW_LINE> if list(result.keys())[0] in ['Abort', 'Warning']: <NEW_LINE> <INDENT> self._volume['control'] = False <NEW_LINE> if self._ping_host(): <NEW_LINE> <INDENT> s...
Use the API to get the latest status.
625941b3e64d504609d74602
def test_uninstall_raise(self): <NEW_LINE> <INDENT> mock_hana_inst = MagicMock() <NEW_LINE> mock_hana_inst.uninstall.side_effect = hanamod.hana.HanaError( 'hana error' ) <NEW_LINE> mock_hana = MagicMock(return_value=mock_hana_inst) <NEW_LINE> with patch.object(hanamod, '_init', mock_hana): <NEW_LINE> <INDENT> with pyte...
Test uninstall method - raise
625941b3507cdc57c6306a94
def get_next_state(self, a, i): <NEW_LINE> <INDENT> cs = self.states[i] <NEW_LINE> ac = self.dcoords(a) <NEW_LINE> ns = cs + ac <NEW_LINE> ns = tuple(ns) <NEW_LINE> if self.is_state(ns): <NEW_LINE> <INDENT> return self.state_index(ns) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return i
Fast next state computation for deterministic models.
625941b39b70327d1c4e0b96