code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def add_item (request): <NEW_LINE> <INDENT> if is_user (request): redirect ('/') <NEW_LINE> if request.POST: <NEW_LINE> <INDENT> form = ItemsAppForm (request.POST) <NEW_LINE> if form.is_valid (): form.save () <NEW_LINE> return redirect ('/menu/set_item') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> page = 'menu/add_it... | Добавляет новой действие приложения | 625941d007f4c71912b115e9 |
def create_finder(opts=None): <NEW_LINE> <INDENT> if not opts: <NEW_LINE> <INDENT> opts = DEF_OPTS <NEW_LINE> <DEDENT> finder = Finder(opts, cache=dummy_cache) <NEW_LINE> finder.debug = True <NEW_LINE> finder.mount_volumes() <NEW_LINE> return finder | Creates finder instance for tests and mounts all volumes. | 625941d0cb5e8a47e48b7c0f |
def _next_batch_3d(self, batch_size, reconstruct=False): <NEW_LINE> <INDENT> sx, sy, sz = self._size <NEW_LINE> x, y, z = self._shape <NEW_LINE> batch = np.zeros((batch_size, self.patch_size), dtype=self.image.dtype) <NEW_LINE> indices = [] <NEW_LINE> s = 0 <NEW_LINE> kk = 0 <NEW_LINE> for i in range(0, x - sx + 1, sel... | Creates 3d patches iteratively, keep only batch_size
patches in memory | 625941d0d53ae8145f87a3d5 |
def stop(self): <NEW_LINE> <INDENT> self._active = False <NEW_LINE> try: <NEW_LINE> <INDENT> self._event_queue.put(False) <NEW_LINE> self._action_queue.put(False) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> pass | Terminates the state machine. | 625941d00c0af96317bb834e |
def _update_action(self): <NEW_LINE> <INDENT> name = self.undo_manager.redo_name <NEW_LINE> if name: <NEW_LINE> <INDENT> name = "&Redo " + name <NEW_LINE> self.enabled = True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> name = "&Redo" <NEW_LINE> self.enabled = False <NEW_LINE> <DEDENT> self.name = name | Update the state of the action. | 625941d0f8510a7c17cf9862 |
def untag_resource(ResourceArn=None, TagKeys=None): <NEW_LINE> <INDENT> pass | Deletes specified tags from a resource.
See also: AWS API Documentation
Exceptions
:example: response = client.untag_resource(
ResourceArn='string',
TagKeys=[
'string',
]
)
:type ResourceArn: string
:param ResourceArn: [REQUIRED] The Am... | 625941d03539df3088e2e4b1 |
def insert_segment( self, start_freq, stop_freq, *, points, ifbw, power, time="AUTO", lo_sideband="AUTO", if_selectivity="NORMal", analog_sweep=False, position=1 ): <NEW_LINE> <INDENT> if analog_sweep: <NEW_LINE> <INDENT> sweep_mode = "ANALog" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> sweep_mode = "STEPped" <NEW_LI... | :param float start_freq: Segment start frequency in Hz
:param float stop_freq: Segment stop frequency in Hz
:param int points: Number of sweep points in the segment
:param float ifbw: IF bandwidth
:param float power: Segment source power in dBm
:param float time: Segment sweep time or segment dwell time in seconds
:par... | 625941d0d268445f265b4fd4 |
def test_setitem_keycheck(self): <NEW_LINE> <INDENT> od = odict() <NEW_LINE> self.assertTrue(od._setitem_keycheck(1)) <NEW_LINE> od[1] = 'a' <NEW_LINE> self.assertFalse(od._setitem_keycheck(1)) | True if key is not in _keys, False otherwise | 625941d06e29344779a62778 |
def continue_the_process(self, lib_num_obj_pair_list, user, lib_sequence_list): <NEW_LINE> <INDENT> continue_or_not = input('Do you want to add user to another library? Enter Y or N: ') <NEW_LINE> if continue_or_not.upper() == 'Y': <NEW_LINE> <INDENT> self.assign_user_to_library(lib_num_obj_pair_list, user, lib_sequenc... | Method to continue the process if user wants to allocate user object to another libraries. | 625941d0d6c5a102081441b1 |
def resto_rel_leq(self, result: Result) -> Result: <NEW_LINE> <INDENT> result = self._empty(result) <NEW_LINE> return self._oper(result, '<=', resto=True) | <restoRel> -> '<=' <add> | 625941d01d351010ab855c82 |
def FindRendererForObject(rdf_obj): <NEW_LINE> <INDENT> from grr.gui.plugins import semantic <NEW_LINE> return semantic.FindRendererForObject(rdf_obj) | A proxy method for semantic.FindRendererForObject. | 625941d04a966d76dd551176 |
def test_face3d_to_from_dict(): <NEW_LINE> <INDENT> pts = (Point3D(0, 0, 2), Point3D(0, 2, 2), Point3D(2, 2, 2), Point3D(2, 0, 2)) <NEW_LINE> plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2)) <NEW_LINE> face = Face3D(pts, plane) <NEW_LINE> face_dict = face.to_dict() <NEW_LINE> new_face = Face3D.from_dict(face_dict) <N... | Test the to/from dict of Face3D objects. | 625941d08a349b6b435e82da |
def loadMusic(self, *args, **kw): <NEW_LINE> <INDENT> if self.base.musicManager: <NEW_LINE> <INDENT> return self.loadSound(self.base.musicManager, *args, **kw) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None | Loads one or more sound files, specifically designated as a
"music" file (that is, uses the musicManager to load the
sound). There is no distinction between sound effect files
and music files other than the particular `AudioManager` used
to load the sound file, but this distinction allows the sound
effects and/or the ... | 625941d0aad79263cf390ba8 |
def coadd_mbobs(mbobs): <NEW_LINE> <INDENT> wsum = 0.0 <NEW_LINE> meta = {} <NEW_LINE> for i, obslist in enumerate(mbobs): <NEW_LINE> <INDENT> obs = obslist[0] <NEW_LINE> meta.update(obs.meta) <NEW_LINE> shape = obs.image.shape <NEW_LINE> if i == 0: <NEW_LINE> <INDENT> coadd_image = np.zeros(shape, dtype='f4') <NEW_LIN... | coadd a set of exposures, assuming they share the same wcs
Parameters
----------
exposures: [lsst.afw.image.Exposure]
List of exposures to coadd
Returns
--------
lsst.afw.image.ExposureF | 625941d0cc40096d61595ab6 |
def get_name(self): <NEW_LINE> <INDENT> return self.name | Get the citizen's name.
:return: name | 625941d063b5f9789fde724c |
@task <NEW_LINE> @hosts('localhost') <NEW_LINE> def copy_json(): <NEW_LINE> <INDENT> sourcePath = 'contents/external/' <NEW_LINE> targetPath = 'build/external/' <NEW_LINE> for base,subdirs,files in os.walk(sourcePath): <NEW_LINE> <INDENT> for file in files: <NEW_LINE> <INDENT> orig = os.path.join(base, file) <NEW_LINE>... | Copy json files under external | 625941d0be7bc26dc91cd765 |
def __init__(self, content, validate = False, document = None): <NEW_LINE> <INDENT> super(RouterStatusEntry, self).__init__(content, lazy_load = not validate) <NEW_LINE> self.document = document <NEW_LINE> entries = _get_descriptor_components(content, validate) <NEW_LINE> if validate: <NEW_LINE> <INDENT> for keyword in... | Parse a router descriptor in a network status document.
:param str content: router descriptor content to be parsed
:param NetworkStatusDocument document: document this descriptor came from
:param bool validate: checks the validity of the content if **True**, skips
these checks otherwise
:raises: **ValueError** if t... | 625941d0ac7a0e7691ed4232 |
def set_Date(self, value): <NEW_LINE> <INDENT> InputSet._set_input(self, 'Date', value) | Set the value of the Date input for this Choreo. ((optional, date) The date of the fuel purchase in YYYY-MM-DD format.) | 625941d0851cf427c661a674 |
def write(self, sock): <NEW_LINE> <INDENT> self.paddingLength = -self.contentLength & 7 <NEW_LINE> header = struct.pack(FCGI_Header, self.version, self.type, self.requestId, self.contentLength, self.paddingLength) <NEW_LINE> self._sendall(sock, header) <NEW_LINE> if self.contentLength: <NEW_LINE> <INDENT> self._sendall... | Encode and write a Record to a socket. | 625941d03346ee7daa2b2ed2 |
def compute_tree(self, tree): <NEW_LINE> <INDENT> g_list_val, g_list_h = self._build_graph(tree) <NEW_LINE> list_val = self._traversal_tree(tree) <NEW_LINE> f = theano.function(g_list_val, g_list_h, allow_input_downcast=True) <NEW_LINE> result = f(*list_val) <NEW_LINE> return result | Compute h for whole tree.
Traversal left, right, cur_node
:param tree: root node
:return: a list of h for each node | 625941d0596a897236089c26 |
def hangerfunc(x, *p): <NEW_LINE> <INDENT> f0, Qi, Qc, df, scale = p <NEW_LINE> a = (x - (f0 + df)) / (f0 + df) <NEW_LINE> b = 2 * df / f0 <NEW_LINE> Q0 = 1. / (1. / Qi + 1. / Qc) <NEW_LINE> return scale * (-2. * Q0 * Qc + Qc ** 2. + Q0 ** 2. * (1. + Qc ** 2. * (2. * a + b) ** 2.)) / ( Qc ** 2 * (1. + 4. * Q0 ** 2. * a... | Hanger function
:param p: [f0, Qi, Qc, df, scale]
:param x: Frequency points
:return: scale*(-2.*Q0*Qc + Qc**2. + Q0**2.*(1. + Qc**2.*(2.*a + b)**2.))/(Qc**2*(1. + 4.*Q0**2.*a**2.)) | 625941d02eb69b55b151ca16 |
def set_shape(self, width, height): <NEW_LINE> <INDENT> if width != self.width or height != self.height: <NEW_LINE> <INDENT> path = QPainterPath() <NEW_LINE> path.addEllipse(0, height / 2, width / 4, height / 2) <NEW_LINE> path.moveTo(width / 4, height * 3 / 4) <NEW_LINE> path.lineTo(width / 2, height * 3 / 4) <NEW_LIN... | Define the shape of the LABEL symbol | 625941d07b180e01f3dc4963 |
def on_show_prefs(self): <NEW_LINE> <INDENT> client.yarss2.get_config().addCallback(self.cb_get_config) | Called when showing preferences window | 625941d05fc7496912cc3ae4 |
def set_tag(tag): <NEW_LINE> <INDENT> print(script_tag + "Setting the Ardublockly package tag to '%s'" % tag) <NEW_LINE> global copy_dir_name <NEW_LINE> global copied_project_dir <NEW_LINE> copy_dir_name = "ardublockly_%s" % tag <NEW_LINE> if platform.system() == "Darwin": <NEW_LINE> <INDENT> copy_dir_name = os.path.jo... | Sets the packaged zip file and copied folder tag to the input argument. So,
the copied folder will be names "ardublockly_<tag>" and the zip file
"ardublockly_<tag>.zip.
If Mac OS X the folder is packed in ardublockly_tag.app/Contents
:tag: String to indicate the tag to use. | 625941d015fb5d323cde0c77 |
def version_cmp(pkg1, pkg2, ignore_epoch=False): <NEW_LINE> <INDENT> del ignore_epoch <NEW_LINE> sym = { '<': -1, '>': 1, '=': 0, } <NEW_LINE> try: <NEW_LINE> <INDENT> cmd = ['pkg', 'version', '--test-version', pkg1, pkg2] <NEW_LINE> ret = __salt__['cmd.run_all'](cmd, output_loglevel='trace', python_shell=False, ignore... | Do a cmp-style comparison on two packages. Return -1 if pkg1 < pkg2, 0 if
pkg1 == pkg2, and 1 if pkg1 > pkg2. Return None if there was a problem
making the comparison.
CLI Example:
.. code-block:: bash
salt '*' pkg.version_cmp '2.1.11' '2.1.12' | 625941d0596a897236089c27 |
def worker(input, output): <NEW_LINE> <INDENT> for args in iter(input.get, 'STOP'): <NEW_LINE> <INDENT> result = generate_list(*args) <NEW_LINE> output.put( (result, current_process().name, args) ) | input is a queue with seed values
output is a queue storing the results of the tasks along with the process name,
and which args the result is for. | 625941d076d4e153a657ec98 |
def get_title(til_file): <NEW_LINE> <INDENT> with open(til_file) as _file: <NEW_LINE> <INDENT> for line in _file: <NEW_LINE> <INDENT> line = line.strip() <NEW_LINE> if line.startswith('#'): <NEW_LINE> <INDENT> return line[1:].lstrip() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None | Read the file until we hit the first line that starts with a #
indicating a title in markdown. We'll use that as the title for this
entry. | 625941d0ab23a570cc2502e9 |
def sanity_check_step(self): <NEW_LINE> <INDENT> custom_paths = { 'files': ['crispr.pl'], 'dirs': ['Modules', 'Examples', 'Rscripts'], } <NEW_LINE> example_dir = os.path.join(self.installdir, 'Examples', 'example1') <NEW_LINE> outfile = os.path.join(self.builddir, 'test.out') <NEW_LINE> example_cmd = ' '.join([ os.path... | Custom sanity check paths for CRISPR-DAV | 625941d055399d3f0558881b |
def _disable_cluster_asg(cluster, asg): <NEW_LINE> <INDENT> disable_asg(asg) <NEW_LINE> _move_asg_from_enabled_to_disabled(cluster, asg) | Shifts ASG from enabled to disabled. | 625941d021a7993f00bc7e57 |
def generate_fake_facility_users(nusers=20, facilities=None, facility_groups=None, password="hellothere"): <NEW_LINE> <INDENT> if not facility_groups: <NEW_LINE> <INDENT> (facility_groups, facilities) = generate_fake_facility_groups(facilities=facilities) <NEW_LINE> <DEDENT> facility_users = [] <NEW_LINE> cur_usernum =... | Add the given fake facility users to each of the given fake facilities.
If no facilities are given, they are created. | 625941d01b99ca400220ac18 |
def isValid(self, model): <NEW_LINE> <INDENT> if not model.Type == '#model': <NEW_LINE> <INDENT> log('Guide is not of type "model"', c.siError) <NEW_LINE> return False <NEW_LINE> <DEDENT> self.settingsProperty = self.model.Properties('Settings') <NEW_LINE> if not self.settingsProperty: <NEW_LINE> <INDENT> log('Guide mi... | Check that required elements of model exist. | 625941d04f6381625f114ba2 |
def __init__(self): <NEW_LINE> <INDENT> self.swaggerTypes = { 'KubeProxyVersion': 'str', 'bootID': 'str', 'containerRuntimeVersion': 'str', 'kernelVersion': 'str', 'kubeletVersion': 'str', 'machineID': 'str', 'osImage': 'str', 'systemUUID': 'str' } <NEW_LINE> self.attributeMap = { 'KubeProxyVersion': 'KubeProxyVersion'... | Attributes:
swaggerTypes (dict): The key is attribute name and the value is attribute type.
attributeMap (dict): The key is attribute name and the value is json key in definition. | 625941d0a934411ee37517fa |
def test_maximum_journeys_with_min_nb_journeys_options(self): <NEW_LINE> <INDENT> query = "journeys?from=2.39592;48.84838&to=2.36381;48.86750&datetime=20180309T080000&min_nb_journeys=7" <NEW_LINE> response = self.query_region(query) <NEW_LINE> self.is_valid_journey_response(response, query) <NEW_LINE> assert len(respon... | The data contains only 6 journeys but we want 7 journeys.
The response has to contain only 6 journeys.
Note : The night bus filter is loaded with default parameters.
With this data, night bus filter parameters doesn't filter anything. | 625941d0236d856c2ad44942 |
def use_numpy(): <NEW_LINE> <INDENT> globals_import_from('numpy', 'degrees', 'degrees') <NEW_LINE> globals_import_from('numpy', 'cos', 'cos') <NEW_LINE> globals_import_from('numpy', 'sin', 'sin') <NEW_LINE> globals_import_from('numpy', 'radians', 'radians') <NEW_LINE> globals_import_from('numpy', 'tan', 'tan') <NEW_LIN... | Import required functions/constants from numpy | 625941d0ad47b63b2c50a0e6 |
def __colorFcn__(self, input): <NEW_LINE> <INDENT> return None | Creates colors from the input data
Parameters
----------
input : Data object
the input data
Returns
-------
Tensor
the color tensor | 625941d0bf627c535bc13336 |
def __mul__(self, rhs): <NEW_LINE> <INDENT> if type(rhs) is int: <NEW_LINE> <INDENT> return [[x * rhs for x in row] for row in self._container] <NEW_LINE> <DEDENT> elif type(rhs) is Matrix: <NEW_LINE> <INDENT> return self._multiply(rhs) <NEW_LINE> <DEDENT> raise ValueError("A Matrix can only be multiplied by a Matrix o... | Method overrides the "*" operator
Arguments:
rhs {Matrix or Integer} -- the matrix or integer to multiply by
Raises:
ValueError -- The other object must be a matrix or an integer
Returns:
Matrix -- The resulting matrix | 625941d085dfad0860c3afc2 |
def buildDictionaries(position): <NEW_LINE> <INDENT> ahead = {} <NEW_LINE> behind = {} <NEW_LINE> position_tuples = [(j,position[j]) for j in range(len(position))] <NEW_LINE> sorted_position = sorted(position_tuples, key = itemgetter(1)) <NEW_LINE> for i in range(len(sorted_position)): <NEW_LINE> <INDENT> ahead[sorted_... | Takes in a list of positions for players i=0 to i=N-1
Returns: the ahead and behind dictionaries (ahead, behind).
Runs in O(nlgn) time | 625941d06fb2d068a760f205 |
def test_alan_method_a_semicolon(self): <NEW_LINE> <INDENT> parser = AlanMethodParser() <NEW_LINE> populate() <NEW_LINE> grammar = Rule.objects.order_by('id') <NEW_LINE> grammar_list = [] <NEW_LINE> grammar_list.append({'id': 0, 'left': '', 'right': ''}) <NEW_LINE> for g in grammar: <NEW_LINE> <INDENT> grammar_list.app... | Testing of code: a;, which is a syntax error | 625941d0a8ecb033257d3234 |
def write_all_files(num_files: int, num_attempts: int = 10) -> int: <NEW_LINE> <INDENT> file_refs = [ make_file_ref(file_name=f"file{f:03d}", root_dir="write_output") for f in range(0, num_files) ] <NEW_LINE> if ray.is_initialized(): <NEW_LINE> <INDENT> results = ray.get( [ r_write_file.remote( fr, SerializableExample(... | Returns the number of failures. | 625941d03617ad0b5ed6805e |
def review_statistics( self, ids=None, subject_ids=None, subject_types=None, updated_after=None, percentages_greater_than=None, percentages_less_than=None, hidden=None, fetch_all=False, ): <NEW_LINE> <INDENT> response = requests.get( self.url_builder.build_wk_url( constants.REVIEW_STATS_ENDPOINT, parameters=locals() ),... | Retrieve all Review Statistics from Wanikani. A Review Statistic is related to a single subject which the user has studied.
:param bool fetch_all: if set to True, instead of fetching only first page of results, will fetch them all.
:param int[] ids: Return only results with the given IDs
:param int[] subject_ids: Retu... | 625941d09b70327d1c4e0f3c |
def distributions_and_v1_optimizers(): <NEW_LINE> <INDENT> return combine( distribution=[ one_device_strategy, mirrored_strategy_with_gpu_and_cpu, mirrored_strategy_with_two_gpus ], optimizer_fn=[adam_optimizer_v1_fn, gradient_descent_optimizer_v1_fn]) | A common set of combination with DistributionStrategies and Optimizers. | 625941d099cbb53fe6792d4d |
def retrieve_form_data(self, lodur_id): <NEW_LINE> <INDENT> self.login() <NEW_LINE> self.browser.open( "{}?modul=36&what=144&event={}&edit=1".format(self.url, lodur_id) ) <NEW_LINE> json_string = None <NEW_LINE> all_scripts = self.browser.page.find_all("script", type="text/javascript") <NEW_LINE> for script in all_scri... | Retrieve all fields from an Einsatzrapport in Lodur | 625941d02c8b7c6e89b35927 |
def set_capital(self, capital: bool): <NEW_LINE> <INDENT> self.capital = capital | Set capital letters. | 625941d0d164cc6175782eb5 |
def read_current_energy(self): <NEW_LINE> <INDENT> self.request_current_energy() <NEW_LINE> self.read_answer() <NEW_LINE> self.process_data_current_energy() | Последовательный вызов функций для чтения текущих показаний со счетчика.
:return: | 625941d0f548e778e58cd6e5 |
def __del__(self): <NEW_LINE> <INDENT> result = nsl._nova.ssp_lrtdp_uninitialize(self.mdpPtr, self) <NEW_LINE> if result != 0: <NEW_LINE> <INDENT> print("Failed to free the LRTDP (CPU) algorithm.") <NEW_LINE> raise Exception() | The deconstructor for the SSPLRTDP class which automatically frees memory. | 625941d06aa9bd52df036f0c |
def main(): <NEW_LINE> <INDENT> exch_account = { 'okex': ['Kevin.wang@126.com', 'thetrading'], 'bina': ['Kevin.wang@126.com'], 'huobi': ['Kevin.wang@126.com'], } <NEW_LINE> all3exchanges = {} <NEW_LINE> for exch in exch_account: <NEW_LINE> <INDENT> if exch == 'okex': <NEW_LINE> <INDENT> for i, acc in enumerate(exch_acc... | 整合以上三个类的数据
| 625941d030bbd722463cbf2d |
def isRunning(self): <NEW_LINE> <INDENT> return not self._is_finished | Return whether the parameterising protocol is still running. | 625941d07b25080760e395c0 |
def write_issues(r, csvout): <NEW_LINE> <INDENT> if r.status_code != 200: <NEW_LINE> <INDENT> raise Exception(r.status_code) <NEW_LINE> <DEDENT> for issue in r.json(): <NEW_LINE> <INDENT> if 'pull_request' not in issue: <NEW_LINE> <INDENT> labels = ', '.join([l['name'] for l in issue['labels']]) <NEW_LINE> date = issue... | Parses JSON response and writes to CSV. | 625941d082261d6c526ab607 |
def __init__(self, name="elasticityexplicittri3"): <NEW_LINE> <INDENT> IntegratorElasticity.__init__(self, name) <NEW_LINE> ModuleElasticityExplicitTri3.__init__(self) <NEW_LINE> self._loggingPrefix = "ElEx " <NEW_LINE> return | Constructor. | 625941d0f7d966606f6aa16c |
def unmask(self, data): <NEW_LINE> <INDENT> n_in_mask_voxels = len(self.in_mask[0]) <NEW_LINE> if data.ndim == 2: <NEW_LINE> <INDENT> n_volumes = data.shape[1] <NEW_LINE> assert(len(data) == n_in_mask_voxels) <NEW_LINE> assert(self.full.ndim == 1) <NEW_LINE> img = np.zeros(self.full.shape + (n_volumes,)) <NEW_LINE> img... | Reconstruct a masked vector into the original 3D volume. | 625941d050485f2cf553cf01 |
def compute_density(self,T=300,p=101325): <NEW_LINE> <INDENT> return p/(self.gas_specific_constant*T) | Computes air density given temperature and pressure
Assumptions:
Ideal gas
Source:
Common equation
Inputs:
T [K] - Temperature
p [Pa] - Pressure
Outputs:
density [kg/m^3]
Properties Used:
self.gas_specific_constant | 625941d056b00c62f0f147c1 |
def create_decoder(self, helper, mode): <NEW_LINE> <INDENT> raise NotImplementedError | Creates the decoder module.
This must be implemented by child classes and instantiate the appropriate
decoder to be tested. | 625941d024f1403a92600ccc |
def test_topo_sort_knows_what_cycles_are(self): <NEW_LINE> <INDENT> d = DepGraph() <NEW_LINE> d.add_edge('a', 'b') <NEW_LINE> d.add_edge('b', 'c') <NEW_LINE> d.add_edge('c', 'a') <NEW_LINE> self.assertRaises(HasACycle, d.topo_sort) <NEW_LINE> assert not d.acyclic | Test that topo_sort fails on cyclic graphs. | 625941d0a219f33f34628ad0 |
def _init_externals(): <NEW_LINE> <INDENT> if __version__ == '2.1.11': <NEW_LINE> <INDENT> sys.path.insert(0, osp.join(osp.dirname(__file__), 'ext', 'gitdb')) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> import gitdb <NEW_LINE> <DEDENT> except ImportError: <NEW_LINE> <INDENT> raise ImportError("'gitdb' could not be fou... | Initialize external projects by putting them into the path | 625941d07d43ff24873a2e08 |
def test_get_resources_max_duration_non_numerical(self): <NEW_LINE> <INDENT> print('(' + self.test_get_resources_max_duration_non_numerical.__name__ + ')', self.test_get_resources_max_duration_non_numerical.__doc__) <NEW_LINE> resources = self.connection.get_resources(max_length='zero') <NEW_LINE> self.assertIsNone(res... | Test get_resources with a maximum required time set to non numerical value | 625941d044b2445a339321fd |
def mac_straddr(mac, printable=False, delimiter=None): <NEW_LINE> <INDENT> if len(mac) != 2: <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> if printable: <NEW_LINE> <INDENT> if delimiter: <NEW_LINE> <INDENT> m = "" <NEW_LINE> for c in mac_straddr(mac): <NEW_LINE> <INDENT> m += "%02x" % c + delimiter <NEW_LINE> <DEDE... | Convert c_ulong*2 to a hexadecimal string or a printable ascii
string delimited by the 3rd parameter
Expect a list of length 2 returned by arp_query | 625941d09f2886367277a9f4 |
def tolist(self): <NEW_LINE> <INDENT> return [x for x in self.data] | Returns the values as a list | 625941d0283ffb24f3c55a68 |
def fle_op(config: Configuration) -> None: <NEW_LINE> <INDENT> b, a = config.pop2_f64() <NEW_LINE> if config.enable_logic_fn_logging: <NEW_LINE> <INDENT> logger.debug("%s(%s, %s)", config.current_instruction.opcode.text, a, b) <NEW_LINE> <DEDENT> if numpy.isnan(a) or numpy.isnan(b): <NEW_LINE> <INDENT> config.push_oper... | Common logic function for the float LE opcodes | 625941d0d486a94d0b98e2ad |
def read_gene_info_file(lineCount=False,short=False): <NEW_LINE> <INDENT> config = Configure() <NEW_LINE> taxaList = config.log['taxa'] <NEW_LINE> geneInfoFile = os.path.join(config.log['data'],"gene_info.db") <NEW_LINE> geneInfoFid = open(geneInfoFile,'rU') <NEW_LINE> header = geneInfoFid.__next__() <NEW_LINE> geneInf... | read the essential info from NCBI's gene info file | 625941d0d268445f265b4fd5 |
@project.command() <NEW_LINE> @click.option('--name', '-n', help='Project name', prompt=True) <NEW_LINE> def delete(name): <NEW_LINE> <INDENT> headers = {'session_id': session_id()} <NEW_LINE> url = api_root + 'projects/%s/delete' % name <NEW_LINE> with click_spinner.spinner(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDE... | Delete project | 625941d0460517430c3942eb |
def configure(self): <NEW_LINE> <INDENT> self.resolve_virtual_columns(*tuple(self.missing_columns)) <NEW_LINE> self.config = self.normalize_config(self._meta.__dict__, self.query_config) <NEW_LINE> self.config['column_searches'] = {} <NEW_LINE> for i, name in enumerate(self.columns.keys()): <NEW_LINE> <INDENT> column_s... | Combines (in order) the declared/inherited inner Meta, any view options, and finally any
valid AJAX GET parameters from client modifications to the data they see. | 625941d08e7ae83300e4b134 |
def __init__ (self, descr) : <NEW_LINE> <INDENT> tid = ru.generate_id ('r.') <NEW_LINE> if not 'head' in descr : <NEW_LINE> <INDENT> raise ValueError ("no 'head' in RelationDescription") <NEW_LINE> <DEDENT> if not 'tail' in descr : <NEW_LINE> <INDENT> raise ValueError ("no 'tail' in RelationDescription") <NEW_LINE>... | Create a new workload dependency element, aka Relation, according to
the description..
Each new relation is assigned a new ID.
Later implementations may allow for an additional id parameter, to
reconnect to the thus identified relation instance. | 625941d063d6d428bbe44657 |
def mergeTwoLists(self, l1, l2): <NEW_LINE> <INDENT> dummy = ListNode(sys.maxint) <NEW_LINE> p = dummy <NEW_LINE> while l1 and l2: <NEW_LINE> <INDENT> if l1.val < l2.val: <NEW_LINE> <INDENT> p.next = l1 <NEW_LINE> l1 = l1.next <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> p.next = l2 <NEW_LINE> l2 = l2.next <NEW_LINE> ... | :type l1: ListNode
:type l2: ListNode
:rtype: ListNode | 625941d063f4b57ef0001280 |
@hypothesis.settings(suppress_health_check=[hypothesis.HealthCheck(3)]) <NEW_LINE> @given(table1=table_strategy, table2=table_strategy) <NEW_LINE> @mock.patch(MODULE_TO_TEST + ".spreadsheet._get_spreadsheet_with_values") <NEW_LINE> def test_spreadsheet_retrieve_spreadsheet_with_given(mock_spreadsheet_get, table1, table... | Gets a Spreadsheet from a spreadsheet id. | 625941d0b5575c28eb68e168 |
def blink(): <NEW_LINE> <INDENT> return _effects["blink"] | Return the ANSI sequence for blinking text
| 625941d02c8b7c6e89b35928 |
def __init__(self, person: Person): <NEW_LINE> <INDENT> super().__init__(person) | Create a job sub-builder for the specified `person`. | 625941d0de87d2750b85fefa |
def fields(self, encoding='utf-8') -> Awaitable[List]: <NEW_LINE> <INDENT> return self.get_connection().hkeys(self._key, encoding=encoding) | Gets all the fields in the hash map.
Args:
encoding (str, optional): The encoding to use for decoding the field keys. Defaults to
'utf-8'.
Returns:
Awaitable[List]: The set of fields in the hash map. | 625941d045492302aab5e42b |
def orderindividuals(popdict, indexes, poporderfile): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> with open(poporderfile, 'r') as infile: <NEW_LINE> <INDENT> poporderlist = [l.strip() for l in infile if len(l.strip()) > 0 and not l.startswith('#')] <NEW_LINE> <DEDENT> <DEDENT> except IOError: <NEW_LINE> <INDENT> print... | takes populations, indexes of inds and desired order of pops, returns list of indexes of individuals | 625941d0507cdc57c6306e43 |
def is_joint_moving(self, joint_id): <NEW_LINE> <INDENT> return self._joints[joint_id].is_moving() | Tells if a given joint is still moving or not.
Parameters:
joint (str):
the key of the joint
Raises:
KeyError if joint does not exist | 625941d0004d5f362079a49a |
def __init__(self, parent=QModelIndex()): <NEW_LINE> <INDENT> super(WorkflowWrapper, self).__init__() <NEW_LINE> self._pathnames = [] <NEW_LINE> self._workm = None <NEW_LINE> self._settings_changed = False <NEW_LINE> self._when_done_import = None | Create a new :class:`WorkflowWrapper` instance. | 625941d0f8510a7c17cf9863 |
def preprocess_image_eval(image, label, height, width, is_training=False, bbox=None, fast_mode=True): <NEW_LINE> <INDENT> if is_training: <NEW_LINE> <INDENT> return preprocess_for_train(image, label, height, width, bbox, fast_mode) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return preprocess_for_eval(image, label, h... | Pre-process one image for training or evaluation.
Args:
image: 3-D Tensor [height, width, channels] with the image.
height: integer, image expected height.
width: integer, image expected width.
is_training: Boolean. If true it would transform an image for train,
otherwise it would transform it for evaluati... | 625941d04f88993c3716c1ce |
@composite <NEW_LINE> def mutable_seq_typed_attrs( draw, defaults=None, allow_mutable_defaults=True, legacy_types_only=False ): <NEW_LINE> <INDENT> default_val = attr.NOTHING <NEW_LINE> val_strat = lists(floats(allow_infinity=False, allow_nan=False)) <NEW_LINE> if defaults is True or (defaults is None and draw(booleans... | Generate a tuple of an attribute and a strategy that yields lists
for that attribute. The lists contain floats. | 625941d050812a4eaa59c489 |
def get_genres(file_name): <NEW_LINE> <INDENT> content = open_file(file_name) <NEW_LINE> genre_index = 3 <NEW_LINE> genres = list(set([game[genre_index] for game in content])) <NEW_LINE> genres = quick_sort(genres) <NEW_LINE> print("Genre list: {0}".format(genres)) <NEW_LINE> return genres | Return and print sorted genre list without duplicates | 625941d015fb5d323cde0c78 |
def get_integrations_by_ids_using_get_with_http_info(self, integration_ids, **kwargs): <NEW_LINE> <INDENT> all_params = ['integration_ids'] <NEW_LINE> all_params.append('async_req') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> all_params.append('_preload_content') <NEW_LINE> all_params.append('_req... | Get Integrations By Ids (getIntegrationsByIds) # noqa: E501
Requested integrations must be owned by tenant which is performing the request. Security check is performed to verify that the user has 'READ' permission for the entity (entities). # noqa: E501
This method makes a synchronous HTTP request by default. To ... | 625941d029b78933be1e5813 |
def l_constraint(model,name,constraints,*args): <NEW_LINE> <INDENT> setattr(model,name,Constraint(*args,noruleinit=True)) <NEW_LINE> v = getattr(model,name) <NEW_LINE> for i in v._index: <NEW_LINE> <INDENT> c = constraints[i] <NEW_LINE> if isinstance(c, LConstraint): <NEW_LINE> <INDENT> variables = c.lhs.variables + [(... | A replacement for pyomo's Constraint that quickly builds linear
constraints.
Instead of
model.name = Constraint(index1,index2,...,rule=f)
call instead
l_constraint(model,name,constraints,index1,index2,...)
where constraints is a dictionary of constraints of the form:
constraints[i] = LConstraint object
OR using ... | 625941d007f4c71912b115eb |
def _init(self, **kwds): <NEW_LINE> <INDENT> name = kwds.get('name') <NEW_LINE> if name and 'name' not in self.data: <NEW_LINE> <INDENT> self.set_name(name) <NEW_LINE> <DEDENT> self.personID = kwds.get('personID', None) <NEW_LINE> self.myName = kwds.get('myName', '') <NEW_LINE> self.billingPos = kwds.get('billingPos', ... | Initialize a Person object.
*personID* -- the unique identifier for the person.
*name* -- the name of the Person, if not in the data dictionary.
*myName* -- the nickname you use for this person.
*myID* -- your personal id for this person.
*data* -- a dictionary used to initialize the object.
*currentRole* -- a Charact... | 625941d0099cdd3c635f0dc3 |
def update(self, epoch=None, train_steps=None): <NEW_LINE> <INDENT> if self.regime is None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> epoch = -1 if epoch is None else epoch <NEW_LINE> train_steps = -1 if train_steps is None else train_steps <NEW_LINE> setting = deepcopy(self.setting) <NEW_LINE> if self.curre... | adjusts according to current epoch or steps and regime.
| 625941d0cb5e8a47e48b7c11 |
def create_settings_hook(cls): <NEW_LINE> <INDENT> def load_item_hook(self, key, value): <NEW_LINE> <INDENT> if key.startswith('hook_test'): <NEW_LINE> <INDENT> return key, value[1:] <NEW_LINE> <DEDENT> <DEDENT> def save_item_hook(self, key, value): <NEW_LINE> <INDENT> if key.startswith('hook_test'): <NEW_LINE> <INDENT... | Create a *Settings_Hook class to use with tests.
It will have the proper name, dynamically created. | 625941d00a366e3fb873e983 |
def movingCount1(self, m: int, n: int, k: int) -> int: <NEW_LINE> <INDENT> return 0 | 深度优先——非递归实现
:param m:
:param n:
:param k:
:return: | 625941d01b99ca400220ac19 |
@app.route("/restaurants/new/", methods=["GET", "POST"]) <NEW_LINE> def new_restaurant(): <NEW_LINE> <INDENT> if request.method == "GET": <NEW_LINE> <INDENT> return render_template("new_restaurant.html") <NEW_LINE> <DEDENT> restaurant = Restaurant(name=request.form.get("name")) <NEW_LINE> session.add(restaurant) <NEW_L... | Route handler for creating a new restaurant.
Returns:
An html template with a form to create a new restaurant | 625941d0a79ad161976cc2ad |
def add(n): <NEW_LINE> <INDENT> return n + 1 | Add 1. | 625941d0e64d504609d749a8 |
def report_exception(e, editor=True): <NEW_LINE> <INDENT> import codecs <NEW_LINE> type, _value, tb = sys.exc_info() <NEW_LINE> simple = io.StringIO() <NEW_LINE> full = io.StringIO() <NEW_LINE> full_tl = traceback_list(tb) <NEW_LINE> simple_tl = filter_traceback_list(full_tl) <NEW_LINE> print(str(renpy.game.exception_i... | Reports an exception by writing it to standard error and
traceback.txt. If `editor` is True, opens the traceback
up in a text editor.
Returns a three-item tuple, with the first item being
a simplified traceback, the second being a full traceback,
and the third being the traceback filename, | 625941d09f2886367277a9f5 |
def to_categorical(label_list): <NEW_LINE> <INDENT> labels_set = sorted( list(set([x for sublist in label_list for x in sublist]))) <NEW_LINE> labels_dict = {k: v for v, k in enumerate(labels_set)} <NEW_LINE> print(labels_dict) <NEW_LINE> return_list = [] <NEW_LINE> for list_ in label_list: <NEW_LINE> <INDENT> categori... | Given a label list, ex: [train_labels, val_labels], returns the categorical int values to Tensor.
:param label_list: list of lists of categorical (strings) labels
:return: list of lists of categorical (int to Tensor) labels
:return: number of different labels | 625941d0fff4ab517eb2f5a4 |
def clean_lagou_company_data(company_dict): <NEW_LINE> <INDENT> if 'size' in company_dict: <NEW_LINE> <INDENT> company_dict.size = company_dict.size.strip() <NEW_LINE> <DEDENT> if 'finance_stage' in company_dict: <NEW_LINE> <INDENT> company_dict.finance_stage = company_dict.finance_stage.strip() <NEW_LINE> <DEDENT> if ... | 清洗爬取到的拉勾公司信息
:param company_dict: tornado.util.ObjectDict | 625941d0e1aae11d1e749e1f |
def __addContinuousNode(self, u, times=[], color=0, linetype=None): <NEW_LINE> <INDENT> if color in self._colors: <NEW_LINE> <INDENT> color = self._colors[color] <NEW_LINE> <DEDENT> if self._node_cpt == 1: <NEW_LINE> <INDENT> self._first_node = u <NEW_LINE> <DEDENT> self._node_cpt += 1 <NEW_LINE> self._nodes[u] = {} <N... | nodeId : identifiant du noeud
times : suite d'intervalles de temps ou le noeud est actif | 625941d0462c4b4f79d1d839 |
def store(self, value): <NEW_LINE> <INDENT> key = value.key <NEW_LINE> if self.allowed_tags is not None and key not in self.allowed_tags: <NEW_LINE> <INDENT> raise ValueError("Unexpected item '%s' in list" % key) <NEW_LINE> <DEDENT> if key == self.first_tag: <NEW_LINE> <INDENT> self.append([]) <NEW_LINE> <DEDENT> self[... | Append an element to the list, checking tags. | 625941d07c178a314d6ef5c9 |
def enable(self): <NEW_LINE> <INDENT> self.log.debug("Enabling") <NEW_LINE> if 'block' in self.config and self.config['block']: <NEW_LINE> <INDENT> self.block_event = self.machine.events.add_handler( 'shot_' + self.name, self._block_handler, priority=self.priority-1) <NEW_LINE> <DEDENT> self.enabled = True | Enables this shot.
Shots are enabled by default when they're created. | 625941d08da39b475bd650dd |
def get_prefixes_first_free_address(self, customer_type='', ip_version=''): <NEW_LINE> <INDENT> uri = ( 'prefix/' + str(customer_type) + '/' + str(ip_version) + '/address/') <NEW_LINE> result = self.phpipam.api_send_request(path=uri, method='get') <NEW_LINE> return result | get first available address | 625941d0e76e3b2f99f3a972 |
def get_vcs_url(*, project, version_type, version_name): <NEW_LINE> <INDENT> if version_type == EXTERNAL: <NEW_LINE> <INDENT> if 'github' in project.repo: <NEW_LINE> <INDENT> user, repo = get_github_username_repo(project.repo) <NEW_LINE> return GITHUB_PULL_REQUEST_URL.format( user=user, repo=repo, number=version_name, ... | Generate VCS (github, gitlab, bitbucket) URL for this version.
Example: https://github.com/rtfd/readthedocs.org/tree/3.4.2/.
External version example: https://github.com/rtfd/readthedocs.org/pull/99/. | 625941d04f88993c3716c1cf |
def text_preprocess(text): <NEW_LINE> <INDENT> text = text.strip() <NEW_LINE> text = text.replace('[', ' ') <NEW_LINE> text = text.replace(']', ' ') <NEW_LINE> text = text.replace('...', 'etc') <NEW_LINE> text = text.replace('%', 'percents') <NEW_LINE> return text | DO NOT REMOVE STOPWORDS | 625941d06fb2d068a760f206 |
def is_opencolorio_installed(raise_exception: Boolean = False) -> Boolean: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> import PyOpenColorIO <NEW_LINE> return True <NEW_LINE> <DEDENT> except ImportError as error: <NEW_LINE> <INDENT> if raise_exception: <NEW_LINE> <INDENT> raise ImportError( '"OpenColorIO" related API f... | Return whether *OpenColorIO* is installed and available.
Parameters
----------
raise_exception
Whether to raise an exception if *OpenColorIO* is unavailable.
Returns
-------
:class:`bool`
Whether *OpenColorIO* is installed.
Raises
------
:class:`ImportError`
If *OpenColorIO* is not installed. | 625941d02ae34c7f2600d299 |
def __init__(self): <NEW_LINE> <INDENT> inkex.Effect.__init__(self) <NEW_LINE> self.OptionParser.add_option('-f', '--filename', action = 'store', type = 'string', dest = 'data_file', help = 'File to get data from?') | Constructor.
Defines the "--what" option of a script. | 625941d00383005118ecf74a |
def published(self): <NEW_LINE> <INDENT> return self.filter(is_published=True) | Find all objects who have have
:attr:`~helpfulfields.models.Publishing.is_published` set to
:data:`True`.
:return: All published objects
:rtype: :class:`~django.db.models.query.QuerySet` subclass | 625941d0b7558d58953c507b |
def rescale_value_range(self, i, output, out_min_val, out_max_val, clip_min=None, clip_max=None, callback=None): <NEW_LINE> <INDENT> args = [] <NEW_LINE> args.append("--input='{}'".format(i)) <NEW_LINE> args.append("--output='{}'".format(output)) <NEW_LINE> args.append("--out_min_val='{}'".format(out_min_val)) <NEW_LIN... | Performs a min-max contrast stretch on an input greytone image.
Keyword arguments:
i -- Input raster file.
output -- Output raster file.
out_min_val -- New minimum value in output image.
out_max_val -- New maximum value in output image.
clip_min -- Optional lower tail clip value.
clip_max -- Optional upper tail ... | 625941d0925a0f43d2549fe0 |
def read_to_end_of_comment(self): <NEW_LINE> <INDENT> cha = self._next_char(); <NEW_LINE> result = '' <NEW_LINE> line = '' <NEW_LINE> while True: <NEW_LINE> <INDENT> if cha == '@': <NEW_LINE> <INDENT> self._char_no -= 1 <NEW_LINE> return result.strip() <NEW_LINE> <DEDENT> elif cha == '\n': <NEW_LINE> <INDENT> self._adv... | Read and return a string starting from the current cursor position
and reading up to end of the "comment" section. The end of a comment is
indicated by the discovery of either an attribute (starting with "@"),
or the end of the comment section. Leading whitespace is stripped. | 625941d0f9cc0f698b140763 |
def bernoulli(gp_link=None): <NEW_LINE> <INDENT> if gp_link is None: <NEW_LINE> <INDENT> gp_link = noise_models.gp_transformations.Probit() <NEW_LINE> <DEDENT> if isinstance(gp_link,noise_models.gp_transformations.Probit): <NEW_LINE> <INDENT> analytical_mean = True <NEW_LINE> analytical_variance = False <NEW_LINE> <DED... | Construct a bernoulli likelihood
:param gp_link: a GPy gp_link function | 625941d0d6c5a102081441b4 |
def _build_model(self, is_train): <NEW_LINE> <INDENT> if is_train: <NEW_LINE> <INDENT> print('Building train model') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print('Building test model') <NEW_LINE> <DEDENT> l2 = 0.0001 <NEW_LINE> nf = self.nf_ <NEW_LINE> with tf.variable_scope('cnn', reuse=not is_train): <NEW_LINE... | Return logit of the model. | 625941d0be7bc26dc91cd767 |
def Conversions_nameToM(*args): <NEW_LINE> <INDENT> return _CsoundAC.Conversions_nameToM(*args) | Conversions_nameToM(std::string name) -> double | 625941d03346ee7daa2b2ed4 |
def test_create_account_view_ko(self): <NEW_LINE> <INDENT> content = { "username": "NewUser", "password1": "carotte65", "password2": "wrong", "phone_number": "+33624354645", } <NEW_LINE> response = self.client.post("/accounts/signup", content) <NEW_LINE> self.assertEqual(response.status_code, 200) | Assert user creation page rejects bad user content | 625941d0851cf427c661a676 |
def read(self, key): <NEW_LINE> <INDENT> if key not in self.db: <NEW_LINE> <INDENT> raise LookupError("No record for key \"%s\" exists." % key) <NEW_LINE> <DEDENT> return self.db[key] | Fetches a record from the database with the given key, raising a LookupError if no record was found.
@param key: The key.
@return dict: The found record.
@raise LookupError: If the record wasn't found. | 625941d0dd821e528d63b311 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.