code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def delete(request, id): <NEW_LINE> <INDENT> return base.delete(request, Task, id) | Delete of Task section.
| 625941cd3c8af77a43ae38bb |
def get_structure_thickness(self): <NEW_LINE> <INDENT> return self.d_cumulative[-1] | Return the structure thickness. | 625941cde76e3b2f99f3a925 |
def __init__(self, _pos, _colors): <NEW_LINE> <INDENT> if isinstance(_pos, Point3D): <NEW_LINE> <INDENT> self.pos = _pos <NEW_LINE> <DEDENT> elif isinstance(_pos, (tuple, list)): <NEW_LINE> <INDENT> self.pos = Point3D(_pos) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise ValueError(f"Piece only accepts the followin... | :param _pos: The 3D position of the
:param _colors: The colors on the piece | 625941cd091ae35668667078 |
def _internal_mount_specification(self, request): <NEW_LINE> <INDENT> from generated.definitions import RepositoryDefinition <NEW_LINE> from generated.definitions import LinkedSourceDefinition <NEW_LINE> def to_protobuf_single_mount(single_mount): <NEW_LINE> <INDENT> if single_mount.shared_path: <NEW_LINE> <INDENT> rai... | Staged Mount/Ownership Spec Wrapper for staged plugins.
Executed before creating a snapshot during sync or before
enable/disable. This plugin operation is run before mounting datasets
on staging to set the mount path and/or ownership.
Run mount/ownership spec operation for a staged source.
Args:
request (StagedMo... | 625941cdd58c6744b4257d7a |
def leafSimilar(self, root1, root2): <NEW_LINE> <INDENT> root1_list = [] <NEW_LINE> root2_list = [] <NEW_LINE> self.getleaf(root1, root1_list) <NEW_LINE> self.getleaf(root2, root2_list) <NEW_LINE> print(root1_list) <NEW_LINE> print(root2_list) <NEW_LINE> isequ = True <NEW_LINE> for i in range(len(root1_list)): <NEW_LIN... | :type root1: TreeNode
:type root2: TreeNode
:rtype: bool | 625941cd627d3e7fe0d68f6a |
def _variable_on_cpu(name, shape, initializer, use_fp16=False): <NEW_LINE> <INDENT> dtype = tf.float16 if use_fp16 else tf.float32 <NEW_LINE> var = tf.get_variable(name, shape, initializer=initializer, dtype=dtype) <NEW_LINE> return var | Helper to create a Variable stored on CPU memory.
Args:
name: name of the variable
shape: list of ints
initializer: initializer for Variable
Returns:
Variable Tensor | 625941cd76d4e153a657ec4b |
def get_data_link(self, params, context=None): <NEW_LINE> <INDENT> return self._client.call_method('SampleService.get_data_link', [params], self._service_ver, context) | Get a link, expired or not, by its ID. This method requires read administration privileges
for the service.
:param params: instance of type "GetDataLinkParams" (get_data_link
parameters. linkid - the link ID.) -> structure: parameter
"linkid" of type "link_id" (A link ID. Must be globally unique.
Always assign... | 625941cd2eb69b55b151c9c9 |
def splitOutput(output): <NEW_LINE> <INDENT> output = re.split("== to simple firewall ==", output)[1] <NEW_LINE> output = re.split("== to even-simpler firewall ==", output)[0] <NEW_LINE> result = list() <NEW_LINE> for line in re.split("\n", output): <NEW_LINE> <INDENT> splitted = [match.group(0) for match in re.findite... | Parse output of the fffuu haskel-tool.
Keys in the list elements:
- action
- protocol
- source
- destination
- source
- inInterface (Optional)
- outInterface (Optional)
- destPorts (Optional)
- srcPorts (Optional)
:param output: Output of fffuu
:type output: str
:returns: List of d... | 625941cdfff4ab517eb2f556 |
def __connect__(self): <NEW_LINE> <INDENT> self.sock = socket.socket() <NEW_LINE> self.sock.settimeout(5) <NEW_LINE> self.sock.connect((self.address, self.port)) <NEW_LINE> self.sock.settimeout(None) | Connect to the TiVo within five seconds or report error. | 625941cd460517430c39429f |
def rescue(self, action, format='text'): <NEW_LINE> <INDENT> def _rescue_save(): <NEW_LINE> <INDENT> self.rpc.request_save_rescue_configuration() <NEW_LINE> return True <NEW_LINE> <DEDENT> def _rescue_delete(): <NEW_LINE> <INDENT> self.rpc.request_delete_rescue_configuration() <NEW_LINE> return True <NEW_LINE> <DEDENT>... | Perform action on the "rescue configuration".
:param str action: identifies the action as follows:
* "get" - retrieves/returns the rescue configuration via **format**
* "save" - saves current configuration as rescue
* "delete" - removes the rescue configuration
* "reload" - loads the rescue config as ... | 625941cdde87d2750b85fead |
def test_remove_untagged_layers(self): <NEW_LINE> <INDENT> test_layers = deepcopy(self.layers) <NEW_LINE> tagged_layers = dockgraph.remove_untagged_layers(test_layers) <NEW_LINE> for identifier, layer in test_layers.items(): <NEW_LINE> <INDENT> self.assertEqual(layer.identifier, identifier) <NEW_LINE> <DEDENT> for iden... | test the remove_untagged_layers function | 625941cdc4546d3d9de72b4f |
def normAxis(self): <NEW_LINE> <INDENT> return self.normDirectDown().asAxis() | Normal Axis.
:return: Axis normal to the Plane self instance | 625941cdf548e778e58cd698 |
def test_addon_layer(self): <NEW_LINE> <INDENT> from spirit.plone.theming.interfaces import ISpiritPloneThemingLayer <NEW_LINE> self.assertIn(ISpiritPloneThemingLayer, registered_layers()) | Validate that the browserlayer for our product is installed. | 625941cd187af65679ca5239 |
@task <NEW_LINE> def migratedb(role = "action", name = "webapp"): <NEW_LINE> <INDENT> with warn_only(): <NEW_LINE> <INDENT> local("psql -U %s -c 'CREATE DATABASE %s;'" %(role, name.lower())) <NEW_LINE> <DEDENT> local("honcho run python manage.py makemigrations") <NEW_LINE> local("honcho run python manage.py migrate") | Create a new postgres database. | 625941cd3cc13d1c6d3c7495 |
def finish_tick(self): <NEW_LINE> <INDENT> if self.paused: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if self.draw_trail_points: <NEW_LINE> <INDENT> if (self.lifetime % self.trail_points_interval) == 0: <NEW_LINE> <INDENT> self.trail_points.push(self.pos) <NEW_LINE> <DEDENT> <DEDENT> elif not self.draw_trail_points... | Can be called after Particle.tick to finish operations. | 625941cd6fb2d068a760f1b8 |
def __init__(self, **kwargs): <NEW_LINE> <INDENT> self.title = '' <NEW_LINE> self.kwargs = kwargs <NEW_LINE> self.tbx = DummyTbx() | title : str | 625941cd283ffb24f3c55a1c |
def sgd_update(weight=None, grad=None, lr=_Null, wd=_Null, rescale_grad=_Null, clip_gradient=_Null, out=None, name=None, **kwargs): <NEW_LINE> <INDENT> return (0,) | Update function for Stochastic Gradient Descent (SDG) optimizer.
It updates the weights using::
weight = weight - learning_rate * gradient
If weight is of ``row_sparse`` storage type,
only the row slices whose indices appear in grad.indices are updated::
for row in gradient.indices:
weight[row] = weight[row]... | 625941cd287bf620b61d3b7e |
def as_name(upi, taxid): <NEW_LINE> <INDENT> return "Unique RNA Sequence {upi}_{taxid}".format( upi=upi, taxid=taxid, ) | Create the name of the RNA sequence using the UPI and taxid. | 625941cdcad5886f8bd270f4 |
def user_from_object(userobject): <NEW_LINE> <INDENT> pass | Function to bridge existing User Manager and User objects
as defined in mpx.lib.user.User with the Users defined here. | 625941cd92d797404e3042a4 |
def output_signature(self): <NEW_LINE> <INDENT> return _trellis.trellis_viterbi_combined_fb_sptr_output_signature(self) | output_signature(self) -> gr_io_signature_sptr | 625941cd15fb5d323cde0c2a |
def test_target_eq(self): <NEW_LINE> <INDENT> target_example_0 = Target([(3, 5), (6, 8)], '1', 'Iphone', 'text with Iphone', 1) <NEW_LINE> target_example_1 = Target([(1, 5)], '3', 'Iphone', 'text with Iphone', 1) <NEW_LINE> target_example_2 = Target([(1, 2)], '2', 'Iphone', 'text with Iphone', 1) <NEW_LINE> target_exam... | Test the Target __eq__ method | 625941cdd99f1b3c44c676a9 |
@utils.supported_filters([]) <NEW_LINE> @database.run_in_session() <NEW_LINE> def delete_cluster_host_config( session, deleter, cluster_id, host_id ): <NEW_LINE> <INDENT> clusterhost = utils.get_db_object( session, models.ClusterHost, cluster_id=cluster_id, host_id=host_id ) <NEW_LINE> return _delete_clusterhost_config... | Delete a clusterhost config. | 625941cde64d504609d7495a |
def dividenconquer(delta, startSigNum, endSigNum, incorrectIndices, dotBCache, dotACache, sumECache, dotDCache, A, IDlist, Mlist, S1list, S2list, S3list, g2, u1b, u2b, ub): <NEW_LINE> <INDENT> global zz, l <NEW_LINE> input = [delta, startSigNum, endSigNum, incorrectIndices, dotBCache, dotACache, sumECache, dotDCache, A... | global k
global m | 625941cd507cdc57c6306df5 |
def word_stats(word_counts): <NEW_LINE> <INDENT> num_unique = len(word_counts) <NEW_LINE> counts = word_counts.values() <NEW_LINE> return (num_unique,counts) | Return number of unique words and word frequences. | 625941cd379a373c97cfac5f |
def test_agilent34410a_r_type_error(): <NEW_LINE> <INDENT> wrong_type = "42" <NEW_LINE> with expected_protocol( ik.agilent.Agilent34410a, [ "CONF?", ], [ "VOLT +1.000000E+01,+3.000000E-06", ], ) as dmm: <NEW_LINE> <INDENT> with pytest.raises(TypeError) as err_info: <NEW_LINE> <INDENT> dmm.r(wrong_type) <NEW_LINE> <DEDE... | Raise TypeError if count is not a integer. | 625941cda8ecb033257d31e8 |
def read_from_markdown(self, filename): <NEW_LINE> <INDENT> if isinstance(filename, str): <NEW_LINE> <INDENT> self.__markdown_filename = filename <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print("type of filename is not string") <NEW_LINE> <DEDENT> with open(self.__markdown_filename, "r") as fn: <NEW_LINE> <INDENT> ... | :param filename: Set filename of markdown target
Directly read data from markdown file and store it | 625941cd97e22403b379d0b4 |
def lengthOfLIS(self, nums): <NEW_LINE> <INDENT> if not nums or len(nums) == 0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> dp = [1 for _ in range(len(nums))] <NEW_LINE> for i, num in enumerate(nums): <NEW_LINE> <INDENT> for j in range(i): <NEW_LINE> <INDENT> if nums[j] < num: <NEW_LINE> <INDENT> dp[i] = max(dp[i]... | :type nums: List[int]
:rtype: int | 625941cd91af0d3eaac9bb34 |
def createInternetRadioStation(self, streamUrl, name, homepageUrl=None): <NEW_LINE> <INDENT> methodName = 'createInternetRadioStation' <NEW_LINE> viewName = '{}.view'.format(methodName) <NEW_LINE> q = self._getQueryDict({ 'streamUrl': streamUrl, 'name': name, 'homepageUrl': homepageUrl}) <NEW_LINE> req = self._getReque... | since 1.16.0
Create an internet radio station
streamUrl:str The stream URL for the station
name:str The user-defined name for the station
homepageUrl:str The homepage URL for the station | 625941cd07f4c71912b1159d |
def remember(self, request, principal, **kw): <NEW_LINE> <INDENT> return [] | Not used neither needed | 625941cd66656f66f7cbc2c6 |
def put(self, rsrc_id, rsrc_data): <NEW_LINE> <INDENT> req_dir = self._req_dirname(rsrc_id) <NEW_LINE> fs.mkdir_safe(req_dir) <NEW_LINE> with io.open(os.path.join(req_dir, _REQ_FILE), 'w') as f: <NEW_LINE> <INDENT> os.fchmod(f.fileno(), 0o644) <NEW_LINE> yaml.dump(rsrc_data, explicit_start=True, explicit_end=True, defa... | Request creation/update of a resource.
:param `str` rsrc_id:
Unique identifier for the requested resource.
:param `str` rsrc_data:
(New) Parameters for the requested resource. | 625941cd435de62698dfdd67 |
def get_next_value(deck_list): <NEW_LINE> <INDENT> move_joker_1(deck_list) <NEW_LINE> move_joker_2(deck_list) <NEW_LINE> triple_cut(deck_list) <NEW_LINE> insert_top_to_bottom(deck_list) <NEW_LINE> value_of_keystream = get_card_at_top_index(deck_list) <NEW_LINE> return value_of_keystream | (list of int) -> int
Return the next potential keystream after it has been encrypted
with all five steps of the algorithm.
>>> get_next_value([1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 3, 6,
9, 12, 15, 18, 21,
24, 27, 2, 5, 8, 11, 14, 17, 20, 23, 26])
11
>>> deck_list = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 3, 6,
9, 12, 15,... | 625941cd4f6381625f114b55 |
def list_objects(self, s3_prefix_path): <NEW_LINE> <INDENT> bucket_name, prefix = S3Util.get_bucket_and_key(s3_prefix_path) <NEW_LINE> bucket = self.s3_resource.Bucket(bucket_name) <NEW_LINE> return ["s3://" + bucket_name + "/" + key.key for key in bucket.objects.filter(Prefix=prefix)] | Lists objects in a S3 bucket which paths start with the specified s3_prefix_path
:param s3_prefix_path: S3 path which is used as a prefix for filtering objects
:return: a list of the paths to the objects in the particular bucket | 625941cd4f6381625f114b56 |
def is_mole(self, beta): <NEW_LINE> <INDENT> k = self.Sup(beta) <NEW_LINE> if k == 0: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> if k <= self.k: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> for e in self.private_items: <NEW_LINE> <INDENT> if self.p_breach(beta, e, k) > self.h: <NEW_LINE> <INDENT> retur... | beta - insieme di attributi | 625941cdd8ef3951e3243658 |
def stopLogging(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.stopped = True <NEW_LINE> logger.log( self.loggerLevel, "{0}[{1}] Stop logging after {2} ...".format(self.prefix, str(datetime.now()), str(datetime.now()-self.initTime)) ) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> pass | ! @brief stop logging | 625941cd1f5feb6acb0c4c6b |
def __init__(self, architecture, weights, save_location=None, learning_rate=0.1, discount_factor=0.95, epsilon=0.10, num_teammates=2): <NEW_LINE> <INDENT> super().__init__(architecture, weights, epsilon, learning_rate, num_teammates) <NEW_LINE> self.target_net = self.get_main_net_copy() <NEW_LINE> self.discount_factor ... | :param state_dims: Dimensionality of state space
:param load_location: Path where network model is loaded from
:param save_location: Path where network model shall be saved | 625941cd76e4537e8c35178e |
def add(a, b): <NEW_LINE> <INDENT> print(a + b) | function that adds 2 numbers | 625941cd63b5f9789fde7200 |
def process(self): <NEW_LINE> <INDENT> if not isinstance(self.__rows__, tuple): <NEW_LINE> <INDENT> with SelectionLock: <NEW_LINE> <INDENT> self.__rows__ = tuple(self.__rows__) <NEW_LINE> <DEDENT> <DEDENT> return self | Processes the Selection, then returns it
Use this if chaining selections but you still need the parent
for later usage. Or if their are mulitple chains from the
same parent selection | 625941cd3346ee7daa2b2e86 |
def load_url_dist(url, model_dir=None): <NEW_LINE> <INDENT> rank, world_size = get_dist_info() <NEW_LINE> rank = int(os.environ.get('LOCAL_RANK', rank)) <NEW_LINE> if rank == 0: <NEW_LINE> <INDENT> checkpoint = model_zoo.load_url(url, model_dir=model_dir) <NEW_LINE> <DEDENT> if world_size > 1: <NEW_LINE> <INDENT> torch... | In distributed setting, this function only download checkpoint at
local rank 0 | 625941cd63b5f9789fde7201 |
def test_do_tree_insert(self): <NEW_LINE> <INDENT> numbers = [10, 7, 15, 12, 1, 3, 33, 35] <NEW_LINE> my_tree = Node(numbers[0]) <NEW_LINE> for number in numbers[1:]: <NEW_LINE> <INDENT> my_tree.add(number) | Just testing the insert | 625941cdd58c6744b4257d7b |
def update(self,x, y): <NEW_LINE> <INDENT> self.rect.x = x <NEW_LINE> self.rect.y = y | Called each frame. | 625941cd9c8ee82313fbb890 |
def counts(table, sample, otu): <NEW_LINE> <INDENT> if sample in table: <NEW_LINE> <INDENT> if otu in table[sample]: <NEW_LINE> <INDENT> return table[sample][otu] <NEW_LINE> <DEDENT> <DEDENT> return 0 | get counts from table structure, or 0 if sample or otu missing | 625941cd63d6d428bbe4460a |
def p_funccall(p): <NEW_LINE> <INDENT> func = getattr(functions, p[1]) <NEW_LINE> if len(p) == 2: <NEW_LINE> <INDENT> p[0] = func() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> p[0] = func(*p[3]) | funccall : IDENTIFIER
| IDENTIFIER OPENBKT args CLOSEBKT | 625941cdcdde0d52a9e5314e |
def getPos(self): <NEW_LINE> <INDENT> s = self.mc.conn.sendReceive("robot.getPos", self.robotId) <NEW_LINE> return Vec3((float(x) for x in s.split(","))) | Get entity position (entityId:int) => Vec3 | 625941cde64d504609d7495b |
def get_level_from_experience(experience): <NEW_LINE> <INDENT> ret_level = MIN_LEVEL <NEW_LINE> for i in range(MAX_LEVEL): <NEW_LINE> <INDENT> if LEVEL_EXP_MAPPING.get(i + 1, DEFAULT_MAX_XP) <= experience: <NEW_LINE> <INDENT> ret_level = i + 1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> <DED... | Returns the lowest level possible for the given experience. | 625941cd8a349b6b435e828e |
def init_database(app: Flask, config: Config, db_session=None) -> None: <NEW_LINE> <INDENT> if not db_session: <NEW_LINE> <INDENT> engine = create_db_engine_from_config(config=config) <NEW_LINE> db_session = create_db_session(engine=engine) <NEW_LINE> <DEDENT> app.db_session = db_session <NEW_LINE> @app.teardown_appcon... | Connect to the database and attach DB session to the app. | 625941cd379a373c97cfac60 |
def is_valid(self): <NEW_LINE> <INDENT> return self.number_samples > 0 | Returns true if valid datasets resp. images are available. | 625941cd66673b3332b921ac |
def build_parse_child_dict(self, words, postags, arcs): <NEW_LINE> <INDENT> child_dict_list = [] <NEW_LINE> for index in range(len(words)): <NEW_LINE> <INDENT> child_dict = dict() <NEW_LINE> for arc_index in range(len(arcs)): <NEW_LINE> <INDENT> if arcs[arc_index].head == index + 1: <NEW_LINE> <INDENT> if arcs[arc_inde... | 为句子中的每个词语维护一个保存句法依存儿子节点的字典
Args:
words: 分词列表
postags: 词性列表
arcs: 句法依存列表 | 625941cda17c0f6771cbe16b |
def transpose_axes(image, axes, asaxes='CTZYX'): <NEW_LINE> <INDENT> for ax in axes: <NEW_LINE> <INDENT> if ax not in asaxes: <NEW_LINE> <INDENT> raise ValueError('unknown axis %s' % ax) <NEW_LINE> <DEDENT> <DEDENT> shape = image.shape <NEW_LINE> for ax in reversed(asaxes): <NEW_LINE> <INDENT> if ax not in axes: <NEW_L... | Return image with its axes permuted to match specified axes.
A view is returned if possible.
>>> transpose_axes(numpy.zeros((2, 3, 4, 5)), 'TYXC', asaxes='CTZYX').shape
(5, 2, 1, 3, 4) | 625941cd21bff66bcd684a6e |
def resolve_last_read_post_absolute_url(self): <NEW_LINE> <INDENT> user = get_current_user() <NEW_LINE> if user is None or not user.is_authenticated: <NEW_LINE> <INDENT> return self.first_unread_post().get_absolute_url() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> pk, pos = self.resolve_last_... | resolve the url that leads to the last post the current user has read. If current user is anonymous, just lead to the thread start.
:return: the url
:rtype: str | 625941cd293b9510aa2c33b2 |
def parse_var_names(_str): <NEW_LINE> <INDENT> global found_first_function <NEW_LINE> if found_first_function: <NEW_LINE> <INDENT> space_sep_str = re.sub('([A-Z]+)', r' \1', _str).lower() <NEW_LINE> space_sep_str = re.sub('_', ' ', space_sep_str).lower() <NEW_LINE> return " " + space_sep_str + " " <NEW_LINE> <DEDENT> e... | Separate any snake_case or CamelCase words before adding to description | 625941cd9c8ee82313fbb891 |
def getHtmlStrMsg(self, strUrl): <NEW_LINE> <INDENT> httpResponseData = self.getHtmlHttpReponse(strUrl) <NEW_LINE> if httpResponseData is not None: <NEW_LINE> <INDENT> strCoding = httpResponseData.headers.get_content_charset() <NEW_LINE> bytesData = httpResponseData.read() <NEW_LINE> if strCoding is not None: <NEW_LINE... | describe: 根据url来获取页面的源代码内容, 已按页面编码来解码, 如为获取到页面编码, 则默认使用utf-8编码
:param strUrl: 需要获取的页面的url
:return: 返回页面数据, 为str类型, 如果请求出错, 则页面数据返回None | 625941cd01c39578d7e74f57 |
def get_output_level(self, channel: Union[int, str]) -> float: <NEW_LINE> <INDENT> if isinstance(channel, str): <NEW_LINE> <INDENT> channel = self.DEFAULTS['outputBNC'][channel] <NEW_LINE> <DEDENT> cmd = f'LAMP? {channel}' <NEW_LINE> respons = self.query(cmd) <NEW_LINE> return float(respons) | Request output amplitude of a channel
Arguments:
channel -- str/int corresponding to a channel (see self.DEFAULTS)
Returns --float, the amplitude in Volts | 625941cdd4950a0f3b08c46a |
def doa(x, pars, dx=False): <NEW_LINE> <INDENT> if not dx: <NEW_LINE> <INDENT> return np.atleast_1d(np.arctan2(x[1], x[0])) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return np.array([-x[1], x[0]]) / (x[0] ** 2 + x[1] ** 2).T.flatten() | Direction of arrival in 2D.
Parameters
----------
x : 2-D ndarray
Returns
------- | 625941cdbf627c535bc132ea |
def initialZeroHebb(self): <NEW_LINE> <INDENT> return torch.zeros(self.nbf, self.nbf, dtype=torch.float, device=self.torch_dev) | Creates variable to store Hebbian plastisity coefficients | 625941cd7047854f462a1525 |
def getAllContextsByClass(self, className): <NEW_LINE> <INDENT> el = self.getContextByClass(className) <NEW_LINE> while el is not None: <NEW_LINE> <INDENT> yield el <NEW_LINE> el = el.getContextByClass(className, getElementMethod='getElementBeforeOffset') | Returns a generator that yields elements found by `.getContextByClass` and
then finds the previous contexts for that element.
>>> s = stream.Stream()
>>> s.append(meter.TimeSignature('2/4'))
>>> s.append(note.Note('C'))
>>> s.append(meter.TimeSignature('3/4'))
>>> n = note.Note('D')
>>> s.append(n)
for ts in n.getAl... | 625941cd50812a4eaa59c43d |
def load_reference_points(path = REFERENCE_POINTS_PATH): <NEW_LINE> <INDENT> global REFERENCE_POINTS_DICT <NEW_LINE> dict, file_lines = {}, [] <NEW_LINE> if not os.path.exists(path): <NEW_LINE> <INDENT> print("ReferencePoints.csv not found") <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> with open(path) as f: file_lines ... | Loads the coordinates of all the reference points into a dict
Reference Point Name: (latitude, longtitude)
the coordinates are stored as a tuple of two floating point values in the dict, whereas the key is a string | 625941cdc432627299f04d61 |
def GetViewInfo(views_fullname): <NEW_LINE> <INDENT> view_paths = sorted(glob.glob(views_fullname)) <NEW_LINE> num_frames = [GetNumFrames(i) for i in view_paths] <NEW_LINE> min_num_frames = min(num_frames) <NEW_LINE> num_views = len(view_paths) <NEW_LINE> return num_views, min_num_frames, view_paths, num_frames | Return information about a group of views. | 625941cd6fece00bbac2d85a |
def load_data(self, profdatafile): <NEW_LINE> <INDENT> import pstats <NEW_LINE> try: <NEW_LINE> <INDENT> stats_indi = [pstats.Stats(profdatafile), ] <NEW_LINE> <DEDENT> except (OSError, IOError): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self.profdata = stats_indi[0] <NEW_LINE> if self.compare_file is not None: <N... | Load profiler data saved by profile/cProfile module | 625941cd796e427e537b06e2 |
def _login_input_mfa_challenge(self, state_token, next_url): <NEW_LINE> <INDENT> pass_code = self._mfa_code <NEW_LINE> if pass_code is None: <NEW_LINE> <INDENT> pass_code = self.ui.input("Enter verification code: ") <NEW_LINE> <DEDENT> response = self._http_client.post( next_url, params={'rememberDevice': self._remembe... | Submit verification code for SMS or TOTP authentication methods | 625941cdb57a9660fec339a0 |
def test_instantiate(self): <NEW_LINE> <INDENT> em = EmailMsg() <NEW_LINE> self.assertIsInstance(em._msg, MIMEMultipart) | Instance is initialize correctly | 625941cd4d74a7450ccd42df |
@nottest <NEW_LINE> def test_running_in_different_directory(): <NEW_LINE> <INDENT> work_folder = "dakota_runs" <NEW_LINE> run_directory = os.path.abspath(os.path.join(os.getcwd(), "running_here")) <NEW_LINE> work_directory = os.path.abspath(os.path.join(run_directory, "..", "working_here")) <NEW_LINE> configuration_fil... | Test ability to provide parameter names. | 625941cd73bcbd0ca4b2c192 |
def maxProfit(self, prices): <NEW_LINE> <INDENT> if not prices: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> pro = 0 <NEW_LINE> l = len(prices) <NEW_LINE> for i in range(l-1): <NEW_LINE> <INDENT> if prices[i+1] > prices[i]: <NEW_LINE> <INDENT> pro += prices[i+1] - prices[i] <NEW_LINE> <DEDENT> <DEDENT> return pro | :type prices: List[int]
:rtype: int | 625941cd9f2886367277a9a9 |
def info(self, event, command, usercommand): <NEW_LINE> <INDENT> pretty_json = json_dumps(self.bot.irc.servers[event.server].info, sort_keys=True, indent=4) <NEW_LINE> info_filename = os.sep.join(['config', 'modules', 'info_dict.json']) <NEW_LINE> with open(info_filename, 'w', encoding='utf-8') as info_file: <NEW_LINE>... | Output bot debug info
@call_level owner | 625941cdcdde0d52a9e5314f |
def loadTable(name, query=None, columns=None): <NEW_LINE> <INDENT> dir_path = os.path.join(table_dir, 'feather') <NEW_LINE> file = os.path.join(dir_path, name +'.feather') <NEW_LINE> d = feather.read_dataframe(file) <NEW_LINE> if columns is None: <NEW_LINE> <INDENT> table = d <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDEN... | This function loads all feather tables in filepath into workspace. | 625941cd21a7993f00bc7e0b |
def test_update_vcs_entity(self): <NEW_LINE> <INDENT> self.main_vcs_resource.save = Mock() <NEW_LINE> self.other_vcs_resource.save = Mock() <NEW_LINE> self.update_main_vcs_entity(string="New Translated String") <NEW_LINE> assert self.main_vcs_translation.strings == {None: "New Translated String"} <NEW_LINE> assert self... | Update the VCS translations with translations in the database. | 625941cdd53ae8145f87a38c |
def f_unc(x, a, b, x0): <NEW_LINE> <INDENT> return f_raw(x, a, b, x0) | similar to the raw function call, but uses unp instead of np for uncertainties calculations.
:return: a + b*(x-x0)**2 , b < 0 | 625941cd004d5f362079a44e |
def BNF(): <NEW_LINE> <INDENT> global bnf <NEW_LINE> if not bnf: <NEW_LINE> <INDENT> intNumber = Word(nums) <NEW_LINE> plus, minus, mult, div = map(Literal, "+-*/") <NEW_LINE> lpar, rpar = map(Suppress, "()") <NEW_LINE> op = plus | minus | mult | div <NEW_LINE> expr = Forward() <NEW_LINE> atom = intNumber.setParseActio... | op :: '*' | '/' | '+' | '-'
integer :: ['+' | '-'] '0'..'9'+
atom :: integer | '(' expr ')'
expr :: atom [ op atom ]* | 625941cd26068e7796caedfb |
def crossProduct(self, Rows, Cols): <NEW_LINE> <INDENT> return [row + col for row in Rows for col in Cols] | This method receive two strings.
Keyword arguments:
Rows -- string of elements of a row e.g. 'ABCDEFGHI'
Cols -- string of elements of a cols e.g. '123456789'
Return:
The cross product of elements in Rows and elements in Cols. | 625941cd4f88993c3716c183 |
def plotagnum(kind, d, iskeyfile='True', keyfile='keylist', type='b'): <NEW_LINE> <INDENT> md = cl.dictmeans(d) <NEW_LINE> if iskeyfile == 'True': <NEW_LINE> <INDENT> keylist = cmn.load_keys(keyfile) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> keylist = sorted(d.keys()) <NEW_LINE> <DEDENT> ylabel = 'Avg num' <NEW_LIN... | Generates a bar plot of the mean number of times each behavior occurs
for each genotype.
kind = 'charge' (wing threat + charge, orientation, or lunge),
'escd' (dominant escalation),
'escm' (mutual escalation)
iskeyfile: specifies whether a keylist file exists; default is 'true'
keyfile: file with a list of the genot... | 625941cdbd1bec0571d9074b |
def sentinel_sentinels(self, service_name): <NEW_LINE> <INDENT> return self.execute_command('SENTINEL SENTINELS', service_name) | Returns a list of sentinels for ``service_name`` | 625941cd1f5feb6acb0c4c6c |
def detunings_code(Neu, Nl, pairs, omega_levelu, iu0, ju0): <NEW_LINE> <INDENT> code_det = "" <NEW_LINE> for l in range(Nl): <NEW_LINE> <INDENT> for pair in pairs[l]: <NEW_LINE> <INDENT> iu, ju = pair <NEW_LINE> code_det += " delta"+str(l+1) <NEW_LINE> code_det += "_"+str(iu+1) <NEW_LINE> code_det += "_"+str(ju+1) <... | Get the code to calculate the simplified detunings.
>>> Ne = 6
>>> Nl = 2
>>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0]
>>> xi = np.zeros((Nl, Ne, Ne))
>>> coup = [[(1, 0), (2, 0)], [(3, 0), (4, 0), (5, 0)]]
>>> for l in range(Nl):
... for pair in coup[l]:
... xi[l, pair[0], pair[1]] = 1.0
...... | 625941cd56ac1b37e62642eb |
def _update_ctx(self, attrs: DataFrame) -> None: <NEW_LINE> <INDENT> coli = {k: i for i, k in enumerate(self.columns)} <NEW_LINE> rowi = {k: i for i, k in enumerate(self.index)} <NEW_LINE> for jj in range(len(attrs.columns)): <NEW_LINE> <INDENT> cn = attrs.columns[jj] <NEW_LINE> j = coli[cn] <NEW_LINE> for rn, c in att... | Update the state of the Styler.
Collects a mapping of {index_label: ['<property>: <value>']}.
Parameters
----------
attrs : DataFrame
should contain strings of '<property>: <value>;<prop2>: <val2>'
Whitespace shouldn't matter and the final trailing ';' shouldn't
matter. | 625941cd6e29344779a6272d |
def __getitem__(self, item): <NEW_LINE> <INDENT> if not hasattr(self, 'hdu_list'): <NEW_LINE> <INDENT> self.update_hdu_list() <NEW_LINE> <DEDENT> ext,ver,ver_sent = self._extract_item(item) <NEW_LINE> try: <NEW_LINE> <INDENT> hdu = self.hdu_list[ext] <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> ext='%s' % ext <NEW_L... | Get an hdu by number, name, and possibly version | 625941cdd486a94d0b98e261 |
def apply_tension(self, T_avg=None, T_left=None, T_right=None): <NEW_LINE> <INDENT> s_l = self.spokes[0] <NEW_LINE> s_r = self.spokes[1] <NEW_LINE> if T_avg is not None: <NEW_LINE> <INDENT> T_l = 2 * T_avg * np.abs(s_r.n[0]) / (np.abs(s_l.n[0]*s_r.n[1]) + np.abs(s_r.n[0]*s_l.n[1])) <NEW_LINE> T_r = 2 * T... | Apply tension to spokes based on average radial tension. | 625941cd8c3a8732951584d7 |
def format_custom_message(self, message, text, data): <NEW_LINE> <INDENT> if message == "cheer" and len(data) == 2: <NEW_LINE> <INDENT> text = text.format(user=data[0], bits=data[1]) <NEW_LINE> <DEDENT> elif message == "sub" and len(data) == 5: <NEW_LINE> <INDENT> text = text.format(user=data[0], streak=data[1], tier=d... | Add relevant data to custom bot messages. | 625941cdd164cc6175782e6a |
def make_pod_spec(self) -> Dict: <NEW_LINE> <INDENT> config = self.model.config <NEW_LINE> image_details = { "imagePath": config["image"], } <NEW_LINE> ports = [ {"name": "pgsql", "containerPort": 5432, "protocol": "TCP"}, ] <NEW_LINE> config_fields = { "JUJU_NODE_NAME": "spec.nodeName", "JUJU_POD_NAME": "metadata.name... | Set up and return our full pod spec here. | 625941cd85dfad0860c3af77 |
def pos_tagger(token_list): <NEW_LINE> <INDENT> return pos_tag(token_list) | Takes a sentence as input and tags tokens with its part of speech
Parameters
----------
token_list : List of tokens to tag its part-of-speech | 625941cda219f33f34628a85 |
def set_UserRegion(self, value): <NEW_LINE> <INDENT> super(RemovePermissionInputSet, self)._set_input('UserRegion', value) | Set the value of the UserRegion input for this Choreo. ((optional, string) The AWS region that corresponds to the SQS endpoint you wish to access. The default region is "us-east-1". See description below for valid values.) | 625941cd498bea3a759b9bcb |
@login_required <NEW_LINE> def editModel(request, model_name, sheettype): <NEW_LINE> <INDENT> c, f = getClasses(sheettype) <NEW_LINE> model = get_object_or_404(c, pk=model_name) <NEW_LINE> tags = [] <NEW_LINE> if sheettype in ["scenario", "studie"]: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT>... | Constructs a form accoring to existing model | 625941cd1d351010ab855c38 |
def move_nodes(self, match, key, chunk_length = 2000, verbose = True, test_mode = False): <NEW_LINE> <INDENT> ret = " RETURN n.%s AS key, labels(n) AS labels , " "properties(n) as properties" % key <NEW_LINE> if test_mode: <NEW_LINE> <INDENT> ret += " limit 100" <NEW_LINE> <DEDENT> results = self.From.co... | match = any match statement in which a node to move is specified with variable n.
key = attribute used in merge statements to non-redundantly add content. must be present
in matched nodes.
Optionally set commit chunk length, verbosity, test mode (limit 100)
WARNING: THIS DEPENDS ON MATCH BETWEEN SETS OF LABELS. => pot... | 625941cde76e3b2f99f3a927 |
def connect(self): <NEW_LINE> <INDENT> if self.user and self.passwd: <NEW_LINE> <INDENT> self.conn = py.MongoClient(self.host, self.port,username=self.user,password=self.passwd) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.conn = pymongo.MongoClient(self.host, self.port) <NEW_LINE> <DEDENT> self.handler = self.co... | 连接MongoDB | 625941cd24f1403a92600c82 |
def __init__(self, space, exponent): <NEW_LINE> <INDENT> super().__init__(space=space, linear=False) <NEW_LINE> self.__norm = LpNorm(space, exponent) <NEW_LINE> self.__exponent = float(exponent) | Initialize a new instance.
Parameters
----------
space : `DiscreteLp` or `FnBase`
Domain of the functional.
exponent : int or infinity
Specifies wich norm to use. | 625941cd7cff6e4e81117aa2 |
def create_master_turnstile_file(filenames, output_file): <NEW_LINE> <INDENT> with open(output_file, 'w') as master_file: <NEW_LINE> <INDENT> master_file.write('C/A,UNIT,SCP,DATEn,TIMEn,DESCn,ENTRIESn,EXITSn\n') <NEW_LINE> for filename in filenames: <NEW_LINE> <INDENT> with open(filename, 'r') as readfile: <NEW_LINE> <... | Write a function that takes the files in the list filenames, which all have the
columns 'C/A, UNIT, SCP, DATEn, TIMEn, DESCn, ENTRIESn, EXITSn', and consolidates
them into one file located at output_file. There should be ONE row with the column
headers, located at the top of the file. The input files do not have colu... | 625941cd283ffb24f3c55a1d |
def strStr(self, haystack, needle): <NEW_LINE> <INDENT> if len(needle) == 0: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> if len(needle) > len(haystack): <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> lenSource = len(haystack) <NEW_LINE> lenTarget = len(needle) <NEW_LINE> for i in range(lenSource-lenTarget+1): <... | :type haystack: str
:type needle: str
:rtype: int | 625941cd5fcc89381b1e17db |
def portals_id_designs_nk_tags_fk_delete_with_http_info(self, id, nk, fk, **kwargs): <NEW_LINE> <INDENT> all_params = ['id', 'nk', 'fk'] <NEW_LINE> all_params.append('callback') <NEW_LINE> all_params.append('_return_http_data_only') <NEW_LINE> params = locals() <NEW_LINE> for key, val in iteritems(params['kwargs']): <N... | Delete a related item by id for tags.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.portals_id_designs_nk_t... | 625941cdd58c6744b4257d7c |
def p_expression_logop(p): <NEW_LINE> <INDENT> p[0] = ('logop', p[1], p[2], p[3]) | expression : expression LT expression
| expression GT expression
| expression LTE expression
| expression GTE expression
| expression NOTEQ expression
| expression EQ expression
| expression AND expression
| expression OR expression | 625941cd4d74a7450ccd42e0 |
def pick_label(self, part_gen, part_file, train_size, psize=1.0, seed=None): <NEW_LINE> <INDENT> if part_gen == 1: <NEW_LINE> <INDENT> print('==== generating partitions ====') <NEW_LINE> _train_part, self.test_part = partitioning.partition_stratified(self.labels, train_size, seed=seed, clabels=self.clabels) <NEW_LINE> ... | This runs at every creation instance
label_type: 'cat' (categorial), 'cont' (continuous) | 625941cd91af0d3eaac9bb35 |
def choose_action(self): <NEW_LINE> <INDENT> if np.random.rand() <= self.epsilon: <NEW_LINE> <INDENT> action = np.random.choice(self.env.actions) <NEW_LINE> return action, 'random' <NEW_LINE> <DEDENT> hc_action, hc_value = self.hippocampus.choose_action() <NEW_LINE> str_action, str_value = self.striatum.choose_action()... | Choose action from both hippocampus and striatum and compare their value.
| 625941cd7c178a314d6ef57c |
def _div_top(self): <NEW_LINE> <INDENT> return '' | Return a division for the top of the table. | 625941cdd6c5a10208144167 |
def unique(x, out_idx=_dtypes.int32, name=None): <NEW_LINE> <INDENT> if out_idx is None: <NEW_LINE> <INDENT> out_idx = _dtypes.int32 <NEW_LINE> <DEDENT> out_idx = _execute.make_type(out_idx, "out_idx") <NEW_LINE> _ctx = _context.context() <NEW_LINE> if _ctx.in_graph_mode(): <NEW_LINE> <INDENT> _, _, _op = _op_def_lib._... | Finds unique elements in a 1-D tensor.
This operation returns a tensor `y` containing all of the unique elements of `x`
sorted in the same order that they occur in `x`. This operation also returns a
tensor `idx` the same size as `x` that contains the index of each value of `x`
in the unique output `y`. In other words:... | 625941cd5fdd1c0f98dc0350 |
def _load_segments(self) -> None: <NEW_LINE> <INDENT> header = self.context.object(self._crash_table_name + constants.BANG + self.dump_header_name, offset = 0, layer_name = self._base_layer) <NEW_LINE> segments = [] <NEW_LINE> offset = self.headerpages <NEW_LINE> header.PhysicalMemoryBlockBuffer.Run.count = header.Phys... | Loads up the segments from the meta_layer. | 625941cd460517430c3942a1 |
def test_pitchtools_PitchArrayCell___init___07(): <NEW_LINE> <INDENT> cell = pitchtools.PitchArrayCell((0, 2)) <NEW_LINE> assert cell.pitches == [NamedPitch(0)] <NEW_LINE> assert cell.width == 2 | Initialize with pitch item, width pair.
| 625941cdb545ff76a8913f33 |
def __str__(self): <NEW_LINE> <INDENT> return "%s.%d" % (cast_to_unicode(self._trader_id.to_bytes()), self._order_number) | format: <trader_id>.<order_number> | 625941cd0383005118ecf6ff |
def checkMsg(msg, typeCheck=None): <NEW_LINE> <INDENT> msg = strToMessage(msg) <NEW_LINE> if msg is None: <NEW_LINE> <INDENT> print("ERROR: Is the Daemon running?") <NEW_LINE> sys.exit(1) <NEW_LINE> <DEDENT> if msg.getType() == ERROR_MSG_TYPE: <NEW_LINE> <INDENT> print("ERROR:",msg.getValue()) <NEW_LINE> sys.exit(1) <N... | Checks if the return is an error, if it is, it will handle it. If not
then it will check it against the provided type. If is not the valid type
it will print it right then and there. If it IS the valid type it will
return it. | 625941cda8ecb033257d31e9 |
def query_windows(self): <NEW_LINE> <INDENT> yutani_lib.yutani_query_windows(self._ptr) | Request a window subsription list. | 625941cd8da39b475bd65090 |
def set_image(in_id, data): <NEW_LINE> <INDENT> recipe = Recipe.get(Recipe.id == in_id) <NEW_LINE> recipe.image = data.get("image", "") <NEW_LINE> recipe.save() | Set image of recipe without changing any other data. | 625941cd15fb5d323cde0c2c |
def localServerAutoStart(self): <NEW_LINE> <INDENT> if not LocalConfig.isMainGui(): <NEW_LINE> <INDENT> log.info("Not the main GUI, will not autostart the server") <NEW_LINE> return True <NEW_LINE> <DEDENT> if self.localServer().isLocalServerRunning(): <NEW_LINE> <INDENT> log.info("A local server already running on thi... | Try to start the embed gns3 server. | 625941cde64d504609d7495c |
def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> super(ProfileForm, self).__init__(*args, **kwargs) <NEW_LINE> for field in self.fields: <NEW_LINE> <INDENT> self.fields[field].widget.attrs.update( { 'class': 'form-control', } ) | Set required and widgets for fields. | 625941cdd99f1b3c44c676aa |
def matchyaml(self, file: Lintable) -> List["MatchError"]: <NEW_LINE> <INDENT> matches: List["MatchError"] = [] <NEW_LINE> filtered_matches: List["MatchError"] = [] <NEW_LINE> if str(file.base_kind) != "text/yaml": <NEW_LINE> <INDENT> return matches <NEW_LINE> <DEDENT> for p in run_yamllint(file.content, YamllintRule.c... | Return matches found for a specific YAML text. | 625941cda79ad161976cc262 |
def on_view_change_advanced(self, e): <NEW_LINE> <INDENT> if type(self.source_selection) == panels.Button_Panel: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> self.source_selection.Destroy() <NEW_LINE> <DEDENT> except wx.PyDeadObjectError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> self.sour... | If the current panel is basic, stay. Otherwise
change to advanced. | 625941cd76d4e153a657ec4e |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.