code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def process_matrix_output(poly_seq, x): <NEW_LINE> <INDENT> L = poly_seq[:] <NEW_LINE> d = degree(L[1], x) <NEW_LINE> i = 2 <NEW_LINE> while i < len(L): <NEW_LINE> <INDENT> d_i = degree(L[i], x) <NEW_LINE> if d_i < 0: <NEW_LINE> <INDENT> L.remove(L[i]) <NEW_LINE> i = i - 1 <NEW_LINE> <DEDENT> if d == d_i: <NEW_LINE> <I... | poly_seq is a polynomial remainder sequence computed either by
(modified_)subresultants_bezout or by (modified_)subresultants_sylv.
This function removes from poly_seq all zero polynomials as well
as all those whose degree is equal to the degree of a preceding
polynomial in poly_seq, as we scan it from left to right. | 625941f094891a1f4081c038 |
def clean_username(self): <NEW_LINE> <INDENT> username = self.cleaned_data['username'] <NEW_LINE> if User.objects.filter(username=username): <NEW_LINE> <INDENT> raise forms.ValidationError('username de usuario ya registrado.') <NEW_LINE> <DEDENT> return username | Comprueba que no exista un username igual en la db | 625941f06fb2d068a760f632 |
def message_unsubscribe(self, partner_ids=None, channel_ids=None): <NEW_LINE> <INDENT> self.mapped('tasks').message_unsubscribe(partner_ids=partner_ids, channel_ids=channel_ids) <NEW_LINE> return super(Project, self).message_unsubscribe(partner_ids=partner_ids, channel_ids=channel_ids) | Unsubscribe from all tasks when unsubscribing from a project | 625941f00c0af96317bb8773 |
def parse_disambiguation(self, markup): <NEW_LINE> <INDENT> m = re.search(self.re["disambiguation"], markup) <NEW_LINE> if m: <NEW_LINE> <INDENT> return self.parse_links(m.group(1)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return [] | Gets the Wikipedia disambiguation page for this article.
A Wikipedia disambiguation link refers to other pages
with the same title but of smaller significance,
e.g. {{dablink|For the IEEE magazine see [[Computer (magazine)]].}} | 625941f04f6381625f114fc7 |
def hasExecutable(self, executable): <NEW_LINE> <INDENT> return executable in self.executables | Check if executable is in this ADAG | 625941f0ec188e330fd5ad1f |
def release(self): <NEW_LINE> <INDENT> self.unlock() | Alias for unlock()
| 625941f07d43ff24873a3230 |
def make_openai_gym_environment(config_filename): <NEW_LINE> <INDENT> with open(config_filename) as cfg: <NEW_LINE> <INDENT> env_config = json.load(cfg) <NEW_LINE> <DEDENT> env_raw = Environment(config=env_config, verbose=1) <NEW_LINE> env = OpenAIGymEnvAdapter(env_raw, ALL_SNAKE_ACTIONS, np.zeros((10, 10))) <NEW_LINE>... | Create an OpenAI Gym environment for the Snake game.
Args:
config_filename: JSON config for the Snake game level.
Returns:
An instance of OpenAI Gym environment. | 625941f0046cf37aa974d2cd |
def invert_network(person_to_networks: Dict[str, List[str]]) -> Dict[str, List[str]]: <NEW_LINE> <INDENT> networks = {} <NEW_LINE> for key in person_to_networks: <NEW_LINE> <INDENT> for network in person_to_networks[key]: <NEW_LINE> <INDENT> if network in networks: <NEW_LINE> <INDENT> networks[network].append(key) <NEW... | Return a dictionary which sorts all people from person_to_networks
by network name.
>>> invert_network({'Meredith Shepherd-Grey': ['Parent Teacher Association'], 'Amelia Hunt': ['Yachting Association', 'Knitting Club'], 'Alex Michael Karev': ['Knitting Club', 'Ethics Board'], 'Owen Hunt': ['Yachting Association', 'Par... | 625941f060cbc95b062c6acf |
def create_pdf(html): <NEW_LINE> <INDENT> buffer = StringIO() <NEW_LINE> pdf = pisa.pisaDocument(StringIO(html), buffer) <NEW_LINE> pdf_file = buffer.getvalue() <NEW_LINE> buffer.close() <NEW_LINE> return pdf_file | Create PDF from html | 625941f031939e2706e4d3ee |
def load(name): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> function = _metrics_sets[name] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> raise ValueError( 'no metrics set registered as %r, options are: %r' % ( name, sorted(_metrics_sets), ), ) <NEW_LINE> <DEDENT> return function() | Return an instance of the metrics set registered with the given name.
Returns
-------
metrics : set[Metric]
A new instance of the metrics set.
Raises
------
ValueError
Raised when no metrics set is registered to ``name`` | 625941f0462c4b4f79d1dc5b |
def empty(self): <NEW_LINE> <INDENT> return len(self.stack[self.use]) == 0 | Returns whether the queue is empty.
:rtype: bool | 625941f063d6d428bbe44a7d |
def _remove_multicast_group(self, datapath, outport, dst): <NEW_LINE> <INDENT> ofproto = datapath.ofproto <NEW_LINE> parser = datapath.ofproto_parser <NEW_LINE> dpid = datapath.id <NEW_LINE> self._send_event( EventMulticastGroupStateChanged( MG_GROUP_REMOVED, dst, outport, [])) <NEW_LINE> self._del_flow_entry(datapath,... | remove flow entries about the group and send a LEAVE message
if exists. | 625941f01b99ca400220b040 |
def job_script(self): <NEW_LINE> <INDENT> if self._cluster is None: <NEW_LINE> <INDENT> raise ValueError( "The cluster is not initialized. This is usually" "caused by calling `job_script` before `start`." ) <NEW_LINE> <DEDENT> return self._cluster.job_script() | Returns the job script that dask will use to submit workers.
The backend must be started before calling this function.
Returns
-------
str | 625941f07d43ff24873a3231 |
def encode_to_words(s): <NEW_LINE> <INDENT> words = s.split(' ') <NEW_LINE> for i, word in enumerate(words): <NEW_LINE> <INDENT> yield ' '.join(CHAR_TO_MORSE.get(ch, ch) for ch in word) | Takes a plaintext string and generates Morse code words
Morse letters are joined by a single space | 625941f0ff9c53063f47c77c |
def loadModule(moduleFilename): <NEW_LINE> <INDENT> if not os.path.isfile(moduleFilename): <NEW_LINE> <INDENT> logging.error("Could not find %s" % moduleFilename) <NEW_LINE> sys.exit(1) <NEW_LINE> <DEDENT> if moduleFilename.endswith(".py") or moduleFilename.endswith(".pyc"): <NEW_LINE> <INDENT> modulePath, moduleName =... | load py file dynamically | 625941f05510c4643540f961 |
def zoomImage(self, var): <NEW_LINE> <INDENT> self.bind("<Button-1>", lambda e: self._cb_clicked(e, var)) <NEW_LINE> self.bind("<B1-Motion>", lambda e: self._cb_currentPos(e, var)) <NEW_LINE> self.bind("<ButtonRelease-1>", lambda e: self._cb_release(e, var)) | Initiates zoom by binding zoom methods to canvas
:param var: Checkbutton variable.
:return: | 625941f05510c4643540f962 |
def stopPropagation(self): <NEW_LINE> <INDENT> self.__propagationStopped = True; | Stops the propagation of the event to further event listeners.
If multiple event listeners are connected to the same event, no
further event listener will be triggered once any trigger calls
stopPropagation(). | 625941f097e22403b379d528 |
def test_invalid_image(self): <NEW_LINE> <INDENT> img_path = os.path.join(os.path.dirname(upath(__file__)), "brokenimg.png") <NEW_LINE> with open(img_path, 'rb') as fh: <NEW_LINE> <INDENT> size = images.get_image_dimensions(fh) <NEW_LINE> self.assertEqual(size, (None, None)) | get_image_dimensions() should return (None, None) for the dimensions of
invalid images (#24441).
brokenimg.png is not a valid image and it has been generated by:
$ echo "123" > brokenimg.png | 625941f09f2886367277ae15 |
def loadImageSeries(filelist=None): <NEW_LINE> <INDENT> if filelist is None or len(filelist) < 1: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> imglist = [] <NEW_LINE> for img in filelist: <NEW_LINE> <INDENT> if not os.path.exists(img): <NEW_LINE> <INDENT> print("unable to find %s" % img) <NEW_LINE> continue <NEW_LINE... | create a list of :py:class:`~PIL.Image.Image` objects for use in a montage | 625941f0a17c0f6771cbe5db |
def test_celsius_to_kelvin(self): <NEW_LINE> <INDENT> expected = 663.15 <NEW_LINE> returned = conversion.celsius_to_kelvin(390) <NEW_LINE> self.assertEqual(returned, expected) <NEW_LINE> expected = 653.15 <NEW_LINE> returned = conversion.celsius_to_kelvin(380) <NEW_LINE> self.assertEqual(returned, expected) <NEW_LINE> ... | Tests the Celsius to Kelvin Conversion | 625941f0a05bb46b383ecda8 |
def get_formfield_overrides(self): <NEW_LINE> <INDENT> return helpers.FORMFIELD_FOR_DBFIELD_DEFAULTS | Hook for specifying the default arguments when
creating a form field for a db field.
By default adds DateWidget for date fields,
TimeChoiceWidget for time fields, SplitDateTime
for datetime fields, and APIChoiceWidget for
foreign keys. | 625941f05fdd1c0f98dc07c1 |
def _newtabmagic_object_page_name(obj): <NEW_LINE> <INDENT> newtab = _get_newtabmagic() <NEW_LINE> newtab.shell.push({'obj': obj}) <NEW_LINE> with patch('subprocess.Popen') as mock_call: <NEW_LINE> <INDENT> newtab.newtab('obj') <NEW_LINE> <DEDENT> call_args = mock_call.call_args[0][0] <NEW_LINE> url = call_args[1] <NEW... | Return path part of help url not including extension. | 625941f09b70327d1c4e1364 |
def has_ionizing_steps(self, name): <NEW_LINE> <INDENT> map_path = fs.join(self.ionizing_steps_path, name) <NEW_LINE> return fs.is_directory(map_path) and not fs.is_empty(map_path) | Thisn function ...
:param name:
:return: | 625941f05fcc89381b1e1c50 |
def __init__(self, conf, exchange_name, routing_key, type, durable, auto_delete): <NEW_LINE> <INDENT> self.queue_arguments = _get_queue_arguments(conf) <NEW_LINE> self.exchange_name = exchange_name <NEW_LINE> self.routing_key = routing_key <NEW_LINE> self.auto_delete = auto_delete <NEW_LINE> self.durable = durable <NEW... | Init the Publisher class with the exchange_name, routing_key,
type, durable auto_delete | 625941f060cbc95b062c6ad0 |
def replace(self, template, msg, style=None, cedict={}, cedir=None): <NEW_LINE> <INDENT> msg.alias = Plus.msnplus_strip(msg.alias) <NEW_LINE> msg.display_name = Plus.msnplus_strip(msg.display_name) <NEW_LINE> msgtext = MarkupParser.replace_emotes(escape(msg.message), cedict, cedir, msg.sender) <NEW_LINE> msgtext = Mark... | replace the variables on template for the values on msg
| 625941f0a8370b7717052e29 |
def minimum(self, x=None): <NEW_LINE> <INDENT> if x is None: <NEW_LINE> <INDENT> x = self.root <NEW_LINE> <DEDENT> while x.left is not self.nil: <NEW_LINE> <INDENT> x = x.left <NEW_LINE> <DEDENT> return x if x is not self.nil else None | Finds the node with the minimal key
Returns nil if tree is empty
Time complexity: O(lg n) (balanced) | 625941f0f548e778e58cdb0c |
def test_register_worker(self): <NEW_LINE> <INDENT> w = GeventWorker(Queue(), pool_size=10) <NEW_LINE> w.register_birth() <NEW_LINE> self.assertEqual(self.testconn.hget(w.key, 'pool_size'), '10') | ensure pool size is registered. | 625941f0be8e80087fb211c6 |
def findit(self,col,row): <NEW_LINE> <INDENT> return _BASE_NOTE_INPUT+col-8*row | All index start at zero | 625941f04527f215b584c9de |
def str5_cmyk(cmyk): <NEW_LINE> <INDENT> pre_string = '(' + str5(cmyk.cyan) + ', ' + str5(cmyk.magenta) + ', ' <NEW_LINE> post_string = str5(cmyk.yellow) + ', ' + str5(cmyk.black) + ')' <NEW_LINE> return pre_string + post_string | Returns: String representation of cmyk in the form "(C, M, Y, K)".
In the output, each of C, M, Y, and K should be exactly 5 characters long.
Hence the output of this function is not the same as str(cmyk)
Example: if str(cmyk) is
'(0.0,31.3725490196,31.3725490196,0.0)'
then str5_cmyk(cmyk) is '(0.000, 31.37,... | 625941f08c0ade5d55d3ef4c |
@stringfunction <NEW_LINE> def GenConfiguration(DSLModel, Table, View): <NEW_LINE> <INDENT> pass | <!-- Search Configuration -->
<z3c:pagelet
name="search.html"
for=".interfaces.${View.interface_name}Container"
class=".${View.TableName}_search.Search"
permission="zope.ManageContent"
${View.z3c_layer} />
<browser:menuItem
title="Search"
for=".interface... | 625941f00a50d4780f667423 |
def testStartMap_Eta(self): <NEW_LINE> <INDENT> TestEntity().put() <NEW_LINE> eta = datetime.datetime.utcnow() + datetime.timedelta(hours=1) <NEW_LINE> shard_count = 4 <NEW_LINE> mapreduce_id = control.start_map( "test_map", __name__ + ".test_handler", "mapreduce.input_readers.DatastoreInputReader", { "entity_kind": __... | Test that MR can be scheduled into the future.
Most of start_map functionality is already tested by handlers_test.
Just a smoke test is enough. | 625941f03d592f4c4ed1d5ea |
def aiff_header_footer(self): <NEW_LINE> <INDENT> from audiotools import decoders <NEW_LINE> from audiotools import bitstream <NEW_LINE> from io import BytesIO <NEW_LINE> decoder = decoders.SHNDecoder(open(self.filename, "rb")) <NEW_LINE> (head, tail) = decoder.pcm_split() <NEW_LINE> decoder.close() <NEW_LINE> if (head... | returns (header, footer) tuple of strings
containing all data before and after the PCM stream
if self.has_foreign_aiff_chunks() is False,
may raise ValueError if the file has no header and footer
for any reason | 625941f0a219f33f34628eee |
def _check_destination(self, destination, overwrite): <NEW_LINE> <INDENT> pass | Override method, the destination is empty | 625941f0d268445f265b53fb |
def decode(self, src, beam_size=3): <NEW_LINE> <INDENT> batch_size = src.batch_size <NEW_LINE> if batch_size > 1: <NEW_LINE> <INDENT> sents, aligns = [], [] <NEW_LINE> for b in range(batch_size): <NEW_LINE> <INDENT> sent, align = self.decode(src[b], beam_size) <NEW_LINE> sents.append(sent[0]) <NEW_LINE> aligns.append(a... | Find the best translation using beam search | 625941f06aa9bd52df037334 |
def test_dictify_with_null(self): <NEW_LINE> <INDENT> Base = declarative_base() <NEW_LINE> class Sensor(Base): <NEW_LINE> <INDENT> __tablename__ = 'sensor' <NEW_LINE> sensor_id = Column(Integer, primary_key=True) <NEW_LINE> institution_id = Column(Integer, nullable=True) <NEW_LINE> sensor_label = Column(String, nullabl... | Test SQLAlchemySchemaNode.dictify(obj) with null values
and show that result is a valid appstruct for the given schema | 625941f007f4c71912b11a11 |
def run(self): <NEW_LINE> <INDENT> self.prelude() <NEW_LINE> id_cart = self.read_id_cart() <NEW_LINE> token = self.read_cart_token(id_cart) <NEW_LINE> self.get_employee_cookie_name() <NEW_LINE> self.get_write_blocks() <NEW_LINE> self.get_nb_employees() <NEW_LINE> for target_customer in range(1, MAX_ID_CUSTOMER): <NEW_L... | Runs the exploit.
| 625941f04e4d5625662d495c |
def symbol_to_number(symbol): <NEW_LINE> <INDENT> symbol = symbol[:1].upper() + symbol[1:].lower() <NEW_LINE> try: <NEW_LINE> <INDENT> return atomic_symbols.index(symbol) + 1 <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> raise InvalidValueError("atomic symbol", symbol, "a valid 1 or 2 letter atomic symbol"... | Converts an atomic symbol to an atomic number.
Args:
symbol - The 1 or 2 letter atomic symbol to convert to an atomic number. For example: "He", "F". Case non-sensitive.
Returns:
The atomic number for the atom specified by the given symbol. | 625941f0956e5f7376d713f8 |
def __init__(self, apidata, site): <NEW_LINE> <INDENT> self.data = LogDict(apidata) <NEW_LINE> self.site = site <NEW_LINE> if self._expectedType is not None and self._expectedType != self.type(): <NEW_LINE> <INDENT> raise Error("Wrong log type! Expecting %s, received %s instead." % (self._expectedType, self.type())) | Initialize object from a logevent dict returned by MW API. | 625941f0baa26c4b54cb16a6 |
def _vars_to_file(vars): <NEW_LINE> <INDENT> clean_vars = [re.sub('[^a-zA-Z0-9_:\-]', '.', str(v)) for v in vars] <NEW_LINE> clean_string = '-'.join(clean_vars) <NEW_LINE> if clean_string.startswith('.'): <NEW_LINE> <INDENT> clean_string = 'c' + clean_string <NEW_LINE> <DEDENT> if len(clean_string) > MAX_FILE_CHARS: <N... | Return a safe string to be used as a file or directory name | 625941f0dd821e528d63b731 |
def execute_transaction(self, array_sql_action): <NEW_LINE> <INDENT> handled_item = 0 <NEW_LINE> try: <NEW_LINE> <INDENT> con = self._connect() <NEW_LINE> sql = "" <NEW_LINE> try: <NEW_LINE> <INDENT> cur = con.cursor() <NEW_LINE> con.autocommit(False) <NEW_LINE> if type(array_sql_action) is list: <NEW_LINE> <INDENT> fo... | :param array_sql_action:
格式是 单个 sql, 或者 list_sql(列表形式的)
list sql 全部执行成功, return len(list_sql)
:return: | 625941f0b7558d58953c5494 |
def file_import(path: str) -> RegressiData: <NEW_LINE> <INDENT> data = RegressiData(path) <NEW_LINE> return data | Import a regressi file with all of it's data.
:param path: path to the file to import
:return: a regressi_data object, containing the same information as the file | 625941f0851cf427c661aa96 |
def all_flags_chash(self): <NEW_LINE> <INDENT> all_flags_chash = dict((( doc.content[self.UID_KEY], doc.content[self.CONTENT_HASH_KEY]) for doc in self._soledad.get_from_index( fields.TYPE_MBOX_IDX, fields.TYPE_FLAGS_VAL, self.mbox))) <NEW_LINE> return all_flags_chash | Return a dict with the content-hash for all flag documents
for this mailbox. | 625941f0f7d966606f6aa597 |
def search(self, word: str) -> bool: <NEW_LINE> <INDENT> length=len(word) <NEW_LINE> dic=self.map[length] <NEW_LINE> if not dic: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if '.' not in word: <NEW_LINE> <INDENT> return word in dic <NEW_LINE> <DEDENT> for i in range(length): <NEW_LINE> <INDENT> if word[i]=='.'... | Returns if the word is in the data structure. A word could contain the dot character '.' to represent any one letter. | 625941f03346ee7daa2b32fd |
def test_set_recipients_normal(): <NEW_LINE> <INDENT> item = Mock() <NEW_LINE> to_recipients = [ {"emailAddress": {"name": "user1", "address": "user1@kopano.com"}}, {"emailAddress": {"address": "user2@kopano.com"}}, ] <NEW_LINE> message.set_recipients(item, to_recipients) <NEW_LINE> assert item.to == "user1 <user1@kopa... | Test set_to_recipients with a correct data. | 625941f066656f66f7cbc739 |
def register_treebuilders_from(module): <NEW_LINE> <INDENT> this_module = sys.modules['third_party.bs4.builder'] <NEW_LINE> for name in module.__all__: <NEW_LINE> <INDENT> obj = getattr(module, name) <NEW_LINE> if issubclass(obj, TreeBuilder): <NEW_LINE> <INDENT> setattr(this_module, name, obj) <NEW_LINE> this_module._... | Copy TreeBuilders from the given module into this module. | 625941f0b5575c28eb68e592 |
def node(self, path=''): <NEW_LINE> <INDENT> pass | Return the node at the specified path.
If the path is the empty string (the default) then return *this* node.
Any missing nodes are created automatically.
e.g::
node = preferences.node('acme.ui')
bgcolor = node.get('bgcolor')
| 625941f0cdde0d52a9e535c4 |
def minPathSum(self, grid): <NEW_LINE> <INDENT> m = len(grid) <NEW_LINE> n = len(grid[0]) <NEW_LINE> for i in range(1, n): <NEW_LINE> <INDENT> grid[0][i] += grid[0][i-1] <NEW_LINE> <DEDENT> for i in range(1, m): <NEW_LINE> <INDENT> grid[i][0] += grid[i-1][0] <NEW_LINE> <DEDENT> for i in range(1, m): <NEW_LINE> <INDENT>... | :type grid: List[List[int]]
:rtype: int | 625941f01f037a2d8b946789 |
def test_defaultmissing_primarykey(self): <NEW_LINE> <INDENT> Base = declarative_base() <NEW_LINE> class User(Base): <NEW_LINE> <INDENT> __tablename__ = 'user' <NEW_LINE> id = Column(Integer, primary_key=True) <NEW_LINE> <DEDENT> schema = SQLAlchemySchemaNode(User) <NEW_LINE> self.assertEqual(schema['id'].missing, cola... | Ensure proper handling of empty values on primary keys
| 625941f0b545ff76a89143a2 |
def __init__(self): <NEW_LINE> <INDENT> BaseObj.__init__(self) <NEW_LINE> self._groupes = {} <NEW_LINE> self._construire() <NEW_LINE> self.commandes = {} | Constructeur du conteneur. | 625941f0f7d966606f6aa598 |
def wordPattern(self, pattern, str): <NEW_LINE> <INDENT> m = OneToOneMap() <NEW_LINE> lst = str.split(" ") <NEW_LINE> if len(pattern) != len(lst): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> for i in xrange(len(pattern)): <NEW_LINE> <INDENT> a = m.get(pattern[i]) <NEW_LINE> b = m.get(lst[i]) <NEW_LINE> if a is... | May not always work due to OneToOneMap implementation in the case that a word is 1-letter.
:type pattern: str
:type str: str
:rtype: bool | 625941f05fc7496912cc3f0a |
def name_value(elem): <NEW_LINE> <INDENT> name = strip_namespace(elem.tag).strip() <NEW_LINE> value = elem.text and elem.text.strip() or '' <NEW_LINE> return name, value | Return the name, value of an etree element `elem` stripping all namespaces
and prefixes from the tag name. | 625941f007d97122c4178e26 |
def test_operations(self, *args): <NEW_LINE> <INDENT> self.assertIsInstance(self.pBDB.config, ConfigurationDB) <NEW_LINE> self.assertIsInstance(self.pBDB.config, PhysBiblioDBSub) <NEW_LINE> self.assertEqual(self.pBDB.config.count(), 0) <NEW_LINE> self.assertTrue(self.pBDB.config.insert("test", "somevalue")) <NEW_LINE> ... | Test count, insert and update, delete and get methods | 625941f08e7ae83300e4b55b |
def read_data(self, data_file, data_type=None): <NEW_LINE> <INDENT> raise NotImplementedError | Returns
-------
data: ``List[Dict]`` | 625941f00a50d4780f667424 |
def on_exit(self, evt): <NEW_LINE> <INDENT> self.Close() | Closes the window | 625941f0aad79263cf390fd6 |
def has_multiple_ar_indexes(self): <NEW_LINE> <INDENT> return self._has_multiple_values_for_attr('ar_index') | Checks if the settings contains multiple indexes of files in the
input archive.
:returns: ``True`` if the settings contains multiple indexes, ``False``
otherwise. | 625941f057b8e32f52483a2c |
def parse_data(urldata): <NEW_LINE> <INDENT> tp = stock_parser() <NEW_LINE> tp.feed(urldata) <NEW_LINE> data = tp.data <NEW_LINE> i = 0 <NEW_LINE> arr = [] <NEW_LINE> stocks = [] <NEW_LINE> for row in data: <NEW_LINE> <INDENT> arr.append(row.replace(",","").replace("元","").replace("\r\n","")) <NEW_LINE> i += 1 <NEW_LIN... | 日期,每股净资产,每股收益,每股现金含量,每股资本公积金,固定资产合计,流动资产合计,资产总计,
长期负债合计,主营业务收入,财务费用,净利润 | 625941f08c3a87329515894e |
def test_059_challenge_lookup(self): <NEW_LINE> <INDENT> self.assertFalse(self.dbstore.challenge_lookup('name', 'challenge3')) | test DBstore.challenge_lookup() method for a not existing entry | 625941f001c39578d7e753c8 |
def testNonINListValueErrorHandler(self): <NEW_LINE> <INDENT> self.assertRaises(datastore_errors.BadQueryError, gql.GQL, 'SELECT * FROM Foo WHERE x = (0, 1)') | Test related to bug #1688699.
Tests an error handler that prevented list filter values with operators
other than IN. | 625941f0167d2b6e31219121 |
def dropdown_options(self): <NEW_LINE> <INDENT> dropdown_options = [ {"label": country, "value": f"{country},{iso_code}"} for country, iso_code in np.unique( self.raw_df[["country", "iso_code"]].dropna().values.astype("<U22"), axis=0, ) if country not in self.excld_ctry ] <NEW_LINE> dropdown_options.sort(key=lambda x: ... | Gets a list of all the countries included in the dataset (for the dropdown).
Excludes countries that we can't get population data for.
Returns:
dropdown_options: The list of countries that will be used in the dropdown | 625941f02ae34c7f2600d6bd |
def generate(self, numRows): <NEW_LINE> <INDENT> ans=[] <NEW_LINE> for i in range(numRows): <NEW_LINE> <INDENT> lis=[1]*(i+1) <NEW_LINE> ans.append(lis) <NEW_LINE> for j in range(1,i): <NEW_LINE> <INDENT> ans[i][j]=ans[i-1][j-1]+ans[i-1][j] <NEW_LINE> <DEDENT> <DEDENT> return ans | :type numRows: int
:rtype: List[List[int]] | 625941f00fa83653e4657544 |
def __init__(self): <NEW_LINE> <INDENT> self.DiskIds = None | :param DiskIds: 将要解挂的云硬盘ID, 通过[DescribeDisks](/document/product/362/16315)接口查询,单次请求最多可解挂10块弹性云盘。
:type DiskIds: list of str | 625941f0be383301e01b5a07 |
def push(self, x: int) -> None: <NEW_LINE> <INDENT> self.helper_data_2.put(x) <NEW_LINE> while not self.helper_data_1.empty(): <NEW_LINE> <INDENT> self.helper_data_2.put(self.helper_data_1.get()) <NEW_LINE> <DEDENT> self.helper_data_1 = self.helper_data_2 <NEW_LINE> self.helper_data_2 = queue.Queue() | Push element x onto stack. | 625941f03617ad0b5ed68483 |
def capitalize_names(input): <NEW_LINE> <INDENT> string =" " <NEW_LINE> string = string.join(input).title() <NEW_LINE> return string.split() | Given a list of first names, capitalize them properly
e.g ["JAMES", "jack", "HArry"] should return ["James", "Jack", "Harry"]
Hint: use built in functions and one of the str type functions to make this happen | 625941f05166f23b2e1a56e6 |
def four_times(x): <NEW_LINE> <INDENT> return 4 * x | docstring
Return 4 * x.
:param x: int.
:return: 4 times x. | 625941f0711fe17d825428eb |
def load_csv(filename, to_numpy=True, split=False, csv_tag=True): <NEW_LINE> <INDENT> if split: <NEW_LINE> <INDENT> data = {} <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> data = [] <NEW_LINE> <DEDENT> with open(filename) as csvfile: <NEW_LINE> <INDENT> reader = csv.reader(csvfile, delimiter=',') <NEW_LINE> for index, ... | This function takes in a filename and creates a list of CSV_Measurements
:param filename: csv filename
:return: the list | 625941f09c8ee82313fbbd04 |
def restart_browser(self, refresh=True, start_game=True, feedback=False): <NEW_LINE> <INDENT> if refresh: <NEW_LINE> <INDENT> self.click_and_wait(p14_browser_refresh, 20) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.click_and_wait() <NEW_LINE> <DEDENT> self.tap(key.K_F12) <NEW_LINE> self.sleep(4) <NEW_LINE> self.... | restarts the browser and sets the game window to be where expected | 625941f0627d3e7fe0d693df |
def aro_stage_ETL(root_path, grow_stage): <NEW_LINE> <INDENT> grow_stage_data = pandas.read_csv(os.path.join(root_path, 'grow_peroid_data', 'grow_period_points.csv')) <NEW_LINE> station_list = pandas.read_csv(os.path.join(root_path, 'grow_peroid_data', 'agro_stations.csv')) <NEW_LINE> start_year = 2001 <NEW_LINE> end_y... | 按年和生育阶段获取目标区内的点 | 625941f0a4f1c619b28b05b8 |
def __init__(self, cli, logger, api, resource_config): <NEW_LINE> <INDENT> super(JuniperStateRunner, self).__init__(logger, api, resource_config) <NEW_LINE> self.cli = cli <NEW_LINE> self.api = api | :param cli:
:param logger:
:param api:
:param resource_config: | 625941f00a366e3fb873edad |
def test_tytable_colspan(): <NEW_LINE> <INDENT> t = tytable() <NEW_LINE> wide_cell = TyTag(TAG_TD,attrib={'COLSPAN':2},text='Wide Column') <NEW_LINE> t.add_head(['foo','bar','baz','bif'],col_auto_ids=['foo','bar','baz','bif']) <NEW_LINE> t.add_data([1,2,3,4], row_auto_id="row1") <NEW_LINE> t.add_data([2,wide_cell,5], r... | test the colspan feature | 625941f0d58c6744b42581ea |
def load_autoinstall_data(self, data): <NEW_LINE> <INDENT> pass | Load autoinstall data.
This is called if there is an autoinstall happening. This
controller may not have any data, and this controller may still
be interactive. | 625941f0f9cc0f698b140b83 |
def __init__(self, fuel=0, name="Taxi"): <NEW_LINE> <INDENT> super().__init__(name, fuel) <NEW_LINE> self.current_fare_distance = 0 | Initialise a Taxi instance, based on parent class Car. | 625941f03cc13d1c6d3c7904 |
def set_active(self): <NEW_LINE> <INDENT> PageView.set_active(self) <NEW_LINE> self.bookmarks.display() <NEW_LINE> hobj = self.get_history() <NEW_LINE> self.active_signal = hobj.connect('active-changed', self.goto_active) <NEW_LINE> self.mru_signal = hobj.connect('mru-changed', self.update_mru_menu) <NEW_LINE> self.upd... | Called when the page becomes active (displayed). | 625941f071ff763f4b549c23 |
def mjd2ctime(mjd): <NEW_LINE> <INDENT> return (np.asarray(mjd)-40587.0)*86400 | Converts from modified julian date to unix time | 625941f0d7e4931a7ee9e4ad |
def which(program): <NEW_LINE> <INDENT> import os <NEW_LINE> def is_exe(fpath): <NEW_LINE> <INDENT> return os.path.isfile(fpath) and os.access(fpath, os.X_OK) <NEW_LINE> <DEDENT> fpath, fname = os.path.split(program) <NEW_LINE> if fpath: <NEW_LINE> <INDENT> if is_exe(program): <NEW_LINE> <INDENT> return program <NEW_LI... | Function to check for presence of executable/installed program
Used for checking presense of ffmpeg/avconv | 625941f0d4950a0f3b08c8d4 |
def get_inspector(format_name): <NEW_LINE> <INDENT> formats = { 'raw': FileInspector, 'qcow2': QcowInspector, 'vhd': VHDInspector, 'vhdx': VHDXInspector, 'vmdk': VMDKInspector, 'vdi': VDIInspector, } <NEW_LINE> return formats.get(format_name) | Returns a FormatInspector class based on the given name.
:param format_name: The name of the disk_format (raw, qcow2, etc).
:returns: A FormatInspector or None if unsupported. | 625941f024f1403a926010ee |
def CPRCEN_engine_chan_get_last_spurt(*args): <NEW_LINE> <INDENT> return _cerevoice_eng.CPRCEN_engine_chan_get_last_spurt(*args) | CPRCEN_engine_chan_get_last_spurt(CPRCEN_engine eng, CPRCEN_channel_handle chan) -> char | 625941f091f36d47f21aca86 |
def __init__(self, configurations_folder: str, folds: int = 10): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self._folds = folds <NEW_LINE> self._input_configs = [f for f in glob(os.path.join(configurations_folder, "config_*")) if os.path.isdir(f)] | :param configurations_folder: input folder containing run results with different configurations / hyperparameters
:param metric: metric by which to find the best model | 625941f07cff6e4e81117f13 |
def test__guess_seqtype_from_file_fasta_no_header(self): <NEW_LINE> <INDENT> with open(get_file_path('no_header.fasta'), 'r') as h: <NEW_LINE> <INDENT> self.assertEqual("fasta", seqio._guess_seqtype_from_file(h)) <NEW_LINE> h.seek(0) <NEW_LINE> string_seq = h.read() <NEW_LINE> self.assertEqual("fasta", seqio._guess_seq... | Test guessing the sequence type from a fasta file without header | 625941f023849d37ff7b3618 |
def leave_one_out(self, classes, nd_labels, colors): <NEW_LINE> <INDENT> x_ticks = arange(len(classes)) <NEW_LINE> x_tick_labels = classes <NEW_LINE> scores = [[] for j in range(len(self.detectors))] <NEW_LINE> for i in range(len(classes)): <NEW_LINE> <INDENT> print('Dropping class', classes[i]) <NEW_LINE> train_classe... | :param classes: A list of class labels over which a class-level leave-one-out cross validation
is carried out. These are shown on x-axis.
:param nd_labels: Labels of novelty detectors. These are shown in the plot legend.
:param colors: Which colors to use when plotting bars. | 625941f0009cb60464c6393a |
def interval(distribution: ArrayLike, unique: Boolean = True) -> NDArray: <NEW_LINE> <INDENT> distribution = as_float_array(distribution) <NEW_LINE> i = np.arange(distribution.size - 1) <NEW_LINE> differences = np.abs(distribution[i + 1] - distribution[i]) <NEW_LINE> if unique: <NEW_LINE> <INDENT> return np.unique(diff... | Return the interval size of given distribution.
Parameters
----------
distribution
Distribution to retrieve the interval.
unique
Whether to return unique intervals if the distribution is
non-uniformly spaced or the complete intervals
Returns
-------
:class:`numpy.ndarray`
Distribution interval.
Exam... | 625941f08a349b6b435e8700 |
def postXMLRaw(server: hikvisionapi.HikvisionServer, path: str, xmldata: str = None) -> dict: <NEW_LINE> <INDENT> headers = {'Content-Type': 'application/xml'} <NEW_LINE> responseRaw = requests.post( "%s/%s" % (server.address(), path), data=xmldata, headers=headers, auth=HTTPDigestAuth(server.user, server.password)) <N... | This returns the response of the DVR to the following POST request
Parameters:
server (HikvisionServer): The basic info about the DVR
path (str): The ISAPI path that will be executed
xmldata (str): This should be formatted using `utils.dict2xml`
This is the data that will be transmitted ... | 625941f0a79ad161976cc6d3 |
def DarkenBitmap(bmp, caption_colour, new_colour): <NEW_LINE> <INDENT> image = bmp.ConvertToImage() <NEW_LINE> red = caption_colour.Red()/float(new_colour.Red()) <NEW_LINE> green = caption_colour.Green()/float(new_colour.Green()) <NEW_LINE> blue = caption_colour.Blue()/float(new_colour.Blue()) <NEW_LINE> image = image.... | Darkens the input bitmap on wxMAC using the input colour.
:param `bmp`: the bitmap to be manipulated;
:param `caption_colour`: the colour of the pane caption;
:param `new_colour`: the colour used to darken the bitmap. | 625941f03317a56b8693a1d7 |
def graph_scores(dict_reads, fig): <NEW_LINE> <INDENT> fig.add_subplot( 2, 4, (1, 8) ) <NEW_LINE> x_val = [round(sum(score*10 for score in item.quality)/len(item.quality))/10 for item in dict_reads] <NEW_LINE> ax = sns.countplot(x_val) <NEW_LINE> ax.set( xlabel="Quality Score", ylabel="Number of Reads", title="Sequence... | Create subplot for mean scores per read. | 625941f0379a373c97cfb0d4 |
def __init__(self, FILEPATH, SHEETTITLE='title', _INDEX=None): <NEW_LINE> <INDENT> path = os.path.split(FILEPATH) <NEW_LINE> if os.path.exists(path[0]) or path[0] == '': <NEW_LINE> <INDENT> if os.path.splitext(path[1])[1] == '.xlsx': <NEW_LINE> <INDENT> self.excel = FILEPATH <NEW_LINE> self.writeexcel_Data(_TITLE=SHEET... | :param FILEPATH: 需要操作的文件路径
:param SHEETNAME: 工作薄名称,默认为title | 625941f04527f215b584c9df |
def _close(self): <NEW_LINE> <INDENT> if not self.root_app.saved: <NEW_LINE> <INDENT> self.popup_window = tk.Toplevel() <NEW_LINE> self.popup_window.geometry("300x100") <NEW_LINE> self.popup_window.wm_title("Save Work?") <NEW_LINE> bkgd_frame = Frame(self.popup_window, width=300, height=100) <NEW_LINE> bkgd_frame.pack(... | Draws the prompt when the close options is clicked in the menu.
Returns
-------
None. | 625941f04e696a04525c99db |
def get_by_create_date(self, keystone_id, offset_arg=None, limit_arg=None, suppress_exception=False, session=None): <NEW_LINE> <INDENT> offset, limit = clean_paging_values(offset_arg, limit_arg) <NEW_LINE> session = self.get_session(session) <NEW_LINE> try: <NEW_LINE> <INDENT> query = session.query(models.Order) ... | Returns a list of orders, ordered by the date they were created at
and paged based on the offset and limit fields.
:param keystone_id: The keystone id for the tenant.
:param offset_arg: The entity number where the query result should
start.
:param limit_arg: The maximum amount of entities in the res... | 625941f0656771135c3ebe03 |
def defined_characters(version=None, scr=None): <NEW_LINE> <INDENT> load_data() <NEW_LINE> try: <NEW_LINE> <INDENT> return _DEFINED_CHARACTERS_CACHE[(version, scr)] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> characters = _defined_characters <NEW_LINE> if version is not None: <NEW_... | Returns the set of all defined characters in the Unicode Standard. | 625941f0dc8b845886cb5ac4 |
def setCiphers(self, Iterable, QSslCipher=None): <NEW_LINE> <INDENT> pass | setCiphers(self, Iterable[QSslCipher]) | 625941f0be8e80087fb211c7 |
def s_box_replace(self, r_e): <NEW_LINE> <INDENT> sub_blocks = self.split_to_parts(r_e, 6) <NEW_LINE> result = [] <NEW_LINE> for i in range(len(sub_blocks)): <NEW_LINE> <INDENT> block = sub_blocks[i] <NEW_LINE> row = int(str(block[0]) + str(block[5]), 2) <NEW_LINE> column = int( str(block[1]) + str(block[2]) + str(bloc... | S盒子中,以 b1 和 b6 确定行,以 b2 和 b5 确定列。 在这里由于没有仔细看书,
造成了最后的问题出现。 | 625941f0046cf37aa974d2cf |
def opposite(self): <NEW_LINE> <INDENT> if self == CellFaction.INSIDE: <NEW_LINE> <INDENT> return CellFaction.OUTSIDE <NEW_LINE> <DEDENT> if self == CellFaction.OUTSIDE: <NEW_LINE> <INDENT> return CellFaction.INSIDE <NEW_LINE> <DEDENT> if self == CellFaction.UNKNOWN: <NEW_LINE> <INDENT> return CellFaction.UNKNOWN <NEW_... | Get the opposite faction. The opposite of UNKNOWN is UNKNOWN. | 625941f023e79379d52eeaea |
@ec_record_api.get() <NEW_LINE> def get_imported_records(request): <NEW_LINE> <INDENT> obj_id = obj_id_from_url(request) <NEW_LINE> if obj_id is not None: <NEW_LINE> <INDENT> res = get_imported_record_dict(obj_id) <NEW_LINE> if res is not None: <NEW_LINE> <INDENT> return res <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT... | We will do one of two possible things here.
1. Return the searchable fields for all Environment Canada records
in JSON format.
2. Return the JSON record of a particular Environment Canada record. | 625941f0462c4b4f79d1dc5d |
def cmd_commands(self, arg): <NEW_LINE> <INDENT> pass | Not supported yet | 625941f0379a373c97cfb0d5 |
def display_letters_guessed(letters_guessed): <NEW_LINE> <INDENT> print("Letters guessed: ", end='') <NEW_LINE> for i in range(len(letters_guessed)): <NEW_LINE> <INDENT> print(letters_guessed[i], end='') <NEW_LINE> <DEDENT> print("\n") | This function will display the letters the user has guessed | 625941f0c432627299f051d8 |
def isGetNode(node): <NEW_LINE> <INDENT> return (node and node.getType()=='get') | Returns true if the node is a positive reply. | 625941f091f36d47f21aca87 |
def send_queue(self, tid): <NEW_LINE> <INDENT> tid_int = u64(tid) <NEW_LINE> send_size = 0 <NEW_LINE> to_send = {} <NEW_LINE> prefix = self.prefix <NEW_LINE> items = [ (startpos, endpos, oid_int) for (oid_int, (startpos, endpos)) in self.queue_contents.items() ] <NEW_LINE> items.sort() <NEW_LINE> for startpos, endpos, ... | Now that this tid is known, send all queued objects to the cache | 625941f092d797404e30471b |
def test_get_anagram_dict(self): <NEW_LINE> <INDENT> dictionary = {3715217: ['test']} <NEW_LINE> test_list = ['test'] <NEW_LINE> test_dict = anagram_generator.get_anagram_dict(test_list) <NEW_LINE> self.assertDictEqual(dictionary, test_dict) <NEW_LINE> dictionary = {3715217: ['test', 'sett']} <NEW_LINE> test_list = ['t... | Test that it can make an anagram dictionary. | 625941f0a934411ee3751c23 |
def _AddRestoreOps(self, filename_tensor, vars_to_save, restore_sequentially, reshape, preferred_shard=-1, name="restore_all"): <NEW_LINE> <INDENT> assign_ops = [] <NEW_LINE> for vs in vars_to_save: <NEW_LINE> <INDENT> v = vs.var <NEW_LINE> restore_control_inputs = assign_ops[-1:] if restore_sequentially else [] <NEW_L... | Add operations to restore vars_to_save.
Args:
filename_tensor: Tensor for the path of the file to load.
vars_to_save: a list of _VarToSave objects.
restore_sequentially: True if we want to restore variables sequentially
within a shard.
reshape: True if we want to reshape loaded tensors to the shape of
... | 625941f02c8b7c6e89b35d4a |
def plot_data( input_data, xlabel=None, ylabel=None, sed=True, figure=None, e_unit=None, ulim_opts={}, errorbar_opts={}, ): <NEW_LINE> <INDENT> import matplotlib.pyplot as plt <NEW_LINE> try: <NEW_LINE> <INDENT> data = validate_data_table(input_data) <NEW_LINE> <DEDENT> except TypeError as exc: <NEW_LINE> <INDENT> if h... | Plot spectral data.
Parameters
----------
input_data : `emcee.EnsembleSampler`, `astropy.table.Table`, or `dict`
Spectral data to plot. Can be given as a data table, a dict generated
with `validate_data_table` or a `emcee.EnsembleSampler` with a data
property.
xlabel : str, optional
Label for the ``x``... | 625941f09f2886367277ae17 |
def PP82_eqMPH(T, q): <NEW_LINE> <INDENT> Tr = 298.15 <NEW_LINE> return q[0] + q[1] * (T - Tr) + q[2] * (T - Tr) ** 2 / 2 | PP82 equation derived by MP Humphreys. | 625941f071ff763f4b549c24 |
def StopApplication(self, application): <NEW_LINE> <INDENT> self._device.ForceStop(application) | Stop the given |application|.
Args:
application: The full package name string of the application to stop. | 625941f0442bda511e8be99e |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.