code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def _run_command(self): <NEW_LINE> <INDENT> fullenv = dict() <NEW_LINE> for key, value in itertools.chain(os.environ.iteritems(), self.OPTS.env.iteritems(), self.env.iteritems()): <NEW_LINE> <INDENT> fullenv[key] = str(value) <NEW_LINE> <DEDENT> if sys.platform == 'win32': <NEW_LINE> <INDENT> preexec_fn = None <NEW_LIN... | Run the test command and get the result
This method sets environment options, then runs the executable. If the
executable isn't found it sets the result to skip. | 625941cecb5e8a47e48b7bd6 |
def testDeviceStatus(self): <NEW_LINE> <INDENT> model = artikcloud.models.device_status.DeviceStatus() | Test DeviceStatus | 625941ce4c3428357757c453 |
def exteriorPoint(self): <NEW_LINE> <INDENT> box = Box() <NEW_LINE> for p in self.points: <NEW_LINE> <INDENT> box.add(p) <NEW_LINE> <DEDENT> off = lambda: 1 - 2 * random() <NEW_LINE> l = box.len() <NEW_LINE> r = lambda i: box[0][i] + random() * l[i] + off() <NEW_LINE> p = self.project(Point(r(0), r(1), r(2))) <NEW_LINE... | Returns a random exterior point near the polygon. | 625941ce287bf620b61d3b8f |
def _clean_result(self, text): <NEW_LINE> <INDENT> text = re.sub('\s\s+', ' ', text) <NEW_LINE> text = re.sub('\.\.+', '.', text) <NEW_LINE> text = text.replace("'", "\\'") <NEW_LINE> return text | Remove double spaces, punctuation and escapes apostrophes. | 625941cebe8e80087fb20d6e |
def create_likelihood(self): <NEW_LINE> <INDENT> map_mak = (self.map_occ == 1) <NEW_LINE> tmp = np.array(np.where(self.map_occ == 1)) <NEW_LINE> mak_lst = [ (tmp[1][i],tmp[0][i]) for i in range(tmp[0].size)] <NEW_LINE> assert self.size_x == self.size_y, "May error!" <NEW_LINE> x, y = np.meshgrid(np.arange(0, self.size... | Just for validate the implementation in AMCL
May have more elegant way ... | 625941ce3d592f4c4ed1d199 |
def push(self, line): <NEW_LINE> <INDENT> self.buffer.append(line) <NEW_LINE> source = "\n".join(self.buffer) <NEW_LINE> more = self.runsource(source, self.filename) <NEW_LINE> if not more: <NEW_LINE> <INDENT> self.resetbuffer() <NEW_LINE> <DEDENT> return more | Push a line to the interpreter.
The line should not have a trailing newline; it may have
internal newlines. The line is appended to a buffer and the
interpreter's runsource() method is called with the
concatenated contents of the buffer as source. If this
indicates that the command was executed or invalid, the buffe... | 625941ce796e427e537b06f2 |
def test_default_id_count(self): <NEW_LINE> <INDENT> id = create_identity() <NEW_LINE> self.assertEqual(id.id_count, 1) | Identity object should have default ID of 1 | 625941ce82261d6c526ab5cb |
def simulate_rate_path(self, x0, T): <NEW_LINE> <INDENT> x = np.atleast_1d(x0) <NEW_LINE> for t in range(T): <NEW_LINE> <INDENT> yield x <NEW_LINE> x = self.A_hat @ x | Simulates the the sequence of employment and unemployent rates.
Parameters
------------
x0 : array
Contains initial values (e0,u0)
T : int
Number of periods to simulate
Returns
---------
x : iterator
Contains sequence of employment and unemployment rates | 625941ce5f7d997b87174bc4 |
def shift_plot(sss: Array, env_gen: Array, env_shf: Array, nsyn: float = 1 ) -> Figure: <NEW_LINE> <INDENT> fig, axs, _ = mem_plot(sss, nsyn, normal=env_gen, shifted=env_shf) <NEW_LINE> axs.set_xlim(1/sss[-1], 1/sss[0]) <NEW_LINE> axs.legend(loc="lower left") <NEW_LINE> mplt.clean_axes(axs) <NEW_LINE> return fig | Shifted optimisation plot.
Comparison of numerical optimisation of the normal and shifted problems.
Parameters
----------
sss : Array (T,)
Rate parameter of Laplace transform of SNR curve
env_gen : Array (T,)
Envelope from normal problem.
env_shf : Array (T,)
Envelope from shifted problem.
nsyn : float, o... | 625941cee5267d203edcddc9 |
def roll(self) -> int: <NEW_LINE> <INDENT> if self.sign == '-': <NEW_LINE> <INDENT> return -1 * randint(1, self.sides) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return randint(1, self.sides) | The act of rolling the Roller to produce a value.
:return: The rolled value
:rtype: int
:example:
>>> a = Dicer(6)
>>> a.roll()
4 | 625941ce26068e7796caee0b |
def get(self, uri, format='json', data=None, authentication=None, **kwargs): <NEW_LINE> <INDENT> content_type = self.get_content_type(format) <NEW_LINE> kwargs['HTTP_ACCEPT'] = content_type <NEW_LINE> if data is not None: <NEW_LINE> <INDENT> kwargs['data'] = data <NEW_LINE> <DEDENT> if authentication is not None: <NEW_... | Performs a simulated ``GET`` request to the provided URI.
Optionally accepts a ``data`` kwarg, which in the case of ``GET``, lets
you send along ``GET`` parameters. This is useful when testing
filtering or other things that read off the ``GET`` params. Example::
from bmga.t... | 625941ced164cc6175782e79 |
def __init__(self): <NEW_LINE> <INDENT> super(P2PBotnet, self).__init__( "P2P Botnet Communication (P2PBotnet)", "Injects P2P Botnet Communication", "Botnet communication") <NEW_LINE> self.update_params([ Parameter(self.PACKETS_LIMIT, IntegerPositive()), Parameter(self.ATTACK_DURATION, IntegerPositive()), Parameter(sel... | Creates a new instance of the Membership Management Communication. | 625941ce91f36d47f21ac61f |
def revealAllMines(self): <NEW_LINE> <INDENT> self.minefield_grid.revealAllMines() | Reveal all Mines on the board | 625941ce8e7ae83300e4b0f8 |
def _unequal_cov(self, starts): <NEW_LINE> <INDENT> bin_counts = self._fill_bins(starts) <NEW_LINE> mean_bin_count = sum(bin_counts) / len(bin_counts) <NEW_LINE> chi_test = _chi_test(bin_counts, mean_bin_count) <NEW_LINE> if chi_test / mean_bin_count > self.max_unequal: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDEN... | returns True if coverage of the site is too unequal (defined by max_unequal) | 625941ced486a94d0b98e271 |
def inherit(data): <NEW_LINE> <INDENT> if 'revisions' in data: <NEW_LINE> <INDENT> for revision in data['revisions']: <NEW_LINE> <INDENT> revision['id'] = '_:' + revision['origin'] + ':' + revision['id'] <NEW_LINE> if 'patch_mboxes' in revision: <NEW_LINE> <INDENT> revision['patchset_files'] = revision.pop('patch_mboxe... | Inherit data, i.e. convert data adhering to the previous version of
the schema to satisfy this version of the schema.
Args:
data: The data to inherit.
Will be modified in place.
Returns:
The inherited data. | 625941ceeab8aa0e5d26dc84 |
def check_target_label(y, target_label, sampling_type): <NEW_LINE> <INDENT> target_stats = dict(Counter(y)) <NEW_LINE> if isinstance(target_label, numbers.Integral): <NEW_LINE> <INDENT> if target_label in target_stats.keys(): <NEW_LINE> <INDENT> return target_label <NEW_LINE> <DEDENT> else: raise ValueError( f"The targ... | check parameter `target_label`. | 625941cedc8b845886cb5661 |
def permutePeptides(self, seed = None): <NEW_LINE> <INDENT> pass | Here to preserve the interface, but does nothing functionally different | 625941ce004d5f362079a45e |
def instance_id(self): <NEW_LINE> <INDENT> pass | Get this instance's id. | 625941ce94891a1f4081bbd5 |
def test_make_a_client_charge(self): <NEW_LINE> <INDENT> pass | Any trade can make a charge to another client user | 625941ce23849d37ff7b31bb |
def test_festivities_list_by_queryparam_start_date(self): <NEW_LINE> <INDENT> response = self.client.get( reverse("festivities-list"), {"start_date": "2021-02-13 20:40:26.744511-05"}, formal="json" ) <NEW_LINE> response_data = json.loads(response.content) <NEW_LINE> self.assertEqual(response_data["data"]["festivities"]... | Valid test to retrieve festivities filtered by queryparams start_date | 625941ced53ae8145f87a39c |
def decode(self, s, key, claims_cls=None, claims_options=None, claims_params=None): <NEW_LINE> <INDENT> if claims_cls is None: <NEW_LINE> <INDENT> claims_cls = JWTClaims <NEW_LINE> <DEDENT> key_func = create_key_func(key) <NEW_LINE> s = to_bytes(s) <NEW_LINE> dot_count = s.count(b'.') <NEW_LINE> if dot_count == 2: <NEW... | Decode the JWS with the given key. This is similar with
:meth:`verify`, except that it will raise BadSignatureError when
signature doesn't match.
:param s: text of JWT
:param key: key used to verify the signature
:param claims_cls: class to be used for JWT claims
:param claims_options: `options` parameters for claims_... | 625941ce6e29344779a6273d |
def delete_tags(FileSystemId=None, TagKeys=None): <NEW_LINE> <INDENT> pass | Deletes the specified tags from a file system. If the DeleteTags request includes a tag key that does not exist, Amazon EFS ignores it and doesn't cause an error. For more information about tags and related restrictions, see Tag Restrictions in the AWS Billing and Cost Management User Guide .
This operation requires pe... | 625941ce57b8e32f524835c7 |
def coupling_full (J, m, n): <NEW_LINE> <INDENT> return J / np.power(np.fabs(m-n), 3.0) if m-n != 0 else 0 | coupling between all molecules | 625941ce167d2b6e31218cc2 |
def globale_to_locale_n(self, gidx): <NEW_LINE> <INDENT> return -self.start_n + gidx | Convert globale array index to locale array index.
:type gidx: sequence of :obj:`int`
:param gidx: Globale index.
:rtype: :obj:`numpy.ndarray`
:return: Locale index. | 625941ce377c676e912722d4 |
def _get_states(self): <NEW_LINE> <INDENT> contact_state = np.zeros(len(self.link_ids)) <NEW_LINE> contacts = self.simulator.get_contact_points(body1=self.body_id1, body2=self.body_id2, link2_id=self.wrt_link) <NEW_LINE> for contact in contacts: <NEW_LINE> <INDENT> link_id = contact[3] <NEW_LINE> if link_id in self.lin... | Get the contact states. | 625941cec432627299f04d72 |
def __init__(self, client): <NEW_LINE> <INDENT> self.client = client <NEW_LINE> self.delay_time = 5 <NEW_LINE> self.name = platform.system() <NEW_LINE> self.release = platform.release() <NEW_LINE> self.version = platform.version() <NEW_LINE> self.cpu = platform.processor() <NEW_LINE> self.arch = platform.machine() | Initialize variables for SystemInfo.
Also on initial load, it's getting all information about the host system
Args:
client (discord.client.Client): Current client object | 625941cee8904600ed9f2058 |
def getSelf(self): <NEW_LINE> <INDENT> pass | Return the IPerson implementer that represents us. | 625941cea05bb46b383ec94d |
def check_invalid_index(): <NEW_LINE> <INDENT> return(str(output_str) == RESPONSE_NO_INDEX) | Returns true if index does not exist -- false otherwise. | 625941ce30c21e258bdfa5ca |
@app.route("/profile", methods=["GET"]) <NEW_LINE> def profile(): <NEW_LINE> <INDENT> google = OAuth2Session(client_id, token=session['oauth_token']) <NEW_LINE> return jsonify(google.get('https://www.googleapis.com/oauth2/v1/userinfo').json()) | Fetching a protected resource using an OAuth 2 token.
| 625941ce656771135c3eb99b |
def assertCheck(path, category): <NEW_LINE> <INDENT> message = ('Should check category "%s" for path "%s".' % (category, path)) <NEW_LINE> self.assertTrue(config.should_check(category, path)) | Assert that the given category should be checked. | 625941ce07d97122c41789b8 |
def bethe_findfill_zeroT(particles, orbital_e, hopping): <NEW_LINE> <INDENT> assert 0. <= particles <= len(orbital_e) <NEW_LINE> zero = lambda e: np.sum([bethe_filling_zeroT(e-e_m, t) for t, e_m in zip(hopping, orbital_e)]) - particles <NEW_LINE> return fsolve(zero, 0) | Return the fermi energy that correspond to the given particle quantity
in a semicircular density of states of a bethe lattice in a multi
orbital case that can be non-degenerate | 625941cee76e3b2f99f3a937 |
def resnet101_dcd(pretrained=False, **kwargs): <NEW_LINE> <INDENT> model = ResNet_dcd(Bottleneck_dy, [3, 4, 23, 3], **kwargs) <NEW_LINE> if pretrained: <NEW_LINE> <INDENT> model.load_state_dict(model_zoo.load_url(model_urls['resnet101'])) <NEW_LINE> <DEDENT> return model | Constructs a ResNet-101 model.
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet | 625941ce283ffb24f3c55a2d |
def cond_not_blank(s): <NEW_LINE> <INDENT> return None if s else "Please enter a response." | Accepts any non-blank input | 625941ceff9c53063f47c320 |
def _linear_ramp(vector, pad_tuple, iaxis, kwargs): <NEW_LINE> <INDENT> end_values = kwargs['end_values'][iaxis] <NEW_LINE> before_delta = ((vector[pad_tuple[0]] - end_values[0]) / float(pad_tuple[0])) <NEW_LINE> after_delta = ((vector[-pad_tuple[1] - 1] - end_values[1]) / float(pad_tuple[1])) <NEW_LINE> before_vector ... | Private function to calculate the before/after vectors for
pad_linear_ramp.
Parameters
----------
vector : ndarray
Input vector that already includes empty padded values.
pad_tuple : tuple
This tuple represents the (before, after) width of the padding
along this particular iaxis.
iaxis : int
The axis c... | 625941ce76e4537e8c35179f |
def get_animations(self): <NEW_LINE> <INDENT> return self.animations.all() | Renvoyer les instances d'animation de l'image | 625941ce5fcc89381b1e17ec |
def reduce(image, size, axis=1, efunc=energy_function, cfunc=compute_cost): <NEW_LINE> <INDENT> out = np.copy(image) <NEW_LINE> if axis == 0: <NEW_LINE> <INDENT> out = np.transpose(out, (1, 0, 2)) <NEW_LINE> <DEDENT> H = out.shape[0] <NEW_LINE> W = out.shape[1] <NEW_LINE> assert W > size, "Size must be smaller than %d"... | Reduces the size of the image using the seam carving process.
At each step, we remove the lowest energy seam from the image. We repeat the process
until we obtain an output of desired size.
Use functions:
- efunc
- cfunc
- backtrack_seam
- remove_seam
Args:
image: numpy array of shape (H, W, 3)
... | 625941ce24f1403a92600c92 |
def stream(self, network_access_profile=values.unset, limit=None, page_size=None): <NEW_LINE> <INDENT> limits = self._version.read_limits(limit, page_size) <NEW_LINE> page = self.page(network_access_profile=network_access_profile, page_size=limits['page_size'], ) <NEW_LINE> return self._version.stream(page, limits['lim... | Streams FleetInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param unicode network_access_profile: The SID or unique name of the Network Acces... | 625941cee64d504609d7496c |
def test_generateByteCode_will_generate_code_for_push_the_working_register_into_the_stack(self): <NEW_LINE> <INDENT> lexer = LexerStateMachine(' x = 5 ', self.context) <NEW_LINE> parser = Parser(lexer, self.manager) <NEW_LINE> self.manager.setParser(parser) <NEW_LINE> token = parser.parse(0) <NEW_LINE> self.information... | =(max=2,min=2)
/ x(max=1,min=1) 5 (max=1,min=1) | 625941cec4546d3d9de72b61 |
def _send_event_to_slave(self, name, event): <NEW_LINE> <INDENT> slave_protocol = self._slave_protocols.get(name) <NEW_LINE> if slave_protocol is None: <NEW_LINE> <INDENT> raise InstrumentProtocolException('Attempted to send event to non-existent protocol: %s' % name) <NEW_LINE> <DEDENT> slave_protocol._async_raise_fsm... | Send an event to a specific protocol
@param name: Name of slave protocol
@param event: Event to be sent | 625941ce507cdc57c6306e08 |
def f(x): <NEW_LINE> <INDENT> return x * x | 返回参数平方
:param x: 底数
:return: 平方数 | 625941ce92d797404e3042b6 |
def traverse(entity): <NEW_LINE> <INDENT> if str(type(entity)) != "<type 'module'>": <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if entity.__name__ not in ['dl', 'sys']: <NEW_LINE> <INDENT> f.write("pydoc -w %s\n" % entity.__name__) <NEW_LINE> if '__all__' in dir(entity): <NEW_LINE> <INDENT... | Traverse a module and create pydoc invocations for it
and any embedded modules. | 625941ced4950a0f3b08c47b |
def box_volume_UPS(a=13, b=11, c=2): <NEW_LINE> <INDENT> return a * b * c | Returns the volume of a box with edge lengths a, b and c
Inputs should be provided in inch, and the output is
expressed in inch^3 | 625941ced10714528d5ffe10 |
def get_load_cell_range(self): <NEW_LINE> <INDENT> load_cell_type = self.read_load_cell_type() <NEW_LINE> try: <NEW_LINE> <INDENT> return self.range_lookup_table[load_cell_type] <NEW_LINE> <DEDENT> except KeyError as ke: <NEW_LINE> <INDENT> raise LookupError("Machine reports unknown load cell is in use") from ke | Get the rated range for the load cell in Newtons (N)
Raises
--------
LookupError if the machine reports a load cell of an unknown type
is in use or does not respond to request to read configuration | 625941ce16aa5153ce3625a5 |
def yolo_head(feats, anchors, num_classes, input_shape, calc_loss=False): <NEW_LINE> <INDENT> num_anchors = len(anchors) <NEW_LINE> anchors_tensor = K.reshape(K.constant(anchors), [1, 1, 1, num_anchors, 2]) <NEW_LINE> grid_shape = K.shape(feats)[1:3] <NEW_LINE> grid_y = K.tile(K.reshape(K.arange(0, stop=grid_shape[0]),... | Convert final layer features to bounding box parameters. | 625941cecc40096d61595a7d |
def discover_arduinos(): <NEW_LINE> <INDENT> serial_ids = Popen(['ls', '/dev/serial/by-id'], stdout=PIPE, stderr=PIPE) <NEW_LINE> paths = [] <NEW_LINE> if serial_ids.returncode: <NEW_LINE> <INDENT> return paths <NEW_LINE> <DEDENT> for id in serial_ids.stdout: <NEW_LINE> <INDENT> id = id.decode('utf8').strip() <NEW_LINE... | Discover all Arduinos connected to the system and return their device paths | 625941ce460517430c3942b1 |
def __init__(self, response, query): <NEW_LINE> <INDENT> assert isinstance(response, pylastica.response.Response), "response must be of type Response: %r" % response <NEW_LINE> assert isinstance(query, pylastica.query.Query), "query must be of type Query: %r" % query <NEW_LINE> self._results = [] <NEW_LINE> self._respo... | @type response: pylastica.response.Response
@type query: pylastica.query.Query | 625941cebde94217f3682f1d |
def set_matrix33(self, matrix33): <NEW_LINE> <INDENT> self.Tr33 = matrix33 | :param matrix33:
:return: | 625941ce91af0d3eaac9bb46 |
def _is_not_complete(node): <NEW_LINE> <INDENT> result = (not isinstance(node, ListNode) and not isinstance(node, ValueNode) and (node == None or node.get_right() == None)) <NEW_LINE> return result | Returns True if specified unary or binary node is not complete -
has its right leaf not set. | 625941ce3eb6a72ae02ec60a |
def list_exist(request): <NEW_LINE> <INDENT> name = request.POST.get('filename') <NEW_LINE> chunk = 0 <NEW_LINE> data = {} <NEW_LINE> filename = "./file/%s" % name <NEW_LINE> if os.path.exists(filename): <NEW_LINE> <INDENT> data['flag_exist'] = True <NEW_LINE> data['file_path'] = filename <NEW_LINE> <DEDENT> else: <NEW... | 判断该文件上传了多少个分片 | 625941cecdde0d52a9e53160 |
def mini_histogram(data): <NEW_LINE> <INDENT> chars = ' ▁▂▃▄▅▆▇█' <NEW_LINE> data_array = array(data) <NEW_LINE> counts, _ = histogram(data_array, bins=10) <NEW_LINE> indices = minmax_scale(counts, feature_range=(0, 8)).round() <NEW_LINE> chart = ''.join(chars[int(i)] for i in indices) <NEW_LINE> return '{min} |{chart}... | Return a histogram of a list of numbers with min and max numbers
labeled. | 625941ced99f1b3c44c676ba |
def load(self): <NEW_LINE> <INDENT> if not super(IFCFASTENER,self).load(): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True | register inverses | 625941ce99cbb53fe6792d13 |
def set_resolve_bgp_route_target_family_config(self): <NEW_LINE> <INDENT> pass | configure resolution config in global routing options if needed | 625941ce3346ee7daa2b2e98 |
def process_single_datetime(self, datetime): <NEW_LINE> <INDENT> self.process_datetime_extents(datetime, datetime) | Process a single datetime search filter and add it to the query dictionary.
Will parse partial datetimes to maximise the search window - e.g. 2009 will find all results
from 2009-01-01T00:00:00 to 2009-12-31T23:59:59
:param datetime: Start datetime string | 625941ce9c8ee82313fbb8a2 |
def plot_raw_BE_data(x, y, cycle, data, signals, folder_name, cmaps = 'inferno'): <NEW_LINE> <INDENT> folder = Make_folder('Raw_Loops_mixed') <NEW_LINE> mymap = plt.get_cmap(cmaps) <NEW_LINE> fig, axes = plt.subplots(1, 5, figsize=(15, 3)) <NEW_LINE> for i, (signal, values) in enumerate(signals.items()): <NEW_LINE> <IN... | Plots raw BE data
TODO: fix the size to make it generalizable
Parameters
----------
data : raw data to plot
Band Excitation Piezoresponse Data
signals : list
description of what to plot
folder_name : string
folder where to save
cmaps : string, optional
colormap to use for plot | 625941cebd1bec0571d9075c |
def check_mate(self): <NEW_LINE> <INDENT> pass | return True or False | 625941ce99fddb7c1c9de4be |
def extract(self, qtile=.999, pchan=.5, cutoff=10000000): <NEW_LINE> <INDENT> main = self.main <NEW_LINE> def _extract(df, form, current, prior, qtile=qtile, pchan=pchan, cutoff=cutoff): <NEW_LINE> <INDENT> rev, exp, ass = current <NEW_LINE> revp, expp, assp = prior <NEW_LINE> largest = df[ ((df[rev] >= df[rev].quantil... | Base method for extracting the largest and most-changed firms for additional validation.
ARGUMENTS
qtile (float) : Quartile cutoff to define the "largest" firms
pchan (float) : Percent change in revenue, assets or expenses that qualfies as a "big change"
cutoff (int) : Revenue threshold below which we ignore large cha... | 625941ce63f4b57ef0001246 |
@api.before_request <NEW_LINE> @auth.login_required <NEW_LINE> def before_request(): <NEW_LINE> <INDENT> if not g.current_user.is_anonymous and not g.current_user.confirmed: <NEW_LINE> <INDENT> return forbidden('Unconfirmed account') | API蓝本中所有路由都能进行自动认证 | 625941ce7d847024c06be3e8 |
def test_fix_types(): <NEW_LINE> <INDENT> for fname, change in ((hp_fif_fname, True), (test_fif_fname, False), (ctf_fname, False)): <NEW_LINE> <INDENT> raw = Raw(fname) <NEW_LINE> mag_picks = pick_types(raw.info, meg='mag') <NEW_LINE> other_picks = np.setdiff1d(np.arange(len(raw.ch_names)), mag_picks) <NEW_LINE> if cha... | Test fixing of channel types
| 625941ce435de62698dfdd79 |
def compute_coherence_values(dictionary, corpus, texts, limit, coherence='c_v', start=2, step=3, mallet_path=None, args={}): <NEW_LINE> <INDENT> coherence_values = [] <NEW_LINE> model_list = [] <NEW_LINE> for num_topics in range(start, limit, step): <NEW_LINE> <INDENT> if mallet_path: <NEW_LINE> <INDENT> model = gensim... | Compute the Cv coherence for various number of topics
:param dictionary: Dictionary
:param corpus: Corpus
:param texts: List of input texts
:param limit: The maximum number of topics
:param coherence: Coherence score to be used
:param start: The minimum number of topics
:param step: The step size for the number of topi... | 625941ce9b70327d1c4e0f02 |
def deleteAgentRoles(self, request, context): <NEW_LINE> <INDENT> context.set_code(grpc.StatusCode.UNIMPLEMENTED) <NEW_LINE> context.set_details('Method not implemented!') <NEW_LINE> raise NotImplementedError('Method not implemented!') | Missing associated documentation comment in .proto file. | 625941ce45492302aab5e3f0 |
def _validate_plugin_form(self, form_info): <NEW_LINE> <INDENT> reason = None <NEW_LINE> valid_types = ['text', 'textarea', 'checkbox', 'select'] <NEW_LINE> for k, v in form_info.iteritems(): <NEW_LINE> <INDENT> if not isinstance(v, dict): <NEW_LINE> <INDENT> reason = 'Invalid form field: ' + k + ' entry is not an obje... | Validates the structure of the form definition of a plugin
included in the package.json file | 625941ce8a349b6b435e82a0 |
def list(self): <NEW_LINE> <INDENT> print("--- Installed packages ---"); <NEW_LINE> for self.__pkgName in self._psort(list(self.__installed[0].keys())): <NEW_LINE> <INDENT> ins = self.getInstalledVersion(); <NEW_LINE> new = 0; <NEW_LINE> if self.__pkgName in self.__dists[self.__rc.distname] and self.__bal... | list installed packages | 625941ce435de62698dfdd7a |
def norm(self): <NEW_LINE> <INDENT> return math.sqrt(self.x**2 + self.y**2 + self.z**2) | norma wektora: self | 625941cecb5e8a47e48b7bd7 |
def main( self, args: t.Optional[t.Sequence[str]] = None, prog_name: t.Optional[str] = None, complete_var: t.Optional[str] = None, standalone_mode: bool = True, windows_expand_args: bool = True, **extra: t.Any, ) -> t.Any: <NEW_LINE> <INDENT> _verify_python_env() <NEW_LINE> if args is None: <NEW_LINE> <INDENT> args = s... | This is the way to invoke a script with all the bells and
whistles as a command line application. This will always terminate
the application after a call. If this is not wanted, ``SystemExit``
needs to be caught.
This method is also available by directly calling the instance of
a :class:`Command`.
:param args: the ... | 625941ce63d6d428bbe4461c |
def create_vm(self, vm_name): <NEW_LINE> <INDENT> virt_url = self._get_virt_connection_url(self._config['connection']) <NEW_LINE> cmd = 'virt-clone --connect=%(url)s -o %(t)s -n %(n)s --auto-clone' % { 't': self._config['template_name'], 'n': vm_name, 'url': virt_url } <NEW_LINE> subprocess.check_call(cmd, shell=True) ... | Clones prebuilt VM template and starts it. | 625941ce4a966d76dd55113d |
def p_fator_ladoDir(p): <NEW_LINE> <INDENT> p[0] = p[2] | fator : ABRE_PAREN ladoDir FECHA_PAREN PONTO_VIRG | 625941ce8c3a8732951584e8 |
@application.route('/get_weather_report', methods=['POST', 'GET']) <NEW_LINE> def get_weather_report(): <NEW_LINE> <INDENT> if request.method == 'POST': <NEW_LINE> <INDENT> data = request.json <NEW_LINE> input_location = data['location'] <NEW_LINE> w_report = weather_report_controller() <NEW_LINE> geo_location = w_repo... | Get the weather report from the controller and render them using the models. | 625941ce656771135c3eb99c |
def __addFirstRowToModel(self, oldModel, newRow): <NEW_LINE> <INDENT> model = QStandardItemModel(self) <NEW_LINE> items = [] <NEW_LINE> for str in newRow: <NEW_LINE> <INDENT> items.append(QStandardItem(str)) <NEW_LINE> <DEDENT> model.appendRow(items) <NEW_LINE> for i in range(oldModel.rowCount()): <NEW_LINE> <INDENT> i... | :type oldModel: QAbstractItemModel
:type newRow: list
:return: QStandardItemModel | 625941ced268445f265b4f9b |
def is_user_state_service_available(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.runtime.service(self, 'user_state') <NEW_LINE> return True <NEW_LINE> <DEDENT> except NoSuchServiceError: <NEW_LINE> <INDENT> return False | Check if the user state service is present in runtime. | 625941ce6fb2d068a760f1cb |
def _draw_treetok(self, treetok, index, depth=0): <NEW_LINE> <INDENT> c = self._tree_canvas <NEW_LINE> margin = ChartView._MARGIN <NEW_LINE> child_xs = [] <NEW_LINE> for child in treetok: <NEW_LINE> <INDENT> if isinstance(child, Tree): <NEW_LINE> <INDENT> child_x, index = self._draw_treetok(child, index, depth + 1) <NE... | @param index: The index of the first leaf in the tree.
@return: The index of the first leaf after the tree. | 625941ce4527f215b584c584 |
def closing(): <NEW_LINE> <INDENT> my_message.set("closeapp") <NEW_LINE> sending_message() | Closing GUI window | 625941ce7d43ff24873a2dcd |
def stopPacketRecorderCmd(self, argv): <NEW_LINE> <INDENT> self.logMethod("stopPacketRecorderCmd", "SPACE") <NEW_LINE> if not SUPP.IF.s_tmRecorder.isRecording(): <NEW_LINE> <INDENT> LOG_WARNING("Packet recording not started", "SPACE") <NEW_LINE> return False <NEW_LINE> <DEDENT> if len(argv) != 1: <NEW_LINE> <INDENT> LO... | Decoded stopPacketRecorder command | 625941ce30bbd722463cbef4 |
def optimise(self): <NEW_LINE> <INDENT> self.get_adjacency() <NEW_LINE> self.initialise_pheremone() <NEW_LINE> self.initial_route = list(self.nodes) <NEW_LINE> self.route_best = self.initial_route <NEW_LINE> self.distance_best = self.get_total_distance(self.route_best) <NEW_LINE> for i in range(iterations): <NEW_LINE> ... | Main class method. This function can be called from an ant colony
optimisation object and returns the best route and distance.
Returns
-------
route_best : numpy array of strings
The shortest route found as determined by the
function get_total_distance().
distance_best : float
The total distance of route_... | 625941ceeab8aa0e5d26dc85 |
def zip_to_csv(filename, dest_dir): <NEW_LINE> <INDENT> zip_ref = zipfile.ZipFile(filename, 'r') <NEW_LINE> cwd = os.getcwd() <NEW_LINE> os.chdir(dest_dir) <NEW_LINE> zip_ref.extractall() <NEW_LINE> os.chdir(cwd) <NEW_LINE> csv_file = os.path.join(dest_dir, zip_ref.namelist()[0]) <NEW_LINE> zip_ref.close() <NEW_LINE> l... | Extracts zipped flights data.
Args:
filename: Corresponding year to download (e.g. '2015').
dest_dir: Directory where the data is stored.
Returns:
The path to the extracted file. | 625941ce1f037a2d8b94632b |
def play_one_game_with_montecarlo(new_game, nmr_games, found_games, mc_width = 100, mc_depth = 20): <NEW_LINE> <INDENT> count_moves = 0 <NEW_LINE> one_game = {} <NEW_LINE> all_directions = [0, 1, 2, 3] <NEW_LINE> spel = new_game <NEW_LINE> while spel.check_if_moves_possible() and count_moves < conf["max_moves"]: <NEW_L... | while moves are possible
simulate all 4 directions
each with mc_width games played for mc_depth moves.
select direction with highest score
play that direction
return highest value on board and the played game | 625941ced8ef3951e324366b |
def match_speeds(session, orders): <NEW_LINE> <INDENT> car_status = session.query(TrainStatus).filter(TrainStatus.identification == orders.who).one() <NEW_LINE> car_status.speed = orders.speed_request <NEW_LINE> session.add(car_status) <NEW_LINE> session.commit() | Match the current speed to the ordered speed. | 625941cee1aae11d1e749de5 |
def nextClosestTime(self, time): <NEW_LINE> <INDENT> from itertools import permutations <NEW_LINE> nums = list(map(str, filter(lambda x: x != ':', list(time)))) <NEW_LINE> closest_time = None <NEW_LINE> for time in permutations(nums): <NEW_LINE> <INDENT> if self.is_valid_time(time): <NEW_LINE> <INDENT> time.insert() <N... | https://leetcode.com/explore/interview/card/google/67/sql-2/471/
:type time: str
:rtype: str | 625941cee5267d203edcddca |
def _syncable(self, *target, nchannels: int = None, sample_rate: int = None, sample_format_id: int = None): <NEW_LINE> <INDENT> nchannels = nchannels if nchannels else self.nchannels <NEW_LINE> sample_format_id = self._sample_format if sample_format_id is None else sample_format_id <NEW_LINE> sample_rate = sample_rate ... | Determines whether the target can be synced with specified properties or not
:param target: wrapped object\s
:param nchannels: number of channels; if the value is None, the target will be compared to the 'self' properties.
:param sample_rate: sample rate; if the value is None, the target will be compared to the 'self... | 625941ce29b78933be1e57d9 |
def blocks_height_signature(self, block_signature): <NEW_LINE> <INDENT> return self.request('get', '/blocks/height/{}'.format(block_signature)) | Get signature of block at height
:param block_signature:
:return:
:rtype: AcrylClientResponse | 625941cea934411ee37517c1 |
def sudoku(grid: Matrix) -> Optional[Matrix]: <NEW_LINE> <INDENT> if is_completed(grid): <NEW_LINE> <INDENT> return grid <NEW_LINE> <DEDENT> location = find_empty_location(grid) <NEW_LINE> if location is not None: <NEW_LINE> <INDENT> row, column = location <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return grid <NEW_... | Takes a partially filled-in grid and attempts to assign values to
all unassigned locations in such a way to meet the requirements
for Sudoku solution (non-duplication across rows, columns, and boxes)
>>> sudoku(initial_grid) # doctest: +NORMALIZE_WHITESPACE
[[3, 1, 6, 5, 7, 8, 4, 9, 2],
[5, 2, 9, 1, 3, 4, 7, 6, 8],
... | 625941ce4428ac0f6e5ba920 |
def sumRegion(self, row1, col1, row2, col2): <NEW_LINE> <INDENT> return self.__sums[row2+1][col2+1] - self.__sums[row2+1][col1] - self.__sums[row1][col2+1] + self.__sums[row1][col1] | sum of elements matrix[(row1,col1)..(row2,col2)], inclusive.
:type row1: int
:type col1: int
:type row2: int
:type col2: int
:rtype: int | 625941ce4e4d5625662d4505 |
def input_unhandled(self, input): <NEW_LINE> <INDENT> if isinstance(input, tuple): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if input == "ctrl w": <NEW_LINE> <INDENT> self.test_ast() <NEW_LINE> self.set_value() <NEW_LINE> <DEDENT> if input == "ctrl a": <NEW_LINE> <INDENT> self.add_view("ast") <NEW_LINE> <DEDENT> i... | Main input handler | 625941ce236d856c2ad44909 |
def select_window(self,windowID): <NEW_LINE> <INDENT> self.do_command("selectWindow", [windowID,]) | Selects a popup window using a window locator; once a popup window has been selected, all
commands go to that window. To select the main window again, use null
as the target.
Window locators provide different ways of specifying the window object:
by title, by internal JavaScript "name," or by JavaScript variable.
... | 625941ceff9c53063f47c321 |
def mergeTwoLists(self, l1, l2): <NEW_LINE> <INDENT> if l1 and not l2: <NEW_LINE> <INDENT> return l1 <NEW_LINE> <DEDENT> if l2 and not l1: <NEW_LINE> <INDENT> return l2 <NEW_LINE> <DEDENT> if not l1 and not l2: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> h1 = l1 <NEW_LINE> h2 = l2 <NEW_LINE> if h1.val < h2.val:... | :type l1: ListNode
:type l2: ListNode
:rtype: ListNode | 625941ce442bda511e8be546 |
def normalize(self): <NEW_LINE> <INDENT> f = self.norm() <NEW_LINE> where = f > 0 <NEW_LINE> f[where] = 1.0 / f[where] <NEW_LINE> f.shape = f.size,1 <NEW_LINE> f = f.repeat(self.ndim,1) <NEW_LINE> data = self.data * f <NEW_LINE> if is_Point(self): <NEW_LINE> <INDENT> return Point(data) <NEW_LINE> <DEDENT> else: <NEW_LI... | normalize()
Return normalized vector (to unit length). | 625941ce6e29344779a6273f |
def __init__(self, value): <NEW_LINE> <INDENT> self.value = value <NEW_LINE> self.children = [] <NEW_LINE> self.parents = [] <NEW_LINE> self.undirected_links = [] | constructor.
@param value: can be anything, even a complex object.
example::
newnode=Node(uniqueid) | 625941ce45492302aab5e3f1 |
def test_success(self): <NEW_LINE> <INDENT> self.assertTrue(self.craft_response_of_type(icmp.Types.EchoReply).success, 'Unable to validate a successful response') <NEW_LINE> self.assertFalse(self.craft_response_of_type(icmp.Types.DestinationUnreachable).success, 'Unable to validate Destination Unreachable') <NEW_LINE> ... | Verifies the if the Response can indicate a success to a request correctly | 625941ce167d2b6e31218cc4 |
def add(self, name): <NEW_LINE> <INDENT> self.members.add(name) | 参加するメンバーを追加する
Args:
name: 参加する人の名前 | 625941ce3539df3088e2e479 |
def map_slots_to_mapping(self): <NEW_LINE> <INDENT> args = {} <NEW_LINE> mappings = self._intent_mappings[self.request.intent] <NEW_LINE> if mappings is not None and len(self.request.slots.keys()) > 0: <NEW_LINE> <INDENT> for to, fr in self._intent_mappings[self.request.intent].items(): <NEW_LINE> <INDENT> if fr in sel... | Map slots to arguments.
Deals with mapping slots to arguments - i.e DEVICE slot mapped to device argument | 625941ce1d351010ab855c4a |
def bs(c, th): <NEW_LINE> <INDENT> b = [] <NEW_LINE> for i in range(c.shape[0]): <NEW_LINE> <INDENT> if c[i].sum() > th: <NEW_LINE> <INDENT> b.append(i) <NEW_LINE> <DEDENT> <DEDENT> return b | **** NEEDS TESTED ****
Provides a method for highlighting cells which
qualify for a beta production | 625941ceaad79263cf390b6f |
def correct_scatter_shebang(self, scatter_file): <NEW_LINE> <INDENT> with open(scatter_file, "rb") as input: <NEW_LINE> <INDENT> lines = input.readlines() <NEW_LINE> if (lines[0].startswith(self.SHEBANG) or not lines[0].startswith("#!")): <NEW_LINE> <INDENT> return scatter_file <NEW_LINE> <DEDENT> else: <NEW_LINE> <IN... | Correct the shebang at the top of a scatter file.
Positional arguments:
scatter_file -- the scatter file to correct
Return:
The location of the correct scatter file
Side Effects:
This method MAY write a new scatter file to disk | 625941ced486a94d0b98e274 |
def _check_out_of_date(srcfile, objfile): <NEW_LINE> <INDENT> stale = True <NEW_LINE> if os.path.exists(objfile): <NEW_LINE> <INDENT> t1 = os.path.getmtime(objfile) <NEW_LINE> t2 = os.path.getmtime(srcfile) <NEW_LINE> if t1 > t2: <NEW_LINE> <INDENT> stale = False <NEW_LINE> <DEDENT> <DEDENT> return stale | Check if existing object files are current with the existing source
files.
Parameters
----------
srcfile : str
source file path
objfile : str
object file path
Returns
-------
stale : bool
boolean indicating if the object file is current | 625941ce627d3e7fe0d68f7e |
def test_all_test_positive_when_hashes_collide(self): <NEW_LINE> <INDENT> bloom_filter = BloomFilter(1000000, 1e-3) <NEW_LINE> bloom_filter.add_by_hash("abc") <NEW_LINE> self.assertEqual(bloom_filter.test_by_hash("def"), False) | BloomFilter.test_by_hash() returns False when filter is empty. | 625941ce23e79379d52ee692 |
def max(self, *args): <NEW_LINE> <INDENT> return _MEDCouplingRemapper.MEDCouplingLinearTime_max(self, *args) | max(self, MEDCouplingTimeDiscretization other) -> MEDCouplingTimeDiscretization
1 | 625941ce50812a4eaa59c450 |
def set_want_to_play(self): <NEW_LINE> <INDENT> data = { 'command': 'find-random-game' } <NEW_LINE> def result_processor(r): <NEW_LINE> <INDENT> if not _check_result_ok(r) or 'game-status' not in r.response: <NEW_LINE> <INDENT> raise AssertionError("Server error - FIXIT") <NEW_LINE> <DEDENT> if r.response['game-status'... | Sets that player wants to play a game with some player.
:return: Asynchronous query returning Game if somebody wants to play with one, None if there's no such player. | 625941ce851cf427c661a63d |
def _multiseries(self, col, x, y, ctype, rsum, rmean): <NEW_LINE> <INDENT> self.autoprint = False <NEW_LINE> x, y = self._check_fields(x, y) <NEW_LINE> chart = None <NEW_LINE> series = self.split_(col) <NEW_LINE> for key in series: <NEW_LINE> <INDENT> instance = series[key] <NEW_LINE> if rsum is not None: <NEW_LINE> <I... | Chart multiple series from a column distinct values | 625941ce3c8af77a43ae38cf |
def __init__(self, dict_): <NEW_LINE> <INDENT> links = self._parse_links(dict_) <NEW_LINE> self._links = Links(links) <NEW_LINE> for key, value in dict_.items(): <NEW_LINE> <INDENT> if isinstance(value, (list, tuple)): <NEW_LINE> <INDENT> d = [JsonResource(x) if isinstance(x, dict) else x for x in value] <NEW_LINE> set... | JsonResource attributes can be accessed with 'dot'. | 625941ce1f037a2d8b94632c |
def get(self, context, instance_id): <NEW_LINE> <INDENT> if utils.is_uuid_like(instance_id): <NEW_LINE> <INDENT> instance = self.db.instance_get_by_uuid(context, instance_id) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> instance = self.db.instance_get(context, instance_id) <NEW_LINE> <DEDENT> inst = dict(instance.iter... | Get a single instance with the given instance_id. | 625941cea934411ee37517c2 |
def square_norm(self): <NEW_LINE> <INDENT> return self.dot(self) | Calculates the squared norm of the vector.
Cheaper than using self.norm() since the expensive
sqrt() isn't needed. | 625941ce8e7ae83300e4b0fb |
def content_loss_np(content_weight, content_current, content_targets): <NEW_LINE> <INDENT> if len(content_current.shape) != 4: <NEW_LINE> <INDENT> raise ValueError('Content dimension error!') <NEW_LINE> <DEDENT> channel = content_current.shape[3] <NEW_LINE> height = content_current.shape[1] <NEW_LINE> width = content_c... | Compute the content loss for style transfer.
:param content_weight: scalar constant we multiply the content_loss by.
:param content_current: features of the current image, 4D-tensor with shape [1, height, width, channels]
:param content_targets: features of the content image, 4D-tensor with shape [1, height, width, cha... | 625941ce31939e2706e4cf98 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.