code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def test_search_in_xml_endpoint(params): <NEW_LINE> <INDENT> pages = search_in_api.search_for_string( url=params['xml_url'], tag=params['tag'], value=params['value'], ) <NEW_LINE> assert pages == [ "https://raw.githubusercontent.com/archatas/search_in_api/master/tests/data/sample-data.xml", "https://raw.githubuserconte... | Test the core function | 625941cd3c8af77a43ae38b2 |
def __init__(self, nx, nodes): <NEW_LINE> <INDENT> if not isinstance(nx, int): <NEW_LINE> <INDENT> raise TypeError("nx must be an integer") <NEW_LINE> <DEDENT> if nx < 1: <NEW_LINE> <INDENT> raise ValueError("nx must be a positive integer") <NEW_LINE> <DEDENT> if not isinstance(nodes, int): <NEW_LINE> <INDENT> raise Ty... | Class constructor
Args:
- nx: is the number of input features.
- nodes: is the number of nodes found in the hidden layer.
Public instance attributes:
- W1: The weights vector for the hidden layer. Upon
instantiation, it should be initialized using a random
normal distribution.
- b1: The bias... | 625941cd21bff66bcd684a65 |
def parse_z0(s: str) -> NumberLike: <NEW_LINE> <INDENT> re_numbers = re.compile(r'\d+') <NEW_LINE> numbers = re.findall(re_numbers, s) <NEW_LINE> if len(numbers)==2: <NEW_LINE> <INDENT> out = float(numbers[0]) +1j*float(numbers[1]) <NEW_LINE> <DEDENT> elif len(numbers)==1: <NEW_LINE> <INDENT> out = float(numbers[0]) <N... | Parse a z0 string.
Parameters
----------
s : str
z0 string, like '50+10j'
Returns
-------
z0 : npy.ndarray
Raises
------
ValueError
If could not arse the z0 string. | 625941cdb545ff76a8913f28 |
def is_executable_file(filename): <NEW_LINE> <INDENT> with open(filename, mode='rb') as f: <NEW_LINE> <INDENT> magic_bytes = f.read(_num_magic_bytes) <NEW_LINE> <DEDENT> if sys.platform == 'darwin': <NEW_LINE> <INDENT> return magic_bytes in [ b'\xfe\xed\xfa\xce', b'\xce\xfa\xed\xfe', b'\xfe\xed\xfa\xcf', b'\xcf\xfa\xed... | Return 'True' if 'filename' names a valid file which is likely
an executable. A file is considered an executable if it starts with the
magic bytes for a EXE, Mach O, or ELF file. | 625941cd498bea3a759b9bc1 |
def bash_pipe(command, fail = True): <NEW_LINE> <INDENT> return execute_pipe(['bash', '-c', command], fail) | Execute a shell command, in GNU Bash
@param command:str The shell command
@param fail:bool Whether to raise an exception if the command fails | 625941cdd18da76e235325e8 |
def conv_layer(x, ksize, stride, feature_num, is_training, name=None, padding="SAME", groups=1): <NEW_LINE> <INDENT> with tf.variable_scope(name) as scope: <NEW_LINE> <INDENT> w = tf.get_variable("w", [ksize, ksize, int(x.get_shape()[-1]) / groups, feature_num], dtype="float") <NEW_LINE> b = tf.get_variable("b", [featu... | Convolutional layer.
:param x: tensor
Input tensor
:param ksize: int
Convolution kernel size
:param stride: int
Convolution stride length
:param feature_num: int
Output feature number
:param is_training: boolean
Whether it is in the training step
:param name: string
Layer... | 625941cd4d74a7450ccd42d6 |
def update(self): <NEW_LINE> <INDENT> temp1 = Label(self,background="white", text=temperatuursensor.getTemperatuur(1)) <NEW_LINE> temp1.grid(column=2, row=5, ipady=5, ipadx=15, padx=5, pady=5) <NEW_LINE> temp2 = Label(self,background="white", text=temperatuursensor.getTemperatuur(2)) <NEW_LINE> temp2.grid(column=2, row... | Basis voor threading
Oke Daan & Marc, dit is ter illustratie, maar basically: | 625941cdbe383301e01b5597 |
def get_sample(self, ptr): <NEW_LINE> <INDENT> im, mask, im_name, mask_name = self.open_as_gray(self.serial_nums[ptr]) <NEW_LINE> return im, mask, im_name, mask_name | Here one sample means one image and one mask.
:param: ptr: ...
Returns:
im: np.array, one image
mask: np.array, one mask | 625941cd627d3e7fe0d68f62 |
def wrap(data): <NEW_LINE> <INDENT> if data is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if isinstance(data, Value): <NEW_LINE> <INDENT> return data <NEW_LINE> <DEDENT> elif isinstance(data, array_types['mxnet']): <NEW_LINE> <INDENT> return Array(data, ArrayType.MXNET) <NEW_LINE> <DEDENT> elif isinstanc... | Wrap given data into its corresponding wrapper class.
For example, :class:`numpy.ndarray` will be converted to
:class:`Array` while float number will become
:class:`Number`. The allowed array types are defined in
:class:`minpy.array_variants.array_types`; the allowed number
types are defined in
:class:`minpy.array_var... | 625941cd6aa9bd52df036eb7 |
def user_can_execovision(user): <NEW_LINE> <INDENT> if not user.is_authenticated(): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> query = GroupMember.objects.filter(user=user, is_admin=True, group__model='Network') <NEW_LINE> if query.count(): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> ... | Check if user is capable of exec-o-vision (but not whether it is currently enabled)
Or, basically, if they are the admin of any networks. | 625941cdbe383301e01b5598 |
def find_bracket(self, board, player, square, direction): <NEW_LINE> <INDENT> temp = square + direction <NEW_LINE> while board[temp] == OPPONENT[player]: <NEW_LINE> <INDENT> if temp < 0: return False <NEW_LINE> if board[temp + direction] == player: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> temp+=direction <NE... | Find a square that forms a match with `square` for `player` in the given
`direction`. Returns None if no such square exists.
Assumes that 'square' is a blank. Direction is one of the eight valid
directions. Return the index of a square in 'player''s color
so that there is a string of opponent pieces in between. | 625941cdd6c5a1020814415d |
def get_all_collections(self): <NEW_LINE> <INDENT> return self.database.collection_names(include_system_collections=True) | return a list of all the collections in the database including system
collections | 625941cdcc0a2c11143dcfa3 |
def testRelValMCWithPileup(self): <NEW_LINE> <INDENT> defaultArguments = getTestArguments() <NEW_LINE> defaultArguments["CouchURL"] = os.environ["COUCHURL"] <NEW_LINE> defaultArguments["CouchDBName"] = "relvalmc_t" <NEW_LINE> defaultArguments["GenOutputModuleName"] = "OutputA" <NEW_LINE> defaultArguments["StepOneOutput... | Configure, instantiate, install into WMBS and check that the
subscriptions in WMBS are setup correctly. | 625941cdad47b63b2c50a092 |
def fetchBag_v1(self, userEmail: str) -> dict: <NEW_LINE> <INDENT> return self._getBag(userEmail).get().to_dict() | Retrieves the bag and returns it as string | 625941cd2eb69b55b151c9c1 |
def testCubes(self): <NEW_LINE> <INDENT> keysExpected = [ 'FU' , 'FRU', 'RU' , 'RBU', 'BU' , 'BLU', 'LU' , 'LFU', 'FR' , 'BR' , 'BL' , 'FL' , 'FD' , 'FRD', 'RD' , 'RBD', 'BD' , 'BLD', 'LD' , 'LFD', ] <NEW_LINE> self.assertListEqual( sorted(keysExpected), sorted(list(self.cube.cubes.keys())) ) | Un Cube() doit posséder tous les petits cubes | 625941cdd99f1b3c44c676a1 |
def get_uid(entry, key, key_secondary, key_search, keymap) -> Optional(str): <NEW_LINE> <INDENT> uid = None <NEW_LINE> if not key_search: <NEW_LINE> <INDENT> key_primary_found = key in entry <NEW_LINE> if key_primary_found and key not in entry and not entry[key]: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if k... | Get UID for data list | 625941cdbe8e80087fb20d55 |
def get_projections_on_elts_and_orbitals(self, dictio): <NEW_LINE> <INDENT> if len(self._projections) == 0: <NEW_LINE> <INDENT> return {} <NEW_LINE> <DEDENT> if self.is_spin_polarized: <NEW_LINE> <INDENT> result = {Spin.up: [], Spin.down: []} <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> result = {Spin.up: []} <NEW_LIN... | Method returning a dictionary of projections on elements and specific
orbitals
Args:
dictio: A dictionary of Elements and Orbitals for which we want
to have projections on. It is given as: {Element:[orbitals]},
e.g., {'Cu':['d','s']}
Returns:
A dictionary of projections on elements in the
... | 625941cd16aa5153ce36258b |
def toTime(integer, absolute=False): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> hours = integer // 60 <NEW_LINE> minutes = integer - (hours * 60) <NEW_LINE> if absolute: <NEW_LINE> <INDENT> hours = hours % 24 <NEW_LINE> <DEDENT> return '{}:{:02} h'.format(hours, minutes) <NEW_LINE> <DEDENT> except Exception: <NEW_LIN... | Integer is input in minutes. | 625941cdbd1bec0571d90742 |
def to_dict(self): <NEW_LINE> <INDENT> raise NotImplementedError() | Abstract method
This method must be implemented by the deriving classes. It must return a Python dict with all parameters of
self, which are needed to create a copy of self.
:return: A Python dict with all needed parameters of self
:rtype: dict | 625941cdab23a570cc250295 |
def configuration_test(self): <NEW_LINE> <INDENT> configuration = {u"applications": COMPLEX_APPLICATION_YAML, u"deployment": COMPLEX_DEPLOYMENT_YAML} <NEW_LINE> setting = self.assertResponseCode( b"POST", b"/configuration/_compose", configuration, OK ) <NEW_LINE> def configuration_set(_): <NEW_LINE> <INDENT> actual = s... | POSTing to ``/configuration/_compose`` in Flocker's custom
configuration format changes the deployment configuration by
parsing the given JSON in Flocker's custom configuration format
and using it to replace the existing configuration. | 625941cd8e7ae83300e4b0df |
def buildWorkload(self): <NEW_LINE> <INDENT> (self.inputPrimaryDataset, self.inputProcessedDataset, self.inputDataTier) = self.inputDataset[1:].split("/") <NEW_LINE> workload = self.createWorkload() <NEW_LINE> workload.setDashboardActivity("reprocessing") <NEW_LINE> self.reportWorkflowToDashboard(workload.getDashboardA... | _buildWorkload_
Build the workload given all of the input parameters.
Not that there will be LogCollect tasks created for each processing
task and Cleanup tasks created for each merge task. | 625941cd8c0ade5d55d3eace |
def Register_SetCH(*args): <NEW_LINE> <INDENT> return _x64dbgapi64.Register_SetCH(*args) | Register_SetCH(unsigned char value) -> bool | 625941cdf9cc0f698b14070e |
def getTagsFromString(string): <NEW_LINE> <INDENT> tags = re.findall("[[][a-zA-Z0-9]+[]]", string) <NEW_LINE> return [tag[1:-1] for tag in tags] | Finds all tags from file
@param string: string we are getting tags from
@return: list of string tags | 625941cd6fece00bbac2d851 |
def __init__(self, wafInstanceId, domain, name, ): <NEW_LINE> <INDENT> self.wafInstanceId = wafInstanceId <NEW_LINE> self.domain = domain <NEW_LINE> self.name = name | :param wafInstanceId: 实例id,WAF实例
:param domain: 域名
:param name: 名称 | 625941cd67a9b606de4a7fcc |
def _store_u1db_data(self): <NEW_LINE> <INDENT> NotImplementedError(self._store_u1db_data) | Store u1db configuration data on backend storage.
See C{_init_u1db_data} documentation. | 625941cd66656f66f7cbc2bd |
def listEntities(path): <NEW_LINE> <INDENT> txt = Path(path).open().read() <NEW_LINE> rx = re.compile(r'<!ENTITY (\S+)\s+ "([^"]+)" ><!--(.+?) -->') <NEW_LINE> a = rx.findall(txt) <NEW_LINE> a.sort(key=lambda x: x[0].lower()) <NEW_LINE> return a | Parses the list from:
http://www.w3.org/2003/entities/2007/w3centities-f.ent | 625941cd5fcc89381b1e17d2 |
def reverse(text): <NEW_LINE> <INDENT> if text == '': <NEW_LINE> <INDENT> return '' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return reverse(text[1:]) + text[0] | This function takes a string and reverses the characters in it. | 625941cd30dc7b7665901a79 |
def add_instance(self, name, config_dir=None, main_configs=[], user_configs=[], macroses={}, with_zookeeper=False, clickhouse_path_dir=None): <NEW_LINE> <INDENT> if self.is_up: <NEW_LINE> <INDENT> raise Exception("Can\'t add instance %s: cluster is already up!" % name) <NEW_LINE> <DEDENT> if name in self.instances: <NE... | Add an instance to the cluster.
name - the name of the instance directory and the value of the 'instance' macro in ClickHouse.
config_dir - a directory with config files which content will be copied to /etc/clickhouse-server/ directory
main_configs - a list of config files that will be added to config.d/ directory
use... | 625941cd63b5f9789fde71f8 |
def _parse_location(self, response): <NEW_LINE> <INDENT> raw = response.xpath('//*[@id="main"]/section[2]/div[1]/p[1]').get().lower() <NEW_LINE> expected_address = "412 Boulevard of the Allies, Pittsburgh, PA 15219" <NEW_LINE> expected_room_name = "Lower Level Conference Room" <NEW_LINE> found_address = "" <NEW_LINE> f... | Parse or generate location. | 625941cd67a9b606de4a7fcd |
def get_topic_sentiment(topic: str): <NEW_LINE> <INDENT> posts = get_posts(topic=topic) <NEW_LINE> topic_pos = 0 <NEW_LINE> topic_neg = 0 <NEW_LINE> topic_neu = 0 <NEW_LINE> sent_report = [] <NEW_LINE> for i in range(len(posts)): <NEW_LINE> <INDENT> post_sent = get_post_sentiment(posts[i]['comments'])[1] <NEW_LINE> top... | Get the overall sentiment for a topic EX: This topic is POSITIVE
:return: report | 625941cdfbf16365ca6f62d8 |
def import_pred_kp(): <NEW_LINE> <INDENT> db_util = DbUtil() <NEW_LINE> article_pred_record_list = load_json("../../static/data/filtered_key_phrase/filtered_key_phrase_1.json") <NEW_LINE> for record_id, article_pred_record in article_pred_record_list.items(): <NEW_LINE> <INDENT> pred_kp = json.dumps(article_pred_record... | 加载(筛选后的)关键词
@return: | 625941cd3346ee7daa2b2e7e |
def build_graph(parameters): <NEW_LINE> <INDENT> input1 = tf.placeholder( dtype=parameters["dtype"], name="input1", shape=parameters["input_shape_1"]) <NEW_LINE> input2 = tf.placeholder( dtype=parameters["dtype"], name="input2", shape=parameters["input_shape_2"]) <NEW_LINE> out = binary_operator(input1, input2) <NEW_LI... | Builds the graph given the current parameters. | 625941cdac7a0e7691ed41df |
def test_georss_w3c(self): <NEW_LINE> <INDENT> layer = Layer.objects.external()[0] <NEW_LINE> layer.minimum_distance = 0 <NEW_LINE> layer.area = None <NEW_LINE> layer.new_nodes_allowed = False <NEW_LINE> layer.save() <NEW_LINE> layer = Layer.objects.get(pk=layer.pk) <NEW_LINE> url = '%s/georss-w3c.xml' % TEST_FILES_PAT... | test GeoRSS w3c | 625941cd5510c4643540f4f7 |
def get_all_groups(self, start, limit, source=None): <NEW_LINE> <INDENT> return ccnet_threaded_rpc.get_all_groups(start, limit, source) | For CE, source is not used and should alwasys be None. | 625941cd7c178a314d6ef573 |
def __or__(self, other ): <NEW_LINE> <INDENT> if isinstance( other, str ): <NEW_LINE> <INDENT> other = Literal( other ) <NEW_LINE> <DEDENT> if not isinstance( other, ParserElement ): <NEW_LINE> <INDENT> warnings.warn("Cannot combine element of type %s with ParserElement" % type(other), SyntaxWarning, stacklevel=2) <NEW... | Implementation of | operator - returns C{MatchFirst} | 625941cd566aa707497f467b |
def turtle_sectors(nb_sectors=46): <NEW_LINE> <INDENT> sectors = [ 1, 6, 16, 26, 46, 66, 91, 136, 196, 251, 341, 406] <NEW_LINE> refines = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] <NEW_LINE> s2r = dict(zip(sectors,refines)) <NEW_LINE> if nb_sectors not in s2r: <NEW_LINE> <INDENT> print('Use a value of nb_se... | Generate faces of a dual icosphere polyhedron mapping the Z+ hemisphere
Args:
refine_level (int): the level of refinement of the dual icosphere. By
default 46 polygons are returned (refine_level=3).
For information, here are the number of faces obtained for the first ten
refinement level: 0: 6, 1: 16,... | 625941cd15baa723493c4088 |
def check_results_ubuntu2110(self): <NEW_LINE> <INDENT> dirty_pages = self.driver.find_element(By.CLASS_NAME, 'dirty_pages') <NEW_LINE> self.assertEqual(dirty_pages.text, '633 pages', 'Unexpected number of dirty pages') <NEW_LINE> ram_pages = self.driver.find_element(By.CLASS_NAME, 'ram_pages') <NEW_LINE> self.assertEq... | Check the results of the analysis of the Ubuntu example | 625941cdde87d2750b85fea6 |
def test_2_Attr(self): <NEW_LINE> <INDENT> c = ds.DSCCAPS() <NEW_LINE> c.dwFlags = 1 <NEW_LINE> c.dwFormats = 2 <NEW_LINE> c.dwChannels = 4 <NEW_LINE> self.assertTrue(c.dwFlags == 1) <NEW_LINE> self.assertTrue(c.dwFormats == 2) <NEW_LINE> self.assertTrue(c.dwChannels == 4) | DSCCAPS attribute access | 625941cd7d847024c06be3cf |
def tune(self, train_data=None, valid_index=pd.Int64Index([]), fit_kwargs=dict()): <NEW_LINE> <INDENT> if not self._features_already_prepared: <NEW_LINE> <INDENT> train_features,valid_features = self.prepare_features(train_data, valid_index) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> train_features = self.train_feat... | Parameters
----------
train_data: pandas.DataFrame
Dataframe with at least columns 'ds' and 'y'.
valid_index: pandas.Index
Array with indexes from train_data to be used for validation.
fit_kwargs: dict
Extra arguments passed to the fit/train call of the model. | 625941cd293b9510aa2c33a9 |
def __init__(self, base, axes, color='black', zorder=5, r=1.0, sign=1): <NEW_LINE> <INDENT> BaseInteractor.__init__(self, base, axes, color=color) <NEW_LINE> self.markers = [] <NEW_LINE> self.axes = axes <NEW_LINE> self._inner_mouse_x = r <NEW_LINE> self._inner_mouse_y = 0 <NEW_LINE> self._inner_save_x = r <NEW_LINE> s... | :param: the color of the line that defined the ring
:param r: the radius of the ring
:param sign: the direction of motion the the marker | 625941cd10dbd63aa1bd2cb7 |
def choose_ok_on_next_confirmation(self): <NEW_LINE> <INDENT> self.do_command("chooseOkOnNextConfirmation", []) | Undo the effect of calling chooseCancelOnNextConfirmation. Note
that Selenium's overridden window.confirm() function will normally automatically
return true, as if the user had manually clicked OK, so you shouldn't
need to use this command unless for some reason you need to change
your mind prior to the next confirmat... | 625941cd097d151d1a222f6d |
@app.route('/send_msg/<to>/<msg>') <NEW_LINE> def send_msg(to, msg): <NEW_LINE> <INDENT> j = {'ret': 0 if wechat.send_text(to, msg) else 1} <NEW_LINE> return flask.Response(json.dumps(j), mimetype='application/json') | @brief send message to user or gourp
@param to: String, user id or group id
@param msg: String, words | 625941cd7d43ff24873a2db3 |
def dim(self): <NEW_LINE> <INDENT> raise NotImplementedError() | Returns the dimension of the ambient vector space | 625941cd01c39578d7e74f4f |
def read(self, buf, n): <NEW_LINE> <INDENT> buff4, count = [''] * 4, 0 <NEW_LINE> while n > 0: <NEW_LINE> <INDENT> current = min(read4(buff4), n) <NEW_LINE> if current == 0: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> buf[count:count+current] = buff4[:current] <NEW_LINE> count += current <NEW_LINE> n -= current <NEW_... | :type buf: Destination buffer (List[str])
:type n: Number of characters to read (int)
:rtype: The number of actual characters read (int) | 625941cdcb5e8a47e48b7bbe |
def write_config(self, show_message: bool = True) -> None: <NEW_LINE> <INDENT> config_parser = self.config_parser <NEW_LINE> if config_parser.has_section("config"): <NEW_LINE> <INDENT> config_parser._sections.move_to_end("config", last=False) <NEW_LINE> <DEDENT> if config_parser.has_section("profiles") and config_parse... | Write the config parser to the config file.
Arguments:
show_message: Whether to show the message. | 625941cd8c3a8732951584ce |
def init_experiment(self): <NEW_LINE> <INDENT> self.demographics_input() <NEW_LINE> self.screen = pygame.display.set_mode(self.screenSize, pygame.FULLSCREEN) <NEW_LINE> self.itemFont = pygame.font.SysFont("Arial", 40) <NEW_LINE> self.instFont = pygame.font.SysFont("Arial", 30) <NEW_LINE> self.screenRect = self.screen.g... | initializes pygame backends explicitly with
predefined settings. | 625941cdd268445f265b4f81 |
def export(): <NEW_LINE> <INDENT> with lcd(repo_root): <NEW_LINE> <INDENT> local('git archive master | tar -x -C ' + workspace) | Exports repository's master branch to a temporary workspace. | 625941cd796e427e537b06d9 |
@named('get-wal') <NEW_LINE> @arg('server_name', completer=server_completer, help='specifies the server name for the command') <NEW_LINE> @arg('wal_name', help='the WAL file to get') <NEW_LINE> @arg('--output-directory', '-o', help='put the retrieved WAL file in this directory ' 'with the original name', default=SUPPRE... | Retrieve WAL_NAME file from SERVER_NAME archive.
The content will be streamed on standard output unless
the --output-directory option is specified. | 625941cdf548e778e58cd691 |
def selectStorageCache( self, sE = None, occupied = None, free = None, usage = None, lastCheckTime = None, meta = None ): <NEW_LINE> <INDENT> return self._query( 'select', 'StorageCache', locals() ) | Gets from StorageCache all rows that match the parameters given.
:Parameters:
**sE** - `[, string, list ]`
name of se
**occupied** - `[, integer, list ]`
occupied storage of se
**free** - `[, integer, list ]`
free storage of se
**usage** - `[, float, list ]`
usage rate of se
**meta** - `[, d... | 625941cd97e22403b379d0ad |
def __init__(self, input_struct=bytes(RX_PCKT_SIZE)): <NEW_LINE> <INDENT> self.data_struct = input_struct <NEW_LINE> meta_data = struct.unpack('<BBBBI', self.data_struct[0:PAYLOAD_START]) <NEW_LINE> self.type = meta_data[0] <NEW_LINE> self.valid = PcktTypes.has_value(self.type) <NEW_LINE> self.timestamp = meta_data[4] ... | Form packet from incoming USB bytes
input_struct -- incoming packet in raw bytes form | 625941cd566aa707497f467c |
def rot2rph (R): <NEW_LINE> <INDENT> h = arctan2 (R[1,0], R[0,0]) <NEW_LINE> ch = cos (h) <NEW_LINE> sh = sin (h) <NEW_LINE> p = arctan2 (-R[2,0], R[0,0]*ch + R[1,0]*sh) <NEW_LINE> r = arctan2 (R[0,2]*sh - R[1,2]*ch, -R[0,1]*sh + R[1,1]*ch); <NEW_LINE> return array ([r,p,h]) | Decompose a 3x3 rotation matrix R into roll, pitch, and yaw angles | 625941cddd821e528d63b2bc |
def create_binary_tree(input_list=[]): <NEW_LINE> <INDENT> if input_list is None or len(input_list) == 0: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> data = input_list.pop(0) <NEW_LINE> if data is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> node = TreeNode(data) <NEW_LINE> node.left = create_binar... | 构建二叉树
:param input_list: 输入数列 | 625941cd4e4d5625662d44eb |
def get_default_role_field_name(self): <NEW_LINE> <INDENT> return | No use for this method, this workflow doesn't support the
'adding from a pool of all resources' logic as the user one does. | 625941cd3617ad0b5ed6800b |
def p_BooleanExpr5(self, t): <NEW_LINE> <INDENT> t[0] = t[2] | BooleanExpr : LPAREN Where RPAREN | 625941cd442bda511e8be52c |
def endswith_lf(line): <NEW_LINE> <INDENT> return line.endswith('\n' if isinstance(line, str) else b'\n') | Return True if line (a text or byte string) ends with '
'. | 625941cd23849d37ff7b31a3 |
def run_seldom(actions_queue: Queue, wait_until_acquire_next_task: float = 1): <NEW_LINE> <INDENT> while not actions_queue.empty(): <NEW_LINE> <INDENT> value_actions = actions_queue.get() <NEW_LINE> perform_actions(value_actions, profile_name="seldom") <NEW_LINE> time.sleep(wait_until_acquire_next_task) | Threading target for one run mechanism that runs seldom | 625941cd099cdd3c635f0d6e |
def render(self, guess=None, with_answer=False): <NEW_LINE> <INDENT> render_string = '%d %s %d = ' % (self.left_side, self.eqn_repr, self.right_side) <NEW_LINE> if guess is not None: <NEW_LINE> <INDENT> render_string += str(guess) <NEW_LINE> <DEDENT> elif with_answer: <NEW_LINE> <INDENT> render_string += str(self.answe... | Return a string representation of the equation. | 625941cdbaa26c4b54cb1233 |
def oldAppConvention(): <NEW_LINE> <INDENT> return foamVersionNumber()>() and foamVersionNumber()<(1,5) | Returns true if the version of OpenFOAM is older than 1.5 and
it therefor uses the 'old' convention to call utilities ("dot, case") | 625941cd377c676e912722bc |
def test_mc_halo_centric_pos_stochasticity(): <NEW_LINE> <INDENT> r = 0.25 <NEW_LINE> Npts = int(100) <NEW_LINE> c15 = np.zeros(Npts) + 15 <NEW_LINE> nfw = NFWPhaseSpace(concentration_bins=np.array((5, 10, 15))) <NEW_LINE> halo_radius = np.zeros(len(c15)) + r <NEW_LINE> x15a, y15a, z15a = nfw.mc_halo_centric_pos(c15, h... | Method used to test stochasticity/deterministic behavior of
`~halotools.empirical_models.NFWPhaseSpace.mc_halo_centric_pos`. | 625941cd71ff763f4b54979f |
def singleNumber(self, nums): <NEW_LINE> <INDENT> if len(nums)==1: <NEW_LINE> <INDENT> return nums[0] <NEW_LINE> <DEDENT> nums.sort() <NEW_LINE> for i in range(1,len(nums),2): <NEW_LINE> <INDENT> if nums[i]!=nums[i-1]: <NEW_LINE> <INDENT> return nums[i-1] <NEW_LINE> <DEDENT> <DEDENT> return nums[-1] | :type nums: List[int]
:rtype: int | 625941cd60cbc95b062c6657 |
def get_fleet( self, ems_system_id, fleet_id, custom_headers=None, raw=False, **operation_config): <NEW_LINE> <INDENT> url = self.get_fleet.metadata['url'] <NEW_LINE> path_format_arguments = { 'emsSystemId': self._serialize.url("ems_system_id", ems_system_id, 'int'), 'fleetId': self._serialize.url("fleet_id", fleet_id,... | Returns information for a fleet on the system.
:param ems_system_id: The unique identifier of the system containing
the EMS data.
:type ems_system_id: int
:param fleet_id: The unique identifier of the fleet of interest.
:type fleet_id: int
:param dict custom_headers: headers that will be added to the request
:param b... | 625941cd1f5feb6acb0c4c64 |
def make_map(config): <NEW_LINE> <INDENT> map = Mapper(directory=config['pylons.paths']['controllers'], always_scan=config['debug']) <NEW_LINE> map.minimization = False <NEW_LINE> map.connect('/error/{action}', controller='error') <NEW_LINE> map.connect('/error/{action}/{id}', controller='error') <NEW_LINE> map.connect... | Create, configure and return the routes Mapper | 625941cd96565a6dacc8f7df |
def unplayed_songs(MC: 'list of Album') -> list: <NEW_LINE> <INDENT> list_of_Songdisplays = all_Songdisplays(MC) <NEW_LINE> result = [] <NEW_LINE> for sd in list_of_Songdisplays: <NEW_LINE> <INDENT> if sd.play_count == 0: <NEW_LINE> <INDENT> result.append(sd) <NEW_LINE> <DEDENT> <DEDENT> return result | Takes a music collection and returns a list of Songdisplays, one for each song that has never been played.
| 625941cd66673b3332b921a5 |
def _filter_tokens(self, no_above, no_below, max_num): <NEW_LINE> <INDENT> max_freq = int(self._num_docs * no_above) <NEW_LINE> if max_freq > 0: <NEW_LINE> <INDENT> log.info("filtering for frequency <= {}".format(max_freq)) <NEW_LINE> bad_tokens = [t for t, v in self.state.doc_frequency.items() if v > max_freq] <NEW_LI... | helper methods to filter dictionary | 625941cd45492302aab5e3d7 |
def get_args(): <NEW_LINE> <INDENT> parser = ap.ArgumentParser(description='Lookup shakemap values at a set of locations, get damage estimate', formatter_class=ap.ArgumentDefaultsHelpFormatter) <NEW_LINE> parser.add_argument('-i', '--ifile', metavar='input_coordinates.csv', type=str, nargs='?', help='.csv file with col... | Get script arguments | 625941cdb830903b967e9a1f |
def __init__(self, body, vertices, offset, auto_order_vertices=False): <NEW_LINE> <INDENT> if auto_order_vertices: <NEW_LINE> <INDENT> raise Exception(NotImplemented) <NEW_LINE> <DEDENT> self._body = body <NEW_LINE> self.offset = offset <NEW_LINE> self.verts = (Vec2d * len(vertices)) <NEW_LINE> self.verts = self.verts(... | body is the body to attach the poly to, verts is an array of
(x,y) defining a convex hull with a counterclockwise winding, offset
is the offset from the body's center of gravity in body local
coordinates. Set auto_order_vertices to automatically order the
vertices | 625941cdd164cc6175782e62 |
def render_indirect(self, program: moderngl.Program, buffer, mode=None, count=-1, *, first=0): <NEW_LINE> <INDENT> vao = self.instance(program) <NEW_LINE> if mode is None: <NEW_LINE> <INDENT> mode = self.mode <NEW_LINE> <DEDENT> vao.render_indirect(buffer, mode=mode, count=count, first=first) | The render primitive (mode) must be the same as the input primitive of the GeometryShader.
The draw commands are 5 integers: (count, instanceCount, firstIndex, baseVertex, baseInstance).
Args:
program: The ``moderngl.Program``
buffer: The ``moderngl.Buffer`` containing indirect draw commands
Keyword Args:
... | 625941cdbf627c535bc132e3 |
def test_subclass_pydantic_basemodel(): <NEW_LINE> <INDENT> assert issubclass(BaseApi, BaseModel) | BaseApi является наследником BaseModel
| 625941cd50485f2cf553ceae |
def __init__(self, selector, tech_ability, rem_fault, ack, next_page): <NEW_LINE> <INDENT> self.selector = selector & 0x1F <NEW_LINE> self.tech_ability = tech_ability & 0xFF <NEW_LINE> self.rem_fault = 1 if rem_fault else 0 <NEW_LINE> self.ack = 1 if ack else 0 <NEW_LINE> self.next_page = 1 if next_page else 0 | selector (int)
Identify which standard is in use
tech_ability (int)
Technology ability. Identifies posible modes of operation.
rem_fault (int or bool)
Flag indicating a link failure
ack (int or bool)
Flag to indicate reception of the base link code word.
next_page (int or bool)
Flag to indicate ... | 625941cd5166f23b2e1a526d |
def logging_icer(user, port, directory, node): <NEW_LINE> <INDENT> ssh_develop_node = f"ssh {node}\n" <NEW_LINE> handle_permission = f"export XDG_RUNTIME_DIR=''\n" <NEW_LINE> cd_directory = f"cd {directory}\n" <NEW_LINE> start_jupyter_notebook = f"jupyter notebook --NotebookApp.token='' --port={port}\n" <NEW_LINE> to_s... | commands are strings arranged in a list. | 625941cd0c0af96317bb82fc |
def format_price(n): <NEW_LINE> <INDENT> return "{:+.2f} Eur".format(abs(n)) | Print formatted price. | 625941cd30c21e258bdfa5b2 |
def __lt__(self, other): <NEW_LINE> <INDENT> return ((self.center.time, self.kind, self.center.full_name) < (other.center.time, other.kind, other.center.full_name)) | A strategy appears before another strategy in a sort if it is the
preferred option given identical costs and outcomes.
First preference is for less travel time, then sorting by
strategy kind as primary < comprehensive < drip and ship.
Finally sort alphabetically by center name | 625941cd21a7993f00bc7e04 |
def get_bad_om(om, scenario='OneCluster'): <NEW_LINE> <INDENT> num_mutations = 0 <NEW_LINE> for row in range(om.shape[0]): <NEW_LINE> <INDENT> num_mutations += np.sum(om[row]) <NEW_LINE> <DEDENT> if scenario is 'NCluster': <NEW_LINE> <INDENT> worst_matrix = np.zeros([om.shape[0], num_mutations], dtype=int) <NEW_LINE> s... | constructs the worst om
:param om: overlap matrix
:param scenario: the scenario that will be used (OneCluster or NCluster)
:return: the worst overlap matrix fir a given scenario | 625941cd851cf427c661a623 |
def launch(self): <NEW_LINE> <INDENT> ret = sim.simxStartSimulation(self.clientID, mode1) <NEW_LINE> return ret | trigger simulations start | 625941cd57b8e32f524835af |
def test_equality(self): <NEW_LINE> <INDENT> self.assertTrue(Dollar(5) == Dollar(5), "$5 == $5") <NEW_LINE> self.assertFalse(Dollar(5) == Dollar(6), "$5 != $6") | 同一性テスト | 625941cdfb3f5b602dac37a7 |
def write_to_csv(flat_file, file_, col_names,pkey): <NEW_LINE> <INDENT> with open(file_, "wb") as a: <NEW_LINE> <INDENT> writer = csv.writer(a) <NEW_LINE> writer.writerow(col_names) <NEW_LINE> for row in flat_file: <NEW_LINE> <INDENT> if row[pkey]: <NEW_LINE> <INDENT> writer.writerow(row) | writes data to csv if the pkey column in not null | 625941cd460517430c394299 |
def __init__(self, config_file=None, **kwargs): <NEW_LINE> <INDENT> self.configs = self.get_configs(config_file, **kwargs) <NEW_LINE> self.date = None | Args:
config_file (str): Path to notes config file in yaml format. | 625941cd627d3e7fe0d68f64 |
def tiles_lite(): <NEW_LINE> <INDENT> starx, stary, galax, galay=es.make_stars(1e10,5e9,[4,8,12,16,20],[13,19,24,30,36],25,3,50,500) <NEW_LINE> plt.figure(figsize=(25,25)) <NEW_LINE> plt.subplot(4,4,1) <NEW_LINE> es.plot_solution(starx,stary,galax,galay,100,40) <NEW_LINE> plt.subplot(4,4,2) <NEW_LINE> es.plot_solution(... | same as above tiles function but for a light mass passage | 625941cd7c178a314d6ef574 |
@app.route('/post/<int:post_id>/edit', methods=["POST"]) <NEW_LINE> @login_required <NEW_LINE> def edit_post(post_id): <NEW_LINE> <INDENT> post = Post.query.get(post_id) <NEW_LINE> new_title = request.form['new_title'] <NEW_LINE> new_desc = request.form['new_desc'] <NEW_LINE> if new_title == '': <NEW_LINE> <INDENT> new... | Allow owners to edit their post | 625941cd16aa5153ce36258c |
def __init__(self, get_element, num_elements, num_threads=1, queue_size=20): <NEW_LINE> <INDENT> self.get_element = get_element <NEW_LINE> assert num_threads > 0 <NEW_LINE> self.num_threads = num_threads <NEW_LINE> self.queue_size = queue_size <NEW_LINE> self.queue = queue.Queue(maxsize=queue_size) <NEW_LINE> self.ptr ... | Args:
get_element: a function that takes a pointer and returns an element
num_elements: total number of elements to put into the queue
num_threads: num of parallel threads, >= 1
queue_size: the maximum size of the queue. Set to some positive integer to save memory, otherwise, set to 0. | 625941cdfbf16365ca6f62d9 |
def add_project_to_workspace(settings): <NEW_LINE> <INDENT> workspace = settings["workspace"] <NEW_LINE> dpn = settings["default_project_name"] <NEW_LINE> file_exclude_patterns = settings["file_exclude_patterns"] <NEW_LINE> folder_exclude_patterns = settings["folder_exclude_patterns"] <NEW_LINE> switch_to_folder = { "p... | Add new project folder to workspace
Just Sublime Text 3 can support this method | 625941cd0383005118ecf6f7 |
def clean_vendor(name): <NEW_LINE> <INDENT> this_dir = path.dirname(path.abspath(__file__)) <NEW_LINE> vendor_dest = path.join(this_dir, 'ceph_deploy/lib/vendor/%s' % name) <NEW_LINE> run(['rm', '-rf', vendor_dest]) | Ensure that vendored code/dirs are removed, possibly when packaging when
the environment flag is set to avoid vendoring. | 625941cdad47b63b2c50a094 |
def __init__(self, version, response, solution): <NEW_LINE> <INDENT> super(TriggerPage, self).__init__(version, response) <NEW_LINE> self._solution = solution | Initialize the TriggerPage
:param Version version: Version that contains the resource
:param Response response: Response from the API
:param account_sid: A 34 character string that uniquely identifies this resource.
:returns: twilio_code.rest.api.v2010.account.usage.trigger.TriggerPage
:rtype: twilio.rest.api.v2010.a... | 625941cd71ff763f4b5497a0 |
def __str__(self): <NEW_LINE> <INDENT> return f"The account have ${self.balance} balance" | This represent the length of account in terms of balance in account | 625941cdd99f1b3c44c676a3 |
def _adjacentObject(self, site, classFilterList=None, ascend=True, beginNearest=True): <NEW_LINE> <INDENT> siteLength = len(site) <NEW_LINE> siteElements = site.elements <NEW_LINE> if (classFilterList is not None and len(classFilterList) == 1 and isinstance(classFilterList[0], str)): <NEW_LINE> <INDENT> if not site.has... | Core method for finding adjacent objects given a single site.
The `site` argument is a Stream that contains this
element. The index of this element if sound in this site,
and either the next or previous element, if found, is returned.
If `ascend` is True index values are
incremented; if False, index values are decrem... | 625941cd16aa5153ce36258d |
def _create_stock_expr(self, var_name, nf_name): <NEW_LINE> <INDENT> mult = ASTBinExpr('*', ASTVarRef(nf_name), ASTVarRef('time_step')) <NEW_LINE> add = ASTBinExpr('+', ASTVarRef(var_name), mult) <NEW_LINE> return ASTAssignExpr(var_name, add) | Create the AST structure representing an updating of a stock.
has the form:
stock = stock + net_flow * time_step | 625941cd283ffb24f3c55a16 |
def experimental_class_param_warning(param_name, class_name, stacklevel=3): <NEW_LINE> <INDENT> warnings.warn( ( f'"{param_name}" is an experimental parameter to the class "{class_name}". It may ' f"break in future versions, even between dot releases. {EXPERIMENTAL_WARNING_HELP}" ), ExperimentalWarning, stacklevel=stac... | Utility for warning that an argument to a constructor is experimental | 625941cdbd1bec0571d90744 |
def GetNScalParam(i_node): <NEW_LINE> <INDENT> ret = NeuronGPU_GetNScalParam(ctypes.c_int(i_node)) <NEW_LINE> if GetErrorCode() != 0: <NEW_LINE> <INDENT> raise ValueError(GetErrorMessage()) <NEW_LINE> <DEDENT> return ret | Get number of scalar parameters for a given node | 625941cdd10714528d5ffdf8 |
def add_block(self, block: Block, x: float, y: float, *args, **kwargs): <NEW_LINE> <INDENT> col, row = self.xy_to_grid(x, y) <NEW_LINE> row -= block.get_cell_size()[1] - 1 <NEW_LINE> return self.add_block_to_grid(block, col, row, *block.get_cell_size(), *args, **kwargs) | Adds a block to the game world at the grid cell that contains ('x', 'y')
Parameters:
block (Block): The block to add to the grid
x (float): The x-coordinate of the position contained by the cell
y (float): The y-coordinate of the position contained by the cell
- See add_block_to_grid for other paramet... | 625941cd2ae34c7f2600d246 |
@app.route('/application', methods=["POST"]) <NEW_LINE> def application(): <NEW_LINE> <INDENT> Firstname = request.form.get("firstname") <NEW_LINE> Lastname = request.form.get("lastname") <NEW_LINE> Salary = request.form.get("salary") <NEW_LINE> Job = request.form.get("job") <NEW_LINE> return render_template("applicati... | Returns string stating what user entered | 625941cd8e7ae83300e4b0e1 |
def database_connection(app): <NEW_LINE> <INDENT> database.init(**settings.DATABASE) <NEW_LINE> app.database = database <NEW_LINE> app.database.set_allow_sync(False) <NEW_LINE> app.objects = peewee_async.Manager(app.database) | Поднимаем коннект к базе | 625941cd8da39b475bd65089 |
def _url_to_dataframe(self, url, nest=None): <NEW_LINE> <INDENT> request = Request(url) <NEW_LINE> response = urlopen(request) <NEW_LINE> elevations = response.read() <NEW_LINE> data = json.loads(elevations) <NEW_LINE> if nest: <NEW_LINE> <INDENT> data = json_normalize(data[nest]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <... | Takes a url and returns the response in a pandas dataframe
:param url: str url
:param nest: column with nested data
:return: pandas dataframe containing data from url | 625941cd8c0ade5d55d3ead0 |
def get_dir(path, dest, env='base'): <NEW_LINE> <INDENT> client = salt.fileclient.get_file_client(__opts__) <NEW_LINE> return client.get_dir(path, dest, env) | Used to recursively copy a directory from the salt master
CLI Example:
salt '*' cp.get_dir salt://path/to/dir/ /minion/dest | 625941cd090684286d50edfa |
def _fit_lm(data, design_matrix, names): <NEW_LINE> <INDENT> from scipy import stats <NEW_LINE> n_samples = len(data) <NEW_LINE> n_features = np.product(data.shape[1:]) <NEW_LINE> if design_matrix.ndim != 2: <NEW_LINE> <INDENT> raise ValueError('Design matrix must be a 2d array') <NEW_LINE> <DEDENT> n_rows, n_predictor... | Aux function. | 625941cd94891a1f4081bbbe |
def ATR(self,DF,n): <NEW_LINE> <INDENT> df = DF.copy() <NEW_LINE> df['H-L']=abs(df['High']-df['Low']) <NEW_LINE> df['H-PC']=abs(df['High']-df['Adj Close'].shift(1)) <NEW_LINE> df['L-PC']=abs(df['Low']-df['Adj Close'].shift(1)) <NEW_LINE> df['TR']=df[['H-L','H-PC','L-PC']].max(axis=1,skipna=False) <NEW_LINE> df['ATR'] =... | function to calculate True Range and Average True Range | 625941cd3617ad0b5ed6800c |
def __init__(self): <NEW_LINE> <INDENT> self.IsAuthorized = None <NEW_LINE> self.CryptoType = None <NEW_LINE> self.CryptoContent = None | :param IsAuthorized: 是否授权
:type IsAuthorized: str
:param CryptoType: 加密类型
:type CryptoType: str
:param CryptoContent: 加密内容
:type CryptoContent: str | 625941cd4e4d5625662d44ec |
def test_solution_combination_with_identical_references(self): <NEW_LINE> <INDENT> f = self._freqs() <NEW_LINE> resp1 = self._i_i_response(f) <NEW_LINE> resp2 = self._i_v_response(f) <NEW_LINE> sol_a = Solution(f) <NEW_LINE> sol_a.add_response(resp1) <NEW_LINE> sol_a.add_response_reference(f, np.ones_like(f), label="A"... | Test identical reference curves in combined solution throws error | 625941cd6fece00bbac2d853 |
def _recursive_map_model(t, model_name): <NEW_LINE> <INDENT> remaining, done = set((t,)), set() <NEW_LINE> while 0 < len(remaining): <NEW_LINE> <INDENT> base = remaining.pop() <NEW_LINE> base.model_name = model_name <NEW_LINE> base.save() <NEW_LINE> done.add(base) <NEW_LINE> for derived in base.derived.all(): <NEW_LINE... | Can't remember what this does. Hnng :) | 625941cd5fcc89381b1e17d4 |
def list_outputs(self, is_plugged=None): <NEW_LINE> <INDENT> super(Smooth, self).list_outputs() <NEW_LINE> if self.sigma == Undefined and self.fwhm == Undefined: <NEW_LINE> <INDENT> print('\nInitialisation failed. Please, set one of the two input ' 'parameters sigma or fwhm ...!') <NEW_LINE> return <NEW_LINE> <DEDENT> ... | Dedicated to the initialisation step of the brick.
The main objective of this method is to produce the outputs of the
bricks (self.outputs) and the associated tags (self.inheritance_dic),
if defined here. In order not to include an output in the database,
this output must be a value of the optional key 'notInDb' of th... | 625941cd67a9b606de4a7fce |
def testAddAndExportKey(self): <NEW_LINE> <INDENT> apt.auth.add_key(WHEEZY_KEY) <NEW_LINE> self.assertEqual(apt.auth.export_key("46925553").split("\n")[2:], WHEEZY_KEY.split("\n")[2:]) | Add an example key. | 625941cd56b00c62f0f1476e |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.