code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def calibrate(hdf5, zoffsets, fit_order, outliers, no_plots = False, wx_wy_fields = ["xsigma", "ysigma"], stage_tilt = [0.0, 0.0, 0.0]): <NEW_LINE> <INDENT> [wx, wy, z, pixel_size] = loadWxWyZData(hdf5, zoffsets, wx_wy_fields = wx_wy_fields, stage_tilt = stage_tilt) <NEW_LINE> print("Fitting (round 1).") <NEW_LINE> [wx...
Run all the steps in Z calibration in a single step. hdf5 - The HDF5 file. zoffsets - Text file containing z offsets. fit_order - An integer in the range 0-4. outliers - Sigma threshold for removing outliers in Wx, Wy. no_plots - Don't make a plot of the fit. wx_wy_fields - Which fields to use for wx and wy. stage_til...
625941df3eb6a72ae02ec845
def delete_event_by_id(self, event_id): <NEW_LINE> <INDENT> event_ids = self.event_ids <NEW_LINE> if event_id in event_ids: <NEW_LINE> <INDENT> events = self._timed_events <NEW_LINE> for event in events: <NEW_LINE> <INDENT> if event.id == event_id: <NEW_LINE> <INDENT> self._timed_events.remove(event) <NEW_LINE> logging...
Delete scheduled event with provided id from the list of timed events
625941df009cb60464c6370f
def register_endpoints(api): <NEW_LINE> <INDENT> api.add_resource(EventList, '/events')
Register endpoints with the Flask app.
625941dfdd821e528d63b506
def update(d, u): <NEW_LINE> <INDENT> for k, v in u.items(): <NEW_LINE> <INDENT> if isinstance(v, collections.abc.Mapping): <NEW_LINE> <INDENT> r = update(d.get(k, {}), v) <NEW_LINE> d[k] = r <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> d[k] = u[k] <NEW_LINE> <DEDENT> <DEDENT> return d
Recursively update a mapping (i.e. a dict, list, set, or tuple). Conceptually, d and u are two sets trees (with nodes and edges). This function goes through all the nodes of u. For each node in u, if d doesn't have that node yet, then this function adds the node from u, otherwise this function overwrites the node alre...
625941dfcb5e8a47e48b7e05
def control_client(context): <NEW_LINE> <INDENT> socket = context.socket(zmq.SUB) <NEW_LINE> socket.connect(CONTROL_SOCKET) <NEW_LINE> socket.setsockopt(zmq.SUBSCRIBE, '') <NEW_LINE> return socket
Control socket for clients to listen on and be controlled
625941df097d151d1a2231b7
def test_tag_and_aliases_in_default_recognized_tags_dict(self): <NEW_LINE> <INDENT> self.assertIn(LineBreakTreeNode, DEFAULT_RECOGNIZED_TAGS_LIST)
Test the presence of the tag and aliases in the dictionary of default recognized tags.
625941dfa8ecb033257d342b
def __init__(self,config,key=int(-1),process_name='merge_bam',prev_step=None,**kwargs): <NEW_LINE> <INDENT> if not prev_step is None: <NEW_LINE> <INDENT> Bam2BamQsubProcess.__init__(self,config,key=key,process_name=process_name,input_dir=prev_step.output_dir,output_dir=prev_step.output_dir,prev_step=prev_step,**kwargs)...
Initializes the process object.
625941dfd18da76e23532839
def get_device_handles(): <NEW_LINE> <INDENT> return [pynvml.nvmlDeviceGetHandleByIndex(i) for i in range(pynvml.nvmlDeviceGetCount())]
Get a list of NVML device handles, one per device. Can throw NVMLError.
625941df0a366e3fb873eb7c
def set_volume(self, setto): <NEW_LINE> <INDENT> command = 'volume ' + setto <NEW_LINE> self.run_command(command)
Set audio volume.
625941df8e71fb1e9831db07
def load_config(self, filename): <NEW_LINE> <INDENT> cfg = RawConfigParser(); <NEW_LINE> cfg.read(filename) <NEW_LINE> section = "oscar.estop" <NEW_LINE> self.button = cfg.getint(section, "button") <NEW_LINE> self.ignore_duration = cfg.getfloat(section, "ignore_duration") <NEW_LINE> self.count_duration = cfg.getfloat(s...
Loads configuration settings from the file whose name is given. It will read the section called "oscar.estop". @param filename: the name of the config file to be read
625941dfeab8aa0e5d26deb8
def add_coords (self, canvas_id, *coords): <NEW_LINE> <INDENT> if not coords: <NEW_LINE> <INDENT> coords = self.canvas.coords(canvas_id) <NEW_LINE> <DEDENT> self.objects[canvas_id] = coords
adds canvas item id with @coords to objects dictionary;
625941df1b99ca400220ae12
def get_plugin(self, name): <NEW_LINE> <INDENT> if name in self._active_plugins: <NEW_LINE> <INDENT> return self._active_plugins[name] <NEW_LINE> <DEDENT> elif self.has_plugin_preset: <NEW_LINE> <INDENT> plugin_cls = self._active_preset.request_plugin(name) <NEW_LINE> plugin = self._init_plugin(plugin_cls) <NEW_LINE> s...
Get the plugin named ``name``. If no such plugin is currently active, try to activate a new one using the current preset.
625941df167d2b6e31218ef4
def retrieve_sub_org_units(self, customer_id, org_unit_path, **kwargs): <NEW_LINE> <INDENT> uri = self.MakeOrganizationUnitOrgunitProvisioningUri( customer_id, params={'get': 'children', 'orgUnitPath': org_unit_path}, **kwargs) <NEW_LINE> return self.RetrieveAllOrgUnitsFromUri(uri)
Retrieve all Sub-OrgUnits of the provided OrgUnit. Args: customer_id: string The ID of the Google Apps customer. org_unit_path: string The organization's full path name. [Note: Each element of the path MUST be URL encoded (example: finance%2Forganization/suborganization)] Returns...
625941dff9cc0f698b140958
def serialize(self): <NEW_LINE> <INDENT> return "m1:%s,m2:%s,m3:%s,m4:%s" % (self.__motor1.get_w(), self.__motor2.get_w(), self.__motor3.get_w(), self.__motor4.get_w())
return a dict of pwm of each motor.
625941dfb545ff76a8914175
def __rrshift__(self, iterable): <NEW_LINE> <INDENT> raise NotImplementedError( 'Needs to implement __rrshift__ : ' + str(self.__class__.__name__))
Chaining operator for Nuts. Needs to be overridden! Takes an input iterable and produces some output iterable. If the number of elements in the input and the output iterable does not change consider NutFunction instead. :param iterable iterable: Iterable to process. :return: Iterable :rtype: iterable :raise: NotImple...
625941df67a9b606de4a8217
def __init__(self, iterable: Iterable, description: str = None, target: int = None, interval: int = 1): <NEW_LINE> <INDENT> self._iterator = iter(iterable) <NEW_LINE> self._progress = 0 <NEW_LINE> if target is None: <NEW_LINE> <INDENT> target = FixedLengthIterable.try_get_len(iterable) <NEW_LINE> <DEDENT> super().__ini...
Create a new progress logging iterator instance :param iterable: the base iterable to iterate while logging progress :param target: the target (maximum) number of iterations to expect :param interval: the minimum interval between progress feedback (in seconds)
625941df5510c4643540f73c
def check_prom(prometheus): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> r = requests_session().get( "http://{}/metrics".format(prometheus), timeout=(30, 30) ) <NEW_LINE> print("[{}] Status Code: {}".format( datetime.now(timezone.utc).astimezone(), r.status_code )) <NEW_LINE> if r.status_code == 200: <NEW_LINE> <INDENT...
Test Prometheus endpoint.
625941df4428ac0f6e5bab54
def get_process_info(self, process_name=None, process_id=None): <NEW_LINE> <INDENT> process_info = [] <NEW_LINE> process_infos = self._get_process_info() <NEW_LINE> if process_name: <NEW_LINE> <INDENT> logger.debug('Collect the specified process name information, ' 'process name: {}.'.format(process_name)) <NEW_LINE> f...
By default, all process information is returned. If the process name is passed in, the incoming process information is returned, and the type list is returned.
625941df4527f215b584c7b3
def rows_columns_diagonals(self): <NEW_LINE> <INDENT> for diagonal_index in range(self.width + self.height - 1): <NEW_LINE> <INDENT> yield self.diagonal(diagonal_index) <NEW_LINE> yield self.anti_diagonal(diagonal_index) <NEW_LINE> <DEDENT> yield from (self.row(i) for i in range(self.height)) <NEW_LINE> yield from (sel...
Return all the rows, columns and diagonals in the board. Yields: list. lists of the rows, columns and diagonals.
625941dfa219f33f34628cc5
@builderFor(action="addConfigNameHost", hypervisor="xen") <NEW_LINE> def insertConfigName(logger, host, configId): <NEW_LINE> <INDENT> con = getXenConnection(host.getLocation().getID(), logger) <NEW_LINE> if not con: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> xen, session, _ = con <NEW_LINE> logger.info("Add config...
Add the given config identifier to the host's tags in Xen. :param logger: A logger used for logging possible errors. :type logger: seealso:: :class:`logging:Logger` :param host: Host-instance to modify. :type host: Host :param configId: An identifier for the configuration this host is now part of. :type configId: st...
625941df55399d3f05588a15
def vacc_set_loadtime(self, loadtime): <NEW_LINE> <INDENT> ldtime_msw = loadtime >> 32 <NEW_LINE> ldtime_lsw = loadtime & 0xffffffff <NEW_LINE> self.registers.vacc_time_lsw.write(lsw=ldtime_lsw) <NEW_LINE> self.registers.vacc_time_msw.write(msw=ldtime_msw)
Set the vacc load time on this xengine board :param loadtime: :return:
625941dfbaa26c4b54cb147c
def setPosition(self, pos): <NEW_LINE> <INDENT> self.position = int(pos * self.max)
deprecated; pos: int a 0.0->1.0 value for the slider position
625941dff548e778e58cd8df
def __repr__(self): <NEW_LINE> <INDENT> return '%s' % self.entries
String representation of this ``Choices`` instance. Notes ----- It will represent the data passed and store in ``self.entries``, not the data really stored in the base list object, which is in the format expected by django, ie a list of tuples with only value and display name. Here, we display everything. Example ---...
625941df2eb69b55b151cc13
def rightbox(self): <NEW_LINE> <INDENT> ps = PaneStack(css_class='spacer') <NEW_LINE> if self.searchbox: <NEW_LINE> <INDENT> ps.append(SearchForm()) <NEW_LINE> <DEDENT> if not c.user_is_loggedin and self.loginbox and not g.read_only_mode: <NEW_LINE> <INDENT> ps.append(LoginFormWide()) <NEW_LINE> <DEDENT> if not isinsta...
generates content in <div class="rightbox">
625941df50812a4eaa59c67e
def set_temperature(self, **kwargs): <NEW_LINE> <INDENT> if const.ATTR_TARGET_TEMP_HIGH in kwargs: <NEW_LINE> <INDENT> self.heater.set_comfort_temperature(kwargs[const.ATTR_TARGET_TEMP_HIGH]) <NEW_LINE> _LOGGER.info("Set HIGH TEMP to {temp}".format(temp=kwargs[const.ATTR_TARGET_TEMP_HIGH])) <NEW_LINE> <DEDENT> if const...
Set new target temperature
625941dfd53ae8145f87a5ca
def main(): <NEW_LINE> <INDENT> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'connect2learn.settings') <NEW_LINE> try: <NEW_LINE> <INDENT> from django.core.management import execute_from_command_line <NEW_LINE> <DEDENT> except ImportError as exc: <NEW_LINE> <INDENT> raise ImportError( "Couldn't import Django. Are yo...
Run administrative tasks.
625941df82261d6c526ab804
def ui_command_delete(self, name): <NEW_LINE> <INDENT> self.delete(name) <NEW_LINE> self.get_root().refresh() <NEW_LINE> self.refresh()
Deletes iSCSI bdev from configuration. Arguments: name - name of the iscsi bdev to be deleted.
625941dfe64d504609d74b9f
def getControl(*args): <NEW_LINE> <INDENT> pass
getControl(self, int controlId) -- Get's the control from this window. Throws: Exception, if Control doesn't exist controlId doesn't have to be a python control, it can be a control id from a xbmc window too (you can find id's in the xml files Note, not python controls are not completely usable yet You can only use ...
625941df1d351010ab855e7b
def __init__(self, record_1, record_2, vcf_keys, sample_idx_map=None): <NEW_LINE> <INDENT> self.record_1 = record_1 <NEW_LINE> self.record_2 = record_2 <NEW_LINE> self.sample_idx_map = sample_idx_map <NEW_LINE> comparison = dict() <NEW_LINE> for key, value in vcf_keys.items(): <NEW_LINE> <INDENT> record_1_value = None ...
Compare two vcf records based on the keys specified in vcf_keys
625941df76d4e153a657ee92
def __init__(self, name: str, buff_stats_and_amounts: [(str, int)], duration: int): <NEW_LINE> <INDENT> super().__init__(name, duration) <NEW_LINE> self.buff_amounts: {str: int} = {KEY_HEALTH_ATTRIBUTE: 0, KEY_MANA_ATTRIBUTE: 0, KEY_ARMOR_ATTRIBUTE: 0, KEY_STRENGTH_ATTRIBUTE: 0} <NEW_LINE> self._manage_buff_types(buff_...
Buff(10, [(armor, 3), (None, None), (None, None)) will increase your armor by 10 for 3 turns :param amount: the amount we are going to increase by :param buff_stats_and_amounts: A list of tuples, each tuple holding (1,2) 1 - the stat we are going to buff (str) "armor" 2 - the amount we are going to buff it by ...
625941df4e696a04525c97ac
@click.command('up') <NEW_LINE> @click.argument('notebook_id', type=int) <NEW_LINE> @click.option('--mem', type=int, default=None, help='Memory allocated for this notebook in MiB.') <NEW_LINE> @click.option('--cpu', type=int, default=None, help='CPU available for this notebook in 1/1000 of a core.') <NEW_LINE> def note...
Start an existing notebook and open it in the browser.
625941df55399d3f05588a16
def test_PythonProcessPane_parse_paste_final_character(): <NEW_LINE> <INDENT> ppp = mu.interface.panes.PythonProcessPane() <NEW_LINE> ppp.parse_input = mock.MagicMock() <NEW_LINE> mock_timer = mock.MagicMock() <NEW_LINE> with mock.patch('mu.interface.panes.QTimer', mock_timer): <NEW_LINE> <INDENT> ppp.parse_paste('\n')...
As above, but ensure that if there a no more remaining characters to parse in the pasted text, then don't schedule any more recursive calls.
625941dfcdde0d52a9e53395
def write_sort_file(staging_dir, extension_priorities, sort_file): <NEW_LINE> <INDENT> for dirpath, _dirname, filenames in os.walk(staging_dir): <NEW_LINE> <INDENT> for filename in filenames: <NEW_LINE> <INDENT> fn = os.path.join(dirpath, filename) <NEW_LINE> for idx, suffix in enumerate(extension_priorities): <NEW_LIN...
Write a sort file for mksquashfs to colocate some files at the beginning. Files are assigned priority by extension, with files earlier in the list appearing first. The result is written to the file object sort_file. mksquashfs takes the sort file with the option '-sort sort_filename'.
625941df566aa707497f48c5
def chromosome(self, chromindex): <NEW_LINE> <INDENT> chidx = np.random.randint(0, len(self.pool[chromindex])) <NEW_LINE> return self.pool[chromindex][chidx]
Get a random chromomsome from the pool :param chromindex: which chromosome are we looking for? :type chromindex: int :rtype: AlleleContainer
625941dfbde94217f368314e
def make_name_unique(xml_data): <NEW_LINE> <INDENT> need_uniq_names = ('problem', 'sequential', 'video', 'course', 'chapter', 'videosequence', 'poll_question', 'vertical') <NEW_LINE> attr = xml_data.attrib <NEW_LINE> tag = xml_data.tag <NEW_LINE> id = lambda x: x <NEW_LINE> lookups = [('url_name', id, False), ('slug', ...
Make sure that the url_name of xml_data is unique. If a previously loaded unnamed descriptor stole this element's url_name, create a new one. Removes 'slug' attribute if present, and adds or overwrites the 'url_name' attribute.
625941dffbf16365ca6f652a
def _new_view_cb(self, app, view): <NEW_LINE> <INDENT> if self.enabled: <NEW_LINE> <INDENT> self._connect_view(view) <NEW_LINE> view.queue_draw() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._view_signals[view] = None
Connects its background changing ability to a view
625941df9f2886367277abeb
def disp(grid): <NEW_LINE> <INDENT> for i, row in enumerate(grid): <NEW_LINE> <INDENT> if i%3 == 0: <NEW_LINE> <INDENT> print() <NEW_LINE> <DEDENT> for j, element in enumerate(row): <NEW_LINE> <INDENT> if j%3 == 0: <NEW_LINE> <INDENT> print('\t', end=' ') <NEW_LINE> <DEDENT> print(element, end=' ') <NEW_LINE> <DEDENT> ...
Display a sudoku grid. Parameters: grid (nested list): sudoku grid Returns: None
625941df956e5f7376d711cc
def is_probable_prime(n): <NEW_LINE> <INDENT> assert n >= 2 <NEW_LINE> if n == 2: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if n % 2 == 0: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> s = 0 <NEW_LINE> d = n-1 <NEW_LINE> while True: <NEW_LINE> <INDENT> quotient, remainder = divmod(d, 2) <NEW_LINE> if r...
Miller-Rabin primality test. A return value of False means n is certainly not prime. A return value of True means n is very likely a prime. >>> is_probable_prime(1) Traceback (most recent call last): ... AssertionError >>> is_probable_prime(2) True >>> is_probable_prime(3) True >>> is_probable_prime(4) False >>> ...
625941df4a966d76dd551372
def global_matches(self, text): <NEW_LINE> <INDENT> matches = [] <NEW_LINE> n = len(text) <NEW_LINE> ks = list(self.namespace.keys()) <NEW_LINE> for k in ks: <NEW_LINE> <INDENT> if not text and k.startswith('_'): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> elif k in completionIgnores: <NEW_LINE> <INDENT> pass <NEW_LIN...
Compute matches when text is a simple name. Return a list of all keywords, built-in functions and names currently defined in self.namespace that match.
625941df0a50d4780f6671f5
@admin.route('/account/<login>/delete', methods=['POST']) <NEW_LINE> @permissions.roles.admin.require(404) <NEW_LINE> def account_delete(login): <NEW_LINE> <INDENT> db = flask.current_app.container.get('db') <NEW_LINE> user = db.session.query(User).filter_by(login=login).first() <NEW_LINE> if user is None: <NEW_LINE> <...
Delete account (POST handler)
625941df85dfad0860c3b1bd
def __init__(self, iface): <NEW_LINE> <INDENT> self.iface = iface <NEW_LINE> self.provider = MapsPrinterProvider() <NEW_LINE> self.plugin_dir = os.path.dirname(__file__) <NEW_LINE> locale = QSettings().value('locale/userLocale')[0:2] <NEW_LINE> locale_path = os.path.join( self.plugin_dir, 'i18n', 'MapsPrinter_{}.qm'.fo...
Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface
625941dfbe383301e01b57e0
def _count_rows_in_data_file(self): <NEW_LINE> <INDENT> reader = self._read_csv_file() <NEW_LINE> row_count = sum(1 for row in reader) <NEW_LINE> self.file_handle.close() <NEW_LINE> return row_count
Simply counts the number of data rows in the csv file
625941df26238365f5f0f1d3
def add_actions(to_obj): <NEW_LINE> <INDENT> for action_name in _standard_action_funcs: <NEW_LINE> <INDENT> setattr ( to_obj.__class__, action_name, _standard_action_funcs[action_name]) <NEW_LINE> <DEDENT> if _class_specific_actions.has_key(to_obj.FriendlyClassName): <NEW_LINE> <INDENT> actions = _class_specific_action...
Add the appropriate actions to the control
625941df460517430c3944dd
def rawPlot3b(stats): <NEW_LINE> <INDENT> def f(t): <NEW_LINE> <INDENT> return numpy.exp(-t) * numpy.cos(2*numpy.pi*-t) <NEW_LINE> <DEDENT> plot_x = 230 <NEW_LINE> plot_y = 120 <NEW_LINE> fig = plt.figure(figsize=[plot_x * 0.01, plot_y * 0.01], dpi=100, ) <NEW_LINE> fig.set_size_inches(plot_x * 0.01, plot_y * 0.01) <NE...
Description. More...
625941df50812a4eaa59c67f
def test_user_can_get_all_parcels_belonging_to_them(self): <NEW_LINE> <INDENT> with self.client: <NEW_LINE> <INDENT> token = self.get_token("new_user", "new_user@gmail.com", "00000", "user") <NEW_LINE> self.create_new_parcel_delivery_order( "Big money", '3', "950", "Diana", "Wandegeya", "Kikoni", token ) <NEW_LINE> res...
Test that user can get parcels that belong to them :return:
625941df462c4b4f79d1da31
def getLightTravelTimes(ra, dec, time2corr): <NEW_LINE> <INDENT> target = SkyCoord(ra, dec, unit=(u.hourangle, u.deg), frame='icrs') <NEW_LINE> ltt_bary = time2corr.light_travel_time(target) <NEW_LINE> ltt_helio = time2corr.light_travel_time(target, 'heliocentric') <NEW_LINE> return ltt_bary, ltt_helio
Get the light travel times to the helio and bary centres TODO: Finish docstring
625941df7d847024c06be620
def get_last_element(array, _start, end): <NEW_LINE> <INDENT> return array[end - 1]
Select last element of array
625941df5fcc89381b1e1a21
def corns_neighbourhood(self, feats): <NEW_LINE> <INDENT> corn_neigh = [] <NEW_LINE> for i, corner in enumerate(feats): <NEW_LINE> <INDENT> x, y = corner.ravel() <NEW_LINE> corn_neigh.append([y-1, y+1, x-1, x+1]) <NEW_LINE> <DEDENT> return corn_neigh
Creates a neighbourhood of size 3x3 around the detected features(corners).
625941df7b180e01f3dc4b58
def process_request_using_post2_with_http_info(self, routing_key, suffix, request_params, request_headers, **kwargs): <NEW_LINE> <INDENT> all_params = ['routing_key', 'suffix', 'request_params', 'request_headers'] <NEW_LINE> all_params.append('async_req') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE...
processRequest # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api_pe.process_request_using_post2_with_http_info(routing_key, suffix, request_params, request_headers, async_req=True) >>> result = thread.get() :param a...
625941df01c39578d7e7519c
def load_handlers(config): <NEW_LINE> <INDENT> for import_path in config['pdcupdater.handlers']: <NEW_LINE> <INDENT> cls = fedmsg.utils.load_class(import_path) <NEW_LINE> handler = cls(config) <NEW_LINE> yield handler
Import and instantiate all handlers listed in the given config.
625941df7c178a314d6ef7c5
def path_from_hash(hash_): <NEW_LINE> <INDENT> hash_version, hash_alg, actual_hash = hash_.split('-') <NEW_LINE> first_stanza = actual_hash[0:2] <NEW_LINE> second_stanza = actual_hash[2:4] <NEW_LINE> path = (hash_version, hash_alg, first_stanza, second_stanza, hash_) <NEW_LINE> return os.path.join(*path)
create a filepath from a hash e.g. hash_ = v0-sha384-01b395a1cbc0f218 will return v0/sha384/01/b3/v0-sha384-01b395a1cbc0f218
625941df76e4537e8c3519d6
def type(self): <NEW_LINE> <INDENT> if '_type' in self.__dict__['_meta']: <NEW_LINE> <INDENT> return self.__dict__['_meta']['_type'] <NEW_LINE> <DEDENT> return None
Document type.
625941df3eb6a72ae02ec846
def set_pwm_value(self, value=50): <NEW_LINE> <INDENT> self._pwm_value = value
设置 PWM 空占比
625941df0a50d4780f6671f6
def __call__(self, *args): <NEW_LINE> <INDENT> return TensorFieldParal.__call__(self, *args)
Redefinition of :meth:`~sage.tensor.modules.free_module_tensor.FreeModuleTensor.__call__` to allow for domain treatment
625941df24f1403a92600ec4
def get_path(score): <NEW_LINE> <INDENT> path = [] <NEW_LINE> n = len(score) <NEW_LINE> path.append((0, 0)) <NEW_LINE> j = 0 <NEW_LINE> for i in range(n - 1): <NEW_LINE> <INDENT> if score[i + 1][j] > score[i + 1][j + 1]: <NEW_LINE> <INDENT> path.append((i + 1, j)) <NEW_LINE> i += 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> ...
利用回溯法求路径 Arguments: score {[type]} -- [description] Returns: list -- 使得总和最大的路径
625941df627d3e7fe0d691b2
def check_hash(self, block): <NEW_LINE> <INDENT> hashint = int(block.hash, 16) <NEW_LINE> for _ in range(block.difficulty): <NEW_LINE> <INDENT> if hashint & 1 != 0: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> hashint >>= 1 <NEW_LINE> <DEDENT> return True
Hashcash based. Solving this should take time O(2^n) where n is difficulty in this implementation. In Bitcoin, the difficulty is more robust by allowing more precise finetuning. Args: block: Block object
625941df94891a1f4081be0b
def ChanIKSetValue(self, *args): <NEW_LINE> <INDENT> return _csnd.Csound_ChanIKSetValue(self, *args)
ChanIKSetValue(Csound self, int channel, double value) -> int
625941dfbe383301e01b57e1
def __init__( self, method: Callable[..., tables.ListTablesResponse], request: tables.ListTablesRequest, response: tables.ListTablesResponse, *, metadata: Sequence[Tuple[str, str]] = () ): <NEW_LINE> <INDENT> self._method = method <NEW_LINE> self._request = tables.ListTablesRequest(request) <NEW_LINE> self._response = ...
Instantiate the pager. Args: method (Callable): The method that was originally called, and which instantiated this pager. request (google.area120.tables_v1alpha1.types.ListTablesRequest): The initial request object. response (google.area120.tables_v1alpha1.types.ListTablesResponse): ...
625941dffff4ab517eb2f79f
def __init__(self): <NEW_LINE> <INDENT> self.root = TrieNode()
Notice: * When insert new word, do not override the existing TrieNode * A flag to indicate whether there is a word ending here.
625941df442bda511e8be775
@auth.route('/logout') <NEW_LINE> @login_required <NEW_LINE> def logout(): <NEW_LINE> <INDENT> logout_user() <NEW_LINE> flash('你已经退出登录') <NEW_LINE> return redirect(url_for('main.index'))
退出
625941df2c8b7c6e89b35b1f
@ensure_csrf_cookie <NEW_LINE> def field_trip(request): <NEW_LINE> <INDENT> state = request.GET.get('state', None) <NEW_LINE> state_name = None <NEW_LINE> if state: <NEW_LINE> <INDENT> sites = FieldTripResource().list(state).order_by('name') <NEW_LINE> form = PassSiteStateForm(initial={'state': state}) <NEW_LINE> state...
Display the list of sites intended for field trips.
625941df1f037a2d8b94655e
def call(self): <NEW_LINE> <INDENT> logger = logging.getLogger("__main__") <NEW_LINE> candles = self.candles <NEW_LINE> if hasattr(candles, 'first_candle'): <NEW_LINE> <INDENT> up, lw, height = self.bolinger_bands(candles=candles, period=13, num_of_std=2.2) <NEW_LINE> rsi14 = self.rsi(candles=candles, period=13) <NEW_L...
Method to check call pattern.
625941dfa17c0f6771cbe3b0
def load_heatpump_table_fromfile(filename): <NEW_LINE> <INDENT> with open(filename, 'r', encoding='utf8') as f: <NEW_LINE> <INDENT> reader = list(csv.reader(f)) <NEW_LINE> data = {'filename': filename} <NEW_LINE> for i, row in enumerate(reader): <NEW_LINE> <INDENT> if row[0] == 'Manufacturer': <NEW_LINE> <INDENT> data[...
Load heat pump performance data from the specified csv file and format the data in a dictionary. EWT : entering temperature in ºC GPM : volumetric flow in L/s WPDc : pressure drop in the coil for the cooling mode in Pa WPDh : pressure drop in the coil for the heating mode in Pa Wc : work of the heat pump for the c...
625941df711fe17d825426c5
def build_query_parameters_from_django_filters(self): <NEW_LINE> <INDENT> params = [] <NEW_LINE> filter_class = getattr(self.callback, 'filter_class', None) <NEW_LINE> if (filter_class is not None and issubclass(filter_class, django_filters.FilterSet)): <NEW_LINE> <INDENT> for name, filter_ in filter_class.base_filters...
introspect ``django_filters.FilterSet`` instances.
625941df07d97122c4178bf3
def test_get_documents(self): <NEW_LINE> <INDENT> database = self.create_database() <NEW_LINE> with database as session: <NEW_LINE> <INDENT> session.add_collection("collection1", "name") <NEW_LINE> session.add_collection("collection2", "id") <NEW_LINE> session.add_document("collection1", "document1") <NEW_LINE> session...
Tests the method returning the list of document rows, given a collection
625941dfb57a9660fec33bea
def parametersToMvision(self) -> dict: <NEW_LINE> <INDENT> return { "line": [self.line[0].tolist(), self.line[1].tolist()], "unitnormal": self.unitnormal.tolist(), }
internal parameters of this analyzer widget to a dictionary that the associated machine vision process understands everything in the dict must be json-seriazable, since this is used to save the analyzer widget state to disk
625941df30bbd722463cc128
def model_convrnn(n_out, input_shape=(1, None), out_activation='softmax'): <NEW_LINE> <INDENT> assert input_shape[0] == 1, 'Mono input please!' <NEW_LINE> model = Sequential() <NEW_LINE> n_mels = 40 <NEW_LINE> model.add(Melspectrogram(sr=SR, n_mels=n_mels, power_melgram=2.0, return_decibel_melgram=True, input_shape=inp...
No reference, just ConvRNN. Symbolic summary: > c2 - c2 - c2 - c2 - r2 - r2 - d1 Parameters ---------- n_out: integer, number of output nodes input_shape: tuple, an input shape, which doesn't include batch-axis. (1, None) means (mono channel, variable length). out_activation: activation f...
625941df3539df3088e2e6ac
def calculate_probability(n): <NEW_LINE> <INDENT> prob_not = math.factorial(365) / (math.factorial(365-n) * 365**n) <NEW_LINE> probability = 1- prob_not <NEW_LINE> return probability
365! / (365-n)! * 365 ^ n
625941dfe1aae11d1e74a01b
def onvalidate(self, d,i,P,s,S,v,V,W): <NEW_LINE> <INDENT> newcolor = 'IndianRed1' if not self.validate(P) else self.default_color <NEW_LINE> self.rootdlg.nametowidget(W).configure(background=newcolor) <NEW_LINE> return True
private validation function to check if it is a valid input i entrybox
625941df29b78933be1e5a08
def code_open_browser(): <NEW_LINE> <INDENT> if gbl_file_name == "": <NEW_LINE> <INDENT> showinfo("Open in Web Browser", "File must be saved to do this. Please save the file and try again.") <NEW_LINE> return internal_return_focus() <NEW_LINE> <DEDENT> if gbl_text_modified: <NEW_LINE> <INDENT> open_con = askyesno("Open...
Opens the current file in the user's default web browser.
625941dfbd1bec0571d90990
def count_vocab_items(self, counter: Dict[str, Dict[str, int]]): <NEW_LINE> <INDENT> for field in self.fields.values(): <NEW_LINE> <INDENT> field.count_vocab_items(counter)
Increments counts in the given `counter` for all of the vocabulary items in all of the `Fields` in this `Instance`.
625941df090684286d50f04a
@validate_str <NEW_LINE> def isiso8601(value): <NEW_LINE> <INDENT> iso8601 = re.compile(r'^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?...
Return whether or not given value is ISO 8601 date. If the value is ISO 8601 date, this function returns ``True``, otherwise ``False``. Examples:: >>> isiso8601('2009-12T12:34') True >>> isiso8601('2009367') False :param value: string to validate ISO 8601 date
625941dfde87d2750b8600f7
def extract_items(target_files, target_files_temp_dir, extract_item_list): <NEW_LINE> <INDENT> logger.info('extracting from %s', target_files) <NEW_LINE> with zipfile.ZipFile( target_files, 'r', allowZip64=True) as target_files_zipfile: <NEW_LINE> <INDENT> target_files_namelist = target_files_zipfile.namelist() <NEW_LI...
Extract items from target files to temporary directory. This function extracts from the specified target files zip archive into the specified temporary directory, the items specified in the extract item list. Args: target_files: The target files zip archive from which to extract items. target_files_temp_dir: The...
625941df5fcc89381b1e1a22
def get_feedback(self) -> str: <NEW_LINE> <INDENT> content = "\n".join(item.get_feedback(self._is_late, 1) for item in self._grades if item._enabled) <NEW_LINE> return FeedbackHTMLTemplates.base.format(content=content, overall_comments=self._overall_comments_html)
Patch together all the grade comments for this submission.
625941df090684286d50f04b
def combine_readings(self, existing_reading, new_reading): <NEW_LINE> <INDENT> combined_reading= [] <NEW_LINE> if existing_reading == None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> for i, token in enumerate(existing_reading): <NEW_LINE> <INDENT> combined_reading.append(self.combine_tokens(token, new_reading[...
combine a new readings with an existing reading token by token
625941df94891a1f4081be0c
def _unit_conversion(self, cmp_func): <NEW_LINE> <INDENT> if isinstance(cmp_func, MethodType): <NEW_LINE> <INDENT> cmp_func = cmp_func.__func__ <NEW_LINE> <DEDENT> def wrapper(self, value): <NEW_LINE> <INDENT> if not isinstance(value, _Quantity): <NEW_LINE> <INDENT> return cmp_func(self, value) <NEW_LINE> <DEDENT> else...
Decorator handling unit conversion to the unit.
625941df67a9b606de4a8218
def dep_bld(self, dep, ns=None): <NEW_LINE> <INDENT> art = Artifact() <NEW_LINE> try: <NEW_LINE> <INDENT> for x in dep: <NEW_LINE> <INDENT> if str(x.tag).endswith('groupId'): <NEW_LINE> <INDENT> art.group = x.text <NEW_LINE> <DEDENT> elif str(x.tag).endswith('artifactId'): <NEW_LINE> <INDENT> art.artifact = x.text <NEW...
Creates an artifact from the xml dep :param dep: :return:
625941dfcb5e8a47e48b7e06
def json(self): <NEW_LINE> <INDENT> return self.data
:rtype: dict
625941df8a349b6b435e84d4
def create_network_interface(name): <NEW_LINE> <INDENT> new_iface = Interface('network') <NEW_LINE> new_iface.source = {'network': name} <NEW_LINE> new_iface.model = "virtio" <NEW_LINE> new_iface.mac_address = utils_net.generate_mac_address_simple() <NEW_LINE> return new_iface
Create network type interface xml.
625941dfa79ad161976cc4a7
def print_simple_message(self, message): <NEW_LINE> <INDENT> print(self.bot_name + ':', message)
Print the passed message and the bot name in front of it.
625941df091ae356686672ba
def toggle_dug(self, toggles=1): <NEW_LINE> <INDENT> self._lock.acquire() <NEW_LINE> for i in range(toggles): <NEW_LINE> <INDENT> for s in self: <NEW_LINE> <INDENT> if s.state == State.UNTOUCHED: <NEW_LINE> <INDENT> s.state = State.DUG <NEW_LINE> <DEDENT> elif s.state == State.DUG: <NEW_LINE> <INDENT> s.state = State.U...
Switches the state of every square contained in this board between UNTOUCHED and DUG (see the code for more info). If the state of a square is FLAGGED no modification occurs. This method is primarily used for debug purposes.
625941df7047854f462a1767
def admin_update_password(self, user, new_password, code=None): <NEW_LINE> <INDENT> password_hash = sscrypt(new_password.encode('utf8')) <NEW_LINE> return self.admin_update_field(user, 'password', password_hash)
Change the user password Args: user_id: user id password: new password Returns: True if the change was successful, False otherwise
625941df30bbd722463cc129
def __init__( self, model: Module, optimizer: Optimizer, train_mb_size: int = 1, train_epochs: int = 1, eval_mb_size: int = 1, device="cpu", plugins: Optional[Sequence["SupervisedPlugin"]] = None, evaluator: EvaluationPlugin = default_evaluator, eval_every=-1, peval_mode="epoch", ): <NEW_LINE> <INDENT> super().__init__...
Init. :param model: PyTorch model. :param optimizer: PyTorch optimizer. :param train_mb_size: mini-batch size for training. :param train_epochs: number of training epochs. :param eval_mb_size: mini-batch size for eval. :param evaluator: (optional) instance of EvaluationPlugin for logging and metric computations. N...
625941df3eb6a72ae02ec847
def __init__(self, description=None, device_filter=None, name=None, object=None, root_manifest_id=None, state=None, when=None): <NEW_LINE> <INDENT> self._description = description <NEW_LINE> self._device_filter = device_filter <NEW_LINE> self._name = name <NEW_LINE> self._object = object <NEW_LINE> self._root_manifest_...
UpdateCampaignPostRequest - a model defined in Swagger
625941df596a897236089e1e
def post(self): <NEW_LINE> <INDENT> decoded_id = self._get_id() <NEW_LINE> if not decoded_id: <NEW_LINE> <INDENT> self.response.set_status(400, self.err_msg) <NEW_LINE> return <NEW_LINE> <DEDENT> party = db.GqlQuery('SELECT * FROM Party WHERE id = :1 LIMIT 1', decoded_id).get() <NEW_LINE> if not party: <NEW_LINE> <INDE...
{ 'code': 'xg43c', 'note': 'wooo party', 'guests': [ { 'id': 0, 'attendance': 1, 'meal': 1 }, { 'name': 'Emily', 'attendance': 1, 'meal': 2 } ] }
625941dfdd821e528d63b508
def add_diag(self, diag): <NEW_LINE> <INDENT> from .diag_lazy_tensor import DiagLazyTensor <NEW_LINE> from .added_diag_lazy_tensor import AddedDiagLazyTensor <NEW_LINE> if self.size(-1) != self.size(-2): <NEW_LINE> <INDENT> raise RuntimeError("add_diag only defined for square matrices") <NEW_LINE> <DEDENT> if self.ndim...
Adds an element to the diagonal of the matrix. Args: - diag (Scalar Tensor)
625941dfd18da76e2353283b
def __init__(self, dataset_info_file, batch_size): <NEW_LINE> <INDENT> self._dataset_info_file = dataset_info_file <NEW_LINE> self._batch_size = batch_size <NEW_LINE> self._img_list = self._init_dataset() <NEW_LINE> self._next_batch_loop_count = 0
:param dataset_info_file:
625941df57b8e32f524837fe
def set_buyer_invoice_data(self, billing_info): <NEW_LINE> <INDENT> self.buyer_name = billing_info.name <NEW_LINE> self.buyer_street = billing_info.street <NEW_LINE> self.buyer_zipcode = billing_info.zipcode <NEW_LINE> self.buyer_city = billing_info.city <NEW_LINE> self.buyer_country = billing_info.country <NEW_LINE> s...
Fill buyer invoice billing and shipping data by copy them from provided buyer's ``BillingInfo`` object. :param billing_info: BillingInfo object :type billing_info: BillingInfo
625941df15baa723493c42d9
@ncjit <NEW_LINE> def np_all_axis1(x): <NEW_LINE> <INDENT> out = x[:, 0, ...] <NEW_LINE> for i in range(1, x.shape[1]): <NEW_LINE> <INDENT> out = np.logical_and(out, x[:, i, ...]) <NEW_LINE> <DEDENT> return out
Numba compatible version of np.all(x, axis=1). Parameters ---------- x : array_like Input array Notes ----- #. Written by David C. Stauffer in January 2021. Examples -------- >>> from dstauffman.nubs import np_all_axis1 >>> import numpy as np >>> x = np.array([[True, True, False, False], [True, False, True, Fal...
625941df8e71fb1e9831db09
def __mul__( self, scalar ): <NEW_LINE> <INDENT> assert self.getSheet() == p.getSheet() <NEW_LINE> return Location(self.getX()*scalar, self.getY()*scalar, self.getSheet())
Point(x1*x2, y1*y2)
625941dfa8370b7717052bff
def get_block_order(self): <NEW_LINE> <INDENT> return self._block_order
Get block ordering scheme
625941df29b78933be1e5a09
def download_file_from_s3(bucket_name, remote_path, local_path): <NEW_LINE> <INDENT> s3 = boto3.resource('s3') <NEW_LINE> s3.Bucket(bucket_name).download_file(remote_path, local_path) <NEW_LINE> return
Download a file from AWS S3 http://boto3.readthedocs.io/en/latest/guide/s3-examples.html
625941df004d5f362079a693
def test_login_disabled(self): <NEW_LINE> <INDENT> self.enable_saml(enabled=False) <NEW_LINE> response = self.client.get(self.LOGIN_URL) <NEW_LINE> self.assertEqual(response.status_code, 404)
When SAML is not enabled, the login view should return 404
625941df167d2b6e31218ef6
@tf_export('tree_ensemble_deserialize') <NEW_LINE> def tree_ensemble_deserialize(tree_ensemble_handle, stamp_token, tree_ensemble_config, name=None): <NEW_LINE> <INDENT> _ctx = _context.context() <NEW_LINE> if _ctx.in_graph_mode(): <NEW_LINE> <INDENT> _, _, _op = _op_def_lib._apply_op_helper( "TreeEnsembleDeserialize",...
Deserializes a serialized tree ensemble config and replaces current tree ensemble. Args: tree_ensemble_handle: A `Tensor` of type `resource`. Handle to the tree ensemble. stamp_token: A `Tensor` of type `int64`. Token to use as the new value of the resource stamp. tree_ensemble_config: A `Tensor` of typ...
625941df21a7993f00bc8057
def bitmask_set(bm,mn,f): <NEW_LINE> <INDENT> return mn | bm[f]
sets the flag f in mn as defined by the bitmask bm to True (or 1) throws KeyError if f is not defined :param bm: bitmask :param mn: magic number :param f: flag
625941dff9cc0f698b14095a
def run_refresh_step(step, directory, args): <NEW_LINE> <INDENT> return RefreshStepApp(step, directory, args).run()
Run ``snappy-refresh-step``.
625941df925a0f43d254a1db
def sequence(*funcs): <NEW_LINE> <INDENT> if len(funcs) == 0: <NEW_LINE> <INDENT> return return_ <NEW_LINE> <DEDENT> def parser(src): <NEW_LINE> <INDENT> for arg1, src in funcs[0](src): <NEW_LINE> <INDENT> for others, src in sequence(*funcs[1:])(src): <NEW_LINE> <INDENT> yield (arg1,) + others, src <NEW_LINE> <DEDENT> ...
Parser combinator, that applies several parsers in sequence. For example, if parser_a parses "A" and parser_b parses "B", then sequence(parser_a, parser_b) parses "AB". This corresponds to <ParserA> <ParserB> in BNF notation.
625941dfeab8aa0e5d26debb
@pytest.fixture() <NEW_LINE> def python_topic(topics_dir: Path) -> Topic: <NEW_LINE> <INDENT> python_topic_dir = topics_dir / 'python' <NEW_LINE> return Topic( name='python', enabled=True, symlinks=[python_topic_dir / 'python.symlink'], installer=python_topic_dir / 'init.zsh', aliaser=python_topic_dir / 'aliases.zsh', ...
Creates a python Topic that is ENABLED & has all attributes set.
625941dfd164cc61757830b0
def __init__(self, params=None): <NEW_LINE> <INDENT> self.n = 1
Constructor
625941df3c8af77a43ae3b05
def uncover(self) -> None: <NEW_LINE> <INDENT> for bit0 in self.get_bits_up(): <NEW_LINE> <INDENT> for bit in bit0.get_other_bits_left(): <NEW_LINE> <INDENT> bit.column.size += 1 <NEW_LINE> bit.up.down = bit <NEW_LINE> bit.down.up = bit <NEW_LINE> <DEDENT> <DEDENT> self.right.left = self <NEW_LINE> self.left.right = se...
inverse of cover
625941df57b8e32f524837ff