code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def update(self, key, value, prev_leaf_hash): <NEW_LINE> <INDENT> rv, _ = self._client("PUT", self._path + "/key/h/" + binascii.hexlify(key) + value.format(), value.data_for_upload(), extraHeaders={ "X-Previous-LeafHash": binascii.hexlify(prev_leaf_hash.leaf_hash())}) <NEW_LINE> return AddEntryResponse(base64.b64decode... | Set the value for a given key in the map, conditional on previous leaf hash.
Calling this has the effect of adding a
mutation to the mutation log for the map, which then reflects in the root hash for
the map. This occurs asynchronously.
key the key to set.
value the entry to set to key to. Typically one of RawDataEntry... | 625941c87d847024c06be32c |
def set_salario(self, salario): <NEW_LINE> <INDENT> self.__salario = salario | Setar o salário do político. | 625941c81f037a2d8b94626f |
def write_uint32(self, value, little_endian=True): <NEW_LINE> <INDENT> if little_endian: <NEW_LINE> <INDENT> endian = '<' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> endian = '>' <NEW_LINE> <DEDENT> return self.pack('%sI' % endian, value) | Pack the value as an unsigned integer and write 4 bytes to the stream. | 625941c844b2445a33932108 |
def writeData(self, device_id, jsondata, packet_size=None, considered_packets=None): <NEW_LINE> <INDENT> if packet_size is None: <NEW_LINE> <INDENT> json_packets = [jsondata] <NEW_LINE> considered_packets = set({0}) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> json_packets = list(chunks(jsondata, packet_size)) <NEW_LI... | Writes data to IoT-Ticket and returns a list of responces.
The jsondata is expected to contain valid data as a list of json objects.
Using packet_size parameter the data sending can be serialized to smaller packets.
Using considered_packets (containing packet numbers) only part of the data can be sent. | 625941c81d351010ab855b8d |
def wallsAndGates(self, rooms): <NEW_LINE> <INDENT> if not any(rooms): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> neighbours=((-1,0),(1,0),(0,1),(0,-1)) <NEW_LINE> cur=set() <NEW_LINE> INF=2**31-1 <NEW_LINE> m,n=len(rooms),len(rooms[0]) <NEW_LINE> for i in range(m): <NEW_LINE> <INDENT> for j in range(n): <NEW_LINE>... | :type rooms: List[List[int]]
:rtype: void Do not return anything, modify rooms in-place instead. | 625941c856b00c62f0f146ca |
def sumar_numeros(a,b,c): <NEW_LINE> <INDENT> suma = a + b + c <NEW_LINE> if a == b and a==c: <NEW_LINE> <INDENT> suma *= 3 <NEW_LINE> <DEDENT> return suma | Calcula la suma de tres números. Si los tres son iguales,
la suma se multiplica por tres | 625941c83d592f4c4ed1d0e1 |
def SetInputForegroundValue(self, *args): <NEW_LINE> <INDENT> return _itkBinaryImageToStatisticsLabelMapFilterPython.itkBinaryImageToStatisticsLabelMapFilterIUL2IF2LM2_SetInputForegroundValue(self, *args) | SetInputForegroundValue(self, unsigned long _arg) | 625941c8f8510a7c17cf976d |
def surface(*args, **kwargs): <NEW_LINE> <INDENT> pass | The cmd creates a NURBS spline surface (rational or non rational). The surface
is created by specifying control vertices (CV's) and knot sequences in the U and
V direction. You cannot query the properties of the surface using this command.
See examples below.
Flags:
- degreeU : du (int) [c... | 625941c8004d5f362079a3a5 |
def portfolio_stock_amount(df,trade_amount): <NEW_LINE> <INDENT> new_df = df.mul(trade_amount, axis=1) <NEW_LINE> return new_df | Multiply the stock price by the corresponding amount | 625941c8e76e3b2f99f3a87e |
def dbinit( *args, **kwargs ): <NEW_LINE> <INDENT> pass | If datastore does not exist, create one. Also intialize
configuration tables for each mounted application under
[mountloc] section. Expect this method to be called when ever platform
starts-up. For more information refer to corresponding plugin's
documentation. | 625941c88e05c05ec3eea3e5 |
def partial_redditors(self, ids: Iterable[str]) -> Iterator[PartialRedditor]: <NEW_LINE> <INDENT> iterable = iter(ids) <NEW_LINE> while True: <NEW_LINE> <INDENT> chunk = list(islice(iterable, 100)) <NEW_LINE> if not chunk: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> params = {"ids": ",".join(chunk)} <NEW_LINE> try: <... | Get user summary data by redditor IDs.
:param ids: An iterable of redditor fullname IDs.
:returns: A iterator producing types.SimpleNamespace objects.
Each ID must be prefixed with ``t2_``.
Invalid IDs are ignored by the server. | 625941c867a9b606de4a7f2c |
def get_dict_car_brand(): <NEW_LINE> <INDENT> car_brands = pd.read_csv(car_brands_filepath, delimiter=',', header=None) <NEW_LINE> dict = {car_brands.values[i, 0]: i for i in range(0, len(car_brands.values))} <NEW_LINE> return dict | Get the dictionary for encoding the car brands.
@return: the dictionary | 625941c8d53ae8145f87a2e3 |
def extfun(): <NEW_LINE> <INDENT> return 'Hello World external function!' | Return a friendly HTTP greeting. | 625941c83c8af77a43ae3811 |
def test_map_coef_pass_refit_OLS(example_results, tmpdir, read_image): <NEW_LINE> <INDENT> image = tmpdir.join('ols_refitmap.gtif').strpath <NEW_LINE> runner = CliRunner() <NEW_LINE> result = runner.invoke( cli, ['-v', 'map', '--root', example_results['root'], '--result', example_results['results_dir'], '--image', exam... | Make a map with refit OLS results
| 625941c8d8ef3951e32435af |
@pytest.mark.unit <NEW_LINE> @pytest.mark.parametrize("problem_name, org_name, geo_name, num_followers", [ ('Homelessness', None, None, 100000), ('Homelessness', None, 'Austin', 10000), ('Sexual Assault', 'University of Texas', None, 10000), ('Sexual Assault', 'University of Texas', 'Austin', 5000), ('Homeless Often La... | Test vardygrify by comparing vardygr and real communities | 625941c8d6c5a102081440bc |
def export_table(self, table, export_dir, input_null_string, input_null_non_string, staging_table, clear_staging_table, enclosed_by, escaped_by, input_fields_terminated_by, input_lines_terminated_by, input_optionally_enclosed_by, batch, relaxed_isolation): <NEW_LINE> <INDENT> cmd = self._export_cmd(table, export_dir, i... | Exports Hive table to remote location. Arguments are copies of direct
sqoop command line Arguments
:param table: Table remote destination
:param export_dir: Hive table to export
:param input_null_string: The string to be interpreted as null for
string columns
:param input_null_non_string: The string to be interpret... | 625941c8442bda511e8be48b |
def main(): <NEW_LINE> <INDENT> with open(sys.argv[1], 'r') as nbfile: <NEW_LINE> <INDENT> notebook = json.load(nbfile) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> del notebook['metadata']['kernelspec'] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> for cell in notebook['cells']: <NE... | Sanitizes the loaded *.ipynb. | 625941c891f36d47f21ac563 |
@app.route("/rn") <NEW_LINE> def random_number(): <NEW_LINE> <INDENT> wat = random.random() <NEW_LINE> return "random: {}".format(wat) | Return a random string | 625941c894891a1f4081bb1b |
def create_macvtap_xml(self): <NEW_LINE> <INDENT> iface = self.kwargs.get('iface') <NEW_LINE> if not iface: <NEW_LINE> <INDENT> raise exceptions.TestError('Create macvtap need iface be set') <NEW_LINE> <DEDENT> net_xml = NetworkXML() <NEW_LINE> net_xml.name = self.name <NEW_LINE> net_xml.forward = {'mode': 'bridge', 'd... | Create XML for a macvtap network. | 625941c8cad5886f8bd2704b |
def __getnewargs__(self) -> Tuple[str, Optional[i18nCatalog]]: <NEW_LINE> <INDENT> return (self.getId(), self._i18n_catalog) | For pickle support | 625941c826238365f5f0eedf |
def disjoint_intervals(starts, ends, ids): <NEW_LINE> <INDENT> _check_disjoint_intervals_inputs(starts, ends, ids) <NEW_LINE> d_j = {} <NEW_LINE> for i, start in enumerate(starts): <NEW_LINE> <INDENT> d_j.setdefault(start, []).append((1, ids[i])) <NEW_LINE> <DEDENT> for i, end in enumerate(ends): <NEW_LINE> <INDENT> d_... | Return list of disjoint intervals.
Produce the set of disjoint intervals from a list of start and end
positions (same chr) and optionally ids.
Empty intervals are reported as well.
!!! The intervals need to be sorted by start and end position before
calling the function and the coordinates should be inclusive.
>>> di... | 625941c866673b3332b92103 |
def timedelta(uom, duration): <NEW_LINE> <INDENT> if not isinstance(uom, str): <NEW_LINE> <INDENT> raise TypeError('Argument "uom" expects type str.') <NEW_LINE> <DEDENT> if not isinstance(duration, int): <NEW_LINE> <INDENT> raise TypeError('Argument "duration" expects type int.') <NEW_LINE> <DEDENT> allowed = ['d', 's... | Generate a datetime timedelta object by using unit of measurements and durations
:param uom: unit of measurement ("d" / "s" / "min" / "h")
:type uom: str
:param duration: duration
:type duration: int
:returns: generated timedelta object
:rtype: object | 625941c8f8510a7c17cf976e |
def main(): <NEW_LINE> <INDENT> args = process_arguments() <NEW_LINE> words = set(" {} ".format(w.rstrip()) for w in args.wordlist) <NEW_LINE> args.wordlist.close() <NEW_LINE> cyphertext = " {} ".format(args.cyphertext.read().rstrip().lower()) <NEW_LINE> args.cyphertext.close() <NEW_LINE> best_shift = 0 <NEW_LINE> best... | Application Entry Point | 625941c829b78933be1e571f |
def test_fields_default_value(self): <NEW_LINE> <INDENT> user = User.objects.create_user( username=self.DUMMY_USERNAME, password=self.DUMMY_PASSWORD ) <NEW_LINE> self.assertEqual(user.first_name, '') <NEW_LINE> self.assertEqual(user.last_name, '') <NEW_LINE> self.assertEqual(user.email, '') <NEW_LINE> self.assertEqual(... | 유저 생성시 필드의 기본값이 원하는 형태로 들어가 있는지 | 625941c857b8e32f5248350c |
def DevTeam_Add(request, pk): <NEW_LINE> <INDENT> User = get_user_model() <NEW_LINE> access_key = settings.USERNAME_FIELD <NEW_LINE> try: <NEW_LINE> <INDENT> candidate = User.objects.get(pk=pk) <NEW_LINE> <DEDENT> except User.DoesNotExist: <NEW_LINE> <INDENT> messages.error(request,"Candidate Not Found [%s]" % pk) <NEW... | Add a Candidate to the Developer Database as a Team Member
:param request:
:param pk:
:return: | 625941c81f5feb6acb0c4bc4 |
def get_range(self, range_index): <NEW_LINE> <INDENT> from_range = self.from_spinboxes[range_index].value() <NEW_LINE> to_range = self.to_spinboxes[range_index].value() <NEW_LINE> return from_range, to_range | Creates the tupe with the start and end page of that range
:param range_index: The index of the range
:return: The tuple (from_page, to_page) as pagenumbers | 625941c8a934411ee3751706 |
def fix_logs(uid, start_date, end_date): <NEW_LINE> <INDENT> start_date = '{:%d/%m/%Y}'.format(start_date) <NEW_LINE> end_date = '{:%d/%m/%Y}'.format(end_date) <NEW_LINE> day_count = (end_date - start_date) + 1 <NEW_LINE> for date in (start_date + datetime.timedelta(i) for i in range(day_count)): <NEW_LINE> <INDENT> da... | Fix logs of uid from start_date to end_date
A normalized log contains 2 logs per day
One check in log before 8:00
One check out log after 17:00 | 625941c8009cb60464c63424 |
def checkResources(zipName, tempDir): <NEW_LINE> <INDENT> if os.path.isfile(zipName): <NEW_LINE> <INDENT> unpackResources(zipName, tempDir) <NEW_LINE> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | Unpacks resources if zipped.
returns True if resources are unpacked from zip. | 625941c8eab8aa0e5d26dbca |
def gen_correct(self, dirs=None): <NEW_LINE> <INDENT> if self.use_liks and dirs is None: <NEW_LINE> <INDENT> correct = np.full(self.L, np.nan) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if dirs is not None: <NEW_LINE> <INDENT> assert dirs.size == self.L <NEW_LINE> dirs = np.array(dirs) <NEW_LINE> <DEDENT> correct = ... | Tries to figure out correct choice from directions and criteria. | 625941c8d268445f265b4ee0 |
def to_url_query_format(self): <NEW_LINE> <INDENT> return urlencode(self.to_dict()) | Returns a URL query format string of all shipping attributes.
:return: String | 625941c86aa9bd52df036e16 |
@bot_action("zalgofy") <NEW_LINE> def zalgofy(update: Update, context: CallbackContext) -> None: <NEW_LINE> <INDENT> transform = zalgo().zalgofy <NEW_LINE> if context.args: <NEW_LINE> <INDENT> update.effective_message.reply_text(transform(update.effective_message.text.replace("/zalgofy ", "").strip())) <NEW_LINE> <DEDE... | Corrupt the way the text looks, and reply
:param update: object representing the incoming update.
:param context: object containing data about the command call. | 625941c8f9cc0f698b14066e |
def _compute(self): <NEW_LINE> <INDENT> algorithm = self._algorithm <NEW_LINE> from sage.matrix.all import MatrixSpace <NEW_LINE> self._maps = None <NEW_LINE> if algorithm == "database": <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> label = self.E.cremona_label(space=False) <NEW_LINE> <DEDENT> except RuntimeError: <NEW_... | Compute the list of curves, and possibly the matrix and
prime-degree isogenies (depending on the algorithm selected).
EXAMPLES::
sage: isocls = EllipticCurve('48a1').isogeny_class('sage').copy()
sage: isocls._mat
sage: isocls._compute(); isocls._mat
[0 2 2 2 0 0]
[2 0 0 0 2 2]
[2 0 0 0 0 0]
... | 625941c83317a56b86939ccd |
def parse_group(self, group, namespace=None, autostep=None): <NEW_LINE> <INDENT> assert self.group_resolver is not None <NEW_LINE> nodestr = self.group_resolver.group_nodes(group, namespace) <NEW_LINE> return self.parse(",".join(nodestr), autostep) | Parse provided single group name (without @ prefix). | 625941c87cff6e4e811179f8 |
def create_state(self, state_manager): <NEW_LINE> <INDENT> embedding_shape = (self.categorical_column.num_buckets, self.dimension) <NEW_LINE> state_manager.create_variable( name=self.shared_collection_name, shape=embedding_shape, dtype=dtypes.float32, trainable=self.trainable, initializer=self.initializer) | Creates the shared embedding lookup variable. | 625941c8851cf427c661a582 |
def set_AccessTokenSecret(self, value): <NEW_LINE> <INDENT> super(SendMessageInputSet, self)._set_input('AccessTokenSecret', value) | Set the value of the AccessTokenSecret input for this Choreo. ((required, string) The Access Token Secret retrieved during the OAuth process (AKA the OAuth User Secret).) | 625941c87c178a314d6ef4d1 |
def _spline3fit(self,xx,yy,dx_knots): <NEW_LINE> <INDENT> knots = np.linspace(xx[0],xx[-1],int((xx[-1]-xx[0])//dx_knots)) <NEW_LINE> knots_in = knots[1:-1] <NEW_LINE> npt_btw_knots = self._get_npt_btw_knots(xx,knots) <NEW_LINE> knots_in = knots_in[(npt_btw_knots[1:]>=1)|(npt_btw_knots[:-1]>=1)] <NEW_LINE> npt_btw_knots... | Spline fitting to a spectrum defined by xx and yy.
The interval between knots needs to be pre-defined. However,
if there are too few points between the knots, some knots can be
removed.
Parameters
----------
xx : array
yy : array
dx_knots : float
the interval between knots.
Returns
-------
spl : scipy.interpola... | 625941c810dbd63aa1bd2c16 |
def get_authored_courses(member, only_published=True): <NEW_LINE> <INDENT> course_details = [] <NEW_LINE> filters = { "instructor": member } <NEW_LINE> if only_published: <NEW_LINE> <INDENT> filters["published"] = True <NEW_LINE> <DEDENT> courses = frappe.get_all('LMS Course', filters) <NEW_LINE> for course in courses:... | Returns the number of courses authored by this user.
| 625941c83539df3088e2e3bd |
@typechecked <NEW_LINE> def identical_returns( x: Tensor[float, X, X, X], y: Tensor[float, Y, Y, Y], ) -> Tuple[Tensor[float, X, X, X], Tensor[float, X, X, X]]: <NEW_LINE> <INDENT> return x, y | Returns first argument with variable shape. | 625941c8ab23a570cc2501f4 |
def new_query_checker(good_shops, df, api_key=API_KEY, search_key=SEARCH_KEY, location_key=LOCATION_KEY): <NEW_LINE> <INDENT> saved_shops = query_gmaps(api_key, search_key, location_key) <NEW_LINE> count = 0 <NEW_LINE> for shops in saved_shops: <NEW_LINE> <INDENT> if any(df._id == shops['_id']): <NEW_LINE> <INDENT> pas... | check if the values in the new query are in the current database | 625941c8d10714528d5ffd54 |
def get_session(): <NEW_LINE> <INDENT> if not hasattr(get_session, "session"): <NEW_LINE> <INDENT> get_session.session = requests_cache.CachedSession( cache_name=CACHE_PATH.rstrip(".sqlite"), expire_after=518400, ) <NEW_LINE> adapter = HTTPAdapter(max_retries=3) <NEW_LINE> get_session.session.mount("http://", adapter) ... | Convenience function that returns request-cache session singleton. | 625941c84f6381625f114aae |
def __init__(self,pdf_file_path,mode = PDFHandleMode.COPY): <NEW_LINE> <INDENT> self.__pdf = PdfFileReader(pdf_file_path) <NEW_LINE> self.file_name = os.path.basename(pdf_file_path) <NEW_LINE> self.metadata = self.__pdf.getXmpMetadata() <NEW_LINE> self.doc_info = self.__pdf.getDocumentInfo() <NEW_LINE> self.pages_num =... | 用一个PDF文件初始化
:param pdf_file_path: PDF文件路径
:param mode: 处理PDF文件的模式,默认为PDFHandleMode.COPY模式 | 625941c88c3a87329515842c |
def __init__(self, text_file_path, report_dict, pat_parent_pheno_status): <NEW_LINE> <INDENT> self.text_file_path = text_file_path <NEW_LINE> self.report_dict = report_dict <NEW_LINE> self.pat_parent_pheno_status = pat_parent_pheno_status | :param text_file_path: 第三部分,表格前面的总结性信息,提供描述模板
:param report_dict: 受检者所有疾病信息汇总的字典
:param pat_parent_pheno_status: 受检者父母疾病表型,来源于基本信息配置文件,可由class GetBasicInfoOfPatient中的get_pat_parent_dis_pheno函数获得 | 625941c8442bda511e8be48c |
def test_fallback_language_no_current(self): <NEW_LINE> <INDENT> x = SimpleModel() <NEW_LINE> x.set_current_language(self.conf_fallback) <NEW_LINE> x.tr_title = "TITLE_FALLBACK" <NEW_LINE> self.assertEqual( x.safe_translation_getter('tr_title', language_code=self.other_lang1), 'TITLE_FALLBACK') | Test whether the fallback language will be returned,
even when the current language does not have a translation. | 625941c8b5575c28eb68e072 |
def asm_code_memory_restore_pointer_value(self, pointer_name, num_above_LCL): <NEW_LINE> <INDENT> assembly_codes = [ '@{}'.format(num_above_LCL), 'D=A', '@LCL', 'A=M-D', 'D=M', '@{}'.format(pointer_name), 'M=D', ] <NEW_LINE> return assembly_codes | Restore the value of pointer, given the pointer name and the location number above LCL | 625941c8f7d966606f6aa076 |
def render_snippet(*template_names: str, **kw: Any) -> str: <NEW_LINE> <INDENT> last_exc = None <NEW_LINE> for template_name in template_names: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> output = render(template_name, extra_vars=kw) <NEW_LINE> if config.get_value('debug'): <NEW_LINE> <INDENT> output = ( '\n<!-- Snipp... | Helper function for rendering snippets. Rendered html has
comment tags added to show the template used. NOTE: unlike other
render functions this takes a list of keywords instead of a dict for
the extra template variables.
:param template_names: the template to render, optionally with fallback
values, for when the ... | 625941c8e8904600ed9f1f9e |
def check_vies(vat): <NEW_LINE> <INDENT> import stdnum.eu.vat <NEW_LINE> return bool(stdnum.eu.vat.check_vies(vat)['valid']) | Check VAT number for EU member state using the SOAP Service | 625941c8d10714528d5ffd55 |
def read(self, chunk_size): <NEW_LINE> <INDENT> self._progress += READ_CHUNKSIZE <NEW_LINE> LOG.debug(_("Read %s bytes from vmdk.") % self._progress) <NEW_LINE> return self.file_handle.read(READ_CHUNKSIZE) | Read a chunk from file. | 625941c8004d5f362079a3a6 |
def new_component_instance(component, name) -> Component: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> module_name, class_name = component.rsplit(".", 1) <NEW_LINE> component_class = getattr(importlib.import_module(module_name), class_name) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> raise ComponentExcep... | Create a component instance (a process) given a component name.
The component name (formed module.class) is used to import the python module containing the class. A new class
instance is then created with the given name.
:param component: component name to load (in the form of module_name.class_name)
:param name: optio... | 625941c823e79379d52ee5d7 |
def maybe_tuple(value): <NEW_LINE> <INDENT> if isinstance(value, tuple): <NEW_LINE> <INDENT> return value <NEW_LINE> <DEDENT> return (value,) | Return `value` as a tuple. If it is already a tuple, return it
unchanged. Otherwise return a 1-element tuple containing `value`. | 625941c8507cdc57c6306d4c |
def render_density(self, cam, density, color=None): <NEW_LINE> <INDENT> density = atomize(density) <NEW_LINE> color = atomize(color) <NEW_LINE> scene = native.Scene(cam, density.top, color.top, self.scatter, self.dsm_size) <NEW_LINE> self.render_scene(scene) | Quickly render a density field, optionally with color. | 625941c8596a897236089b34 |
def main(): <NEW_LINE> <INDENT> logging.basicConfig(level=logging.INFO) <NEW_LINE> logger = logging.getLogger(__name__) <NEW_LINE> logger.info("Creating a database using the customer model.") <NEW_LINE> cm.DATABASE.create_tables([cm.Customer]) | Creates Customer table.
:return: | 625941c8d58c6744b4257cd3 |
def addProtocol(self, *protocols): <NEW_LINE> <INDENT> for protocol in protocols: <NEW_LINE> <INDENT> if isinstance(protocol, collections.abc.Iterable): <NEW_LINE> <INDENT> self._ifAndProto.extend(protocol) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._ifAndProto.append(protocol) | Add a protocol entity.
Also accepts iterables for adding multiple at once | 625941c89c8ee82313fbb7e7 |
def merge_argentina_data(self, import_or_export): <NEW_LINE> <INDENT> data_dir_home = Path('E:\cobus_group\阿根廷') <NEW_LINE> im_ex_dir = data_dir_home / import_or_export <NEW_LINE> data_type = im_ex_dir.name <NEW_LINE> data_title = list() <NEW_LINE> df = None <NEW_LINE> for date_dir in im_ex_dir.iterdir(): <NEW_LINE> <I... | 合并阿根廷数据
:param import_or_export: 进口或出口
:return: | 625941c87047854f462a147e |
def __init__(self, connection=None, namespace=""): <NEW_LINE> <INDENT> super(ExtendedMetrics, self).__init__(connection, namespace) | A convenience class for reporting metric samples
to a C{txstatsd} server configured with the
L{ConfigurableProcessor<txstatsd.server.configurableprocessor>}
processor.
@param connection: The connection endpoint representing
the C{txstatsd} server.
@param namespace: The top-level namespace identifying the
origi... | 625941c87d847024c06be32d |
def __init__(self, x, y, radius): <NEW_LINE> <INDENT> self.x = x <NEW_LINE> self.y = y <NEW_LINE> self.radius = radius | Initialize position & radius. | 625941c8cb5e8a47e48b7b1e |
def _validate_password(self, resource, request): <NEW_LINE> <INDENT> plain_passwd = resource.password <NEW_LINE> if request.method.lower() == "post" and (not (plain_passwd or "") or len(plain_passwd.strip()) == 0): <NEW_LINE> <INDENT> raise FantasticoRoaError("password attribute is mandatory when creating a new user.")... | This method validates the password from submitted resource. Additionally plain text passwords are hashed. | 625941c89f2886367277a901 |
def test_qy_py_printf(): <NEW_LINE> <INDENT> import sys <NEW_LINE> from cStringIO import StringIO <NEW_LINE> old_stdout = sys.stdout <NEW_LINE> try: <NEW_LINE> <INDENT> new_stdout = StringIO() <NEW_LINE> sys.stdout = new_stdout <NEW_LINE> @emit_and_execute() <NEW_LINE> def _(): <NEW_LINE> <INDENT> @qy.for_(8) <NEW_LINE... | Test the py_printf() LLVM construct with arguments. | 625941c850485f2cf553ce0c |
def _prepare_invoice(self, cr, uid, order, lines, context=None): <NEW_LINE> <INDENT> if context is None: <NEW_LINE> <INDENT> context = {} <NEW_LINE> <DEDENT> journal_id = self.pool['account.invoice'].default_get(cr, uid, ['journal_id'], context=context)['journal_id'] <NEW_LINE> if not journal_id: <NEW_LINE> <INDENT> ra... | Prepare the dict of values to create the new invoice for a
sales order. This method may be overridden to implement custom
invoice generation (making sure to call super() to establish
a clean extension chain).
:param browse_record order: sale.order record to invoice
:param list(int) line: list of invoice line IDs that ... | 625941c8adb09d7d5db6c803 |
@receiver(post_delete, sender=Coordinator, dispatch_uid="CoordinatorDeleted") <NEW_LINE> def post_delete_coordinator(sender, instance, **kwargs): <NEW_LINE> <INDENT> user = instance.user <NEW_LINE> user.is_staff = False <NEW_LINE> user.is_superuser = False <NEW_LINE> user.coordinator = None <NEW_LINE> user.save() | Automatically delete users if there's no profile attached to them
or adjust privileges | 625941c8097d151d1a222ecd |
def __init__(self, id, label, pattern_name=None, url=None, weight=0, title=None, template='navutils/node.html', children=[], css_class=None, reverse_kwargs=[], attrs={}, link_attrs={}, **kwargs): <NEW_LINE> <INDENT> if pattern_name and url: <NEW_LINE> <INDENT> raise ValueError('MenuNode accepts either a url or a patter... | :param str id: a unique identifier for further retrieval
:param str label: a label for the node, that will be displayed in templates
:param str pattern_name: the name of a django url, such as `myapp:index` to use
as a link for the node. It will be automatically reversed.
:param str url: a URL to use as a link for the n... | 625941c8bf627c535bc13242 |
def PlotCalSpecRadiance(self, savePath=None, saveExt='png'): <NEW_LINE> <INDENT> if self.calTablesCalculated: <NEW_LINE> <INDENT> numsubplots = len(list(self.dicCaldata.keys())) <NEW_LINE> p = ryplot.Plotter(1,numsubplots,1, figsize=(10,10)) <NEW_LINE> for j,tmprInstr in enumerate(self.dicCaldata): <NEW_LINE> <INDENT> ... | Plot spectral radiance data for the calibration temperatures.
The filename is constructed from the given object name, save path, and
the word 'CalRadiance'.
Args:
| savePath (string): Path to where the plots must be saved (optional).
| saveExt (string) : Extension to save the plot as, default of 'png' (option... | 625941c830dc7b76659019da |
def dump_model(self, fo, fmap='', with_stats = False): <NEW_LINE> <INDENT> if isinstance(fo,str): <NEW_LINE> <INDENT> fo = open(fo,'w') <NEW_LINE> need_close = True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> need_close = False <NEW_LINE> <DEDENT> ret = self.get_dump(fmap, with_stats) <NEW_LINE> for i in range(len(re... | dump model into text file
Args:
fo: string
file name to be dumped
fmap: string, optional
file name of feature map names
with_stats: bool, optional
whether output statistics of the split
Returns:
None | 625941c876e4537e8c3516e5 |
def update_index(units): <NEW_LINE> <INDENT> languages = Language.objects.have_translation() <NEW_LINE> if units.exists(): <NEW_LINE> <INDENT> index = get_source_index() <NEW_LINE> writer = BufferedWriter(index) <NEW_LINE> try: <NEW_LINE> <INDENT> for unit in units.iterator(): <NEW_LINE> <INDENT> update_source_unit_ind... | Update fulltext index for given set of units. | 625941c86fece00bbac2d7b1 |
def plot_action_histogram(actions, title): <NEW_LINE> <INDENT> acts_id = utils.unhot(actions) <NEW_LINE> fig, ax = plt.subplots() <NEW_LINE> bins = np.arange(-.5, utils.n_actions + .5) <NEW_LINE> ax.hist(acts_id, range=(0,6), bins=bins, rwidth=.9) <NEW_LINE> ax.set(title=title, xlim=(-.5, utils.n_actions -.5)) <NEW_LIN... | Plot the histogram of actions from the expert dataset | 625941c83617ad0b5ed67f6b |
def get_all_idtaxa_seqtaxa( xml ): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> taxa = xml.xpath('taxa')[0] <NEW_LINE> <DEDENT> except IndexError as e: <NEW_LINE> <INDENT> raise InvalidBeastXmlError('Missing taxa tag') <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> alignment = xml.xpath('alignment')[0] <NEW_LINE> <DEDENT... | Get a zipped list of all <taxa><taxon>... and <alignment><taxa>... | 625941c815fb5d323cde0b82 |
def build_path(self, basename): <NEW_LINE> <INDENT> return (posixpath.join(self._directory_prefix, basename + self._suffix), self._context) | Construct the search path to use for a file with name basename.
Returns a tuple (pathname, context), where pathname is the path to try
and context is any additional data associated with this search entry
(if any). | 625941c826238365f5f0eee0 |
def remove_mount_point(self, path): <NEW_LINE> <INDENT> fs('rmmount', '-dir', path) | Unmount an AFS volume. | 625941c871ff763f4b5496fd |
def stop(self): <NEW_LINE> <INDENT> self._context.remove_service_listener(self) <NEW_LINE> if self.services: <NEW_LINE> <INDENT> return [(service, reference) for reference, service in self.services.items()] | Stops the dependency manager (must be called before clear())
:return: The removed bindings (list) or None | 625941c81f037a2d8b946271 |
def _run_differential_expression_analysis( annotation_layer: Optional[str] = None, comparisons: List[Tuple[str, str]] = None, normalize_covariates: List[str] = None, num_samples: int = 50, genes_per_batch: int = 100000, ) -> None: <NEW_LINE> <INDENT> dataloader = require("dataloader") <NEW_LINE> if annotation_layer is ... | Runs differential expression analysis | 625941c8de87d2750b85fe05 |
def sort(l): <NEW_LINE> <INDENT> i = 0 <NEW_LINE> while i != len(l): <NEW_LINE> <INDENT> insert(l, i) <NEW_LINE> i += 1 <NEW_LINE> <DEDENT> return l | Record the values in l from smallest to largest. | 625941c8e1aae11d1e749d2a |
def countSubstrings(self, s): <NEW_LINE> <INDENT> self.string = s <NEW_LINE> self.count = 0 <NEW_LINE> for i in range(len(s)): <NEW_LINE> <INDENT> self.count_palindrom(i,i) <NEW_LINE> self.count_palindrom(i,i+1) <NEW_LINE> <DEDENT> return self.count | :type s: str
:rtype: int | 625941c8090684286d50ed58 |
def error_band ( value , *errors , **kwargs ) : <NEW_LINE> <INDENT> v , epos , eneg = value_errors ( value , *errors ) <NEW_LINE> return error_band2 ( v , epos , eneg , **kwargs ) | Helper function to prepare drawing the error band(s)
>>> objects = error_band ( 1 , 0.2 , (-0.1,0.4) , (0.1,-0.3) , min_value = 0 , max_value = 10 , transpose = False )
>>> for o in objects : o.draw() | 625941c8099cdd3c635f0ccf |
def write(self, *args): <NEW_LINE> <INDENT> valstring = " ".join(args) <NEW_LINE> y, x = self.stdscr.getyx() <NEW_LINE> valstring = " ".join(args) <NEW_LINE> self.stdscr.addstr(self.outputPosition.y, self.outputPosition.x, valstring) <NEW_LINE> self.stdscr.scroll(1) <NEW_LINE> self.stdscr.move(y, x) | Print values in args to console | 625941c87b180e01f3dc4872 |
def get_version(): <NEW_LINE> <INDENT> version = '.'.join([str(i) for i in VERSION[:-1]]) <NEW_LINE> if VERSION[-1]: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> revision = REVISION.split()[1] <NEW_LINE> <DEDENT> except IndexError: <NEW_LINE> <INDENT> revision = 'unknown' <NEW_LINE> <DEDENT> version = '%s-%s-rev%s' % (... | Returns the human-readable version string. | 625941c86fb2d068a760f110 |
def create(standard_out_path, nested_out_path, binary_out_path): <NEW_LINE> <INDENT> __create_standard(standard_out_path) <NEW_LINE> __create_nested(nested_out_path) <NEW_LINE> __create_binary(binary_out_path) | Create example Avro data stores | 625941c866673b3332b92104 |
def get_full_name(self): <NEW_LINE> <INDENT> full_name = self.full_name <NEW_LINE> return full_name.strip() | Returns the first_name plus the last_name, with a space in between. | 625941c8596a897236089b35 |
def register_application(self, app): <NEW_LINE> <INDENT> if app.slug in self.applications: <NEW_LINE> <INDENT> self.log.error("Tried to register application '{0}' more than once.".format(app.slug)) <NEW_LINE> raise SuiteException("Tried to register multiple applications with the same name.") <NEW_LINE> <DEDENT> self.ap... | This is called automatically whenever an Application object is constructed. | 625941c8a8370b7717052914 |
def policy_iteration(env, gamma, max_iteration, tol): <NEW_LINE> <INDENT> V = np.zeros(env.nS) <NEW_LINE> policy = np.zeros(env.nS, dtype=int) <NEW_LINE> for x in range(max_iteration): <NEW_LINE> <INDENT> V = policy_evaluation(env, policy, gamma, max_iteration, tol) <NEW_LINE> new_p, is_stable = policy_improvement(env,... | Implement Policy iteration algorithm.
You should use the policy_evaluation and policy_improvement methods to
implement this method.
Parameters
----------
env: OpenAI env.
env.P: dictionary
the transition probabilities of the environment
P[state][action] is tuples with (probabil... | 625941c8851cf427c661a583 |
def POST(self, api, **kwargs): <NEW_LINE> <INDENT> return self.__call('POST', api, **kwargs) | Call an API with POST.
| 625941c8627d3e7fe0d68ec3 |
def classify(tree, data): <NEW_LINE> <INDENT> data = data[:] <NEW_LINE> classification = [] <NEW_LINE> for record in data: <NEW_LINE> <INDENT> classification.append(get_classification(record, tree)) <NEW_LINE> <DEDENT> return classification | Returns a list of classifications for each of the records in the data
list as determined by the given decision tree. | 625941c8ad47b63b2c509ff3 |
def get_config(): <NEW_LINE> <INDENT> cfg = VersioneerConfig() <NEW_LINE> cfg.VCS = "git" <NEW_LINE> cfg.style = "pep440" <NEW_LINE> cfg.tag_prefix = "" <NEW_LINE> cfg.parentdir_prefix = "crowddynamics-" <NEW_LINE> cfg.versionfile_source = "crowddynamics/_version.py" <NEW_LINE> cfg.verbose = False <NEW_LINE> return cfg | Create, populate and return the VersioneerConfig() object. | 625941c8925a0f43d2549eea |
def append_left(self, contents): <NEW_LINE> <INDENT> self.dll.push(contents) <NEW_LINE> self.head_node = self.dll.head_node <NEW_LINE> self.tail_node = self.dll.tail_node | Add a node to the left side of this dll. | 625941c823849d37ff7b3103 |
def dJf_exact(x): <NEW_LINE> <INDENT> return arrayFunc(_dJf_exact, x) | dJf/dx calculated directly from the integral. | 625941c8293b9510aa2c330b |
def __get_export_path(self, export_str: str) -> list: <NEW_LINE> <INDENT> export_path = export_str.split(".") <NEW_LINE> for key in range(len(export_path)): <NEW_LINE> <INDENT> if re.match("[0-9]", export_path[key]): <NEW_LINE> <INDENT> export_path[key] = int(export_path[key]) <NEW_LINE> <DEDENT> <DEDENT> return export... | convert dict path string doted style into splited list
convert into int if necessary | 625941c8e5267d203edcdd12 |
@app.route('/request', methods=['GET']) <NEW_LINE> @authenticated <NEW_LINE> def list_requests(): <NEW_LINE> <INDENT> vc3_client = get_vc3_client() <NEW_LINE> vc3_requests = vc3_client.listRequests() <NEW_LINE> nodesets = vc3_client.listNodesets() <NEW_LINE> clusters = vc3_client.listClusters() <NEW_LINE> request_list ... | List View of Virtual Clusters | 625941c8167d2b6e31218c0a |
def test_threejs_render_torus(self): <NEW_LINE> <INDENT> my_threejs_renderer = threejs_renderer.ThreejsRenderer() <NEW_LINE> dict_shape, dict_edge = my_threejs_renderer.DisplayShape(torus_shp) <NEW_LINE> self.assertTrue(dict_shape) <NEW_LINE> self.assertTrue(not dict_edge) | Render a simple torus in threejs | 625941c80fa83653e465702f |
def org_create_team(self, org, **kwargs): <NEW_LINE> <INDENT> kwargs['_return_http_data_only'] = True <NEW_LINE> if kwargs.get('async_req'): <NEW_LINE> <INDENT> return self.org_create_team_with_http_info(org, **kwargs) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> (data) = self.org_create_team_with_http_info(org, **kwa... | Create a team # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.org_create_team(org, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str org: name of the organization (required)
:param CreateT... | 625941c8a8ecb033257d3141 |
def extract(self, xmltext): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> xml_tree = ET.fromstring(xmltext) <NEW_LINE> encrypt = xml_tree.find("Encrypt") <NEW_LINE> return ierror.WXBizMsgCrypt_OK, encrypt.text <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> print(e) <NEW_LINE> return ierror.WXBizMsgCrypt_... | 提取出xml数据包中的加密消息
@param xmltext: 待提取的xml字符串
@return: 提取出的加密消息字符串 | 625941c8a934411ee3751707 |
def integration_elements(self, codim): <NEW_LINE> <INDENT> return self._integration_elements(codim) | `retval[e]` is given as `sqrt(det(A^T*A))`, where `A = embeddings(codim)[0][e]`. | 625941c89b70327d1c4e0e48 |
def _get_groups(self, req, is_detail): <NEW_LINE> <INDENT> context = req.environ['cinder.context'] <NEW_LINE> filters = req.params.copy() <NEW_LINE> marker, limit, offset = common.get_pagination_params(filters) <NEW_LINE> sort_keys, sort_dirs = common.get_sort_params(filters) <NEW_LINE> filters.pop('list_volume', None)... | Returns a list of groups through view builder. | 625941c80a366e3fb873e88d |
def getSum(self, a: int, b: int) -> int: <NEW_LINE> <INDENT> if b == 0: <NEW_LINE> <INDENT> return a if a <= 0x7FFFFFFF else a | (~0x100000000+1) <NEW_LINE> <DEDENT> a, b = (a ^ b) % 0x100000000 , ((a & b) << 1) % 0x100000000 <NEW_LINE> return self.getSum(a, b) | 因为Python的整数不是固定的32位,所以需要做一些特殊的处理,具体见代码吧。
代码里的将一个数对0x100000000取模(注意:Python的取模运算结果恒为非负数),
是希望该数的二进制表示从第32位开始到更高的位都同是0(最低位是第0位),以在0-31位上模拟一个32位的int。 | 625941c8f548e778e58cd5f1 |
def upgrade(nb, from_version=1): <NEW_LINE> <INDENT> if orig_version == 1: <NEW_LINE> <INDENT> newnb = new_notebook() <NEW_LINE> ws = new_worksheet() <NEW_LINE> for cell in nb.cells: <NEW_LINE> <INDENT> if cell.cell_type == u'code': <NEW_LINE> <INDENT> newcell = new_code_cell(input=cell.get('code'),prompt_number=cell.g... | Convert a notebook to the v2 format.
Parameters
----------
nb : NotebookNode
The Python representation of the notebook to convert.
orig_version : int
The original version of the notebook to convert. | 625941c830bbd722463cbe39 |
def enforce_domain_sanity(domain): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if isinstance(domain, bytes): <NEW_LINE> <INDENT> domain = domain.decode('utf-8') <NEW_LINE> <DEDENT> domain.encode('ascii') <NEW_LINE> <DEDENT> except UnicodeError: <NEW_LINE> <INDENT> raise errors.ConfigurationError("Non-ASCII domain name... | Method which validates domain value and errors out if
the requirements are not met.
:param domain: Domain to check
:type domain: `str` or `unicode`
:raises ConfigurationError: for invalid domains and cases where Let's
Encrypt currently will not issue certificates
:returns: The domain cast ... | 625941c838b623060ff0ae62 |
def get_data(self, path_list, reverse=False): <NEW_LINE> <INDENT> data = [] <NEW_LINE> for path in path_list: <NEW_LINE> <INDENT> output = os.path.join(path, self.fnames['output']) <NEW_LINE> pot = glob.glob(os.path.join(path, self.fnames['pot']))[0] <NEW_LINE> outdat = Output(output) <NEW_LINE> potdat = Pot(pot) <NEW_... | reverseをTrueにするとc/aをa/cにして読み込む
(soc100の計算で使用) | 625941c8cdde0d52a9e530a7 |
def __init__( self, *, id: Optional[float] = None, display_name: Optional[str] = None, order: Optional[float] = None, description: Optional[str] = None, type: Optional[Union[str, "SolutionType"]] = None, data: Optional[List[List["NameValuePair"]]] = None, metadata: Optional[List[List["NameValuePair"]]] = None, **kwargs... | :keyword id: Solution Id.
:paramtype id: float
:keyword display_name: Display Name of the solution.
:paramtype display_name: str
:keyword order: Order of the solution.
:paramtype order: float
:keyword description: Description of the solution.
:paramtype description: str
:keyword type: Type of Solution. Possible values ... | 625941c82eb69b55b151c922 |
def chroma(self, amount=0.15, color=None, blend=None): <NEW_LINE> <INDENT> if color is None: <NEW_LINE> <INDENT> color = get_bg_color(self.resource) <NEW_LINE> <DEDENT> if blend: <NEW_LINE> <INDENT> self.fx('avfilter.chromakey', { 'av.color': color, 'av.similarity': amount, 'av.blend': blend }) <NEW_LINE> <DEDENT> else... | Removes a color from the clip, making it transparent
Args:
amount (float): distance to the color, between 0.0 and 1.0. The higher the number the more will be removed.
color (str): The color to remove. If left blank, the top left pixel color will be used.
blend (float): Chromakey blend value, between 0 and ... | 625941c892d797404e3041fe |
def DrawSplitter(self, dc): <NEW_LINE> <INDENT> backColour = self.GetBackgroundColour() <NEW_LINE> dc.SetBrush(wx.Brush(backColour, wx.SOLID)) <NEW_LINE> dc.SetPen(wx.Pen(backColour)) <NEW_LINE> dc.Clear() <NEW_LINE> if wx.VERSION >= _RENDER_VER: <NEW_LINE> <INDENT> if self.HasFlag(wx.SP_3DBORDER): <NEW_LINE> <INDENT> ... | Actually draws the sashes. | 625941c8283ffb24f3c55976 |
def login(self, client): <NEW_LINE> <INDENT> return client.post('/login', data=dict(email="jessica.a.lopez@yale.edu",password="andiamo"), follow_redirects=True) | submit login info | 625941c8fb3f5b602dac3706 |
def invert_lifetime_high(t): <NEW_LINE> <INDENT> return (((t / 1000.) - 0.003) / 1.2)**(-1./1.85) | Compute stellar masses given lifetimes (valid for <40 Myr).
Args:
t (array): lifetime in Myr.
Returns:
array: stellar masses. | 625941c83317a56b86939cce |
def plot_timeline(s, unit, start=None, end=None, ax=None): <NEW_LINE> <INDENT> if not start: <NEW_LINE> <INDENT> start = UNITS[unit](s.min()) <NEW_LINE> <DEDENT> if not end: <NEW_LINE> <INDENT> end = UNITS[unit](s.max()) <NEW_LINE> <DEDENT> load = Counter(s.apply(UNITS[unit])) <NEW_LINE> axis = pd.date_range(start, end... | Ploting the time binned histogram
:s: a series with datetime as labels
:unit: a unit applied for aggregation
:start: the start of range to plot
:end: the end of range to plot
:returns: a plot of event frequence distribution | 625941c8be8e80087fb20cb8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.