nwo
stringlengths
5
106
sha
stringlengths
40
40
path
stringlengths
4
174
language
stringclasses
1 value
identifier
stringlengths
1
140
parameters
stringlengths
0
87.7k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
426k
docstring
stringlengths
0
64.3k
docstring_summary
stringlengths
0
26.3k
docstring_tokens
list
function
stringlengths
18
4.83M
function_tokens
list
url
stringlengths
83
304
tomplus/kubernetes_asyncio
f028cc793e3a2c519be6a52a49fb77ff0b014c9b
kubernetes_asyncio/client/api/networking_v1beta1_api.py
python
NetworkingV1beta1Api.read_namespaced_ingress_status_with_http_info
(self, name, namespace, **kwargs)
return self.api_client.call_api( '/apis/networking.k8s.io/v1beta1/namespaces/{namespace}/ingresses/{name}/status', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='NetworkingV1beta1Ingress', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
read_namespaced_ingress_status # noqa: E501 read status of the specified Ingress # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.read_namespaced_ingress_status_with_http_info(name, namespace, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str name: name of the Ingress (required) :param str namespace: object name and auth scope, such as for teams and projects (required) :param str pretty: If 'true', then the output is pretty printed. :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(NetworkingV1beta1Ingress, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread.
read_namespaced_ingress_status # noqa: E501
[ "read_namespaced_ingress_status", "#", "noqa", ":", "E501" ]
def read_namespaced_ingress_status_with_http_info(self, name, namespace, **kwargs): # noqa: E501 """read_namespaced_ingress_status # noqa: E501 read status of the specified Ingress # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.read_namespaced_ingress_status_with_http_info(name, namespace, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str name: name of the Ingress (required) :param str namespace: object name and auth scope, such as for teams and projects (required) :param str pretty: If 'true', then the output is pretty printed. :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(NetworkingV1beta1Ingress, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'name', 'namespace', 'pretty' ] all_params.extend( [ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout' ] ) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method read_namespaced_ingress_status" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'name' is set if self.api_client.client_side_validation and ('name' not in local_var_params or # noqa: E501 local_var_params['name'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `name` when calling `read_namespaced_ingress_status`") # noqa: E501 # verify the required parameter 'namespace' is set if self.api_client.client_side_validation and ('namespace' not in local_var_params or # noqa: E501 local_var_params['namespace'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `namespace` when calling `read_namespaced_ingress_status`") # noqa: E501 collection_formats = {} path_params = {} if 'name' in local_var_params: path_params['name'] = local_var_params['name'] # noqa: E501 if 'namespace' in local_var_params: path_params['namespace'] = local_var_params['namespace'] # noqa: E501 query_params = [] if 'pretty' in local_var_params and local_var_params['pretty'] is not None: # noqa: E501 query_params.append(('pretty', local_var_params['pretty'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json', 'application/yaml', 'application/vnd.kubernetes.protobuf']) # noqa: E501 # Authentication setting auth_settings = ['BearerToken'] # noqa: E501 return self.api_client.call_api( '/apis/networking.k8s.io/v1beta1/namespaces/{namespace}/ingresses/{name}/status', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='NetworkingV1beta1Ingress', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
[ "def", "read_namespaced_ingress_status_with_http_info", "(", "self", ",", "name", ",", "namespace", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "local_var_params", "=", "locals", "(", ")", "all_params", "=", "[", "'name'", ",", "'namespace'", ",", "'prett...
https://github.com/tomplus/kubernetes_asyncio/blob/f028cc793e3a2c519be6a52a49fb77ff0b014c9b/kubernetes_asyncio/client/api/networking_v1beta1_api.py#L2284-L2383
pytorch/fairseq
1575f30dd0a9f7b3c499db0b4767aa4e9f79056c
fairseq/data/audio/data_cfg.py
python
S2TDataConfig.shuffle
(self)
return self.config.get("shuffle", False)
Shuffle dataset samples before batching
Shuffle dataset samples before batching
[ "Shuffle", "dataset", "samples", "before", "batching" ]
def shuffle(self) -> bool: """Shuffle dataset samples before batching""" return self.config.get("shuffle", False)
[ "def", "shuffle", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "config", ".", "get", "(", "\"shuffle\"", ",", "False", ")" ]
https://github.com/pytorch/fairseq/blob/1575f30dd0a9f7b3c499db0b4767aa4e9f79056c/fairseq/data/audio/data_cfg.py#L56-L58
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/lib-python/3/pickle.py
python
_Pickler._batch_setitems
(self, items)
[]
def _batch_setitems(self, items): # Helper to batch up SETITEMS sequences; proto >= 1 only save = self.save write = self.write if not self.bin: for k, v in items: save(k) save(v) write(SETITEM) return items = iter(items) r = range(self._BATCHSIZE) while items is not None: tmp = [] for i in r: try: tmp.append(next(items)) except StopIteration: items = None break n = len(tmp) if n > 1: write(MARK) for k, v in tmp: save(k) save(v) write(SETITEMS) elif n: k, v = tmp[0] save(k) save(v) write(SETITEM)
[ "def", "_batch_setitems", "(", "self", ",", "items", ")", ":", "# Helper to batch up SETITEMS sequences; proto >= 1 only", "save", "=", "self", ".", "save", "write", "=", "self", ".", "write", "if", "not", "self", ".", "bin", ":", "for", "k", ",", "v", "in",...
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/pickle.py#L653-L686
PanJinquan/tensorflow_models_learning
e7a2773d526e01c76fc8366868099ca3d7a819b4
slim/datasets/build_imagenet_data.py
python
_find_human_readable_labels
(synsets, synset_to_human)
return humans
Build a list of human-readable labels. Args: synsets: list of strings; each string is a unique WordNet ID. synset_to_human: dict of synset to human labels, e.g., 'n02119022' --> 'red fox, Vulpes vulpes' Returns: List of human-readable strings corresponding to each synset.
Build a list of human-readable labels.
[ "Build", "a", "list", "of", "human", "-", "readable", "labels", "." ]
def _find_human_readable_labels(synsets, synset_to_human): """Build a list of human-readable labels. Args: synsets: list of strings; each string is a unique WordNet ID. synset_to_human: dict of synset to human labels, e.g., 'n02119022' --> 'red fox, Vulpes vulpes' Returns: List of human-readable strings corresponding to each synset. """ humans = [] for s in synsets: assert s in synset_to_human, ('Failed to find: %s' % s) humans.append(synset_to_human[s]) return humans
[ "def", "_find_human_readable_labels", "(", "synsets", ",", "synset_to_human", ")", ":", "humans", "=", "[", "]", "for", "s", "in", "synsets", ":", "assert", "s", "in", "synset_to_human", ",", "(", "'Failed to find: %s'", "%", "s", ")", "humans", ".", "append...
https://github.com/PanJinquan/tensorflow_models_learning/blob/e7a2773d526e01c76fc8366868099ca3d7a819b4/slim/datasets/build_imagenet_data.py#L540-L555
vchoutas/smplx
cfa54f8135ca6cb8b3588c2d893a4df7a94032ed
smplx/lbs.py
python
batch_rigid_transform
( rot_mats: Tensor, joints: Tensor, parents: Tensor, dtype=torch.float32 )
return posed_joints, rel_transforms
Applies a batch of rigid transformations to the joints Parameters ---------- rot_mats : torch.tensor BxNx3x3 Tensor of rotation matrices joints : torch.tensor BxNx3 Locations of joints parents : torch.tensor BxN The kinematic tree of each object dtype : torch.dtype, optional: The data type of the created tensors, the default is torch.float32 Returns ------- posed_joints : torch.tensor BxNx3 The locations of the joints after applying the pose rotations rel_transforms : torch.tensor BxNx4x4 The relative (with respect to the root joint) rigid transformations for all the joints
Applies a batch of rigid transformations to the joints
[ "Applies", "a", "batch", "of", "rigid", "transformations", "to", "the", "joints" ]
def batch_rigid_transform( rot_mats: Tensor, joints: Tensor, parents: Tensor, dtype=torch.float32 ) -> Tensor: """ Applies a batch of rigid transformations to the joints Parameters ---------- rot_mats : torch.tensor BxNx3x3 Tensor of rotation matrices joints : torch.tensor BxNx3 Locations of joints parents : torch.tensor BxN The kinematic tree of each object dtype : torch.dtype, optional: The data type of the created tensors, the default is torch.float32 Returns ------- posed_joints : torch.tensor BxNx3 The locations of the joints after applying the pose rotations rel_transforms : torch.tensor BxNx4x4 The relative (with respect to the root joint) rigid transformations for all the joints """ joints = torch.unsqueeze(joints, dim=-1) rel_joints = joints.clone() rel_joints[:, 1:] -= joints[:, parents[1:]] transforms_mat = transform_mat( rot_mats.reshape(-1, 3, 3), rel_joints.reshape(-1, 3, 1)).reshape(-1, joints.shape[1], 4, 4) transform_chain = [transforms_mat[:, 0]] for i in range(1, parents.shape[0]): # Subtract the joint location at the rest pose # No need for rotation, since it's identity when at rest curr_res = torch.matmul(transform_chain[parents[i]], transforms_mat[:, i]) transform_chain.append(curr_res) transforms = torch.stack(transform_chain, dim=1) # The last column of the transformations contains the posed joints posed_joints = transforms[:, :, :3, 3] joints_homogen = F.pad(joints, [0, 0, 0, 1]) rel_transforms = transforms - F.pad( torch.matmul(transforms, joints_homogen), [3, 0, 0, 0, 0, 0, 0, 0]) return posed_joints, rel_transforms
[ "def", "batch_rigid_transform", "(", "rot_mats", ":", "Tensor", ",", "joints", ":", "Tensor", ",", "parents", ":", "Tensor", ",", "dtype", "=", "torch", ".", "float32", ")", "->", "Tensor", ":", "joints", "=", "torch", ".", "unsqueeze", "(", "joints", ",...
https://github.com/vchoutas/smplx/blob/cfa54f8135ca6cb8b3588c2d893a4df7a94032ed/smplx/lbs.py#L345-L401
Neuraxio/Neuraxle
c5627e663ef6d50736bc6a01110afa626fffec07
neuraxle/hyperparams/distributions.py
python
Normal.cdf
(self, x)
return norm.cdf(x, loc=self._mean, scale=self._std)
Calculate the Normal cumulative distribution value at position `x`. :param x: value where the cumulative distribution function is evaluated. :return: value of the cumulative distribution function.
Calculate the Normal cumulative distribution value at position `x`. :param x: value where the cumulative distribution function is evaluated. :return: value of the cumulative distribution function.
[ "Calculate", "the", "Normal", "cumulative", "distribution", "value", "at", "position", "x", ".", ":", "param", "x", ":", "value", "where", "the", "cumulative", "distribution", "function", "is", "evaluated", ".", ":", "return", ":", "value", "of", "the", "cum...
def cdf(self, x) -> float: """ Calculate the Normal cumulative distribution value at position `x`. :param x: value where the cumulative distribution function is evaluated. :return: value of the cumulative distribution function. """ if self.hard_clip_min is not None and (x < self.hard_clip_min): return 0. if self.hard_clip_max is not None and (x > self.hard_clip_max): return 1. if self.hard_clip_min is not None or self.hard_clip_max is not None: a = -np.inf b = np.inf if self.hard_clip_min is not None: a = (self.hard_clip_min - self._mean) / self._std if self.hard_clip_max is not None: b = (self.hard_clip_max - self._mean) / self._std return truncnorm.cdf(x, a=a, b=b, loc=self._mean, scale=self._std) return norm.cdf(x, loc=self._mean, scale=self._std)
[ "def", "cdf", "(", "self", ",", "x", ")", "->", "float", ":", "if", "self", ".", "hard_clip_min", "is", "not", "None", "and", "(", "x", "<", "self", ".", "hard_clip_min", ")", ":", "return", "0.", "if", "self", ".", "hard_clip_max", "is", "not", "N...
https://github.com/Neuraxio/Neuraxle/blob/c5627e663ef6d50736bc6a01110afa626fffec07/neuraxle/hyperparams/distributions.py#L1170-L1194
TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials
5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e
deep-learning/udacity-deeplearning/Solutions/project-5/helper.py
python
_read32
(bytestream)
return np.frombuffer(bytestream.read(4), dtype=dt)[0]
Read 32-bit integer from bytesteam :param bytestream: A bytestream :return: 32-bit integer
Read 32-bit integer from bytesteam :param bytestream: A bytestream :return: 32-bit integer
[ "Read", "32", "-", "bit", "integer", "from", "bytesteam", ":", "param", "bytestream", ":", "A", "bytestream", ":", "return", ":", "32", "-", "bit", "integer" ]
def _read32(bytestream): """ Read 32-bit integer from bytesteam :param bytestream: A bytestream :return: 32-bit integer """ dt = np.dtype(np.uint32).newbyteorder('>') return np.frombuffer(bytestream.read(4), dtype=dt)[0]
[ "def", "_read32", "(", "bytestream", ")", ":", "dt", "=", "np", ".", "dtype", "(", "np", ".", "uint32", ")", ".", "newbyteorder", "(", "'>'", ")", "return", "np", ".", "frombuffer", "(", "bytestream", ".", "read", "(", "4", ")", ",", "dtype", "=", ...
https://github.com/TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials/blob/5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e/deep-learning/udacity-deeplearning/Solutions/project-5/helper.py#L14-L21
MDudek-ICS/TRISIS-TRITON-HATMAN
15a00af7fd1040f0430729d024427601f84886a1
decompiled_code/library/functools.py
python
wraps
(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES)
return partial(update_wrapper, wrapped=wrapped, assigned=assigned, updated=updated)
Decorator factory to apply update_wrapper() to a wrapper function Returns a decorator that invokes update_wrapper() with the decorated function as the wrapper argument and the arguments to wraps() as the remaining arguments. Default arguments are as for update_wrapper(). This is a convenience function to simplify applying partial() to update_wrapper().
Decorator factory to apply update_wrapper() to a wrapper function Returns a decorator that invokes update_wrapper() with the decorated function as the wrapper argument and the arguments to wraps() as the remaining arguments. Default arguments are as for update_wrapper(). This is a convenience function to simplify applying partial() to update_wrapper().
[ "Decorator", "factory", "to", "apply", "update_wrapper", "()", "to", "a", "wrapper", "function", "Returns", "a", "decorator", "that", "invokes", "update_wrapper", "()", "with", "the", "decorated", "function", "as", "the", "wrapper", "argument", "and", "the", "ar...
def wraps(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES): """Decorator factory to apply update_wrapper() to a wrapper function Returns a decorator that invokes update_wrapper() with the decorated function as the wrapper argument and the arguments to wraps() as the remaining arguments. Default arguments are as for update_wrapper(). This is a convenience function to simplify applying partial() to update_wrapper(). """ return partial(update_wrapper, wrapped=wrapped, assigned=assigned, updated=updated)
[ "def", "wraps", "(", "wrapped", ",", "assigned", "=", "WRAPPER_ASSIGNMENTS", ",", "updated", "=", "WRAPPER_UPDATES", ")", ":", "return", "partial", "(", "update_wrapper", ",", "wrapped", "=", "wrapped", ",", "assigned", "=", "assigned", ",", "updated", "=", ...
https://github.com/MDudek-ICS/TRISIS-TRITON-HATMAN/blob/15a00af7fd1040f0430729d024427601f84886a1/decompiled_code/library/functools.py#L34-L43
TabbycatDebate/tabbycat
7cc3b2fa1cc34569501a4be10fe9234b98c65df3
tabbycat/utils/templatetags/debate_tags.py
python
RoundURLNode.render
(self, context)
return super().render(context)
Add the round to the arguments, then render as usual.
Add the round to the arguments, then render as usual.
[ "Add", "the", "round", "to", "the", "arguments", "then", "render", "as", "usual", "." ]
def render(self, context): """Add the round to the arguments, then render as usual.""" # Similar comment as for TournamentURLNode.render() round = self.round.resolve(context) if self.round else context['round'] tournament_slug = Variable("'" + round.tournament.slug + "'") round_seq = Variable("'%d'" % round.seq) self.args = list(self._args) # make a copy in case render() gets called multiple times self.kwargs = dict(self._kwargs) if self.kwargs: self.kwargs['tournament_slug'] = tournament_slug self.kwargs['round_seq'] = round_seq else: self.args = [tournament_slug, round_seq] + self.args return super().render(context)
[ "def", "render", "(", "self", ",", "context", ")", ":", "# Similar comment as for TournamentURLNode.render()", "round", "=", "self", ".", "round", ".", "resolve", "(", "context", ")", "if", "self", ".", "round", "else", "context", "[", "'round'", "]", "tournam...
https://github.com/TabbycatDebate/tabbycat/blob/7cc3b2fa1cc34569501a4be10fe9234b98c65df3/tabbycat/utils/templatetags/debate_tags.py#L110-L126
arrayfire/arrayfire-python
96fa9768ee02e5fb5ffcaf3d1f744c898b141637
arrayfire/device.py
python
device_gc
()
Ask the garbage collector to free all unlocked memory
Ask the garbage collector to free all unlocked memory
[ "Ask", "the", "garbage", "collector", "to", "free", "all", "unlocked", "memory" ]
def device_gc(): """ Ask the garbage collector to free all unlocked memory """ safe_call(backend.get().af_device_gc())
[ "def", "device_gc", "(", ")", ":", "safe_call", "(", "backend", ".", "get", "(", ")", ".", "af_device_gc", "(", ")", ")" ]
https://github.com/arrayfire/arrayfire-python/blob/96fa9768ee02e5fb5ffcaf3d1f744c898b141637/arrayfire/device.py#L341-L345
karan/HackerNewsAPI
0e2df2e28f3a6090559eacdefdb99f4d6780ddf5
hn/hn.py
python
HN._build_story
(self, all_rows)
return all_stories
Builds and returns a list of stories (dicts) from the passed source.
Builds and returns a list of stories (dicts) from the passed source.
[ "Builds", "and", "returns", "a", "list", "of", "stories", "(", "dicts", ")", "from", "the", "passed", "source", "." ]
def _build_story(self, all_rows): """ Builds and returns a list of stories (dicts) from the passed source. """ # list to hold all stories all_stories = [] for (info, detail) in all_rows: #-- Get the into about a story --# # split in 3 cells info_cells = info.findAll('td') rank = int(info_cells[0].string[:-1]) title = '%s' % info_cells[2].find('a').string link = info_cells[2].find('a').get('href') # by default all stories are linking posts is_self = False # the link doesn't contains "http" meaning an internal link if link.find('item?id=') is -1: # slice " (abc.com) " domain = info_cells[2].findAll('span')[1].string[2:-1] else: link = '%s/%s' % (BASE_URL, link) domain = BASE_URL is_self = True #-- Get the into about a story --# #-- Get the detail about a story --# # split in 2 cells, we need only second detail_cell = detail.findAll('td')[1] # list of details we need, 5 count detail_concern = detail_cell.contents num_comments = -1 if re.match(r'^(\d+)\spoint.*', detail_concern[0].string) is not \ None: # can be a link or self post points = int(re.match(r'^(\d+)\spoint.*', detail_concern[ 0].string).groups()[0]) submitter = '%s' % detail_concern[2].string submitter_profile = '%s/%s' % (BASE_URL, detail_concern[ 2].get('href')) published_time = ' '.join(detail_concern[3].strip().split()[ :3]) comment_tag = detail_concern[4] story_id = int(re.match(r'.*=(\d+)', comment_tag.get( 'href')).groups()[0]) comments_link = '%s/item?id=%d' % (BASE_URL, story_id) comment_count = re.match(r'(\d+)\s.*', comment_tag.string) try: # regex matched, cast to int num_comments = int(comment_count.groups()[0]) except AttributeError: # did not match, assign 0 num_comments = 0 else: # this is a job post points = 0 submitter = '' submitter_profile = '' published_time = '%s' % detail_concern[0] comment_tag = '' try: story_id = int(re.match(r'.*=(\d+)', link).groups()[0]) except AttributeError: # job listing that points to external link story_id = -1 comments_link = '' comment_count = -1 #-- Get the detail about a story --# story = Story(rank, story_id, title, link, domain, points, submitter, published_time, submitter_profile, num_comments, comments_link, is_self) all_stories.append(story) return all_stories
[ "def", "_build_story", "(", "self", ",", "all_rows", ")", ":", "# list to hold all stories", "all_stories", "=", "[", "]", "for", "(", "info", ",", "detail", ")", "in", "all_rows", ":", "#-- Get the into about a story --#", "# split in 3 cells", "info_cells", "=", ...
https://github.com/karan/HackerNewsAPI/blob/0e2df2e28f3a6090559eacdefdb99f4d6780ddf5/hn/hn.py#L57-L138
galaxyproject/galaxy
4c03520f05062e0f4a1b3655dc0b7452fda69943
lib/galaxy/webapps/galaxy/api/history_contents.py
python
get_index_query_params
( v: Optional[str] = Query( # Should this be deprecated at some point and directly use the latest version by default? default=None, title="Version", description="Only `dev` value is allowed. Set it to use the latest version of this endpoint.", example="dev", ), dataset_details: Optional[str] = Query( default=None, alias="details", title="Dataset Details", description=( "A comma-separated list of encoded dataset IDs that will return additional (full) details " "instead of the *summary* default information." ), deprecated=True, # TODO: remove 'dataset_details' when the UI doesn't need it ), )
return parse_index_query_params( v=v, dataset_details=dataset_details, )
This function is meant to be used as a dependency to render the OpenAPI documentation correctly
This function is meant to be used as a dependency to render the OpenAPI documentation correctly
[ "This", "function", "is", "meant", "to", "be", "used", "as", "a", "dependency", "to", "render", "the", "OpenAPI", "documentation", "correctly" ]
def get_index_query_params( v: Optional[str] = Query( # Should this be deprecated at some point and directly use the latest version by default? default=None, title="Version", description="Only `dev` value is allowed. Set it to use the latest version of this endpoint.", example="dev", ), dataset_details: Optional[str] = Query( default=None, alias="details", title="Dataset Details", description=( "A comma-separated list of encoded dataset IDs that will return additional (full) details " "instead of the *summary* default information." ), deprecated=True, # TODO: remove 'dataset_details' when the UI doesn't need it ), ) -> HistoryContentsIndexParams: """This function is meant to be used as a dependency to render the OpenAPI documentation correctly""" return parse_index_query_params( v=v, dataset_details=dataset_details, )
[ "def", "get_index_query_params", "(", "v", ":", "Optional", "[", "str", "]", "=", "Query", "(", "# Should this be deprecated at some point and directly use the latest version by default?", "default", "=", "None", ",", "title", "=", "\"Version\"", ",", "description", "=", ...
https://github.com/galaxyproject/galaxy/blob/4c03520f05062e0f4a1b3655dc0b7452fda69943/lib/galaxy/webapps/galaxy/api/history_contents.py#L108-L131
smokeleeteveryday/CTF_WRITEUPS
4683f0d41c92c4ed407cc3dd3b1760c68a05943f
2015/ASISCTF/reversing/selfie/solution/selfie_descramble.py
python
descramble
(selfie)
return res
[]
def descramble(selfie): scrambled = get_scrambled_buffer(get_hidden_elf(selfie)) #Try bruteforce approach v9 = 1521 res = "" for i in xrange(v9): if not(sitoor(i)): res += scrambled[i + 1] return res
[ "def", "descramble", "(", "selfie", ")", ":", "scrambled", "=", "get_scrambled_buffer", "(", "get_hidden_elf", "(", "selfie", ")", ")", "#Try bruteforce approach", "v9", "=", "1521", "res", "=", "\"\"", "for", "i", "in", "xrange", "(", "v9", ")", ":", "if"...
https://github.com/smokeleeteveryday/CTF_WRITEUPS/blob/4683f0d41c92c4ed407cc3dd3b1760c68a05943f/2015/ASISCTF/reversing/selfie/solution/selfie_descramble.py#L37-L45
googleads/google-ads-python
2a1d6062221f6aad1992a6bcca0e7e4a93d2db86
google/ads/googleads/v9/services/services/google_ads_service/client.py
python
GoogleAdsServiceClient.common_billing_account_path
(billing_account: str,)
return "billingAccounts/{billing_account}".format( billing_account=billing_account, )
Return a fully-qualified billing_account string.
Return a fully-qualified billing_account string.
[ "Return", "a", "fully", "-", "qualified", "billing_account", "string", "." ]
def common_billing_account_path(billing_account: str,) -> str: """Return a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, )
[ "def", "common_billing_account_path", "(", "billing_account", ":", "str", ",", ")", "->", "str", ":", "return", "\"billingAccounts/{billing_account}\"", ".", "format", "(", "billing_account", "=", "billing_account", ",", ")" ]
https://github.com/googleads/google-ads-python/blob/2a1d6062221f6aad1992a6bcca0e7e4a93d2db86/google/ads/googleads/v9/services/services/google_ads_service/client.py#L2918-L2922
fedora-infra/bodhi
2b1df12d85eb2e575d8e481a3936c4f92d1fe29a
bodhi/server/validators.py
python
validate_build_tags
(request, **kwargs)
Ensure that all of the referenced builds are tagged as candidates. Args: request (pyramid.request.Request): The current request. kwargs (dict): The kwargs of the related service definition. Unused.
Ensure that all of the referenced builds are tagged as candidates.
[ "Ensure", "that", "all", "of", "the", "referenced", "builds", "are", "tagged", "as", "candidates", "." ]
def validate_build_tags(request, **kwargs): """ Ensure that all of the referenced builds are tagged as candidates. Args: request (pyramid.request.Request): The current request. kwargs (dict): The kwargs of the related service definition. Unused. """ tag_types, tag_rels = Release.get_tags(request.db) edited = request.validated.get('edited') release = None if edited: valid_tags = tag_types['candidate'] + tag_types['testing'] update = request.db.query(Update).filter_by(alias=edited).first() if not update: # No need to tack on any more errors here, since they should have # already been added by `validate_builds` return release = update.release else: valid_tags = tag_types['candidate'] from_tag = request.validated.get('from_tag') if from_tag: valid_tags.append(from_tag) for build in request.validated.get('builds') or []: valid = False tags = cache_tags(request, build) if tags is None: return build_rel = cache_release(request, build) if build_rel is None: return # Disallow adding builds for a different release if edited: if build_rel is not release: request.errors.add('body', 'builds', 'Cannot add a %s build to an %s update' % ( build_rel.name, release.name)) return for tag in tags: if tag in valid_tags: valid = True break if not valid: request.errors.add( 'body', 'builds', 'Invalid tag: {} not tagged with any of the following tags {}'.format( build, valid_tags))
[ "def", "validate_build_tags", "(", "request", ",", "*", "*", "kwargs", ")", ":", "tag_types", ",", "tag_rels", "=", "Release", ".", "get_tags", "(", "request", ".", "db", ")", "edited", "=", "request", ".", "validated", ".", "get", "(", "'edited'", ")", ...
https://github.com/fedora-infra/bodhi/blob/2b1df12d85eb2e575d8e481a3936c4f92d1fe29a/bodhi/server/validators.py#L305-L356
fossasia/pslab-python
bb53a334b729d0956ed9f4ce6899903f3e4868ef
pslab/external/MPU925x.py
python
MPU925x.WhoAmI_AK8963
(self)
Returns the ID fo magnetometer AK8963 if found. It should be 0x48.
Returns the ID fo magnetometer AK8963 if found. It should be 0x48.
[ "Returns", "the", "ID", "fo", "magnetometer", "AK8963", "if", "found", ".", "It", "should", "be", "0x48", "." ]
def WhoAmI_AK8963(self): ''' Returns the ID fo magnetometer AK8963 if found. It should be 0x48. ''' self.initMagnetometer() v = self.I2C.readBulk(self.AK8963_ADDRESS, 0, 1)[0] if v == 0x48: return 'AK8963 at %s' % hex(v) else: return 'AK8963 not found. returned :%s' % hex(v)
[ "def", "WhoAmI_AK8963", "(", "self", ")", ":", "self", ".", "initMagnetometer", "(", ")", "v", "=", "self", ".", "I2C", ".", "readBulk", "(", "self", ".", "AK8963_ADDRESS", ",", "0", ",", "1", ")", "[", "0", "]", "if", "v", "==", "0x48", ":", "re...
https://github.com/fossasia/pslab-python/blob/bb53a334b729d0956ed9f4ce6899903f3e4868ef/pslab/external/MPU925x.py#L161-L171
cloudera/hue
23f02102d4547c17c32bd5ea0eb24e9eadd657a4
desktop/core/ext-py/SQLAlchemy-1.3.17/lib/sqlalchemy/sql/crud.py
python
_append_param_insert_pk_returning
(compiler, stmt, c, values, kw)
Create a primary key expression in the INSERT statement and possibly a RETURNING clause for it. If the column has a Python-side default, we will create a bound parameter for it and "pre-execute" the Python function. If the column has a SQL expression default, or is a sequence, we will add it directly into the INSERT statement and add a RETURNING element to get the new value. If the column has a server side default or is marked as the "autoincrement" column, we will add a RETRUNING element to get at the value. If all the above tests fail, that indicates a primary key column with no noted default generation capabilities that has no parameter passed; raise an exception.
Create a primary key expression in the INSERT statement and possibly a RETURNING clause for it.
[ "Create", "a", "primary", "key", "expression", "in", "the", "INSERT", "statement", "and", "possibly", "a", "RETURNING", "clause", "for", "it", "." ]
def _append_param_insert_pk_returning(compiler, stmt, c, values, kw): """Create a primary key expression in the INSERT statement and possibly a RETURNING clause for it. If the column has a Python-side default, we will create a bound parameter for it and "pre-execute" the Python function. If the column has a SQL expression default, or is a sequence, we will add it directly into the INSERT statement and add a RETURNING element to get the new value. If the column has a server side default or is marked as the "autoincrement" column, we will add a RETRUNING element to get at the value. If all the above tests fail, that indicates a primary key column with no noted default generation capabilities that has no parameter passed; raise an exception. """ if c.default is not None: if c.default.is_sequence: if compiler.dialect.supports_sequences and ( not c.default.optional or not compiler.dialect.sequences_optional ): proc = compiler.process(c.default, **kw) values.append((c, proc)) compiler.returning.append(c) elif c.default.is_clause_element: values.append( (c, compiler.process(c.default.arg.self_group(), **kw)) ) compiler.returning.append(c) else: values.append((c, _create_insert_prefetch_bind_param(compiler, c))) elif c is stmt.table._autoincrement_column or c.server_default is not None: compiler.returning.append(c) elif not c.nullable: # no .default, no .server_default, not autoincrement, we have # no indication this primary key column will have any value _warn_pk_with_no_anticipated_value(c)
[ "def", "_append_param_insert_pk_returning", "(", "compiler", ",", "stmt", ",", "c", ",", "values", ",", "kw", ")", ":", "if", "c", ".", "default", "is", "not", "None", ":", "if", "c", ".", "default", ".", "is_sequence", ":", "if", "compiler", ".", "dia...
https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/SQLAlchemy-1.3.17/lib/sqlalchemy/sql/crud.py#L424-L462
bigaidream-projects/drmad
a4bb6010595d956f29c5a42a095bab76a60b29eb
cpu_ver/funkyyak/scheme/core.py
python
getval
(arg, grad, localenv)
[]
def getval(arg, grad, localenv): if isinstance(arg, tape): arg.env['outgrad'] = kyfun((), call('add', (call(kyfun((), grad, localenv), ()), call(arg.env['outgrad'], ()))), {}) return arg.value else: return arg
[ "def", "getval", "(", "arg", ",", "grad", ",", "localenv", ")", ":", "if", "isinstance", "(", "arg", ",", "tape", ")", ":", "arg", ".", "env", "[", "'outgrad'", "]", "=", "kyfun", "(", "(", ")", ",", "call", "(", "'add'", ",", "(", "call", "(",...
https://github.com/bigaidream-projects/drmad/blob/a4bb6010595d956f29c5a42a095bab76a60b29eb/cpu_ver/funkyyak/scheme/core.py#L55-L61
paramiko/paramiko
88f35a537428e430f7f26eee8026715e357b55d6
paramiko/transport.py
python
Transport.connect
( self, hostkey=None, username="", password=None, pkey=None, gss_host=None, gss_auth=False, gss_kex=False, gss_deleg_creds=True, gss_trust_dns=True, )
return
Negotiate an SSH2 session, and optionally verify the server's host key and authenticate using a password or private key. This is a shortcut for `start_client`, `get_remote_server_key`, and `Transport.auth_password` or `Transport.auth_publickey`. Use those methods if you want more control. You can use this method immediately after creating a Transport to negotiate encryption with a server. If it fails, an exception will be thrown. On success, the method will return cleanly, and an encrypted session exists. You may immediately call `open_channel` or `open_session` to get a `.Channel` object, which is used for data transfer. .. note:: If you fail to supply a password or private key, this method may succeed, but a subsequent `open_channel` or `open_session` call may fail because you haven't authenticated yet. :param .PKey hostkey: the host key expected from the server, or ``None`` if you don't want to do host key verification. :param str username: the username to authenticate as. :param str password: a password to use for authentication, if you want to use password authentication; otherwise ``None``. :param .PKey pkey: a private key to use for authentication, if you want to use private key authentication; otherwise ``None``. :param str gss_host: The target's name in the kerberos database. Default: hostname :param bool gss_auth: ``True`` if you want to use GSS-API authentication. :param bool gss_kex: Perform GSS-API Key Exchange and user authentication. :param bool gss_deleg_creds: Whether to delegate GSS-API client credentials. :param gss_trust_dns: Indicates whether or not the DNS is trusted to securely canonicalize the name of the host being connected to (default ``True``). :raises: `.SSHException` -- if the SSH2 negotiation fails, the host key supplied by the server is incorrect, or authentication fails. .. versionchanged:: 2.3 Added the ``gss_trust_dns`` argument.
Negotiate an SSH2 session, and optionally verify the server's host key and authenticate using a password or private key. This is a shortcut for `start_client`, `get_remote_server_key`, and `Transport.auth_password` or `Transport.auth_publickey`. Use those methods if you want more control.
[ "Negotiate", "an", "SSH2", "session", "and", "optionally", "verify", "the", "server", "s", "host", "key", "and", "authenticate", "using", "a", "password", "or", "private", "key", ".", "This", "is", "a", "shortcut", "for", "start_client", "get_remote_server_key",...
def connect( self, hostkey=None, username="", password=None, pkey=None, gss_host=None, gss_auth=False, gss_kex=False, gss_deleg_creds=True, gss_trust_dns=True, ): """ Negotiate an SSH2 session, and optionally verify the server's host key and authenticate using a password or private key. This is a shortcut for `start_client`, `get_remote_server_key`, and `Transport.auth_password` or `Transport.auth_publickey`. Use those methods if you want more control. You can use this method immediately after creating a Transport to negotiate encryption with a server. If it fails, an exception will be thrown. On success, the method will return cleanly, and an encrypted session exists. You may immediately call `open_channel` or `open_session` to get a `.Channel` object, which is used for data transfer. .. note:: If you fail to supply a password or private key, this method may succeed, but a subsequent `open_channel` or `open_session` call may fail because you haven't authenticated yet. :param .PKey hostkey: the host key expected from the server, or ``None`` if you don't want to do host key verification. :param str username: the username to authenticate as. :param str password: a password to use for authentication, if you want to use password authentication; otherwise ``None``. :param .PKey pkey: a private key to use for authentication, if you want to use private key authentication; otherwise ``None``. :param str gss_host: The target's name in the kerberos database. Default: hostname :param bool gss_auth: ``True`` if you want to use GSS-API authentication. :param bool gss_kex: Perform GSS-API Key Exchange and user authentication. :param bool gss_deleg_creds: Whether to delegate GSS-API client credentials. :param gss_trust_dns: Indicates whether or not the DNS is trusted to securely canonicalize the name of the host being connected to (default ``True``). :raises: `.SSHException` -- if the SSH2 negotiation fails, the host key supplied by the server is incorrect, or authentication fails. .. versionchanged:: 2.3 Added the ``gss_trust_dns`` argument. """ if hostkey is not None: # TODO: a more robust implementation would be to ask each key class # for its nameS plural, and just use that. # TODO: that could be used in a bunch of other spots too if isinstance(hostkey, RSAKey): self._preferred_keys = [ "rsa-sha2-512", "rsa-sha2-256", "ssh-rsa", ] else: self._preferred_keys = [hostkey.get_name()] self.set_gss_host( gss_host=gss_host, trust_dns=gss_trust_dns, gssapi_requested=gss_kex or gss_auth, ) self.start_client() # check host key if we were given one # If GSS-API Key Exchange was performed, we are not required to check # the host key. if (hostkey is not None) and not gss_kex: key = self.get_remote_server_key() if ( key.get_name() != hostkey.get_name() or key.asbytes() != hostkey.asbytes() ): self._log(DEBUG, "Bad host key from server") self._log( DEBUG, "Expected: {}: {}".format( hostkey.get_name(), repr(hostkey.asbytes()) ), ) self._log( DEBUG, "Got : {}: {}".format( key.get_name(), repr(key.asbytes()) ), ) raise SSHException("Bad host key from server") self._log( DEBUG, "Host key verified ({})".format(hostkey.get_name()) ) if (pkey is not None) or (password is not None) or gss_auth or gss_kex: if gss_auth: self._log( DEBUG, "Attempting GSS-API auth... (gssapi-with-mic)" ) # noqa self.auth_gssapi_with_mic( username, self.gss_host, gss_deleg_creds ) elif gss_kex: self._log(DEBUG, "Attempting GSS-API auth... (gssapi-keyex)") self.auth_gssapi_keyex(username) elif pkey is not None: self._log(DEBUG, "Attempting public-key auth...") self.auth_publickey(username, pkey) else: self._log(DEBUG, "Attempting password auth...") self.auth_password(username, password) return
[ "def", "connect", "(", "self", ",", "hostkey", "=", "None", ",", "username", "=", "\"\"", ",", "password", "=", "None", ",", "pkey", "=", "None", ",", "gss_host", "=", "None", ",", "gss_auth", "=", "False", ",", "gss_kex", "=", "False", ",", "gss_del...
https://github.com/paramiko/paramiko/blob/88f35a537428e430f7f26eee8026715e357b55d6/paramiko/transport.py#L1266-L1392
NVIDIA/flowtron
701780103910522282336d9e014e59f345070145
text/cleaners.py
python
transliteration_cleaners
(text)
return text
Pipeline for non-English text that transliterates to ASCII.
Pipeline for non-English text that transliterates to ASCII.
[ "Pipeline", "for", "non", "-", "English", "text", "that", "transliterates", "to", "ASCII", "." ]
def transliteration_cleaners(text): '''Pipeline for non-English text that transliterates to ASCII.''' text = convert_to_ascii(text) text = lowercase(text) text = collapse_whitespace(text) return text
[ "def", "transliteration_cleaners", "(", "text", ")", ":", "text", "=", "convert_to_ascii", "(", "text", ")", "text", "=", "lowercase", "(", "text", ")", "text", "=", "collapse_whitespace", "(", "text", ")", "return", "text" ]
https://github.com/NVIDIA/flowtron/blob/701780103910522282336d9e014e59f345070145/text/cleaners.py#L106-L111
dgilland/pydash
24ad0e43b51b367d00447c45baa68c9c03ad1a52
src/pydash/utilities.py
python
conforms
(source)
return _conforms
Creates a function that invokes the predicate properties of `source` with the corresponding property values of a given object, returning ``True`` if all predicates return truthy, else ``False``. Args: source (dict|list): The object of property predicates to conform to. Returns: callable: Returns the new spec function. Example: >>> func = conforms({'b': lambda n: n > 1}) >>> func({'b': 2}) True >>> func({'b': 0}) False >>> func = conforms([lambda n: n > 1, lambda n: n == 0]) >>> func([2, 0]) True >>> func([0, 0]) False .. versionadded:: 4.0.0
Creates a function that invokes the predicate properties of `source` with the corresponding property values of a given object, returning ``True`` if all predicates return truthy, else ``False``.
[ "Creates", "a", "function", "that", "invokes", "the", "predicate", "properties", "of", "source", "with", "the", "corresponding", "property", "values", "of", "a", "given", "object", "returning", "True", "if", "all", "predicates", "return", "truthy", "else", "Fals...
def conforms(source): """ Creates a function that invokes the predicate properties of `source` with the corresponding property values of a given object, returning ``True`` if all predicates return truthy, else ``False``. Args: source (dict|list): The object of property predicates to conform to. Returns: callable: Returns the new spec function. Example: >>> func = conforms({'b': lambda n: n > 1}) >>> func({'b': 2}) True >>> func({'b': 0}) False >>> func = conforms([lambda n: n > 1, lambda n: n == 0]) >>> func([2, 0]) True >>> func([0, 0]) False .. versionadded:: 4.0.0 """ def _conforms(obj): for key, predicate in iterator(source): if not pyd.has(obj, key) or not predicate(obj[key]): return False return True return _conforms
[ "def", "conforms", "(", "source", ")", ":", "def", "_conforms", "(", "obj", ")", ":", "for", "key", ",", "predicate", "in", "iterator", "(", "source", ")", ":", "if", "not", "pyd", ".", "has", "(", "obj", ",", "key", ")", "or", "not", "predicate", ...
https://github.com/dgilland/pydash/blob/24ad0e43b51b367d00447c45baa68c9c03ad1a52/src/pydash/utilities.py#L156-L190
google/pytype
fa43edc95dd42ade6e3147d6580d63e778c9d506
pytype/errors.py
python
ErrorLog.not_instantiable
(self, stack, cls)
Instantiating an abstract class.
Instantiating an abstract class.
[ "Instantiating", "an", "abstract", "class", "." ]
def not_instantiable(self, stack, cls): """Instantiating an abstract class.""" message = "Can't instantiate %s with abstract methods %s" % ( cls.full_name, ", ".join(sorted(cls.abstract_methods))) self.error(stack, message)
[ "def", "not_instantiable", "(", "self", ",", "stack", ",", "cls", ")", ":", "message", "=", "\"Can't instantiate %s with abstract methods %s\"", "%", "(", "cls", ".", "full_name", ",", "\", \"", ".", "join", "(", "sorted", "(", "cls", ".", "abstract_methods", ...
https://github.com/google/pytype/blob/fa43edc95dd42ade6e3147d6580d63e778c9d506/pytype/errors.py#L891-L895
fonttools/fonttools
892322aaff6a89bea5927379ec06bc0da3dfb7df
Lib/fontTools/feaLib/ast.py
python
deviceToString
(device)
[]
def deviceToString(device): if device is None: return "<device NULL>" else: return "<device %s>" % ", ".join("%d %d" % t for t in device)
[ "def", "deviceToString", "(", "device", ")", ":", "if", "device", "is", "None", ":", "return", "\"<device NULL>\"", "else", ":", "return", "\"<device %s>\"", "%", "\", \"", ".", "join", "(", "\"%d %d\"", "%", "t", "for", "t", "in", "device", ")" ]
https://github.com/fonttools/fonttools/blob/892322aaff6a89bea5927379ec06bc0da3dfb7df/Lib/fontTools/feaLib/ast.py#L80-L84
home-assistant/core
265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1
homeassistant/components/intesishome/climate.py
python
IntesisAC.target_temperature
(self)
return self._target_temp
Return the current setpoint temperature if unit is on.
Return the current setpoint temperature if unit is on.
[ "Return", "the", "current", "setpoint", "temperature", "if", "unit", "is", "on", "." ]
def target_temperature(self): """Return the current setpoint temperature if unit is on.""" return self._target_temp
[ "def", "target_temperature", "(", "self", ")", ":", "return", "self", ".", "_target_temp" ]
https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/intesishome/climate.py#L476-L478
meetbill/zabbix_manager
739e5b51facf19cc6bda2b50f29108f831cf833e
ZabbixTool/lib_zabbix/w_lib/zabbix_api_lib.py
python
ZabbixAPISubClass.do_request
(self, req)
return self.parent.do_request(req)
[]
def do_request(self, req): return self.parent.do_request(req)
[ "def", "do_request", "(", "self", ",", "req", ")", ":", "return", "self", ".", "parent", ".", "do_request", "(", "req", ")" ]
https://github.com/meetbill/zabbix_manager/blob/739e5b51facf19cc6bda2b50f29108f831cf833e/ZabbixTool/lib_zabbix/w_lib/zabbix_api_lib.py#L339-L340
bashtage/linearmodels
9256269f01ff8c5f85e65342d66149a5636661b6
linearmodels/shared/utility.py
python
AttrDict.keys
(self)
return self.__private_dict__.keys()
Return an ordered list-like object providing a view on AD's keys
Return an ordered list-like object providing a view on AD's keys
[ "Return", "an", "ordered", "list", "-", "like", "object", "providing", "a", "view", "on", "AD", "s", "keys" ]
def keys(self) -> AbstractSet[Any]: """Return an ordered list-like object providing a view on AD's keys""" return self.__private_dict__.keys()
[ "def", "keys", "(", "self", ")", "->", "AbstractSet", "[", "Any", "]", ":", "return", "self", ".", "__private_dict__", ".", "keys", "(", ")" ]
https://github.com/bashtage/linearmodels/blob/9256269f01ff8c5f85e65342d66149a5636661b6/linearmodels/shared/utility.py#L59-L61
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/lib/python2.7/site-packages/celery/concurrency/asynpool.py
python
AsynPool._on_soft_timeout
(self, job, soft, hard, hub)
[]
def _on_soft_timeout(self, job, soft, hard, hub): # only used by async pool. if hard: self._tref_for_id[job] = hub.call_later( hard - soft, self._on_hard_timeout, job, ) try: result = self._cache[job] except KeyError: pass # job ready else: self.on_soft_timeout(result) finally: if not hard: # remove tref self._discard_tref(job)
[ "def", "_on_soft_timeout", "(", "self", ",", "job", ",", "soft", ",", "hard", ",", "hub", ")", ":", "# only used by async pool.", "if", "hard", ":", "self", ".", "_tref_for_id", "[", "job", "]", "=", "hub", ".", "call_later", "(", "hard", "-", "soft", ...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/celery/concurrency/asynpool.py#L514-L529
chribsen/simple-machine-learning-examples
dc94e52a4cebdc8bb959ff88b81ff8cfeca25022
venv/lib/python2.7/site-packages/sklearn/utils/validation.py
python
as_float_array
(X, copy=True, force_all_finite=True)
Converts an array-like to an array of floats The new dtype will be np.float32 or np.float64, depending on the original type. The function can create a copy or modify the argument depending on the argument copy. Parameters ---------- X : {array-like, sparse matrix} copy : bool, optional If True, a copy of X will be created. If False, a copy may still be returned if X's dtype is not a floating point type. force_all_finite : boolean (default=True) Whether to raise an error on np.inf and np.nan in X. Returns ------- XT : {array, sparse matrix} An array of type np.float
Converts an array-like to an array of floats
[ "Converts", "an", "array", "-", "like", "to", "an", "array", "of", "floats" ]
def as_float_array(X, copy=True, force_all_finite=True): """Converts an array-like to an array of floats The new dtype will be np.float32 or np.float64, depending on the original type. The function can create a copy or modify the argument depending on the argument copy. Parameters ---------- X : {array-like, sparse matrix} copy : bool, optional If True, a copy of X will be created. If False, a copy may still be returned if X's dtype is not a floating point type. force_all_finite : boolean (default=True) Whether to raise an error on np.inf and np.nan in X. Returns ------- XT : {array, sparse matrix} An array of type np.float """ if isinstance(X, np.matrix) or (not isinstance(X, np.ndarray) and not sp.issparse(X)): return check_array(X, ['csr', 'csc', 'coo'], dtype=np.float64, copy=copy, force_all_finite=force_all_finite, ensure_2d=False) elif sp.issparse(X) and X.dtype in [np.float32, np.float64]: return X.copy() if copy else X elif X.dtype in [np.float32, np.float64]: # is numpy array return X.copy('F' if X.flags['F_CONTIGUOUS'] else 'C') if copy else X else: return X.astype(np.float32 if X.dtype == np.int32 else np.float64)
[ "def", "as_float_array", "(", "X", ",", "copy", "=", "True", ",", "force_all_finite", "=", "True", ")", ":", "if", "isinstance", "(", "X", ",", "np", ".", "matrix", ")", "or", "(", "not", "isinstance", "(", "X", ",", "np", ".", "ndarray", ")", "and...
https://github.com/chribsen/simple-machine-learning-examples/blob/dc94e52a4cebdc8bb959ff88b81ff8cfeca25022/venv/lib/python2.7/site-packages/sklearn/utils/validation.py#L68-L101
SpamScope/spamscope
ffbfc53b9a3503ef3041cee94c6726c8b899118d
src/modules/bitmap/bitmap.py
python
BitMap.set_property_score
(self, *args)
Add to score the given properties.
Add to score the given properties.
[ "Add", "to", "score", "the", "given", "properties", "." ]
def set_property_score(self, *args): """Add to score the given properties. """ for p in args: if p not in self.bitmap: raise PropertyDoesNotExists( "Property {!r} does not exists".format(p)) value = self.bitmap.get(p) # New score self._score |= (1 << value)
[ "def", "set_property_score", "(", "self", ",", "*", "args", ")", ":", "for", "p", "in", "args", ":", "if", "p", "not", "in", "self", ".", "bitmap", ":", "raise", "PropertyDoesNotExists", "(", "\"Property {!r} does not exists\"", ".", "format", "(", "p", ")...
https://github.com/SpamScope/spamscope/blob/ffbfc53b9a3503ef3041cee94c6726c8b899118d/src/modules/bitmap/bitmap.py#L111-L122
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/oceanus/v20190422/models.py
python
CreateJobRequest.__init__
(self)
r""" :param Name: 作业名称,允许输入长度小于等于50个字符的中文、英文、数字、-(横线)、_(下划线)、.(点),且符号必须半角字符。注意作业名不能和现有作业同名 :type Name: str :param JobType: 作业的类型,1 表示 SQL 作业,2 表示 JAR 作业 :type JobType: int :param ClusterType: 集群的类型,1 表示共享集群,2 表示独享集群 :type ClusterType: int :param ClusterId: 当 ClusterType=2 时,必选,用来指定该作业提交的独享集群 ID :type ClusterId: str :param CuMem: 设置每 CU 的内存规格,单位为 GB,支持 2、4、8、16(需申请开通白名单后使用)。默认为 4,即 1 CU 对应 4 GB 的运行内存 :type CuMem: int :param Remark: 作业的备注信息,可以随意设置 :type Remark: str :param FolderId: 作业名所属文件夹ID,根目录为"root" :type FolderId: str :param FlinkVersion: 作业运行的Flink版本 :type FlinkVersion: str
r""" :param Name: 作业名称,允许输入长度小于等于50个字符的中文、英文、数字、-(横线)、_(下划线)、.(点),且符号必须半角字符。注意作业名不能和现有作业同名 :type Name: str :param JobType: 作业的类型,1 表示 SQL 作业,2 表示 JAR 作业 :type JobType: int :param ClusterType: 集群的类型,1 表示共享集群,2 表示独享集群 :type ClusterType: int :param ClusterId: 当 ClusterType=2 时,必选,用来指定该作业提交的独享集群 ID :type ClusterId: str :param CuMem: 设置每 CU 的内存规格,单位为 GB,支持 2、4、8、16(需申请开通白名单后使用)。默认为 4,即 1 CU 对应 4 GB 的运行内存 :type CuMem: int :param Remark: 作业的备注信息,可以随意设置 :type Remark: str :param FolderId: 作业名所属文件夹ID,根目录为"root" :type FolderId: str :param FlinkVersion: 作业运行的Flink版本 :type FlinkVersion: str
[ "r", ":", "param", "Name", ":", "作业名称,允许输入长度小于等于50个字符的中文、英文、数字、", "-", "(横线)、_(下划线)、", ".", "(点),且符号必须半角字符。注意作业名不能和现有作业同名", ":", "type", "Name", ":", "str", ":", "param", "JobType", ":", "作业的类型,1", "表示", "SQL", "作业,2", "表示", "JAR", "作业", ":", "type", "JobType"...
def __init__(self): r""" :param Name: 作业名称,允许输入长度小于等于50个字符的中文、英文、数字、-(横线)、_(下划线)、.(点),且符号必须半角字符。注意作业名不能和现有作业同名 :type Name: str :param JobType: 作业的类型,1 表示 SQL 作业,2 表示 JAR 作业 :type JobType: int :param ClusterType: 集群的类型,1 表示共享集群,2 表示独享集群 :type ClusterType: int :param ClusterId: 当 ClusterType=2 时,必选,用来指定该作业提交的独享集群 ID :type ClusterId: str :param CuMem: 设置每 CU 的内存规格,单位为 GB,支持 2、4、8、16(需申请开通白名单后使用)。默认为 4,即 1 CU 对应 4 GB 的运行内存 :type CuMem: int :param Remark: 作业的备注信息,可以随意设置 :type Remark: str :param FolderId: 作业名所属文件夹ID,根目录为"root" :type FolderId: str :param FlinkVersion: 作业运行的Flink版本 :type FlinkVersion: str """ self.Name = None self.JobType = None self.ClusterType = None self.ClusterId = None self.CuMem = None self.Remark = None self.FolderId = None self.FlinkVersion = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "Name", "=", "None", "self", ".", "JobType", "=", "None", "self", ".", "ClusterType", "=", "None", "self", ".", "ClusterId", "=", "None", "self", ".", "CuMem", "=", "None", "self", ".", "Remark",...
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/oceanus/v20190422/models.py#L133-L159
replit-archive/empythoned
977ec10ced29a3541a4973dc2b59910805695752
cpython/Lib/mhlib.py
python
Folder.getcurrent
(self)
Return the current message. Raise Error when there is none.
Return the current message. Raise Error when there is none.
[ "Return", "the", "current", "message", ".", "Raise", "Error", "when", "there", "is", "none", "." ]
def getcurrent(self): """Return the current message. Raise Error when there is none.""" seqs = self.getsequences() try: return max(seqs['cur']) except (ValueError, KeyError): raise Error, "no cur message"
[ "def", "getcurrent", "(", "self", ")", ":", "seqs", "=", "self", ".", "getsequences", "(", ")", "try", ":", "return", "max", "(", "seqs", "[", "'cur'", "]", ")", "except", "(", "ValueError", ",", "KeyError", ")", ":", "raise", "Error", ",", "\"no cur...
https://github.com/replit-archive/empythoned/blob/977ec10ced29a3541a4973dc2b59910805695752/cpython/Lib/mhlib.py#L334-L340
biopython/biopython
2dd97e71762af7b046d7f7f8a4f1e38db6b06c86
Bio/KEGG/KGML/KGML_pathway.py
python
Reaction.entry
(self)
return self._pathway.entries[self._id]
Return the Entry corresponding to this reaction.
Return the Entry corresponding to this reaction.
[ "Return", "the", "Entry", "corresponding", "to", "this", "reaction", "." ]
def entry(self): """Return the Entry corresponding to this reaction.""" return self._pathway.entries[self._id]
[ "def", "entry", "(", "self", ")", ":", "return", "self", ".", "_pathway", ".", "entries", "[", "self", ".", "_id", "]" ]
https://github.com/biopython/biopython/blob/2dd97e71762af7b046d7f7f8a4f1e38db6b06c86/Bio/KEGG/KGML/KGML_pathway.py#L748-L750
oracle/graalpython
577e02da9755d916056184ec441c26e00b70145c
graalpython/lib-python/3/smtpd.py
python
SMTPChannel.__conn
(self)
return self.conn
[]
def __conn(self): warn("Access to __conn attribute on SMTPChannel is deprecated, " "use 'conn' instead", DeprecationWarning, 2) return self.conn
[ "def", "__conn", "(", "self", ")", ":", "warn", "(", "\"Access to __conn attribute on SMTPChannel is deprecated, \"", "\"use 'conn' instead\"", ",", "DeprecationWarning", ",", "2", ")", "return", "self", ".", "conn" ]
https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/smtpd.py#L289-L292
cea-hpc/clustershell
c421133ed4baa69e35ff76c476d4097201485344
lib/ClusterShell/Task.py
python
Task.info
(self, info_key, def_val=None)
return self._info.get(info_key, def_val)
Return per-task information. See set_info() for a list of reserved task info_keys.
Return per-task information. See set_info() for a list of reserved task info_keys.
[ "Return", "per", "-", "task", "information", ".", "See", "set_info", "()", "for", "a", "list", "of", "reserved", "task", "info_keys", "." ]
def info(self, info_key, def_val=None): """ Return per-task information. See set_info() for a list of reserved task info_keys. """ return self._info.get(info_key, def_val)
[ "def", "info", "(", "self", ",", "info_key", ",", "def_val", "=", "None", ")", ":", "return", "self", ".", "_info", ".", "get", "(", "info_key", ",", "def_val", ")" ]
https://github.com/cea-hpc/clustershell/blob/c421133ed4baa69e35ff76c476d4097201485344/lib/ClusterShell/Task.py#L480-L485
frescobaldi/frescobaldi
301cc977fc4ba7caa3df9e4bf905212ad5d06912
frescobaldi_app/autocomplete/harvest.py
python
schemewords
(document)
Harvests all schemewords from the document.
Harvests all schemewords from the document.
[ "Harvests", "all", "schemewords", "from", "the", "document", "." ]
def schemewords(document): """Harvests all schemewords from the document.""" for t in tokeniter.all_tokens(document): if type(t) is ly.lex.scheme.Word: yield t
[ "def", "schemewords", "(", "document", ")", ":", "for", "t", "in", "tokeniter", ".", "all_tokens", "(", "document", ")", ":", "if", "type", "(", "t", ")", "is", "ly", ".", "lex", ".", "scheme", ".", "Word", ":", "yield", "t" ]
https://github.com/frescobaldi/frescobaldi/blob/301cc977fc4ba7caa3df9e4bf905212ad5d06912/frescobaldi_app/autocomplete/harvest.py#L51-L55
mukund109/word-mesh
2be945d988d661bd51afa6bd646f944c9c5d202a
wordmesh/static_wordmesh.py
python
Wordmesh.set_fontcolor
(self, by='scores', colorscale='YlOrRd', custom_colors=None)
This function can be used to pick a metric which decides the font color for each extracted keyword. By default, the font color is assigned based on the score of each keyword. Fonts can be picked by: 'random', 'scores', 'pos_tag', 'clustering_criteria' You can also choose custom font colors by passing in a list of (R,G,B) tuples with values for each component falling in [0,255]. Parameters ---------- by : str or None, optional The metric used to assign font sizes. Can be None if custom colors are being used colorscale: str or None, optional One of [Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues]. When by=='scores', this will be used to determine the colorscale. custom_colors : list of 3-tuple, optional A list of RGB tuples. Each tuple corresponding to the color of a keyword. Returns ------- None
This function can be used to pick a metric which decides the font color for each extracted keyword. By default, the font color is assigned based on the score of each keyword. Fonts can be picked by: 'random', 'scores', 'pos_tag', 'clustering_criteria' You can also choose custom font colors by passing in a list of (R,G,B) tuples with values for each component falling in [0,255]. Parameters ---------- by : str or None, optional The metric used to assign font sizes. Can be None if custom colors are being used colorscale: str or None, optional One of [Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues]. When by=='scores', this will be used to determine the colorscale. custom_colors : list of 3-tuple, optional A list of RGB tuples. Each tuple corresponding to the color of a keyword. Returns ------- None
[ "This", "function", "can", "be", "used", "to", "pick", "a", "metric", "which", "decides", "the", "font", "color", "for", "each", "extracted", "keyword", ".", "By", "default", "the", "font", "color", "is", "assigned", "based", "on", "the", "score", "of", ...
def set_fontcolor(self, by='scores', colorscale='YlOrRd', custom_colors=None): """ This function can be used to pick a metric which decides the font color for each extracted keyword. By default, the font color is assigned based on the score of each keyword. Fonts can be picked by: 'random', 'scores', 'pos_tag', 'clustering_criteria' You can also choose custom font colors by passing in a list of (R,G,B) tuples with values for each component falling in [0,255]. Parameters ---------- by : str or None, optional The metric used to assign font sizes. Can be None if custom colors are being used colorscale: str or None, optional One of [Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues]. When by=='scores', this will be used to determine the colorscale. custom_colors : list of 3-tuple, optional A list of RGB tuples. Each tuple corresponding to the color of a keyword. Returns ------- None """ if custom_colors is not None: assert len(custom_colors) == len(self.keywords) if isinstance(custom_colors[0], str): self.fontcolors = custom_colors else: self.fontcolors = [] for rgb in custom_colors: assert len(rgb)==3 self.fontcolors.append('rgb'+str(rgb)) elif by=='random': tone = np.random.choice(list(cl.flipper()['seq']['3'].keys())) self.fontcolors = np.random.choice(list(cl.flipper()['seq']\ ['3'][tone]), len(self.keywords)) elif by=='scores': scales = {**cl.scales['8']['div'], **cl.scales['8']['seq']} #Even though, currently all colorscales in 'scales.keys()' can be #used, only the ones listed in the doc can be used for creating a #colorbar in the plotly plot assert colorscale in ['Greys','YlGnBu', 'Greens', 'YlOrRd', 'Bluered', 'RdBu', 'Reds', 'Blues'] colors = scales[colorscale].copy() colors.reverse() #The keywords are binned based on their scores mn, mx = self.scores.min(), self.scores.max() bins = np.linspace(mn,mx,8) indices = np.digitize(self.scores, bins)-1 self.fontcolors = [colors[i] for i in indices] elif by=='pos_tag': c = cl.scales['5']['qual']['Set2'] + ['rgb(254,254,254)', 'rgb(254,254,254)'] tags = ['NOUN','PROPN','ADJ','VERB','ADV','SYM','ADP'] mapping = {tag:c[i] for i,tag in enumerate(tags)} self.fontcolors = list(map(mapping.get, self.pos_tags)) elif by=='clustering_criteria': mds = MDS(3, dissimilarity='precomputed').\ fit_transform(self.similarity_matrix) mds = mds-mds.min() mds = mds*205/mds.max() + 50 self.fontcolors = ['rgb'+str(tuple(rgb)) for rgb in mds] else: raise ValueError() #raise flag to indicate that the fontcolors have been modified self._flag_fontcolors = True
[ "def", "set_fontcolor", "(", "self", ",", "by", "=", "'scores'", ",", "colorscale", "=", "'YlOrRd'", ",", "custom_colors", "=", "None", ")", ":", "if", "custom_colors", "is", "not", "None", ":", "assert", "len", "(", "custom_colors", ")", "==", "len", "(...
https://github.com/mukund109/word-mesh/blob/2be945d988d661bd51afa6bd646f944c9c5d202a/wordmesh/static_wordmesh.py#L260-L341
ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework
cb692f527e4e819b6c228187c5702d990a180043
external/Scripting Engine/packages/IronPython.StdLib.2.7.4/content/Lib/sets.py
python
Set.__isub__
(self, other)
return self
Remove all elements of another set from this set.
Remove all elements of another set from this set.
[ "Remove", "all", "elements", "of", "another", "set", "from", "this", "set", "." ]
def __isub__(self, other): """Remove all elements of another set from this set.""" self._binary_sanity_check(other) self.difference_update(other) return self
[ "def", "__isub__", "(", "self", ",", "other", ")", ":", "self", ".", "_binary_sanity_check", "(", "other", ")", "self", ".", "difference_update", "(", "other", ")", "return", "self" ]
https://github.com/ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework/blob/cb692f527e4e819b6c228187c5702d990a180043/external/Scripting Engine/packages/IronPython.StdLib.2.7.4/content/Lib/sets.py#L471-L475
jgagneastro/coffeegrindsize
22661ebd21831dba4cf32bfc6ba59fe3d49f879c
App/dist/coffeegrindsize.app/Contents/Resources/lib/python3.7/pandas/core/arrays/base.py
python
ExtensionArray._from_sequence
(cls, scalars, dtype=None, copy=False)
Construct a new ExtensionArray from a sequence of scalars. Parameters ---------- scalars : Sequence Each element will be an instance of the scalar type for this array, ``cls.dtype.type``. dtype : dtype, optional Construct for this particular dtype. This should be a Dtype compatible with the ExtensionArray. copy : boolean, default False If True, copy the underlying data. Returns ------- ExtensionArray
Construct a new ExtensionArray from a sequence of scalars.
[ "Construct", "a", "new", "ExtensionArray", "from", "a", "sequence", "of", "scalars", "." ]
def _from_sequence(cls, scalars, dtype=None, copy=False): """ Construct a new ExtensionArray from a sequence of scalars. Parameters ---------- scalars : Sequence Each element will be an instance of the scalar type for this array, ``cls.dtype.type``. dtype : dtype, optional Construct for this particular dtype. This should be a Dtype compatible with the ExtensionArray. copy : boolean, default False If True, copy the underlying data. Returns ------- ExtensionArray """ raise AbstractMethodError(cls)
[ "def", "_from_sequence", "(", "cls", ",", "scalars", ",", "dtype", "=", "None", ",", "copy", "=", "False", ")", ":", "raise", "AbstractMethodError", "(", "cls", ")" ]
https://github.com/jgagneastro/coffeegrindsize/blob/22661ebd21831dba4cf32bfc6ba59fe3d49f879c/App/dist/coffeegrindsize.app/Contents/Resources/lib/python3.7/pandas/core/arrays/base.py#L115-L134
Tautulli/Tautulli
2410eb33805aaac4bd1c5dad0f71e4f15afaf742
lib/cherrypy/_cpreqbody.py
python
Entity.__next__
(self)
return line
[]
def __next__(self): line = self.readline() if not line: raise StopIteration return line
[ "def", "__next__", "(", "self", ")", ":", "line", "=", "self", ".", "readline", "(", ")", "if", "not", "line", ":", "raise", "StopIteration", "return", "line" ]
https://github.com/Tautulli/Tautulli/blob/2410eb33805aaac4bd1c5dad0f71e4f15afaf742/lib/cherrypy/_cpreqbody.py#L489-L493
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/lib/python2.7/site-packages/requests/models.py
python
Response.text
(self)
return content
Content of the response, in unicode. If Response.encoding is None, encoding will be guessed using ``chardet``. The encoding of the response content is determined based solely on HTTP headers, following RFC 2616 to the letter. If you can take advantage of non-HTTP knowledge to make a better guess at the encoding, you should set ``r.encoding`` appropriately before accessing this property.
Content of the response, in unicode.
[ "Content", "of", "the", "response", "in", "unicode", "." ]
def text(self): """Content of the response, in unicode. If Response.encoding is None, encoding will be guessed using ``chardet``. The encoding of the response content is determined based solely on HTTP headers, following RFC 2616 to the letter. If you can take advantage of non-HTTP knowledge to make a better guess at the encoding, you should set ``r.encoding`` appropriately before accessing this property. """ # Try charset from content-type content = None encoding = self.encoding if not self.content: return str('') # Fallback to auto-detected encoding. if self.encoding is None: encoding = self.apparent_encoding # Decode unicode from given encoding. try: content = str(self.content, encoding, errors='replace') except (LookupError, TypeError): # A LookupError is raised if the encoding was not found which could # indicate a misspelling or similar mistake. # # A TypeError can be raised if encoding is None # # So we try blindly encoding. content = str(self.content, errors='replace') return content
[ "def", "text", "(", "self", ")", ":", "# Try charset from content-type", "content", "=", "None", "encoding", "=", "self", ".", "encoding", "if", "not", "self", ".", "content", ":", "return", "str", "(", "''", ")", "# Fallback to auto-detected encoding.", "if", ...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/requests/models.py#L831-L866
matrix-org/synapse
8e57584a5859a9002759963eb546d523d2498a01
synapse/http/site.py
python
SynapseRequest._should_log_request
(self)
return True
Whether we should log at INFO that we processed the request.
Whether we should log at INFO that we processed the request.
[ "Whether", "we", "should", "log", "at", "INFO", "that", "we", "processed", "the", "request", "." ]
def _should_log_request(self) -> bool: """Whether we should log at INFO that we processed the request.""" if self.path == b"/health": return False if self.method == b"OPTIONS": return False return True
[ "def", "_should_log_request", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "path", "==", "b\"/health\"", ":", "return", "False", "if", "self", ".", "method", "==", "b\"OPTIONS\"", ":", "return", "False", "return", "True" ]
https://github.com/matrix-org/synapse/blob/8e57584a5859a9002759963eb546d523d2498a01/synapse/http/site.py#L457-L465
ktbyers/netmiko
4c3732346eea1a4a608abd9e09d65eeb2f577810
netmiko/utilities.py
python
obtain_all_devices
( my_devices: Dict[str, Union[List[str], Dict[str, Any]]] )
return new_devices
Dynamically create 'all' group.
Dynamically create 'all' group.
[ "Dynamically", "create", "all", "group", "." ]
def obtain_all_devices( my_devices: Dict[str, Union[List[str], Dict[str, Any]]] ) -> Dict[str, Dict[str, Any]]: """Dynamically create 'all' group.""" new_devices = {} for device_name, device_or_group in my_devices.items(): # Skip any groups if not isinstance(device_or_group, list): new_devices[device_name] = device_or_group return new_devices
[ "def", "obtain_all_devices", "(", "my_devices", ":", "Dict", "[", "str", ",", "Union", "[", "List", "[", "str", "]", ",", "Dict", "[", "str", ",", "Any", "]", "]", "]", ")", "->", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]...
https://github.com/ktbyers/netmiko/blob/4c3732346eea1a4a608abd9e09d65eeb2f577810/netmiko/utilities.py#L180-L189
inspurer/WorkAttendanceSystem
1221e2d67bdf5bb15fe99517cc3ded58ccb066df
V1.0/venv/Lib/site-packages/pip-9.0.1-py3.5.egg/pip/_vendor/lockfile/pidlockfile.py
python
PIDLockFile.break_lock
(self)
Break an existing lock. Removes the PID file if it already exists, otherwise does nothing.
Break an existing lock.
[ "Break", "an", "existing", "lock", "." ]
def break_lock(self): """ Break an existing lock. Removes the PID file if it already exists, otherwise does nothing. """ remove_existing_pidfile(self.path)
[ "def", "break_lock", "(", "self", ")", ":", "remove_existing_pidfile", "(", "self", ".", "path", ")" ]
https://github.com/inspurer/WorkAttendanceSystem/blob/1221e2d67bdf5bb15fe99517cc3ded58ccb066df/V1.0/venv/Lib/site-packages/pip-9.0.1-py3.5.egg/pip/_vendor/lockfile/pidlockfile.py#L108-L115
tp4a/teleport
1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad
server/www/packages/packages-darwin/x64/PIL/ImageFont.py
python
FreeTypeFont.getsize
(self, text, direction=None, features=None)
return (size[0] + offset[0], size[1] + offset[1])
[]
def getsize(self, text, direction=None, features=None): size, offset = self.font.getsize(text, direction, features) return (size[0] + offset[0], size[1] + offset[1])
[ "def", "getsize", "(", "self", ",", "text", ",", "direction", "=", "None", ",", "features", "=", "None", ")", ":", "size", ",", "offset", "=", "self", ".", "font", ".", "getsize", "(", "text", ",", "direction", ",", "features", ")", "return", "(", ...
https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-darwin/x64/PIL/ImageFont.py#L160-L162
google-research/task_adaptation
d7630d3c43ba052b5a35546b312d9454a9f2c96b
task_adaptation/data/kitti.py
python
_closest_object_distance_pp
(x)
return {"image": x["image"], "label": label}
Predict the distance to the closest object.
Predict the distance to the closest object.
[ "Predict", "the", "distance", "to", "the", "closest", "object", "." ]
def _closest_object_distance_pp(x): """Predict the distance to the closest object.""" # Label distribution: # Location feature contains (x, y, z) in meters w.r.t. the camera. dist = tf.reduce_min(x["objects"]["location"][:, 2]) thrs = np.array([-100, 5.6, 8.4, 13.4, 23.4]) label = tf.reduce_max(tf.where((thrs - dist) < 0)) return {"image": x["image"], "label": label}
[ "def", "_closest_object_distance_pp", "(", "x", ")", ":", "# Label distribution:", "# Location feature contains (x, y, z) in meters w.r.t. the camera.", "dist", "=", "tf", ".", "reduce_min", "(", "x", "[", "\"objects\"", "]", "[", "\"location\"", "]", "[", ":", ",", "...
https://github.com/google-research/task_adaptation/blob/d7630d3c43ba052b5a35546b312d9454a9f2c96b/task_adaptation/data/kitti.py#L79-L87
cuthbertLab/music21
bd30d4663e52955ed922c10fdf541419d8c67671
music21/layout.py
python
LayoutScore.getSystemBeforeThis
(self, pageId, systemId)
given a pageId and systemId, get the (pageId, systemId) for the previous system. return (None, None) if it's the first system on the first page This test score has five systems on the first page, three on the second, and two on the third >>> lt = corpus.parse('demos/layoutTestMore.xml') >>> ls = layout.divideByPages(lt, fastMeasures = True) >>> systemId = 1 >>> pageId = 2 # last system, last page >>> while systemId is not None: ... pageId, systemId = ls.getSystemBeforeThis(pageId, systemId) ... (pageId, systemId) (2, 0) (1, 2) (1, 1) (1, 0) (0, 4) (0, 3) (0, 2) (0, 1) (0, 0) (None, None)
given a pageId and systemId, get the (pageId, systemId) for the previous system.
[ "given", "a", "pageId", "and", "systemId", "get", "the", "(", "pageId", "systemId", ")", "for", "the", "previous", "system", "." ]
def getSystemBeforeThis(self, pageId, systemId): # noinspection PyShadowingNames ''' given a pageId and systemId, get the (pageId, systemId) for the previous system. return (None, None) if it's the first system on the first page This test score has five systems on the first page, three on the second, and two on the third >>> lt = corpus.parse('demos/layoutTestMore.xml') >>> ls = layout.divideByPages(lt, fastMeasures = True) >>> systemId = 1 >>> pageId = 2 # last system, last page >>> while systemId is not None: ... pageId, systemId = ls.getSystemBeforeThis(pageId, systemId) ... (pageId, systemId) (2, 0) (1, 2) (1, 1) (1, 0) (0, 4) (0, 3) (0, 2) (0, 1) (0, 0) (None, None) ''' if systemId > 0: return pageId, systemId - 1 else: if pageId == 0: return (None, None) previousPageId = pageId - 1 numSystems = len(self.pages[previousPageId].systems) return previousPageId, numSystems - 1
[ "def", "getSystemBeforeThis", "(", "self", ",", "pageId", ",", "systemId", ")", ":", "# noinspection PyShadowingNames", "if", "systemId", ">", "0", ":", "return", "pageId", ",", "systemId", "-", "1", "else", ":", "if", "pageId", "==", "0", ":", "return", "...
https://github.com/cuthbertLab/music21/blob/bd30d4663e52955ed922c10fdf541419d8c67671/music21/layout.py#L1320-L1346
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/cvm/v20170312/models.py
python
Image.__init__
(self)
r""" :param ImageId: 镜像ID :type ImageId: str :param OsName: 镜像操作系统 :type OsName: str :param ImageType: 镜像类型 :type ImageType: str :param CreatedTime: 镜像创建时间 :type CreatedTime: str :param ImageName: 镜像名称 :type ImageName: str :param ImageDescription: 镜像描述 :type ImageDescription: str :param ImageSize: 镜像大小 :type ImageSize: int :param Architecture: 镜像架构 :type Architecture: str :param ImageState: 镜像状态: CREATING-创建中 NORMAL-正常 CREATEFAILED-创建失败 USING-使用中 SYNCING-同步中 IMPORTING-导入中 IMPORTFAILED-导入失败 :type ImageState: str :param Platform: 镜像来源平台 :type Platform: str :param ImageCreator: 镜像创建者 :type ImageCreator: str :param ImageSource: 镜像来源 :type ImageSource: str :param SyncPercent: 同步百分比 注意:此字段可能返回 null,表示取不到有效值。 :type SyncPercent: int :param IsSupportCloudinit: 镜像是否支持cloud-init 注意:此字段可能返回 null,表示取不到有效值。 :type IsSupportCloudinit: bool :param SnapshotSet: 镜像关联的快照信息 注意:此字段可能返回 null,表示取不到有效值。 :type SnapshotSet: list of Snapshot
r""" :param ImageId: 镜像ID :type ImageId: str :param OsName: 镜像操作系统 :type OsName: str :param ImageType: 镜像类型 :type ImageType: str :param CreatedTime: 镜像创建时间 :type CreatedTime: str :param ImageName: 镜像名称 :type ImageName: str :param ImageDescription: 镜像描述 :type ImageDescription: str :param ImageSize: 镜像大小 :type ImageSize: int :param Architecture: 镜像架构 :type Architecture: str :param ImageState: 镜像状态: CREATING-创建中 NORMAL-正常 CREATEFAILED-创建失败 USING-使用中 SYNCING-同步中 IMPORTING-导入中 IMPORTFAILED-导入失败 :type ImageState: str :param Platform: 镜像来源平台 :type Platform: str :param ImageCreator: 镜像创建者 :type ImageCreator: str :param ImageSource: 镜像来源 :type ImageSource: str :param SyncPercent: 同步百分比 注意:此字段可能返回 null,表示取不到有效值。 :type SyncPercent: int :param IsSupportCloudinit: 镜像是否支持cloud-init 注意:此字段可能返回 null,表示取不到有效值。 :type IsSupportCloudinit: bool :param SnapshotSet: 镜像关联的快照信息 注意:此字段可能返回 null,表示取不到有效值。 :type SnapshotSet: list of Snapshot
[ "r", ":", "param", "ImageId", ":", "镜像ID", ":", "type", "ImageId", ":", "str", ":", "param", "OsName", ":", "镜像操作系统", ":", "type", "OsName", ":", "str", ":", "param", "ImageType", ":", "镜像类型", ":", "type", "ImageType", ":", "str", ":", "param", "Crea...
def __init__(self): r""" :param ImageId: 镜像ID :type ImageId: str :param OsName: 镜像操作系统 :type OsName: str :param ImageType: 镜像类型 :type ImageType: str :param CreatedTime: 镜像创建时间 :type CreatedTime: str :param ImageName: 镜像名称 :type ImageName: str :param ImageDescription: 镜像描述 :type ImageDescription: str :param ImageSize: 镜像大小 :type ImageSize: int :param Architecture: 镜像架构 :type Architecture: str :param ImageState: 镜像状态: CREATING-创建中 NORMAL-正常 CREATEFAILED-创建失败 USING-使用中 SYNCING-同步中 IMPORTING-导入中 IMPORTFAILED-导入失败 :type ImageState: str :param Platform: 镜像来源平台 :type Platform: str :param ImageCreator: 镜像创建者 :type ImageCreator: str :param ImageSource: 镜像来源 :type ImageSource: str :param SyncPercent: 同步百分比 注意:此字段可能返回 null,表示取不到有效值。 :type SyncPercent: int :param IsSupportCloudinit: 镜像是否支持cloud-init 注意:此字段可能返回 null,表示取不到有效值。 :type IsSupportCloudinit: bool :param SnapshotSet: 镜像关联的快照信息 注意:此字段可能返回 null,表示取不到有效值。 :type SnapshotSet: list of Snapshot """ self.ImageId = None self.OsName = None self.ImageType = None self.CreatedTime = None self.ImageName = None self.ImageDescription = None self.ImageSize = None self.Architecture = None self.ImageState = None self.Platform = None self.ImageCreator = None self.ImageSource = None self.SyncPercent = None self.IsSupportCloudinit = None self.SnapshotSet = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "ImageId", "=", "None", "self", ".", "OsName", "=", "None", "self", ".", "ImageType", "=", "None", "self", ".", "CreatedTime", "=", "None", "self", ".", "ImageName", "=", "None", "self", ".", "Im...
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/cvm/v20170312/models.py#L3186-L3243
wagtail/wagtail
ba8207a5d82c8a1de8f5f9693a7cd07421762999
wagtail/admin/widgets/chooser.py
python
AdminPageChooser._get_lowest_common_page_class
(self)
Return a Page class that is an ancestor for all Page classes in ``target_models``, and is also a concrete Page class itself.
Return a Page class that is an ancestor for all Page classes in ``target_models``, and is also a concrete Page class itself.
[ "Return", "a", "Page", "class", "that", "is", "an", "ancestor", "for", "all", "Page", "classes", "in", "target_models", "and", "is", "also", "a", "concrete", "Page", "class", "itself", "." ]
def _get_lowest_common_page_class(self): """ Return a Page class that is an ancestor for all Page classes in ``target_models``, and is also a concrete Page class itself. """ if len(self.target_models) == 1: # Shortcut for a single page type return self.target_models[0] else: return Page
[ "def", "_get_lowest_common_page_class", "(", "self", ")", ":", "if", "len", "(", "self", ".", "target_models", ")", "==", "1", ":", "# Shortcut for a single page type", "return", "self", ".", "target_models", "[", "0", "]", "else", ":", "return", "Page" ]
https://github.com/wagtail/wagtail/blob/ba8207a5d82c8a1de8f5f9693a7cd07421762999/wagtail/admin/widgets/chooser.py#L94-L103
PokemonGoF/PokemonGo-Bot-Desktop
4bfa94f0183406c6a86f93645eff7abd3ad4ced8
build/pywin/Lib/lib2to3/refactor.py
python
_get_headnode_dict
(fixer_list)
return dict(head_nodes)
Accepts a list of fixers and returns a dictionary of head node type --> fixer list.
Accepts a list of fixers and returns a dictionary of head node type --> fixer list.
[ "Accepts", "a", "list", "of", "fixers", "and", "returns", "a", "dictionary", "of", "head", "node", "type", "--", ">", "fixer", "list", "." ]
def _get_headnode_dict(fixer_list): """ Accepts a list of fixers and returns a dictionary of head node type --> fixer list. """ head_nodes = collections.defaultdict(list) every = [] for fixer in fixer_list: if fixer.pattern: try: heads = _get_head_types(fixer.pattern) except _EveryNode: every.append(fixer) else: for node_type in heads: head_nodes[node_type].append(fixer) else: if fixer._accept_type is not None: head_nodes[fixer._accept_type].append(fixer) else: every.append(fixer) for node_type in chain(pygram.python_grammar.symbol2number.itervalues(), pygram.python_grammar.tokens): head_nodes[node_type].extend(every) return dict(head_nodes)
[ "def", "_get_headnode_dict", "(", "fixer_list", ")", ":", "head_nodes", "=", "collections", ".", "defaultdict", "(", "list", ")", "every", "=", "[", "]", "for", "fixer", "in", "fixer_list", ":", "if", "fixer", ".", "pattern", ":", "try", ":", "heads", "=...
https://github.com/PokemonGoF/PokemonGo-Bot-Desktop/blob/4bfa94f0183406c6a86f93645eff7abd3ad4ced8/build/pywin/Lib/lib2to3/refactor.py#L78-L100
matrix-org/synapse
8e57584a5859a9002759963eb546d523d2498a01
synapse/storage/databases/main/profile.py
python
ProfileWorkerStore.is_subscribed_remote_profile_for_user
(self, user_id: str)
return False
Check whether we are interested in a remote user's profile.
Check whether we are interested in a remote user's profile.
[ "Check", "whether", "we", "are", "interested", "in", "a", "remote", "user", "s", "profile", "." ]
async def is_subscribed_remote_profile_for_user(self, user_id: str) -> bool: """Check whether we are interested in a remote user's profile.""" res: Optional[str] = await self.db_pool.simple_select_one_onecol( table="group_users", keyvalues={"user_id": user_id}, retcol="user_id", allow_none=True, desc="should_update_remote_profile_cache_for_user", ) if res: return True res = await self.db_pool.simple_select_one_onecol( table="group_invites", keyvalues={"user_id": user_id}, retcol="user_id", allow_none=True, desc="should_update_remote_profile_cache_for_user", ) if res: return True return False
[ "async", "def", "is_subscribed_remote_profile_for_user", "(", "self", ",", "user_id", ":", "str", ")", "->", "bool", ":", "res", ":", "Optional", "[", "str", "]", "=", "await", "self", ".", "db_pool", ".", "simple_select_one_onecol", "(", "table", "=", "\"gr...
https://github.com/matrix-org/synapse/blob/8e57584a5859a9002759963eb546d523d2498a01/synapse/storage/databases/main/profile.py#L120-L143
mike01/pypacker
7e98b2cb00c465f726490580761ad6261302b6a6
pypacker/utils.py
python
get_wlan_mode
(iface)
return _MODE_STR_INT_TRANSLATE.get(found_str, WLAN_MODE_UNKNOWN)
return -- [MODE_MANAGED | MODE_MONITOR | MODE_UNKNOWN]
return -- [MODE_MANAGED | MODE_MONITOR | MODE_UNKNOWN]
[ "return", "--", "[", "MODE_MANAGED", "|", "MODE_MONITOR", "|", "MODE_UNKNOWN", "]" ]
def get_wlan_mode(iface): """ return -- [MODE_MANAGED | MODE_MONITOR | MODE_UNKNOWN] """ cmd_call = ["iwconfig", iface] output = subprocess.check_output(cmd_call) match = PATTERN_MODE.search(output) found_str = match.group(1).lower() return _MODE_STR_INT_TRANSLATE.get(found_str, WLAN_MODE_UNKNOWN)
[ "def", "get_wlan_mode", "(", "iface", ")", ":", "cmd_call", "=", "[", "\"iwconfig\"", ",", "iface", "]", "output", "=", "subprocess", ".", "check_output", "(", "cmd_call", ")", "match", "=", "PATTERN_MODE", ".", "search", "(", "output", ")", "found_str", "...
https://github.com/mike01/pypacker/blob/7e98b2cb00c465f726490580761ad6261302b6a6/pypacker/utils.py#L52-L61
hasanirtiza/Pedestron
3bdcf8476edc0741f28a80dd4cb161ac532507ee
tools/crowdhuman/coco.py
python
COCO.loadRes
(self, resFile)
return res
Load result file and return a result api object. :param resFile (str) : file name of result file :return: res (obj) : result api object
Load result file and return a result api object. :param resFile (str) : file name of result file :return: res (obj) : result api object
[ "Load", "result", "file", "and", "return", "a", "result", "api", "object", ".", ":", "param", "resFile", "(", "str", ")", ":", "file", "name", "of", "result", "file", ":", "return", ":", "res", "(", "obj", ")", ":", "result", "api", "object" ]
def loadRes(self, resFile): """ Load result file and return a result api object. :param resFile (str) : file name of result file :return: res (obj) : result api object """ res = COCO() res.dataset['images'] = [img for img in self.dataset['images']] # print('Loading and preparing results...') tic = time.time() if type(resFile) == str or type(resFile) == unicode: anns = json.load(open(resFile)) elif type(resFile) == np.ndarray: anns = self.loadNumpyAnnotations(resFile) else: anns = resFile assert type(anns) == list, 'results in not an array of objects' annsImgIds = [ann['image_id'] for ann in anns] assert set(annsImgIds) == (set(annsImgIds) & set(self.getImgIds())), \ 'Results do not correspond to current coco set' if 'caption' in anns[0]: imgIds = set([img['id'] for img in res.dataset['images']]) & set([ann['image_id'] for ann in anns]) res.dataset['images'] = [img for img in res.dataset['images'] if img['id'] in imgIds] for id, ann in enumerate(anns): ann['id'] = id+1 elif 'bbox' in anns[0] and not anns[0]['bbox'] == []: res.dataset['categories'] = copy.deepcopy(self.dataset['categories']) for id, ann in enumerate(anns): bb = ann['bbox'] x1, x2, y1, y2 = [bb[0], bb[0]+bb[2], bb[1], bb[1]+bb[3]] if not 'segmentation' in ann: ann['segmentation'] = [[x1, y1, x1, y2, x2, y2, x2, y1]] ann['area'] = bb[2]*bb[3] ann['height'] = bb[3] # if id>64181: # pass ann['id'] = id+1 ann['iscrowd'] = 0 elif 'segmentation' in anns[0]: res.dataset['categories'] = copy.deepcopy(self.dataset['categories']) for id, ann in enumerate(anns): # now only support compressed RLE format as segmentation results ann['area'] = maskUtils.area(ann['segmentation']) if not 'bbox' in ann: ann['bbox'] = maskUtils.toBbox(ann['segmentation']) ann['id'] = id+1 ann['iscrowd'] = 0 elif 'keypoints' in anns[0]: res.dataset['categories'] = copy.deepcopy(self.dataset['categories']) for id, ann in enumerate(anns): s = ann['keypoints'] x = s[0::3] y = s[1::3] x0,x1,y0,y1 = np.min(x), np.max(x), np.min(y), np.max(y) ann['area'] = (x1-x0)*(y1-y0) ann['id'] = id + 1 ann['bbox'] = [x0,y0,x1-x0,y1-y0] # print('DONE (t={:0.2f}s)'.format(time.time()- tic)) res.dataset['annotations'] = anns res.createIndex() return res
[ "def", "loadRes", "(", "self", ",", "resFile", ")", ":", "res", "=", "COCO", "(", ")", "res", ".", "dataset", "[", "'images'", "]", "=", "[", "img", "for", "img", "in", "self", ".", "dataset", "[", "'images'", "]", "]", "# print('Loading and preparing ...
https://github.com/hasanirtiza/Pedestron/blob/3bdcf8476edc0741f28a80dd4cb161ac532507ee/tools/crowdhuman/coco.py#L292-L354
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/lib/python2.7/site-packages/urllib3/contrib/pyopenssl.py
python
PyOpenSSLContext.set_ciphers
(self, ciphers)
[]
def set_ciphers(self, ciphers): if isinstance(ciphers, six.text_type): ciphers = ciphers.encode('utf-8') self._ctx.set_cipher_list(ciphers)
[ "def", "set_ciphers", "(", "self", ",", "ciphers", ")", ":", "if", "isinstance", "(", "ciphers", ",", "six", ".", "text_type", ")", ":", "ciphers", "=", "ciphers", ".", "encode", "(", "'utf-8'", ")", "self", ".", "_ctx", ".", "set_cipher_list", "(", "c...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/urllib3/contrib/pyopenssl.py#L406-L409
AppScale/gts
46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9
AppServer/lib/django-1.2/django/contrib/gis/geos/mutable_list.py
python
ListMixin.sort
(self, cmp=cmp, key=None, reverse=False)
Standard list sort method
Standard list sort method
[ "Standard", "list", "sort", "method" ]
def sort(self, cmp=cmp, key=None, reverse=False): "Standard list sort method" if key: temp = [(key(v),v) for v in self] temp.sort(cmp=cmp, key=lambda x: x[0], reverse=reverse) self[:] = [v[1] for v in temp] else: temp = list(self) temp.sort(cmp=cmp, reverse=reverse) self[:] = temp
[ "def", "sort", "(", "self", ",", "cmp", "=", "cmp", ",", "key", "=", "None", ",", "reverse", "=", "False", ")", ":", "if", "key", ":", "temp", "=", "[", "(", "key", "(", "v", ")", ",", "v", ")", "for", "v", "in", "self", "]", "temp", ".", ...
https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/django-1.2/django/contrib/gis/geos/mutable_list.py#L205-L214
ladybug-tools/honeybee-legacy
bd62af4862fe022801fb87dbc8794fdf1dff73a9
src/Honeybee_Generate Average Sky.py
python
getAverageRadiationValues
(epw_file, month, hour)
return avrDirRad, avrDifRad
[]
def getAverageRadiationValues(epw_file, month, hour): numberOfDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] dirRadCollection =[] difRadCollection =[] studyHours = [] for day in range(1, numberOfDays[month-1]): studyHours.append(date2Hour(month, day, hour)) epwfile = open(epw_file,"r") for lineCount, line in enumerate(epwfile): if lineCount -7 in studyHours: dirRad = (float(line.split(',')[14])) difRad = (float(line.split(',')[15])) dirRadCollection.append(dirRad) difRadCollection.append(difRad) avrDirRad = sum(dirRadCollection)/len(dirRadCollection) avrDifRad = sum(difRadCollection)/len(difRadCollection) return avrDirRad, avrDifRad
[ "def", "getAverageRadiationValues", "(", "epw_file", ",", "month", ",", "hour", ")", ":", "numberOfDays", "=", "[", "31", ",", "28", ",", "31", ",", "30", ",", "31", ",", "30", ",", "31", ",", "31", ",", "30", ",", "31", ",", "30", ",", "31", "...
https://github.com/ladybug-tools/honeybee-legacy/blob/bd62af4862fe022801fb87dbc8794fdf1dff73a9/src/Honeybee_Generate Average Sky.py#L65-L84
naftaliharris/tauthon
5587ceec329b75f7caf6d65a036db61ac1bae214
Lib/mimetypes.py
python
MimeTypes.guess_type
(self, url, strict=True)
Guess the type of a file based on its URL. Return value is a tuple (type, encoding) where type is None if the type can't be guessed (no or unknown suffix) or a string of the form type/subtype, usable for a MIME Content-type header; and encoding is None for no encoding or the name of the program used to encode (e.g. compress or gzip). The mappings are table driven. Encoding suffixes are case sensitive; type suffixes are first tried case sensitive, then case insensitive. The suffixes .tgz, .taz and .tz (case sensitive!) are all mapped to '.tar.gz'. (This is table-driven too, using the dictionary suffix_map.) Optional `strict' argument when False adds a bunch of commonly found, but non-standard types.
Guess the type of a file based on its URL.
[ "Guess", "the", "type", "of", "a", "file", "based", "on", "its", "URL", "." ]
def guess_type(self, url, strict=True): """Guess the type of a file based on its URL. Return value is a tuple (type, encoding) where type is None if the type can't be guessed (no or unknown suffix) or a string of the form type/subtype, usable for a MIME Content-type header; and encoding is None for no encoding or the name of the program used to encode (e.g. compress or gzip). The mappings are table driven. Encoding suffixes are case sensitive; type suffixes are first tried case sensitive, then case insensitive. The suffixes .tgz, .taz and .tz (case sensitive!) are all mapped to '.tar.gz'. (This is table-driven too, using the dictionary suffix_map.) Optional `strict' argument when False adds a bunch of commonly found, but non-standard types. """ scheme, url = urllib.splittype(url) if scheme == 'data': # syntax of data URLs: # dataurl := "data:" [ mediatype ] [ ";base64" ] "," data # mediatype := [ type "/" subtype ] *( ";" parameter ) # data := *urlchar # parameter := attribute "=" value # type/subtype defaults to "text/plain" comma = url.find(',') if comma < 0: # bad data URL return None, None semi = url.find(';', 0, comma) if semi >= 0: type = url[:semi] else: type = url[:comma] if '=' in type or '/' not in type: type = 'text/plain' return type, None # never compressed, so encoding is None base, ext = posixpath.splitext(url) while ext in self.suffix_map: base, ext = posixpath.splitext(base + self.suffix_map[ext]) if ext in self.encodings_map: encoding = self.encodings_map[ext] base, ext = posixpath.splitext(base) else: encoding = None types_map = self.types_map[True] if ext in types_map: return types_map[ext], encoding elif ext.lower() in types_map: return types_map[ext.lower()], encoding elif strict: return None, encoding types_map = self.types_map[False] if ext in types_map: return types_map[ext], encoding elif ext.lower() in types_map: return types_map[ext.lower()], encoding else: return None, encoding
[ "def", "guess_type", "(", "self", ",", "url", ",", "strict", "=", "True", ")", ":", "scheme", ",", "url", "=", "urllib", ".", "splittype", "(", "url", ")", "if", "scheme", "==", "'data'", ":", "# syntax of data URLs:", "# dataurl := \"data:\" [ mediatype ] [...
https://github.com/naftaliharris/tauthon/blob/5587ceec329b75f7caf6d65a036db61ac1bae214/Lib/mimetypes.py#L95-L155
nilearn/nilearn
9edba4471747efacf21260bf470a346307f52706
nilearn/externals/tempita/__init__.py
python
_Empty.__call__
(self, *args, **kw)
return self
[]
def __call__(self, *args, **kw): return self
[ "def", "__call__", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "return", "self" ]
https://github.com/nilearn/nilearn/blob/9edba4471747efacf21260bf470a346307f52706/nilearn/externals/tempita/__init__.py#L623-L624
UsergeTeam/Userge
aa0cb4b452d2887321170a52f99f8eb88d33fada
userge/plugins/utils/welcome.py
python
dowel
(msg: Message)
enable welcome message
enable welcome message
[ "enable", "welcome", "message" ]
async def dowel(msg: Message): """ enable welcome message """ await raw_do(msg, 'Welcome', WELCOME_COLLECTION, WELCOME_CHATS)
[ "async", "def", "dowel", "(", "msg", ":", "Message", ")", ":", "await", "raw_do", "(", "msg", ",", "'Welcome'", ",", "WELCOME_COLLECTION", ",", "WELCOME_CHATS", ")" ]
https://github.com/UsergeTeam/Userge/blob/aa0cb4b452d2887321170a52f99f8eb88d33fada/userge/plugins/utils/welcome.py#L103-L105
apigee/henchman
13c53c66669800aaa89f1799ac974b45ec473c3d
modules/curl/curl/requests/requests/packages/urllib3/__init__.py
python
disable_warnings
(category=exceptions.HTTPWarning)
Helper for quickly disabling all urllib3 warnings.
Helper for quickly disabling all urllib3 warnings.
[ "Helper", "for", "quickly", "disabling", "all", "urllib3", "warnings", "." ]
def disable_warnings(category=exceptions.HTTPWarning): """ Helper for quickly disabling all urllib3 warnings. """ warnings.simplefilter('ignore', category)
[ "def", "disable_warnings", "(", "category", "=", "exceptions", ".", "HTTPWarning", ")", ":", "warnings", ".", "simplefilter", "(", "'ignore'", ",", "category", ")" ]
https://github.com/apigee/henchman/blob/13c53c66669800aaa89f1799ac974b45ec473c3d/modules/curl/curl/requests/requests/packages/urllib3/__init__.py#L67-L71
fuzzbunch/fuzzbunch
4b60a6c7cf9f84cf389d3fcdb9281de84ffb5802
fuzzbunch/pyreadline/console/ironpython_console.py
python
Console.getkeypress
(self)
Return next key press event from the queue, ignoring others.
Return next key press event from the queue, ignoring others.
[ "Return", "next", "key", "press", "event", "from", "the", "queue", "ignoring", "others", "." ]
def getkeypress(self): '''Return next key press event from the queue, ignoring others.''' ck=System.ConsoleKey while 1: e = System.Console.ReadKey(True) if e.Key == System.ConsoleKey.PageDown: #PageDown self.scroll_window(12) elif e.Key == System.ConsoleKey.PageUp:#PageUp self.scroll_window(-12) elif str(e.KeyChar)=="\000":#Drop deadkeys log_sock("Deadkey: %s"%e) return event(self,e) pass else: return event(self,e)
[ "def", "getkeypress", "(", "self", ")", ":", "ck", "=", "System", ".", "ConsoleKey", "while", "1", ":", "e", "=", "System", ".", "Console", ".", "ReadKey", "(", "True", ")", "if", "e", ".", "Key", "==", "System", ".", "ConsoleKey", ".", "PageDown", ...
https://github.com/fuzzbunch/fuzzbunch/blob/4b60a6c7cf9f84cf389d3fcdb9281de84ffb5802/fuzzbunch/pyreadline/console/ironpython_console.py#L304-L318
SurrealAI/surreal
ae9e5f43bdd7d1bc6d39d0a4783b96b2c117fade
surreal/learner/ppo.py
python
PPOLearner._clip_loss
(self, obs, actions, advantages, behave_pol)
return clip_loss, stats
Computes the loss with current data. also returns a dictionary of statistics which includes surrogate loss, clipped surrogate los, policy entropy, clip constant return: surreal.utils.pytorch.GPUVariable, dict Args: obs: batch of observations in form of (batch_size, obs_dim) actions: batch of actions in form of (batch_size, act_dim) advantages: batch of normalized advantage, (batch_size, 1) behave_pol: batch of behavior policy (batch_size, 2 * act_dim) Returns: clip_loss: Variable for loss stats: dictionary of recorded statistics
Computes the loss with current data. also returns a dictionary of statistics which includes surrogate loss, clipped surrogate los, policy entropy, clip constant return: surreal.utils.pytorch.GPUVariable, dict Args: obs: batch of observations in form of (batch_size, obs_dim) actions: batch of actions in form of (batch_size, act_dim) advantages: batch of normalized advantage, (batch_size, 1) behave_pol: batch of behavior policy (batch_size, 2 * act_dim) Returns: clip_loss: Variable for loss stats: dictionary of recorded statistics
[ "Computes", "the", "loss", "with", "current", "data", ".", "also", "returns", "a", "dictionary", "of", "statistics", "which", "includes", "surrogate", "loss", "clipped", "surrogate", "los", "policy", "entropy", "clip", "constant", "return", ":", "surreal", ".", ...
def _clip_loss(self, obs, actions, advantages, behave_pol): """ Computes the loss with current data. also returns a dictionary of statistics which includes surrogate loss, clipped surrogate los, policy entropy, clip constant return: surreal.utils.pytorch.GPUVariable, dict Args: obs: batch of observations in form of (batch_size, obs_dim) actions: batch of actions in form of (batch_size, act_dim) advantages: batch of normalized advantage, (batch_size, 1) behave_pol: batch of behavior policy (batch_size, 2 * act_dim) Returns: clip_loss: Variable for loss stats: dictionary of recorded statistics """ learn_pol = self.model.forward_actor(obs, self.cells) learn_prob = self.pd.likelihood(actions, learn_pol) behave_prob = self.pd.likelihood(actions, behave_pol) prob_ratio = learn_prob / behave_prob cliped_ratio = torch.clamp(prob_ratio, 1 - self.clip_epsilon, 1 + self.clip_epsilon) surr = -prob_ratio * advantages.view(-1, 1) cliped_surr = -cliped_ratio * advantages.view(-1, 1) clip_loss = torch.cat([surr, cliped_surr], 1).max(1)[0].mean() stats = { "_surr_loss": surr.mean().item(), "_clip_surr_loss": clip_loss.item(), "_entropy": self.pd.entropy(learn_pol).mean().item(), '_clip_epsilon': self.clip_epsilon } return clip_loss, stats
[ "def", "_clip_loss", "(", "self", ",", "obs", ",", "actions", ",", "advantages", ",", "behave_pol", ")", ":", "learn_pol", "=", "self", ".", "model", ".", "forward_actor", "(", "obs", ",", "self", ".", "cells", ")", "learn_prob", "=", "self", ".", "pd"...
https://github.com/SurrealAI/surreal/blob/ae9e5f43bdd7d1bc6d39d0a4783b96b2c117fade/surreal/learner/ppo.py#L194-L225
dabeaz/ply
559a7a1feabb0853be79d4f4dd9e9e9e5ea0d08c
example/ansic/cparse.py
python
p_direct_abstract_declarator_5
(t)
direct_abstract_declarator : LPAREN parameter_type_list_opt RPAREN
direct_abstract_declarator : LPAREN parameter_type_list_opt RPAREN
[ "direct_abstract_declarator", ":", "LPAREN", "parameter_type_list_opt", "RPAREN" ]
def p_direct_abstract_declarator_5(t): 'direct_abstract_declarator : LPAREN parameter_type_list_opt RPAREN' pass
[ "def", "p_direct_abstract_declarator_5", "(", "t", ")", ":", "pass" ]
https://github.com/dabeaz/ply/blob/559a7a1feabb0853be79d4f4dd9e9e9e5ea0d08c/example/ansic/cparse.py#L524-L526
AppScale/gts
46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9
AppServer/lib/webob-1.1.1/webob/response.py
python
_request_uri
(environ)
return url
Like wsgiref.url.request_uri, except eliminates :80 ports Return the full request URI
Like wsgiref.url.request_uri, except eliminates :80 ports
[ "Like", "wsgiref", ".", "url", ".", "request_uri", "except", "eliminates", ":", "80", "ports" ]
def _request_uri(environ): """Like wsgiref.url.request_uri, except eliminates :80 ports Return the full request URI""" url = environ['wsgi.url_scheme']+'://' from urllib import quote if environ.get('HTTP_HOST'): url += environ['HTTP_HOST'] else: url += environ['SERVER_NAME'] + ':' + environ['SERVER_PORT'] if url.endswith(':80') and environ['wsgi.url_scheme'] == 'http': url = url[:-3] elif url.endswith(':443') and environ['wsgi.url_scheme'] == 'https': url = url[:-4] url += quote(environ.get('SCRIPT_NAME') or '/') from urllib import quote path_info = quote(environ.get('PATH_INFO','')) if not environ.get('SCRIPT_NAME'): url += path_info[1:] else: url += path_info return url
[ "def", "_request_uri", "(", "environ", ")", ":", "url", "=", "environ", "[", "'wsgi.url_scheme'", "]", "+", "'://'", "from", "urllib", "import", "quote", "if", "environ", ".", "get", "(", "'HTTP_HOST'", ")", ":", "url", "+=", "environ", "[", "'HTTP_HOST'",...
https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/webob-1.1.1/webob/response.py#L1148-L1171
open-io/oio-sds
16041950b6056a55d5ce7ca77795defe6dfa6c61
oio/directory/admin.py
python
AdminClient.has_base
(self, params, **kwargs)
return body
Ask each peer if base exists.
Ask each peer if base exists.
[ "Ask", "each", "peer", "if", "base", "exists", "." ]
def has_base(self, params, **kwargs): """ Ask each peer if base exists. """ _, body = self._request('POST', '/has', params=params, **kwargs) return body
[ "def", "has_base", "(", "self", ",", "params", ",", "*", "*", "kwargs", ")", ":", "_", ",", "body", "=", "self", ".", "_request", "(", "'POST'", ",", "'/has'", ",", "params", "=", "params", ",", "*", "*", "kwargs", ")", "return", "body" ]
https://github.com/open-io/oio-sds/blob/16041950b6056a55d5ce7ca77795defe6dfa6c61/oio/directory/admin.py#L175-L180
nltk/nltk
3f74ac55681667d7ef78b664557487145f51eb02
nltk/chunk/regexp.py
python
ChunkString._verify
(self, s, verify_tags)
Check to make sure that ``s`` still corresponds to some chunked version of ``_pieces``. :type verify_tags: bool :param verify_tags: Whether the individual tags should be checked. If this is false, ``_verify`` will check to make sure that ``_str`` encodes a chunked version of *some* list of tokens. If this is true, then ``_verify`` will check to make sure that the tags in ``_str`` match those in ``_pieces``. :raise ValueError: if the internal string representation of this ``ChunkString`` is invalid or not consistent with _pieces.
Check to make sure that ``s`` still corresponds to some chunked version of ``_pieces``.
[ "Check", "to", "make", "sure", "that", "s", "still", "corresponds", "to", "some", "chunked", "version", "of", "_pieces", "." ]
def _verify(self, s, verify_tags): """ Check to make sure that ``s`` still corresponds to some chunked version of ``_pieces``. :type verify_tags: bool :param verify_tags: Whether the individual tags should be checked. If this is false, ``_verify`` will check to make sure that ``_str`` encodes a chunked version of *some* list of tokens. If this is true, then ``_verify`` will check to make sure that the tags in ``_str`` match those in ``_pieces``. :raise ValueError: if the internal string representation of this ``ChunkString`` is invalid or not consistent with _pieces. """ # Check overall form if not ChunkString._VALID.match(s): raise ValueError( "Transformation generated invalid " "chunkstring:\n %s" % s ) # Check that parens are balanced. If the string is long, we # have to do this in pieces, to avoid a maximum recursion # depth limit for regular expressions. brackets = ChunkString._BRACKETS.sub("", s) for i in range(1 + len(brackets) // 5000): substr = brackets[i * 5000 : i * 5000 + 5000] if not ChunkString._BALANCED_BRACKETS.match(substr): raise ValueError( "Transformation generated invalid " "chunkstring:\n %s" % s ) if verify_tags <= 0: return tags1 = (re.split(r"[\{\}<>]+", s))[1:-1] tags2 = [self._tag(piece) for piece in self._pieces] if tags1 != tags2: raise ValueError( "Transformation generated invalid " "chunkstring: tag changed" )
[ "def", "_verify", "(", "self", ",", "s", ",", "verify_tags", ")", ":", "# Check overall form", "if", "not", "ChunkString", ".", "_VALID", ".", "match", "(", "s", ")", ":", "raise", "ValueError", "(", "\"Transformation generated invalid \"", "\"chunkstring:\\n %s\...
https://github.com/nltk/nltk/blob/3f74ac55681667d7ef78b664557487145f51eb02/nltk/chunk/regexp.py#L107-L148
OpenShot/openshot-qt
bbd2dd040a4e2a6120791e6c65ae0ddf212cb73d
src/windows/export.py
python
Export.updateFrameRate
(self)
Callback for changing the frame rate
Callback for changing the frame rate
[ "Callback", "for", "changing", "the", "frame", "rate" ]
def updateFrameRate(self): """Callback for changing the frame rate""" # Adjust the main timeline reader self.timeline.info.width = self.txtWidth.value() self.timeline.info.height = self.txtHeight.value() self.timeline.info.fps.num = self.txtFrameRateNum.value() self.timeline.info.fps.den = self.txtFrameRateDen.value() self.timeline.info.sample_rate = self.txtSampleRate.value() self.timeline.info.channels = self.txtChannels.value() self.timeline.info.channel_layout = self.cboChannelLayout.currentData() # Determine max frame (based on clips) self.timeline_length_int = self.timeline.GetMaxFrame() # Set the min and max frame numbers for this project self.txtStartFrame.setValue(1) self.txtEndFrame.setValue(self.timeline_length_int) # Calculate differences between editing/preview FPS and export FPS current_fps = get_app().project.get("fps") current_fps_float = float(current_fps["num"]) / float(current_fps["den"]) new_fps_float = float(self.txtFrameRateNum.value()) / float(self.txtFrameRateDen.value()) self.export_fps_factor = new_fps_float / current_fps_float self.original_fps_factor = current_fps_float / new_fps_float
[ "def", "updateFrameRate", "(", "self", ")", ":", "# Adjust the main timeline reader", "self", ".", "timeline", ".", "info", ".", "width", "=", "self", ".", "txtWidth", ".", "value", "(", ")", "self", ".", "timeline", ".", "info", ".", "height", "=", "self"...
https://github.com/OpenShot/openshot-qt/blob/bbd2dd040a4e2a6120791e6c65ae0ddf212cb73d/src/windows/export.py#L317-L340
Cadene/tensorflow-model-zoo.torch
990b10ffc22d4c8eacb2a502f20415b4f70c74c2
models/research/street/python/vgsl_model.py
python
VGSLImageModel._AddOutputLayer
(self, prev_layer, out_dims, out_func, num_classes)
return logits, output
Add the fully-connected logits and SoftMax/Logistic output Layer. Args: prev_layer: Output of last layer of main network. out_dims: Number of output dimensions, 0, 1 or 2. out_func: Output non-linearity. 's' or 'c'=softmax, 'l'=logistic. num_classes: Number of outputs/size of last output dimension. Returns: logits: Pre-softmax/logistic fully-connected output shaped to out_dims. outputs: Post-softmax/logistic shaped to out_dims. Raises: ValueError: if syntax is incorrect.
Add the fully-connected logits and SoftMax/Logistic output Layer.
[ "Add", "the", "fully", "-", "connected", "logits", "and", "SoftMax", "/", "Logistic", "output", "Layer", "." ]
def _AddOutputLayer(self, prev_layer, out_dims, out_func, num_classes): """Add the fully-connected logits and SoftMax/Logistic output Layer. Args: prev_layer: Output of last layer of main network. out_dims: Number of output dimensions, 0, 1 or 2. out_func: Output non-linearity. 's' or 'c'=softmax, 'l'=logistic. num_classes: Number of outputs/size of last output dimension. Returns: logits: Pre-softmax/logistic fully-connected output shaped to out_dims. outputs: Post-softmax/logistic shaped to out_dims. Raises: ValueError: if syntax is incorrect. """ # Reduce dimensionality appropriate to the output dimensions. batch_in = shapes.tensor_dim(prev_layer, dim=0) height_in = shapes.tensor_dim(prev_layer, dim=1) width_in = shapes.tensor_dim(prev_layer, dim=2) depth_in = shapes.tensor_dim(prev_layer, dim=3) if out_dims: # Combine any remaining height and width with batch and unpack after. shaped = tf.reshape(prev_layer, [-1, depth_in]) else: # Everything except batch goes to depth, and therefore has to be known. shaped = tf.reshape(prev_layer, [-1, height_in * width_in * depth_in]) logits = slim.fully_connected(shaped, num_classes, activation_fn=None) if out_func == 'l': raise ValueError('Logistic not yet supported!') else: output = tf.nn.softmax(logits) # Reshape to the dessired output. if out_dims == 2: output_shape = [batch_in, height_in, width_in, num_classes] elif out_dims == 1: output_shape = [batch_in, height_in * width_in, num_classes] else: output_shape = [batch_in, num_classes] output = tf.reshape(output, output_shape, name='Output') logits = tf.reshape(logits, output_shape) return logits, output
[ "def", "_AddOutputLayer", "(", "self", ",", "prev_layer", ",", "out_dims", ",", "out_func", ",", "num_classes", ")", ":", "# Reduce dimensionality appropriate to the output dimensions.", "batch_in", "=", "shapes", ".", "tensor_dim", "(", "prev_layer", ",", "dim", "=",...
https://github.com/Cadene/tensorflow-model-zoo.torch/blob/990b10ffc22d4c8eacb2a502f20415b4f70c74c2/models/research/street/python/vgsl_model.py#L382-L423
junyanz/BicycleGAN
40b9d52c27b9831f56c1c7c7a6ddde8bc9149067
util/html.py
python
HTML.get_image_dir
(self)
return self.img_dir
Return the directory that stores images
Return the directory that stores images
[ "Return", "the", "directory", "that", "stores", "images" ]
def get_image_dir(self): """Return the directory that stores images""" return self.img_dir
[ "def", "get_image_dir", "(", "self", ")", ":", "return", "self", ".", "img_dir" ]
https://github.com/junyanz/BicycleGAN/blob/40b9d52c27b9831f56c1c7c7a6ddde8bc9149067/util/html.py#L35-L37
CGATOxford/cgat
326aad4694bdfae8ddc194171bb5d73911243947
CGAT/scripts/cgat2rdf.py
python
buildParam
(**kwargs)
return param
return a parameter with default values. Specific fields can be set by providing keyword arguments.
return a parameter with default values.
[ "return", "a", "parameter", "with", "default", "values", "." ]
def buildParam(**kwargs): '''return a parameter with default values. Specific fields can be set by providing keyword arguments. ''' param = {} param['label'] = "label" param['description'] = "description" param['rank'] = 1 param['display'] = 'show' param['min_occurrence'] = 0 param['max_occurrence'] = 1 # get default value param['value'] = "value" param['type'] = "text" param['dependencies'] = {} param['property_bag'] = {} param['arg_long'] = '--long-argument' param.update(kwargs) return param
[ "def", "buildParam", "(", "*", "*", "kwargs", ")", ":", "param", "=", "{", "}", "param", "[", "'label'", "]", "=", "\"label\"", "param", "[", "'description'", "]", "=", "\"description\"", "param", "[", "'rank'", "]", "=", "1", "param", "[", "'display'"...
https://github.com/CGATOxford/cgat/blob/326aad4694bdfae8ddc194171bb5d73911243947/CGAT/scripts/cgat2rdf.py#L364-L387
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/cfw/v20190904/cfw_client.py
python
CfwClient.CreateNatFwInstance
(self, request)
创建防火墙实例 :param request: Request instance for CreateNatFwInstance. :type request: :class:`tencentcloud.cfw.v20190904.models.CreateNatFwInstanceRequest` :rtype: :class:`tencentcloud.cfw.v20190904.models.CreateNatFwInstanceResponse`
创建防火墙实例
[ "创建防火墙实例" ]
def CreateNatFwInstance(self, request): """创建防火墙实例 :param request: Request instance for CreateNatFwInstance. :type request: :class:`tencentcloud.cfw.v20190904.models.CreateNatFwInstanceRequest` :rtype: :class:`tencentcloud.cfw.v20190904.models.CreateNatFwInstanceResponse` """ try: params = request._serialize() body = self.call("CreateNatFwInstance", params) response = json.loads(body) if "Error" not in response["Response"]: model = models.CreateNatFwInstanceResponse() model._deserialize(response["Response"]) return model else: code = response["Response"]["Error"]["Code"] message = response["Response"]["Error"]["Message"] reqid = response["Response"]["RequestId"] raise TencentCloudSDKException(code, message, reqid) except Exception as e: if isinstance(e, TencentCloudSDKException): raise else: raise TencentCloudSDKException(e.message, e.message)
[ "def", "CreateNatFwInstance", "(", "self", ",", "request", ")", ":", "try", ":", "params", "=", "request", ".", "_serialize", "(", ")", "body", "=", "self", ".", "call", "(", "\"CreateNatFwInstance\"", ",", "params", ")", "response", "=", "json", ".", "l...
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/cfw/v20190904/cfw_client.py#L169-L194
django-oscar/django-oscar
ffcc530844d40283b6b1552778a140536b904f5f
src/oscar/apps/shipping/repository.py
python
Repository.apply_shipping_offers
(self, basket, methods)
return [self.apply_shipping_offer(basket, method, offer) for method in methods]
Apply shipping offers to the passed set of methods
Apply shipping offers to the passed set of methods
[ "Apply", "shipping", "offers", "to", "the", "passed", "set", "of", "methods" ]
def apply_shipping_offers(self, basket, methods): """ Apply shipping offers to the passed set of methods """ # We default to only applying the first shipping discount. offer = basket.shipping_discounts[0]['offer'] return [self.apply_shipping_offer(basket, method, offer) for method in methods]
[ "def", "apply_shipping_offers", "(", "self", ",", "basket", ",", "methods", ")", ":", "# We default to only applying the first shipping discount.", "offer", "=", "basket", ".", "shipping_discounts", "[", "0", "]", "[", "'offer'", "]", "return", "[", "self", ".", "...
https://github.com/django-oscar/django-oscar/blob/ffcc530844d40283b6b1552778a140536b904f5f/src/oscar/apps/shipping/repository.py#L68-L75
nlloyd/SubliminalCollaborator
5c619e17ddbe8acb9eea8996ec038169ddcd50a1
libs/twisted/mail/pop3.py
python
IMailbox.getMessage
(index)
Retrieve a file-like object for a particular message. @type index: C{int} @param index: The number of the message to retrieve @rtype: A file-like object @return: A file containing the message data with lines delimited by C{\\n}.
Retrieve a file-like object for a particular message.
[ "Retrieve", "a", "file", "-", "like", "object", "for", "a", "particular", "message", "." ]
def getMessage(index): """Retrieve a file-like object for a particular message. @type index: C{int} @param index: The number of the message to retrieve @rtype: A file-like object @return: A file containing the message data with lines delimited by C{\\n}. """
[ "def", "getMessage", "(", "index", ")", ":" ]
https://github.com/nlloyd/SubliminalCollaborator/blob/5c619e17ddbe8acb9eea8996ec038169ddcd50a1/libs/twisted/mail/pop3.py#L888-L897
scipy/scipy
e0a749f01e79046642ccfdc419edbf9e7ca141ad
scipy/stats/_mstats_basic.py
python
trimtail
(data, proportiontocut=0.2, tail='left', inclusive=(True,True), axis=None)
return trimr(data, limits=limits, axis=axis, inclusive=inclusive)
Trims the data by masking values from one tail. Parameters ---------- data : array_like Data to trim. proportiontocut : float, optional Percentage of trimming. If n is the number of unmasked values before trimming, the number of values after trimming is ``(1 - proportiontocut) * n``. Default is 0.2. tail : {'left','right'}, optional If 'left' the `proportiontocut` lowest values will be masked. If 'right' the `proportiontocut` highest values will be masked. Default is 'left'. inclusive : {(bool, bool) tuple}, optional Tuple indicating whether the number of data being masked on each side should be rounded (True) or truncated (False). Default is (True, True). axis : int, optional Axis along which to perform the trimming. If None, the input array is first flattened. Default is None. Returns ------- trimtail : ndarray Returned array of same shape as `data` with masked tail values.
Trims the data by masking values from one tail.
[ "Trims", "the", "data", "by", "masking", "values", "from", "one", "tail", "." ]
def trimtail(data, proportiontocut=0.2, tail='left', inclusive=(True,True), axis=None): """ Trims the data by masking values from one tail. Parameters ---------- data : array_like Data to trim. proportiontocut : float, optional Percentage of trimming. If n is the number of unmasked values before trimming, the number of values after trimming is ``(1 - proportiontocut) * n``. Default is 0.2. tail : {'left','right'}, optional If 'left' the `proportiontocut` lowest values will be masked. If 'right' the `proportiontocut` highest values will be masked. Default is 'left'. inclusive : {(bool, bool) tuple}, optional Tuple indicating whether the number of data being masked on each side should be rounded (True) or truncated (False). Default is (True, True). axis : int, optional Axis along which to perform the trimming. If None, the input array is first flattened. Default is None. Returns ------- trimtail : ndarray Returned array of same shape as `data` with masked tail values. """ tail = str(tail).lower()[0] if tail == 'l': limits = (proportiontocut,None) elif tail == 'r': limits = (None, proportiontocut) else: raise TypeError("The tail argument should be in ('left','right')") return trimr(data, limits=limits, axis=axis, inclusive=inclusive)
[ "def", "trimtail", "(", "data", ",", "proportiontocut", "=", "0.2", ",", "tail", "=", "'left'", ",", "inclusive", "=", "(", "True", ",", "True", ")", ",", "axis", "=", "None", ")", ":", "tail", "=", "str", "(", "tail", ")", ".", "lower", "(", ")"...
https://github.com/scipy/scipy/blob/e0a749f01e79046642ccfdc419edbf9e7ca141ad/scipy/stats/_mstats_basic.py#L1795-L1834
microsoft/azure-devops-python-api
451cade4c475482792cbe9e522c1fee32393139e
azure-devops/azure/devops/v5_1/git/git_client_base.py
python
GitClientBase.update_pull_request_statuses
(self, patch_document, repository_id, pull_request_id, project=None)
UpdatePullRequestStatuses. [Preview API] Update pull request statuses collection. The only supported operation type is `remove`. :param :class:`<[JsonPatchOperation]> <azure.devops.v5_1.git.models.[JsonPatchOperation]>` patch_document: Operations to apply to the pull request statuses in JSON Patch format. :param str repository_id: The repository ID of the pull request’s target branch. :param int pull_request_id: ID of the pull request. :param str project: Project ID or project name
UpdatePullRequestStatuses. [Preview API] Update pull request statuses collection. The only supported operation type is `remove`. :param :class:`<[JsonPatchOperation]> <azure.devops.v5_1.git.models.[JsonPatchOperation]>` patch_document: Operations to apply to the pull request statuses in JSON Patch format. :param str repository_id: The repository ID of the pull request’s target branch. :param int pull_request_id: ID of the pull request. :param str project: Project ID or project name
[ "UpdatePullRequestStatuses", ".", "[", "Preview", "API", "]", "Update", "pull", "request", "statuses", "collection", ".", "The", "only", "supported", "operation", "type", "is", "remove", ".", ":", "param", ":", "class", ":", "<", "[", "JsonPatchOperation", "]"...
def update_pull_request_statuses(self, patch_document, repository_id, pull_request_id, project=None): """UpdatePullRequestStatuses. [Preview API] Update pull request statuses collection. The only supported operation type is `remove`. :param :class:`<[JsonPatchOperation]> <azure.devops.v5_1.git.models.[JsonPatchOperation]>` patch_document: Operations to apply to the pull request statuses in JSON Patch format. :param str repository_id: The repository ID of the pull request’s target branch. :param int pull_request_id: ID of the pull request. :param str project: Project ID or project name """ route_values = {} if project is not None: route_values['project'] = self._serialize.url('project', project, 'str') if repository_id is not None: route_values['repositoryId'] = self._serialize.url('repository_id', repository_id, 'str') if pull_request_id is not None: route_values['pullRequestId'] = self._serialize.url('pull_request_id', pull_request_id, 'int') content = self._serialize.body(patch_document, '[JsonPatchOperation]') self._send(http_method='PATCH', location_id='b5f6bb4f-8d1e-4d79-8d11-4c9172c99c35', version='5.1-preview.1', route_values=route_values, content=content, media_type='application/json-patch+json')
[ "def", "update_pull_request_statuses", "(", "self", ",", "patch_document", ",", "repository_id", ",", "pull_request_id", ",", "project", "=", "None", ")", ":", "route_values", "=", "{", "}", "if", "project", "is", "not", "None", ":", "route_values", "[", "'pro...
https://github.com/microsoft/azure-devops-python-api/blob/451cade4c475482792cbe9e522c1fee32393139e/azure-devops/azure/devops/v5_1/git/git_client_base.py#L2314-L2335
JiYou/openstack
8607dd488bde0905044b303eb6e52bdea6806923
packages/source/cinder/cinder/openstack/common/rpc/impl_kombu.py
python
Connection._fetch_ssl_params
(self)
Handles fetching what ssl params should be used for the connection (if any)
Handles fetching what ssl params should be used for the connection (if any)
[ "Handles", "fetching", "what", "ssl", "params", "should", "be", "used", "for", "the", "connection", "(", "if", "any", ")" ]
def _fetch_ssl_params(self): """Handles fetching what ssl params should be used for the connection (if any)""" ssl_params = dict() # http://docs.python.org/library/ssl.html - ssl.wrap_socket if self.conf.kombu_ssl_version: ssl_params['ssl_version'] = self.conf.kombu_ssl_version if self.conf.kombu_ssl_keyfile: ssl_params['keyfile'] = self.conf.kombu_ssl_keyfile if self.conf.kombu_ssl_certfile: ssl_params['certfile'] = self.conf.kombu_ssl_certfile if self.conf.kombu_ssl_ca_certs: ssl_params['ca_certs'] = self.conf.kombu_ssl_ca_certs # We might want to allow variations in the # future with this? ssl_params['cert_reqs'] = ssl.CERT_REQUIRED if not ssl_params: # Just have the default behavior return True else: # Return the extended behavior return ssl_params
[ "def", "_fetch_ssl_params", "(", "self", ")", ":", "ssl_params", "=", "dict", "(", ")", "# http://docs.python.org/library/ssl.html - ssl.wrap_socket", "if", "self", ".", "conf", ".", "kombu_ssl_version", ":", "ssl_params", "[", "'ssl_version'", "]", "=", "self", "."...
https://github.com/JiYou/openstack/blob/8607dd488bde0905044b303eb6e52bdea6806923/packages/source/cinder/cinder/openstack/common/rpc/impl_kombu.py#L449-L472
CedricGuillemet/Imogen
ee417b42747ed5b46cb11b02ef0c3630000085b3
bin/Lib/chunk.py
python
Chunk.seek
(self, pos, whence=0)
Seek to specified position into the chunk. Default position is 0 (start of chunk). If the file is not seekable, this will result in an error.
Seek to specified position into the chunk. Default position is 0 (start of chunk). If the file is not seekable, this will result in an error.
[ "Seek", "to", "specified", "position", "into", "the", "chunk", ".", "Default", "position", "is", "0", "(", "start", "of", "chunk", ")", ".", "If", "the", "file", "is", "not", "seekable", "this", "will", "result", "in", "an", "error", "." ]
def seek(self, pos, whence=0): """Seek to specified position into the chunk. Default position is 0 (start of chunk). If the file is not seekable, this will result in an error. """ if self.closed: raise ValueError("I/O operation on closed file") if not self.seekable: raise OSError("cannot seek") if whence == 1: pos = pos + self.size_read elif whence == 2: pos = pos + self.chunksize if pos < 0 or pos > self.chunksize: raise RuntimeError self.file.seek(self.offset + pos, 0) self.size_read = pos
[ "def", "seek", "(", "self", ",", "pos", ",", "whence", "=", "0", ")", ":", "if", "self", ".", "closed", ":", "raise", "ValueError", "(", "\"I/O operation on closed file\"", ")", "if", "not", "self", ".", "seekable", ":", "raise", "OSError", "(", "\"canno...
https://github.com/CedricGuillemet/Imogen/blob/ee417b42747ed5b46cb11b02ef0c3630000085b3/bin/Lib/chunk.py#L98-L115
neurolib-dev/neurolib
8d8ed2ceb422e9a1367193495a7e2df96cf4e4a3
neurolib/models/aln/timeIntegration.py
python
timeIntegration
(params)
return timeIntegration_njit_elementwise( dt, duration, distr_delay, filter_sigma, Cmat, Dmat, c_gl, Ke_gl, tau_ou, sigma_ou, mue_ext_mean, mui_ext_mean, sigmae_ext, sigmai_ext, Ke, Ki, de, di, tau_se, tau_si, tau_de, tau_di, cee, cie, cii, cei, Jee_max, Jei_max, Jie_max, Jii_max, a, b, EA, tauA, C, gL, EL, DeltaT, VT, Vr, Vs, Tref, taum, mufe, mufi, IA, seem, seim, seev, seiv, siim, siem, siiv, siev, precalc_r, precalc_V, precalc_tau_mu, precalc_tau_sigma, dI, ds, sigmarange, Irange, N, Dmat_ndt, t, rates_exc, rates_inh, rd_exc, rd_inh, sqrt_dt, startind, ndt_de, ndt_di, mue_ou, mui_ou, ext_exc_rate, ext_inh_rate, ext_exc_current, ext_inh_current, noise_exc, noise_inh, )
Sets up the parameters for time integration Return: rates_exc: N*L array : containing the exc. neuron rates in kHz time series of the N nodes rates_inh: N*L array : containing the inh. neuron rates in kHz time series of the N nodes t: L array : time in ms mufe: N vector : final value of mufe for each node mufi: N vector : final value of mufi for each node IA: N vector : final value of IA for each node seem : N vector : final value of seem for each node seim : N vector : final value of seim for each node siem : N vector : final value of siem for each node siim : N vector : final value of siim for each node seev : N vector : final value of seev for each node seiv : N vector : final value of seiv for each node siev : N vector : final value of siev for each node siiv : N vector : final value of siiv for each node :param params: Parameter dictionary of the model :type params: dict :return: Integrated activity variables of the model :rtype: (numpy.ndarray,)
Sets up the parameters for time integration Return: rates_exc: N*L array : containing the exc. neuron rates in kHz time series of the N nodes rates_inh: N*L array : containing the inh. neuron rates in kHz time series of the N nodes t: L array : time in ms mufe: N vector : final value of mufe for each node mufi: N vector : final value of mufi for each node IA: N vector : final value of IA for each node seem : N vector : final value of seem for each node seim : N vector : final value of seim for each node siem : N vector : final value of siem for each node siim : N vector : final value of siim for each node seev : N vector : final value of seev for each node seiv : N vector : final value of seiv for each node siev : N vector : final value of siev for each node siiv : N vector : final value of siiv for each node
[ "Sets", "up", "the", "parameters", "for", "time", "integration", "Return", ":", "rates_exc", ":", "N", "*", "L", "array", ":", "containing", "the", "exc", ".", "neuron", "rates", "in", "kHz", "time", "series", "of", "the", "N", "nodes", "rates_inh", ":",...
def timeIntegration(params): """Sets up the parameters for time integration Return: rates_exc: N*L array : containing the exc. neuron rates in kHz time series of the N nodes rates_inh: N*L array : containing the inh. neuron rates in kHz time series of the N nodes t: L array : time in ms mufe: N vector : final value of mufe for each node mufi: N vector : final value of mufi for each node IA: N vector : final value of IA for each node seem : N vector : final value of seem for each node seim : N vector : final value of seim for each node siem : N vector : final value of siem for each node siim : N vector : final value of siim for each node seev : N vector : final value of seev for each node seiv : N vector : final value of seiv for each node siev : N vector : final value of siev for each node siiv : N vector : final value of siiv for each node :param params: Parameter dictionary of the model :type params: dict :return: Integrated activity variables of the model :rtype: (numpy.ndarray,) """ dt = params["dt"] # Time step for the Euler intergration (ms) duration = params["duration"] # imulation duration (ms) RNGseed = params["seed"] # seed for RNG # set to 0 for faster computation # ------------------------------------------------------------------------ # global coupling parameters # Connectivity matric # Interareal relative coupling strengths (values between 0 and 1), Cmat(i,j) connnection from jth to ith Cmat = params["Cmat"] c_gl = params["c_gl"] # EPSP amplitude between areas Ke_gl = params["Ke_gl"] # number of incoming E connections (to E population) from each area N = len(Cmat) # Number of areas # Interareal connection delay lengthMat = params["lengthMat"] signalV = params["signalV"] if N == 1: Dmat = np.ones((N, N)) * params["de"] else: Dmat = dp.computeDelayMatrix( lengthMat, signalV ) # Interareal connection delays, Dmat(i,j) Connnection from jth node to ith (ms) Dmat[np.eye(len(Dmat)) == 1] = np.ones(len(Dmat)) * params["de"] Dmat_ndt = np.around(Dmat / dt).astype(int) # delay matrix in multiples of dt # ------------------------------------------------------------------------ # local network (area) parameters [identical for all areas for now] ### model parameters filter_sigma = params["filter_sigma"] # distributed delay between areas, not tested, but should work # distributed delay is implemented by a convolution with the delay kernel # the convolution is represented as a linear ODE with the timescale that # corresponds to the width of the delay distribution distr_delay = params["distr_delay"] # external input parameters: tau_ou = params["tau_ou"] # Parameter of the Ornstein-Uhlenbeck process for the external input(ms) # Parameter of the Ornstein-Uhlenbeck (OU) process for the external input ( mV/ms/sqrt(ms) ) sigma_ou = params["sigma_ou"] mue_ext_mean = params["mue_ext_mean"] # Mean external excitatory input (OU process) (mV/ms) mui_ext_mean = params["mui_ext_mean"] # Mean external inhibitory input (OU process) (mV/ms) sigmae_ext = params["sigmae_ext"] # External exc input standard deviation ( mV/sqrt(ms) ) sigmai_ext = params["sigmai_ext"] # External inh input standard deviation ( mV/sqrt(ms) ) # recurrent coupling parameters Ke = params["Ke"] # Recurrent Exc coupling. "EE = IE" assumed for act_dep_coupling in current implementation Ki = params["Ki"] # Recurrent Exc coupling. "EI = II" assumed for act_dep_coupling in current implementation # Recurrent connection delays de = params["de"] # Local constant delay "EE = IE" (ms) di = params["di"] # Local constant delay "EI = II" (ms) tau_se = params["tau_se"] # Synaptic decay time constant for exc. connections "EE = IE" (ms) tau_si = params["tau_si"] # Synaptic decay time constant for inh. connections "EI = II" (ms) tau_de = params["tau_de"] tau_di = params["tau_di"] cee = params["cee"] # strength of exc. connection # -> determines ePSP magnitude in state-dependent way (in the original model) cie = params["cie"] # strength of inh. connection # -> determines iPSP magnitude in state-dependent way (in the original model) cei = params["cei"] cii = params["cii"] # Recurrent connections coupling strength Jee_max = params["Jee_max"] # ( mV/ms ) Jei_max = params["Jei_max"] # ( mV/ms ) Jie_max = params["Jie_max"] # ( mV/ms ) Jii_max = params["Jii_max"] # ( mV/ms ) # rescales c's here: multiplication with tau_se makes # the increase of s subject to a single input spike invariant to tau_se # division by J ensures that mu = J*s will result in a PSP of exactly c # for a single spike! cee = cee * tau_se / Jee_max # ms cie = cie * tau_se / Jie_max # ms cei = cei * tau_si / abs(Jei_max) # ms cii = cii * tau_si / abs(Jii_max) # ms c_gl = c_gl * tau_se / Jee_max # ms # neuron model parameters a = params["a"] # Adaptation coupling term ( nS ) b = params["b"] # Spike triggered adaptation ( pA ) EA = params["EA"] # Adaptation reversal potential ( mV ) tauA = params["tauA"] # Adaptation time constant ( ms ) # if params below are changed, preprocessing required C = params["C"] # membrane capacitance ( pF ) gL = params["gL"] # Membrane conductance ( nS ) EL = params["EL"] # Leak reversal potential ( mV ) DeltaT = params["DeltaT"] # Slope factor ( EIF neuron ) ( mV ) VT = params["VT"] # Effective threshold (in exp term of the aEIF model)(mV) Vr = params["Vr"] # Membrane potential reset value (mV) Vs = params["Vs"] # Cutoff or spike voltage value, determines the time of spike (mV) Tref = params["Tref"] # Refractory time (ms) taum = C / gL # membrane time constant # ------------------------------------------------------------------------ # Lookup tables for the transfer functions precalc_r, precalc_V, precalc_tau_mu, precalc_tau_sigma = ( params["precalc_r"], params["precalc_V"], params["precalc_tau_mu"], params["precalc_tau_sigma"], ) # parameter for the lookup tables dI = params["dI"] ds = params["ds"] sigmarange = params["sigmarange"] Irange = params["Irange"] # Initialization # Floating point issue in np.arange() workaraound: use integers in np.arange() t = np.arange(1, round(duration, 6) / dt + 1) * dt # Time variable (ms) sqrt_dt = np.sqrt(dt) ndt_de = np.around(de / dt).astype(int) ndt_di = np.around(di / dt).astype(int) rd_exc = np.zeros((N, N)) # kHz rd_exc(i,j): Connection from jth node to ith rd_inh = np.zeros(N) # Already done above when Dmat_ndt is built # for l in range(N): # Dmat_ndt[l, l] = ndt_de # if no distributed, this is a fixed value (E-E coupling) max_global_delay = max(np.max(Dmat_ndt), ndt_de, ndt_di) startind = int(max_global_delay + 1) # state variable arrays, have length of t + startind # they store initial conditions AND simulated data rates_exc = np.zeros((N, startind + len(t))) rates_inh = np.zeros((N, startind + len(t))) IA = np.zeros((N, startind + len(t))) # ------------------------------------------------------------------------ # Set initial values mufe = params["mufe_init"].copy() # Filtered mean input (mu) for exc. population mufi = params["mufi_init"].copy() # Filtered mean input (mu) for inh. population IA_init = params["IA_init"].copy() # Adaptation current (pA) seem = params["seem_init"].copy() # Mean exc synaptic input seim = params["seim_init"].copy() seev = params["seev_init"].copy() # Exc synaptic input variance seiv = params["seiv_init"].copy() siim = params["siim_init"].copy() # Mean inh synaptic input siem = params["siem_init"].copy() siiv = params["siiv_init"].copy() # Inh synaptic input variance siev = params["siev_init"].copy() mue_ou = params["mue_ou"].copy() # Mean of external exc OU input (mV/ms) mui_ou = params["mui_ou"].copy() # Mean of external inh ON inout (mV/ms) # Set the initial firing rates. # if initial values are just a Nx1 array if np.shape(params["rates_exc_init"])[1] == 1: # repeat the 1-dim value stardind times rates_exc_init = np.dot(params["rates_exc_init"], np.ones((1, startind))) # kHz rates_inh_init = np.dot(params["rates_inh_init"], np.ones((1, startind))) # kHz # set initial adaptation current IA_init = np.dot(params["IA_init"], np.ones((1, startind))) # if initial values are a Nxt array else: rates_exc_init = params["rates_exc_init"][:, -startind:] rates_inh_init = params["rates_inh_init"][:, -startind:] IA_init = params["IA_init"][:, -startind:] np.random.seed(RNGseed) # Save the noise in the rates array to save memory rates_exc[:, startind:] = np.random.standard_normal((N, len(t))) rates_inh[:, startind:] = np.random.standard_normal((N, len(t))) # Set the initial conditions rates_exc[:, :startind] = rates_exc_init rates_inh[:, :startind] = rates_inh_init IA[:, :startind] = IA_init noise_exc = np.zeros((N,)) noise_inh = np.zeros((N,)) # tile external inputs to appropriate shape ext_exc_current = adjust_shape(params["ext_exc_current"], rates_exc) ext_inh_current = adjust_shape(params["ext_inh_current"], rates_exc) ext_exc_rate = adjust_shape(params["ext_exc_rate"], rates_exc) ext_inh_rate = adjust_shape(params["ext_inh_rate"], rates_exc) # ------------------------------------------------------------------------ return timeIntegration_njit_elementwise( dt, duration, distr_delay, filter_sigma, Cmat, Dmat, c_gl, Ke_gl, tau_ou, sigma_ou, mue_ext_mean, mui_ext_mean, sigmae_ext, sigmai_ext, Ke, Ki, de, di, tau_se, tau_si, tau_de, tau_di, cee, cie, cii, cei, Jee_max, Jei_max, Jie_max, Jii_max, a, b, EA, tauA, C, gL, EL, DeltaT, VT, Vr, Vs, Tref, taum, mufe, mufi, IA, seem, seim, seev, seiv, siim, siem, siiv, siev, precalc_r, precalc_V, precalc_tau_mu, precalc_tau_sigma, dI, ds, sigmarange, Irange, N, Dmat_ndt, t, rates_exc, rates_inh, rd_exc, rd_inh, sqrt_dt, startind, ndt_de, ndt_di, mue_ou, mui_ou, ext_exc_rate, ext_inh_rate, ext_exc_current, ext_inh_current, noise_exc, noise_inh, )
[ "def", "timeIntegration", "(", "params", ")", ":", "dt", "=", "params", "[", "\"dt\"", "]", "# Time step for the Euler intergration (ms)", "duration", "=", "params", "[", "\"duration\"", "]", "# imulation duration (ms)", "RNGseed", "=", "params", "[", "\"seed\"", "]...
https://github.com/neurolib-dev/neurolib/blob/8d8ed2ceb422e9a1367193495a7e2df96cf4e4a3/neurolib/models/aln/timeIntegration.py#L7-L312
Azure/azure-devops-cli-extension
11334cd55806bef0b99c3bee5a438eed71e44037
azure-devops/azext_devops/devops_sdk/v6_0/pipeline_permissions/pipeline_permissions_client.py
python
PipelinePermissionsClient.update_pipeline_permisions_for_resources
(self, resource_authorizations, project)
return self._deserialize('[ResourcePipelinePermissions]', self._unwrap_collection(response))
UpdatePipelinePermisionsForResources. [Preview API] Batch API to authorize/unauthorize a list of definitions for a multiple resources. :param [ResourcePipelinePermissions] resource_authorizations: :param str project: Project ID or project name :rtype: [ResourcePipelinePermissions]
UpdatePipelinePermisionsForResources. [Preview API] Batch API to authorize/unauthorize a list of definitions for a multiple resources. :param [ResourcePipelinePermissions] resource_authorizations: :param str project: Project ID or project name :rtype: [ResourcePipelinePermissions]
[ "UpdatePipelinePermisionsForResources", ".", "[", "Preview", "API", "]", "Batch", "API", "to", "authorize", "/", "unauthorize", "a", "list", "of", "definitions", "for", "a", "multiple", "resources", ".", ":", "param", "[", "ResourcePipelinePermissions", "]", "reso...
def update_pipeline_permisions_for_resources(self, resource_authorizations, project): """UpdatePipelinePermisionsForResources. [Preview API] Batch API to authorize/unauthorize a list of definitions for a multiple resources. :param [ResourcePipelinePermissions] resource_authorizations: :param str project: Project ID or project name :rtype: [ResourcePipelinePermissions] """ route_values = {} if project is not None: route_values['project'] = self._serialize.url('project', project, 'str') content = self._serialize.body(resource_authorizations, '[ResourcePipelinePermissions]') response = self._send(http_method='PATCH', location_id='b5b9a4a4-e6cd-4096-853c-ab7d8b0c4eb2', version='6.0-preview.1', route_values=route_values, content=content) return self._deserialize('[ResourcePipelinePermissions]', self._unwrap_collection(response))
[ "def", "update_pipeline_permisions_for_resources", "(", "self", ",", "resource_authorizations", ",", "project", ")", ":", "route_values", "=", "{", "}", "if", "project", "is", "not", "None", ":", "route_values", "[", "'project'", "]", "=", "self", ".", "_seriali...
https://github.com/Azure/azure-devops-cli-extension/blob/11334cd55806bef0b99c3bee5a438eed71e44037/azure-devops/azext_devops/devops_sdk/v6_0/pipeline_permissions/pipeline_permissions_client.py#L73-L89
maas/maas
db2f89970c640758a51247c59bf1ec6f60cf4ab5
src/provisioningserver/drivers/power/__init__.py
python
PowerDriver.power_on
(self, system_id, context)
Implement this method for the actual implementation of the power on command.
Implement this method for the actual implementation of the power on command.
[ "Implement", "this", "method", "for", "the", "actual", "implementation", "of", "the", "power", "on", "command", "." ]
def power_on(self, system_id, context): """Implement this method for the actual implementation of the power on command. """
[ "def", "power_on", "(", "self", ",", "system_id", ",", "context", ")", ":" ]
https://github.com/maas/maas/blob/db2f89970c640758a51247c59bf1ec6f60cf4ab5/src/provisioningserver/drivers/power/__init__.py#L275-L278
oracle/graalpython
577e02da9755d916056184ec441c26e00b70145c
graalpython/lib-graalpython/_weakref.py
python
ProxyType.__gt__
(self, other)
return _proxy_get(self) > other
[]
def __gt__(self, other): return _proxy_get(self) > other
[ "def", "__gt__", "(", "self", ",", "other", ")", ":", "return", "_proxy_get", "(", "self", ")", ">", "other" ]
https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-graalpython/_weakref.py#L96-L97
SchrodingersGat/KiBoM
69e0a305bc1c376cfcbb0998e29cf846284b8734
kibom/debug.py
python
info
(*arg)
Display an info message.
Display an info message.
[ "Display", "an", "info", "message", "." ]
def info(*arg): """ Display an info message. """ global MSG_LEVEL if MSG_LEVEL < MSG_INFO: return _msg(MSG_CODES[MSG_INFO], *arg)
[ "def", "info", "(", "*", "arg", ")", ":", "global", "MSG_LEVEL", "if", "MSG_LEVEL", "<", "MSG_INFO", ":", "return", "_msg", "(", "MSG_CODES", "[", "MSG_INFO", "]", ",", "*", "arg", ")" ]
https://github.com/SchrodingersGat/KiBoM/blob/69e0a305bc1c376cfcbb0998e29cf846284b8734/kibom/debug.py#L71-L80
sripathikrishnan/redis-rdb-tools
548b11ec3c81a603f5b321228d07a61a0b940159
rdbtools/callbacks.py
python
KeyValsOnlyCallback._start_key
(self, key, length)
[]
def _start_key(self, key, length): if not self._is_first_key_in_db: self._out.write(b',') self._out.write(b'\r\n') self._is_first_key_in_db = False self._elements_in_key = length self._element_index = 0
[ "def", "_start_key", "(", "self", ",", "key", ",", "length", ")", ":", "if", "not", "self", ".", "_is_first_key_in_db", ":", "self", ".", "_out", ".", "write", "(", "b','", ")", "self", ".", "_out", ".", "write", "(", "b'\\r\\n'", ")", "self", ".", ...
https://github.com/sripathikrishnan/redis-rdb-tools/blob/548b11ec3c81a603f5b321228d07a61a0b940159/rdbtools/callbacks.py#L191-L197
matrix-org/synapse
8e57584a5859a9002759963eb546d523d2498a01
synapse/storage/databases/main/registration.py
python
RegistrationWorkerStore.get_user_id_by_threepid
(self, medium: str, address: str)
return user_id
Returns user id from threepid Args: medium: threepid medium e.g. email address: threepid address e.g. me@example.com. This must already be in canonical form. Returns: The user ID or None if no user id/threepid mapping exists
Returns user id from threepid
[ "Returns", "user", "id", "from", "threepid" ]
async def get_user_id_by_threepid(self, medium: str, address: str) -> Optional[str]: """Returns user id from threepid Args: medium: threepid medium e.g. email address: threepid address e.g. me@example.com. This must already be in canonical form. Returns: The user ID or None if no user id/threepid mapping exists """ user_id = await self.db_pool.runInteraction( "get_user_id_by_threepid", self.get_user_id_by_threepid_txn, medium, address ) return user_id
[ "async", "def", "get_user_id_by_threepid", "(", "self", ",", "medium", ":", "str", ",", "address", ":", "str", ")", "->", "Optional", "[", "str", "]", ":", "user_id", "=", "await", "self", ".", "db_pool", ".", "runInteraction", "(", "\"get_user_id_by_threepi...
https://github.com/matrix-org/synapse/blob/8e57584a5859a9002759963eb546d523d2498a01/synapse/storage/databases/main/registration.py#L854-L868
worron/ACYLS
91b68780112fb6f6d23c37b003f426dd9ad3e241
scripts/lib/fssupport.py
python
get_svg_first
(*dirlist)
Find first SVG icon in directories
Find first SVG icon in directories
[ "Find", "first", "SVG", "icon", "in", "directories" ]
def get_svg_first(*dirlist): """Find first SVG icon in directories""" for path in dirlist: for root, _, files in os.walk(path): for filename in files: if filename.endswith('.svg'): return os.path.join(root, filename)
[ "def", "get_svg_first", "(", "*", "dirlist", ")", ":", "for", "path", "in", "dirlist", ":", "for", "root", ",", "_", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "for", "filename", "in", "files", ":", "if", "filename", ".", "endswi...
https://github.com/worron/ACYLS/blob/91b68780112fb6f6d23c37b003f426dd9ad3e241/scripts/lib/fssupport.py#L23-L29
AnonGit90210/RamanujanMachine
1f4f8f76e61291f4dc4a81fead4a721f21f5f943
utils.py
python
grouper
(iterable, n, fillvalue=None)
return zip_longest(*args, fillvalue=fillvalue)
Collect data into fixed-length chunks or blocks
Collect data into fixed-length chunks or blocks
[ "Collect", "data", "into", "fixed", "-", "length", "chunks", "or", "blocks" ]
def grouper(iterable, n, fillvalue=None): "Collect data into fixed-length chunks or blocks" # grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx" args = [iter(iterable)] * n return zip_longest(*args, fillvalue=fillvalue)
[ "def", "grouper", "(", "iterable", ",", "n", ",", "fillvalue", "=", "None", ")", ":", "# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx\"", "args", "=", "[", "iter", "(", "iterable", ")", "]", "*", "n", "return", "zip_longest", "(", "*", "args", ",", "fillvalue"...
https://github.com/AnonGit90210/RamanujanMachine/blob/1f4f8f76e61291f4dc4a81fead4a721f21f5f943/utils.py#L172-L176
facetoe/zenpy
e614e973aa4d3c4c2a0b91767c2d8565f48ec717
zenpy/lib/api.py
python
SatisfactionRatingApi.create
(self, ticket, satisfaction_rating)
return SatisfactionRatingRequest(self).post(ticket, satisfaction_rating)
Create/update a Satisfaction Rating for a ticket. :param ticket: Ticket object or id :param satisfaction_rating: SatisfactionRating object.
Create/update a Satisfaction Rating for a ticket.
[ "Create", "/", "update", "a", "Satisfaction", "Rating", "for", "a", "ticket", "." ]
def create(self, ticket, satisfaction_rating): """ Create/update a Satisfaction Rating for a ticket. :param ticket: Ticket object or id :param satisfaction_rating: SatisfactionRating object. """ return SatisfactionRatingRequest(self).post(ticket, satisfaction_rating)
[ "def", "create", "(", "self", ",", "ticket", ",", "satisfaction_rating", ")", ":", "return", "SatisfactionRatingRequest", "(", "self", ")", ".", "post", "(", "ticket", ",", "satisfaction_rating", ")" ]
https://github.com/facetoe/zenpy/blob/e614e973aa4d3c4c2a0b91767c2d8565f48ec717/zenpy/lib/api.py#L1177-L1185
freqtrade/freqtrade
13651fd3be8d5ce8dcd7c94b920bda4e00b75aca
freqtrade/optimize/hyperopt_tools.py
python
HyperoptTools.show_epoch_details
(results, total_epochs: int, print_json: bool, no_header: bool = False, header_str: str = None)
Display details of the hyperopt result
Display details of the hyperopt result
[ "Display", "details", "of", "the", "hyperopt", "result" ]
def show_epoch_details(results, total_epochs: int, print_json: bool, no_header: bool = False, header_str: str = None) -> None: """ Display details of the hyperopt result """ params = results.get('params_details', {}) non_optimized = results.get('params_not_optimized', {}) # Default header string if header_str is None: header_str = "Best result" if not no_header: explanation_str = HyperoptTools._format_explanation_string(results, total_epochs) print(f"\n{header_str}:\n\n{explanation_str}\n") if print_json: result_dict: Dict = {} for s in ['buy', 'sell', 'protection', 'roi', 'stoploss', 'trailing']: HyperoptTools._params_update_for_json(result_dict, params, non_optimized, s) print(rapidjson.dumps(result_dict, default=str, number_mode=rapidjson.NM_NATIVE)) else: HyperoptTools._params_pretty_print(params, 'buy', "Buy hyperspace params:", non_optimized) HyperoptTools._params_pretty_print(params, 'sell', "Sell hyperspace params:", non_optimized) HyperoptTools._params_pretty_print(params, 'protection', "Protection hyperspace params:", non_optimized) HyperoptTools._params_pretty_print(params, 'roi', "ROI table:", non_optimized) HyperoptTools._params_pretty_print(params, 'stoploss', "Stoploss:", non_optimized) HyperoptTools._params_pretty_print(params, 'trailing', "Trailing stop:", non_optimized)
[ "def", "show_epoch_details", "(", "results", ",", "total_epochs", ":", "int", ",", "print_json", ":", "bool", ",", "no_header", ":", "bool", "=", "False", ",", "header_str", ":", "str", "=", "None", ")", "->", "None", ":", "params", "=", "results", ".", ...
https://github.com/freqtrade/freqtrade/blob/13651fd3be8d5ce8dcd7c94b920bda4e00b75aca/freqtrade/optimize/hyperopt_tools.py#L160-L191
praw-dev/praw
d1280b132f509ad115f3941fb55f13f979068377
praw/models/inbox.py
python
Inbox.collapse
(self, items: List["praw.models.Message"])
Mark an inbox message as collapsed. :param items: A list containing instances of :class:`.Message`. Requests are batched at 25 items (reddit limit). For example, to collapse all unread Messages, try: .. code-block:: python from praw.models import Message unread_messages = [] for item in reddit.inbox.unread(limit=None): if isinstance(item, Message): unread_messages.append(item) reddit.inbox.collapse(unread_messages) .. seealso:: :meth:`.Message.uncollapse`
Mark an inbox message as collapsed.
[ "Mark", "an", "inbox", "message", "as", "collapsed", "." ]
def collapse(self, items: List["praw.models.Message"]): """Mark an inbox message as collapsed. :param items: A list containing instances of :class:`.Message`. Requests are batched at 25 items (reddit limit). For example, to collapse all unread Messages, try: .. code-block:: python from praw.models import Message unread_messages = [] for item in reddit.inbox.unread(limit=None): if isinstance(item, Message): unread_messages.append(item) reddit.inbox.collapse(unread_messages) .. seealso:: :meth:`.Message.uncollapse` """ while items: data = {"id": ",".join(x.fullname for x in items[:25])} self._reddit.post(API_PATH["collapse"], data=data) items = items[25:]
[ "def", "collapse", "(", "self", ",", "items", ":", "List", "[", "\"praw.models.Message\"", "]", ")", ":", "while", "items", ":", "data", "=", "{", "\"id\"", ":", "\",\"", ".", "join", "(", "x", ".", "fullname", "for", "x", "in", "items", "[", ":", ...
https://github.com/praw-dev/praw/blob/d1280b132f509ad115f3941fb55f13f979068377/praw/models/inbox.py#L34-L61
bikalims/bika.lims
35e4bbdb5a3912cae0b5eb13e51097c8b0486349
bika/lims/api.py
python
get_review_status
(brain_or_object)
return get_workflow_status_of(brain_or_object, state_var="review_state")
Get the `review_state` of an object :param brain_or_object: A single catalog brain or content object :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain :returns: Value of the review_status variable :rtype: String
Get the `review_state` of an object
[ "Get", "the", "review_state", "of", "an", "object" ]
def get_review_status(brain_or_object): """Get the `review_state` of an object :param brain_or_object: A single catalog brain or content object :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain :returns: Value of the review_status variable :rtype: String """ if is_brain(brain_or_object): return brain_or_object.review_state return get_workflow_status_of(brain_or_object, state_var="review_state")
[ "def", "get_review_status", "(", "brain_or_object", ")", ":", "if", "is_brain", "(", "brain_or_object", ")", ":", "return", "brain_or_object", ".", "review_state", "return", "get_workflow_status_of", "(", "brain_or_object", ",", "state_var", "=", "\"review_state\"", "...
https://github.com/bikalims/bika.lims/blob/35e4bbdb5a3912cae0b5eb13e51097c8b0486349/bika/lims/api.py#L769-L779
SteveDoyle2/pyNastran
eda651ac2d4883d95a34951f8a002ff94f642a1a
pyNastran/op2/result_objects/op2_objects.py
python
BaseScalarObject.export_to_hdf5
(self, group, log: SimpleLogger)
exports the object to HDF5 format
exports the object to HDF5 format
[ "exports", "the", "object", "to", "HDF5", "format" ]
def export_to_hdf5(self, group, log: SimpleLogger) -> None: """exports the object to HDF5 format""" export_to_hdf5(self, group, log)
[ "def", "export_to_hdf5", "(", "self", ",", "group", ",", "log", ":", "SimpleLogger", ")", "->", "None", ":", "export_to_hdf5", "(", "self", ",", "group", ",", "log", ")" ]
https://github.com/SteveDoyle2/pyNastran/blob/eda651ac2d4883d95a34951f8a002ff94f642a1a/pyNastran/op2/result_objects/op2_objects.py#L109-L111
beetbox/beets
2fea53c34dd505ba391cb345424e0613901c8025
beets/dbcore/db.py
python
Database.transaction
(self)
return Transaction(self)
Get a :class:`Transaction` object for interacting directly with the underlying SQLite database.
Get a :class:`Transaction` object for interacting directly with the underlying SQLite database.
[ "Get", "a", ":", "class", ":", "Transaction", "object", "for", "interacting", "directly", "with", "the", "underlying", "SQLite", "database", "." ]
def transaction(self): """Get a :class:`Transaction` object for interacting directly with the underlying SQLite database. """ return Transaction(self)
[ "def", "transaction", "(", "self", ")", ":", "return", "Transaction", "(", "self", ")" ]
https://github.com/beetbox/beets/blob/2fea53c34dd505ba391cb345424e0613901c8025/beets/dbcore/db.py#L989-L993
prody/ProDy
b24bbf58aa8fffe463c8548ae50e3955910e5b7f
prody/dynamics/entropy.py
python
calcOverallNetEntropyTransfer
(model, turbo=False)
return overallNetEntropyTransfer
This function calculates the net entropy transfer for a whole structure with a given time constant tau based on GNM.
This function calculates the net entropy transfer for a whole structure with a given time constant tau based on GNM.
[ "This", "function", "calculates", "the", "net", "entropy", "transfer", "for", "a", "whole", "structure", "with", "a", "given", "time", "constant", "tau", "based", "on", "GNM", "." ]
def calcOverallNetEntropyTransfer(model, turbo=False): """This function calculates the net entropy transfer for a whole structure with a given time constant tau based on GNM. """ if not isinstance(model, NMA): raise TypeError('model must be a NMA instance') elif model.is3d(): raise TypeError('model must be a 1-dimensional NMA instance') linalg = importLA() n_atoms = model.numAtoms() n_modes = model.numModes() tau_max = 5.0 tau_step = 0.1 taus = np.arange(start=tau_step, stop=tau_max+1e-6, step=tau_step) taus = np.insert(taus,0,0.000001) numTaus = len(taus) netEntropyTransfer = np.zeros((numTaus,n_atoms,n_atoms)) if turbo: try: from joblib import Parallel, delayed import multiprocessing as mp except: LOGGER.report('joblib and multiprocessing is not imported. Running' + 'with sequential execution.') LOGGER.timeit('_ent_trans') n_cpu = mp.cpu_count() netEntropyTransfer = Parallel(n_jobs=n_cpu)(delayed(calcAllEntropyTransfer)(model,taus[i]) \ for i in range(numTaus)) netEntropyTransfer = np.asarray(netEntropyTransfer) else: LOGGER.timeit('_ent_trans') for i in range(len(taus)): netEntropyTransfer[i,:,:] = calcAllEntropyTransfer(model,taus[i]) LOGGER.report('Net Entropy Transfer calculation is completed in %.1fs.', '_ent_trans') overallNetEntropyTransfer = np.zeros((n_atoms,n_atoms)) LOGGER.timeit('_num_int') for i in range(n_atoms): for j in range(n_atoms): if i != j: overallNetEntropyTransfer[i,j] = np.trapz(netEntropyTransfer[:,i,j],taus) LOGGER.report('Numerical integration is completed in %.1fs.', '_num_int') return overallNetEntropyTransfer
[ "def", "calcOverallNetEntropyTransfer", "(", "model", ",", "turbo", "=", "False", ")", ":", "if", "not", "isinstance", "(", "model", ",", "NMA", ")", ":", "raise", "TypeError", "(", "'model must be a NMA instance'", ")", "elif", "model", ".", "is3d", "(", ")...
https://github.com/prody/ProDy/blob/b24bbf58aa8fffe463c8548ae50e3955910e5b7f/prody/dynamics/entropy.py#L101-L151
dask/dask
c2b962fec1ba45440fe928869dc64cfe9cc36506
dask/array/linalg.py
python
sfqr
(data, name=None)
return Q, R
Direct Short-and-Fat QR Currently, this is a quick hack for non-tall-and-skinny matrices which are one chunk tall and (unless they are one chunk wide) have chunks that are wider than they are tall Q [R_1 R_2 ...] = [A_1 A_2 ...] it computes the factorization Q R_1 = A_1, then computes the other R_k's in parallel. Parameters ---------- data: Array See Also -------- dask.array.linalg.qr Main user API that uses this function dask.array.linalg.tsqr Variant for tall-and-skinny case
Direct Short-and-Fat QR
[ "Direct", "Short", "-", "and", "-", "Fat", "QR" ]
def sfqr(data, name=None): """Direct Short-and-Fat QR Currently, this is a quick hack for non-tall-and-skinny matrices which are one chunk tall and (unless they are one chunk wide) have chunks that are wider than they are tall Q [R_1 R_2 ...] = [A_1 A_2 ...] it computes the factorization Q R_1 = A_1, then computes the other R_k's in parallel. Parameters ---------- data: Array See Also -------- dask.array.linalg.qr Main user API that uses this function dask.array.linalg.tsqr Variant for tall-and-skinny case """ nr, nc = len(data.chunks[0]), len(data.chunks[1]) cr, cc = data.chunks[0][0], data.chunks[1][0] if not ( (data.ndim == 2) and (nr == 1) # Is a matrix and ( # Has exactly one block row (cr <= cc) or (nc == 1) # Chunking dimension on rows is at least that on cols or... ) ): # ... only one block col raise ValueError( "Input must have the following properties:\n" " 1. Have two dimensions\n" " 2. Have only one row of blocks\n" " 3. Either one column of blocks or (first) chunk size on cols\n" " is at most that on rows (e.g.: for a 5x20 matrix,\n" " chunks=((5), (8,4,8)) is fine, but chunks=((5), (4,8,8)) is not;\n" " still, prefer something simple like chunks=(5,10) or chunks=5)\n\n" "Note: This function (sfqr) supports QR decomposition in the case\n" "of short-and-fat matrices (single row chunk/block; see qr)" ) prefix = name or "sfqr-" + tokenize(data) prefix += "_" m, n = data.shape qq, rr = np.linalg.qr(np.ones(shape=(1, 1), dtype=data.dtype)) layers = data.__dask_graph__().layers.copy() dependencies = data.__dask_graph__().dependencies.copy() # data = A = [A_1 A_rest] name_A_1 = prefix + "A_1" name_A_rest = prefix + "A_rest" layers[name_A_1] = {(name_A_1, 0, 0): (data.name, 0, 0)} dependencies[name_A_1] = set(data.__dask_layers__()) layers[name_A_rest] = { (name_A_rest, 0, idx): (data.name, 0, 1 + idx) for idx in range(nc - 1) } if len(layers[name_A_rest]) > 0: dependencies[name_A_rest] = set(data.__dask_layers__()) else: dependencies[name_A_rest] = set() # Q R_1 = A_1 name_Q_R1 = prefix + "Q_R_1" name_Q = prefix + "Q" name_R_1 = prefix + "R_1" layers[name_Q_R1] = {(name_Q_R1, 0, 0): (np.linalg.qr, (name_A_1, 0, 0))} dependencies[name_Q_R1] = {name_A_1} layers[name_Q] = {(name_Q, 0, 0): (operator.getitem, (name_Q_R1, 0, 0), 0)} dependencies[name_Q] = {name_Q_R1} layers[name_R_1] = {(name_R_1, 0, 0): (operator.getitem, (name_Q_R1, 0, 0), 1)} dependencies[name_R_1] = {name_Q_R1} graph = HighLevelGraph(layers, dependencies) Q_meta = meta_from_array(data, len((m, min(m, n))), dtype=qq.dtype) R_1_meta = meta_from_array(data, len((min(m, n), cc)), dtype=rr.dtype) Q = Array(graph, name_Q, shape=(m, min(m, n)), chunks=(m, min(m, n)), meta=Q_meta) R_1 = Array(graph, name_R_1, shape=(min(m, n), cc), chunks=(cr, cc), meta=R_1_meta) # R = [R_1 Q'A_rest] Rs = [R_1] if nc > 1: A_rest_meta = meta_from_array(data, len((min(m, n), n - cc)), dtype=rr.dtype) A_rest = Array( graph, name_A_rest, shape=(min(m, n), n - cc), chunks=(cr, data.chunks[1][1:]), meta=A_rest_meta, ) Rs.append(Q.T.dot(A_rest)) R = concatenate(Rs, axis=1) return Q, R
[ "def", "sfqr", "(", "data", ",", "name", "=", "None", ")", ":", "nr", ",", "nc", "=", "len", "(", "data", ".", "chunks", "[", "0", "]", ")", ",", "len", "(", "data", ".", "chunks", "[", "1", "]", ")", "cr", ",", "cc", "=", "data", ".", "c...
https://github.com/dask/dask/blob/c2b962fec1ba45440fe928869dc64cfe9cc36506/dask/array/linalg.py#L508-L613
Tautulli/Tautulli
2410eb33805aaac4bd1c5dad0f71e4f15afaf742
plexpy/plextv.py
python
PlexTV.get_pin
(self, pin='')
[]
def get_pin(self, pin=''): plextv_response = self.get_plextv_pin(pin=pin, output_format='xml') if plextv_response: try: xml_head = plextv_response.getElementsByTagName('pin') if xml_head: pin = {'id': xml_head[0].getAttribute('id'), 'code': xml_head[0].getAttribute('code'), 'token': xml_head[0].getAttribute('authToken') } return pin else: logger.warn("Tautulli PlexTV :: Could not get Plex authentication pin.") return None except Exception as e: logger.warn("Tautulli PlexTV :: Unable to parse XML for get_pin: %s." % e) return None else: return None
[ "def", "get_pin", "(", "self", ",", "pin", "=", "''", ")", ":", "plextv_response", "=", "self", ".", "get_plextv_pin", "(", "pin", "=", "pin", ",", "output_format", "=", "'xml'", ")", "if", "plextv_response", ":", "try", ":", "xml_head", "=", "plextv_res...
https://github.com/Tautulli/Tautulli/blob/2410eb33805aaac4bd1c5dad0f71e4f15afaf742/plexpy/plextv.py#L208-L230
gentoo/portage
e5be73709b1a42b40380fd336f9381452b01a723
repoman/lib/repoman/modules/scan/ebuild/ebuild.py
python
Ebuild.__init__
(self, **kwargs)
Class init @param qatracker: QATracker instance @param portdb: portdb instance @param repo_settings: repository settings instance @param vcs_settings: VCSSettings instance @param checks: checks dictionary
Class init
[ "Class", "init" ]
def __init__(self, **kwargs): """Class init @param qatracker: QATracker instance @param portdb: portdb instance @param repo_settings: repository settings instance @param vcs_settings: VCSSettings instance @param checks: checks dictionary """ super(Ebuild, self).__init__(**kwargs) self.qatracker = kwargs.get("qatracker") self.portdb = kwargs.get("portdb") self.repo_settings = kwargs.get("repo_settings") self.vcs_settings = kwargs.get("vcs_settings") self.checks = kwargs.get("checks") self.root_config = RootConfig( self.repo_settings.repoman_settings, self.repo_settings.trees[self.repo_settings.root], None, ) self.changed = None self.xpkg = None self.y_ebuild = None self.pkg = None self.metadata = None self.eapi = None self.inherited = None self.live_ebuild = None self.keywords = None self.pkgs = {}
[ "def", "__init__", "(", "self", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Ebuild", ",", "self", ")", ".", "__init__", "(", "*", "*", "kwargs", ")", "self", ".", "qatracker", "=", "kwargs", ".", "get", "(", "\"qatracker\"", ")", "self", ".",...
https://github.com/gentoo/portage/blob/e5be73709b1a42b40380fd336f9381452b01a723/repoman/lib/repoman/modules/scan/ebuild/ebuild.py#L23-L52
MDudek-ICS/TRISIS-TRITON-HATMAN
15a00af7fd1040f0430729d024427601f84886a1
decompiled_code/library/base64.py
python
decodestring
(s)
return binascii.a2b_base64(s)
Decode a string.
Decode a string.
[ "Decode", "a", "string", "." ]
def decodestring(s): """Decode a string.""" return binascii.a2b_base64(s)
[ "def", "decodestring", "(", "s", ")", ":", "return", "binascii", ".", "a2b_base64", "(", "s", ")" ]
https://github.com/MDudek-ICS/TRISIS-TRITON-HATMAN/blob/15a00af7fd1040f0430729d024427601f84886a1/decompiled_code/library/base64.py#L290-L292
cobbler/cobbler
eed8cdca3e970c8aa1d199e80b8c8f19b3f940cc
cobbler/items/system.py
python
NetworkInterface.mac_address
(self)
return self._mac_address
mac_address property. :getter: Returns the value for ``mac_address``. :setter: Sets the value for the property ``mac_address``. :return:
mac_address property.
[ "mac_address", "property", "." ]
def mac_address(self) -> str: """ mac_address property. :getter: Returns the value for ``mac_address``. :setter: Sets the value for the property ``mac_address``. :return: """ return self._mac_address
[ "def", "mac_address", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_mac_address" ]
https://github.com/cobbler/cobbler/blob/eed8cdca3e970c8aa1d199e80b8c8f19b3f940cc/cobbler/items/system.py#L290-L298
nodesign/weio
1d67d705a5c36a2e825ad13feab910b0aca9a2e8
openWrt/files/usr/lib/python2.7/site-packages/sockjs/tornado/session.py
python
Session.flush
(self)
Flush message queue if there's an active connection running
Flush message queue if there's an active connection running
[ "Flush", "message", "queue", "if", "there", "s", "an", "active", "connection", "running" ]
def flush(self): """Flush message queue if there's an active connection running""" self._pending_flush = False if self.handler is None or not self.handler.active or not self.send_queue: return self.handler.send_pack('a[%s]' % self.send_queue) self.send_queue = ''
[ "def", "flush", "(", "self", ")", ":", "self", ".", "_pending_flush", "=", "False", "if", "self", ".", "handler", "is", "None", "or", "not", "self", ".", "handler", ".", "active", "or", "not", "self", ".", "send_queue", ":", "return", "self", ".", "h...
https://github.com/nodesign/weio/blob/1d67d705a5c36a2e825ad13feab910b0aca9a2e8/openWrt/files/usr/lib/python2.7/site-packages/sockjs/tornado/session.py#L358-L366
carla-simulator/scenario_runner
f4d00d88eda4212a1e119515c96281a4be5c234e
srunner/scenarios/route_scenario.py
python
RouteScenario._update_ego_vehicle
(self)
return ego_vehicle
Set/Update the start position of the ego_vehicle
Set/Update the start position of the ego_vehicle
[ "Set", "/", "Update", "the", "start", "position", "of", "the", "ego_vehicle" ]
def _update_ego_vehicle(self): """ Set/Update the start position of the ego_vehicle """ # move ego to correct position elevate_transform = self.route[0][0] elevate_transform.location.z += 0.5 ego_vehicle = CarlaDataProvider.request_new_actor('vehicle.lincoln.mkz_2017', elevate_transform, rolename='hero') return ego_vehicle
[ "def", "_update_ego_vehicle", "(", "self", ")", ":", "# move ego to correct position", "elevate_transform", "=", "self", ".", "route", "[", "0", "]", "[", "0", "]", "elevate_transform", ".", "location", ".", "z", "+=", "0.5", "ego_vehicle", "=", "CarlaDataProvid...
https://github.com/carla-simulator/scenario_runner/blob/f4d00d88eda4212a1e119515c96281a4be5c234e/srunner/scenarios/route_scenario.py#L212-L224
MegviiDetection/video_analyst
f4d1bccb1c698961fed3cb70808f1177fab13bdd
videoanalyst/optim/optimizer/optimizer_impl/utils/lr_multiply.py
python
multiply_lr
(optimizer, lr_ratios, verbose=False)
return optimizer
apply learning rate ratio for per-layer adjustment
apply learning rate ratio for per-layer adjustment
[ "apply", "learning", "rate", "ratio", "for", "per", "-", "layer", "adjustment" ]
def multiply_lr(optimizer, lr_ratios, verbose=False): """ apply learning rate ratio for per-layer adjustment """ assert len(optimizer.param_groups) == len(lr_ratios) for ith, (param_group, lr_ratio) in enumerate(zip(optimizer.param_groups, lr_ratios)): param_group['lr'] *= lr_ratio if verbose: logger.info("%d params in param_group %d multiplied by ratio %.2g" % (len(param_group['params']), ith, lr_ratio)) return optimizer
[ "def", "multiply_lr", "(", "optimizer", ",", "lr_ratios", ",", "verbose", "=", "False", ")", ":", "assert", "len", "(", "optimizer", ".", "param_groups", ")", "==", "len", "(", "lr_ratios", ")", "for", "ith", ",", "(", "param_group", ",", "lr_ratio", ")"...
https://github.com/MegviiDetection/video_analyst/blob/f4d1bccb1c698961fed3cb70808f1177fab13bdd/videoanalyst/optim/optimizer/optimizer_impl/utils/lr_multiply.py#L93-L102