code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
def save_mch_wave( mix_wavdata, output_filename, sample_width=2, params=None, framerate=16000 ): <NEW_LINE> <INDENT> a_wavdata = mix_wavdata.transpose() <NEW_LINE> out_wavdata = a_wavdata.copy(order="C") <NEW_LINE> print("# save data:", output_filename, out_wavdata.shape) <NEW_LINE> ww = wave.Wave_write(output_filename...
多チャンネルwavファイルの保存 Args: mix_wavdata: 波形データnch x nframe output_filename (str): 入力信号(一次元信号) sample_width (int): 1サンプルあたりのバイト数, e.g., 2byte(16bit), 3byte(24bit) params (List): その他パラメータ一覧をタプル framerate (int): フレームレート
625941ed26068e7796caf20c
def _updateActions(self): <NEW_LINE> <INDENT> selected = bool(self._selectedSaveSlot()) <NEW_LINE> self.actionRemove.setEnabled(selected) <NEW_LINE> self.actionSave.setEnabled(selected)
Update the Save/remove action enabled state.
625941edc432627299f0516f
def __iter__(self): <NEW_LINE> <INDENT> for child in chain(*self.children): <NEW_LINE> <INDENT> yield child <NEW_LINE> <DEDENT> yield self
Iterates over the node and all it's subnodes :return: the iterator
625941ed15baa723493c449f
def doSheet_CreateSheetNamedSelection(self,sheetURI,rangeName,range): <NEW_LINE> <INDENT> params = {} <NEW_LINE> params['context'] = self.context <NEW_LINE> params['sheetURI'] = self.fixTypes(sheetURI) <NEW_LINE> params['rangeName'] = self.fixTypes(rangeName) <NEW_LINE> params['range'] = self.fixTypes(range) <NEW_LINE>...
Creates a range in the sheet. A range is a named set of sequential rows and columns.
625941ed0a366e3fb873ed44
def first_5cards(self): <NEW_LINE> <INDENT> return self._first_attack_5cards
Returns True if first attack 5 cards restriction is enabled.
625941edb5575c28eb68e52a
def read_dt(self, station, ref_station, start, end): <NEW_LINE> <INDENT> pair = (ref_station, station) <NEW_LINE> table_path = self.time_deltas_group + '/station_%d/station_%d' % pair <NEW_LINE> table = self.data.get_node(table_path, 'time_deltas') <NEW_LINE> ts0 = datetime_to_gps(start) <NEW_LINE> ts1 = datetime_to_gp...
Read timedeltas from HDF5 file
625941ed4a966d76dd55153a
def define_api_method(component, api_method_record, copy_record=True): <NEW_LINE> <INDENT> if copy_record: <NEW_LINE> <INDENT> api_method_record = copy.deepcopy(api_method_record) <NEW_LINE> <DEDENT> api_method_record.component = component <NEW_LINE> if not api_method_record.ok_to_overwrite: <NEW_LINE> <INDENT> if api_...
Registers an API-method with a Component instance. Args: component (Component): The Component object to register the API method with. api_method_record (APIMethodRecord): The APIMethodRecord describing the to-be-registered API-method. copy_record (bool): Whether to deepcopy the APIMethodRecord prior to han...
625941edeab8aa0e5d26e07f
def __init__(self, parent, **kwargs): <NEW_LINE> <INDENT> super(CadenceMayaStatusElement, self).__init__(parent, **kwargs) <NEW_LINE> self._colors = None <NEW_LINE> self._running = False <NEW_LINE> self._status = False <NEW_LINE> mainLayout = self._getLayout(self, QtGui.QVBoxLayout) <NEW_LINE> self.setContentsMargins...
Creates a new instance of CadenceNimbleStatusElement.
625941ed9f2886367277adae
def train(self, states, rewards, next_states, done, weight, summary=True): <NEW_LINE> <INDENT> if summary: <NEW_LINE> <INDENT> ops = [self.td_error, self.error_summary, self.optimization_op] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> ops = [self.td_error, self.optimization_op] <NEW_LINE> <DEDENT> feed_dict = { self....
Function that takes a transition (s,a,r,s') and optimizes Bellman error. Args: states: object, a batch of observations. rewards: np.array, immediate reward attained after executing those actions dtype must be float32 and shape must be (batch_size,). next_states: object, observations that followed states. d...
625941ed8e05c05ec3eea89e
def read(self, scaler=None): <NEW_LINE> <INDENT> if (scaler == None): <NEW_LINE> <INDENT> counts = [] <NEW_LINE> for i in range(self.nchans): <NEW_LINE> <INDENT> self.pvs['counts'][i].array_get() <NEW_LINE> <DEDENT> self.pvs['count'].pend_io() <NEW_LINE> for i in range(self.nchans): <NEW_LINE> <INDENT> counts.append(se...
Returns the current counts on the scaler. The default is to return a list of counts, one for each of the .Sn fields in the record, i.e. [.S1, .S2 ...]. If the scaler keyword is specified then only the counts on that scaler are returned. Keywords: scaler: The number of the specific scaler channel to read and...
625941ed8a43f66fc4b54585
def _captcha_cookie(self): <NEW_LINE> <INDENT> cookies = requests.get('https://sinespcidadao.sinesp.gov.br/sinesp-cidadao/captchaMobile.png', proxies=self._proxies, verify=False).cookies <NEW_LINE> jsessionid = cookies.get('JSESSIONID') <NEW_LINE> return {'JSESSIONID': jsessionid}
Performs a captcha request and return the cookie.
625941ede64d504609d74d65
@api_view(['GET', 'POST']) <NEW_LINE> def APIrequests(request): <NEW_LINE> <INDENT> err = False <NEW_LINE> try: <NEW_LINE> <INDENT> with open(REQUESTS_FILE, 'r') as file: <NEW_LINE> <INDENT> data = json.load(file) <NEW_LINE> <DEDENT> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> err = True <NEW_LINE> data = [] <N...
returns a list of all requests raised for unavailable material for a GET request or receives an index to be deleted from requests raised for a POST request
625941ed8c3a8732951588e6
def next(self): <NEW_LINE> <INDENT> return self.__next__()
Py2 compatibility
625941ed30c21e258bdfa9c8
def is_empty(self): <NEW_LINE> <INDENT> return len(self) == 0
Returns ``True`` if the list is empty.
625941eda79ad161976cc66b
def tweet_text(cls,status_item): <NEW_LINE> <INDENT> twitter_info = json.dumps(status_item._json) <NEW_LINE> valid_json_string = '[' + twitter_info + ']' <NEW_LINE> data_dictionary = json.loads(valid_json_string) <NEW_LINE> if data_dictionary[0]['lang'] == 'th': <NEW_LINE> <INDENT> return data_dictionary[0]['text']
Convert Status item to json string. Pick only Thai 'text' from json dictionary and return in list.
625941edd486a94d0b98e66c
def enqueue(self, item): <NEW_LINE> <INDENT> self.stack_1.stack_push(item)
Method for adding a new item to end of Queue.
625941ed627d3e7fe0d69377
def update_GIBS_xml(date, xml_file): <NEW_LINE> <INDENT> tree = ET.parse(xml_file) <NEW_LINE> root = tree.getroot() <NEW_LINE> url = root[0][0].text <NEW_LINE> old_date = re.split('/', url)[6] <NEW_LINE> new_url = re.sub(old_date, date, url) <NEW_LINE> root[0][0].text = new_url <NEW_LINE> tree.write(xml_file) <NEW_LINE...
Puts the date of interest into the GIBS XML file. For research mode, not operations
625941eda8370b7717052dc3
def firstMissingPositive(self, nums): <NEW_LINE> <INDENT> if not nums: <NEW_LINE> <INDENT> return 1 <NEW_LINE> <DEDENT> for i in range(1, len(nums) + 2): <NEW_LINE> <INDENT> if i not in nums: <NEW_LINE> <INDENT> return i
:type nums: List[int] :rtype: int
625941ed91af0d3eaac9bf43
def get_cnn_layer_labels(max_conv_size=7): <NEW_LINE> <INDENT> conv_layer_labels = ['fc', 'max-pool', 'avg-pool', 'softmax'] <NEW_LINE> for conv_size in range(3, max_conv_size+1, 2): <NEW_LINE> <INDENT> conv_layer_labels.append('conv%d'%(conv_size)) <NEW_LINE> conv_layer_labels.append('res%d'%(conv_size)) <NEW_LINE> <D...
Gets the layer labels for a CNN.
625941edd18da76e23532a03
def _check_offline_mode(self): <NEW_LINE> <INDENT> ret_offline_mode = self.get_variable("OFFLINE_MODE") <NEW_LINE> self.__offline_mode = not ret_offline_mode in ("OFF", "0")
Check if the database was set to offline_mode.
625941eda17c0f6771cbe575
@app.route("/api/posts", methods=["GET"]) <NEW_LINE> @decorators.accept("application/json") <NEW_LINE> def posts_get(): <NEW_LINE> <INDENT> title_like = request.args.get("title_like") <NEW_LINE> body_like = request.args.get("body_like") <NEW_LINE> posts = session.query(models.Post) <NEW_LINE> if title_like and body_lik...
Endpoint to retreive blog posts
625941ed50485f2cf553d2c1
def flip_tiles(self, flip_list)-> list: <NEW_LINE> <INDENT> for element in flip_list: <NEW_LINE> <INDENT> self.board_state[element[0]][element[1]] = self.current_player
Flips the items that need to be flipped.
625941edcdde0d52a9e5355d
def __exit__(self, exc_type, exc_value, exc_traceback): <NEW_LINE> <INDENT> self.end = time.time() <NEW_LINE> elapsed = self.end - self.start <NEW_LINE> if exc_type: <NEW_LINE> <INDENT> print(f"{exc_type.__name__}: {exc_value}") <NEW_LINE> logging.info(self.message.strip()) <NEW_LINE> logging.error(f"({exc_type.__name_...
Calculate and report the elapsed time.
625941ed67a9b606de4a83dc
def show_labels(self, set_id=None, show=True): <NEW_LINE> <INDENT> self.visible_new_labels = show <NEW_LINE> if set_id is None: <NEW_LINE> <INDENT> for sid in range(1, len(self.data.plot_data)+1): <NEW_LINE> <INDENT> self._show_set_labels(sid, show) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> self._show_set_...
Shows or hide datapoint labels for selected PC set.
625941ed379a373c97cfb06c
def speak(regex_string=None, clean_quotes=True): <NEW_LINE> <INDENT> if regex_string is None: <NEW_LINE> <INDENT> regex_string = input("Enter a regular expression:") <NEW_LINE> <DEDENT> if clean_quotes: <NEW_LINE> <INDENT> regex_string = check_for_quotes(regex_string) <NEW_LINE> <DEDENT> print(parse_tree(regex_string))
Given a regular expression, prints the translation for that regular expression. clean_quotes: If true, checks if the given regular expression is enclosed in quotation marks and removes them before translating it.
625941ed091ae3566866747b
def test_profiles_filters(self): <NEW_LINE> <INDENT> with self.settings(API_LOCKDOWN=False): <NEW_LINE> <INDENT> filter_url = self.profiles_list_url <NEW_LINE> resp = self.api_client.get(filter_url) <NEW_LINE> self.assertValidJSONResponse(resp) <NEW_LINE> self.assertEqual(len(self.deserialize(resp)['objects']), 9) <NEW...
Test profiles filtering
625941ed4f88993c3716c587
def search(request): <NEW_LINE> <INDENT> error = False <NEW_LINE> if 'q' in request.POST: <NEW_LINE> <INDENT> q = request.POST['q'] <NEW_LINE> if not q: <NEW_LINE> <INDENT> error = True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> books = Book.objects.filter(authors__Name__icontains=q) <NEW_LINE> return render_to_resp...
search
625941edfff4ab517eb2f965
def test_CreateRegisterLabel1(self): <NEW_LINE> <INDENT> self.delayDisplay("Starting the test") <NEW_LINE> import urllib <NEW_LINE> downloads = ( ('http://slicer.kitware.com/midas3/download?items=5767', 'FA.nrrd', slicer.util.loadVolume), ) <NEW_LINE> for url,name,loader in downloads: <NEW_LINE> <INDENT> filePath = sli...
Ideally you should have several levels of tests. At the lowest level tests should exercise the functionality of the logic with different inputs (both valid and invalid). At higher levels your tests should emulate the way the user would interact with your code and confirm that it still works the way you intended. One ...
625941ed711fe17d82542885
def bubble_sort(items): <NEW_LINE> <INDENT> working = True <NEW_LINE> while working: <NEW_LINE> <INDENT> working = False <NEW_LINE> for index, item in enumerate(items): <NEW_LINE> <INDENT> if index < len(items) - 1: <NEW_LINE> <INDENT> next_index = index + 1 <NEW_LINE> next_item = items[next_index] <NEW_LINE> if item >...
Sort items with a bubble sort.
625941ed4c3428357757c84a
def set_QdQ(columns): <NEW_LINE> <INDENT> Ti, Td, dT = columns['Ti'], columns['Td'], columns['dT'] <NEW_LINE> Ld, dL = columns['Ld'], columns['dL'] <NEW_LINE> Qx, Qz = TiTdL2Qxz(Ti, Td, Ld) <NEW_LINE> dQ = dTdL2dQ(Td-Ti, dT, Ld, dL) <NEW_LINE> columns['Qx'], columns['Qz'], columns['dQ'] = Qx, Qz, dQ <NEW_LINE> return c...
Generate Q and dQ fields from angles and geometry
625941ed442bda511e8be937
def required_state_sequence_length(self): <NEW_LINE> <INDENT> raise Exception('Not implemented')
Get the needed number of sensor states needed to compute the evalute and goal functions returns: int
625941ed097d151d1a22337c
def get_user_profile(self): <NEW_LINE> <INDENT> r = self.fitbit_service.get('http://api.fitbit.com/1/user/-/profile.json', header_auth=True) <NEW_LINE> logging.debug('Getting user profile. %s %s', r.status_code, r.text) <NEW_LINE> if r.status_code != 200: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> return r.jso...
Returns user profile information
625941ed6e29344779a62b36
def shuffle_data_index(self, batch_size): <NEW_LINE> <INDENT> self.dataset_size = np.shape(self.train_images)[0] <NEW_LINE> data_index = np.arange(self.dataset_size) <NEW_LINE> np.random.shuffle(data_index) <NEW_LINE> self.max_batch = self.dataset_size//batch_size <NEW_LINE> random_index = np.random.randint(low = 0, hi...
shuffle the image in every epoch
625941edbe7bc26dc91cdb1c
def apply_time_leverage_fees(self): <NEW_LINE> <INDENT> if self.fees.is_it_time_for_leverage_fee(self.coin_symbol, self.hours_position_open): <NEW_LINE> <INDENT> if self.apply_leverage_fees_on_all_capital: <NEW_LINE> <INDENT> fees_current_capital = self.fees.apply_leverage_time_for_fee_in_hours(self.coin_symbol, self.c...
Checks if its time fo leverage fees and updates position stats accordingly :return:
625941ed851cf427c661aa30
def to_snake_case(self, variable_name): <NEW_LINE> <INDENT> name = re.sub(r'(?<!^)(?=[A-Z])', '_', variable_name).lower() <NEW_LINE> return name
Converts from TransactionType to transaction_type :param variable_name: :return:
625941ed7b25080760e3997c
def SetInput2(self, *args): <NEW_LINE> <INDENT> return _itkMorphologicalWatershedFromMarkersImageFilterPython.itkMorphologicalWatershedFromMarkersImageFilterIUC2IUC2_SetInput2(self, *args)
SetInput2(self, itkImageUC2 input)
625941ed23e79379d52eea83
def getTWOTCodeFromLexiconCode( self, key ): <NEW_LINE> <INDENT> keyDigits = key[1:] <NEW_LINE> if key in self.IndexEntries['heb']: return self.IndexEntries['heb'][key][6] <NEW_LINE> if key in self.IndexEntries['arc']: return self.IndexEntries['arc'][key][6]
The key is a three letter code like 'aac'. Returns a BDB code, e.g., '4a'
625941ed236d856c2ad44d08
def compareTo(s1, s2): <NEW_LINE> <INDENT> if s1 == '' and s2 == '': <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> elif ord(s1[0]) > ord(s2[0]): <NEW_LINE> <INDENT> return 0 + ord(s1[0]) <NEW_LINE> <DEDENT> elif ord(s1[0]) < ord(s2[0]): <NEW_LINE> <INDENT> return 0 - ord(s2[0]) <NEW_LINE> <DEDENT> elif s1[1:2] == ''...
A function to compare two strings. Args: s1 (string): The first string. s2 (string): The second string. Returns: int: A value corresponding with the comparison of two strings. Returns a positive integer if s1 is greater than s2. Returns a negative integer if s1 is less than s2. ...
625941edb57a9660fec33db2
def testGetProgramViaGparent(self): <NEW_LINE> <INDENT> children = Program.objects.filter(gparent=self.page) <NEW_LINE> self.failIf(self.child not in children)
Get the Program via the Gparent Rule
625941ed4e696a04525c9973
def get_image_key(data_output): <NEW_LINE> <INDENT> return [ key for key in list(data_output.keys()) if "/" in key and key.split("/")[0] == "image" ][0]
Return its indices; otherwise, return empty list.
625941ede8904600ed9f245c
def p_comparison(p): <NEW_LINE> <INDENT> if len(p) == 2: <NEW_LINE> <INDENT> p[0] = p[1] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> p[0] = parse_model.BinaryExpression(p[1], p[2], p[3])
comparison : a_expr | a_expr cmp_operator a_expr
625941edab23a570cc2506ad
def add_syncaction_list(self, action, list_id=None, list_name=None): <NEW_LINE> <INDENT> if list_id is not None: <NEW_LINE> <INDENT> destination = '{{ContactList[%s]}}' % list_id <NEW_LINE> <DEDENT> elif list_name is not None: <NEW_LINE> <INDENT> url = self.bulk_base + '/{obj}/lists?q="name={list_name}"'.format( obj=se...
add sync action based on shared list ID/Name :param int list_id: shared list ID :param str list_name: shared list name
625941eddc8b845886cb5a5d
def session(s: socket): <NEW_LINE> <INDENT> s.send(b'SHELL') <NEW_LINE> while True: <NEW_LINE> <INDENT> ui = input(f"{s.getpeername()[0]}: ") <NEW_LINE> if ui[:5] == 'SEND ': <NEW_LINE> <INDENT> if ui[5:12] != 'TIMEOUT': <NEW_LINE> <INDENT> body = ui[5:] <NEW_LINE> packets = prepare_command(body) <NEW_LINE> <DEDENT> el...
:param s: A connected client
625941ed462c4b4f79d1dbf6
def __subscribeToCommands(self): <NEW_LINE> <INDENT> if self._options['org'] == "quickstart": <NEW_LINE> <INDENT> self.logger.warning("QuickStart applications do not support commands") <NEW_LINE> return False <NEW_LINE> <DEDENT> if not self.connectEvent.wait(timeout=10): <NEW_LINE> <INDENT> self.logger.warning("Unable ...
Subscribe to commands sent to this device.
625941ed10dbd63aa1bd30c8
def main( argv: Sequence[str] = sys.argv[1:], loop: Optional[asyncio.AbstractEventLoop] = None ) -> None: <NEW_LINE> <INDENT> args = docopt( __doc__, argv=argv, version=pkg_resources.require("rflink")[0].version ) <NEW_LINE> level = logging.ERROR <NEW_LINE> if args["-v"]: <NEW_LINE> <INDENT> level = logging.INFO <NEW_L...
Parse argument and setup main program loop.
625941ed26238365f5f0f39c
def do_pivot(self, entering, leaving): <NEW_LINE> <INDENT> entering_row = self.nonbasic.index(entering) <NEW_LINE> leaving_row = self.basic.index(leaving) <NEW_LINE> self.nonbasic[entering_row] = leaving <NEW_LINE> self.basic[leaving_row] = entering <NEW_LINE> self.gauss_jordan(leaving_row + 1, entering) <NEW_LINE> sel...
Apply the pivot transformation on the tableau. entering: Variable which will enter the basis. leaving: Variable which will leave the basis.
625941ed5fdd1c0f98dc075c
def get_task_functions(tasknames): <NEW_LINE> <INDENT> task_fns = [] <NEW_LINE> for task_name in tasknames: <NEW_LINE> <INDENT> task_func = getattr(tasks, 'do_%s' % task_name, None) <NEW_LINE> if not task_func or not type(task_func) is types.FunctionType: <NEW_LINE> <INDENT> logging.error("Task name '%s' is invalid.", ...
Given a list of task names, return a list of corresponding functions. Raises ValueError if an approriately named function can't be found. :param tasknames: A list of task names. :type tasknames: list(str) :return: A list of functions. :rtype: list(type.FunctionType)
625941ed566aa707497f4a88
def load(self): <NEW_LINE> <INDENT> item = self.table.get_item(session_key = self.session_key, consistent = getattr(settings, 'DYNAMODB_SESSIONS_ALWAYS_CONSISTENT', False)) <NEW_LINE> try: <NEW_LINE> <INDENT> if not item.items(): <NEW_LINE> <INDENT> logger.info("No items with this session key, creating new") <NEW_LINE>...
Get session data from DynamoDB, runs it through the session data de-coder (base64->dict), sets ``self.session``. :rtype: dict :returns: The de-coded session data, as a dict.
625941ed3c8af77a43ae3ccd
def __init__(self, database, inspect_parser, query_parser, aggressive=False, **kwargs): <NEW_LINE> <INDENT> super().__init__(**kwargs) <NEW_LINE> self.db = database <NEW_LINE> self.inspect = inspect_parser <NEW_LINE> self.query = query_parser <NEW_LINE> self.aggressive = aggressive
Create a new `NEOShell`. Creating this object doesn't start the session - for that, use `.cmdloop()`. :param database: The `NEODatabase` containing data on NEOs and their close approaches. :param inspect_parser: The subparser for the `inspect` subcommand. :param query_parser: The subparser for the `query` subcommand....
625941ed4e696a04525c9974
def inherits_from(obj, a_class): <NEW_LINE> <INDENT> if issubclass(type(obj), a_class) and type(obj) != a_class: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False
inherits from func
625941ed187af65679ca5646
def echo_udp(): <NEW_LINE> <INDENT> usock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) <NEW_LINE> usock.bind(('0.0.0.0',0)) <NEW_LINE> port = usock.getsockname()[1] <NEW_LINE> def serve(): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> data,addr=usock.recvfrom(2048) <NEW_LINE> if not data: <NEW_LINE> <INDENT>...
spawn a udp server, bind to a local port, receive data, echo data back to client, return port the socket is receiving on
625941ed30dc7b7665901e86
def sign(self): <NEW_LINE> <INDENT> print("sign {}".format(self.uid)) <NEW_LINE> data = self._uid_data() <NEW_LINE> api = self._genapi(king_daily_sign) <NEW_LINE> self._post(api, self.headers, data) <NEW_LINE> print("收集签到的金币 {}".format(self.uid)) <NEW_LINE> api = self._genapi(king_daily_luckydraw) <NEW_LINE> return sel...
每小时签到并收集金币
625941ed57b8e32f524839c5
def _sync(self): <NEW_LINE> <INDENT> self._client.update() <NEW_LINE> def identify_device(device): <NEW_LINE> <INDENT> from tellduslive import (DIM, UP, TURNON) <NEW_LINE> if device.methods & DIM: <NEW_LINE> <INDENT> return 'light' <NEW_LINE> <DEDENT> elif device.methods & UP: <NEW_LINE> <INDENT> return 'cover' <NEW_LI...
Update local list of devices.
625941edd99f1b3c44c67aab
def override_variables_binds(variables, new_mapping): <NEW_LINE> <INDENT> if isinstance(variables, list): <NEW_LINE> <INDENT> variables_ordered_dict = convert_to_order_dict(variables) <NEW_LINE> <DEDENT> elif isinstance(variables, (OrderedDict, dict)): <NEW_LINE> <INDENT> variables_ordered_dict = variables <NEW_LINE> <...
convert variables in testcase to ordered mapping, with new_mapping overrided
625941ed44b2445a339325b8
def dist2(self,other): <NEW_LINE> <INDENT> return (self-other).norm2()
Computes the squared distance between self and other.
625941ed7c178a314d6ef98e
def CalculateFileStorageDir(disk_type, cfg, instance_name, file_storage_dir=None): <NEW_LINE> <INDENT> instance_file_storage_dir = None <NEW_LINE> if disk_type in constants.DTS_FILEBASED: <NEW_LINE> <INDENT> joinargs = [] <NEW_LINE> cfg_storage = None <NEW_LINE> if disk_type == constants.DT_FILE: <NEW_LINE> <INDENT> cf...
Calculate final instance file storage dir. @type disk_type: disk template @param disk_type: L{constants.DT_FILE}, L{constants.DT_SHARED_FILE}, or L{constants.DT_GLUSTER} @type cfg: ConfigWriter @param cfg: the configuration that is to be used. @type file_storage_dir: path @param file_storage_dir: th...
625941ed6e29344779a62b37
def setAlbum(self, album): <NEW_LINE> <INDENT> self.album = album
Función modificá el album de la rola.
625941ed9c8ee82313fbbc9d
def save_user(self, root_pass, username, user_pass, home, shell): <NEW_LINE> <INDENT> self.ks = [] <NEW_LINE> print() <NEW_LINE> if root_pass: <NEW_LINE> <INDENT> root_pass = self.encrypt_passwd(root_pass) <NEW_LINE> root = 'rootpw --iscrypted ' + root_pass <NEW_LINE> self.ks.append(root) <NEW_LINE> self.save_section('...
Save user section.
625941ed66656f66f7cbc6d3
def update_other_state(self): <NEW_LINE> <INDENT> if vistrails.core.system.systemType in ['Darwin']: <NEW_LINE> <INDENT> self._use_metal_style_cb.setChecked( self._configuration.check('useMacBrushedMetalStyle'))
update_state(configuration: VistrailConfiguration) -> None Update the dialog state based on a new configuration
625941ed7cff6e4e81117eac
def test_prepends_filename(self): <NEW_LINE> <INDENT> contains_filename = re.compile('^filename') <NEW_LINE> self.are_all_matches(contains_filename)
ensures that the filename is prepended to each line emitted
625941ed5166f23b2e1a567f
def download_progress_callback(block_num, block_size, expected_size): <NEW_LINE> <INDENT> total_blocks = int(math.ceil(expected_size / block_size)) <NEW_LINE> progress_increment = int(math.ceil(total_blocks / 100)) <NEW_LINE> if block_num % progress_increment == 0: <NEW_LINE> <INDENT> print(".", end='', flush=False) <N...
Callback for urllib.urlretrieve which prints a dot for every percent of a file downloaded
625941ed7c178a314d6ef98f
def get_state_count(data): <NEW_LINE> <INDENT> state_count = {} <NEW_LINE> for index in list(data.index): <NEW_LINE> <INDENT> if index % 1000 == 0: <NEW_LINE> <INDENT> print("processing at:", index) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> point = Point(data.loc[index, "lng"], data.loc[index, "lat"]) <NEW_LINE> for...
Get state widgets from a single process
625941ed56b00c62f0f14b83
def list_by_subscription( self, get_deleted: Optional[bool] = None, **kwargs: Any ) -> AsyncIterable["_models.TestBaseAccountListResult"]: <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } <NEW_LINE> error_ma...
Lists all the Test Base Accounts in a subscription. This API is required by ARM guidelines. :param get_deleted: The flag indicating if we need to include the Test Base Accounts which were soft deleted before. :type get_deleted: bool :keyword callable cls: A custom type or function that will be passed the direct respo...
625941ed7047854f462a192a
def layoutToPos(lpos): <NEW_LINE> <INDENT> return (lpos[0]*MIN_WALL_SIZE,lpos[1]*MIN_WALL_SIZE)
Returns the center position associated with the grid spot x, y
625941ed435de62698dfe174
def train(self, documents): <NEW_LINE> <INDENT> self.class_prior = defaultdict(lambda : 0.0) <NEW_LINE> self.word_class_prob = defaultdict(lambda : defaultdict(lambda : 0.0)) <NEW_LINE> self.total_docs = 0.0 <NEW_LINE> self.class_no_of_docs = defaultdict(lambda : 0) <NEW_LINE> all_labels = {'spam','ham'} <NEW_LINE> cla...
Given a list of labeled Document objects, compute the class priors and word conditional probabilities, following Figure 13.2 of your book. Store these as instance variables, to be used by the classify method subsequently. Params: documents...A list of training Documents. Returns: Nothing.
625941ed004d5f362079a856
def pc_output_buffers_full_var(self, *args): <NEW_LINE> <INDENT> return _spacegrant_swig.hdlc_framer_sptr_pc_output_buffers_full_var(self, *args)
pc_output_buffers_full_var(hdlc_framer_sptr self, int which) -> float pc_output_buffers_full_var(hdlc_framer_sptr self) -> pmt_vector_float
625941eda05bb46b383ecd43
@pytest.fixture(scope="module") <NEW_LINE> def topology_with_tls(topology_m2): <NEW_LINE> <INDENT> [i.enable_tls() for i in topology_m2] <NEW_LINE> repl = ReplicationManager(DEFAULT_SUFFIX) <NEW_LINE> repl.test_replication(topology_m2.ms['supplier1'], topology_m2.ms['supplier2']) <NEW_LINE> return topology_m2
Enable TLS on all suppliers
625941ed8a349b6b435e8699
def testTrialEndedEarly2(self): <NEW_LINE> <INDENT> stats = self.default_statistics() <NEW_LINE> trial_count = stats[str(0)]["n"] + stats[str(1)]["n"] <NEW_LINE> sched, mock_runner = self.schedulerSetup(trial_count) <NEW_LINE> trials = sched._state["bracket"].current_trials() <NEW_LINE> for t in trials[:-1]: <NEW_LINE>...
Check successive halving happened even when last trial failed
625941ed56b00c62f0f14b84
def tokenize_posts(table=None, forum=None, start_time=None, end_time=None): <NEW_LINE> <INDENT> _, session = get_mysql_session() <NEW_LINE> Post = table or get_post_db(forum) <NEW_LINE> posts = Post.__table__ <NEW_LINE> engine, session = get_mysql_session() <NEW_LINE> tokenize = StemTokenizer(stem=False) <NEW_LINE> if ...
Convert the raw_text for every one of a forum's comments to list of tokens. Save as 'tokens' column in database. This function processes 30 days of posts at a time.
625941ed10dbd63aa1bd30c9
def _parse_grid(self, grid): <NEW_LINE> <INDENT> values = dict((s, self.digits) for s in self.squares) <NEW_LINE> for s, d in self.grid_values(grid).items(): <NEW_LINE> <INDENT> if d in self.digits and not self._assign(values, s, d): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> return values
convert grid to a dict of possible values, {square: digits}, or return False if a contradiction is detected.
625941ed45492302aab5e7f0
@when("I reset the state") <NEW_LINE> def step_reset_state(context: dict) -> None: <NEW_LINE> <INDENT> context.initial_state.clear()
Reset the Current State. This step will reset the current state.
625941ed2c8b7c6e89b35ce3
def get_bbox_lims(bbox): <NEW_LINE> <INDENT> p0 = bbox.min <NEW_LINE> p1 = bbox.max <NEW_LINE> return (p0[0], p1[0]), (p0[1], p1[1])
Returns the boundaries of the X and Y intervals of a C{Bbox}.
625941ed5fcc89381b1e1bea
def end_main_slideshow(self): <NEW_LINE> <INDENT> self.presentation.end()
End the main slideshow.
625941ed925a0f43d254a3a3
def testCircuitCircuitTermination(self): <NEW_LINE> <INDENT> pass
Test CircuitCircuitTermination
625941ed4527f215b584c979
def scan(self, quiet=False): <NEW_LINE> <INDENT> res = None <NEW_LINE> while not res or res.text == "": <NEW_LINE> <INDENT> if not quiet: <NEW_LINE> <INDENT> LOGGER.info("func=%s", self.current_pos) <NEW_LINE> <DEDENT> res = self.modem.xml_getter(self.current_pos, {}) <NEW_LINE> if res.text == "": <NEW_LINE> <INDENT> i...
Scan the modem for functions. This iterates of the function calls
625941ed50812a4eaa59c843
def format_item(self, client): <NEW_LINE> <INDENT> return unicode(client)
the display of a currently selected object in the area below the search box. html is OK
625941ed15baa723493c44a1
def __init__(self, lat, lon): <NEW_LINE> <INDENT> self.cont = 0 <NEW_LINE> self.points = [] <NEW_LINE> self.lat = lat <NEW_LINE> self.lon = lon <NEW_LINE> self.lock = False
Constructor :param: lat: Latitude :type lat: float :param: lon: Longitude :type lon: float
625941ed4f6381625f114f62
def kmeans(points, k, centers=None, tolerance=1, max_iterations=0): <NEW_LINE> <INDENT> return _kmeans(points=points, k=k, centers=centers, tolerance=tolerance, max_iterations=max_iterations)
Return a list of *k* centers (means). Initial centers are optional. :param points: (values, weight) tuples to find centers of. value is a list of integer values. :type points: list :param k: number of centers to calculate :type k: int :param centers: initial centers, leave blank to randomly select :type cen...
625941ed1f037a2d8b946724
def boss_coming(func): <NEW_LINE> <INDENT> @wraps(func) <NEW_LINE> def wrapper(): <NEW_LINE> <INDENT> result = func() <NEW_LINE> result += ' is coming!' <NEW_LINE> return result <NEW_LINE> <DEDENT> return wrapper
Decorator function
625941ed4a966d76dd55153c
def test_decapsulation_of_non_encapsulated_data(self): <NEW_LINE> <INDENT> data = bytes([0, 1, 2, 3]) <NEW_LINE> rx_msg = msg.ApiMsg(data, msg_format="encapsulated") <NEW_LINE> self.assertFalse(rx_msg.decapsulate())
Try to decapsulate a non-encapsulated data object
625941edeab8aa0e5d26e081
def test_check_status_exclude_list(self): <NEW_LINE> <INDENT> self.assertTrue(self.tester.check_status( ["private", "waiting_approval"], exclude=True)) <NEW_LINE> self.assertTrue(self.tester.check_status( ["private", "waiting_approval"], exclude=True, conn_handler=self.conn_handler)) <NEW_LINE> self.assertFalse(self.te...
check_status work passing a list of status and the exclude flag
625941ed15fb5d323cde103f
@noerror <NEW_LINE> def handle_101(response, exc=None): <NEW_LINE> <INDENT> if response.status_code == 101: <NEW_LINE> <INDENT> connection = response.connection <NEW_LINE> request = response._request <NEW_LINE> handler = request.websocket_handler <NEW_LINE> if not handler: <NEW_LINE> <INDENT> handler = WS() <NEW_LINE> ...
Websocket upgrade as ``on_headers`` event.
625941ed99cbb53fe679310c
def parse_item(self, response): <NEW_LINE> <INDENT> item = DoubanItem() <NEW_LINE> item['number'] = response.xpath('//div[@class="top250"]/span[@class="top250-no"]/text()').extract()[0].split('.')[-1] <NEW_LINE> item['movie'] = response.xpath('//h1/span[@property="v:itemreviewed"]/text()').extract()[0].split(' ')[0] <N...
从从详情页响应文件中提出需要的信息, 放入管道中待处理
625941ed8c3a8732951588e8
def basic_block(filters, stage, block, transition_strides=(1, 1), dilation_rate=(1, 1), is_first_block_of_first_layer=False, dropout=None, residual_unit=_bn_relu_conv): <NEW_LINE> <INDENT> def f(input_features): <NEW_LINE> <INDENT> conv_name_base, bn_name_base = _block_name_base(stage, block) <NEW_LINE> if is_first_blo...
Basic 3 X 3 convolution blocks for use on resnets with layers <= 34. Follows improved proposed scheme in http://arxiv.org/pdf/1603.05027v2.pdf
625941ed004d5f362079a857
def _get_child(self): <NEW_LINE> <INDENT> if 'child' not in self._params: <NEW_LINE> <INDENT> raise Ad5248Error('getting child address') <NEW_LINE> <DEDENT> child = int(self._params['child'], 0) <NEW_LINE> return child
Check and return child param. Returns: child: 7-bit i2c address.
625941ed99fddb7c1c9de8b5
def read_sudoku(file): <NEW_LINE> <INDENT> stream = open(file) <NEW_LINE> data = stream.readlines() <NEW_LINE> stream.close() <NEW_LINE> return eval("".join(data))
Reads and returns in a Sudoku problem from a file.
625941ed099cdd3c635f1180
def make_database_dump_filename(dump_path, name, hostname=None): <NEW_LINE> <INDENT> if os.path.sep in name: <NEW_LINE> <INDENT> raise ValueError('Invalid database name {}'.format(name)) <NEW_LINE> <DEDENT> return os.path.join(os.path.expanduser(dump_path), hostname or 'localhost', name)
Based on the given dump directory path, database name, and hostname, return a filename to use for the database dump. The hostname defaults to localhost. Raise ValueError if the database name is invalid.
625941ed63f4b57ef0001631
def do_redo(self, args): <NEW_LINE> <INDENT> idx = int(args) <NEW_LINE> cmdline = None <NEW_LINE> cnt = 1 <NEW_LINE> try: <NEW_LINE> <INDENT> for line in open(self.hist_file): <NEW_LINE> <INDENT> if cnt == idx: <NEW_LINE> <INDENT> cmdline = line.strip() <NEW_LINE> break <NEW_LINE> <DEDENT> cnt += 1 <NEW_LINE> <DEDENT> ...
Execute command of index of history. spp > redo 5 # exec 5th command in the history
625941eda79ad161976cc66d
def sendConnectionConfirm(self): <NEW_LINE> <INDENT> message = ServerConnectionConfirm() <NEW_LINE> message.protocolNeg.code.value = NegociationType.TYPE_RDP_NEG_RSP <NEW_LINE> message.protocolNeg.selectedProtocol.value = self._selectedProtocol <NEW_LINE> self._transport.send(message) <NEW_LINE> self._transport.transpo...
Write connection confirm message Start TLS connection Next state is recvData @see : http://msdn.microsoft.com/en-us/library/cc240501.aspx
625941ed23849d37ff7b35b2
def global_scope(self): <NEW_LINE> <INDENT> scope = ctypes.c_long(0) <NEW_LINE> self._call(const.GET_, const.ATTR_SCOPE_, ctypes.byref(scope)) <NEW_LINE> if scope.value == const.GLOBAL_SCOPE.value: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> elif scope.value == const.VARIABLE_SCOPE.value: <NEW_LINE> <INDENT> re...
Determine scope of this attribute. Returns ======= out : bool True if global (i.e. gAttr), False if zAttr
625941edbe7bc26dc91cdb1d
def update(self, dt): <NEW_LINE> <INDENT> self.now = pg.time.get_ticks() <NEW_LINE> if self.state_machine.done: <NEW_LINE> <INDENT> self.done = True <NEW_LINE> <DEDENT> machine_args = self.render_surf, self.keys, self.now, dt, self.scale <NEW_LINE> self.state_machine.update(*machine_args)
Checks if the state_machine is done and then updates the state_machine with the appropiate arguments.
625941ed9b70327d1c4e12ff
def set_min_peers(self,value): <NEW_LINE> <INDENT> self.dlconfig['min_peers'] = value
Minimum number of peers to not do rerequesting. @param value A number of peers.
625941ed8da39b475bd654a2
def has_header(self, header_name): <NEW_LINE> <INDENT> return header_name in self.headers
return true if the header is set
625941eda8370b7717052dc5
def GetBasicMap(self): <NEW_LINE> <INDENT> return super(IGPUtilities2, self).GetBasicMap()
Method IGPUtilities2.GetBasicMap OUTPUT ppMap : IBasicMap**
625941edaad79263cf390f71
def post_blacklist_item(self): <NEW_LINE> <INDENT> blacklistbase = blacklist.BlacklistBase().lbbase <NEW_LINE> data = self.request.params['item'] <NEW_LINE> blacklist_obj = blacklist.Blacklist( item=data ) <NEW_LINE> id_doc = blacklist_obj.create_item() <NEW_LINE> session = self.request.session <NEW_LINE> session['relo...
Post doc blacklist
625941edd6c5a10208144577
def twoSum(self, nums, target): <NEW_LINE> <INDENT> index_dict = dict() <NEW_LINE> for i in range(len(nums)): <NEW_LINE> <INDENT> comp_num = target - nums[i] <NEW_LINE> if comp_num in index_dict: <NEW_LINE> <INDENT> return [index_dict[comp_num], i] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> index_dict[nums[i]] = i
:type nums: List[int] :type target: int :rtype: List[int]
625941ed7d847024c06be7e8
def classification_loss(logits, labels, weights): <NEW_LINE> <INDENT> inner_dim = logits.get_shape().as_list()[-1] <NEW_LINE> with tf.name_scope('classifier_loss'): <NEW_LINE> <INDENT> if inner_dim == 1: <NEW_LINE> <INDENT> loss = tf.nn.sigmoid_cross_entropy_with_logits( logits=tf.squeeze(logits), labels=tf.cast(labels...
Computes cross entropy loss between logits and labels. Args: logits: 2-D [timesteps*batch_size, m] float tensor, where m=1 if num_classes=2, otherwise m=num_classes. labels: 1-D [timesteps*batch_size] integer tensor. weights: 1-D [timesteps*batch_size] float tensor. Returns: Loss scalar of type float.
625941edbaa26c4b54cb1642
def get_initial(self): <NEW_LINE> <INDENT> initial = super().get_initial() <NEW_LINE> initial['contact_type'] = '0' <NEW_LINE> initial['operator'] = self.request.user <NEW_LINE> if 'contact_info_query' in self.request.session: <NEW_LINE> <INDENT> query = self.request.session['contact_info_query'] <NEW_LINE> initial['vi...
デフォルト値の設定
625941ed76d4e153a657f05a
def t_NAME(self, t): <NEW_LINE> <INDENT> t.type = self.reserved.get(t.value, 'NAME') <NEW_LINE> return t
[A-Za-z_][A-za-z0-9_']*
625941ed091ae3566866747d
def targetting(self, event=0): <NEW_LINE> <INDENT> if event: <NEW_LINE> <INDENT> self.an = math.atan((event.y - 500) / (event.x - 20)) <NEW_LINE> <DEDENT> if self.f2_on: <NEW_LINE> <INDENT> canv.itemconfig(self.id, fill='red') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> canv.itemconfig(self.id, fill='black') <NEW_LIN...
Прицеливание. Зависит от положения мыши.
625941ed99fddb7c1c9de8b6