code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def get_kmer_locations(seq, kmer="A"): <NEW_LINE> <INDENT> index = 0 <NEW_LINE> locations = [] <NEW_LINE> while index < len(seq): <NEW_LINE> <INDENT> i = seq.find(kmer,index,index+len(kmer)) <NEW_LINE> if i == -1: <NEW_LINE> <INDENT> index += 1 <NEW_LINE> continue <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> locations... | Finds the starting locations of kmers if they are present in a DNA sequence
seq: A DNA sequence provided in string format consisting of only valid nucleotides.
kmer: a string representing a DNA subsequence of length k
returns: All the start locations, if any, of `kmer` in `seq`. | 625941e1b830903b967e9c9a |
def make_csv_dict(video): <NEW_LINE> <INDENT> duration_val = str(video["duration"]) if video["duration"] > 0 else _("Pending") <NEW_LINE> ret = dict( [ (name_col, video["client_video_id"]), (duration_col, duration_val), (added_col, video["created"].isoformat()), (video_id_col, video["edx_video_id"]), (status_col, video... | Makes a dictionary suitable for writing CSV output. This involves
extracting the required items from the original video dict and
converting all keys and values to UTF-8 encoded string objects,
because the CSV module doesn't play well with unicode objects. | 625941e18e7ae83300e4b360 |
def _table_attrs(table): <NEW_LINE> <INDENT> cmd = ["osqueryi"] + ["--json"] + ["pragma table_info({})".format(table)] <NEW_LINE> res = __salt__["cmd.run_all"](cmd) <NEW_LINE> if res["retcode"] == 0: <NEW_LINE> <INDENT> attrs = [] <NEW_LINE> text = salt.utils.json.loads(res["stdout"]) <NEW_LINE> for item in text: <NEW_... | Helper function to find valid table attributes | 625941e1f9cc0f698b14098b |
def set_table_value(self, data_dict): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.setRowCount(len(data_dict)) <NEW_LINE> self.setColumnCount(2) <NEW_LINE> for ind, (key, value) in enumerate(data_dict.items()): <NEW_LINE> <INDENT> item0 = QtWidgets.QTableWidgetItem(key) <NEW_LINE> item0.setFlags(item0.flags() ^ Qt... | Set the data values dictionnary to the custom table.
=============== ====================== ================================================
**Parameters** **Type** **Description**
*data_dict* ordered dictionnary the contents to be stored in the custom table
=============== ==================... | 625941e182261d6c526ab837 |
def dumb_test(): <NEW_LINE> <INDENT> g_names = ['first', 'second'] <NEW_LINE> init_data = np.ones([3,2,5,10]) <NEW_LINE> init_data[0,1] += 1 <NEW_LINE> init_data[1,0] += 2 <NEW_LINE> init_data[1,1] += 3 <NEW_LINE> init_data[2,0] += 4 <NEW_LINE> init_data[2,1] += 5 <NEW_LINE> t1 = TemporalMultiGrid(5, 10, 2, 3, grid_nam... | Dumb unit tests, move to testing framework
| 625941e116aa5153ce36280b |
def _FilterDebuggeeList(self, all_debuggees, pattern): <NEW_LINE> <INDENT> if not all_debuggees: <NEW_LINE> <INDENT> raise errors.NoDebuggeeError() <NEW_LINE> <DEDENT> latest_debuggees = _FilterStaleMinorVersions(all_debuggees) <NEW_LINE> debuggees = ([d for d in all_debuggees if d.target_id == pattern] + [d for d in l... | Finds the debuggee which matches the given pattern.
Args:
all_debuggees: A list of debuggees to search.
pattern: A string containing a debuggee ID or a regular expression that
matches a single debuggee's name or description. If it matches any
debuggee name, the description will not be inspected.
Returns:
... | 625941e1d8ef3951e32438d1 |
def __copy__(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> x = type(self)(self.__class__) <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> cls = self.__class__ <NEW_LINE> x = cls.__new__(cls) <NEW_LINE> <DEDENT> x.__dict__.update(self.__dict__) <NEW_LINE> x.atoms = [] <NEW_LINE> for atom in self.atoms: <... | Function to override the copy() method.
Returns
-------
output : Cell
A new instance with the appropriate properties set. | 625941e1009cb60464c63742 |
def xmlify_content(page): <NEW_LINE> <INDENT> stack = [ET.Element("text")] <NEW_LINE> re_titles = re.compile(r'^(=+) *(.*) *\1$') <NEW_LINE> for line in page.content.splitlines(): <NEW_LINE> <INDENT> match = re.match(re_titles, line) <NEW_LINE> if match: <NEW_LINE> <INDENT> n = max(len(match.group(1)), 2) <NEW_LINE> if... | Given a single Wikipedia page object, converts its text into an XML structure organized by
page sections. | 625941e1d164cc61757830e2 |
def test_season_episode_str_from_show(self): <NEW_LINE> <INDENT> path_to_showdb = os.path.join('example', '.showdb.json') <NEW_LINE> show = tracker.TrackedShow(title='game of thrones', _next_episode='s6e9') <NEW_LINE> showdb = tracker.load_database(path_to_showdb) <NEW_LINE> show._set_next_prev(showdb) <NEW_LINE> self.... | Test that we can build a season-episode code from a TrackedShow instance | 625941e17b25080760e397ea |
def remove_user_option(self, option_name, section_name=None): <NEW_LINE> <INDENT> self.reload() <NEW_LINE> parser = self._get_parser() <NEW_LINE> if section_name is None: <NEW_LINE> <INDENT> section = parser <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> section = parser[section_name] <NEW_LINE> <DEDENT> try: <NEW_LINE>... | Remove a user option and save the configuration file.
:param option_name: The option to be removed.
:param section_name: The section the option is defined in, default to
the default section. | 625941e14c3428357757c6b9 |
def process(self, str_date): <NEW_LINE> <INDENT> fname = r'./exp_sub_%s.data' %(str_date) <NEW_LINE> key = 'subscribe_list:%s' %(str_date) <NEW_LINE> with open(fname,'a+') as f: <NEW_LINE> <INDENT> for n in range(self.redisDB.llen(key)): <NEW_LINE> <INDENT> line = self.redisDB.lindex(key, n) <NEW_LINE> f.write(line +'\... | 从Redis读取,写入文件 | 625941e1fbf16365ca6f655d |
def get_browser_hist(self, br_name): <NEW_LINE> <INDENT> if br_name.lower() not in list(Browser.supported_br.keys()) : <NEW_LINE> <INDENT> raise ValueError("Not Supported Browser") <NEW_LINE> <DEDENT> self.name = br_name <NEW_LINE> db_locs = Browser.supported_br[br_name][PLATFORM] <NEW_LINE> for loc in db_locs : <NEW_L... | Return a string of browser's database file's path.
If browser is not supported, a ValueError exception will be raised.
If browser database file is not found, a FileNotFoundError exception will be raised.
Takes browser's name, if the browser name is not supported a ValueError exception will be raised. | 625941e1fb3f5b602dac3a2a |
def apb_read_slow(self, address, write_ir=False): <NEW_LINE> <INDENT> if write_ir: <NEW_LINE> <INDENT> self.jtag_write_irs(ir_bits = bits_of_n(5,0x11)) <NEW_LINE> pass <NEW_LINE> <DEDENT> if self.use_apb_target_jtag: self.jtag_tms([0,0,0,0,0,0]) <NEW_LINE> data = self.jtag_write_drs(dr_bits = bits_of_n(50,((address&0xf... | Requires the JTAG state machine to be in reset or idle.
Writes the IR to be 'access' if required, then does the appropriate read access; it then waits and does another operation to get the data back | 625941e15166f23b2e1a54ec |
def __init__(self, bounds=None, dimension=None, resolving_power=None, resolving_power_bounds=None, energy_bands=None, sample_size=None, bandpass_name=None, em_band=None, transition=None, restwav=None): <NEW_LINE> <INDENT> self.bounds = bounds <NEW_LINE> self.dimension = dimension <NEW_LINE> self.resolving_power = resol... | Initialize an Energy instance.
Arguments:
None | 625941e1be8e80087fb20fd1 |
def testLinearEthane(self): <NEW_LINE> <INDENT> self.assertFalse(Molecule().fromSMILES('CC').isLinear()) | Test the Molecule.isLinear() method. | 625941e163d6d428bbe44883 |
def __init__(self, collection, parent = None): <NEW_LINE> <INDENT> pass | void Akonadi.CollectionCreateJob.__init__(Akonadi.Collection collection, QObject parent = None) | 625941e11b99ca400220ae46 |
def write_results(results_file, values, labels): <NEW_LINE> <INDENT> arr_values = np.asarray(values) <NEW_LINE> arr_labels = np.asarray(labels) <NEW_LINE> results = np.column_stack((arr_values, arr_labels)) <NEW_LINE> np.savetxt(results_file, results, delimiter="\t", fmt="%s") | Write a Dakota results file from a set of input values.
Parameters
----------
results_file : str
The path to a Dakota results file.
values : array_like
A list or array of numeric values.
labels : str
A list of labels to attach to the values. | 625941e1cad5886f8bd2736c |
def printCite(self, key): <NEW_LINE> <INDENT> t = ["\t"+zi[0]+":\t\""+zi[1]+"\",\n" for zi in self._bib[key][1].items()] <NEW_LINE> tt = "".join(t) <NEW_LINE> return '@{0}'.format(self._bib[key][0])+'{'+'{0},\n'.format(key)+tt+'}' | Print out a complete bibtex entry | 625941e13539df3088e2e6de |
def test_search_name(self): <NEW_LINE> <INDENT> finds = self.search_results("Gmail Team") <NEW_LINE> self.assertEqual(len(finds), 4) | Search by email name | 625941e1ff9c53063f47c585 |
def get_grid(self): <NEW_LINE> <INDENT> grid = open_cp.data.Grid(xsize=self._grid_size, ysize=self._grid_size, xoffset=self._xoffset, yoffset=self._yoffset) <NEW_LINE> return open_cp.geometry.mask_grid_by_points_intersection( self._as_coords(), grid, bbox=True) | Make a grid for the current settings. Clipped to contain all data
points. | 625941e1796e427e537b095c |
def test_apply_cloud_providers_config_extend(self): <NEW_LINE> <INDENT> overrides = {'my-production-envs': [{'extends': 'my-dev-envs:ec2', 'location': 'us-east-1', 'user': 'ec2-user@mycorp.com' }], 'my-dev-envs': [{'id': 'ABCDEFGHIJKLMNOP', 'user': 'user@mycorp.com', 'location': 'ap-southeast-1', 'key': 'supersecretkey... | Tests the successful extension of a cloud provider | 625941e185dfad0860c3b1ef |
def dom_get_node(dom, node_name): <NEW_LINE> <INDENT> for e in dom.getElementsByTagName("node"): <NEW_LINE> <INDENT> if e.hasAttribute("uname") and e.getAttribute("uname") == node_name: <NEW_LINE> <INDENT> return e <NEW_LINE> <DEDENT> <DEDENT> return None | Commandline options: no options | 625941e1a79ad161976cc4d8 |
def _CheckFontOS2Values(path, font, ttf): <NEW_LINE> <INDENT> results = [] <NEW_LINE> font_file = font.filename <NEW_LINE> full_font_file = os.path.join(path, font_file) <NEW_LINE> expected_style = font.style <NEW_LINE> expected_weight = font.weight <NEW_LINE> os2 = ttf['OS/2'] <NEW_LINE> fs_selection_flags = fonts.FsS... | Check sanity of values hidden in the 'OS/2' table.
Notably usWeightClass, fsType, fsSelection.
Args:
path: Path to directory containing font.
font: A font record from a METADATA.pb.
ttf: A fontTools.ttLib.TTFont for the font.
Returns:
A list of ResultMessageTuple for tests performed. | 625941e14d74a7450ccd4557 |
def get_job_logs_dir(args=None, unique_id=None): <NEW_LINE> <INDENT> start_time = time.strftime('%Y-%m-%dT%H.%M') <NEW_LINE> if args is not None: <NEW_LINE> <INDENT> logdir = args.logdir or get_logs_dir() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> logdir = get_logs_dir() <NEW_LINE> <DEDENT> if unique_id is None: <NE... | Create a log directory for a job, or a stand alone execution of a test.
:param args: :class:`argparse.Namespace` instance with cmdline arguments
(optional).
:rtype: basestring | 625941e1460517430c39450f |
def do_action(self): <NEW_LINE> <INDENT> self.index_list.empty_list_check() <NEW_LINE> self.loggit.info( 'Opening {0} selected indices: {1}'.format( len(self.index_list.indices), self.index_list.indices ) ) <NEW_LINE> try: <NEW_LINE> <INDENT> index_lists = utils.chunk_index_list(self.index_list.indices) <NEW_LINE> for ... | Open closed indices in `index_list.indices` | 625941e1e1aae11d1e74a04e |
def read_file(self, filename): <NEW_LINE> <INDENT> self.filename=filename <NEW_LINE> self.lineno=0 <NEW_LINE> fp=open(filename) <NEW_LINE> lines = fp.readlines() <NEW_LINE> lines.append("\n") <NEW_LINE> self.parse_lines(lines, 0, self.objects) <NEW_LINE> fp.close() | read one file | 625941e1baa26c4b54cb14af |
def DeleteMessage(self, instanceID, id, autoHandleToken=None): <NEW_LINE> <INDENT> return self.__callMethod("DeleteMessage", {"instanceID": instanceID, "id": id}, autoHandleToken=autoHandleToken) | Delete a single message
:param instanceID: Unique ID of MailStore instance in which this command is invoked.
:type instanceID str
:param id: Unique ID of message. Format: <store_id>:<message_num>
:type id: str | 625941e12eb69b55b151cc47 |
def run(self): <NEW_LINE> <INDENT> super(SignTransaction, self).run() | Run rest request | 625941e1a05bb46b383ecbb2 |
def test_canNotSendIfInNoPMCreatorGroup(self): <NEW_LINE> <INDENT> pmCreator2 = self.portal.portal_membership.getMemberById('pmCreator2') <NEW_LINE> self.assertTrue([group for group in self.portal.acl_users.source_groups.getGroupsForPrincipal(pmCreator2) if group.endswith('_creators')]) <NEW_LINE> self.portal.portal_gr... | If the user that wants to send the item in PloneMeeting is not a creator in PM,
aka is not in a _creators suffixed group, a message is displayed to him. | 625941e1e5267d203edce02c |
def setBrightness(self, brightness): <NEW_LINE> <INDENT> if (brightness > 15): <NEW_LINE> <INDENT> brightness = 15 <NEW_LINE> <DEDENT> self.i2c.write8(self.__HT16K33_REGISTER_DIMMING | brightness, 0x00) | Sets the brightness level from 0..15 | 625941e1b830903b967e9c9b |
def __init__(self): <NEW_LINE> <INDENT> self.VpcId = None <NEW_LINE> self.SubnetId = None <NEW_LINE> self.HaVipName = None <NEW_LINE> self.Vip = None | :param VpcId: `HAVIP`所在私有网络`ID`。
:type VpcId: str
:param SubnetId: `HAVIP`所在子网`ID`。
:type SubnetId: str
:param HaVipName: `HAVIP`名称。
:type HaVipName: str
:param Vip: 指定虚拟IP地址,必须在`VPC`网段内且未被占用。不指定则自动分配。
:type Vip: str | 625941e13317a56b86939fe3 |
def obfuscate_string(a_str): <NEW_LINE> <INDENT> return base64.b64encode(a_str) | use base64 to obfuscate a string | 625941e197e22403b379d32f |
def get_tutor_attacks(lines, generation=7): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> index = lines.index('Durch Attacken-Lehrer') <NEW_LINE> index = lines.index(str(generation) + '. Generation', index) <NEW_LINE> <DEDENT> except: return set() <NEW_LINE> tutor_attacks = set() <NEW_LINE> index += 10 if generation > 3... | Parses the html lines and returns a
list of attacks to be obtained by attack tutors
in one generation. | 625941e1925a0f43d254a20e |
def downweight_quality(quality,change_bases_c=None,change_bases_t=None): <NEW_LINE> <INDENT> if(change_bases_t and change_bases_c): <NEW_LINE> <INDENT> qual_filter=[ a or b for a, b in zip(change_bases_c,change_bases_t)] <NEW_LINE> <DEDENT> elif(change_bases_t): <NEW_LINE> <INDENT> qual_filter=change_bases_t <NEW_LINE>... | Returns PHRED qualities that remove downweight Cs or Ts at
the start of reads. | 625941e1283ffb24f3c55c91 |
def __init__(self, model: Autoencoder): <NEW_LINE> <INDENT> self.model = model <NEW_LINE> self.use_conditions = self.model._conditional_decoder() <NEW_LINE> self.use_sf = self.model._use_sf() | Arguments:
model: An autoencoder model. | 625941e196565a6dacc8fa5e |
def accel_quit(self, *args): <NEW_LINE> <INDENT> if self.client.get_bool(KEY('/general/prompt_on_quit')): <NEW_LINE> <INDENT> procs = self.get_running_fg_processes() <NEW_LINE> self.isPromptQuitDialogOpened = True <NEW_LINE> dialog = PromptQuitDialog(self.window, procs) <NEW_LINE> response = dialog.run() == gtk.RESPONS... | Callback to prompt the user whether to quit Guake or not.
| 625941e1d4950a0f3b08c6de |
def getNextStep(self): <NEW_LINE> <INDENT> if not self.steps: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if not self.remote: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if self.terminate or self.stopped: <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> s = self.steps.pop(0) <NEW_LINE> if s.alwaysRun... | This method is called to obtain the next BuildStep for this build.
When it returns None (or raises a StopIteration exception), the build
is complete. | 625941e1498bea3a759b9e42 |
def column_to_list(data, index): <NEW_LINE> <INDENT> column_list = [] <NEW_LINE> for item in data: <NEW_LINE> <INDENT> column_list.append(item[index]) <NEW_LINE> <DEDENT> return column_list | Return the list of elements in data argument (dataset) on index column in the same order. | 625941e17b25080760e397eb |
def verifyCertificate(self, request): <NEW_LINE> <INDENT> self.send_verifyCertificate(request) <NEW_LINE> return self.recv_verifyCertificate() | Parameters:
- request | 625941e1cb5e8a47e48b7e39 |
def get_types(self, cnxt=None, support_status=None, type_name=None, version=None): <NEW_LINE> <INDENT> if support_status is not None and not support.is_valid_status( support_status): <NEW_LINE> <INDENT> msg = (_('Invalid support status and should be one of %s') % six.text_type(support.SUPPORT_STATUSES)) <NEW_LINE> rais... | Return a list of valid resource types. | 625941e121bff66bcd684ce3 |
def schema_class_resolver(self, main_plugin: SerpycoPlugin) -> SchemaUsage: <NEW_LINE> <INDENT> serpyco_plugin_kwargs = {} <NEW_LINE> serpyco_name_resolver_kwargs = {} <NEW_LINE> if self._exclude: <NEW_LINE> <INDENT> serpyco_plugin_kwargs["exclude"] = self._exclude <NEW_LINE> serpyco_name_resolver_kwargs["exclude"] = s... | Return schema class with adaptation if needed.
:param main_plugin: Apispec plugin associated for marshmallow
:return: schema generated from given schema or original schema if
no change required. | 625941e1be383301e01b5813 |
def SetItemHasChildren(self, item, has=True): <NEW_LINE> <INDENT> item.SetHasPlus(has) <NEW_LINE> self.RefreshLine(item) | Forces the appearance/disappearance of the button next to the item.
:param `item`: an instance of L{GenericTreeItem};
:param bool `has`: ``True`` to have a button next to an item, ``False`` otherwise. | 625941e1aad79263cf390dda |
def get_include(): <NEW_LINE> <INDENT> import os <NEW_LINE> return os.path.join(os.path.dirname(__file__), 'include') | Return absolute path to directory containing Arrow C++ include
headers. Similar to numpy.get_include | 625941e1462c4b4f79d1da63 |
def encode(self, longUrl): <NEW_LINE> <INDENT> while longUrl not in self.url2code: <NEW_LINE> <INDENT> tinyCode = "".join(random.choice(Codec.alphabet) for _ in range(6)) <NEW_LINE> if tinyCode not in self.code2url: <NEW_LINE> <INDENT> self.url2code[longUrl] = tinyCode <NEW_LINE> self.code2url[tinyCode] = longUrl <NEW_... | Encodes a URL to a shortened URL.
:type longUrl: str
:rtype: str | 625941e1956e5f7376d71200 |
def get_peer_submission(self, student_item_dict, assessment): <NEW_LINE> <INDENT> from openassessment.assessment.api import peer as peer_api <NEW_LINE> peer_submission = False <NEW_LINE> try: <NEW_LINE> <INDENT> peer_submission = peer_api.get_submission_to_assess( self.submission_uuid, assessment["must_be_graded_by"] )... | Retrieve a submission to peer-assess.
Args:
student_item_dict (dict): The student item for the student creating the submission.
assessment (dict): A dict describing the requirements for grading.
Returns:
dict: The serialized submission model. | 625941e14e696a04525c97e0 |
def crs_add(self): <NEW_LINE> <INDENT> checks = [] <NEW_LINE> if hasattr(self.project, 'crsadd'): <NEW_LINE> <INDENT> c = self.project.crsadd <NEW_LINE> for flag in c.other_flags.all(): <NEW_LINE> <INDENT> if not flag.code: <NEW_LINE> <INDENT> checks.append((u'warning', u'CRS other flag (id: %s) has no code ' u'specifi... | Check if crs add other flags have a code and significance.
Check if loan status year is present if any of the other loan status fields
is present.
Check if loan status currency or default currency is present if any of
the other loan status fields is present.
:return: List of tuples; Boolean for check passed and string... | 625941e199fddb7c1c9de723 |
def test_get_user_by_id(user_client, user): <NEW_LINE> <INDENT> resp = user_client.get(reverse("users_api-detail", kwargs={"pk": user.id})) <NEW_LINE> assert resp.status_code == status.HTTP_200_OK <NEW_LINE> assert resp.json() == { "id": user.id, "username": user.username, "email": user.email, "legal_address": { "first... | Test that user can request their own user by id | 625941e124f1403a92600ef7 |
def command_demote(args): <NEW_LINE> <INDENT> if args['USER'] == 'superadmin': <NEW_LINE> <INDENT> print('Cannot demote the superadmin!') <NEW_LINE> exit(1) <NEW_LINE> <DEDENT> res = db.update_dj_status(args['USER'], 'admin', False) <NEW_LINE> if res is not None: <NEW_LINE> <INDENT> print('User "{}" is no longer an adm... | Demote an admin to user. | 625941e14e696a04525c97e1 |
@contextlib.contextmanager <NEW_LINE> def nostderr(): <NEW_LINE> <INDENT> savestderr = sys.stderr <NEW_LINE> class Devnull(object): <NEW_LINE> <INDENT> def write(self, _): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> <DEDENT> sys.stderr = Devnull() <NEW_LINE> try: <NEW_LINE> <INDENT> yield <NEW_LINE> <DEDENT> finally: ... | Context manager to suppress standard error
http://stackoverflow.com/questions/1809958/hide-stderr-output-in-unit-tests | 625941e11f037a2d8b946591 |
def _get_storage_format(self): <NEW_LINE> <INDENT> storage = { 'path': self._path, 'storage_type': self.storage_type, 'added_by_module': 'backups', 'credentials': self.credentials, 'schedule': self.schedule.get_storage_format() } <NEW_LINE> if self.uuid: <NEW_LINE> <INDENT> storage['uuid'] = self.uuid <NEW_LINE> <DEDEN... | Return a dict representing the repository. | 625941e1a05bb46b383ecbb3 |
@pytest.hookspec(firstresult=True) <NEW_LINE> def pytest_xdist_make_scheduler(config, log): <NEW_LINE> <INDENT> pass | return a node scheduler implementation | 625941e176d4e153a657eec6 |
def check_reversible(self): <NEW_LINE> <INDENT> reversible = [i.reversible for i in self.elementary_reactions] <NEW_LINE> return reversible | Check if each elementary reaction is reversible
Returns
-------
reversible : list
a list of True and False indicating if each elementary
reaction is reversible
Examples
--------
>>> reader = XMLReader("tests/rxns.xml")
>>> reaction_system = reader.get_reaction_systems()
>>> reaction_system[0].check_reversible... | 625941e107d97122c4178c27 |
def test_loss(net, criterion, y0_l): <NEW_LINE> <INDENT> def net_func(t, y): <NEW_LINE> <INDENT> v = net.forward(torch.tensor(y, dtype=torch.float32)).detach().numpy() <NEW_LINE> return v <NEW_LINE> <DEDENT> t = np.linspace(start=args.T0, stop=args.Tend, num=args.num_point) <NEW_LINE> func = spiral <NEW_LINE> data_y, d... | INPUT:
net = trained neural network
criterion = a function that takes in two y arrays and calculates loss
OUTPUT:
test loss according to criterion | 625941e13346ee7daa2b3102 |
def me_diatomic(bond, n, l_min, l_max, m, which_neighbour, overlap=False): <NEW_LINE> <INDENT> label = n[0] + ORBITAL_QN[l_min] + n[1] + ORBITAL_QN[l_max] + '_' + M_QN[m] <NEW_LINE> if overlap: <NEW_LINE> <INDENT> flag = 'OV_' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> flag = 'PARAMS_' <NEW_LINE> <DEDENT> try: <NEW_... | The function looks up into the table of parameters making a query parametrized by:
Parameters
----------
bond :
a bond type represented by a list of atom labels
n :
combination of the principal quantum numbers of atoms
l_min :
min(l1, l2), where l1 and l2 are orbital quantum numbers of atoms
l_max :
ma... | 625941e126068e7796caf078 |
def update(self, state, action, nextState, reward): <NEW_LINE> <INDENT> a = self.alpha <NEW_LINE> oldQ = self.getQValue(state, action) <NEW_LINE> y = self.discount <NEW_LINE> nextQ = 0.0 <NEW_LINE> if len(self.getLegalActions(state)) != 0 and nextState != None: <NEW_LINE> <INDENT> nextQ = self.getValue(nextState) <NEW_... | The parent class calls this to observe a
state = action => nextState and reward transition.
You should do your Q-Value update here
NOTE: You should never call this function,
it will be called on your behalf | 625941e13eb6a72ae02ec87a |
def approve(owner, spender, amount): <NEW_LINE> <INDENT> assert (amount > 0) <NEW_LINE> assert (not isPaused()) <NEW_LINE> assert (isAddress(spender)) <NEW_LINE> assert (CheckWitness(owner)) <NEW_LINE> Put(ctx, concat(concat(APPROVE_KEY, owner), spender), amount) <NEW_LINE> ApproveEvent(owner, spender, amount) <NEW_LIN... | owner allow spender to spend amount of token from owner account
Note here, the amount should be less than the balance of owner right now.
:param owner:
:param spender:
:param amount: amount>=0
:return: True means success, False or raising exception means failure. | 625941e1fb3f5b602dac3a2b |
def set_generic(self, name, value): <NEW_LINE> <INDENT> self._check_enabled() <NEW_LINE> for configs in self.get_configuration_dicts(): <NEW_LINE> <INDENT> for config in configs.values(): <NEW_LINE> <INDENT> config.set_generic(name, value) | Set generic | 625941e1a8370b7717052c32 |
def rating_quads(lang, cutoff=DEFAULT_CUTOFF, filter=None): <NEW_LINE> <INDENT> from conceptnet.models import AssertionVote <NEW_LINE> ratings = AssertionVote.objects.filter( assertion__concept1__num_assertions__gte=cutoff, assertion__concept2__num_assertions__gte=cutoff) <NEW_LINE> if filter is not None: <NEW_LINE> <I... | Generates a quad for each rating (vote) on Assertions.
A django.db.models.Q object passed to filter will be applied to
the Vote queryset. | 625941e1aad79263cf390ddb |
def __str__(self): <NEW_LINE> <INDENT> return str(self.value) | Just converts the underlying data to a string.
This is apparently Not The Way you're supposed to handle this, but it seems like it should work.
>>> str(SpellRange('90 feet'))
'90 feet' | 625941e18c3a873295158753 |
def delexicalize(response_text, data_line): <NEW_LINE> <INDENT> text = response_text <NEW_LINE> for slot, value in data_line.slot_values.iteritems(): <NEW_LINE> <INDENT> if slot == 'alternative': <NEW_LINE> <INDENT> if value == '2': <NEW_LINE> <INDENT> for val in ['second', '2nd']: <NEW_LINE> <INDENT> text = re.sub(r'\... | Delexicalize (normalized) response text. | 625941e1cdde0d52a9e533ca |
def main(args_in=None): <NEW_LINE> <INDENT> args = docopt.docopt(__doc__, args_in) <NEW_LINE> routes = [] <NEW_LINE> if args['-H']: <NEW_LINE> <INDENT> routes = [Route(args['<host>'], int(args['<port>']), int(args['<local_port>']))] <NEW_LINE> <DEDENT> elif args['-c']: <NEW_LINE> <INDENT> with open(args['<conf_path>'],... | logic entrance for this program
:param args_in: the specified command line args; default to None, uses sys.argv[1:]
:return: | 625941e129b78933be1e5a3c |
def DayOfWeek(self): <NEW_LINE> <INDENT> pass | Compatibility: see Day. | 625941e1d18da76e2353286e |
@task <NEW_LINE> def deploy_tiles(local_file): <NEW_LINE> <INDENT> remote_file = '/srv/tiles/tiles.mbtiles' <NEW_LINE> put(local_path=local_file, remote_path=remote_file) <NEW_LINE> versioned_path = '/srv/%s/tiles-%s' % (env.user, datetime.now().strftime('%Y%m%d%H%M')) <NEW_LINE> run('mb-util {file} {path}'.format(file... | Deploy tiles from a file to the web server
:param local_file: local mbtiles file to push to the server | 625941e17c178a314d6ef7f9 |
def t_SUPEQ(p): <NEW_LINE> <INDENT> return p | >= | 625941e115baa723493c430c |
def test_api_search( self ): <NEW_LINE> <INDENT> params = self.get_test_user_form(); <NEW_LINE> params[ 'q' ] = 'second' <NEW_LINE> rv = self.client.get( '/api/posts/search?' + urllib.parse.urlencode( params ) ) <NEW_LINE> assert b'second post' in rv.data <NEW_LINE> json_data = json.loads( rv.data.decode( 'utf-8' ) ) <... | test /api/posts/search | 625941e173bcbd0ca4b2c40a |
def is_digit(code_point): <NEW_LINE> <INDENT> if False: <NEW_LINE> <INDENT> return (UNICODE_ATTRIBUTES[code_point]['name'] and UNICODE_ATTRIBUTES[code_point]['category'] == 'Nd') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return (code_point >= 0x0030 and code_point <= 0x0039) | Checks whether the character with this code point is a digit | 625941e1498bea3a759b9e43 |
def extract_tile(image: Image, x: int, y: int) -> List[Color]: <NEW_LINE> <INDENT> pixels_with_alpha = [image.getpixel((i, j)) for j in range(y*8, y*8+8) for i in range(x*8, x*8+8)] <NEW_LINE> mode = image.mode <NEW_LINE> if (mode == 'RGBA'): <NEW_LINE> <INDENT> pixels = [(r, g, b) for (r, g, b, _) in pixels_with_alpha... | Extract the (x, y) tile and returns the flattened pixel list
The returned pixels do not have their alpha values! | 625941e17c178a314d6ef7fa |
def allprecursors(obsstore, nodes, ignoreflags=0): <NEW_LINE> <INDENT> remaining = set(nodes) <NEW_LINE> seen = set(remaining) <NEW_LINE> while remaining: <NEW_LINE> <INDENT> current = remaining.pop() <NEW_LINE> yield current <NEW_LINE> for mark in obsstore.precursors.get(current, ()): <NEW_LINE> <INDENT> if mark[2] & ... | Yield node for every precursors of <nodes>.
Some precursors may be unknown locally.
This is a linear yield unsuited to detecting folded changesets. It includes
initial nodes too. | 625941e156b00c62f0f149f0 |
def is_validated_morse_code(user_input): <NEW_LINE> <INDENT> alpabet_to_morse = get_morse_code_dict() <NEW_LINE> morse_to_alpabet = get_morse_to_alpabet(alpabet_to_morse) <NEW_LINE> split_input = user_input.split() <NEW_LINE> result = True <NEW_LINE> for input_element in split_input: <NEW_LINE> <INDENT> if input_elemen... | Input:
- user_input : 문자열값으로 사용자가 입력하는 문자
Output:
- 입력한 값이 아래에 해당될 경우 False, 그렇지 않으면 True
1) "-","."," "외 다른 글자가 포함되어 있는 경우
2) get_morse_code_dict 함수에 정의된 Morse Code 부호외 다른 코드가 입력된 경우 ex)......
Examples:
>>> import morsecode as mc
>>> mc.is_validated_morse_code("..")
True
>>> mc.is_v... | 625941e176e4537e8c351a0a |
def PEditStokes (inUV, outUV, err): <NEW_LINE> <INDENT> if inUV.myClass=='AIPSUVData': <NEW_LINE> <INDENT> raise TypeError("Function unavailable for "+inUV.myClass) <NEW_LINE> <DEDENT> if not inUV.UVIsA(): <NEW_LINE> <INDENT> raise TypeError("inUV MUST be a Python Obit UV") <NEW_LINE> <DEDENT> if ((not scratch) and (no... | Stokes editing of UV data, FG table out
All data on a given baseline/correlator are flagged if the
amplitude of the datatype "FlagStok" exceeds maxAmp.
If a fraction of bad baselines on any antenna/channel/IF exceeds
maxBad, then all data to that correlator is flagged.
Flagging entries are written into FG ta... | 625941e1a934411ee3751a29 |
def _add_folders(self, path): <NEW_LINE> <INDENT> parent = path.rsplit('\\', 2)[0] + '\\' <NEW_LINE> if parent == '\\': <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if parent not in self._paths_set: <NEW_LINE> <INDENT> self.add_folder_row(parent) <NEW_LINE> <DEDENT> self._add_folders(parent) | Strips the path leaf and adds it to the frame if it does not exist. | 625941e1091ae356686672ed |
def test_common_creation_steps(self): <NEW_LINE> <INDENT> MT = qdb.metadata_template.base_metadata_template.MetadataTemplate <NEW_LINE> with self.assertRaises(IncompetentQiitaDeveloperError): <NEW_LINE> <INDENT> MT._common_creation_steps(None, 1) | common_creation_steps raises an error from base class
| 625941e16e29344779a629a5 |
def test_Action(self): <NEW_LINE> <INDENT> test_node = Mock(spec=['attrib', 'text', 'findall']) <NEW_LINE> test_node.attrib = { '{http://www.w3.org/2001/XMLSchema-instance}t1': 't1', '{http://www.openrtp.org/namespaces/rtc_ext}t1': 't1', } <NEW_LINE> test_node.text = 'b' <NEW_LINE> test_node.findall.return_value = [] <... | test for Action.__init__ & setImplemented | 625941e15fdd1c0f98dc05c9 |
def _as_reference_point(self) -> np.ndarray: <NEW_LINE> <INDENT> ref_val = [] <NEW_LINE> for fn, f in self._classification.items(): <NEW_LINE> <INDENT> if f[0] == "<": <NEW_LINE> <INDENT> ref_val.append(self._method.problem.ideal[fn]) <NEW_LINE> <DEDENT> elif f[0] == "<>": <NEW_LINE> <INDENT> ref_val.append(self._metho... | Return classification information as reference point
| 625941e14a966d76dd5513a7 |
def save(self, file_name_prefix, save_folder): <NEW_LINE> <INDENT> file_url_keras_model = os.path.join(save_folder, file_name_prefix + "_rnn_model.h5") <NEW_LINE> self.model.save(file_url_keras_model) <NEW_LINE> file_url_class = os.path.join(save_folder, file_name_prefix + "_rnn_class.pkl") <NEW_LINE> with open(file_ur... | Saves the trained model into a h5 file
Args:
file_name_prefix: a file name prefix having the following format 'named_entity_recognition_%Y%m%d_%H%M%S'
save_folder: folder under which to save the files
Return:
None | 625941e11d351010ab855eb0 |
def test_initial_connection(self): <NEW_LINE> <INDENT> socketio = SocketIO('localhost', 5000, LoggingNamespace) <NEW_LINE> status = socketio.connected <NEW_LINE> socketio.disconnect() <NEW_LINE> assert status is True | socket connections are working | 625941e18a43f66fc4b543f6 |
def bound_value(value, minimum=-math.inf, maximum=math.inf, to_int=False): <NEW_LINE> <INDENT> if minimum is None: <NEW_LINE> <INDENT> minimum = -math.inf <NEW_LINE> <DEDENT> if maximum is None: <NEW_LINE> <INDENT> maximum = math.inf <NEW_LINE> <DEDENT> if to_int: <NEW_LINE> <INDENT> if isinstance(minimum, float) and m... | Bounds a value between a minimum and maximum
:param value: the value to bound
:type value: int/float
:param minimum: the lower bound
:type minimum: int/float
:param maximum: the upper bound
:type maximum: int/float
:param to_int: whether or not to cast the result to an int
:type to_int: bool
:returns: the bounded... | 625941e11f037a2d8b946592 |
@tf_export(v1=["dimension_at_index"]) <NEW_LINE> def dimension_at_index(shape, index): <NEW_LINE> <INDENT> assert isinstance(shape, TensorShape) <NEW_LINE> if shape.rank is None: <NEW_LINE> <INDENT> return Dimension(None) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return shape.dims[index] | Compatibility utility required to allow for both V1 and V2 behavior in TF.
Until the release of TF 2.0, we need the legacy behavior of `TensorShape` to
coexist with the new behavior. This utility is a bridge between the two.
If you want to retrieve the Dimension instance corresponding to a certain
index in a TensorSh... | 625941e167a9b606de4a824c |
def mm_move(board, player): <NEW_LINE> <INDENT> if board.check_win() is not None: <NEW_LINE> <INDENT> return SCORES[board.check_win()], (-1, -1) <NEW_LINE> <DEDENT> empty_squares = board.get_empty_squares() <NEW_LINE> sign = 1 if player is provided.PLAYERX else -1 <NEW_LINE> score = -2 <NEW_LINE> move = (-1, -1) <NEW_L... | Make a move on the board.
Returns a tuple with two elements. The first element is the score
of the given board and the second element is the desired move as a
tuple, (row, col). | 625941e10c0af96317bb857c |
def load_dataset(csv_path, label_col='y', add_intercept=False): <NEW_LINE> <INDENT> def add_intercept_fn(x): <NEW_LINE> <INDENT> global add_intercept <NEW_LINE> return add_intercept(x) <NEW_LINE> <DEDENT> allowed_label_cols = ('y', 't') <NEW_LINE> if label_col not in allowed_label_cols: <NEW_LINE> <INDENT> raise ValueE... | Load dataset from a CSV file.
Args:
csv_path: Path to CSV file containing dataset.
label_col: Name of column to use as labels (should be 'y' or 't').
add_intercept: Add an intercept entry to x-values.
Returns:
xs: Numpy array of x-values (inputs).
ys: Numpy array of y-values (labels). | 625941e18e7ae83300e4b362 |
def _set_kubernetes_api_connection_info(self): <NEW_LINE> <INDENT> api_host = os.environ.get('KUBERNETES_SERVICE_HOST', "kubernetes.default") <NEW_LINE> api_port = os.environ.get('KUBERNETES_SERVICE_PORT', "443") <NEW_LINE> self.api_url = "https://{}:{}".format(api_host, api_port) | Set kubernetes API string from default container environment
variables | 625941e1e1aae11d1e74a04f |
def makegenstr(payload): <NEW_LINE> <INDENT> return maketlv('\x1b', payload) | Construct a DER encoding of an ASN.1 GeneralString of given payload | 625941e1b5575c28eb68e398 |
def add_salt_pepper(tomo, prob=0.01, val=None): <NEW_LINE> <INDENT> tomo = dtype.as_ndarray(tomo) <NEW_LINE> dx, dy, dz = tomo.shape <NEW_LINE> ind = np.random.rand(dx, dy, dz) < prob <NEW_LINE> if val is None: <NEW_LINE> <INDENT> val = tomo.max() <NEW_LINE> <DEDENT> tomo[ind] = val <NEW_LINE> return tomo | Add salt and pepper noise.
Parameters
----------
tomo : ndarray
3D tomographic data.
prob : float, optional
Independent probability that each element of a pixel might be
corrupted by the salt and pepper type noise.
val : float, optional
Value to be assigned to the corrupted pixels.
Returns
-------
nda... | 625941e16aa9bd52df03713a |
def hardDrop(self): <NEW_LINE> <INDENT> x1 = self.piece.getMinH() <NEW_LINE> x2 = self.piece.getMaxH() <NEW_LINE> y = self.piece.getMaxV() <NEW_LINE> for j in range(y+1,20): <NEW_LINE> <INDENT> nbCasesLibres=0 <NEW_LINE> for i in range(x1,x2+1): <NEW_LINE> <INDENT> if self.board.grille[j][i]==0: <NEW_LINE> <INDENT> nbC... | Fonction permettant de faire chuter la pièce
en jeu au point le plus bas possible | 625941e182261d6c526ab839 |
def __str__(self): <NEW_LINE> <INDENT> return "[ %s ]" % ",".join( self.tokens ) | String interface | 625941e18c0ade5d55d3ed53 |
def clones(self): <NEW_LINE> <INDENT> raise NotImplementedError("This function is not written yet. Please put in an issue on the github page.") | self.clones() -> Number of clones.
@return: Number of clones. | 625941e15fc7496912cc3d13 |
def FormatHeader(header, char='*'): <NEW_LINE> <INDENT> format_string = '\n{{0:{0:s}^80}}'.format(char) <NEW_LINE> return format_string.format(u' {0:s} '.format(header)) | Formats the header as a line of 80 chars with the header text centered. | 625941e16fb2d068a760f437 |
def serialize(self, buff): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> buff.write(_struct_i.pack(self.buttonID)) <NEW_LINE> length = len(self.auxiliaryValues) <NEW_LINE> buff.write(_struct_I.pack(length)) <NEW_LINE> pattern = '<%si'%length <NEW_LINE> buff.write(struct.pack(pattern, *self.auxiliaryValues)) <NEW_LINE> <... | serialize message into buffer
:param buff: buffer, ``StringIO`` | 625941e13cc13d1c6d3c770d |
def test_create_branch(self): <NEW_LINE> <INDENT> self._test_push(self.authentication, 'refs/heads/release/0.0.1') | Test manager's ability to create branches. | 625941e116aa5153ce36280d |
def noise(self, sigma, attr=("x", "y", "z")): <NEW_LINE> <INDENT> if sigma < 0: <NEW_LINE> <INDENT> raise ValueError("Standard deviation must be positive.") <NEW_LINE> <DEDENT> for at in attr: <NEW_LINE> <INDENT> if at in self.data: <NEW_LINE> <INDENT> if isinstance(self.data[at], numpy.ndarray): <NEW_LINE> <INDENT> se... | Adds white noise of standard deviation 'sigma' to all elements with attribute 'attr'.
@sigma: standard deviation of the Gaussian (white) noise
@[attr]: attribute to perturb (positions by default) | 625941e121a7993f00bc808b |
def parse_args(self, ap_mac, ssid, passphrase, channel=None, double_3handshake=True, encrypt_3handshake=True, wait_3handshake=0, double_gtk_refresh=True, arp_target_ip=None, arp_source_ip=None, wait_gtk=10, **kwargs): <NEW_LINE> <INDENT> super(KrackAP, self).parse_args(**kwargs) <NEW_LINE> self.mac = ap_mac <NEW_LINE> ... | Mandatory arguments:
@iface: interface to use (must be in monitor mode)
@ap_mac: AP's MAC
@ssid: AP's SSID
@passphrase: AP's Passphrase (min 8 char.)
Optional arguments:
@channel: used by the interface. Default 6, autodetected on windows
Krack attacks options:
- Msg 3/4 handshake replay:
double_3handshake: double t... | 625941e1fbf16365ca6f655f |
def getUserBGs(uid: int) -> list: <NEW_LINE> <INDENT> bgs = glob.db.fetch("SELECT custom_bgs FROM user_kotrik_settings WHERE uid = %s", [uid]) <NEW_LINE> if not bgs: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> return bgs['custom_bgs'].split("|") | I'm tired, but this function returns the list with custom bgs! | 625941e17b25080760e397ec |
def add_mode(self, name, mode_or_component, toggle_value = False, groups = set(), behaviour = None): <NEW_LINE> <INDENT> if not name not in self._mode_map.keys(): <NEW_LINE> <INDENT> raise AssertionError <NEW_LINE> if not isinstance(groups, set): <NEW_LINE> <INDENT> groups = set(groups) <NEW_LINE> <DEDENT> mode = tomod... | Adds a mode of the given name into the component. The mode
object should be a Mode or ControlSurfaceComponent instance.
The 'toggle_value' is the light value the toggle_botton will
be set to when the component is on this mode.
If 'group' is not None, the mode will be put in the group
identified by the passed object.... | 625941e1ab23a570cc25051a |
def sol4(filename): <NEW_LINE> <INDENT> lang_freq = Load_LangMetric("char_freq_english.txt", "\n", string.ascii_lowercase + " ") <NEW_LINE> return MaxScore(filename, lang_freq) | Returns the string that is encoded by single-char encryption from a list of strings | 625941e14428ac0f6e5bab8a |
def test_editor_can_delete_owned_internal_resources(self): <NEW_LINE> <INDENT> client = test_utils.get_client_with_user_logged_in(EditorTest.superuser_login) <NEW_LINE> response = client.get('{}repository/resourceinfotype_model/{}/delete/' .format(ADMINROOT, EditorTest.testfixture4.id)) <NEW_LINE> self.assertContains(r... | Verifies that an editor user can delete owned resources that have
"internal" as publication status. | 625941e15fdd1c0f98dc05ca |
def validate_user_categories(self, user): <NEW_LINE> <INDENT> if 'categories' not in self.cleaned_data: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> user_categories = set(user.categories.all()) <NEW_LINE> categories = set(self.cleaned_data['categories']) <NEW_LINE> if not categories.issubset(user_categories): <NEW_LI... | Check that user belongs to the selected categories. | 625941e15e10d32532c5f2ba |
def create(self, request): <NEW_LINE> <INDENT> body = request.data <NEW_LINE> property_state_ids = body['property_state_ids'] <NEW_LINE> taxlot_state_ids = body['taxlot_state_ids'] <NEW_LINE> organization = Organization.objects.get(pk=request.query_params['organization_id']) <NEW_LINE> return_value = do_checks(organiza... | This API endpoint will create a new cleansing operation process in the background,
on potentially a subset of properties/taxlots, and return back a query key
---
parameters:
- name: organization_id
description: Organization ID
type: integer
required: true
paramType: query
- name: data_qu... | 625941e1796e427e537b095d |
def _timed_callable(self): <NEW_LINE> <INDENT> if self.loop_active: <NEW_LINE> <INDENT> self.log.warning("% missed a frame!", self) <NEW_LINE> return <NEW_LINE> <DEDENT> self.loop_active = True <NEW_LINE> product = self.produce() <NEW_LINE> if product is not None: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.input... | Callback function for timer. Calls implemented produce() function
which returns the data this thread produces. | 625941e182261d6c526ab83a |
def get_audits( self, references=None, authorization=None, x_request_id=None, continuation_token=None, filter=None, ids=None, limit=None, names=None, offset=None, sort=None, async_req=False, _return_http_data_only=False, _preload_content=True, _request_timeout=None, ): <NEW_LINE> <INDENT> kwargs = dict( authorization=a... | Retrieves audit objects.
Args:
references (list[FixedReference], optional):
A list of references to query for. Overrides ids and names keyword arguments.
x_request_id (str, optional):
A header to provide to track the API call. Generated by the server if not
provided.
continuation_t... | 625941e16aa9bd52df03713b |
def reverse(self, x): <NEW_LINE> <INDENT> n = x if x > 0 else -x <NEW_LINE> res = 0 <NEW_LINE> while n: <NEW_LINE> <INDENT> res = res * 10 + n % 10 <NEW_LINE> n = n / 10 <NEW_LINE> <DEDENT> if res > 0x7fffffff: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> return res if x > 0 else -res | :type x: int
:rtype: int | 625941e1851cf427c661a8a1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.