code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def curAncestralGen(self) -> "size_t": <NEW_LINE> <INDENT> return _simuPOP_std.Population_curAncestralGen(self) | Obsolete or undocumented function. | 625941df16aa5153ce3627d5 |
def __init__(self): <NEW_LINE> <INDENT> self.__get_master_key() <NEW_LINE> self.__config = Config() <NEW_LINE> self.__name = bytes.fromhex(self.__config.uhost_name) <NEW_LINE> self.__inbound_queue = queue.Queue() <NEW_LINE> self.__outbound_queue = queue.Queue() <NEW_LINE> self.database = DataBaseConnection(init_db=True... | Initialization | 625941df76e4537e8c3519d2 |
def as_set_partition(self, a_list): <NEW_LINE> <INDENT> n_list = max(a_list[1:] + [1]) <NEW_LINE> n_data = self.n_data <NEW_LINE> data = self.data <NEW_LINE> partition = [[] for _ in range(n_list)] <NEW_LINE> for i in range(n_data): <NEW_LINE> <INDENT> partition[a_list[i + 1] - 1].append(data[i]) <NEW_LINE> <DEDENT> re... | Transform a restricted growth function into a partition | 625941df7c178a314d6ef7c1 |
def set_x_slot(self, slot): <NEW_LINE> <INDENT> idx = self.slot_to_index(slot) <NEW_LINE> self.set_x(idx[0], idx[1]) | Convenience method for 'x', using slot (e.g. in a 3x3 grid slots are numbered from 1 to 9 (left to right)
:param slot: the slot number for a grid
:return: | 625941dfb545ff76a8914172 |
@main.command() <NEW_LINE> @click.pass_context <NEW_LINE> def export_expense(ctx): <NEW_LINE> <INDENT> shop = reduce(operator.or_, [Q(shop__contains=i.name) for i in JcbShop.objects.all()]) <NEW_LINE> mapper = dict((v, k) for k, v in JcbReceipt.get_fields_map().items()) <NEW_LINE> def _patch(instance, name): <NEW_LINE>... | Expense Paid JCB | 625941df3cc13d1c6d3c76d6 |
def capture_screenshots(case_name, page): <NEW_LINE> <INDENT> global driver <NEW_LINE> file_name = case_name.split("/")[-1] <NEW_LINE> if RunConfig.NEW_REPORT is None: <NEW_LINE> <INDENT> raise NameError('没有初始化测试报告目录') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> image_dir = os.path.join(RunConfig.NEW_REPORT, "image",... | 配置用例失败截图路径
:param case_name: 用例名
:return: | 625941df94891a1f4081be07 |
def inject_nulls(data: Mapping, field_names) -> dict: <NEW_LINE> <INDENT> record = dict() <NEW_LINE> for field in field_names: <NEW_LINE> <INDENT> record[field] = data.get(field, None) <NEW_LINE> <DEDENT> return record | Insert None as value for missing fields. | 625941df7cff6e4e81117ce2 |
def hooks(self): <NEW_LINE> <INDENT> return self._session.find_many(Hook) | :rtype: list(:class:`.Hook`)
:returns:
Returns list of existing hooks that user have access.
.. note::
This request always needs to be authenticated. | 625941df507cdc57c630703f |
def iss_track_plot(lon, lat, right, left): <NEW_LINE> <INDENT> fig = plt.figure(figsize=(12, 6)) <NEW_LINE> ax = plt.axes(projection=ccrs.PlateCarree()) <NEW_LINE> ax.stock_img() <NEW_LINE> plt.plot(lon, lat, 'k', transform=ccrs.Geodetic()) <NEW_LINE> qw = plt.fill(right, left, facecolor='b', alpha=0.45, transform=ccrs... | Plotting the ISS track and DESIS swath
Parameters:
lon: ISS longitude
lat: ISS latitude
right: Latitude-Longitude of the DESIS right swath
left: Latitude-Longitude of the DESIS left swath
Returns:
plt: Matplotlib figure handle | 625941df56ac1b37e6264527 |
def get_all_hosts(self): <NEW_LINE> <INDENT> return self.server.get_hosts() | Returns a dictionary of the existing hosts keys are their names
and values their ManagedObjectReference object. | 625941df656771135c3ebbcf |
def __str__(self): <NEW_LINE> <INDENT> return 'Level: {}, Value: {}, Currency: {}'.format(self.level, self.value, self.type) | Return price. | 625941dffb3f5b602dac39f4 |
def test_save_data_with_saturated_fat_serving(self): <NEW_LINE> <INDENT> mock_result = {"products": [ { "categories": "category", "product_name_fr": "name", "brands": "brand", "quantity": "quantity", "nutrition_grade_fr": "e", "url": "url", "code": "code", "nutriments": { "saturated-fat_serving": "saturated-fat_serving... | Verify that an item is created in database with a nutritional
value saturated fat serving field if the field saturated fat serving
is available in API response | 625941df7d43ff24873a2fff |
def __init__(self, num_particles, num_generations, max_speed=None, phi1=1.5, phi2=2.0, **kwargs): <NEW_LINE> <INDENT> assert all([len(v) == 2 and v[0] <= v[1] for v in kwargs.values()]), 'kwargs.values() are not [lb, ub] pairs' <NEW_LINE> self._bounds = kwargs <NEW_LINE> self._num_particles = num_particles <NEW_LINE> s... | Initializes a PSO solver.
:param num_particles: number of particles to use
:type num_particles: int
:param num_generations: number of generations to use
:type num_generations: int
:param max_speed: maximum velocity of each particle
:type max_speed: float or None
:param phi1: parameter used in updating position based o... | 625941df96565a6dacc8fa27 |
def getAdjustedCheckInDate(self): <NEW_LINE> <INDENT> pass | If the user payed | 625941df2c8b7c6e89b35b1b |
def traceback(M,seq1,seq2,i,j,Parameters): <NEW_LINE> <INDENT> alignedseq1 = "" <NEW_LINE> alignedseq2 = "" <NEW_LINE> while M[i][j] != 0: <NEW_LINE> <INDENT> if j==0 or (M[i][j] == M[i-1][j] + Parameters.gap): <NEW_LINE> <INDENT> alignedseq2 = alignedseq2 + "-" <NEW_LINE> alignedseq1 = alignedseq1 + seq1[i-1] <NEW_LIN... | Esta funcao encontra o melhor aliamente seguindo o algoritmo a seguir:
0- verificar se a celula corrente esta na borda
1- obter os n vizinhos
2- obter o valor da celula corrente
3- Usar a formula
a) M[i][j-1] + Parameters.gap == atual ?
b) M[i-1][j-1] + Parameters.score(seq1[i-1],... | 625941df377c676e91272504 |
def test_dir_exist_with_w2(self): <NEW_LINE> <INDENT> os.chmod(self.path_dir1, self.base_perm1) <NEW_LINE> with gen_libs.no_std_out(): <NEW_LINE> <INDENT> self.assertFalse( arg_parser.arg_dir_chk(self.args_array2, self.dir_perms_chk4)) <NEW_LINE> <DEDENT> os.chmod(self.path_dir1, self.base_perm7) | Function: test_dir_exist_with_w2
Description: Test with directory and with no write access.
Arguments: | 625941dfde87d2750b8600f2 |
def deserialize_without_type(self, reader: serialization.BinaryReader) -> None: <NEW_LINE> <INDENT> self.start_height = reader.read_uint32() | Deserialize the object from a binary stream without deserializing the base class `type` property.
Args:
reader: instance. | 625941dfaad79263cf390da3 |
@sbuild.parse <NEW_LINE> def movh(reg, imm16): <NEW_LINE> <INDENT> reg = imm16.zeroExtend(32) << i32(16) | MOVH - Copy a shifted imm16 to a register. | 625941df07d97122c4178bef |
def test_get_page_query_string(self): <NEW_LINE> <INDENT> resp = self.client.get( reverse("meupet:pet_list", args=[self.status_group.slug, self.pet.kind.slug]), {"page": 1} ) <NEW_LINE> self.assertContains(resp, self.pet.name) | Should return the page informed in the query string | 625941dfd7e4931a7ee9e27c |
def test_proxy_timelock_early(chain, web3, customer, customer_2, team_multisig, proxy_buyer, crowdsale, token, unlock_time): <NEW_LINE> <INDENT> assert proxy_buyer.functions.getState().call() == 1 <NEW_LINE> assert proxy_buyer.functions.isPresale().call() == True <NEW_LINE> proxy_buyer.functions.setTimeLock(unlock_time... | Try to claim before timeLock has passed. | 625941dfd268445f265b51cb |
def expected_energy_term(self, state, average, state_below, average_below): <NEW_LINE> <INDENT> self.input_space.validate(state_below) <NEW_LINE> if self.requires_reformat: <NEW_LINE> <INDENT> if not isinstance(state_below, tuple): <NEW_LINE> <INDENT> for sb in get_debug_values(state_below): <NEW_LINE> <INDENT> if sb.s... | .. todo::
WRITEME | 625941df3539df3088e2e6a8 |
def __setup_bands_label__(self, frame: object): <NEW_LINE> <INDENT> self.uic['bands'] = {} <NEW_LINE> chosen_bands = self.listener.get_item('bands') <NEW_LINE> bands_frame = tk.LabelFrame(frame, borderwidth=1, text="Analysed Bands", bg=ACCENT_COLOR, foreground=TEXT_COLOR, font=(None, HEADER_SIZE), highlightbackground=T... | Adds the Bands label components to the UI.
Args:
- frame: component to add labels to. | 625941dfa4f1c619b28b038f |
def process_mnistm(): <NEW_LINE> <INDENT> data = np.load('../data/MNIST_M/mnistm_data.pkl', allow_pickle=True) <NEW_LINE> train_img = data['train'] <NEW_LINE> train_tar = data['train_label'] <NEW_LINE> valid_img = data['valid'] <NEW_LINE> valid_tar = data['valid_label'] <NEW_LINE> test_img = data['test'] <NEW_LINE> tes... | (56000, 28, 28, 3)
(56000,)
(14000, 28, 28, 3)
(14000,)
:return: | 625941dfb830903b967e9c65 |
def show_suspicious_boards(self): <NEW_LINE> <INDENT> boards = set() <NEW_LINE> output_file = 'moveconfig.suspicious' <NEW_LINE> for slot in self.slots: <NEW_LINE> <INDENT> boards |= slot.get_suspicious_boards() <NEW_LINE> <DEDENT> if boards: <NEW_LINE> <INDENT> boards = '\n'.join(boards) + '\n' <NEW_LINE> msg = 'The f... | Display all boards (defconfigs) with possible misconversion. | 625941df3617ad0b5ed68253 |
def fetch_object(self, session, id): <NEW_LINE> <INDENT> raise NotImplementedError | Fetch and return an object. | 625941df67a9b606de4a8214 |
def __init__( self, **kwargs ): <NEW_LINE> <INDENT> super(DistanceScoringFunction, self).__init__(**kwargs) <NEW_LINE> self.type = 'distance' <NEW_LINE> self.parameters = kwargs['parameters'] | :keyword field_name: Required. The name of the field used as input to the scoring function.
:paramtype field_name: str
:keyword boost: Required. A multiplier for the raw score. Must be a positive number not equal
to 1.0.
:paramtype boost: float
:keyword interpolation: A value indicating how boosting will be interpolat... | 625941df66656f66f7cbc50a |
def __init__(self, *args): <NEW_LINE> <INDENT> this = _howto_swig.new_ofdm_carrier_allocator_cvc_sptr(*args) <NEW_LINE> try: self.this.append(this) <NEW_LINE> except: self.this = this | __init__(boost::shared_ptr<(gr::howto::ofdm_carrier_allocator_cvc)> self) -> ofdm_carrier_allocator_cvc_sptr
__init__(boost::shared_ptr<(gr::howto::ofdm_carrier_allocator_cvc)> self, ofdm_carrier_allocator_cvc p) -> ofdm_carrier_allocator_cvc_sptr | 625941dfadb09d7d5db6caea |
def unsubscribe_folder(self, folder): <NEW_LINE> <INDENT> typ, data = self._imap.unsubscribe(folder) <NEW_LINE> self._checkok('unsubscribe', typ, data) <NEW_LINE> return data | Unsubscribe a folder.
@param folder: Folder name to unsubscribe.
@return: Server response message. | 625941dfa79ad161976cc4a3 |
def removeElements(self, head, val): <NEW_LINE> <INDENT> ptr = head <NEW_LINE> h = pre = ListNode(0) <NEW_LINE> pre.next = ptr <NEW_LINE> while ptr: <NEW_LINE> <INDENT> if ptr.val == val: <NEW_LINE> <INDENT> pre.next = ptr.next <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> pre = ptr <NEW_LINE> <DEDENT> ptr = ptr.next <... | :type head: ListNode
:type val: int
:rtype: ListNode | 625941df66656f66f7cbc509 |
def collected_all_objects(self): <NEW_LINE> <INDENT> return self.objects == {} | Check if there is no objects left on the maze. | 625941df8c3a87329515871b |
def get_publisher(self, connection=None, exchange=None, exchange_type=None, **options): <NEW_LINE> <INDENT> exchange = self.exchange if exchange is None else exchange <NEW_LINE> if exchange_type is None: <NEW_LINE> <INDENT> exchange_type = self.exchange_type <NEW_LINE> <DEDENT> connection = connection or self.establish... | Deprecated method to get the task publisher (now called producer).
Should be replaced with :class:`kombu.Producer`:
.. code-block:: python
with app.connection_for_write() as conn:
with app.amqp.Producer(conn) as prod:
my_task.apply_async(producer=prod)
or even better is to use the :class... | 625941df7047854f462a1763 |
def clear_gateway(self): <NEW_LINE> <INDENT> self.gateway = None | Clear the currently set CrabGateway. | 625941df596a897236089e1a |
def updateMulti(self,**kargs): <NEW_LINE> <INDENT> for i in kargs: setattr(self,i,kargs[i]) <NEW_LINE> self.__init__() | Multi-argument update function. | 625941dfdd821e528d63b504 |
def shutDown(self): <NEW_LINE> <INDENT> for pwm_signal in self.pwm_signals: <NEW_LINE> <INDENT> pwm_signal.stop() <NEW_LINE> <DEDENT> GPIO.cleanup() <NEW_LINE> self.car_log.info("shutDown,angle=0") | 因为--del--回收机制不好用,采用自定义程序处理收尾工作 | 625941dfcb5e8a47e48b7e03 |
def p_clause_num_workers(t): <NEW_LINE> <INDENT> t[0] = ( ['num_threads(' + t[3] + ')'], {'num_workers':t[3]} ) | clause : NUM_WORKERS LPAREN INT RPAREN | 625941df3eb6a72ae02ec843 |
def find(self, rules): <NEW_LINE> <INDENT> for rule in rules: <NEW_LINE> <INDENT> if self == rule: <NEW_LINE> <INDENT> return rule <NEW_LINE> <DEDENT> <DEDENT> return None | Convenience method that finds the current Rule in a list.
| 625941df21bff66bcd684cac |
def __enter__(self): <NEW_LINE> <INDENT> self.workdir = tempfile.mkdtemp(prefix='aaltoasr', dir=self.args.tempdir) <NEW_LINE> return self | Make a working directory for a single execution. | 625941df32920d7e50b28530 |
def vgg4(**kwargs): <NEW_LINE> <INDENT> model = VGG_small(make_layers(cfg_small['A']), **kwargs) <NEW_LINE> return model | VGG 4-layer model (configuration_small "A") | 625941dfa8ecb033257d3429 |
def sample(self, step, state): <NEW_LINE> <INDENT> if step % self.istep == 0: <NEW_LINE> <INDENT> time = step * self.dt <NEW_LINE> data = numpy.mean(state[self.voi, :], axis=1)[:, numpy.newaxis, :] <NEW_LINE> return [time, data] | Records if integration step corresponds to sampling period. | 625941dfcad5886f8bd27336 |
def __init__(self, history_path): <NEW_LINE> <INDENT> self.history_path = history_path <NEW_LINE> self.connected = False <NEW_LINE> self.session = None | :param history_path: Path to database (created if
does not exist)
:type history_path: string | 625941df4c3428357757c683 |
@app.task <NEW_LINE> def fetch_data(): <NEW_LINE> <INDENT> apiurl = settings.DB_API_ENDPOINT <NEW_LINE> modes_url = "{0}modes".format(apiurl) <NEW_LINE> satellites_url = "{0}satellites".format(apiurl) <NEW_LINE> transmitters_url = "{0}transmitters".format(apiurl) <NEW_LINE> try: <NEW_LINE> <INDENT> modes = urllib2.urlo... | Task to fetch all data from DB | 625941df851cf427c661a869 |
def is_keyboard_prox(self, s, d): <NEW_LINE> <INDENT> d = self.keyboard_dist(s, d) <NEW_LINE> return d < 1.0 | Checks whether two words are close in terms of keys
:param s: character
:param d: character
:return: weight | 625941df4c3428357757c684 |
def get_years(page_soup): <NEW_LINE> <INDENT> years_td = page_soup.find_all('td', {'class': 'h_t'}) <NEW_LINE> logger.debug('"years_td" VAR is: %s' % years_td) <NEW_LINE> if years_td is not None: <NEW_LINE> <INDENT> years = [convert_to_number(td.text) for td in years_td] <NEW_LINE> logger.info('Lay danh sach cac nam th... | Lay danh sach cac nam hien co trong trang | 625941df1f5feb6acb0c4ea8 |
def _thread_read_serial(self, ser): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> while not self._is_terminated: <NEW_LINE> <INDENT> c = ser.read(1) <NEW_LINE> if len(c) == 0: <NEW_LINE> <INDENT> time.sleep(0.01) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._output_buf += c <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> ex... | Push the output of the given serial port into our output | 625941df0a366e3fb873eb7a |
def set_color_scheme(self, color_scheme: int) -> Response: <NEW_LINE> <INDENT> return self.set_info(color_scheme=color_scheme) | Sets color scheme
:param color_scheme: Id of new color scheme
:type color_scheme: str
:rtype: :class:`Response` | 625941df1b99ca400220ae10 |
def setInputToTaraInputForAllChannels(self, IOPin): <NEW_LINE> <INDENT> newDIOtype = bytearray([0x00, 0x00, 0x20]) <NEW_LINE> return self.setDIOtype(IOPin, newDIOtype, 0) | Setzt DIOtype für den angegeben IO Pin
Der gewaehlte IOPin muss im Vorfeld als Eingang (Input) konfiguriert werden. Wird dieser Eingang high, wird Tara für alle DMS-Eingaenge aufgerufen
:param IOPin: IOPin 1..16 (1.1 - 4.4)
:type IOPin: uint8
:return: AntwortErrorCode und AntwortErrorText
:rtype: liste | 625941df5fdd1c0f98dc0592 |
def parse_string(fileobj): <NEW_LINE> <INDENT> log = logging.getLogger(__name__) <NEW_LINE> indicator = fileobj.read(1) <NEW_LINE> if ord(indicator) == 0: <NEW_LINE> <INDENT> return "" <NEW_LINE> <DEDENT> elif ord(indicator) == 11: <NEW_LINE> <INDENT> uleb = parse_uleb128(fileobj) <NEW_LINE> s = fileobj.read(uleb).deco... | Get an OSU string from the file object
:param fileobj: The file object
:type fileobj: FileIO[bytes]
:return: The string | 625941df435de62698dfdfab |
def _read_data_chunk(self, file, data_objects, chunk_index): <NEW_LINE> <INDENT> raise NotImplementedError("Reading a single chunk is not implemented for interleaved data") | Not used for interleaved data, multiple chunks are read at once
| 625941df851cf427c661a86a |
def mungeForUri(x): <NEW_LINE> <INDENT> return alphaNumericOnly(asciiChars(x)).lower() | Take an arbitrary string and make it into something that can be used as a URI | 625941df29b78933be1e5a05 |
def write_request(self, service, characteristic, data, offset, withoutResponse): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.on_before_write(service, characteristic, unbufferize(data), offset, withoutResponse) <NEW_LINE> self.device_write(service, characteristic, data, offset, withoutResponse) <NEW_LINE> <DEDENT>... | Forward write request to device. | 625941df56b00c62f0f149b9 |
def test_cli_slice_invalid(sample): <NEW_LINE> <INDENT> runner = CliRunner() <NEW_LINE> input_file = sample("InAs_nosym.hdf5") <NEW_LINE> with tempfile.NamedTemporaryFile() as out_file: <NEW_LINE> <INDENT> with pytest.raises(IndexError): <NEW_LINE> <INDENT> runner.invoke( cli, ["slice", "-o", out_file.name, "-i", input... | Check that passing an invalid index to the 'slice' command raises
an error. | 625941df004d5f362079a68f |
def __GetConnection(self): <NEW_LINE> <INDENT> self.conn = httplib.HTTPConnection(BLIP_API_URL) <NEW_LINE> return self.conn | Returns fresh connection to Blip | 625941df167d2b6e31218ef2 |
def killall(app): <NEW_LINE> <INDENT> for pid in psutil.get_pid_list(): <NEW_LINE> <INDENT> p = psutil.Process(pid) <NEW_LINE> if app == p.name: <NEW_LINE> <INDENT> print('killing: ' + p.name) <NEW_LINE> os.kill(pid, signal.SIGKILL) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> r = re.compile('.*' + app + '.*', re.IGNO... | terminates all instances of an app | 625941df57b8e32f524837fb |
def _get_auth_tokens(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> auth_tokens = load_json(self._session_filepath) <NEW_LINE> return auth_tokens <NEW_LINE> <DEDENT> except HomeAssistantError as ex: <NEW_LINE> <INDENT> _LOGGER.warning( "Loading authentication tokens from file '%s' failed: %s", self._session_filepa... | Read sorted authentication tokens from disk.
Returns the auth_tokens dictionary. | 625941df3c8af77a43ae3b01 |
def utterance_remainder(self): <NEW_LINE> <INDENT> utt = normalize(self.data.get("utterance", "")) <NEW_LINE> if utt and "__tags__" in self.data: <NEW_LINE> <INDENT> for token in self.data["__tags__"]: <NEW_LINE> <INDENT> utt = utt.replace(token.get("key", ""), "") <NEW_LINE> <DEDENT> <DEDENT> return normalize(utt) | For intents get the portion not consumed by Adapt.
For example: if they say 'Turn on the family room light' and there are
entity matches for "turn on" and "light", then it will leave behind
" the family room " which is then normalized to "family room".
Returns:
str: Leftover words or None if not an utterance. | 625941dfc432627299f04fa6 |
def getFreeLinks(nisdon_query_link = 'http://www.nisdon.com/search/label/free?max-results=', max_query = 200): <NEW_LINE> <INDENT> full_link = '%s%d' %(nisdon_query_link, max_query) <NEW_LINE> br = mechanize.Browser(factory=mechanize.RobustFactory()) <NEW_LINE> br.set_handle_robots(False) <NEW_LINE> webpage = br.open(f... | Get a the list of classes and links | 625941df91af0d3eaac9bd79 |
def to_dict(self): <NEW_LINE> <INDENT> result = {} <NEW_LINE> for attr, _ in six.iteritems(self.swagger_types): <NEW_LINE> <INDENT> value = getattr(self, attr) <NEW_LINE> if isinstance(value, list): <NEW_LINE> <INDENT> result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) <NEW_LINE> <... | Returns the model properties as a dict | 625941dfe8904600ed9f228f |
def send_binary(self, bin_buf): <NEW_LINE> <INDENT> if not self._soc: <NEW_LINE> <INDENT> raise Exception("No socket") <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> self._soc.sendall(bin_buf) <NEW_LINE> <DEDENT> except Exception as e: <NEW_LINE> <INDENT> logger.warning("send failed, ex=%s", SolBase.extostr(e)) <NEW_LINE... | Send binary
:param bin_buf: str
:type bin_buf: str | 625941df97e22403b379d2f9 |
def _get_stack(self, directory, scope=None, write_access=False): <NEW_LINE> <INDENT> if scope is not None: <NEW_LINE> <INDENT> if scope == 'breezy': <NEW_LINE> <INDENT> return GlobalStack() <NEW_LINE> <DEDENT> elif scope == 'locations': <NEW_LINE> <INDENT> return LocationStack(directory) <NEW_LINE> <DEDENT> elif scope ... | Get the configuration stack specified by ``directory`` and ``scope``.
:param directory: Where the configurations are derived from.
:param scope: A specific config to start from.
:param write_access: Whether a write access to the stack will be
attempted. | 625941df76d4e153a657ee90 |
def jaccard_distance(s1, s2): <NEW_LINE> <INDENT> set1, set2 = set(s1), set(s2) <NEW_LINE> return 1 - len(set1 & set2) / len(set1 | set2) | jaccard distance
http://en.wikipedia.org/wiki/Jaccard_index
jaccard distance doesn't consider term frequency
0 means equal, and 1 totally different | 625941dfe64d504609d74b9e |
def text_norm_after_cut(word_list): <NEW_LINE> <INDENT> def remove_words(word_list, file_name=None, remove_wrd_list=None): <NEW_LINE> <INDENT> if file_name is not None: <NEW_LINE> <INDENT> dir_path = os.path.dirname(os.path.realpath(__file__)) <NEW_LINE> all_remove = open(os.path.join(dir_path, file_name), 'r').read().... | input is a word list, which is segmented by jieba | 625941df796e427e537b0926 |
def wait_while_selector(self, selector): <NEW_LINE> <INDENT> self.wait_for(lambda: not self.exists(selector), 'Element matching "%s" is still available' % selector) <NEW_LINE> return True, self._release_last_resources() | Waits until the selector no longer matches an element on the frame.
:param selector: The selector to wait for. | 625941df6fb2d068a760f400 |
def process(self, chan_bufs, buf_num): <NEW_LINE> <INDENT> pass | Process a list of channel buffers. | 625941df45492302aab5e625 |
def boto_do_retry(f): <NEW_LINE> <INDENT> for i in range(RETRY_ATTEMPTS): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> f() <NEW_LINE> return <NEW_LINE> <DEDENT> except ( client.exceptions.LimitExceededException, client.exceptions.ResourceInUseException ): <NEW_LINE> <INDENT> if i == (RETRY_ATTEMPTS - 1): <NEW_LINE> <IN... | Boto Client will throw errors while resources are updating.
Use this function to catch and retry those errors until the operation
succeeds. | 625941df4a966d76dd551370 |
def qof_session_get_error(*args): <NEW_LINE> <INDENT> return _gnucash_core_c.qof_session_get_error(*args) | qof_session_get_error(QofSession session) -> QofBackendError | 625941df0c0af96317bb8546 |
def test_post(self): <NEW_LINE> <INDENT> data = { 'name': "Robert'); DROP TABLE Students;--'", 'email': 'Bobby.Tables+327@xkcd.com', } <NEW_LINE> request = self.create_request('post', auth=True, data=data) <NEW_LINE> request.user.is_staff = True <NEW_LINE> response = self.view_class.as_view()(request) <NEW_LINE> self.a... | Users should be able to create. | 625941dfab23a570cc2504e3 |
def elapseTime(self, gameState): <NEW_LINE> <INDENT> newPosDist = util.Counter() <NEW_LINE> for p in self.legalPositions: <NEW_LINE> <INDENT> newPosDist[p] = 0 <NEW_LINE> <DEDENT> for oldPos in self.legalPositions: <NEW_LINE> <INDENT> trans = self.getPositionDistribution(self.setGhostPosition(gameState, oldPos)) <NEW_L... | Update self.beliefs in response to a time step passing from the current
state.
The transition model is not entirely stationary: it may depend on
Pacman's current position (e.g., for DirectionalGhost). However, this
is not a problem, as Pacman's current position is known.
In order to obtain the distribution over new ... | 625941df462c4b4f79d1da2e |
def warning(self, message): <NEW_LINE> <INDENT> self.logger.warning(str(self.header) + ' > ' + str(message)) | Warning with header | 625941dfa05bb46b383ecb7e |
def sort_by_match_type(match, sort_order): <NEW_LINE> <INDENT> idx = (match['sample_id'], match['protocol_no']) <NEW_LINE> if 'match_type' in match and match['match_type'] == 'variant': <NEW_LINE> <INDENT> sort_order[idx] = add_sort_value(sort_value=0, priority=1, sort_order_li=sort_order[idx]) <NEW_LINE> <DEDENT> elif... | Second highest priority sorting | 625941df15baa723493c42d6 |
def root_enabled_history(self, instance): <NEW_LINE> <INDENT> url = "/mgmt/instances/%s/root" % base.getid(instance) <NEW_LINE> resp, body = self.api.client.get(url) <NEW_LINE> if not body: <NEW_LINE> <INDENT> raise Exception("Call to " + url + " did not return a body.") <NEW_LINE> <DEDENT> return body['root_history'] | Get root access history of one instance. | 625941df0a50d4780f6671f3 |
def test_round_robin_cooperator_v_titfortat(self): <NEW_LINE> <INDENT> P1 = axelrod.Cooperator() <NEW_LINE> P2 = axelrod.TitForTat() <NEW_LINE> tournament = axelrod.Axelrod(P1, P2) <NEW_LINE> tournament.round_robin(turns=10) <NEW_LINE> self.assertEqual([(str(player), player.score) for player in sorted(tournament.player... | Test round robin: the cooperator does very well WITH tit for tat | 625941dff9cc0f698b140957 |
def test_packer_binary_which(host): <NEW_LINE> <INDENT> assert host.check_output('which packer') == PACKAGE_BINARY | Tests the output to confirm packer's binary location. | 625941df85dfad0860c3b1bb |
def __hash__(self) -> int: <NEW_LINE> <INDENT> return hash(self.unique_id) | Return a hash of self. | 625941df15fb5d323cde0e73 |
def web_treasury_h5(request): <NEW_LINE> <INDENT> if request.method == 'POST': <NEW_LINE> <INDENT> form = TreasuryForm(request.POST) <NEW_LINE> if form.is_valid(): <NEW_LINE> <INDENT> response = urllib2.urlopen(form.cleaned_data['url']) <NEW_LINE> html = response.readlines() <NEW_LINE> if len(html) < 6: <NEW_LINE> <IND... | Web import treasury data int db and h5
:param request: request
:return: render | 625941df4428ac0f6e5bab53 |
def __active_frame(self, current): <NEW_LINE> <INDENT> if isinstance(current, self.frame): <NEW_LINE> <INDENT> if current.is_focus(): <NEW_LINE> <INDENT> return current <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> <DEDENT> for child in current.get_children(): <NEW_LINE> <INDENT> found =... | recursive function, should start with zSplitWindow.mw_center | 625941df6aa9bd52df037104 |
def readLine(self): <NEW_LINE> <INDENT> trace = False and not g.unitTesting <NEW_LINE> at = self <NEW_LINE> if at.read_i < len(at.read_lines): <NEW_LINE> <INDENT> s = at.read_lines[at.read_i] <NEW_LINE> at.read_i += 1 <NEW_LINE> if trace: g.trace(at.read_i - 1, repr(s)) <NEW_LINE> return s <NEW_LINE> <DEDENT> else: <NE... | Read one line from file using the present encoding.
Returns at.read_lines[at.read_i++] | 625941df66673b3332b923f0 |
def jump(self, nums): <NEW_LINE> <INDENT> if len(nums) == 1: <NEW_LINE> <INDENT> return(0) <NEW_LINE> <DEDENT> debug = False <NEW_LINE> sol = len(nums)*[0] <NEW_LINE> for i in range((len(nums)-1),-1,-1): <NEW_LINE> <INDENT> if debug: print('index',i) <NEW_LINE> if debug: print('number',nums[i]) <NEW_LINE> if i+nums[i] ... | :type nums: List[int]
:rtype: int | 625941df4527f215b584c7b2 |
def stack_info(stack_print=True, short_filename=True): <NEW_LINE> <INDENT> stack_calls = traceback.extract_stack() <NEW_LINE> filenames = [] <NEW_LINE> linenums = [] <NEW_LINE> function_names = [] <NEW_LINE> statements = [] <NEW_LINE> if stack_print: <NEW_LINE> <INDENT> print(f"Stack Length = {len(stack_calls)}") <NEW_... | Inspect the call stack to learn how a methods are invoked.
Parameters
----------
stack_print : boolean
Flag to print full contents of the stack.
short_filename : boolean
Option to use simple file names rather than the full path
Returns
-------
filenames : []
File names associated call stack
linenums : []
... | 625941df76e4537e8c3519d3 |
def minSteps(self, n): <NEW_LINE> <INDENT> dp = [0 for i in range(n+1)] <NEW_LINE> for i in range(2, n+1): <NEW_LINE> <INDENT> dp[i] = i <NEW_LINE> for j in range(i-1, 1, -1): <NEW_LINE> <INDENT> if i % j == 0: <NEW_LINE> <INDENT> dp[i] = dp[j] + i / j <NEW_LINE> break <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return dp[-1... | :type n: int
:rtype: int | 625941dffb3f5b602dac39f5 |
def get_deposit(self, uuid): <NEW_LINE> <INDENT> URL = 'https://api.upbit.com/v1/deposit' <NEW_LINE> data = {'uuid': uuid} <NEW_LINE> return self._get(URL, self._get_headers(data), data) | 개별 입금 조회
https://docs.upbit.com/v1.0/reference#%EA%B0%9C%EB%B3%84-%EC%9E%85%EA%B8%88-%EC%A1%B0%ED%9A%8C
:param str uuid: 개별 입금의 UUID
:return: json object | 625941df01c39578d7e7519a |
def test(root, expected_result): <NEW_LINE> <INDENT> postitem_strings = [ str(postitem) + '\n' for postitem in postdb.walk_thread(root, yield_inner=True) ] <NEW_LINE> postitem_strings = ''.join(postitem_strings) <NEW_LINE> self.assertEqual(postitem_strings, expected_result) | Tests whether the the :func:`PostDB.walk_thread` function
returns the given result when executed with the given root. | 625941df0fa83653e4657317 |
def get_queryset(self): <NEW_LINE> <INDENT> queryset = Profile.objects.all() <NEW_LINE> if self.action == 'list': <NEW_LINE> <INDENT> return queryset.filter(age__gte=0) <NEW_LINE> <DEDENT> return queryset | Restrict list to public-only. | 625941df3317a56b86939faf |
def fileName(self): <NEW_LINE> <INDENT> stub = os.path.basename(self.srcPath) <NEW_LINE> i = stub.rfind('.') <NEW_LINE> if (i != 1): <NEW_LINE> <INDENT> return stub[0:i] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return stub | Filename of this source
If none, ??? | 625941df3eb6a72ae02ec844 |
@API.route('/new/', methods=['POST']) <NEW_LINE> @API.route('/new', methods=['POST']) <NEW_LINE> @api_login_required(acls=['create_project']) <NEW_LINE> @api_method <NEW_LINE> def api_new_project(): <NEW_LINE> <INDENT> user = pagure.lib.search_user(SESSION, username=flask.g.fas_user.username) <NEW_LINE> output = {} <NE... | Create a new project
--------------------
Create a new project on this pagure instance.
::
POST /api/0/<repo>/new
Input
^^^^^
+------------------+---------+--------------+---------------------------+
| Key | Type | Optionality | Description |
+==================+=========+=======... | 625941df287bf620b61d3dc0 |
def test_zones_post_201_created(self): <NEW_LINE> <INDENT> response = self.assert_post(self.basepath, self.post_data_one) <NEW_LINE> self.assertEqual(response['Location'], '/api/v1/zones/reverse/%s' % self.post_data_one['name']) | "Posting a new zone should return 201 and location | 625941df627d3e7fe0d691b0 |
def get_quantiles(self, alpha, ks=None, dds=None, suco=True): <NEW_LINE> <INDENT> if ks is None: <NEW_LINE> <INDENT> ks = range(self.K) <NEW_LINE> <DEDENT> if dds is None: <NEW_LINE> <INDENT> dds = range(self.d) <NEW_LINE> <DEDENT> quantiles = np.zeros((len(ks), len(alpha), len(dds))) <NEW_LINE> for ik, k in enumerate(... | Returns alpha quantile(s) in each dimension of sample j
(the pooled data if j = None) for each of the clusters. | 625941df56ac1b37e6264529 |
def get_cloud_param(self, cloud_name: str, param_name: str) -> Result: <NEW_LINE> <INDENT> if param_name in self.get_cloud(cloud_name).value: <NEW_LINE> <INDENT> if bool(self.credentials[cloud_name][param_name]): <NEW_LINE> <INDENT> return Result(True, self.credentials[cloud_name][param_name]) <NEW_LINE> <DEDENT> <DEDE... | Get value of param_name from credential's cloud definition | 625941df7d43ff24873a3001 |
def main(course_name, run, output_dir = '/output', date_file = 'coursera_course_dates.csv'): <NEW_LINE> <INDENT> input_dir = os.path.join('/input', course_name, run) <NEW_LINE> print('fetching data for run {0}'.format(run)) <NEW_LINE> date_file_path = os.path.join(input_dir, date_file) <NEW_LINE> course_start, course_... | Main workhorse function; builds full quiz datasets (appended and week-only) for course_name and writes as CSVs to ouput_dir.
:param course_name: course short name; should match name in coursera_course_dates.csv
:param date_file: course dates CSV file
:param output_dir: output directory
:return: None; writes output to o... | 625941dffff4ab517eb2f79d |
def test_update_document(self): <NEW_LINE> <INDENT> pass | Test case for update_document
Update Document | 625941df2eb69b55b151cc12 |
def __init__(self, cursor, name): <NEW_LINE> <INDENT> self.name = name <NEW_LINE> print(sql_create_table(name)) | usage: | 625941dfd18da76e23532838 |
def _set_prevent_teardown(self, v, load=False): <NEW_LINE> <INDENT> if hasattr(v, "_utype"): <NEW_LINE> <INDENT> v = v._utype(v) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> t = YANGDynClass( v, base=YANGBool, default=YANGBool("false"), is_leaf=True, yang_name="prevent-teardown", parent=self, path_helper=self._path_hel... | Setter method for prevent_teardown, mapped from YANG variable /network_instances/network_instance/protocols/protocol/bgp/neighbors/neighbor/afi_safis/afi_safi/l2vpn_vpls/prefix_limit/config/prevent_teardown (boolean)
If this variable is read-only (config: false) in the
source YANG file, then _set_prevent_te... | 625941df44b2445a339323f3 |
@test_harness.test(['emulator']) <NEW_LINE> def gdb_breakpoint(*unused): <NEW_LINE> <INDENT> hexfile = test_harness.build_program(['count.S'], image_type='raw') <NEW_LINE> with EmulatorProcess(hexfile), DebugConnection() as conn: <NEW_LINE> <INDENT> conn.expect('Z0,0000000c', 'OK') <NEW_LINE> conn.expect('Z0,00000010',... | Validate stopping at a breakpoint and continuing after stopping.
This sets two breakpoints | 625941df711fe17d825426c3 |
def CompositeIndexForGeoQuery(query): <NEW_LINE> <INDENT> required = True <NEW_LINE> kind = query.kind() <NEW_LINE> assert not query.has_ancestor() <NEW_LINE> ancestor = False <NEW_LINE> filters = query.filter_list() <NEW_LINE> preintersection_props = set() <NEW_LINE> geo_props = set() <NEW_LINE> for filter in filters:... | Builds a descriptor for a composite index needed for a geo query.
Args:
query: A datastore_pb.Query instance.
Returns:
A tuple in the same form as produced by CompositeIndexForQuery. | 625941dfbe8e80087fb20f9d |
def test_append_non_empty(): <NEW_LINE> <INDENT> from dll import DoublyLinkedList <NEW_LINE> my_list = DoublyLinkedList() <NEW_LINE> my_list.insert(4) <NEW_LINE> my_list.append(8) <NEW_LINE> assert my_list.tail.val == 8 | Assert node gets appended to the end of the lsit. | 625941df92d797404e3044ea |
def test_check_products_section_not_shown_for_staff_user(self): <NEW_LINE> <INDENT> profile_page = self.client.get('/profile/') <NEW_LINE> self.assertNotIn('<div id="products" ', profile_page.content) | Test that the products section is not showed for staff users as
staff shouldn't buy products from | 625941df0383005118ecf940 |
def __add__(self, other): <NEW_LINE> <INDENT> return RealRange((self[0] + other[0], self[1] + other[1])) | Addition operation.
@param other: The other operand.
@type other: L{RealRange}
@return: Sum of ranges.
@rtype: L{RealRange} | 625941dfa4f1c619b28b0391 |
def simulate(self, x_0, U, computeNoiseAgain=False): <NEW_LINE> <INDENT> x_0 = mat(x_0) <NEW_LINE> if x_0.shape[0] == 1: <NEW_LINE> <INDENT> x_0 = x_0.T <NEW_LINE> <DEDENT> assert x_0.shape[1] == 1 <NEW_LINE> assert x_0.shape[0] == self.A.shape[1] <NEW_LINE> U = mat(U) <NEW_LINE> assert U.shape[0] == self.B.shape[1] <N... | Compute multiple time steps. The simulation is run until the control
inputs (U) are exhausted.
Dimensions of input and outputs:
The second dimension is the step number; so U[:,2] is the control
input for step three.
Parameter:
x_0:
initial conditions: 1D array or matrix. Will be converted to
colum... | 625941df94891a1f4081be0a |
def tearDown(self): <NEW_LINE> <INDENT> del self.city | safely deleting the object | 625941df3c8af77a43ae3b02 |
def _get_ach_mult(include_pro_bonus: bool = False) -> int: <NEW_LINE> <INDENT> val: int = _ba.get_account_misc_read_val('achAwardMult', 5) <NEW_LINE> assert isinstance(val, int) <NEW_LINE> if include_pro_bonus and _ba.app.accounts.have_pro(): <NEW_LINE> <INDENT> val *= 2 <NEW_LINE> <DEDENT> return val | Return the multiplier for achievement pts.
(just for display; changing this here won't affect actual rewards) | 625941df66656f66f7cbc50c |
@verify <NEW_LINE> def run(user_data): <NEW_LINE> <INDENT> if user_data["is_authenticated"]: <NEW_LINE> <INDENT> flag = False <NEW_LINE> while not flag: <NEW_LINE> <INDENT> print("-".center(70, "-")) <NEW_LINE> print("欢迎光临ATM电子银行".center(60," ")) <NEW_LINE> print("-".center(70, "-")) <NEW_LINE> print("【1】进入商城\t【2】用户管理\... | 程序主函数入口,根据用户的输入,调用不同的功能函数
:param user_data:
:return: none | 625941df5fc7496912cc3cdd |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.