repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
TestInABox/stackInABox
stackinabox/stack.py
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L226-L268
def call(self, method, request, uri, headers): """Make a call into the thread's StackInABox instance. :param method: HTTP Method (e.g GET, POST) :param request: a Request object containing the request data :param uri: the URI of the request submitted with the method :param heade...
[ "def", "call", "(", "self", ",", "method", ",", "request", ",", "uri", ",", "headers", ")", ":", "logger", ".", "debug", "(", "'StackInABox({0}): Received call to {1} - {2}'", ".", "format", "(", "self", ".", "__id", ",", "method", ",", "uri", ")", ")", ...
Make a call into the thread's StackInABox instance. :param method: HTTP Method (e.g GET, POST) :param request: a Request object containing the request data :param uri: the URI of the request submitted with the method :param headers: the return headers in a Case-Insensitive dict ...
[ "Make", "a", "call", "into", "the", "thread", "s", "StackInABox", "instance", "." ]
python
train
inveniosoftware/invenio-accounts
invenio_accounts/context_processors/jwt.py
https://github.com/inveniosoftware/invenio-accounts/blob/b0d2f0739b00dbefea22ca15d7d374a1b4a63aec/invenio_accounts/context_processors/jwt.py#L17-L36
def jwt_proccessor(): """Context processor for jwt.""" def jwt(): """Context processor function to generate jwt.""" token = current_accounts.jwt_creation_factory() return Markup( render_template( current_app.config['ACCOUNTS_JWT_DOM_TOKEN_TEMPLATE'], ...
[ "def", "jwt_proccessor", "(", ")", ":", "def", "jwt", "(", ")", ":", "\"\"\"Context processor function to generate jwt.\"\"\"", "token", "=", "current_accounts", ".", "jwt_creation_factory", "(", ")", "return", "Markup", "(", "render_template", "(", "current_app", "."...
Context processor for jwt.
[ "Context", "processor", "for", "jwt", "." ]
python
train
HazyResearch/metal
metal/contrib/visualization/analysis.py
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/contrib/visualization/analysis.py#L10-L19
def view_label_matrix(L, colorbar=True): """Display an [n, m] matrix of labels""" L = L.todense() if sparse.issparse(L) else L plt.imshow(L, aspect="auto") plt.title("Label Matrix") if colorbar: labels = sorted(np.unique(np.asarray(L).reshape(-1, 1).squeeze())) boundaries = np.array(...
[ "def", "view_label_matrix", "(", "L", ",", "colorbar", "=", "True", ")", ":", "L", "=", "L", ".", "todense", "(", ")", "if", "sparse", ".", "issparse", "(", "L", ")", "else", "L", "plt", ".", "imshow", "(", "L", ",", "aspect", "=", "\"auto\"", ")...
Display an [n, m] matrix of labels
[ "Display", "an", "[", "n", "m", "]", "matrix", "of", "labels" ]
python
train
jsmits/django-logutils
django_logutils/middleware.py
https://github.com/jsmits/django-logutils/blob/e88f6e0a08c6f3df9e61f96cfb6cd79bc5ea8a88/django_logutils/middleware.py#L17-L46
def create_log_dict(request, response): """ Create a dictionary with logging data. """ remote_addr = request.META.get('REMOTE_ADDR') if remote_addr in getattr(settings, 'INTERNAL_IPS', []): remote_addr = request.META.get( 'HTTP_X_FORWARDED_FOR') or remote_addr user_email = "...
[ "def", "create_log_dict", "(", "request", ",", "response", ")", ":", "remote_addr", "=", "request", ".", "META", ".", "get", "(", "'REMOTE_ADDR'", ")", "if", "remote_addr", "in", "getattr", "(", "settings", ",", "'INTERNAL_IPS'", ",", "[", "]", ")", ":", ...
Create a dictionary with logging data.
[ "Create", "a", "dictionary", "with", "logging", "data", "." ]
python
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L543-L550
def set_simple_fault_geometry_3D(w, src): """ Builds a 3D polygon from a node instance """ assert "simpleFaultSource" in src.tag geometry_node = src.nodes[get_taglist(src).index("simpleFaultGeometry")] fault_attrs = parse_simple_fault_geometry(geometry_node) build_polygon_from_fault_attrs(w,...
[ "def", "set_simple_fault_geometry_3D", "(", "w", ",", "src", ")", ":", "assert", "\"simpleFaultSource\"", "in", "src", ".", "tag", "geometry_node", "=", "src", ".", "nodes", "[", "get_taglist", "(", "src", ")", ".", "index", "(", "\"simpleFaultGeometry\"", ")"...
Builds a 3D polygon from a node instance
[ "Builds", "a", "3D", "polygon", "from", "a", "node", "instance" ]
python
train
mitsei/dlkit
dlkit/json_/repository/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/managers.py#L743-L758
def get_asset_repository_assignment_session(self): """Gets the session for assigning asset to repository mappings. return: (osid.repository.AssetRepositoryAssignmentSession) - an ``AssetRepositoryAsignmentSession`` raise: OperationFailed - unable to complete request rai...
[ "def", "get_asset_repository_assignment_session", "(", "self", ")", ":", "if", "not", "self", ".", "supports_asset_repository_assignment", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "# pylint: disable=no-member", "return", "sessions", ".", "Asse...
Gets the session for assigning asset to repository mappings. return: (osid.repository.AssetRepositoryAssignmentSession) - an ``AssetRepositoryAsignmentSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_asset_reposito...
[ "Gets", "the", "session", "for", "assigning", "asset", "to", "repository", "mappings", "." ]
python
train
ssato/python-anyconfig
src/anyconfig/schema.py
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/schema.py#L65-L81
def _validate(data, schema, ac_schema_safe=True, **options): """ See the descritpion of :func:`validate` for more details of parameters and return value. Validate target object 'data' with given schema object. """ try: jsonschema.validate(data, schema, **options) except (jsonschema...
[ "def", "_validate", "(", "data", ",", "schema", ",", "ac_schema_safe", "=", "True", ",", "*", "*", "options", ")", ":", "try", ":", "jsonschema", ".", "validate", "(", "data", ",", "schema", ",", "*", "*", "options", ")", "except", "(", "jsonschema", ...
See the descritpion of :func:`validate` for more details of parameters and return value. Validate target object 'data' with given schema object.
[ "See", "the", "descritpion", "of", ":", "func", ":", "validate", "for", "more", "details", "of", "parameters", "and", "return", "value", "." ]
python
train
Nic30/hwt
hwt/serializer/resourceAnalyzer/utils.py
https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/serializer/resourceAnalyzer/utils.py#L39-L52
def registerMUX(self, stm: Union[HdlStatement, Operator], sig: RtlSignal, inputs_cnt: int): """ mux record is in format (self.MUX, n, m) where n is number of bits of this mux and m is number of possible inputs """ assert inputs_cnt > 1 res = se...
[ "def", "registerMUX", "(", "self", ",", "stm", ":", "Union", "[", "HdlStatement", ",", "Operator", "]", ",", "sig", ":", "RtlSignal", ",", "inputs_cnt", ":", "int", ")", ":", "assert", "inputs_cnt", ">", "1", "res", "=", "self", ".", "resources", "w", ...
mux record is in format (self.MUX, n, m) where n is number of bits of this mux and m is number of possible inputs
[ "mux", "record", "is", "in", "format", "(", "self", ".", "MUX", "n", "m", ")", "where", "n", "is", "number", "of", "bits", "of", "this", "mux", "and", "m", "is", "number", "of", "possible", "inputs" ]
python
test
python-openxml/python-docx
docx/oxml/shape.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/shape.py#L61-L75
def new(cls, cx, cy, shape_id, pic): """ Return a new ``<wp:inline>`` element populated with the values passed as parameters. """ inline = parse_xml(cls._inline_xml()) inline.extent.cx = cx inline.extent.cy = cy inline.docPr.id = shape_id inline.do...
[ "def", "new", "(", "cls", ",", "cx", ",", "cy", ",", "shape_id", ",", "pic", ")", ":", "inline", "=", "parse_xml", "(", "cls", ".", "_inline_xml", "(", ")", ")", "inline", ".", "extent", ".", "cx", "=", "cx", "inline", ".", "extent", ".", "cy", ...
Return a new ``<wp:inline>`` element populated with the values passed as parameters.
[ "Return", "a", "new", "<wp", ":", "inline", ">", "element", "populated", "with", "the", "values", "passed", "as", "parameters", "." ]
python
train
pallets/werkzeug
examples/plnt/utils.py
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/examples/plnt/utils.py#L76-L80
def render_template(template_name, **context): """Render a template into a response.""" tmpl = jinja_env.get_template(template_name) context["url_for"] = url_for return Response(tmpl.render(context), mimetype="text/html")
[ "def", "render_template", "(", "template_name", ",", "*", "*", "context", ")", ":", "tmpl", "=", "jinja_env", ".", "get_template", "(", "template_name", ")", "context", "[", "\"url_for\"", "]", "=", "url_for", "return", "Response", "(", "tmpl", ".", "render"...
Render a template into a response.
[ "Render", "a", "template", "into", "a", "response", "." ]
python
train
leancloud/python-sdk
leancloud/query.py
https://github.com/leancloud/python-sdk/blob/fea3240257ce65e6a32c7312a5cee1f94a51a587/leancloud/query.py#L424-L444
def matched(self, key, regex, ignore_case=False, multi_line=False): """ 增加查询条件,限制查询结果对象指定字段满足指定的正则表达式。 :param key: 查询条件字段名 :param regex: 查询正则表达式 :param ignore_case: 查询是否忽略大小写,默认不忽略 :param multi_line: 查询是否匹配多行,默认不匹配 :rtype: Query """ if not isinsta...
[ "def", "matched", "(", "self", ",", "key", ",", "regex", ",", "ignore_case", "=", "False", ",", "multi_line", "=", "False", ")", ":", "if", "not", "isinstance", "(", "regex", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "'match...
增加查询条件,限制查询结果对象指定字段满足指定的正则表达式。 :param key: 查询条件字段名 :param regex: 查询正则表达式 :param ignore_case: 查询是否忽略大小写,默认不忽略 :param multi_line: 查询是否匹配多行,默认不匹配 :rtype: Query
[ "增加查询条件,限制查询结果对象指定字段满足指定的正则表达式。" ]
python
train
secdev/scapy
scapy/contrib/pnio.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio.py#L74-L96
def s2i_frameid(x): """ Get pnio frame ID from a representation name Performs a reverse look-up in PNIO_FRAME_IDS dictionary :param x: a value of PNIO_FRAME_IDS dict :returns: integer """ try: return { "RT_CLASS_3": 0x0100, "RT_CLASS_1": 0x8000, "RT_...
[ "def", "s2i_frameid", "(", "x", ")", ":", "try", ":", "return", "{", "\"RT_CLASS_3\"", ":", "0x0100", ",", "\"RT_CLASS_1\"", ":", "0x8000", ",", "\"RT_CLASS_UDP\"", ":", "0xC000", ",", "\"FragmentationFrameID\"", ":", "0xFF80", ",", "}", "[", "x", "]", "ex...
Get pnio frame ID from a representation name Performs a reverse look-up in PNIO_FRAME_IDS dictionary :param x: a value of PNIO_FRAME_IDS dict :returns: integer
[ "Get", "pnio", "frame", "ID", "from", "a", "representation", "name" ]
python
train
graphql-python/graphql-core-next
graphql/language/parser.py
https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/language/parser.py#L161-L171
def parse_definition(lexer: Lexer) -> DefinitionNode: """Definition: ExecutableDefinition or TypeSystemDefinition""" if peek(lexer, TokenKind.NAME): func = _parse_definition_functions.get(cast(str, lexer.token.value)) if func: return func(lexer) elif peek(lexer, TokenKind.BRACE_L...
[ "def", "parse_definition", "(", "lexer", ":", "Lexer", ")", "->", "DefinitionNode", ":", "if", "peek", "(", "lexer", ",", "TokenKind", ".", "NAME", ")", ":", "func", "=", "_parse_definition_functions", ".", "get", "(", "cast", "(", "str", ",", "lexer", "...
Definition: ExecutableDefinition or TypeSystemDefinition
[ "Definition", ":", "ExecutableDefinition", "or", "TypeSystemDefinition" ]
python
train
pandas-dev/pandas
pandas/plotting/_misc.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_misc.py#L566-L593
def lag_plot(series, lag=1, ax=None, **kwds): """Lag plot for time series. Parameters ---------- series : Time series lag : lag of the scatter plot, default 1 ax : Matplotlib axis object, optional kwds : Matplotlib scatter method keyword arguments, optional Returns ------- clas...
[ "def", "lag_plot", "(", "series", ",", "lag", "=", "1", ",", "ax", "=", "None", ",", "*", "*", "kwds", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "# workaround because `c='b'` is hardcoded in matplotlibs scatter method", "kwds", ".", "setdefau...
Lag plot for time series. Parameters ---------- series : Time series lag : lag of the scatter plot, default 1 ax : Matplotlib axis object, optional kwds : Matplotlib scatter method keyword arguments, optional Returns ------- class:`matplotlib.axis.Axes`
[ "Lag", "plot", "for", "time", "series", "." ]
python
train
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwx.py
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwx.py#L175-L228
def pick_keys(self, keys, use="", alg=""): """ The assumption is that upper layer has made certain you only get keys you can use. :param alg: The crypto algorithm :param use: What the key should be used for :param keys: A list of JWK instances :return: A list of ...
[ "def", "pick_keys", "(", "self", ",", "keys", ",", "use", "=", "\"\"", ",", "alg", "=", "\"\"", ")", ":", "if", "not", "alg", ":", "alg", "=", "self", "[", "\"alg\"", "]", "if", "alg", "==", "\"none\"", ":", "return", "[", "]", "_k", "=", "self...
The assumption is that upper layer has made certain you only get keys you can use. :param alg: The crypto algorithm :param use: What the key should be used for :param keys: A list of JWK instances :return: A list of JWK instances that fulfill the requirements
[ "The", "assumption", "is", "that", "upper", "layer", "has", "made", "certain", "you", "only", "get", "keys", "you", "can", "use", "." ]
python
train
quiltdata/quilt
compiler/quilt/tools/build.py
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/build.py#L599-L612
def generate_build_file(startpath, outfilename=DEFAULT_BUILDFILE): """ Generate a build file (yaml) based on the contents of a directory tree. """ buildfilepath = os.path.join(startpath, outfilename) if os.path.exists(buildfilepath): raise BuildException("Build file %s already exists." %...
[ "def", "generate_build_file", "(", "startpath", ",", "outfilename", "=", "DEFAULT_BUILDFILE", ")", ":", "buildfilepath", "=", "os", ".", "path", ".", "join", "(", "startpath", ",", "outfilename", ")", "if", "os", ".", "path", ".", "exists", "(", "buildfilepa...
Generate a build file (yaml) based on the contents of a directory tree.
[ "Generate", "a", "build", "file", "(", "yaml", ")", "based", "on", "the", "contents", "of", "a", "directory", "tree", "." ]
python
train
log2timeline/dfvfs
dfvfs/vfs/apfs_file_system.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/apfs_file_system.py#L180-L189
def GetRootFileEntry(self): """Retrieves the root file entry. Returns: APFSFileEntry: file entry. """ path_spec = apfs_path_spec.APFSPathSpec( location=self.LOCATION_ROOT, identifier=self.ROOT_DIRECTORY_IDENTIFIER, parent=self._path_spec.parent) return self.GetFileEntryByPathS...
[ "def", "GetRootFileEntry", "(", "self", ")", ":", "path_spec", "=", "apfs_path_spec", ".", "APFSPathSpec", "(", "location", "=", "self", ".", "LOCATION_ROOT", ",", "identifier", "=", "self", ".", "ROOT_DIRECTORY_IDENTIFIER", ",", "parent", "=", "self", ".", "_...
Retrieves the root file entry. Returns: APFSFileEntry: file entry.
[ "Retrieves", "the", "root", "file", "entry", "." ]
python
train
PmagPy/PmagPy
pmagpy/pmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L5647-L5672
def doseigs(s): """ convert s format for eigenvalues and eigenvectors Parameters __________ s=[x11,x22,x33,x12,x23,x13] : the six tensor elements Return __________ tau : [t1,t2,t3] tau is an list of eigenvalues in decreasing order: V : [[V1_dec,V1_inc],[V2_dec,V2...
[ "def", "doseigs", "(", "s", ")", ":", "#", "A", "=", "s2a", "(", "s", ")", "# convert s to a (see Tauxe 1998)", "tau", ",", "V", "=", "tauV", "(", "A", ")", "# convert to eigenvalues (t), eigenvectors (V)", "Vdirs", "=", "[", "]", "for", "v", "in", "V", ...
convert s format for eigenvalues and eigenvectors Parameters __________ s=[x11,x22,x33,x12,x23,x13] : the six tensor elements Return __________ tau : [t1,t2,t3] tau is an list of eigenvalues in decreasing order: V : [[V1_dec,V1_inc],[V2_dec,V2_inc],[V3_dec,V3_inc]] ...
[ "convert", "s", "format", "for", "eigenvalues", "and", "eigenvectors" ]
python
train
pybel/pybel-tools
src/pybel_tools/utils.py
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L75-L83
def tanimoto_set_similarity(x: Iterable[X], y: Iterable[X]) -> float: """Calculate the tanimoto set similarity.""" a, b = set(x), set(y) union = a | b if not union: return 0.0 return len(a & b) / len(union)
[ "def", "tanimoto_set_similarity", "(", "x", ":", "Iterable", "[", "X", "]", ",", "y", ":", "Iterable", "[", "X", "]", ")", "->", "float", ":", "a", ",", "b", "=", "set", "(", "x", ")", ",", "set", "(", "y", ")", "union", "=", "a", "|", "b", ...
Calculate the tanimoto set similarity.
[ "Calculate", "the", "tanimoto", "set", "similarity", "." ]
python
valid
sepandhaghighi/pycm
pycm/pycm_overall_func.py
https://github.com/sepandhaghighi/pycm/blob/cb03258afd6a821d10acba73c965aaac174bedcd/pycm/pycm_overall_func.py#L327-L349
def cross_entropy_calc(TOP, P, POP): """ Calculate cross entropy. :param TOP: test outcome positive :type TOP : dict :param P: condition positive :type P : dict :param POP: population :type POP : dict :return: cross entropy as float """ try: result = 0 for i ...
[ "def", "cross_entropy_calc", "(", "TOP", ",", "P", ",", "POP", ")", ":", "try", ":", "result", "=", "0", "for", "i", "in", "TOP", ".", "keys", "(", ")", ":", "reference_likelihood", "=", "P", "[", "i", "]", "/", "POP", "[", "i", "]", "response_li...
Calculate cross entropy. :param TOP: test outcome positive :type TOP : dict :param P: condition positive :type P : dict :param POP: population :type POP : dict :return: cross entropy as float
[ "Calculate", "cross", "entropy", "." ]
python
train
Nic30/hwt
hwt/simulator/hdlSimulator.py
https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/simulator/hdlSimulator.py#L434-L443
def read(self, sig) -> Value: """ Read value from signal or interface """ try: v = sig._val except AttributeError: v = sig._sigInside._val return v.clone()
[ "def", "read", "(", "self", ",", "sig", ")", "->", "Value", ":", "try", ":", "v", "=", "sig", ".", "_val", "except", "AttributeError", ":", "v", "=", "sig", ".", "_sigInside", ".", "_val", "return", "v", ".", "clone", "(", ")" ]
Read value from signal or interface
[ "Read", "value", "from", "signal", "or", "interface" ]
python
test
cloud-custodian/cloud-custodian
tools/c7n_azure/c7n_azure/tags.py
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_azure/c7n_azure/tags.py#L99-L108
def get_tag_value(resource, tag, utf_8=False): """Get the resource's tag value.""" tags = {k.lower(): v for k, v in resource.get('tags', {}).items()} value = tags.get(tag, False) if value is not False: if utf_8: value = value.encode('utf8').decode('u...
[ "def", "get_tag_value", "(", "resource", ",", "tag", ",", "utf_8", "=", "False", ")", ":", "tags", "=", "{", "k", ".", "lower", "(", ")", ":", "v", "for", "k", ",", "v", "in", "resource", ".", "get", "(", "'tags'", ",", "{", "}", ")", ".", "i...
Get the resource's tag value.
[ "Get", "the", "resource", "s", "tag", "value", "." ]
python
train
Kortemme-Lab/klab
klab/benchmarking/analysis/ssm.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/benchmarking/analysis/ssm.py#L482-L500
def get_std_xy_dataset_statistics(x_values, y_values, expect_negative_correlation = False, STDev_cutoff = 1.0): '''Calls parse_csv and returns the analysis in a format similar to get_xy_dataset_statistics in klab.stats.misc.''' assert(len(x_values) == len(y_values)) csv_lines = ['ID,X,Y'] + [','.join(map(st...
[ "def", "get_std_xy_dataset_statistics", "(", "x_values", ",", "y_values", ",", "expect_negative_correlation", "=", "False", ",", "STDev_cutoff", "=", "1.0", ")", ":", "assert", "(", "len", "(", "x_values", ")", "==", "len", "(", "y_values", ")", ")", "csv_line...
Calls parse_csv and returns the analysis in a format similar to get_xy_dataset_statistics in klab.stats.misc.
[ "Calls", "parse_csv", "and", "returns", "the", "analysis", "in", "a", "format", "similar", "to", "get_xy_dataset_statistics", "in", "klab", ".", "stats", ".", "misc", "." ]
python
train
materialsproject/pymatgen
pymatgen/alchemy/transmuters.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/alchemy/transmuters.py#L206-L222
def append_transformed_structures(self, tstructs_or_transmuter): """ Method is overloaded to accept either a list of transformed structures or transmuter, it which case it appends the second transmuter"s structures. Args: tstructs_or_transmuter: A list of transformed...
[ "def", "append_transformed_structures", "(", "self", ",", "tstructs_or_transmuter", ")", ":", "if", "isinstance", "(", "tstructs_or_transmuter", ",", "self", ".", "__class__", ")", ":", "self", ".", "transformed_structures", ".", "extend", "(", "tstructs_or_transmuter...
Method is overloaded to accept either a list of transformed structures or transmuter, it which case it appends the second transmuter"s structures. Args: tstructs_or_transmuter: A list of transformed structures or a transmuter.
[ "Method", "is", "overloaded", "to", "accept", "either", "a", "list", "of", "transformed", "structures", "or", "transmuter", "it", "which", "case", "it", "appends", "the", "second", "transmuter", "s", "structures", "." ]
python
train
kubernetes-client/python
kubernetes/client/apis/certificates_v1beta1_api.py
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/certificates_v1beta1_api.py#L942-L962
def read_certificate_signing_request_status(self, name, **kwargs): """ read status of the specified CertificateSigningRequest This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.read_certificat...
[ "def", "read_certificate_signing_request_status", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "read...
read status of the specified CertificateSigningRequest This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.read_certificate_signing_request_status(name, async_req=True) >>> result = thread.get() ...
[ "read", "status", "of", "the", "specified", "CertificateSigningRequest", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "pass", "async_req", "=", "True", ">...
python
train
pyvisa/pyvisa
pyvisa/thirdparty/prettytable.py
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/thirdparty/prettytable.py#L1430-L1438
def from_html(html_code, **kwargs): """ Generates a list of PrettyTables from a string of HTML code. Each <table> in the HTML becomes one PrettyTable object. """ parser = TableHandler(**kwargs) parser.feed(html_code) return parser.tables
[ "def", "from_html", "(", "html_code", ",", "*", "*", "kwargs", ")", ":", "parser", "=", "TableHandler", "(", "*", "*", "kwargs", ")", "parser", ".", "feed", "(", "html_code", ")", "return", "parser", ".", "tables" ]
Generates a list of PrettyTables from a string of HTML code. Each <table> in the HTML becomes one PrettyTable object.
[ "Generates", "a", "list", "of", "PrettyTables", "from", "a", "string", "of", "HTML", "code", ".", "Each", "<table", ">", "in", "the", "HTML", "becomes", "one", "PrettyTable", "object", "." ]
python
train
textX/textX
textx/scoping/__init__.py
https://github.com/textX/textX/blob/5796ac38116ad86584392dbecdbf923ede746361/textx/scoping/__init__.py#L255-L270
def pre_ref_resolution_callback(self, other_model): """ (internal: used to store a model after parsing into the repository) Args: other_model: the parsed model Returns: nothing """ # print("PRE-CALLBACK{}".format(filename)) filename = oth...
[ "def", "pre_ref_resolution_callback", "(", "self", ",", "other_model", ")", ":", "# print(\"PRE-CALLBACK{}\".format(filename))", "filename", "=", "other_model", ".", "_tx_filename", "assert", "(", "filename", ")", "other_model", ".", "_tx_model_repository", "=", "GlobalMo...
(internal: used to store a model after parsing into the repository) Args: other_model: the parsed model Returns: nothing
[ "(", "internal", ":", "used", "to", "store", "a", "model", "after", "parsing", "into", "the", "repository", ")" ]
python
train
jobovy/galpy
galpy/potential/FerrersPotential.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/FerrersPotential.py#L170-L187
def _zforce(self,R,z,phi=0.,t=0.): """ NAME: _zforce PURPOSE: evaluate the vertical force for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: ...
[ "def", "_zforce", "(", "self", ",", "R", ",", "z", ",", "phi", "=", "0.", ",", "t", "=", "0.", ")", ":", "if", "not", "self", ".", "isNonAxi", ":", "phi", "=", "0.", "self", ".", "_compute_xyzforces", "(", "R", ",", "z", ",", "phi", ",", "t",...
NAME: _zforce PURPOSE: evaluate the vertical force for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: the vertical force
[ "NAME", ":", "_zforce", "PURPOSE", ":", "evaluate", "the", "vertical", "force", "for", "this", "potential", "INPUT", ":", "R", "-", "Galactocentric", "cylindrical", "radius", "z", "-", "vertical", "height", "phi", "-", "azimuth", "t", "-", "time", "OUTPUT", ...
python
train
coleifer/django-relationships
relationships/models.py
https://github.com/coleifer/django-relationships/blob/f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805/relationships/models.py#L112-L130
def remove(self, user, status=None, symmetrical=False): """ Remove a relationship from one user to another, with the same caveats and behavior as adding a relationship. """ if not status: status = RelationshipStatus.objects.following() res = Relationship.obje...
[ "def", "remove", "(", "self", ",", "user", ",", "status", "=", "None", ",", "symmetrical", "=", "False", ")", ":", "if", "not", "status", ":", "status", "=", "RelationshipStatus", ".", "objects", ".", "following", "(", ")", "res", "=", "Relationship", ...
Remove a relationship from one user to another, with the same caveats and behavior as adding a relationship.
[ "Remove", "a", "relationship", "from", "one", "user", "to", "another", "with", "the", "same", "caveats", "and", "behavior", "as", "adding", "a", "relationship", "." ]
python
train
rochacbruno/flasgger
examples/custom_validation_function.py
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/examples/custom_validation_function.py#L17-L24
def drop_id_validate(data, schema): """ Custom validation function which drops parameter '_id' if present in data """ jsonschema.validate(data, schema) if data.get('_id') is not None: del data['_id']
[ "def", "drop_id_validate", "(", "data", ",", "schema", ")", ":", "jsonschema", ".", "validate", "(", "data", ",", "schema", ")", "if", "data", ".", "get", "(", "'_id'", ")", "is", "not", "None", ":", "del", "data", "[", "'_id'", "]" ]
Custom validation function which drops parameter '_id' if present in data
[ "Custom", "validation", "function", "which", "drops", "parameter", "_id", "if", "present", "in", "data" ]
python
train
manrajgrover/halo
halo/_utils.py
https://github.com/manrajgrover/halo/blob/0ac5149dea965b27b09f0776df9095ebf013fb4d/halo/_utils.py#L80-L96
def is_text_type(text): """Check if given parameter is a string or not Parameters ---------- text : * Parameter to be checked for text type Returns ------- bool Whether parameter is a string or not """ if isinstance(text, six.text_type) or isinstance(text, six.strin...
[ "def", "is_text_type", "(", "text", ")", ":", "if", "isinstance", "(", "text", ",", "six", ".", "text_type", ")", "or", "isinstance", "(", "text", ",", "six", ".", "string_types", ")", ":", "return", "True", "return", "False" ]
Check if given parameter is a string or not Parameters ---------- text : * Parameter to be checked for text type Returns ------- bool Whether parameter is a string or not
[ "Check", "if", "given", "parameter", "is", "a", "string", "or", "not" ]
python
train
nfcpy/nfcpy
src/nfc/tag/tt2.py
https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt2.py#L496-L520
def write(self, page, data): """Send a WRITE command to store data on the tag. The *page* argument specifies the offset in multiples of 4 bytes. The *data* argument must be a string or bytearray of length 4. Command execution errors raise :exc:`Type2TagCommandError`. "...
[ "def", "write", "(", "self", ",", "page", ",", "data", ")", ":", "if", "len", "(", "data", ")", "!=", "4", ":", "raise", "ValueError", "(", "\"data must be a four byte string or array\"", ")", "log", ".", "debug", "(", "\"write {0} to page {1}\"", ".", "form...
Send a WRITE command to store data on the tag. The *page* argument specifies the offset in multiples of 4 bytes. The *data* argument must be a string or bytearray of length 4. Command execution errors raise :exc:`Type2TagCommandError`.
[ "Send", "a", "WRITE", "command", "to", "store", "data", "on", "the", "tag", "." ]
python
train
aliyun/aliyun-log-python-sdk
aliyun/log/pluralize.py
https://github.com/aliyun/aliyun-log-python-sdk/blob/ac383db0a16abf1e5ef7df36074374184b43516e/aliyun/log/pluralize.py#L37-L94
def pluralize(singular): """Return plural form of given lowercase singular word (English only). Based on ActiveState recipe http://code.activestate.com/recipes/413172/ >>> pluralize('') '' >>> pluralize('goose') 'geese' >>> pluralize('dolly') 'dollies' >>> pluralize('genius') 'g...
[ "def", "pluralize", "(", "singular", ")", ":", "if", "not", "singular", ":", "return", "''", "plural", "=", "ABERRANT_PLURAL_MAP", ".", "get", "(", "singular", ")", "if", "plural", ":", "return", "plural", "root", "=", "singular", "try", ":", "if", "sing...
Return plural form of given lowercase singular word (English only). Based on ActiveState recipe http://code.activestate.com/recipes/413172/ >>> pluralize('') '' >>> pluralize('goose') 'geese' >>> pluralize('dolly') 'dollies' >>> pluralize('genius') 'genii' >>> pluralize('jones')...
[ "Return", "plural", "form", "of", "given", "lowercase", "singular", "word", "(", "English", "only", ")", ".", "Based", "on", "ActiveState", "recipe", "http", ":", "//", "code", ".", "activestate", ".", "com", "/", "recipes", "/", "413172", "/" ]
python
train
vtraag/leidenalg
setup.py
https://github.com/vtraag/leidenalg/blob/a9e15116973a81048edf02ef7cf800d54debe1cc/setup.py#L408-L415
def configure(self, ext): """Configures the given Extension object using this build configuration.""" ext.include_dirs += self.include_dirs ext.library_dirs += self.library_dirs ext.libraries += self.libraries ext.extra_compile_args += self.extra_compile_args ext.extra_li...
[ "def", "configure", "(", "self", ",", "ext", ")", ":", "ext", ".", "include_dirs", "+=", "self", ".", "include_dirs", "ext", ".", "library_dirs", "+=", "self", ".", "library_dirs", "ext", ".", "libraries", "+=", "self", ".", "libraries", "ext", ".", "ext...
Configures the given Extension object using this build configuration.
[ "Configures", "the", "given", "Extension", "object", "using", "this", "build", "configuration", "." ]
python
train
googleapis/google-cloud-python
datastore/google/cloud/datastore/transaction.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/datastore/google/cloud/datastore/transaction.py#L196-L212
def begin(self): """Begins a transaction. This method is called automatically when entering a with statement, however it can be called explicitly if you don't want to use a context manager. :raises: :class:`~exceptions.ValueError` if the transaction has already...
[ "def", "begin", "(", "self", ")", ":", "super", "(", "Transaction", ",", "self", ")", ".", "begin", "(", ")", "try", ":", "response_pb", "=", "self", ".", "_client", ".", "_datastore_api", ".", "begin_transaction", "(", "self", ".", "project", ")", "se...
Begins a transaction. This method is called automatically when entering a with statement, however it can be called explicitly if you don't want to use a context manager. :raises: :class:`~exceptions.ValueError` if the transaction has already begun.
[ "Begins", "a", "transaction", "." ]
python
train
AWegnerGitHub/smokeapi
smokeapi/smokeapi.py
https://github.com/AWegnerGitHub/smokeapi/blob/0ba786712e1f7377e5a83539a9ba8d5b3461b9c9/smokeapi/smokeapi.py#L186-L255
def send_data(self, endpoint=None, **kwargs): """Sends data to the API. This call is similar to ``fetch``, but **sends** data to the API instead of retrieving it. Returned data will appear in the ``items`` key of the resulting dictionary. Sending data **requires** tha...
[ "def", "send_data", "(", "self", ",", "endpoint", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "endpoint", ":", "raise", "ValueError", "(", "'No end point provided.'", ")", "if", "not", "self", ".", "token", ":", "raise", "ValueError", "(...
Sends data to the API. This call is similar to ``fetch``, but **sends** data to the API instead of retrieving it. Returned data will appear in the ``items`` key of the resulting dictionary. Sending data **requires** that the ``token`` is set. :param endpoint: (string)...
[ "Sends", "data", "to", "the", "API", "." ]
python
train
coinkite/connectrum
connectrum/svr_info.py
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/svr_info.py#L203-L211
def add_single(self, hostname, ports, nickname=None, **kws): ''' Explicitly add a single entry. Hostname is a FQDN and ports is either a single int (assumed to be TCP port) or Electrum protocol/port number specification with spaces in between. ''' nickname = n...
[ "def", "add_single", "(", "self", ",", "hostname", ",", "ports", ",", "nickname", "=", "None", ",", "*", "*", "kws", ")", ":", "nickname", "=", "nickname", "or", "hostname", "self", "[", "hostname", ".", "lower", "(", ")", "]", "=", "ServerInfo", "("...
Explicitly add a single entry. Hostname is a FQDN and ports is either a single int (assumed to be TCP port) or Electrum protocol/port number specification with spaces in between.
[ "Explicitly", "add", "a", "single", "entry", ".", "Hostname", "is", "a", "FQDN", "and", "ports", "is", "either", "a", "single", "int", "(", "assumed", "to", "be", "TCP", "port", ")", "or", "Electrum", "protocol", "/", "port", "number", "specification", "...
python
train
ph4r05/monero-serialize
monero_serialize/core/message_types.py
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/message_types.py#L153-L164
def container_elem_type(container_type, params): """ Returns container element type :param container_type: :param params: :return: """ elem_type = params[0] if params else None if elem_type is None: elem_type = container_type.ELEM_TYPE return elem_type
[ "def", "container_elem_type", "(", "container_type", ",", "params", ")", ":", "elem_type", "=", "params", "[", "0", "]", "if", "params", "else", "None", "if", "elem_type", "is", "None", ":", "elem_type", "=", "container_type", ".", "ELEM_TYPE", "return", "el...
Returns container element type :param container_type: :param params: :return:
[ "Returns", "container", "element", "type" ]
python
train
pantsbuild/pants
pants-plugins/src/python/internal_backend/utilities/register.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/pants-plugins/src/python/internal_backend/utilities/register.py#L122-L134
def notes_for_version(self, version): """Given the parsed Version of pants, return its release notes. TODO: This method should parse out the specific version from the resulting file: see https://github.com/pantsbuild/pants/issues/1708 """ branch_name = self._branch_name(version) branch_notes_...
[ "def", "notes_for_version", "(", "self", ",", "version", ")", ":", "branch_name", "=", "self", ".", "_branch_name", "(", "version", ")", "branch_notes_file", "=", "self", ".", "_branch_notes", ".", "get", "(", "branch_name", ",", "None", ")", "if", "branch_n...
Given the parsed Version of pants, return its release notes. TODO: This method should parse out the specific version from the resulting file: see https://github.com/pantsbuild/pants/issues/1708
[ "Given", "the", "parsed", "Version", "of", "pants", "return", "its", "release", "notes", "." ]
python
train
tensorflow/probability
tensorflow_probability/python/vi/csiszar_divergence.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/vi/csiszar_divergence.py#L712-L780
def symmetrized_csiszar_function(logu, csiszar_function, name=None): """Symmetrizes a Csiszar-function in log-space. A Csiszar-function is a member of, ```none F = { f:R_+ to R : f convex }. ``` The symmetrized Csiszar-function is defined as: ```none f_g(u) = 0.5 g(u) + 0.5 u g (1 / u) ``` wher...
[ "def", "symmetrized_csiszar_function", "(", "logu", ",", "csiszar_function", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "compat", ".", "v1", ".", "name_scope", "(", "name", ",", "\"symmetrized_csiszar_function\"", ",", "[", "logu", "]", ")", ":",...
Symmetrizes a Csiszar-function in log-space. A Csiszar-function is a member of, ```none F = { f:R_+ to R : f convex }. ``` The symmetrized Csiszar-function is defined as: ```none f_g(u) = 0.5 g(u) + 0.5 u g (1 / u) ``` where `g` is some other Csiszar-function. We say the function is "symmetriz...
[ "Symmetrizes", "a", "Csiszar", "-", "function", "in", "log", "-", "space", "." ]
python
test
blockstack/blockstack-core
blockstack/blockstackd.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1188-L1204
def rpc_get_names_owned_by_address(self, address, **con_info): """ Get the list of names owned by an address. Return {'status': True, 'names': ...} on success Return {'error': ...} on error """ if not check_address(address): return {'error': 'Invalid address',...
[ "def", "rpc_get_names_owned_by_address", "(", "self", ",", "address", ",", "*", "*", "con_info", ")", ":", "if", "not", "check_address", "(", "address", ")", ":", "return", "{", "'error'", ":", "'Invalid address'", ",", "'http_status'", ":", "400", "}", "db"...
Get the list of names owned by an address. Return {'status': True, 'names': ...} on success Return {'error': ...} on error
[ "Get", "the", "list", "of", "names", "owned", "by", "an", "address", ".", "Return", "{", "status", ":", "True", "names", ":", "...", "}", "on", "success", "Return", "{", "error", ":", "...", "}", "on", "error" ]
python
train
tensorpack/tensorpack
examples/GAN/GAN.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/examples/GAN/GAN.py#L27-L62
def build_losses(self, logits_real, logits_fake): """ Build standard GAN loss and set `self.g_loss` and `self.d_loss`. D and G play two-player minimax game with value function V(G,D) min_G max _D V(D, G) = IE_{x ~ p_data} [log D(x)] + IE_{z ~ p_fake} [log (1 - D(G(z)))] Args...
[ "def", "build_losses", "(", "self", ",", "logits_real", ",", "logits_fake", ")", ":", "with", "tf", ".", "name_scope", "(", "\"GAN_loss\"", ")", ":", "score_real", "=", "tf", ".", "sigmoid", "(", "logits_real", ")", "score_fake", "=", "tf", ".", "sigmoid",...
Build standard GAN loss and set `self.g_loss` and `self.d_loss`. D and G play two-player minimax game with value function V(G,D) min_G max _D V(D, G) = IE_{x ~ p_data} [log D(x)] + IE_{z ~ p_fake} [log (1 - D(G(z)))] Args: logits_real (tf.Tensor): discrim logits from real sample...
[ "Build", "standard", "GAN", "loss", "and", "set", "self", ".", "g_loss", "and", "self", ".", "d_loss", "." ]
python
train
omtinez/pddb
pddb/pddb.py
https://github.com/omtinez/pddb/blob/a24cee0702c8286c5c466c51ca65cf8dbc2c183c/pddb/pddb.py#L160-L253
def load(self, table_names=None, table_schemas=None, table_rowgens=None): ''' Initiates the tables, schemas and record generators for this database. Parameters ---------- table_names : list of str, str or None List of tables to load into this database. If `auto_load`...
[ "def", "load", "(", "self", ",", "table_names", "=", "None", ",", "table_schemas", "=", "None", ",", "table_rowgens", "=", "None", ")", ":", "# Check for table schemas", "if", "table_schemas", "is", "not", "None", ":", "table_schemas", "=", "self", ".", "_ch...
Initiates the tables, schemas and record generators for this database. Parameters ---------- table_names : list of str, str or None List of tables to load into this database. If `auto_load` is true, inserting a record into a new table not provided here will automatically...
[ "Initiates", "the", "tables", "schemas", "and", "record", "generators", "for", "this", "database", "." ]
python
train
ccubed/PyMoe
Pymoe/Bakatsuki/__init__.py
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Bakatsuki/__init__.py#L26-L55
def active(self): """ Get a list of active projects. :return list: A list of tuples containing a title and pageid in that order. """ projects = [] r = requests.get(self.api, params={'action': 'query', 'list': 'categorymembers', 'cmpageid': self.a...
[ "def", "active", "(", "self", ")", ":", "projects", "=", "[", "]", "r", "=", "requests", ".", "get", "(", "self", ".", "api", ",", "params", "=", "{", "'action'", ":", "'query'", ",", "'list'", ":", "'categorymembers'", ",", "'cmpageid'", ":", "self"...
Get a list of active projects. :return list: A list of tuples containing a title and pageid in that order.
[ "Get", "a", "list", "of", "active", "projects", "." ]
python
train
lmjohns3/downhill
downhill/base.py
https://github.com/lmjohns3/downhill/blob/42111ab03b5e6fa47b7bf7c7cb5caa402f10ce6d/downhill/base.py#L261-L279
def _log(self, monitors, iteration, label='', suffix=''): '''Log the state of the optimizer on the console. Parameters ---------- monitors : OrderedDict A dictionary of monitor names mapped to values. These names and values are what is being logged. itera...
[ "def", "_log", "(", "self", ",", "monitors", ",", "iteration", ",", "label", "=", "''", ",", "suffix", "=", "''", ")", ":", "label", "=", "label", "or", "self", ".", "__class__", ".", "__name__", "fields", "=", "(", "(", "'{}={:.6f}'", ")", ".", "f...
Log the state of the optimizer on the console. Parameters ---------- monitors : OrderedDict A dictionary of monitor names mapped to values. These names and values are what is being logged. iteration : int Optimization iteration that we are logging. ...
[ "Log", "the", "state", "of", "the", "optimizer", "on", "the", "console", "." ]
python
train
materialsproject/pymatgen
pymatgen/io/babel.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/babel.py#L201-L221
def gen3d_conformer(self): """ A combined method to first generate 3D structures from 0D or 2D structures and then find the minimum energy conformer: 1. Use OBBuilder to create a 3D structure using rules and ring templates 2. Do 250 steps of a steepest descent geometry optimizati...
[ "def", "gen3d_conformer", "(", "self", ")", ":", "gen3d", "=", "ob", ".", "OBOp", ".", "FindType", "(", "\"Gen3D\"", ")", "gen3d", ".", "Do", "(", "self", ".", "_obmol", ")" ]
A combined method to first generate 3D structures from 0D or 2D structures and then find the minimum energy conformer: 1. Use OBBuilder to create a 3D structure using rules and ring templates 2. Do 250 steps of a steepest descent geometry optimization with the MMFF94 forcefield ...
[ "A", "combined", "method", "to", "first", "generate", "3D", "structures", "from", "0D", "or", "2D", "structures", "and", "then", "find", "the", "minimum", "energy", "conformer", ":", "1", ".", "Use", "OBBuilder", "to", "create", "a", "3D", "structure", "us...
python
train
fitnr/convertdate
convertdate/gregorian.py
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/gregorian.py#L43-L58
def to_jd2(year, month, day): '''Gregorian to Julian Day Count for years between 1801-2099''' # http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html legal_date(year, month, day) if month <= 2: year = year - 1 month = month + 12 a = floor(year / 100) b = floor(a / 4) c = ...
[ "def", "to_jd2", "(", "year", ",", "month", ",", "day", ")", ":", "# http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html", "legal_date", "(", "year", ",", "month", ",", "day", ")", "if", "month", "<=", "2", ":", "year", "=", "year", "-", "1", "month", "...
Gregorian to Julian Day Count for years between 1801-2099
[ "Gregorian", "to", "Julian", "Day", "Count", "for", "years", "between", "1801", "-", "2099" ]
python
train
ColtonProvias/sqlalchemy-jsonapi
sqlalchemy_jsonapi/serializer.py
https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L692-L713
def get_resource(self, session, query, api_type, obj_id): """ Fetch a resource. :param session: SQLAlchemy session :param query: Dict of query args :param api_type: Type of the resource :param obj_id: ID of the resource """ resource = self._fetch_resource...
[ "def", "get_resource", "(", "self", ",", "session", ",", "query", ",", "api_type", ",", "obj_id", ")", ":", "resource", "=", "self", ".", "_fetch_resource", "(", "session", ",", "api_type", ",", "obj_id", ",", "Permissions", ".", "VIEW", ")", "include", ...
Fetch a resource. :param session: SQLAlchemy session :param query: Dict of query args :param api_type: Type of the resource :param obj_id: ID of the resource
[ "Fetch", "a", "resource", "." ]
python
train
edx/edx-submissions
submissions/api.py
https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L307-L357
def get_submission_and_student(uuid, read_replica=False): """ Retrieve a submission by its unique identifier, including the associated student item. Args: uuid (str): the unique identifier of the submission. Kwargs: read_replica (bool): If true, attempt to use the read replica database...
[ "def", "get_submission_and_student", "(", "uuid", ",", "read_replica", "=", "False", ")", ":", "# This may raise API exceptions", "submission", "=", "get_submission", "(", "uuid", ",", "read_replica", "=", "read_replica", ")", "# Retrieve the student item from the cache", ...
Retrieve a submission by its unique identifier, including the associated student item. Args: uuid (str): the unique identifier of the submission. Kwargs: read_replica (bool): If true, attempt to use the read replica database. If no read replica is available, use the default databas...
[ "Retrieve", "a", "submission", "by", "its", "unique", "identifier", "including", "the", "associated", "student", "item", "." ]
python
train
OpenTreeOfLife/peyotl
peyotl/phylo/compat.py
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylo/compat.py#L31-L38
def sets_are_rooted_compat(one_set, other): """treats the 2 sets are sets of taxon IDs on the same (unstated) universe of taxon ids. Returns True clades implied by each are compatible and False otherwise """ if one_set.issubset(other) or other.issubset(one_set): return True return not in...
[ "def", "sets_are_rooted_compat", "(", "one_set", ",", "other", ")", ":", "if", "one_set", ".", "issubset", "(", "other", ")", "or", "other", ".", "issubset", "(", "one_set", ")", ":", "return", "True", "return", "not", "intersection_not_empty", "(", "one_set...
treats the 2 sets are sets of taxon IDs on the same (unstated) universe of taxon ids. Returns True clades implied by each are compatible and False otherwise
[ "treats", "the", "2", "sets", "are", "sets", "of", "taxon", "IDs", "on", "the", "same", "(", "unstated", ")", "universe", "of", "taxon", "ids", ".", "Returns", "True", "clades", "implied", "by", "each", "are", "compatible", "and", "False", "otherwise" ]
python
train
mrallen1/pygett
pygett/files.py
https://github.com/mrallen1/pygett/blob/1e21f8674a3634a901af054226670174b5ce2d87/pygett/files.py#L108-L130
def upload_url(self): """ This method generates URLs which allow overwriting a file's content with new content. The output is suitable for use in the ``send_data()`` method below. Input: * None Output: * A URL (string) Example:: fil...
[ "def", "upload_url", "(", "self", ")", ":", "if", "self", ".", "put_upload_url", ":", "return", "self", ".", "put_upload_url", "else", ":", "response", "=", "GettRequest", "(", ")", ".", "get", "(", "\"/files/%s/%s/upload?accesstoken=%s\"", "%", "(", "self", ...
This method generates URLs which allow overwriting a file's content with new content. The output is suitable for use in the ``send_data()`` method below. Input: * None Output: * A URL (string) Example:: file = client.get_file("4ddfds", 0) ...
[ "This", "method", "generates", "URLs", "which", "allow", "overwriting", "a", "file", "s", "content", "with", "new", "content", ".", "The", "output", "is", "suitable", "for", "use", "in", "the", "send_data", "()", "method", "below", "." ]
python
train
materialsproject/pymatgen
pymatgen/util/coord.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/util/coord.py#L335-L356
def get_angle(v1, v2, units="degrees"): """ Calculates the angle between two vectors. Args: v1: Vector 1 v2: Vector 2 units: "degrees" or "radians". Defaults to "degrees". Returns: Angle between them in degrees. """ d = np.dot(v1, v2) / np.linalg.norm(v1) / np.l...
[ "def", "get_angle", "(", "v1", ",", "v2", ",", "units", "=", "\"degrees\"", ")", ":", "d", "=", "np", ".", "dot", "(", "v1", ",", "v2", ")", "/", "np", ".", "linalg", ".", "norm", "(", "v1", ")", "/", "np", ".", "linalg", ".", "norm", "(", ...
Calculates the angle between two vectors. Args: v1: Vector 1 v2: Vector 2 units: "degrees" or "radians". Defaults to "degrees". Returns: Angle between them in degrees.
[ "Calculates", "the", "angle", "between", "two", "vectors", "." ]
python
train
consbio/ncdjango
ncdjango/geoprocessing/evaluation.py
https://github.com/consbio/ncdjango/blob/f807bfd1e4083ab29fbc3c4d4418be108383a710/ncdjango/geoprocessing/evaluation.py#L349-L357
def fn_min(self, a, axis=None): """ Return the minimum of an array, ignoring any NaNs. :param a: The array. :return: The minimum value of the array. """ return numpy.nanmin(self._to_ndarray(a), axis=axis)
[ "def", "fn_min", "(", "self", ",", "a", ",", "axis", "=", "None", ")", ":", "return", "numpy", ".", "nanmin", "(", "self", ".", "_to_ndarray", "(", "a", ")", ",", "axis", "=", "axis", ")" ]
Return the minimum of an array, ignoring any NaNs. :param a: The array. :return: The minimum value of the array.
[ "Return", "the", "minimum", "of", "an", "array", "ignoring", "any", "NaNs", "." ]
python
train
swharden/SWHLab
doc/oldcode/swhlab/core/common.py
https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L875-L882
def TK_message(title,msg): """use the GUI to pop up a message.""" root = tkinter.Tk() root.withdraw() #hide tk window root.attributes("-topmost", True) #always on top root.lift() #bring to top tkinter.messagebox.showwarning(title, msg) root.destroy()
[ "def", "TK_message", "(", "title", ",", "msg", ")", ":", "root", "=", "tkinter", ".", "Tk", "(", ")", "root", ".", "withdraw", "(", ")", "#hide tk window", "root", ".", "attributes", "(", "\"-topmost\"", ",", "True", ")", "#always on top", "root", ".", ...
use the GUI to pop up a message.
[ "use", "the", "GUI", "to", "pop", "up", "a", "message", "." ]
python
valid
google-research/batch-ppo
agents/tools/batch_env.py
https://github.com/google-research/batch-ppo/blob/3d09705977bae4e7c3eb20339a3b384d2a5531e4/agents/tools/batch_env.py#L101-L118
def reset(self, indices=None): """Reset the environment and convert the resulting observation. Args: indices: The batch indices of environments to reset; defaults to all. Returns: Batch of observations. """ if indices is None: indices = np.arange(len(self._envs)) if self._blo...
[ "def", "reset", "(", "self", ",", "indices", "=", "None", ")", ":", "if", "indices", "is", "None", ":", "indices", "=", "np", ".", "arange", "(", "len", "(", "self", ".", "_envs", ")", ")", "if", "self", ".", "_blocking", ":", "observs", "=", "["...
Reset the environment and convert the resulting observation. Args: indices: The batch indices of environments to reset; defaults to all. Returns: Batch of observations.
[ "Reset", "the", "environment", "and", "convert", "the", "resulting", "observation", "." ]
python
train
numenta/htmresearch
htmresearch/algorithms/lateral_pooler.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/algorithms/lateral_pooler.py#L270-L297
def _adaptSynapses(self, inputVector, activeColumns, overlaps): """ The primary method in charge of learning. Adapts the permanence values of the synapses based on the input vector, and the chosen columns after inhibition round. Permanence values are increased for synapses connected to input bits th...
[ "def", "_adaptSynapses", "(", "self", ",", "inputVector", ",", "activeColumns", ",", "overlaps", ")", ":", "inputIndices", "=", "np", ".", "where", "(", "inputVector", ">", "0", ")", "[", "0", "]", "permChanges", "=", "np", ".", "zeros", "(", "self", "...
The primary method in charge of learning. Adapts the permanence values of the synapses based on the input vector, and the chosen columns after inhibition round. Permanence values are increased for synapses connected to input bits that are turned on, and decreased for synapses connected to inputs bits th...
[ "The", "primary", "method", "in", "charge", "of", "learning", ".", "Adapts", "the", "permanence", "values", "of", "the", "synapses", "based", "on", "the", "input", "vector", "and", "the", "chosen", "columns", "after", "inhibition", "round", ".", "Permanence", ...
python
train
chris1610/barnum-proj
barnum/gen_data.py
https://github.com/chris1610/barnum-proj/blob/0a38f24bde66373553d02fbf67b733c1d55ada33/barnum/gen_data.py#L112-L119
def create_nouns(max=2): """ Return a string of random nouns up to max number """ nouns = [] for noun in range(0, max): nouns.append(random.choice(noun_list)) return " ".join(nouns)
[ "def", "create_nouns", "(", "max", "=", "2", ")", ":", "nouns", "=", "[", "]", "for", "noun", "in", "range", "(", "0", ",", "max", ")", ":", "nouns", ".", "append", "(", "random", ".", "choice", "(", "noun_list", ")", ")", "return", "\" \"", ".",...
Return a string of random nouns up to max number
[ "Return", "a", "string", "of", "random", "nouns", "up", "to", "max", "number" ]
python
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_gasheli.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_gasheli.py#L135-L148
def cmd_gasheli(self, args): '''gas help commands''' usage = "Usage: gasheli <start|stop|set>" if len(args) < 1: print(usage) return if args[0] == "start": self.start_motor() elif args[0] == "stop": self.stop_motor() elif ar...
[ "def", "cmd_gasheli", "(", "self", ",", "args", ")", ":", "usage", "=", "\"Usage: gasheli <start|stop|set>\"", "if", "len", "(", "args", ")", "<", "1", ":", "print", "(", "usage", ")", "return", "if", "args", "[", "0", "]", "==", "\"start\"", ":", "sel...
gas help commands
[ "gas", "help", "commands" ]
python
train
ethereum/py-evm
eth/tools/builder/chain/builders.py
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/tools/builder/chain/builders.py#L453-L486
def chain_split(*splits: Iterable[Callable[..., Any]]) -> Callable[[BaseChain], Iterable[BaseChain]]: # noqa: E501 """ Construct and execute multiple concurrent forks of the chain. Any number of forks may be executed. For each fork, provide an iterable of commands. Returns the resulting chain o...
[ "def", "chain_split", "(", "*", "splits", ":", "Iterable", "[", "Callable", "[", "...", ",", "Any", "]", "]", ")", "->", "Callable", "[", "[", "BaseChain", "]", ",", "Iterable", "[", "BaseChain", "]", "]", ":", "# noqa: E501", "if", "not", "splits", ...
Construct and execute multiple concurrent forks of the chain. Any number of forks may be executed. For each fork, provide an iterable of commands. Returns the resulting chain objects for each fork. .. code-block:: python chain_a, chain_b = build( mining_chain, chain...
[ "Construct", "and", "execute", "multiple", "concurrent", "forks", "of", "the", "chain", "." ]
python
train
pyrapt/rapt
rapt/treebrd/grammars/core_grammar.py
https://github.com/pyrapt/rapt/blob/0193a07aafff83a887fdc9e5e0f25eafa5b1b205/rapt/treebrd/grammars/core_grammar.py#L161-L166
def parameter(self, parser): """ Return a parser the parses parameters. """ return (Suppress(self.syntax.params_start).leaveWhitespace() + Group(parser) + Suppress(self.syntax.params_stop))
[ "def", "parameter", "(", "self", ",", "parser", ")", ":", "return", "(", "Suppress", "(", "self", ".", "syntax", ".", "params_start", ")", ".", "leaveWhitespace", "(", ")", "+", "Group", "(", "parser", ")", "+", "Suppress", "(", "self", ".", "syntax", ...
Return a parser the parses parameters.
[ "Return", "a", "parser", "the", "parses", "parameters", "." ]
python
train
BerkeleyAutomation/perception
perception/cnn.py
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/cnn.py#L141-L146
def open_session(self): """ Open tensorflow session. Exposed for memory management. """ with self._graph.as_default(): init = tf.initialize_all_variables() self._sess = tf.Session() self._sess.run(init)
[ "def", "open_session", "(", "self", ")", ":", "with", "self", ".", "_graph", ".", "as_default", "(", ")", ":", "init", "=", "tf", ".", "initialize_all_variables", "(", ")", "self", ".", "_sess", "=", "tf", ".", "Session", "(", ")", "self", ".", "_ses...
Open tensorflow session. Exposed for memory management.
[ "Open", "tensorflow", "session", ".", "Exposed", "for", "memory", "management", "." ]
python
train
IndicoDataSolutions/IndicoIo-python
indicoio/custom/custom.py
https://github.com/IndicoDataSolutions/IndicoIo-python/blob/6f262a23f09d76fede63d1ccb87f9f7cf2cfc8aa/indicoio/custom/custom.py#L81-L117
def visualize_explanation(explanation, label=None): """ Given the output of the explain() endpoint, produces a terminal visual that plots response strength over a sequence """ if not sys.version_info[:2] >= (3, 5): raise IndicoError("Python >= 3.5+ is required for explanation visualization") ...
[ "def", "visualize_explanation", "(", "explanation", ",", "label", "=", "None", ")", ":", "if", "not", "sys", ".", "version_info", "[", ":", "2", "]", ">=", "(", "3", ",", "5", ")", ":", "raise", "IndicoError", "(", "\"Python >= 3.5+ is required for explanati...
Given the output of the explain() endpoint, produces a terminal visual that plots response strength over a sequence
[ "Given", "the", "output", "of", "the", "explain", "()", "endpoint", "produces", "a", "terminal", "visual", "that", "plots", "response", "strength", "over", "a", "sequence" ]
python
train
thespacedoctor/fundamentals
fundamentals/tools.py
https://github.com/thespacedoctor/fundamentals/blob/1d2c007ac74442ec2eabde771cfcacdb9c1ab382/fundamentals/tools.py#L389-L481
def _setup_tunnel( self): """ *setup ssh tunnel if required* """ from subprocess import Popen, PIPE, STDOUT import pymysql as ms # SETUP TUNNEL IF REQUIRED if "ssh tunnel" in self.settings: # TEST TUNNEL DOES NOT ALREADY EXIST ...
[ "def", "_setup_tunnel", "(", "self", ")", ":", "from", "subprocess", "import", "Popen", ",", "PIPE", ",", "STDOUT", "import", "pymysql", "as", "ms", "# SETUP TUNNEL IF REQUIRED", "if", "\"ssh tunnel\"", "in", "self", ".", "settings", ":", "# TEST TUNNEL DOES NOT A...
*setup ssh tunnel if required*
[ "*", "setup", "ssh", "tunnel", "if", "required", "*" ]
python
train
openstack/networking-cisco
networking_cisco/plugins/cisco/cfg_agent/service_helpers/routing_svc_helper.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/cfg_agent/service_helpers/routing_svc_helper.py#L1141-L1163
def _router_added(self, router_id, router): """Operations when a router is added. Create a new RouterInfo object for this router and add it to the service helpers router_info dictionary. Then `router_added()` is called on the device driver. :param router_id: id of the router ...
[ "def", "_router_added", "(", "self", ",", "router_id", ",", "router", ")", ":", "ri", "=", "RouterInfo", "(", "router_id", ",", "router", ")", "driver", "=", "self", ".", "driver_manager", ".", "set_driver", "(", "router", ")", "if", "router", "[", "ROUT...
Operations when a router is added. Create a new RouterInfo object for this router and add it to the service helpers router_info dictionary. Then `router_added()` is called on the device driver. :param router_id: id of the router :param router: router dict :return: None
[ "Operations", "when", "a", "router", "is", "added", "." ]
python
train
pyviz/holoviews
holoviews/core/util.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/util.py#L1520-L1534
def stream_name_mapping(stream, exclude_params=['name'], reverse=False): """ Return a complete dictionary mapping between stream parameter names to their applicable renames, excluding parameters listed in exclude_params. If reverse is True, the mapping is from the renamed strings to the origina...
[ "def", "stream_name_mapping", "(", "stream", ",", "exclude_params", "=", "[", "'name'", "]", ",", "reverse", "=", "False", ")", ":", "filtered", "=", "[", "k", "for", "k", "in", "stream", ".", "params", "(", ")", ".", "keys", "(", ")", "if", "k", "...
Return a complete dictionary mapping between stream parameter names to their applicable renames, excluding parameters listed in exclude_params. If reverse is True, the mapping is from the renamed strings to the original stream parameter names.
[ "Return", "a", "complete", "dictionary", "mapping", "between", "stream", "parameter", "names", "to", "their", "applicable", "renames", "excluding", "parameters", "listed", "in", "exclude_params", "." ]
python
train
romanorac/discomll
discomll/dataset.py
https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/dataset.py#L160-L194
def generate_urls(self, first_url, last_url): """ Function generates URLs in split command fashion. If first_url is xaaaaa and last_url is xaaaac, it will automatically generate xaaaab. """ first_url = first_url.split("/") last_url = last_url.split("/") if first_url[0].lo...
[ "def", "generate_urls", "(", "self", ",", "first_url", ",", "last_url", ")", ":", "first_url", "=", "first_url", ".", "split", "(", "\"/\"", ")", "last_url", "=", "last_url", ".", "split", "(", "\"/\"", ")", "if", "first_url", "[", "0", "]", ".", "lowe...
Function generates URLs in split command fashion. If first_url is xaaaaa and last_url is xaaaac, it will automatically generate xaaaab.
[ "Function", "generates", "URLs", "in", "split", "command", "fashion", ".", "If", "first_url", "is", "xaaaaa", "and", "last_url", "is", "xaaaac", "it", "will", "automatically", "generate", "xaaaab", "." ]
python
train
pandas-dev/pandas
pandas/core/sparse/frame.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/frame.py#L809-L817
def transpose(self, *args, **kwargs): """ Returns a DataFrame with the rows/columns switched. """ nv.validate_transpose(args, kwargs) return self._constructor( self.values.T, index=self.columns, columns=self.index, default_fill_value=self._default_fill_val...
[ "def", "transpose", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "nv", ".", "validate_transpose", "(", "args", ",", "kwargs", ")", "return", "self", ".", "_constructor", "(", "self", ".", "values", ".", "T", ",", "index", "=", ...
Returns a DataFrame with the rows/columns switched.
[ "Returns", "a", "DataFrame", "with", "the", "rows", "/", "columns", "switched", "." ]
python
train
lorien/grab
grab/document.py
https://github.com/lorien/grab/blob/8b301db2a08c830245b61c589e58af6234f4db79/grab/document.py#L260-L279
def copy(self, new_grab=None): """ Clone the Response object. """ obj = self.__class__() obj.process_grab(new_grab if new_grab else self.grab) copy_keys = ('status', 'code', 'head', 'body', 'total_time', 'connect_time', 'name_lookup_time', ...
[ "def", "copy", "(", "self", ",", "new_grab", "=", "None", ")", ":", "obj", "=", "self", ".", "__class__", "(", ")", "obj", ".", "process_grab", "(", "new_grab", "if", "new_grab", "else", "self", ".", "grab", ")", "copy_keys", "=", "(", "'status'", ",...
Clone the Response object.
[ "Clone", "the", "Response", "object", "." ]
python
train
Cymmetria/honeycomb
honeycomb/integrationmanager/tasks.py
https://github.com/Cymmetria/honeycomb/blob/33ea91b5cf675000e4e85dd02efe580ea6e95c86/honeycomb/integrationmanager/tasks.py#L61-L66
def send_alert_to_subscribed_integrations(alert): """Send Alert to relevant integrations.""" valid_configured_integrations = get_valid_configured_integrations(alert) for configured_integration in valid_configured_integrations: threading.Thread(target=create_integration_alert_and_call_send, args=(al...
[ "def", "send_alert_to_subscribed_integrations", "(", "alert", ")", ":", "valid_configured_integrations", "=", "get_valid_configured_integrations", "(", "alert", ")", "for", "configured_integration", "in", "valid_configured_integrations", ":", "threading", ".", "Thread", "(", ...
Send Alert to relevant integrations.
[ "Send", "Alert", "to", "relevant", "integrations", "." ]
python
train
saltstack/salt
salt/template.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/template.py#L35-L139
def compile_template(template, renderers, default, blacklist, whitelist, saltenv='base', sls='', input_data='', **kwargs): ''' Take the path to ...
[ "def", "compile_template", "(", "template", ",", "renderers", ",", "default", ",", "blacklist", ",", "whitelist", ",", "saltenv", "=", "'base'", ",", "sls", "=", "''", ",", "input_data", "=", "''", ",", "*", "*", "kwargs", ")", ":", "# if any error occurs,...
Take the path to a template and return the high data structure derived from the template. Helpers: :param mask_value: Mask value for debugging purposes (prevent sensitive information etc) example: "mask_value="pass*". All "passwd", "password", "pass" will be masked (as text).
[ "Take", "the", "path", "to", "a", "template", "and", "return", "the", "high", "data", "structure", "derived", "from", "the", "template", "." ]
python
train
zeroSteiner/smoke-zephyr
smoke_zephyr/argparse_types.py
https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/argparse_types.py#L127-L133
def timespan_type(arg): """An argparse type representing a timespan such as 6h for 6 hours.""" try: arg = parse_timespan(arg) except ValueError: raise argparse.ArgumentTypeError("{0} is not a valid time span".format(repr(arg))) return arg
[ "def", "timespan_type", "(", "arg", ")", ":", "try", ":", "arg", "=", "parse_timespan", "(", "arg", ")", "except", "ValueError", ":", "raise", "argparse", ".", "ArgumentTypeError", "(", "\"{0} is not a valid time span\"", ".", "format", "(", "repr", "(", "arg"...
An argparse type representing a timespan such as 6h for 6 hours.
[ "An", "argparse", "type", "representing", "a", "timespan", "such", "as", "6h", "for", "6", "hours", "." ]
python
train
Azure/azure-sdk-for-python
azure-servicemanagement-legacy/azure/servicemanagement/servicemanagementservice.py
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/servicemanagementservice.py#L592-L633
def change_deployment_configuration(self, service_name, deployment_name, configuration, treat_warnings_as_error=False, mode='Auto', extended_properties=None): ''' Initiates a change to...
[ "def", "change_deployment_configuration", "(", "self", ",", "service_name", ",", "deployment_name", ",", "configuration", ",", "treat_warnings_as_error", "=", "False", ",", "mode", "=", "'Auto'", ",", "extended_properties", "=", "None", ")", ":", "_validate_not_none",...
Initiates a change to the deployment configuration. service_name: Name of the hosted service. deployment_name: The name of the deployment. configuration: The base-64 encoded service configuration file for the deployment. treat_warnings_as_error: ...
[ "Initiates", "a", "change", "to", "the", "deployment", "configuration", "." ]
python
test
cltk/cltk
cltk/corpus/readers.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/corpus/readers.py#L444-L452
def lines(self: object, fileids: str, plaintext: bool = True): """ Tokenizes documents in the corpus by line """ for text in self.texts(fileids, plaintext): text = re.sub(r'\n\s*\n', '\n', text, re.MULTILINE) # Remove blank lines for line in text.split('\n'): ...
[ "def", "lines", "(", "self", ":", "object", ",", "fileids", ":", "str", ",", "plaintext", ":", "bool", "=", "True", ")", ":", "for", "text", "in", "self", ".", "texts", "(", "fileids", ",", "plaintext", ")", ":", "text", "=", "re", ".", "sub", "(...
Tokenizes documents in the corpus by line
[ "Tokenizes", "documents", "in", "the", "corpus", "by", "line" ]
python
train
iterative/dvc
dvc/remote/ssh/connection.py
https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/remote/ssh/connection.py#L31-L38
def percent_cb(name, complete, total): """ Callback for updating target progress """ logger.debug( "{}: {} transferred out of {}".format( name, sizeof_fmt(complete), sizeof_fmt(total) ) ) progress.update_target(name, complete, total)
[ "def", "percent_cb", "(", "name", ",", "complete", ",", "total", ")", ":", "logger", ".", "debug", "(", "\"{}: {} transferred out of {}\"", ".", "format", "(", "name", ",", "sizeof_fmt", "(", "complete", ")", ",", "sizeof_fmt", "(", "total", ")", ")", ")",...
Callback for updating target progress
[ "Callback", "for", "updating", "target", "progress" ]
python
train
marcinmiklitz/pywindow
pywindow/trajectory.py
https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/trajectory.py#L943-L1034
def analysis(self, frames='all', ncpus=1, override=False, **kwargs): """ Perform structural analysis on a frame/ set of frames. Depending on the passed parameters a frame, a list of particular frames, a range of frames (from, to), or all frames can be analysed with this function...
[ "def", "analysis", "(", "self", ",", "frames", "=", "'all'", ",", "ncpus", "=", "1", ",", "override", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "override", "is", "True", ":", "self", ".", "analysis_output", "=", "{", "}", "if", "isinst...
Perform structural analysis on a frame/ set of frames. Depending on the passed parameters a frame, a list of particular frames, a range of frames (from, to), or all frames can be analysed with this function. The analysis is performed on each frame and each discrete molecule in ...
[ "Perform", "structural", "analysis", "on", "a", "frame", "/", "set", "of", "frames", "." ]
python
train
Laufire/ec
ec/modules/helpers.py
https://github.com/Laufire/ec/blob/63e84a1daef9234487d7de538e5da233a7d13071/ec/modules/helpers.py#L164-L179
def reconfigArg(ArgConfig): r"""Reconfigures an argument based on its configuration. """ _type = ArgConfig.get('type') if _type: if hasattr(_type, '__ec_config__'): # pass the ArgConfig to the CustomType: _type.__ec_config__(ArgConfig) if not 'type_str' in ArgConfig: ArgConfig['type_str'] = (_...
[ "def", "reconfigArg", "(", "ArgConfig", ")", ":", "_type", "=", "ArgConfig", ".", "get", "(", "'type'", ")", "if", "_type", ":", "if", "hasattr", "(", "_type", ",", "'__ec_config__'", ")", ":", "# pass the ArgConfig to the CustomType:", "_type", ".", "__ec_con...
r"""Reconfigures an argument based on its configuration.
[ "r", "Reconfigures", "an", "argument", "based", "on", "its", "configuration", "." ]
python
train
costastf/locationsharinglib
_CI/library/patch.py
https://github.com/costastf/locationsharinglib/blob/dcd74b0cdb59b951345df84987238763e50ef282/_CI/library/patch.py#L804-L821
def findfile(self, old, new): """ return name of file to be patched or None """ if exists(old): return old elif exists(new): return new else: # [w] Google Code generates broken patches with its online editor debug("broken patch from Google Code, stripping prefixes..") if ol...
[ "def", "findfile", "(", "self", ",", "old", ",", "new", ")", ":", "if", "exists", "(", "old", ")", ":", "return", "old", "elif", "exists", "(", "new", ")", ":", "return", "new", "else", ":", "# [w] Google Code generates broken patches with its online editor", ...
return name of file to be patched or None
[ "return", "name", "of", "file", "to", "be", "patched", "or", "None" ]
python
train
spdx/tools-python
spdx/parsers/tagvalue.py
https://github.com/spdx/tools-python/blob/301d72f6ae57c832c1da7f6402fa49b192de6810/spdx/parsers/tagvalue.py#L1126-L1141
def p_annotation_type_1(self, p): """annotation_type : ANNOTATION_TYPE LINE""" try: if six.PY2: value = p[2].decode(encoding='utf-8') else: value = p[2] self.builder.add_annotation_type(self.document, value) except CardinalityEr...
[ "def", "p_annotation_type_1", "(", "self", ",", "p", ")", ":", "try", ":", "if", "six", ".", "PY2", ":", "value", "=", "p", "[", "2", "]", ".", "decode", "(", "encoding", "=", "'utf-8'", ")", "else", ":", "value", "=", "p", "[", "2", "]", "self...
annotation_type : ANNOTATION_TYPE LINE
[ "annotation_type", ":", "ANNOTATION_TYPE", "LINE" ]
python
valid
TUNE-Archive/freight_forwarder
freight_forwarder/container/host_config.py
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/container/host_config.py#L525-L548
def extra_hosts(self, value): """ :param value: :return None: """ if value is None: self._extra_hosts = value elif isinstance(value, list): # TODO: better validation self._extra_hosts = value elif isinstance(value, dict): ...
[ "def", "extra_hosts", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "self", ".", "_extra_hosts", "=", "value", "elif", "isinstance", "(", "value", ",", "list", ")", ":", "# TODO: better validation", "self", ".", "_extra_hosts", "="...
:param value: :return None:
[ ":", "param", "value", ":", ":", "return", "None", ":" ]
python
train
pyca/pyopenssl
src/OpenSSL/crypto.py
https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/src/OpenSSL/crypto.py#L2677-L2707
def load_publickey(type, buffer): """ Load a public key from a buffer. :param type: The file type (one of :data:`FILETYPE_PEM`, :data:`FILETYPE_ASN1`). :param buffer: The buffer the key is stored in. :type buffer: A Python string object, either unicode or bytestring. :return: The PKey o...
[ "def", "load_publickey", "(", "type", ",", "buffer", ")", ":", "if", "isinstance", "(", "buffer", ",", "_text_type", ")", ":", "buffer", "=", "buffer", ".", "encode", "(", "\"ascii\"", ")", "bio", "=", "_new_mem_buf", "(", "buffer", ")", "if", "type", ...
Load a public key from a buffer. :param type: The file type (one of :data:`FILETYPE_PEM`, :data:`FILETYPE_ASN1`). :param buffer: The buffer the key is stored in. :type buffer: A Python string object, either unicode or bytestring. :return: The PKey object. :rtype: :class:`PKey`
[ "Load", "a", "public", "key", "from", "a", "buffer", "." ]
python
test
BDNYC/astrodbkit
astrodbkit/astrodb.py
https://github.com/BDNYC/astrodbkit/blob/02c03c5e91aa7c7b0f3b5fa95bcf71e33ffcee09/astrodbkit/astrodb.py#L660-L683
def close(self, silent=False): """ Close the database and ask to save and delete the file Parameters ---------- silent: bool Close quietly without saving or deleting (Default: False). """ if not silent: saveme = get_input("Save database co...
[ "def", "close", "(", "self", ",", "silent", "=", "False", ")", ":", "if", "not", "silent", ":", "saveme", "=", "get_input", "(", "\"Save database contents to '{}/'? (y, [n]) \\n\"", "\"To save elsewhere, run db.save() before closing. \"", ".", "format", "(", "self", "...
Close the database and ask to save and delete the file Parameters ---------- silent: bool Close quietly without saving or deleting (Default: False).
[ "Close", "the", "database", "and", "ask", "to", "save", "and", "delete", "the", "file" ]
python
train
ska-sa/montblanc
montblanc/impl/rime/tensorflow/sources/fits_beam_source_provider.py
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/fits_beam_source_provider.py#L237-L261
def _create_axes(filenames, file_dict): """ Create a FitsAxes object """ try: # Loop through the file_dictionary, finding the # first open FITS file. f = iter(f for tup in file_dict.itervalues() for f in tup if f is not None).next() except StopIteration as e: rai...
[ "def", "_create_axes", "(", "filenames", ",", "file_dict", ")", ":", "try", ":", "# Loop through the file_dictionary, finding the", "# first open FITS file.", "f", "=", "iter", "(", "f", "for", "tup", "in", "file_dict", ".", "itervalues", "(", ")", "for", "f", "...
Create a FitsAxes object
[ "Create", "a", "FitsAxes", "object" ]
python
train
rene-aguirre/pywinusb
pywinusb/hid/core.py
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1571-L1609
def show_hids(target_vid = 0, target_pid = 0, output = None): """Check all HID devices conected to PC hosts.""" # first be kind with local encodings if not output: # beware your script should manage encodings output = sys.stdout # then the big cheese... from . import tools ...
[ "def", "show_hids", "(", "target_vid", "=", "0", ",", "target_pid", "=", "0", ",", "output", "=", "None", ")", ":", "# first be kind with local encodings\r", "if", "not", "output", ":", "# beware your script should manage encodings\r", "output", "=", "sys", ".", "...
Check all HID devices conected to PC hosts.
[ "Check", "all", "HID", "devices", "conected", "to", "PC", "hosts", "." ]
python
train
Erotemic/utool
utool/util_inspect.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L2270-L2423
def get_func_sourcecode(func, stripdef=False, stripret=False, strip_docstr=False, strip_comments=False, remove_linenums=None): """ wrapper around inspect.getsource but takes into account utool decorators strip flags are very hacky as of now Args: ...
[ "def", "get_func_sourcecode", "(", "func", ",", "stripdef", "=", "False", ",", "stripret", "=", "False", ",", "strip_docstr", "=", "False", ",", "strip_comments", "=", "False", ",", "remove_linenums", "=", "None", ")", ":", "import", "utool", "as", "ut", "...
wrapper around inspect.getsource but takes into account utool decorators strip flags are very hacky as of now Args: func (function): stripdef (bool): stripret (bool): (default = False) strip_docstr (bool): (default = False) strip_comments (bool): (default = False) ...
[ "wrapper", "around", "inspect", ".", "getsource", "but", "takes", "into", "account", "utool", "decorators", "strip", "flags", "are", "very", "hacky", "as", "of", "now" ]
python
train
stevearc/dql
dql/cli.py
https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/cli.py#L165-L204
def initialize( self, region="us-west-1", host=None, port=8000, config_dir=None, session=None ): """ Set up the repl for execution. """ try: import readline import rlcompleter except ImportError: # Windows doesn't have readline, so gracefully ignor...
[ "def", "initialize", "(", "self", ",", "region", "=", "\"us-west-1\"", ",", "host", "=", "None", ",", "port", "=", "8000", ",", "config_dir", "=", "None", ",", "session", "=", "None", ")", ":", "try", ":", "import", "readline", "import", "rlcompleter", ...
Set up the repl for execution.
[ "Set", "up", "the", "repl", "for", "execution", "." ]
python
train
csirtgadgets/csirtgsdk-py
csirtgsdk/indicator.py
https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/indicator.py#L116-L146
def create(self): """ Submit action on the Indicator object :return: Indicator Object """ uri = '/users/{0}/feeds/{1}/indicators'\ .format(self.user, self.feed) data = { "indicator": json.loads(str(self.indicator)), "comment": self.co...
[ "def", "create", "(", "self", ")", ":", "uri", "=", "'/users/{0}/feeds/{1}/indicators'", ".", "format", "(", "self", ".", "user", ",", "self", ".", "feed", ")", "data", "=", "{", "\"indicator\"", ":", "json", ".", "loads", "(", "str", "(", "self", ".",...
Submit action on the Indicator object :return: Indicator Object
[ "Submit", "action", "on", "the", "Indicator", "object" ]
python
train
bcbio/bcbio-nextgen
bcbio/variation/sentieon.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/sentieon.py#L137-L149
def run_gvcftyper(vrn_files, out_file, region, data): """Produce joint called variants from input gVCF files. """ if not utils.file_exists(out_file): with file_transaction(data, out_file) as tx_out_file: license = license_export(data) ref_file = dd.get_ref_file(data) ...
[ "def", "run_gvcftyper", "(", "vrn_files", ",", "out_file", ",", "region", ",", "data", ")", ":", "if", "not", "utils", ".", "file_exists", "(", "out_file", ")", ":", "with", "file_transaction", "(", "data", ",", "out_file", ")", "as", "tx_out_file", ":", ...
Produce joint called variants from input gVCF files.
[ "Produce", "joint", "called", "variants", "from", "input", "gVCF", "files", "." ]
python
train
pandas-dev/pandas
pandas/io/pytables.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/pytables.py#L3872-L3880
def read(self, where=None, columns=None, **kwargs): """we have n indexable columns, with an arbitrary number of data axes """ if not self.read_axes(where=where, **kwargs): return None raise NotImplementedError("Panel is removed in pandas 0.25.0")
[ "def", "read", "(", "self", ",", "where", "=", "None", ",", "columns", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "read_axes", "(", "where", "=", "where", ",", "*", "*", "kwargs", ")", ":", "return", "None", "raise"...
we have n indexable columns, with an arbitrary number of data axes
[ "we", "have", "n", "indexable", "columns", "with", "an", "arbitrary", "number", "of", "data", "axes" ]
python
train
pgjones/quart
quart/config.py
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/config.py#L181-L203
def from_json(self, filename: str, silent: bool=False) -> None: """Load the configuration values from a JSON formatted file. This allows configuration to be loaded as so .. code-block:: python app.config.from_json('config.json') Arguments: filename: The filena...
[ "def", "from_json", "(", "self", ",", "filename", ":", "str", ",", "silent", ":", "bool", "=", "False", ")", "->", "None", ":", "file_path", "=", "self", ".", "root_path", "/", "filename", "try", ":", "with", "open", "(", "file_path", ")", "as", "fil...
Load the configuration values from a JSON formatted file. This allows configuration to be loaded as so .. code-block:: python app.config.from_json('config.json') Arguments: filename: The filename which when appended to :attr:`root_path` gives the path ...
[ "Load", "the", "configuration", "values", "from", "a", "JSON", "formatted", "file", "." ]
python
train
lionheart/django-pyodbc
django_pyodbc/introspection.py
https://github.com/lionheart/django-pyodbc/blob/46adda7b0bfabfa2640f72592c6f6f407f78b363/django_pyodbc/introspection.py#L221-L260
def get_key_columns(self, cursor, table_name): """ Backends can override this to return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table. """ source_field_dict = self._name_to_index(cursor, table_name) sql = """ se...
[ "def", "get_key_columns", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "source_field_dict", "=", "self", ".", "_name_to_index", "(", "cursor", ",", "table_name", ")", "sql", "=", "\"\"\"\nselect\n COLUMN_NAME = fk_cols.COLUMN_NAME,\n REFERENCED_TABLE_NAM...
Backends can override this to return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table.
[ "Backends", "can", "override", "this", "to", "return", "a", "list", "of", "(", "column_name", "referenced_table_name", "referenced_column_name", ")", "for", "all", "key", "columns", "in", "given", "table", "." ]
python
train
sveetch/py-css-styleguide
py_css_styleguide/model.py
https://github.com/sveetch/py-css-styleguide/blob/5acc693f71b2fa7d944d7fed561ae0a7699ccd0f/py_css_styleguide/model.py#L89-L98
def set_rule(self, name, properties): """ Set a rules as object attribute. Arguments: name (string): Rule name to set as attribute name. properties (dict): Dictionnary of properties. """ self._rule_attrs.append(name) setattr(self, name, properties...
[ "def", "set_rule", "(", "self", ",", "name", ",", "properties", ")", ":", "self", ".", "_rule_attrs", ".", "append", "(", "name", ")", "setattr", "(", "self", ",", "name", ",", "properties", ")" ]
Set a rules as object attribute. Arguments: name (string): Rule name to set as attribute name. properties (dict): Dictionnary of properties.
[ "Set", "a", "rules", "as", "object", "attribute", "." ]
python
train
mushkevych/scheduler
synergy/scheduler/tree_node.py
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/scheduler/tree_node.py#L51-L66
def is_finalizable(self): """method checks whether: - all counterpart of this node in dependent_on trees are finished - all direct children of the node are finished - the node itself is in active state""" composite_state = self.dependent_on_composite_state() if not co...
[ "def", "is_finalizable", "(", "self", ")", ":", "composite_state", "=", "self", ".", "dependent_on_composite_state", "(", ")", "if", "not", "composite_state", ".", "all_finished", ":", "return", "False", "if", "self", ".", "job_record", "is", "None", ":", "sel...
method checks whether: - all counterpart of this node in dependent_on trees are finished - all direct children of the node are finished - the node itself is in active state
[ "method", "checks", "whether", ":", "-", "all", "counterpart", "of", "this", "node", "in", "dependent_on", "trees", "are", "finished", "-", "all", "direct", "children", "of", "the", "node", "are", "finished", "-", "the", "node", "itself", "is", "in", "acti...
python
train
i3visio/osrframework
osrframework/thirdparties/pipl_com/lib/fields.py
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/thirdparties/pipl_com/lib/fields.py#L345-L350
def to_dict(self): """Extend Field.to_dict, take the display_international attribute.""" d = Field.to_dict(self) if self.display_international: d['display_international'] = self.display_international return d
[ "def", "to_dict", "(", "self", ")", ":", "d", "=", "Field", ".", "to_dict", "(", "self", ")", "if", "self", ".", "display_international", ":", "d", "[", "'display_international'", "]", "=", "self", ".", "display_international", "return", "d" ]
Extend Field.to_dict, take the display_international attribute.
[ "Extend", "Field", ".", "to_dict", "take", "the", "display_international", "attribute", "." ]
python
train
spyder-ide/spyder
spyder/plugins/help/utils/sphinxify.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/utils/sphinxify.py#L77-L82
def warning(message, css_path=CSS_PATH): """Print a warning message on the rich text view""" env = Environment() env.loader = FileSystemLoader(osp.join(CONFDIR_PATH, 'templates')) warning = env.get_template("warning.html") return warning.render(css_path=css_path, text=message)
[ "def", "warning", "(", "message", ",", "css_path", "=", "CSS_PATH", ")", ":", "env", "=", "Environment", "(", ")", "env", ".", "loader", "=", "FileSystemLoader", "(", "osp", ".", "join", "(", "CONFDIR_PATH", ",", "'templates'", ")", ")", "warning", "=", ...
Print a warning message on the rich text view
[ "Print", "a", "warning", "message", "on", "the", "rich", "text", "view" ]
python
train
hannes-brt/hebel
hebel/pycuda_ops/cudart.py
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cudart.py#L686-L703
def cudaDriverGetVersion(): """ Get installed CUDA driver version. Return the version of the installed CUDA driver as an integer. If no driver is detected, 0 is returned. Returns ------- version : int Driver version. """ version = ctypes.c_int() status = _libcudart.cu...
[ "def", "cudaDriverGetVersion", "(", ")", ":", "version", "=", "ctypes", ".", "c_int", "(", ")", "status", "=", "_libcudart", ".", "cudaDriverGetVersion", "(", "ctypes", ".", "byref", "(", "version", ")", ")", "cudaCheckStatus", "(", "status", ")", "return", ...
Get installed CUDA driver version. Return the version of the installed CUDA driver as an integer. If no driver is detected, 0 is returned. Returns ------- version : int Driver version.
[ "Get", "installed", "CUDA", "driver", "version", "." ]
python
train
tensorflow/probability
tensorflow_probability/python/internal/distribution_util.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1415-L1561
def fill_triangular(x, upper=False, name=None): r"""Creates a (batch of) triangular matrix from a vector of inputs. Created matrix can be lower- or upper-triangular. (It is more efficient to create the matrix as upper or lower, rather than transpose.) Triangular matrix elements are filled in a clockwise spira...
[ "def", "fill_triangular", "(", "x", ",", "upper", "=", "False", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", "\"fill_triangular\"", ")", ":", "x", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "x", ...
r"""Creates a (batch of) triangular matrix from a vector of inputs. Created matrix can be lower- or upper-triangular. (It is more efficient to create the matrix as upper or lower, rather than transpose.) Triangular matrix elements are filled in a clockwise spiral. See example, below. If `x.shape` is `[b1, ...
[ "r", "Creates", "a", "(", "batch", "of", ")", "triangular", "matrix", "from", "a", "vector", "of", "inputs", "." ]
python
test
Robin8Put/pmes
balance/handler.py
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/balance/handler.py#L794-L836
async def get_wallets(self, *args, **kwargs): """ Get users wallets by uid Accepts: - uid [integer] (users id) Returns a list: - [ { "address": [string], "uid": [integer], "amount_active": [integer], "amount_frozen": [integer] }, ] """ logging.debug("\n [+] -- G...
[ "async", "def", "get_wallets", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logging", ".", "debug", "(", "\"\\n [+] -- Get wallets debugging.\"", ")", "if", "kwargs", ".", "get", "(", "\"message\"", ")", ":", "kwargs", "=", "json", ...
Get users wallets by uid Accepts: - uid [integer] (users id) Returns a list: - [ { "address": [string], "uid": [integer], "amount_active": [integer], "amount_frozen": [integer] }, ]
[ "Get", "users", "wallets", "by", "uid" ]
python
train
rigetti/pyquil
pyquil/api/_base_connection.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/api/_base_connection.py#L52-L59
def post_json(session, url, json): """ Post JSON to the Forest endpoint. """ res = session.post(url, json=json) if res.status_code >= 400: raise parse_error(res) return res
[ "def", "post_json", "(", "session", ",", "url", ",", "json", ")", ":", "res", "=", "session", ".", "post", "(", "url", ",", "json", "=", "json", ")", "if", "res", ".", "status_code", ">=", "400", ":", "raise", "parse_error", "(", "res", ")", "retur...
Post JSON to the Forest endpoint.
[ "Post", "JSON", "to", "the", "Forest", "endpoint", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xorbbrowserwidget/xorbquerywidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbbrowserwidget/xorbquerywidget.py#L172-L186
def setModelData( self, editor, model, index ): """ Sets the data for the given index from the editor's value. :param editor | <QWidget> model | <QAbstractItemModel> index | <QModelIndex> """ tree = self.paren...
[ "def", "setModelData", "(", "self", ",", "editor", ",", "model", ",", "index", ")", ":", "tree", "=", "self", ".", "parent", "(", ")", "querywidget", "=", "tree", ".", "parent", "(", ")", "factory", "=", "querywidget", ".", "factory", "(", ")", "item...
Sets the data for the given index from the editor's value. :param editor | <QWidget> model | <QAbstractItemModel> index | <QModelIndex>
[ "Sets", "the", "data", "for", "the", "given", "index", "from", "the", "editor", "s", "value", ".", ":", "param", "editor", "|", "<QWidget", ">", "model", "|", "<QAbstractItemModel", ">", "index", "|", "<QModelIndex", ">" ]
python
train
romana/vpc-router
vpcrouter/monitor/plugins/multi.py
https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/monitor/plugins/multi.py#L187-L203
def get_info(self): """ Return plugin information. """ plugin_infos = {} for pc in self.plugins: plugin_infos.update(pc.get_info()) return { self.get_plugin_name() : { "version" : self.get_version(), "sub-plugin...
[ "def", "get_info", "(", "self", ")", ":", "plugin_infos", "=", "{", "}", "for", "pc", "in", "self", ".", "plugins", ":", "plugin_infos", ".", "update", "(", "pc", ".", "get_info", "(", ")", ")", "return", "{", "self", ".", "get_plugin_name", "(", ")"...
Return plugin information.
[ "Return", "plugin", "information", "." ]
python
train