code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def delete_element(self, id): <NEW_LINE> <INDENT> self.elements.pop(id) | Delete an element by its ID.
Parameters
----------
id : int
ID of the element to delete from the list of elements. | 625941ca56b00c62f0f146f5 |
def get_close_matches(word, possibilities, n=3, cutoff=0.6): <NEW_LINE> <INDENT> result = [] <NEW_LINE> s = SequenceMatcher() <NEW_LINE> s.set_seq2(word) <NEW_LINE> for x in possibilities: <NEW_LINE> <INDENT> s.set_seq1(x) <NEW_LINE> if s.real_quick_ratio() >= cutoff and s.quick_ratio() >= cutoff and s.ratio() >= cutof... | Use SequenceMatcher to return list of close matches.
word is a sequence for which close matches are desired (typically a string).
possibilities is a list of sequences against which to match word (typically a list of strings).
Optional arg n (default 3) is the maximum number of close matches to return. n must be > 0.... | 625941ca2eb69b55b151c94a |
def load(): <NEW_LINE> <INDENT> registerFunction("gtfo", gtfo, restricted = True) | Lets the bot get the fuck out on command. | 625941ca26238365f5f0ef09 |
def friendly_date(self): <NEW_LINE> <INDENT> date = self.created_at.strftime("%a %b %d %Y, %-I:%M %p") <NEW_LINE> return date | Create friendly date | 625941cabaa26c4b54cb11bc |
def add_comment(self, comment=None): <NEW_LINE> <INDENT> self.do("Add Comment") <NEW_LINE> new_comment = Comment(self.diagram, comment) <NEW_LINE> self.diagram.comments.append(new_comment) <NEW_LINE> if comment is None: <NEW_LINE> <INDENT> new_comment.is_selected = True <NEW_LINE> self.diagram.show_comment_property(new... | This method add a comment in the diagram.
Parameters:
* **block**
Returns:
* **Types** (:class:`boolean<boolean>`) | 625941cad10714528d5ffd7e |
def type_Q_x0(self): <NEW_LINE> <INDENT> v = self.as_Q_x0_atom() <NEW_LINE> return gen_leech2_type(v) >> 4 | Return type of element if it is in the subgroup :math:`Q_{x0}`
If the element is in the subgroup :math:`Q_{x0}` of the monster
then the function returns the type of the vector in the Leech
lattice modulo 2 corresponding to this element. That type is
0, 2, 3, or 4.
The function raises ValueError if the element is not... | 625941caa934411ee3751730 |
def calculate_handlen(hand): <NEW_LINE> <INDENT> length = 0 <NEW_LINE> for key in hand.keys(): <NEW_LINE> <INDENT> length += hand[key] <NEW_LINE> <DEDENT> return length | Returns the length (number of letters) in the current hand.
hand: dictionary (string-> int)
returns: integer | 625941ca187af65679ca51ba |
def search_products(search_query): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> product = Product.get(Product.product_id == search_query) <NEW_LINE> menu.display_product(product) <NEW_LINE> <DEDENT> except DoesNotExist: <NEW_LINE> <INDENT> print("Product ID# '{}' does not exist in the database".format( search_query )) ... | Searches for a product by the product's ID field | 625941ca046cf37aa974cde4 |
def activeSubWindow(self): <NEW_LINE> <INDENT> print('returning lastActiveRealWindow=', self.lastActiveRealWindow) <NEW_LINE> return self.lastActiveRealWindow | returns last active subwindow
:return: SubWindow object | 625941ca2ae34c7f2600d1cd |
def find_subclass( base_class: ParentClass, name: str ) -> ty.Optional[ty.Type[ParentClass]]: <NEW_LINE> <INDENT> for cname, clazz in get_subclasses_with_name(base_class): <NEW_LINE> <INDENT> if cname == name: <NEW_LINE> <INDENT> return clazz <NEW_LINE> <DEDENT> <DEDENT> return None | Find subclass to given `base_class` with given value of
attribute `name` | 625941ca4c3428357757c3c4 |
def try_opening_tempfile(dirpath): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> tempfile = os.path.join(dirpath, 'test.tmp') <NEW_LINE> with open(tempfile, 'w') as f: <NEW_LINE> <INDENT> f.write('test') <NEW_LINE> <DEDENT> if not os.path.isfile(tempfile): <NEW_LINE> <INDENT> raise Exception('file wasn\'t found after wr... | some users see WebKit returning undefined from the openDatabase call. this
function attempts to open a file in the database directory and write to it-
to see if they don't have permission. | 625941ca596a897236089b5d |
def ChiSquared(params, fit_dict): <NEW_LINE> <INDENT> bands_frame = fit_dict['bands_frame'] <NEW_LINE> temp_vector, mass_vector, beta_vector, correl_err_vector = ParamsExtract(params, fit_dict) <NEW_LINE> pred_fluxes = ModelFlux(bands_frame['wavelength'], temp_vector, mass_vector, fit_dict['distance'], kappa_0=fit_dict... | Function to calculate residuals, and thence chi-squared, of model, accounting for colour corrections | 625941ca38b623060ff0ae8a |
def load_metadata(self): <NEW_LINE> <INDENT> for md_type in self.md_files: <NEW_LINE> <INDENT> if md_type == "primary_db": <NEW_LINE> <INDENT> self.primary = PrimaryDatabaseMD(self.md_files["primary_db"]) <NEW_LINE> <DEDENT> elif md_type == "primary": <NEW_LINE> <INDENT> self.primary = PrimaryMD(self.md_files["primary"... | Parse available metadata files into memory. | 625941ca1f5feb6acb0c4bee |
def __init__(__self__, *, function_arn: pulumi.Input[str], position: pulumi.Input[int], invocation_type: Optional[pulumi.Input[str]] = None, topic_arn: Optional[pulumi.Input[str]] = None): <NEW_LINE> <INDENT> pulumi.set(__self__, "function_arn", function_arn) <NEW_LINE> pulumi.set(__self__, "position", position) <NEW_L... | :param pulumi.Input[str] function_arn: The ARN of the Lambda function to invoke
:param pulumi.Input[int] position: The position of the action in the receipt rule
:param pulumi.Input[str] invocation_type: `Event` or `RequestResponse`
:param pulumi.Input[str] topic_arn: The ARN of an SNS topic to notify | 625941ca656771135c3eb90a |
def ajouter_element(self, element): <NEW_LINE> <INDENT> self.mod_elements.append(element) | Ajoute un élément dans la salle. | 625941ca435de62698dfdce9 |
def get_host_name(self): <NEW_LINE> <INDENT> return self.__get_value("agentLevelParams/hostname") | Retrieve host name on which ambari agent is running
:return: host name | 625941ca090684286d50ed81 |
def isSBML(filename): <NEW_LINE> <INDENT> doc = md.parse(filename) <NEW_LINE> for child in doc.childNodes: <NEW_LINE> <INDENT> if child.nodeType == child.ELEMENT_NODE and child.nodeName == 'sbml': <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> return False | Check model in `filename` is in SBML format. | 625941ca377c676e91272245 |
def unquote(text, quote_char='"'): <NEW_LINE> <INDENT> text = pyd.to_string(text) <NEW_LINE> inner = text[1:-1] <NEW_LINE> if text == '{0}{1}{0}'.format(quote_char, inner): <NEW_LINE> <INDENT> text = inner <NEW_LINE> <DEDENT> return text | Unquote `text` by removing `quote_char` if `text` begins and ends with
it.
Args:
text (str): String to unquote.
Returns:
str: Unquoted string.
Example:
>>> unquote('"abc"')
'abc'
>>> unquote('"abc"', '#')
'"abc"'
>>> unquote('#abc', '#')
'#abc'
>>> unquote('#abc#', '#')
'abc'... | 625941ca55399d3f05588750 |
def get(self, request, uuid=None): <NEW_LINE> <INDENT> user_profile = models.UserProfile.objects.get(user=request.user) <NEW_LINE> network = user_profile.network <NEW_LINE> try: <NEW_LINE> <INDENT> tower = models.BTS.objects.get(uuid=uuid, network=user_profile.network) <NEW_LINE> <DEDENT> except models.BTS.DoesNotExist... | Handles GET requests. | 625941ca1d351010ab855bb8 |
def __describe_callback(self, name, desc, file): <NEW_LINE> <INDENT> s = EnchantStr("") <NEW_LINE> name = s.decode(name) <NEW_LINE> desc = s.decode(desc) <NEW_LINE> file = s.decode(file) <NEW_LINE> self.__describe_result.append((name, desc, file)) | Collector callback for dictionary description.
This method is used as a callback into the _enchant function
'enchant_broker_describe'. It collects the given arguments in
a tuple and appends them to the list '__describe_result'. | 625941caaad79263cf390adc |
def __init__( self, model_name: str, name: str, modulus: int, remainder: int ): <NEW_LINE> <INDENT> super().__init__(model_name, name) <NEW_LINE> self.modulus = modulus <NEW_LINE> self.remainder = remainder | Initializes new instance of :see:AddHashPartition.
Arguments:
model_name:
The name of the :see:PartitionedPostgresModel.
name:
The name to give to the new partition table.
modulus:
Integer value by which the key is divided.
remainder:
The remainder of the hash value wh... | 625941ca63f4b57ef00011b7 |
def generate_stop_dict(response): <NEW_LINE> <INDENT> data = json.loads(response['Payload'].read().decode('utf-8')) <NEW_LINE> data = json.loads(data) <NEW_LINE> stop_instances = {} <NEW_LINE> for key, value in data.items(): <NEW_LINE> <INDENT> launch_time = parser.parse(value['LaunchTime']) <NEW_LINE> stop_on = launch... | Generates a dictionary of untagged instances to stop. | 625941ca2c8b7c6e89b3585d |
def _calculate_ACC_levy(annual_income): <NEW_LINE> <INDENT> if annual_income < ACC_MAX: <NEW_LINE> <INDENT> levy = annual_income * ACC_LEVY_RATE <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> levy = ACC_MAX * ACC_LEVY_RATE <NEW_LINE> <DEDENT> return levy | Calculate ACC levy on annual income | 625941ca07d97122c4178926 |
def get_config(self, *args, **kwargs): <NEW_LINE> <INDENT> config = boto.ec2.autoscale.launchconfig.LaunchConfiguration( connection=self.connection, *args, **kwargs ) <NEW_LINE> throttled_call(self.connection.create_launch_configuration, config) <NEW_LINE> return config | Returns a new launch configuration | 625941cabe7bc26dc91cd69d |
def input_donor_amt(d_amt=0): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> print("\nEnter a nonzero Donation Amount:") <NEW_LINE> d_amt = user_input() <NEW_LINE> if not d_amt: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> d_amt = conv_str(d_amt, float) <NEW_LINE> if d_amt: <NEW_LINE> <INDENT> break <NEW_LINE> <D... | Prompt user for donation amount
If input cannot be converted to float, prompt again. | 625941ca07d97122c4178927 |
def build_scale(): <NEW_LINE> <INDENT> rssi_list = range(-100,0) <NEW_LINE> rssi_list = rssi_list[::-1] <NEW_LINE> return rssi_list | Returns list of numbers from 0 to -100 for RSSI base | 625941ca5166f23b2e1a51f5 |
def scheduled(self): <NEW_LINE> <INDENT> return super(TestManager, self).get_query_set().filter(state='scheduled') | Method that return the Queryset with the Scheduled Test | 625941cae8904600ed9f1fc9 |
def fetch_metadata_map(title=None, author=None, isbn=None): <NEW_LINE> <INDENT> fetch_args = fetch_metadata_args(title, author, isbn) <NEW_LINE> raw_metadata = check_output(fetch_args) <NEW_LINE> return extract_raw_metadata_map(raw_metadata) | Extracts metadata about an ebook, returning a dict.
At least one of title, author, or ISBN is required; it is suggested to
either provide ISBN or both title and author. In the case of multiple books
matching a particular set of identifiers, the first one found will be returned
Args:
title (str, optional): Title of... | 625941ca091ae35668666ffc |
def get(self,request,iteration_uid,format = None): <NEW_LINE> <INDENT> backlog_data = get_all_backlogs_by_iteration_uid(iteration_uid) <NEW_LINE> if backlog_data: <NEW_LINE> <INDENT> response_serializer= BacklogResponseSerializer(backlog_data,many = True) <NEW_LINE> return Response(response_serializer.data, status=stat... | Request-type: POST
Method for Fetching Backlog detail by iteration_uid
---
request_serializer = BacklogRequestSerializer
response_serializer = BacklogResponseSerializer | 625941ca8c3a873295158457 |
def xticks2lon(new_xticks=None): <NEW_LINE> <INDENT> if new_xticks is not None: <NEW_LINE> <INDENT> plt.gca().set_xticks(new_xticks) <NEW_LINE> <DEDENT> current_xticks = plt.gca().get_xticks() <NEW_LINE> current_xticklabels = plt.gca().get_xticklabels() <NEW_LINE> new_xticklabels = current_xticklabels <NEW_LINE> for i,... | Convert xticks to longitudes. | 625941ca21a7993f00bc7d8b |
def default_ability(self, player, center_x, center_y): <NEW_LINE> <INDENT> radius = self.light_distance() <NEW_LINE> player.destroy_blocks_in_radius( radius, center_x, center_y ) | l.default_ability( Player, int, int ) -> None
Executes the default lantern ability, which is destroying breakable blocks. | 625941cad10714528d5ffd7f |
def output(self, msg) -> None: <NEW_LINE> <INDENT> print(f"{datetime.now()}\t{msg}") | Output message of backtesting engine. | 625941ca0a50d4780f666f2e |
def compute_new_versions(current_dev_version): <NEW_LINE> <INDENT> release_version = current_dev_version.removesuffix(".dev0") <NEW_LINE> if release_version == current_dev_version: <NEW_LINE> <INDENT> raise Exception(f"{current_dev_version} is not a dev version") <NEW_LINE> <DEDENT> pieces = list(map(int, release_versi... | Return (release_version, next_dev_version) | 625941cafb3f5b602dac372f |
def main(): <NEW_LINE> <INDENT> data = input() <NEW_LINE> data = data.split(' ') <NEW_LINE> data = list(map(float, data)) <NEW_LINE> print("Remaining balance:", (payingdebtoffinayear(data[0], data[1], data[2]))) | @author : SandhyaKamisetty | 625941ca7047854f462a14a7 |
def with_data(self, newdata): <NEW_LINE> <INDENT> self._v1_current_data.update(dict(newdata)) <NEW_LINE> self._v1_needs_refresh = False <NEW_LINE> return self | bulk-set instance data | 625941caf7d966606f6aa0a0 |
def insert_tables(cur, conn): <NEW_LINE> <INDENT> for query in insert_table_queries: <NEW_LINE> <INDENT> print(query) <NEW_LINE> cur.execute(query) <NEW_LINE> conn.commit() | Insert data from staging tables
cur
executes commands
conn
connects to sql database | 625941cab830903b967e99a8 |
def toggle_visibility(self, force_tray=False) -> None: <NEW_LINE> <INDENT> if self.window.windowState() == Qt.WindowMinimized or not self.window.isVisible(): <NEW_LINE> <INDENT> self.show() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.close(force_tray=force_tray) | Toggle window visibility. | 625941ca6e29344779a626af |
def test_zernike_func_yy_corr(coeff_yy, noll_index_yy, eidos_data_yy): <NEW_LINE> <INDENT> from africanus.rime import zernike_dde <NEW_LINE> npix = 17 <NEW_LINE> nsrc = npix ** 2 <NEW_LINE> ntime = 1 <NEW_LINE> na = 1 <NEW_LINE> nchan = 1 <NEW_LINE> ncorr = 1 <NEW_LINE> thresh = 15 <NEW_LINE> npoly = thresh <NEW_LINE> ... | Tests reconstruction of yy correlation against eidos | 625941ca4f6381625f114ad7 |
def test_sample_weight(): <NEW_LINE> <INDENT> X = np.arange(100)[:, np.newaxis] <NEW_LINE> y = np.ones(100) <NEW_LINE> y[:50] = 0.0 <NEW_LINE> sample_weight = np.ones(100) <NEW_LINE> sample_weight[y == 0] = 0.0 <NEW_LINE> clf = DecisionTreeClassifier(random_state=0) <NEW_LINE> clf.fit(X, y, sample_weight=sample_weight)... | Check sample weighting. | 625941ca5fdd1c0f98dc02d0 |
def get_budget_param(request): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> budget_id = float(request.GET.get('budget')) <NEW_LINE> if budget_id not in request.budget_id_list: <NEW_LINE> <INDENT> budget_id = -1 <NEW_LINE> <DEDENT> <DEDENT> except TypeError: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> except Val... | Выбранный бюджет | 625941ca711fe17d8254240a |
def parse_expr(expr): <NEW_LINE> <INDENT> res, remainder = match_expr(expr) <NEW_LINE> if remainder: <NEW_LINE> <INDENT> raise ValueError("Invalid expression!") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return res | Helper function to match the full string as a python expression
:param expr:
:return: The python expression represented by the string
:raises ValueError: If no match can be found | 625941ca4e4d5625662d4475 |
def get_user_values(user_file): <NEW_LINE> <INDENT> var2value = defaultdict() <NEW_LINE> if isfile(user_file): <NEW_LINE> <INDENT> with open(user_file, 'r') as user_fh: <NEW_LINE> <INDENT> lines = user_fh.readlines() <NEW_LINE> <DEDENT> for line in lines: <NEW_LINE> <INDENT> match = RE_ENV.match(line) <NEW_LINE> if mat... | Read file in and turn var=value into a dict we return. | 625941ca3346ee7daa2b2e08 |
def _cmp_letters(self, letter1, letter2): <NEW_LINE> <INDENT> from sage.misc.superseded import deprecation <NEW_LINE> deprecation(21435, "cmp_letters is deprecated. Use sortkey_letters instead") <NEW_LINE> rk = self.alphabet().rank <NEW_LINE> return int(rk(letter1) - rk(letter2)) | Returns a negative number, zero or a positive number if
``letter1`` < ``letter2``, ``letter1`` == ``letter2`` or
``letter1`` > ``letter2`` respectively.
INPUT:
- ``letter1`` -- a letter in the alphabet
- ``letter2`` -- a letter in the alphabet
EXAMPLES::
sage: W = FiniteWords('woa')
sage: W.cmp_letters('w',... | 625941ca71ff763f4b549727 |
def setOkrList(self, openid, okrlist): <NEW_LINE> <INDENT> if OpenOkr.objects.filter(openid=openid): <NEW_LINE> <INDENT> if okrlist is not None and okrlist != '': <NEW_LINE> <INDENT> OpenOkr.objects.filter(openid=openid).update(okrlist=str(okrlist).strip()) <NEW_LINE> return True <NEW_LINE> <DEDENT> <DEDENT> else: <NEW... | 保存用户信息
:param openid:
:param okrlist:
:return: | 625941ca656771135c3eb90b |
def generate_header_file(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> input_reader = pywrap_tensorflow.NewCheckpointReader(FLAGS.input_path) <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> raise e <NEW_LINE> <DEDENT> cnn_config, weights, biases = _extract_layer_variables(input_reader) <NEW_LINE> asser... | Generates a C header file from a Tensorflow model ckpt. | 625941ca66656f66f7cbc247 |
def IsSinglyConnected(nodes): <NEW_LINE> <INDENT> for node_id, _ in enumerate(nodes): <NEW_LINE> <INDENT> if HasForwardOrCrossLink(nodes, node_id): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> return True | Determine if a directed graph is singly connected.
Args:
nodes: adjacency lists representation of a directed graph, a list of Node.
Returns:
True: if `nodes` is singly connected.
False: otherwise. | 625941ca5f7d997b87174b34 |
def showPanel(self, panelID): <NEW_LINE> <INDENT> if panelID == self._curPanelID: return <NEW_LINE> if self._curPanelID is not None: <NEW_LINE> <INDENT> self._root.remove(self._panels[self._curPanelID]) <NEW_LINE> <DEDENT> self._root.add(self._panels[panelID]) <NEW_LINE> self._curPanelID = panelID | Show the panel with the given ID.
| 625941ca0a50d4780f666f2f |
def split(self, split_point): <NEW_LINE> <INDENT> if self.other_strand == '+': <NEW_LINE> <INDENT> return (Alignment(self.my_chrom, self.my_start, self.my_start + split_point, self.other_chrom, self.other_start, self.other_start + split_point, self.other_strand), Alignment(self.my_chrom, self.my_start + split_point, se... | Return two new alignments created by splitting this alignment at an offset relative to its start. | 625941caf8510a7c17cf9799 |
def all(self, data={}, **kwargs): <NEW_LINE> <INDENT> return super(Refund, self).all(data, **kwargs) | "
Fetch All Refund
Returns:
Refund dict | 625941ca8e05c05ec3eea411 |
def nms(dets, thresh, force_suppress=True, num_classes=1): <NEW_LINE> <INDENT> x1 = dets[:, 2] <NEW_LINE> y1 = dets[:, 3] <NEW_LINE> x2 = dets[:, 4] <NEW_LINE> y2 = dets[:, 5] <NEW_LINE> scores = dets[:, 1] <NEW_LINE> cids = dets[:, 0] <NEW_LINE> areas = (x2 - x1) * (y2 - y1) <NEW_LINE> order = scores.argsort()[::-1] <... | greedily select boxes with high confidence and overlap with current maximum <= thresh
rule out overlap >= thresh
:param dets: NDArray, [[cid, score, x1, y1, x2, y2]]
:param thresh: retain overlap < thresh
:return: indexes to keep | 625941ca32920d7e50b2826c |
def query_kwargs(self, eq_fields, fields): <NEW_LINE> <INDENT> kwargs = {'%s__eq' % self.hash_key.name: self.hash_key.resolve(scope=eq_fields)} <NEW_LINE> if self.index_name is not None: <NEW_LINE> <INDENT> kwargs['index'] = self.index_name <NEW_LINE> <DEDENT> remaining = set(eq_fields) <NEW_LINE> remaining = remaining... | Get the query and filter kwargs for querying against this index | 625941cade87d2750b85fe2f |
def rate_limited(hz: float): <NEW_LINE> <INDENT> def decorator_rate_limit(decorated_fn): <NEW_LINE> <INDENT> last_invocation = 0 <NEW_LINE> nanos_per_invocation = 1000000000 / hz <NEW_LINE> rate_limited_value = None <NEW_LINE> def rate_limited_fn(*args, **kwargs): <NEW_LINE> <INDENT> nonlocal last_invocation <NEW_LINE>... | Describe how often a method should be called from your loop().
You call this every loop() iteration and it invokes your method
on your schedule.
:param hz: How many times per second should the function run?
:return: Decorator for your function suitable for loop(). | 625941ca30dc7b7665901a04 |
def test_valid_self(self): <NEW_LINE> <INDENT> cert = self.generate_certificate() <NEW_LINE> self.assertIsNone(cert.validate([cert], None, None, None)) | Test validation of X.509 self-signed certificate | 625941cabde94217f3682e8e |
@db_session <NEW_LINE> def get_data_for_hotel(hotel_name, filter): <NEW_LINE> <INDENT> loc_hotel = Hotel.get(name=hotel_name) <NEW_LINE> if loc_hotel is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raw_sql_filter = generate_raw_filer(filter) <NEW_LINE> if len(raw_sql_filter) == 0:... | If all reviews from hotel are necessary.
Args:
hotel_name (str): The name of the Hotel.
Returns:
list of serialized data from Reviews of None if no data or no such Hotel. | 625941ca004d5f362079a3d0 |
def __init__(self, latex, parens=None, tall=False): <NEW_LINE> <INDENT> self.latex = latex <NEW_LINE> self.sans_parens = latex <NEW_LINE> self.tall = tall <NEW_LINE> if parens is not None: <NEW_LINE> <INDENT> left_parens = parens <NEW_LINE> if left_parens == '{': <NEW_LINE> <INDENT> left_parens = r'\{' <NEW_LINE> <DEDE... | Instantiate with the latex representing the math.
Optionally include parenthesis to wrap around it and the height.
`parens` must be one of '(', '[' or '{'.
`tall` is a boolean (see note above). | 625941cabe8e80087fb20ce1 |
def DrawLaser(self, laser, reverse=0): <NEW_LINE> <INDENT> x2 = laser.vector.x <NEW_LINE> if reverse: <NEW_LINE> <INDENT> x2 -= laser.velocity.x <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> x2 += laser.velocity.x <NEW_LINE> <DEDENT> pygame.draw.line(self.screen, self.colours[laser.player][self.Tower.Values.SECONDARY],... | Draw a specific laser. | 625941ca796e427e537b0663 |
def make_soup(url): <NEW_LINE> <INDENT> htmlFile = urllib.request.urlopen(url).read() <NEW_LINE> soup = BeautifulSoup(htmlFile) <NEW_LINE> return soup | Makes a BeautifulSoup object from a url.
Parameters:
url: string url for webpage to parse | 625941ca99cbb53fe6792c84 |
def parameter_spec(self): <NEW_LINE> <INDENT> return OrderedDict(sorted(SAMModule.parameter_spec().items())) | Returns the minima-maxima of each explorable variable.
Note: Dictionary is an OrderedDict with items sorted by key, to
ensure that items are interpreted in the same way everywhere. | 625941ca4f88993c3716c105 |
def do_plot(self, args, mgr=None): <NEW_LINE> <INDENT> self.plot_mptcpstream(args) | Plot DSN vs time | 625941cad99f1b3c44c6762c |
def test_makefile_root(self): <NEW_LINE> <INDENT> test_path = path.join(self._get_project_root(), 'main.c') <NEW_LINE> mfile = Makefile(['-I', '-isystem']) <NEW_LINE> flags = mfile.get_flags(test_path) <NEW_LINE> self._check_include(flags, "inc") <NEW_LINE> self._check_define(flags, "REQUIRED_DEFINE") <NEW_LINE> self._... | Test finding and parsing root Makefile. | 625941ca498bea3a759b9b4c |
def create_service_ecs(service_id, environment_id, asset_obj_id, operator=None): <NEW_LINE> <INDENT> pass | 创建服务关联ECS | 625941cad486a94d0b98e1e2 |
def signalTransferEnded(self, engine_path, workflow_id): <NEW_LINE> <INDENT> if workflow_id != -1: <NEW_LINE> <INDENT> self._database_server.add_workflow_ended_transfer( workflow_id, engine_path) | Has to be called each time a file transfer ends for the
workflows to be proceeded. | 625941cad18da76e23532573 |
def unconfigure_pins(): <NEW_LINE> <INDENT> GPIO.cleanup() | A function to unconfigure the GPIO pins. | 625941cabde94217f3682e8f |
def class_to_json(obj): <NEW_LINE> <INDENT> return (obj.__dict__) | function that returns the dictionary description with simple
data structure (list, dictionary, string, integer and boolean)
for JSON serialization of an object | 625941ca30bbd722463cbe63 |
def setup_package(): <NEW_LINE> <INDENT> global TEST_WORKSPACE <NEW_LINE> TEST_WORKSPACE = env.get_workspace('cppcheck') <NEW_LINE> os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE <NEW_LINE> codechecker_cfg = { 'suppress_file': None, 'skip_list_file': None, 'check_env': env.test_env(TEST_WORKSPACE), 'workspace': TEST_WOR... | Setup the environment for the tests then start the server. | 625941ca7b25080760e394f7 |
def projects_upload_to(instance, filename): <NEW_LINE> <INDENT> today = timezone.now().strftime("%Y/%m") <NEW_LINE> return "projects/{date}/{slug}/{filename}".format( date=today, slug=instance.project.slug, filename=filename) | construct path to uploaded project archives | 625941ca4e4d5625662d4476 |
def do_precise(array, val, indices): <NEW_LINE> <INDENT> if index_dom.size(indices) == 1: <NEW_LINE> <INDENT> not_relevant, relevant = partition( array, lambda elem: index_dom.is_empty( index_dom.meet(indices, elem[0]) ) ) <NEW_LINE> updated_relevant = [ (split, elem[1]) for elem in relevant for split in index_dom.spli... | :param list array: A set of arrays to update, represented by an
element of the sparse array domain.
:param object val: A set of concrete values to update the arrays with,
represented by an element of the sparse array domain's element
domain.
:param object indices: A set of indices to update the array at,
... | 625941ca460517430c394224 |
def pattern_matching(self): <NEW_LINE> <INDENT> self.pm = {} <NEW_LINE> method = cv2.TM_CCOEFF_NORMED <NEW_LINE> threshold = self.pm_thresh <NEW_LINE> cw, ch = self.crop.shape[::-1] <NEW_LINE> for temp in self.temp_num: <NEW_LINE> <INDENT> highest = 0 <NEW_LINE> highest_pt = [] <NEW_LINE> for i in range(1, 4): <NEW_LIN... | Pattern Matching is used to identify numbers in the cropped image
CV_TM_CCOEFF is used in this case
* Result is still not accurate | 625941caad47b63b2c50a01d |
def _init_result(self): <NEW_LINE> <INDENT> self._columns = self._connection.get_column_metadata(self) <NEW_LINE> self._has_more_data = True if len(self._columns) > 0 else False <NEW_LINE> self._items = [] <NEW_LINE> self._page_size = 20 <NEW_LINE> self._position = -1 <NEW_LINE> self._connection.set_active_result(self ... | Initialize the result. | 625941caa4f1c619b28b00d8 |
def test_write_page_margins_top(self): <NEW_LINE> <INDENT> self.worksheet.set_margins(top=0.5) <NEW_LINE> self.worksheet._write_page_margins() <NEW_LINE> exp = """<pageMargins left="0.7" right="0.7" top="0.5" bottom="0.75" header="0.3" footer="0.3"/>""" <NEW_LINE> got = self.fh.getvalue() <NEW_LINE> self.assertEqual(go... | Test the _write_page_margins() method with top margin | 625941ca1f037a2d8b94629b |
def test_config_util_initialisation(): <NEW_LINE> <INDENT> template = fudge.Fake("template") <NEW_LINE> config_util = ConfigUtil(template) <NEW_LINE> config_util.values |should| equal_to({}) <NEW_LINE> config_util.template |should| be(template) | Test ConfigUtil initialises properly | 625941ca8e71fb1e9831d847 |
def test_title_multiple_valuekeys(self): <NEW_LINE> <INDENT> options = [ { "title": "title", "values": [ ["key"], ["key2"] ] } ] <NEW_LINE> expected = { "title": [ ("key\tDefault", "key"), ("key2\tDefault", "key2") ] } <NEW_LINE> compiled_key_values = COMPLETION_COMPILER.compile_values(options) <NEW_LINE> self.assertEq... | . | 625941ca009cb60464c6344f |
def _handleSslErrors(self, reply, errorList): <NEW_LINE> <INDENT> url = reply.url().toDisplayString() <NEW_LINE> server = self.getServerFromString(url) <NEW_LINE> certificate = binascii.hexlify(errorList[0].certificate().digest()).decode('utf-8') <NEW_LINE> if server.acceptInsecureCertificate() == certificate: <NEW_LIN... | Called when an SSL error occur | 625941cad8ef3951e32435db |
def get_key(self, key_name=None, public=True): <NEW_LINE> <INDENT> if key_name is None: <NEW_LINE> <INDENT> key_name = 'default' <NEW_LINE> <DEDENT> key_name = key_name + '.pub' if public else key_name <NEW_LINE> key = self.keys.get(key_name) <NEW_LINE> if not key: <NEW_LINE> <INDENT> raise KeyException('No such key: %... | Retrieves a :class:`Key` by name.
:param key_name: ``str``, the name of the key to retrieve. If not given, the default value is ``default``.
:returns: :class:`Key` if the key is found; otherwise raises :class:`KeyException`. | 625941ca8da39b475bd65011 |
def _gen_names(self, prefix): <NEW_LINE> <INDENT> self.transform = '%s_xfm.xfm' % prefix <NEW_LINE> self.inv_transform = '%s_inv_xfm.xfm' % prefix <NEW_LINE> self.transform_grid = '%s_xfm_grid_0.mnc' % prefix <NEW_LINE> self.inv_transform_grid = '%s_inv_xfm_grid_0.mnc' % prefix <NEW_LINE> self.grid = '%s_grid_0.mnc' % ... | generate temporary file names bases on prefix | 625941caff9c53063f47c291 |
def _has_onchange(self, field, other_fields): <NEW_LINE> <INDENT> return field.name in self._onchange_methods or any(dep in other_fields for dep, _ in self._field_triggers[field]) | Return whether ``field`` should trigger an onchange event in the
presence of ``other_fields``. | 625941ca44b2445a33932134 |
def test_no_init_values(): <NEW_LINE> <INDENT> import dynamicmethod <NEW_LINE> class Example(object): <NEW_LINE> <INDENT> x = 0 <NEW_LINE> y = 0 <NEW_LINE> @dynamicmethod <NEW_LINE> def get_x(self): <NEW_LINE> <INDENT> return self.x <NEW_LINE> <DEDENT> @dynamicmethod <NEW_LINE> def get_y(self): <NEW_LINE> <INDENT> retu... | Test if init does not set the initial value for the instance. | 625941ca4a966d76dd5510ac |
def compress_amount(n): <NEW_LINE> <INDENT> if not n: return 0 <NEW_LINE> e = 0 <NEW_LINE> while (n % 10) == 0 and e < 9: <NEW_LINE> <INDENT> n = n // 10 <NEW_LINE> e = e + 1 <NEW_LINE> <DEDENT> if e < 9: <NEW_LINE> <INDENT> n, d = divmod(n, 10); <NEW_LINE> return 1 + (n*9 + d - 1)*10 + e <NEW_LINE> <DEDENT> else: <NEW... | Compress 64-bit integer values, preferring a smaller size for whole
numbers (base-10), so as to achieve run-length encoding gains on real-
world data. The basic algorithm:
* If the amount is 0, return 0
* Divide the amount (in base units) evenly by the largest power of 10
possible; call the exponent e (e ... | 625941cae5267d203edcdd3c |
def _load_pupil(self): <NEW_LINE> <INDENT> conn = databaseHandler.openConnection() <NEW_LINE> c = conn.cursor() <NEW_LINE> c.execute("SELECT * FROM pupils WHERE actor_id=?",[self.id]) <NEW_LINE> alldetails = list(c.fetchall()) <NEW_LINE> c.execute("SELECT * FROM homework_set WHERE actor_id=?",[self.id]) <NEW_LINE> all_... | If the actor is a pupil they have some extra
information that must be loaded separately.
Internal function, shouldn't be called outside of
actor class | 625941ca94891a1f4081bb47 |
def __init__(self, vocabulary: Vocabulary, tag_namespace: str = "tags", ignore_classes: List[str] = None, label_encoding: str = "BIO") -> None: <NEW_LINE> <INDENT> if label_encoding not in ["BIO", "BIOUL"]: <NEW_LINE> <INDENT> raise ConfigurationError("Unknown label encoding - expected 'BIO' or 'BIOUL'.") <NEW_LINE> <D... | Parameters
----------
vocabulary : ``Vocabulary``, required.
A vocabulary containing the tag namespace.
tag_namespace : str, required.
This metric assumes that a BIO format is used in which the
labels are of the format: ["B-LABEL", "I-LABEL"].
ignore_classes : List[str], optional.
Span labels which will... | 625941ca4e696a04525c94e9 |
def GetSizeOfObjectInPixels(self, *args): <NEW_LINE> <INDENT> return _itkRelabelComponentImageFilterPython.itkRelabelComponentImageFilterIUL3IUC3_GetSizeOfObjectInPixels(self, *args) | GetSizeOfObjectInPixels(self, unsigned long obj) -> unsigned long | 625941ca099cdd3c635f0cf9 |
def count(self): <NEW_LINE> <INDENT> elements = self.find() <NEW_LINE> return len(elements) | Get count of elements. | 625941ca7c178a314d6ef4fc |
def is_created_reader(id_controller: str, id_reader: str) -> bool: <NEW_LINE> <INDENT> filtered = list( filter( filter_last_data_reader(id_reader), enumerate(list_data[id_controller]) ) ) <NEW_LINE> return len(filtered) > 0 | Return True if SensorData with idController and IdReader is
Already Created. | 625941ca85dfad0860c3aef8 |
def __init__(self, api_key=None, language='ko-KR'): <NEW_LINE> <INDENT> self._logger = logging.getLogger(__name__) <NEW_LINE> self._request_url = None <NEW_LINE> self._language = None <NEW_LINE> self._api_key = None <NEW_LINE> self._http = requests.Session() <NEW_LINE> self.language = language <NEW_LINE> self.api_key =... | Arguments:
api_key - the public api key which allows access to Google APIs | 625941ca009cb60464c63450 |
def __init__(self): <NEW_LINE> <INDENT> self.threads = [] <NEW_LINE> self.data_requests = {} | Controller instance initializer.
| 625941ca3c8af77a43ae383e |
def test_useroldid_get(self): <NEW_LINE> <INDENT> crusoe = self.fixtures.crusoe <NEW_LINE> bathound = models.User(username="bathound", fullname="Bathound") <NEW_LINE> db.session.add(bathound) <NEW_LINE> db.session.commit() <NEW_LINE> merged = models.merge_users(crusoe, bathound) <NEW_LINE> if merged == crusoe: <NEW_LIN... | Test for verifying creation and retrieval of UserOldId instance | 625941ca8e05c05ec3eea412 |
def filter_queryset(self, queryset): <NEW_LINE> <INDENT> queryset = queryset.filter(parent__isnull=True) <NEW_LINE> query = self.request.query_params.get('q', None) <NEW_LINE> if query: <NEW_LINE> <INDENT> queryset = queryset.filter(Q(name__icontains=query) | Q(name_th__icontains=query) | Q(type__icontains=query) | Q(i... | Override 'get_queryset' method in order to customize filter | 625941ca6e29344779a626b0 |
def __getattr__(self, name: str) -> Any: <NEW_LINE> <INDENT> return getattr(self.orig_method, name) | Proxy all unknown attributes to the original method.
This is important for some of the decorators in the `unittest`
module, such as `unittest.skipIf`. | 625941ca85dfad0860c3aef9 |
def fetch_hourly(self, hour=None, dry_run=False, force_update=False): <NEW_LINE> <INDENT> raise NotImplementedError | Fetch the specified hourly chart for this service and update the relevant table
:param datetime hour: The specific (tz aware) hour to update. If no hour is specified, the current live chart
will be fetched.
:param bool dry_run: True if the chart data should not be written to the database.
:param bool force_update:... | 625941ca26238365f5f0ef0b |
def recompile(source, filename, mode, flags=0, firstlineno=1, privateprefix=None): <NEW_LINE> <INDENT> if isinstance(source, ast.AST): <NEW_LINE> <INDENT> a = source <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> a = parse_snippet(source, filename, mode, flags, firstlineno) <NEW_LINE> <DEDENT> node = a.body[0] <NEW_LINE... | recompile output of uncompile back to a code object.
source may also be preparsed AST | 625941ca7c178a314d6ef4fd |
@orderby.command() <NEW_LINE> @click.argument('name') <NEW_LINE> def tag(name): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> manager = Actions() <NEW_LINE> ordered_tasks = manager.order_by_tag(name) <NEW_LINE> click.echo("Ordered by tag:" + name) <NEW_LINE> click.echo() <NEW_LINE> console_utils.format_print_ordered(ord... | Ordering task by tag | 625941ca91f36d47f21ac590 |
def to_singular(name): <NEW_LINE> <INDENT> return name[:-1] if name.endswith("s") else name | Convert the name to singular if it is plural
This just trims a trailing 's', if found. | 625941ca2ae34c7f2600d1cf |
def cget(self, *args): <NEW_LINE> <INDENT> return self.canvas.itemcget(self.tag, *args) | look up the value of the given option for this item. | 625941ca3617ad0b5ed67f95 |
def __init__(self, spark_session, spark_context): <NEW_LINE> <INDENT> self.spark_session = spark_session <NEW_LINE> self.spark_context = spark_context <NEW_LINE> self.jvm = self.spark_context._jvm <NEW_LINE> self.jcatalog = spark_session._jsparkSession.catalog() | Setting up defaults and holders until real values are known. | 625941ca1f037a2d8b94629c |
def get_features_and_label(df) : <NEW_LINE> <INDENT> return df[df.columns[:-1]],df[df.columns[-1]] | returns the features data frame and label | 625941ca5fcc89381b1e175c |
def get_name(self, id): <NEW_LINE> <INDENT> if id in self.database: <NEW_LINE> <INDENT> return self.database[id] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return ':'.join(id[i:i+2] for i in xrange(0, len(id), 2)) | returns the name associated with the given id
Arguments:
id -- a node id (without colons) | 625941ca5510c4643540f484 |
def get_voltage(self): <NEW_LINE> <INDENT> voltage = self.pirasmart.pira_voltage <NEW_LINE> return voltage | Get voltage | 625941ca1f5feb6acb0c4bf0 |
def get_children(self): <NEW_LINE> <INDENT> children = Category.objects.get_child_tree_from_list( self.project, (self,), with_root=False) <NEW_LINE> return children | Returns a list of Category objects that are children of this category. | 625941cad7e4931a7ee9dfbc |
def reg_get_all_keys(self, hive_name, user = None, start = None, end = None, reg = False): <NEW_LINE> <INDENT> keys = [] <NEW_LINE> if self.all_offsets == {}: <NEW_LINE> <INDENT> self.populate_offsets() <NEW_LINE> <DEDENT> if self.current_offsets == {}: <NEW_LINE> <INDENT> self.set_current(hive_name, user) <NEW_LINE> <... | This function enumerates all keys in specified hives and
collects lastwrite times. | 625941ca1f5feb6acb0c4bef |
def _calculateNumberOfSequences(self): <NEW_LINE> <INDENT> self._seqMap = {} <NEW_LINE> seqCounter = 0 <NEW_LINE> for fhIdx, fh in enumerate(self._fileHandlers): <NEW_LINE> <INDENT> for k in fh['inputs'].keys(): <NEW_LINE> <INDENT> self._seqMap[seqCounter] = (fhIdx, k) <NEW_LINE> seqCounter += 1 <NEW_LINE> <DEDENT> <DE... | Calculate and return the number of sequences in the dataset.
This method also initializes a sequences map which maps sequence
indices into HDF file handlers.
:rtype: int
:return: the number of sequences in the dataset | 625941ca656771135c3eb90c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.