repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
heroku/sf-suds
suds/resolver.py
NodeResolver.query
def query(self, name, node): """ blindly query the schema by name """ #log.debug('searching schema for (%s)', name) qref = qualify(name, node, node.namespace()) query = BlindQuery(qref) result = query.execute(self.schema) return (result, [])
python
def query(self, name, node): """ blindly query the schema by name """ #log.debug('searching schema for (%s)', name) qref = qualify(name, node, node.namespace()) query = BlindQuery(qref) result = query.execute(self.schema) return (result, [])
[ "def", "query", "(", "self", ",", "name", ",", "node", ")", ":", "#log.debug('searching schema for (%s)', name)", "qref", "=", "qualify", "(", "name", ",", "node", ",", "node", ".", "namespace", "(", ")", ")", "query", "=", "BlindQuery", "(", "qref", ")", ...
blindly query the schema by name
[ "blindly", "query", "the", "schema", "by", "name" ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/resolver.py#L383-L389
heroku/sf-suds
suds/resolver.py
GraphResolver.query
def query(self, name): """ blindly query the schema by name """ #log.debug('searching schema for (%s)', name) schema = self.schema wsdl = self.wsdl() if wsdl is None: qref = qualify(name, schema.root, schema.tns) else: qref = qualify(name, wsdl.roo...
python
def query(self, name): """ blindly query the schema by name """ #log.debug('searching schema for (%s)', name) schema = self.schema wsdl = self.wsdl() if wsdl is None: qref = qualify(name, schema.root, schema.tns) else: qref = qualify(name, wsdl.roo...
[ "def", "query", "(", "self", ",", "name", ")", ":", "#log.debug('searching schema for (%s)', name)", "schema", "=", "self", ".", "schema", "wsdl", "=", "self", ".", "wsdl", "(", ")", "if", "wsdl", "is", "None", ":", "qref", "=", "qualify", "(", "name", "...
blindly query the schema by name
[ "blindly", "query", "the", "schema", "by", "name" ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/resolver.py#L451-L462
heroku/sf-suds
suds/wsdl.py
Binding.resolvesoapbody
def resolvesoapbody(self, definitions, op): """ Resolve soap body I{message} parts by cross-referencing with operation defined in port type. @param definitions: A definitions object. @type definitions: L{Definitions} @param op: An I{operation} object. @type op: I...
python
def resolvesoapbody(self, definitions, op): """ Resolve soap body I{message} parts by cross-referencing with operation defined in port type. @param definitions: A definitions object. @type definitions: L{Definitions} @param op: An I{operation} object. @type op: I...
[ "def", "resolvesoapbody", "(", "self", ",", "definitions", ",", "op", ")", ":", "ptop", "=", "self", ".", "type", ".", "operation", "(", "op", ".", "name", ")", "if", "ptop", "is", "None", ":", "raise", "Exception", ",", "\"operation '%s' not defined in po...
Resolve soap body I{message} parts by cross-referencing with operation defined in port type. @param definitions: A definitions object. @type definitions: L{Definitions} @param op: An I{operation} object. @type op: I{operation}
[ "Resolve", "soap", "body", "I", "{", "message", "}", "parts", "by", "cross", "-", "referencing", "with", "operation", "defined", "in", "port", "type", "." ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/wsdl.py#L677-L708
heroku/sf-suds
suds/wsdl.py
Binding.resolveheaders
def resolveheaders(self, definitions, op): """ Resolve soap header I{message} references. @param definitions: A definitions object. @type definitions: L{Definitions} @param op: An I{operation} object. @type op: I{operation} """ soap = op.soap heade...
python
def resolveheaders(self, definitions, op): """ Resolve soap header I{message} references. @param definitions: A definitions object. @type definitions: L{Definitions} @param op: An I{operation} object. @type op: I{operation} """ soap = op.soap heade...
[ "def", "resolveheaders", "(", "self", ",", "definitions", ",", "op", ")", ":", "soap", "=", "op", ".", "soap", "headers", "=", "soap", ".", "input", ".", "headers", "+", "soap", ".", "output", ".", "headers", "for", "header", "in", "headers", ":", "m...
Resolve soap header I{message} references. @param definitions: A definitions object. @type definitions: L{Definitions} @param op: An I{operation} object. @type op: I{operation}
[ "Resolve", "soap", "header", "I", "{", "message", "}", "references", "." ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/wsdl.py#L710-L733
heroku/sf-suds
suds/wsdl.py
Binding.resolvefaults
def resolvefaults(self, definitions, op): """ Resolve soap fault I{message} references by cross-referencing with operation defined in port type. @param definitions: A definitions object. @type definitions: L{Definitions} @param op: An I{operation} object. @type op...
python
def resolvefaults(self, definitions, op): """ Resolve soap fault I{message} references by cross-referencing with operation defined in port type. @param definitions: A definitions object. @type definitions: L{Definitions} @param op: An I{operation} object. @type op...
[ "def", "resolvefaults", "(", "self", ",", "definitions", ",", "op", ")", ":", "ptop", "=", "self", ".", "type", ".", "operation", "(", "op", ".", "name", ")", "if", "ptop", "is", "None", ":", "raise", "Exception", ",", "\"operation '%s' not defined in port...
Resolve soap fault I{message} references by cross-referencing with operation defined in port type. @param definitions: A definitions object. @type definitions: L{Definitions} @param op: An I{operation} object. @type op: I{operation}
[ "Resolve", "soap", "fault", "I", "{", "message", "}", "references", "by", "cross", "-", "referencing", "with", "operation", "defined", "in", "port", "type", "." ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/wsdl.py#L735-L757
heroku/sf-suds
suds/store.py
DocumentStore.find
def find(self, location): """ Find the specified location in the store. @param location: The I{location} part of a URL. @type location: str @return: An input stream to the document. @rtype: StringIO """ try: content = self.store[location] ...
python
def find(self, location): """ Find the specified location in the store. @param location: The I{location} part of a URL. @type location: str @return: An input stream to the document. @rtype: StringIO """ try: content = self.store[location] ...
[ "def", "find", "(", "self", ",", "location", ")", ":", "try", ":", "content", "=", "self", ".", "store", "[", "location", "]", "return", "StringIO", "(", "content", ")", "except", ":", "reason", "=", "'location \"%s\" not in document store'", "%", "location"...
Find the specified location in the store. @param location: The I{location} part of a URL. @type location: str @return: An input stream to the document. @rtype: StringIO
[ "Find", "the", "specified", "location", "in", "the", "store", "." ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/store.py#L567-L580
heroku/sf-suds
suds/servicedefinition.py
ServiceDefinition.publictypes
def publictypes(self): """ get all public types """ for t in self.wsdl.schema.types.values(): if t in self.params: continue if t in self.types: continue item = (t, t) self.types.append(item) tc = lambda x,y: cmp(x[0].name, y[0].name) self.t...
python
def publictypes(self): """ get all public types """ for t in self.wsdl.schema.types.values(): if t in self.params: continue if t in self.types: continue item = (t, t) self.types.append(item) tc = lambda x,y: cmp(x[0].name, y[0].name) self.t...
[ "def", "publictypes", "(", "self", ")", ":", "for", "t", "in", "self", ".", "wsdl", ".", "schema", ".", "types", ".", "values", "(", ")", ":", "if", "t", "in", "self", ".", "params", ":", "continue", "if", "t", "in", "self", ".", "types", ":", ...
get all public types
[ "get", "all", "public", "types" ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/servicedefinition.py#L140-L148
heroku/sf-suds
suds/sax/enc.py
Encoder.encode
def encode(self, s): """ Encode special characters found in string I{s}. @param s: A string to encode. @type s: str @return: The encoded string. @rtype: str """ if isinstance(s, basestring) and self.needsEncoding(s): for x in self.encodings: ...
python
def encode(self, s): """ Encode special characters found in string I{s}. @param s: A string to encode. @type s: str @return: The encoded string. @rtype: str """ if isinstance(s, basestring) and self.needsEncoding(s): for x in self.encodings: ...
[ "def", "encode", "(", "self", ",", "s", ")", ":", "if", "isinstance", "(", "s", ",", "basestring", ")", "and", "self", ".", "needsEncoding", "(", "s", ")", ":", "for", "x", "in", "self", ".", "encodings", ":", "s", "=", "s", ".", "replace", "(", ...
Encode special characters found in string I{s}. @param s: A string to encode. @type s: str @return: The encoded string. @rtype: str
[ "Encode", "special", "characters", "found", "in", "string", "I", "{", "s", "}", "." ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/sax/enc.py#L55-L66
heroku/sf-suds
suds/sax/enc.py
Encoder.decode
def decode(self, s): """ Decode special characters encodings found in string I{s}. @param s: A string to decode. @type s: str @return: The decoded string. @rtype: str """ if isinstance(s, basestring) and '&' in s: for x in self.decodings: ...
python
def decode(self, s): """ Decode special characters encodings found in string I{s}. @param s: A string to decode. @type s: str @return: The decoded string. @rtype: str """ if isinstance(s, basestring) and '&' in s: for x in self.decodings: ...
[ "def", "decode", "(", "self", ",", "s", ")", ":", "if", "isinstance", "(", "s", ",", "basestring", ")", "and", "'&'", "in", "s", ":", "for", "x", "in", "self", ".", "decodings", ":", "s", "=", "s", ".", "replace", "(", "x", "[", "0", "]", ","...
Decode special characters encodings found in string I{s}. @param s: A string to decode. @type s: str @return: The decoded string. @rtype: str
[ "Decode", "special", "characters", "encodings", "found", "in", "string", "I", "{", "s", "}", "." ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/sax/enc.py#L68-L79
heroku/sf-suds
suds/sax/parser.py
Parser.parse
def parse(self, file=None, string=None): """ SAX parse XML text. @param file: Parse a python I{file-like} object. @type file: I{file-like} object. @param string: Parse string XML. @type string: str """ timer = metrics.Timer() timer.start() ...
python
def parse(self, file=None, string=None): """ SAX parse XML text. @param file: Parse a python I{file-like} object. @type file: I{file-like} object. @param string: Parse string XML. @type string: str """ timer = metrics.Timer() timer.start() ...
[ "def", "parse", "(", "self", ",", "file", "=", "None", ",", "string", "=", "None", ")", ":", "timer", "=", "metrics", ".", "Timer", "(", ")", "timer", ".", "start", "(", ")", "sax", ",", "handler", "=", "self", ".", "saxparser", "(", ")", "if", ...
SAX parse XML text. @param file: Parse a python I{file-like} object. @type file: I{file-like} object. @param string: Parse string XML. @type string: str
[ "SAX", "parse", "XML", "text", "." ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/sax/parser.py#L117-L139
heroku/sf-suds
suds/bindings/binding.py
Binding.get_message
def get_message(self, method, args, kwargs, options=None): """ Get the soap message for the specified method, args and soapheaders. This is the entry point for creating the outbound soap message. @param method: The method being invoked. @type method: I{service.Method} @pa...
python
def get_message(self, method, args, kwargs, options=None): """ Get the soap message for the specified method, args and soapheaders. This is the entry point for creating the outbound soap message. @param method: The method being invoked. @type method: I{service.Method} @pa...
[ "def", "get_message", "(", "self", ",", "method", ",", "args", ",", "kwargs", ",", "options", "=", "None", ")", ":", "content", "=", "self", ".", "headercontent", "(", "method", ",", "options", "=", "options", ")", "header", "=", "self", ".", "header",...
Get the soap message for the specified method, args and soapheaders. This is the entry point for creating the outbound soap message. @param method: The method being invoked. @type method: I{service.Method} @param args: A list of args for the method invoked. @type args: list ...
[ "Get", "the", "soap", "message", "for", "the", "specified", "method", "args", "and", "soapheaders", ".", "This", "is", "the", "entry", "point", "for", "creating", "the", "outbound", "soap", "message", "." ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/bindings/binding.py#L104-L128
heroku/sf-suds
suds/client.py
SoapClient.invoke
def invoke(self, args, kwargs): """ Send the required soap message to invoke the specified method @param args: A list of args for the method invoked. @type args: list @param kwargs: Named (keyword) args for the method invoked. @type kwargs: dict @return: The resul...
python
def invoke(self, args, kwargs): """ Send the required soap message to invoke the specified method @param args: A list of args for the method invoked. @type args: list @param kwargs: Named (keyword) args for the method invoked. @type kwargs: dict @return: The resul...
[ "def", "invoke", "(", "self", ",", "args", ",", "kwargs", ")", ":", "timer", "=", "metrics", ".", "Timer", "(", ")", "timer", ".", "start", "(", ")", "result", "=", "None", "binding", "=", "self", ".", "method", ".", "binding", ".", "input", "soape...
Send the required soap message to invoke the specified method @param args: A list of args for the method invoked. @type args: list @param kwargs: Named (keyword) args for the method invoked. @type kwargs: dict @return: The result of the method invocation. @rtype: I{builti...
[ "Send", "the", "required", "soap", "message", "to", "invoke", "the", "specified", "method" ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/client.py#L594-L622
heroku/sf-suds
suds/client.py
SoapClient.send
def send(self, soapenv): """ Send soap message. @param soapenv: A soap envelope to send. @type soapenv: L{Document} @return: The reply to the sent message. @rtype: I{builtin} or I{subclass of} L{Object} """ result = None location = self.location() ...
python
def send(self, soapenv): """ Send soap message. @param soapenv: A soap envelope to send. @type soapenv: L{Document} @return: The reply to the sent message. @rtype: I{builtin} or I{subclass of} L{Object} """ result = None location = self.location() ...
[ "def", "send", "(", "self", ",", "soapenv", ")", ":", "result", "=", "None", "location", "=", "self", ".", "location", "(", ")", "binding", "=", "self", ".", "method", ".", "binding", ".", "input", "transport", "=", "self", ".", "options", ".", "tran...
Send soap message. @param soapenv: A soap envelope to send. @type soapenv: L{Document} @return: The reply to the sent message. @rtype: I{builtin} or I{subclass of} L{Object}
[ "Send", "soap", "message", "." ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/client.py#L624-L671
heroku/sf-suds
suds/client.py
SoapClient.headers
def headers(self): """ Get http headers or the http/https request. @return: A dictionary of header/values. @rtype: dict """ action = self.method.soap.action stock = { 'Content-Type' : 'text/xml; charset=utf-8', 'SOAPAction': action } result = dict(stock, *...
python
def headers(self): """ Get http headers or the http/https request. @return: A dictionary of header/values. @rtype: dict """ action = self.method.soap.action stock = { 'Content-Type' : 'text/xml; charset=utf-8', 'SOAPAction': action } result = dict(stock, *...
[ "def", "headers", "(", "self", ")", ":", "action", "=", "self", ".", "method", ".", "soap", ".", "action", "stock", "=", "{", "'Content-Type'", ":", "'text/xml; charset=utf-8'", ",", "'SOAPAction'", ":", "action", "}", "result", "=", "dict", "(", "stock", ...
Get http headers or the http/https request. @return: A dictionary of header/values. @rtype: dict
[ "Get", "http", "headers", "or", "the", "http", "/", "https", "request", "." ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/client.py#L673-L683
heroku/sf-suds
suds/client.py
SoapClient.succeeded
def succeeded(self, binding, reply): """ Request succeeded, process the reply @param binding: The binding to be used to process the reply. @type binding: L{bindings.binding.Binding} @param reply: The raw reply text. @type reply: str @return: The method result. ...
python
def succeeded(self, binding, reply): """ Request succeeded, process the reply @param binding: The binding to be used to process the reply. @type binding: L{bindings.binding.Binding} @param reply: The raw reply text. @type reply: str @return: The method result. ...
[ "def", "succeeded", "(", "self", ",", "binding", ",", "reply", ")", ":", "log", ".", "debug", "(", "'http succeeded:\\n%s'", ",", "reply", ")", "plugins", "=", "PluginContainer", "(", "self", ".", "options", ".", "plugins", ")", "if", "len", "(", "reply"...
Request succeeded, process the reply @param binding: The binding to be used to process the reply. @type binding: L{bindings.binding.Binding} @param reply: The raw reply text. @type reply: str @return: The method result. @rtype: I{builtin}, L{Object} @raise WebFaul...
[ "Request", "succeeded", "process", "the", "reply" ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/client.py#L685-L710
heroku/sf-suds
suds/client.py
SoapClient.failed
def failed(self, binding, error): """ Request failed, process reply based on reason @param binding: The binding to be used to process the reply. @type binding: L{suds.bindings.binding.Binding} @param error: The http error message @type error: L{transport.TransportError} ...
python
def failed(self, binding, error): """ Request failed, process reply based on reason @param binding: The binding to be used to process the reply. @type binding: L{suds.bindings.binding.Binding} @param error: The http error message @type error: L{transport.TransportError} ...
[ "def", "failed", "(", "self", ",", "binding", ",", "error", ")", ":", "status", ",", "reason", "=", "(", "error", ".", "httpcode", ",", "tostr", "(", "error", ")", ")", "reply", "=", "error", ".", "fp", ".", "read", "(", ")", "log", ".", "debug",...
Request failed, process reply based on reason @param binding: The binding to be used to process the reply. @type binding: L{suds.bindings.binding.Binding} @param error: The http error message @type error: L{transport.TransportError}
[ "Request", "failed", "process", "reply", "based", "on", "reason" ]
train
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/client.py#L712-L733
asottile/cheetah_lint
cheetah_lint/flake.py
_get_line_no_from_comments
def _get_line_no_from_comments(py_line): """Return the line number parsed from the comment or 0.""" matched = LINECOL_COMMENT_RE.match(py_line) if matched: return int(matched.group(1)) else: return 0
python
def _get_line_no_from_comments(py_line): """Return the line number parsed from the comment or 0.""" matched = LINECOL_COMMENT_RE.match(py_line) if matched: return int(matched.group(1)) else: return 0
[ "def", "_get_line_no_from_comments", "(", "py_line", ")", ":", "matched", "=", "LINECOL_COMMENT_RE", ".", "match", "(", "py_line", ")", "if", "matched", ":", "return", "int", "(", "matched", ".", "group", "(", "1", ")", ")", "else", ":", "return", "0" ]
Return the line number parsed from the comment or 0.
[ "Return", "the", "line", "number", "parsed", "from", "the", "comment", "or", "0", "." ]
train
https://github.com/asottile/cheetah_lint/blob/1ecd54933e63073a7e77d65c8a2514a21e145c34/cheetah_lint/flake.py#L131-L137
asottile/cheetah_lint
cheetah_lint/flake.py
_find_bounds
def _find_bounds(py_line_no, py_by_line_no, cheetah_by_line_no): """Searches before and after in the python source to find comments which denote cheetah line numbers. If a lower bound is not found, 0 is substituted. If an upper bound is not found, len(cheetah lines) is returned. The result is a lower...
python
def _find_bounds(py_line_no, py_by_line_no, cheetah_by_line_no): """Searches before and after in the python source to find comments which denote cheetah line numbers. If a lower bound is not found, 0 is substituted. If an upper bound is not found, len(cheetah lines) is returned. The result is a lower...
[ "def", "_find_bounds", "(", "py_line_no", ",", "py_by_line_no", ",", "cheetah_by_line_no", ")", ":", "# Find lower bound", "for", "line_no", "in", "range", "(", "py_line_no", ",", "0", ",", "-", "1", ")", ":", "lower_bound", "=", "_get_line_no_from_comments", "(...
Searches before and after in the python source to find comments which denote cheetah line numbers. If a lower bound is not found, 0 is substituted. If an upper bound is not found, len(cheetah lines) is returned. The result is a lower-inclusive upper-exclusive range: [..., ...)
[ "Searches", "before", "and", "after", "in", "the", "python", "source", "to", "find", "comments", "which", "denote", "cheetah", "line", "numbers", ".", "If", "a", "lower", "bound", "is", "not", "found", "0", "is", "substituted", ".", "If", "an", "upper", ...
train
https://github.com/asottile/cheetah_lint/blob/1ecd54933e63073a7e77d65c8a2514a21e145c34/cheetah_lint/flake.py#L140-L166
asottile/cheetah_lint
cheetah_lint/flake.py
_find_fuzzy_line
def _find_fuzzy_line( py_line_no, py_by_line_no, cheetah_by_line_no, prefer_first ): """Attempt to fuzzily find matching lines.""" stripped_line = _fuzz_py_line(py_by_line_no[py_line_no]) cheetah_lower_bound, cheetah_upper_bound = _find_bounds( py_line_no, py_by_line_no, cheetah_by_line_no, ...
python
def _find_fuzzy_line( py_line_no, py_by_line_no, cheetah_by_line_no, prefer_first ): """Attempt to fuzzily find matching lines.""" stripped_line = _fuzz_py_line(py_by_line_no[py_line_no]) cheetah_lower_bound, cheetah_upper_bound = _find_bounds( py_line_no, py_by_line_no, cheetah_by_line_no, ...
[ "def", "_find_fuzzy_line", "(", "py_line_no", ",", "py_by_line_no", ",", "cheetah_by_line_no", ",", "prefer_first", ")", ":", "stripped_line", "=", "_fuzz_py_line", "(", "py_by_line_no", "[", "py_line_no", "]", ")", "cheetah_lower_bound", ",", "cheetah_upper_bound", "...
Attempt to fuzzily find matching lines.
[ "Attempt", "to", "fuzzily", "find", "matching", "lines", "." ]
train
https://github.com/asottile/cheetah_lint/blob/1ecd54933e63073a7e77d65c8a2514a21e145c34/cheetah_lint/flake.py#L184-L204
asottile/cheetah_lint
cheetah_lint/reorder_imports.py
perform_step
def perform_step(file_contents, step): """Performs a step of the transformation. :param text file_contents: Contends of the cheetah template :param function step: Function taking xmldoc and returning new contents :returns: new contents of the file. """ assert type(file_contents) is not bytes ...
python
def perform_step(file_contents, step): """Performs a step of the transformation. :param text file_contents: Contends of the cheetah template :param function step: Function taking xmldoc and returning new contents :returns: new contents of the file. """ assert type(file_contents) is not bytes ...
[ "def", "perform_step", "(", "file_contents", ",", "step", ")", ":", "assert", "type", "(", "file_contents", ")", "is", "not", "bytes", "xmldoc", "=", "parse", "(", "file_contents", ")", "return", "step", "(", "xmldoc", ")" ]
Performs a step of the transformation. :param text file_contents: Contends of the cheetah template :param function step: Function taking xmldoc and returning new contents :returns: new contents of the file.
[ "Performs", "a", "step", "of", "the", "transformation", "." ]
train
https://github.com/asottile/cheetah_lint/blob/1ecd54933e63073a7e77d65c8a2514a21e145c34/cheetah_lint/reorder_imports.py#L110-L119
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
_get_sender
def _get_sender(*sender_params, **kwargs): """ Utility function acting as a Sender factory - ensures senders don't get created twice of more for the same target server """ notify_func = kwargs['notify_func'] with _sender_instances_lock: existing_sender = _sender_instances.get(sender_para...
python
def _get_sender(*sender_params, **kwargs): """ Utility function acting as a Sender factory - ensures senders don't get created twice of more for the same target server """ notify_func = kwargs['notify_func'] with _sender_instances_lock: existing_sender = _sender_instances.get(sender_para...
[ "def", "_get_sender", "(", "*", "sender_params", ",", "*", "*", "kwargs", ")", ":", "notify_func", "=", "kwargs", "[", "'notify_func'", "]", "with", "_sender_instances_lock", ":", "existing_sender", "=", "_sender_instances", ".", "get", "(", "sender_params", ","...
Utility function acting as a Sender factory - ensures senders don't get created twice of more for the same target server
[ "Utility", "function", "acting", "as", "a", "Sender", "factory", "-", "ensures", "senders", "don", "t", "get", "created", "twice", "of", "more", "for", "the", "same", "target", "server" ]
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L642-L656
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
terminate
def terminate(): """ Stops all the active Senders by flushing the buffers and closing the underlying sockets """ with _sender_instances_lock: for sender_key, sender in _sender_instances.items(): sender.close() _sender_instances.clear()
python
def terminate(): """ Stops all the active Senders by flushing the buffers and closing the underlying sockets """ with _sender_instances_lock: for sender_key, sender in _sender_instances.items(): sender.close() _sender_instances.clear()
[ "def", "terminate", "(", ")", ":", "with", "_sender_instances_lock", ":", "for", "sender_key", ",", "sender", "in", "_sender_instances", ".", "items", "(", ")", ":", "sender", ".", "close", "(", ")", "_sender_instances", ".", "clear", "(", ")" ]
Stops all the active Senders by flushing the buffers and closing the underlying sockets
[ "Stops", "all", "the", "active", "Senders", "by", "flushing", "the", "buffers", "and", "closing", "the", "underlying", "sockets" ]
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L659-L667
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
PythonSDK._format_event
def _format_event(self, orig_event, external_metadata=None): """ Format the event to the expected Alooma format, packing it into a message field and adding metadata :param orig_event: The original event that was sent, should be dict, str or unic...
python
def _format_event(self, orig_event, external_metadata=None): """ Format the event to the expected Alooma format, packing it into a message field and adding metadata :param orig_event: The original event that was sent, should be dict, str or unic...
[ "def", "_format_event", "(", "self", ",", "orig_event", ",", "external_metadata", "=", "None", ")", ":", "event_wrapper", "=", "{", "}", "# Add ISO6801 timestamp and frame info", "timestamp", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", ".", "isofo...
Format the event to the expected Alooma format, packing it into a message field and adding metadata :param orig_event: The original event that was sent, should be dict, str or unicode. :param external_metadata: (Optional) a dict containing metadata to ...
[ "Format", "the", "event", "to", "the", "expected", "Alooma", "format", "packing", "it", "into", "a", "message", "field", "and", "adding", "metadata", ":", "param", "orig_event", ":", "The", "original", "event", "that", "was", "sent", "should", "be", "dict", ...
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L178-L219
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
PythonSDK.report
def report(self, event, metadata=None, block=None): """ Reports an event to Alooma by formatting it properly and placing it in the buffer to be sent by the Sender instance :param event: A dict / string representing an event :param metadata: (Optional) A dict with extra metadat...
python
def report(self, event, metadata=None, block=None): """ Reports an event to Alooma by formatting it properly and placing it in the buffer to be sent by the Sender instance :param event: A dict / string representing an event :param metadata: (Optional) A dict with extra metadat...
[ "def", "report", "(", "self", ",", "event", ",", "metadata", "=", "None", ",", "block", "=", "None", ")", ":", "# Don't allow reporting if the underlying sender is terminated", "if", "self", ".", "_sender", ".", "is_terminated", ":", "self", ".", "_notify", "(",...
Reports an event to Alooma by formatting it properly and placing it in the buffer to be sent by the Sender instance :param event: A dict / string representing an event :param metadata: (Optional) A dict with extra metadata to be attached to the event :param bl...
[ "Reports", "an", "event", "to", "Alooma", "by", "formatting", "it", "properly", "and", "placing", "it", "in", "the", "buffer", "to", "be", "sent", "by", "the", "Sender", "instance", ":", "param", "event", ":", "A", "dict", "/", "string", "representing", ...
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L221-L250
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
PythonSDK.report_many
def report_many(self, event_list, metadata=None, block=None): """ Reports all the given events to Alooma by formatting them properly and placing them in the buffer to be sent by the Sender instance :param event_list: A list of dicts / strings representing events :param metadata: ...
python
def report_many(self, event_list, metadata=None, block=None): """ Reports all the given events to Alooma by formatting them properly and placing them in the buffer to be sent by the Sender instance :param event_list: A list of dicts / strings representing events :param metadata: ...
[ "def", "report_many", "(", "self", ",", "event_list", ",", "metadata", "=", "None", ",", "block", "=", "None", ")", ":", "failed_list", "=", "[", "]", "for", "index", ",", "event", "in", "enumerate", "(", "event_list", ")", ":", "queued_successfully", "=...
Reports all the given events to Alooma by formatting them properly and placing them in the buffer to be sent by the Sender instance :param event_list: A list of dicts / strings representing events :param metadata: (Optional) A dict with extra metadata to be attached to t...
[ "Reports", "all", "the", "given", "events", "to", "Alooma", "by", "formatting", "them", "properly", "and", "placing", "them", "in", "the", "buffer", "to", "be", "sent", "by", "the", "Sender", "instance", ":", "param", "event_list", ":", "A", "list", "of", ...
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L252-L272
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
PythonSDK._notify
def _notify(self, log_level, message): """ Calls the callback function and logs messages using the PySDK logger :param log_level: An integer representing the log level, as specified in the Python `logging` library :param message: The actual message to be sent ...
python
def _notify(self, log_level, message): """ Calls the callback function and logs messages using the PySDK logger :param log_level: An integer representing the log level, as specified in the Python `logging` library :param message: The actual message to be sent ...
[ "def", "_notify", "(", "self", ",", "log_level", ",", "message", ")", ":", "timestamp", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "logger", ".", "log", "(", "log_level", ",", "str", "(", "message", ")", ")", "try", ":", "self", ".", ...
Calls the callback function and logs messages using the PySDK logger :param log_level: An integer representing the log level, as specified in the Python `logging` library :param message: The actual message to be sent to the logger and the `callback` ...
[ "Calls", "the", "callback", "function", "and", "logs", "messages", "using", "the", "PySDK", "logger", ":", "param", "log_level", ":", "An", "integer", "representing", "the", "log", "level", "as", "specified", "in", "the", "Python", "logging", "library", ":", ...
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L274-L287
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
_Sender._choose_host
def _choose_host(self): """ This method randomly chooses a server from the server list given as a parameter to the parent PythonSDK :return: The selected host to which the Sender will attempt to connect """ # If a host hasn't been chosen yet or there is o...
python
def _choose_host(self): """ This method randomly chooses a server from the server list given as a parameter to the parent PythonSDK :return: The selected host to which the Sender will attempt to connect """ # If a host hasn't been chosen yet or there is o...
[ "def", "_choose_host", "(", "self", ")", ":", "# If a host hasn't been chosen yet or there is only one host", "if", "len", "(", "self", ".", "_hosts", ")", "==", "1", "or", "self", ".", "_http_host", "is", "None", ":", "self", ".", "_http_host", "=", "self", "...
This method randomly chooses a server from the server list given as a parameter to the parent PythonSDK :return: The selected host to which the Sender will attempt to connect
[ "This", "method", "randomly", "chooses", "a", "server", "from", "the", "server", "list", "given", "as", "a", "parameter", "to", "the", "parent", "PythonSDK", ":", "return", ":", "The", "selected", "host", "to", "which", "the", "Sender", "will", "attempt", ...
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L365-L394
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
_Sender._verify_connection
def _verify_connection(self): """ Checks availability of the Alooma server :return: If the server is reachable, returns True :raises: If connection fails, raises exceptions.ConnectionFailed """ try: res = self._session.get(self._connection_validation_url, json...
python
def _verify_connection(self): """ Checks availability of the Alooma server :return: If the server is reachable, returns True :raises: If connection fails, raises exceptions.ConnectionFailed """ try: res = self._session.get(self._connection_validation_url, json...
[ "def", "_verify_connection", "(", "self", ")", ":", "try", ":", "res", "=", "self", ".", "_session", ".", "get", "(", "self", ".", "_connection_validation_url", ",", "json", "=", "{", "}", ")", "logger", ".", "debug", "(", "consts", ".", "LOG_MSG_VERIFYI...
Checks availability of the Alooma server :return: If the server is reachable, returns True :raises: If connection fails, raises exceptions.ConnectionFailed
[ "Checks", "availability", "of", "the", "Alooma", "server", ":", "return", ":", "If", "the", "server", "is", "reachable", "returns", "True", ":", "raises", ":", "If", "connection", "fails", "raises", "exceptions", ".", "ConnectionFailed" ]
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L396-L421
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
_Sender._verify_token
def _verify_token(self): """ Verifies the validity of the token against the remote server :return: True if the token is valid, else raises exceptions.BadToken """ res = self._session.get(self._token_verification_url) if not res.ok: raise exceptions.BadToken(co...
python
def _verify_token(self): """ Verifies the validity of the token against the remote server :return: True if the token is valid, else raises exceptions.BadToken """ res = self._session.get(self._token_verification_url) if not res.ok: raise exceptions.BadToken(co...
[ "def", "_verify_token", "(", "self", ")", ":", "res", "=", "self", ".", "_session", ".", "get", "(", "self", ".", "_token_verification_url", ")", "if", "not", "res", ".", "ok", ":", "raise", "exceptions", ".", "BadToken", "(", "consts", ".", "LOG_MSG_BAD...
Verifies the validity of the token against the remote server :return: True if the token is valid, else raises exceptions.BadToken
[ "Verifies", "the", "validity", "of", "the", "token", "against", "the", "remote", "server", ":", "return", ":", "True", "if", "the", "token", "is", "valid", "else", "raises", "exceptions", ".", "BadToken" ]
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L423-L431
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
_Sender._send_batch
def _send_batch(self, batch): """ Sends a batch to the destination server via HTTP REST API """ try: json_batch = '[' + ','.join(batch) + ']' # Make JSON array string logger.debug(consts.LOG_MSG_SENDING_BATCH, len(batch), len(json_batch),...
python
def _send_batch(self, batch): """ Sends a batch to the destination server via HTTP REST API """ try: json_batch = '[' + ','.join(batch) + ']' # Make JSON array string logger.debug(consts.LOG_MSG_SENDING_BATCH, len(batch), len(json_batch),...
[ "def", "_send_batch", "(", "self", ",", "batch", ")", ":", "try", ":", "json_batch", "=", "'['", "+", "','", ".", "join", "(", "batch", ")", "+", "']'", "# Make JSON array string", "logger", ".", "debug", "(", "consts", ".", "LOG_MSG_SENDING_BATCH", ",", ...
Sends a batch to the destination server via HTTP REST API
[ "Sends", "a", "batch", "to", "the", "destination", "server", "via", "HTTP", "REST", "API" ]
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L457-L479
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
_Sender._sender_main
def _sender_main(self): """ Runs on a pysdk_sender_thread and handles sending events to the Alooma server. Events are sent every <self._batch_interval> seconds or whenever batch size reaches <self._batch_size> """ if not self._http_host: self._choose_host() ...
python
def _sender_main(self): """ Runs on a pysdk_sender_thread and handles sending events to the Alooma server. Events are sent every <self._batch_interval> seconds or whenever batch size reaches <self._batch_size> """ if not self._http_host: self._choose_host() ...
[ "def", "_sender_main", "(", "self", ")", ":", "if", "not", "self", ".", "_http_host", ":", "self", ".", "_choose_host", "(", ")", "last_batch_time", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "while", "not", "(", "self", ".", "_is_termina...
Runs on a pysdk_sender_thread and handles sending events to the Alooma server. Events are sent every <self._batch_interval> seconds or whenever batch size reaches <self._batch_size>
[ "Runs", "on", "a", "pysdk_sender_thread", "and", "handles", "sending", "events", "to", "the", "Alooma", "server", ".", "Events", "are", "sent", "every", "<self", ".", "_batch_interval", ">", "seconds", "or", "whenever", "batch", "size", "reaches", "<self", "."...
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L517-L556
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
_Sender.enqueue_event
def enqueue_event(self, event, block): """ Enqueues an event in the buffer to be sent to the Alooma server :param event: A dict representing a formatted event to be sent by the sender :param block: Whether or not we should block if the event buffer is full :...
python
def enqueue_event(self, event, block): """ Enqueues an event in the buffer to be sent to the Alooma server :param event: A dict representing a formatted event to be sent by the sender :param block: Whether or not we should block if the event buffer is full :...
[ "def", "enqueue_event", "(", "self", ",", "event", ",", "block", ")", ":", "try", ":", "self", ".", "_event_queue", ".", "put_nowait", "(", "event", ")", "if", "self", ".", "_notified_buffer_full", ":", "# Non-blocking and buffer was full", "self", ".", "_noti...
Enqueues an event in the buffer to be sent to the Alooma server :param event: A dict representing a formatted event to be sent by the sender :param block: Whether or not we should block if the event buffer is full :return: True if the event was enqueued successfully, else F...
[ "Enqueues", "an", "event", "in", "the", "buffer", "to", "be", "sent", "to", "the", "Alooma", "server", ":", "param", "event", ":", "A", "dict", "representing", "a", "formatted", "event", "to", "be", "sent", "by", "the", "sender", ":", "param", "block", ...
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L558-L582
Aloomaio/python-sdk
alooma_pysdk/alooma_pysdk.py
_Sender.__get_event
def __get_event(self, block=True, timeout=1): """ Retrieves an event. If self._exceeding_event is not None, it'll be returned. Otherwise, an event is dequeued from the event buffer. If The event which was retrieved is bigger than the permitted batch size, it'll be omitted, and th...
python
def __get_event(self, block=True, timeout=1): """ Retrieves an event. If self._exceeding_event is not None, it'll be returned. Otherwise, an event is dequeued from the event buffer. If The event which was retrieved is bigger than the permitted batch size, it'll be omitted, and th...
[ "def", "__get_event", "(", "self", ",", "block", "=", "True", ",", "timeout", "=", "1", ")", ":", "while", "True", ":", "if", "self", ".", "_exceeding_event", ":", "# An event was omitted from last batch", "event", "=", "self", ".", "_exceeding_event", "self",...
Retrieves an event. If self._exceeding_event is not None, it'll be returned. Otherwise, an event is dequeued from the event buffer. If The event which was retrieved is bigger than the permitted batch size, it'll be omitted, and the next event in the event buffer is returned
[ "Retrieves", "an", "event", ".", "If", "self", ".", "_exceeding_event", "is", "not", "None", "it", "ll", "be", "returned", ".", "Otherwise", "an", "event", "is", "dequeued", "from", "the", "event", "buffer", ".", "If", "The", "event", "which", "was", "re...
train
https://github.com/Aloomaio/python-sdk/blob/e6e7322d0b23d90b1ff0320e9a9c431c82c0c277/alooma_pysdk/alooma_pysdk.py#L591-L614
limdauto/drf_openapi
drf_openapi/entities.py
OpenApiSchemaGenerator.get_links
def get_links(self, request=None): """ Return a dictionary containing all the links that should be included in the API schema. """ links = LinkNode() # Generate (path, method, view) given (path, method, callback). paths = [] view_endpoints = [] fo...
python
def get_links(self, request=None): """ Return a dictionary containing all the links that should be included in the API schema. """ links = LinkNode() # Generate (path, method, view) given (path, method, callback). paths = [] view_endpoints = [] fo...
[ "def", "get_links", "(", "self", ",", "request", "=", "None", ")", ":", "links", "=", "LinkNode", "(", ")", "# Generate (path, method, view) given (path, method, callback).", "paths", "=", "[", "]", "view_endpoints", "=", "[", "]", "for", "path", ",", "method", ...
Return a dictionary containing all the links that should be included in the API schema.
[ "Return", "a", "dictionary", "containing", "all", "the", "links", "that", "should", "be", "included", "in", "the", "API", "schema", "." ]
train
https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/entities.py#L111-L144
limdauto/drf_openapi
drf_openapi/entities.py
OpenApiSchemaGenerator.get_path_fields
def get_path_fields(self, path, method, view): """ Return a list of `coreapi.Field` instances corresponding to any templated path variables. """ model = getattr(getattr(view, 'queryset', None), 'model', None) fields = [] for variable in uritemplate.variables(path...
python
def get_path_fields(self, path, method, view): """ Return a list of `coreapi.Field` instances corresponding to any templated path variables. """ model = getattr(getattr(view, 'queryset', None), 'model', None) fields = [] for variable in uritemplate.variables(path...
[ "def", "get_path_fields", "(", "self", ",", "path", ",", "method", ",", "view", ")", ":", "model", "=", "getattr", "(", "getattr", "(", "view", ",", "'queryset'", ",", "None", ")", ",", "'model'", ",", "None", ")", "fields", "=", "[", "]", "for", "...
Return a list of `coreapi.Field` instances corresponding to any templated path variables.
[ "Return", "a", "list", "of", "coreapi", ".", "Field", "instances", "corresponding", "to", "any", "templated", "path", "variables", "." ]
train
https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/entities.py#L231-L276
limdauto/drf_openapi
drf_openapi/entities.py
OpenApiSchemaGenerator.get_serializer_class
def get_serializer_class(self, view, method_func): """ Try to get the serializer class from view method. If view method don't have request serializer, fallback to serializer_class on view class """ if hasattr(method_func, 'request_serializer'): return getattr(method_f...
python
def get_serializer_class(self, view, method_func): """ Try to get the serializer class from view method. If view method don't have request serializer, fallback to serializer_class on view class """ if hasattr(method_func, 'request_serializer'): return getattr(method_f...
[ "def", "get_serializer_class", "(", "self", ",", "view", ",", "method_func", ")", ":", "if", "hasattr", "(", "method_func", ",", "'request_serializer'", ")", ":", "return", "getattr", "(", "method_func", ",", "'request_serializer'", ")", "if", "hasattr", "(", ...
Try to get the serializer class from view method. If view method don't have request serializer, fallback to serializer_class on view class
[ "Try", "to", "get", "the", "serializer", "class", "from", "view", "method", ".", "If", "view", "method", "don", "t", "have", "request", "serializer", "fallback", "to", "serializer_class", "on", "view", "class" ]
train
https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/entities.py#L278-L292
limdauto/drf_openapi
drf_openapi/entities.py
OpenApiSchemaGenerator.fallback_schema_from_field
def fallback_schema_from_field(self, field): """ Fallback schema for field that isn't inspected properly by DRF and probably won't land in upstream canon due to its hacky nature only for doc purposes """ title = force_text(field.label) if field.label else '' description = force_t...
python
def fallback_schema_from_field(self, field): """ Fallback schema for field that isn't inspected properly by DRF and probably won't land in upstream canon due to its hacky nature only for doc purposes """ title = force_text(field.label) if field.label else '' description = force_t...
[ "def", "fallback_schema_from_field", "(", "self", ",", "field", ")", ":", "title", "=", "force_text", "(", "field", ".", "label", ")", "if", "field", ".", "label", "else", "''", "description", "=", "force_text", "(", "field", ".", "help_text", ")", "if", ...
Fallback schema for field that isn't inspected properly by DRF and probably won't land in upstream canon due to its hacky nature only for doc purposes
[ "Fallback", "schema", "for", "field", "that", "isn", "t", "inspected", "properly", "by", "DRF", "and", "probably", "won", "t", "land", "in", "upstream", "canon", "due", "to", "its", "hacky", "nature", "only", "for", "doc", "purposes" ]
train
https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/entities.py#L294-L308
limdauto/drf_openapi
drf_openapi/entities.py
OpenApiSchemaGenerator.get_serializer_fields
def get_serializer_fields(self, path, method, view, version=None, method_func=None): """ Return a list of `coreapi.Field` instances corresponding to any request body input, as determined by the serializer class. """ if method in ('PUT', 'PATCH', 'POST'): location = 'f...
python
def get_serializer_fields(self, path, method, view, version=None, method_func=None): """ Return a list of `coreapi.Field` instances corresponding to any request body input, as determined by the serializer class. """ if method in ('PUT', 'PATCH', 'POST'): location = 'f...
[ "def", "get_serializer_fields", "(", "self", ",", "path", ",", "method", ",", "view", ",", "version", "=", "None", ",", "method_func", "=", "None", ")", ":", "if", "method", "in", "(", "'PUT'", ",", "'PATCH'", ",", "'POST'", ")", ":", "location", "=", ...
Return a list of `coreapi.Field` instances corresponding to any request body input, as determined by the serializer class.
[ "Return", "a", "list", "of", "coreapi", ".", "Field", "instances", "corresponding", "to", "any", "request", "body", "input", "as", "determined", "by", "the", "serializer", "class", "." ]
train
https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/entities.py#L310-L356
limdauto/drf_openapi
examples/snippets/serializers.py
SnippetSerializerV1.update
def update(self, instance, validated_data): """ Update and return an existing `Snippet` instance, given the validated data. """ instance.title = validated_data.get('title', instance.title) instance.code = validated_data.get('code', instance.code) instance.linenos = valida...
python
def update(self, instance, validated_data): """ Update and return an existing `Snippet` instance, given the validated data. """ instance.title = validated_data.get('title', instance.title) instance.code = validated_data.get('code', instance.code) instance.linenos = valida...
[ "def", "update", "(", "self", ",", "instance", ",", "validated_data", ")", ":", "instance", ".", "title", "=", "validated_data", ".", "get", "(", "'title'", ",", "instance", ".", "title", ")", "instance", ".", "code", "=", "validated_data", ".", "get", "...
Update and return an existing `Snippet` instance, given the validated data.
[ "Update", "and", "return", "an", "existing", "Snippet", "instance", "given", "the", "validated", "data", "." ]
train
https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/examples/snippets/serializers.py#L39-L49
limdauto/drf_openapi
drf_openapi/codec.py
_generate_openapi_object
def _generate_openapi_object(document): """ Generates root of the Swagger spec. """ parsed_url = urlparse.urlparse(document.url) swagger = OrderedDict() swagger['swagger'] = '2.0' swagger['info'] = OrderedDict() swagger['info']['title'] = document.title swagger['info']['description...
python
def _generate_openapi_object(document): """ Generates root of the Swagger spec. """ parsed_url = urlparse.urlparse(document.url) swagger = OrderedDict() swagger['swagger'] = '2.0' swagger['info'] = OrderedDict() swagger['info']['title'] = document.title swagger['info']['description...
[ "def", "_generate_openapi_object", "(", "document", ")", ":", "parsed_url", "=", "urlparse", ".", "urlparse", "(", "document", ".", "url", ")", "swagger", "=", "OrderedDict", "(", ")", "swagger", "[", "'swagger'", "]", "=", "'2.0'", "swagger", "[", "'info'",...
Generates root of the Swagger spec.
[ "Generates", "root", "of", "the", "Swagger", "spec", "." ]
train
https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/codec.py#L120-L141
limdauto/drf_openapi
drf_openapi/codec.py
_get_responses
def _get_responses(link): """ Returns an OpenApi-compliant response """ template = link.response_schema template.update({'description': 'Success'}) res = {200: template} res.update(link.error_status_codes) return res
python
def _get_responses(link): """ Returns an OpenApi-compliant response """ template = link.response_schema template.update({'description': 'Success'}) res = {200: template} res.update(link.error_status_codes) return res
[ "def", "_get_responses", "(", "link", ")", ":", "template", "=", "link", ".", "response_schema", "template", ".", "update", "(", "{", "'description'", ":", "'Success'", "}", ")", "res", "=", "{", "200", ":", "template", "}", "res", ".", "update", "(", ...
Returns an OpenApi-compliant response
[ "Returns", "an", "OpenApi", "-", "compliant", "response" ]
train
https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/codec.py#L183-L190
limdauto/drf_openapi
drf_openapi/codec.py
_get_parameters
def _get_parameters(link, encoding): """ Generates Swagger Parameter Item object. """ parameters = [] properties = {} required = [] for field in link.fields: parser = OpenApiFieldParser(link, field) if parser.location == 'form': if encoding in ('multipart/form-da...
python
def _get_parameters(link, encoding): """ Generates Swagger Parameter Item object. """ parameters = [] properties = {} required = [] for field in link.fields: parser = OpenApiFieldParser(link, field) if parser.location == 'form': if encoding in ('multipart/form-da...
[ "def", "_get_parameters", "(", "link", ",", "encoding", ")", ":", "parameters", "=", "[", "]", "properties", "=", "{", "}", "required", "=", "[", "]", "for", "field", "in", "link", ".", "fields", ":", "parser", "=", "OpenApiFieldParser", "(", "link", "...
Generates Swagger Parameter Item object.
[ "Generates", "Swagger", "Parameter", "Item", "object", "." ]
train
https://github.com/limdauto/drf_openapi/blob/1673c6e039eec7f089336a83bdc31613f32f7e21/drf_openapi/codec.py#L216-L254
demianbrecht/sanction
sanction/__init__.py
Client.auth_uri
def auth_uri(self, redirect_uri=None, scope=None, scope_delim=None, state=None, **kwargs): """ Builds the auth URI for the authorization endpoint :param scope: (optional) The `scope` parameter to pass for authorization. The format should match that expected by ...
python
def auth_uri(self, redirect_uri=None, scope=None, scope_delim=None, state=None, **kwargs): """ Builds the auth URI for the authorization endpoint :param scope: (optional) The `scope` parameter to pass for authorization. The format should match that expected by ...
[ "def", "auth_uri", "(", "self", ",", "redirect_uri", "=", "None", ",", "scope", "=", "None", ",", "scope_delim", "=", "None", ",", "state", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "{", "'client_id'", ":", "self",...
Builds the auth URI for the authorization endpoint :param scope: (optional) The `scope` parameter to pass for authorization. The format should match that expected by the provider (i.e. Facebook expects comma-delimited, while Google expects space...
[ "Builds", "the", "auth", "URI", "for", "the", "authorization", "endpoint" ]
train
https://github.com/demianbrecht/sanction/blob/08575f149c7ece20c902148c4d1576ab162ae0a8/sanction/__init__.py#L63-L93
demianbrecht/sanction
sanction/__init__.py
Client.request_token
def request_token(self, parser=None, redirect_uri=None, **kwargs): """ Request an access token from the token endpoint. This is largely a helper method and expects the client code to understand what the server expects. Anything that's passed into ``**kwargs`` will be sent (``urlencode``d...
python
def request_token(self, parser=None, redirect_uri=None, **kwargs): """ Request an access token from the token endpoint. This is largely a helper method and expects the client code to understand what the server expects. Anything that's passed into ``**kwargs`` will be sent (``urlencode``d...
[ "def", "request_token", "(", "self", ",", "parser", "=", "None", ",", "redirect_uri", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "kwargs", "and", "kwargs", "or", "{", "}", "parser", "=", "parser", "or", "_default_parser", "kwargs", ...
Request an access token from the token endpoint. This is largely a helper method and expects the client code to understand what the server expects. Anything that's passed into ``**kwargs`` will be sent (``urlencode``d) to the endpoint. Client secret and client ID are automatically includ...
[ "Request", "an", "access", "token", "from", "the", "token", "endpoint", ".", "This", "is", "largely", "a", "helper", "method", "and", "expects", "the", "client", "code", "to", "understand", "what", "the", "server", "expects", ".", "Anything", "that", "s", ...
train
https://github.com/demianbrecht/sanction/blob/08575f149c7ece20c902148c4d1576ab162ae0a8/sanction/__init__.py#L95-L147
demianbrecht/sanction
sanction/__init__.py
Client.request
def request(self, url, method=None, data=None, headers=None, parser=None): """ Request user data from the resource endpoint :param url: The path to the resource and querystring if required :param method: HTTP method. Defaults to ``GET`` unless data is not None in which ca...
python
def request(self, url, method=None, data=None, headers=None, parser=None): """ Request user data from the resource endpoint :param url: The path to the resource and querystring if required :param method: HTTP method. Defaults to ``GET`` unless data is not None in which ca...
[ "def", "request", "(", "self", ",", "url", ",", "method", "=", "None", ",", "data", "=", "None", ",", "headers", "=", "None", ",", "parser", "=", "None", ")", ":", "assert", "self", ".", "access_token", "is", "not", "None", "parser", "=", "parser", ...
Request user data from the resource endpoint :param url: The path to the resource and querystring if required :param method: HTTP method. Defaults to ``GET`` unless data is not None in which case it defaults to ``POST`` :param data: Data to be POSTed to the resource endpoi...
[ "Request", "user", "data", "from", "the", "resource", "endpoint", ":", "param", "url", ":", "The", "path", "to", "the", "resource", "and", "querystring", "if", "required", ":", "param", "method", ":", "HTTP", "method", ".", "Defaults", "to", "GET", "unless...
train
https://github.com/demianbrecht/sanction/blob/08575f149c7ece20c902148c4d1576ab162ae0a8/sanction/__init__.py#L153-L184
fermiPy/fermipy
fermipy/diffuse/fitting.py
build_srcdict
def build_srcdict(gta, prop): """Build a dictionary that maps from source name to the value of a source property Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object prop : str The name of the property we are mapping Returns ------- odict : dict ...
python
def build_srcdict(gta, prop): """Build a dictionary that maps from source name to the value of a source property Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object prop : str The name of the property we are mapping Returns ------- odict : dict ...
[ "def", "build_srcdict", "(", "gta", ",", "prop", ")", ":", "o", "=", "{", "}", "for", "s", "in", "gta", ".", "roi", ".", "sources", ":", "o", "[", "s", ".", "name", "]", "=", "s", "[", "prop", "]", "return", "o" ]
Build a dictionary that maps from source name to the value of a source property Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object prop : str The name of the property we are mapping Returns ------- odict : dict Dictionary that maps from source ...
[ "Build", "a", "dictionary", "that", "maps", "from", "source", "name", "to", "the", "value", "of", "a", "source", "property" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/fitting.py#L33-L56
fermiPy/fermipy
fermipy/diffuse/fitting.py
get_src_names
def get_src_names(gta): """Build and return a list of source name Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object Returns ------- l : list Names of the source """ o = [] for s in gta.roi.sources: o += [s.name] return sorted(o)
python
def get_src_names(gta): """Build and return a list of source name Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object Returns ------- l : list Names of the source """ o = [] for s in gta.roi.sources: o += [s.name] return sorted(o)
[ "def", "get_src_names", "(", "gta", ")", ":", "o", "=", "[", "]", "for", "s", "in", "gta", ".", "roi", ".", "sources", ":", "o", "+=", "[", "s", ".", "name", "]", "return", "sorted", "(", "o", ")" ]
Build and return a list of source name Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object Returns ------- l : list Names of the source
[ "Build", "and", "return", "a", "list", "of", "source", "name" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/fitting.py#L59-L79
fermiPy/fermipy
fermipy/diffuse/fitting.py
set_wts_get_npred_wt
def set_wts_get_npred_wt(gta, maskname): """Set a weights file and get the weighted npred for all the sources Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object maskname : str The path to the file with the mask Returns ------- odict : dict ...
python
def set_wts_get_npred_wt(gta, maskname): """Set a weights file and get the weighted npred for all the sources Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object maskname : str The path to the file with the mask Returns ------- odict : dict ...
[ "def", "set_wts_get_npred_wt", "(", "gta", ",", "maskname", ")", ":", "if", "is_null", "(", "maskname", ")", ":", "maskname", "=", "None", "gta", ".", "set_weights_map", "(", "maskname", ")", "for", "name", "in", "gta", ".", "like", ".", "sourceNames", "...
Set a weights file and get the weighted npred for all the sources Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object maskname : str The path to the file with the mask Returns ------- odict : dict Dictionary mapping from source name to weighted ...
[ "Set", "a", "weights", "file", "and", "get", "the", "weighted", "npred", "for", "all", "the", "sources" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/fitting.py#L82-L109
fermiPy/fermipy
fermipy/diffuse/fitting.py
snapshot
def snapshot(gta, plotter, key, do_weighted=True, make_plots=True): """Take a snapshot of the ROI Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object plotter : `fermipy.plotting.AnalysisPlotter` The object that makes the plots key : str Key for this s...
python
def snapshot(gta, plotter, key, do_weighted=True, make_plots=True): """Take a snapshot of the ROI Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object plotter : `fermipy.plotting.AnalysisPlotter` The object that makes the plots key : str Key for this s...
[ "def", "snapshot", "(", "gta", ",", "plotter", ",", "key", ",", "do_weighted", "=", "True", ",", "make_plots", "=", "True", ")", ":", "gta", ".", "write_roi", "(", "key", ",", "save_model_map", "=", "True", ",", "make_plots", "=", "make_plots", ",", "s...
Take a snapshot of the ROI Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object plotter : `fermipy.plotting.AnalysisPlotter` The object that makes the plots key : str Key for this snapshot, used to create filenames do_weighted : bool If True, ...
[ "Take", "a", "snapshot", "of", "the", "ROI" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/fitting.py#L112-L142
fermiPy/fermipy
fermipy/diffuse/fitting.py
get_unchanged
def get_unchanged(src_list, npred_dict_new, npred_dict_old, npred_threshold=1e4, frac_threshold=0.9): """Compare two dictionarys of npreds, and get the list of sources than have changed less that set thresholds Parameters ---------- src_list : ...
python
def get_unchanged(src_list, npred_dict_new, npred_dict_old, npred_threshold=1e4, frac_threshold=0.9): """Compare two dictionarys of npreds, and get the list of sources than have changed less that set thresholds Parameters ---------- src_list : ...
[ "def", "get_unchanged", "(", "src_list", ",", "npred_dict_new", ",", "npred_dict_old", ",", "npred_threshold", "=", "1e4", ",", "frac_threshold", "=", "0.9", ")", ":", "o", "=", "[", "]", "for", "s", "in", "src_list", ":", "npred_new", "=", "npred_dict_new",...
Compare two dictionarys of npreds, and get the list of sources than have changed less that set thresholds Parameters ---------- src_list : list List of sources to examine npred_dict_new : dict Dictionary mapping source name to npred for the current weights file npred_dict_old...
[ "Compare", "two", "dictionarys", "of", "npreds", "and", "get", "the", "list", "of", "sources", "than", "have", "changed", "less", "that", "set", "thresholds" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/fitting.py#L145-L191
fermiPy/fermipy
fermipy/diffuse/fitting.py
FitDiffuse.run_analysis
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) if not HAVE_ST: raise RuntimeError( "Trying to run fermipy analysis, but don't have ST") if args.load_baseline: gta = GTAnalysis.create(args.roi_baseline, ...
python
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) if not HAVE_ST: raise RuntimeError( "Trying to run fermipy analysis, but don't have ST") if args.load_baseline: gta = GTAnalysis.create(args.roi_baseline, ...
[ "def", "run_analysis", "(", "self", ",", "argv", ")", ":", "args", "=", "self", ".", "_parser", ".", "parse_args", "(", "argv", ")", "if", "not", "HAVE_ST", ":", "raise", "RuntimeError", "(", "\"Trying to run fermipy analysis, but don't have ST\"", ")", "if", ...
Run this analysis
[ "Run", "this", "analysis" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/fitting.py#L214-L276
fermiPy/fermipy
fermipy/diffuse/fitting.py
FitDiffuse_SG.build_job_configs
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} # Tweak the batch job args try: self._interface._lsf_args.update(dict(n=2)) self._interface._lsf_args.update(dict(R='\"select[rhel60&&!fell] -R span[hosts=1]\"')) ...
python
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} # Tweak the batch job args try: self._interface._lsf_args.update(dict(n=2)) self._interface._lsf_args.update(dict(R='\"select[rhel60&&!fell] -R span[hosts=1]\"')) ...
[ "def", "build_job_configs", "(", "self", ",", "args", ")", ":", "job_configs", "=", "{", "}", "# Tweak the batch job args", "try", ":", "self", ".", "_interface", ".", "_lsf_args", ".", "update", "(", "dict", "(", "n", "=", "2", ")", ")", "self", ".", ...
Hook to build job configurations
[ "Hook", "to", "build", "job", "configurations" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/fitting.py#L303-L336
fermiPy/fermipy
fermipy/scripts/coadd.py
main
def main(): """ Main function for command line usage """ usage = "usage: %(prog)s [options] " description = "Merge a set of Fermi-LAT files." parser = argparse.ArgumentParser(usage=usage, description=description) parser.add_argument('-o', '--output', default=None, type=str, ...
python
def main(): """ Main function for command line usage """ usage = "usage: %(prog)s [options] " description = "Merge a set of Fermi-LAT files." parser = argparse.ArgumentParser(usage=usage, description=description) parser.add_argument('-o', '--output', default=None, type=str, ...
[ "def", "main", "(", ")", ":", "usage", "=", "\"usage: %(prog)s [options] \"", "description", "=", "\"Merge a set of Fermi-LAT files.\"", "parser", "=", "argparse", ".", "ArgumentParser", "(", "usage", "=", "usage", ",", "description", "=", "description", ")", "parse...
Main function for command line usage
[ "Main", "function", "for", "command", "line", "usage" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/coadd.py#L12-L37
fermiPy/fermipy
fermipy/jobs/native_impl.py
get_native_default_args
def get_native_default_args(): """ Get the correct set of batch jobs arguments. """ native_default_args = dict(max_jobs=500, time_per_cycle=15, jobs_per_cycle=20, max_job_age=90, no_ba...
python
def get_native_default_args(): """ Get the correct set of batch jobs arguments. """ native_default_args = dict(max_jobs=500, time_per_cycle=15, jobs_per_cycle=20, max_job_age=90, no_ba...
[ "def", "get_native_default_args", "(", ")", ":", "native_default_args", "=", "dict", "(", "max_jobs", "=", "500", ",", "time_per_cycle", "=", "15", ",", "jobs_per_cycle", "=", "20", ",", "max_job_age", "=", "90", ",", "no_batch", "=", "False", ")", "return",...
Get the correct set of batch jobs arguments.
[ "Get", "the", "correct", "set", "of", "batch", "jobs", "arguments", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/native_impl.py#L123-L131
fermiPy/fermipy
fermipy/jobs/native_impl.py
NativeInterface.dispatch_job_hook
def dispatch_job_hook(self, link, key, job_config, logfile, stream=sys.stdout): """Send a single job to be executed Parameters ---------- link : `fermipy.jobs.chain.Link` The link used to invoke the command we are running key : str A string that identif...
python
def dispatch_job_hook(self, link, key, job_config, logfile, stream=sys.stdout): """Send a single job to be executed Parameters ---------- link : `fermipy.jobs.chain.Link` The link used to invoke the command we are running key : str A string that identif...
[ "def", "dispatch_job_hook", "(", "self", ",", "link", ",", "key", ",", "job_config", ",", "logfile", ",", "stream", "=", "sys", ".", "stdout", ")", ":", "full_sub_dict", "=", "job_config", ".", "copy", "(", ")", "full_command", "=", "\"%s >& %s\"", "%", ...
Send a single job to be executed Parameters ---------- link : `fermipy.jobs.chain.Link` The link used to invoke the command we are running key : str A string that identifies this particular instance of the job job_config : dict A dictionrar...
[ "Send", "a", "single", "job", "to", "be", "executed" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/native_impl.py#L39-L72
fermiPy/fermipy
fermipy/logger.py
log_level
def log_level(level): """This is a function that returns a python like level from a HEASOFT like level. """ levels_dict = {0: 50, 1: 40, 2: 30, 3: 20, 4: 10} if not isinstance(level, int): level = int(level) i...
python
def log_level(level): """This is a function that returns a python like level from a HEASOFT like level. """ levels_dict = {0: 50, 1: 40, 2: 30, 3: 20, 4: 10} if not isinstance(level, int): level = int(level) i...
[ "def", "log_level", "(", "level", ")", ":", "levels_dict", "=", "{", "0", ":", "50", ",", "1", ":", "40", ",", "2", ":", "30", ",", "3", ":", "20", ",", "4", ":", "10", "}", "if", "not", "isinstance", "(", "level", ",", "int", ")", ":", "le...
This is a function that returns a python like level from a HEASOFT like level.
[ "This", "is", "a", "function", "that", "returns", "a", "python", "like", "level", "from", "a", "HEASOFT", "like", "level", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/logger.py#L11-L28
fermiPy/fermipy
fermipy/logger.py
Logger.setup
def setup(config=None, logfile=None): """This method sets up the default configuration of the logger. Once this method is called all subsequent instances Logger instances will inherit this configuration.""" if config is None: configpath = os.path.join(fermipy.PACKAGE_ROOT, ...
python
def setup(config=None, logfile=None): """This method sets up the default configuration of the logger. Once this method is called all subsequent instances Logger instances will inherit this configuration.""" if config is None: configpath = os.path.join(fermipy.PACKAGE_ROOT, ...
[ "def", "setup", "(", "config", "=", "None", ",", "logfile", "=", "None", ")", ":", "if", "config", "is", "None", ":", "configpath", "=", "os", ".", "path", ".", "join", "(", "fermipy", ".", "PACKAGE_ROOT", ",", "'config'", ",", "'logging.yaml'", ")", ...
This method sets up the default configuration of the logger. Once this method is called all subsequent instances Logger instances will inherit this configuration.
[ "This", "method", "sets", "up", "the", "default", "configuration", "of", "the", "logger", ".", "Once", "this", "method", "is", "called", "all", "subsequent", "instances", "Logger", "instances", "will", "inherit", "this", "configuration", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/logger.py#L36-L53
fermiPy/fermipy
fermipy/logger.py
Logger.configure
def configure(name, logfile, loglevel=logging.DEBUG): """Create a python logger instance and configure it. Parameters ---------- name : str Logger name. logfile : str Path to the log file. loglevel : int Default log level for STDOUT....
python
def configure(name, logfile, loglevel=logging.DEBUG): """Create a python logger instance and configure it. Parameters ---------- name : str Logger name. logfile : str Path to the log file. loglevel : int Default log level for STDOUT....
[ "def", "configure", "(", "name", ",", "logfile", ",", "loglevel", "=", "logging", ".", "DEBUG", ")", ":", "# logging.config.dictConfig({", "# 'version': 1,", "# 'disable_existing_loggers': False})", "logger", "=", "logging", ".", "getLog...
Create a python logger instance and configure it. Parameters ---------- name : str Logger name. logfile : str Path to the log file. loglevel : int Default log level for STDOUT.
[ "Create", "a", "python", "logger", "instance", "and", "configure", "it", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/logger.py#L62-L114
fermiPy/fermipy
fermipy/jobs/link.py
extract_arguments
def extract_arguments(args, defaults): """Extract a set of arguments from a large dictionary Parameters ---------- args : dict Dictionary with the arguments values to use defaults : dict Dictionary with all the argument to extract, and default values for each Returns ----...
python
def extract_arguments(args, defaults): """Extract a set of arguments from a large dictionary Parameters ---------- args : dict Dictionary with the arguments values to use defaults : dict Dictionary with all the argument to extract, and default values for each Returns ----...
[ "def", "extract_arguments", "(", "args", ",", "defaults", ")", ":", "out_dict", "=", "convert_option_dict_to_dict", "(", "defaults", ")", "for", "key", "in", "defaults", ".", "keys", "(", ")", ":", "mapped_val", "=", "args", ".", "get", "(", "key", ",", ...
Extract a set of arguments from a large dictionary Parameters ---------- args : dict Dictionary with the arguments values to use defaults : dict Dictionary with all the argument to extract, and default values for each Returns ------- out_dict : dict A dictionary ...
[ "Extract", "a", "set", "of", "arguments", "from", "a", "large", "dictionary" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L24-L50
fermiPy/fermipy
fermipy/jobs/link.py
check_files
def check_files(filelist, file_stage_manager=None, return_found=True, return_missing=True): """Check that all files in a list exist Parameters ---------- filelist : list The list of files we are checking for. file_stage_manager : `fermipy.jo...
python
def check_files(filelist, file_stage_manager=None, return_found=True, return_missing=True): """Check that all files in a list exist Parameters ---------- filelist : list The list of files we are checking for. file_stage_manager : `fermipy.jo...
[ "def", "check_files", "(", "filelist", ",", "file_stage_manager", "=", "None", ",", "return_found", "=", "True", ",", "return_missing", "=", "True", ")", ":", "found", "=", "[", "]", "missing", "=", "[", "]", "none_count", "=", "0", "for", "fname", "in",...
Check that all files in a list exist Parameters ---------- filelist : list The list of files we are checking for. file_stage_manager : `fermipy.jobs.file_archive.FileStageManager` A object that maps files to scratch space if needed. return_found : list A list with the pat...
[ "Check", "that", "all", "files", "in", "a", "list", "exist" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L53-L111
fermiPy/fermipy
fermipy/jobs/link.py
add_argument
def add_argument(parser, dest, info): """ Add an argument to an `argparse.ArgumentParser` object Parameters ---------- parser : `argparse.ArgumentParser` The parser in question dest : str The destination for the argument info : `tuple` The information associated with t...
python
def add_argument(parser, dest, info): """ Add an argument to an `argparse.ArgumentParser` object Parameters ---------- parser : `argparse.ArgumentParser` The parser in question dest : str The destination for the argument info : `tuple` The information associated with t...
[ "def", "add_argument", "(", "parser", ",", "dest", ",", "info", ")", ":", "default", ",", "helpstr", ",", "typeinfo", "=", "info", "if", "dest", "==", "'args'", ":", "parser", ".", "add_argument", "(", "'args'", ",", "nargs", "=", "'+'", ",", "default"...
Add an argument to an `argparse.ArgumentParser` object Parameters ---------- parser : `argparse.ArgumentParser` The parser in question dest : str The destination for the argument info : `tuple` The information associated with the argument in question.
[ "Add", "an", "argument", "to", "an", "argparse", ".", "ArgumentParser", "object" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L114-L139
fermiPy/fermipy
fermipy/jobs/link.py
convert_dict_to_option_dict
def convert_dict_to_option_dict(input_dict): """Convert a simple key-value dictionary to a dictionary of options tuples""" ret_dict = {} for key, value in input_dict.items(): ret_dict[key] = convert_value_to_option_tuple(value) return ret_dict
python
def convert_dict_to_option_dict(input_dict): """Convert a simple key-value dictionary to a dictionary of options tuples""" ret_dict = {} for key, value in input_dict.items(): ret_dict[key] = convert_value_to_option_tuple(value) return ret_dict
[ "def", "convert_dict_to_option_dict", "(", "input_dict", ")", ":", "ret_dict", "=", "{", "}", "for", "key", ",", "value", "in", "input_dict", ".", "items", "(", ")", ":", "ret_dict", "[", "key", "]", "=", "convert_value_to_option_tuple", "(", "value", ")", ...
Convert a simple key-value dictionary to a dictionary of options tuples
[ "Convert", "a", "simple", "key", "-", "value", "dictionary", "to", "a", "dictionary", "of", "options", "tuples" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L164-L169
fermiPy/fermipy
fermipy/jobs/link.py
convert_option_dict_to_dict
def convert_option_dict_to_dict(option_dict): """Convert a dictionary of options tuples to a simple key-value dictionary""" ret_dict = {} for key, value in option_dict.items(): if is_null(value): ret_dict[key] = None elif isinstance(value, tuple): ret_dict[key] = valu...
python
def convert_option_dict_to_dict(option_dict): """Convert a dictionary of options tuples to a simple key-value dictionary""" ret_dict = {} for key, value in option_dict.items(): if is_null(value): ret_dict[key] = None elif isinstance(value, tuple): ret_dict[key] = valu...
[ "def", "convert_option_dict_to_dict", "(", "option_dict", ")", ":", "ret_dict", "=", "{", "}", "for", "key", ",", "value", "in", "option_dict", ".", "items", "(", ")", ":", "if", "is_null", "(", "value", ")", ":", "ret_dict", "[", "key", "]", "=", "Non...
Convert a dictionary of options tuples to a simple key-value dictionary
[ "Convert", "a", "dictionary", "of", "options", "tuples", "to", "a", "simple", "key", "-", "value", "dictionary" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L172-L182
fermiPy/fermipy
fermipy/jobs/link.py
reduce_by_keys
def reduce_by_keys(orig_dict, keys, default=None): """Reduce a dictionary by selecting a set of keys """ ret = {} for key in keys: ret[key] = orig_dict.get(key, default) return ret
python
def reduce_by_keys(orig_dict, keys, default=None): """Reduce a dictionary by selecting a set of keys """ ret = {} for key in keys: ret[key] = orig_dict.get(key, default) return ret
[ "def", "reduce_by_keys", "(", "orig_dict", ",", "keys", ",", "default", "=", "None", ")", ":", "ret", "=", "{", "}", "for", "key", "in", "keys", ":", "ret", "[", "key", "]", "=", "orig_dict", ".", "get", "(", "key", ",", "default", ")", "return", ...
Reduce a dictionary by selecting a set of keys
[ "Reduce", "a", "dictionary", "by", "selecting", "a", "set", "of", "keys" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L184-L189
fermiPy/fermipy
fermipy/jobs/link.py
Link.construct_docstring
def construct_docstring(options): """Construct a docstring for a set of options""" s = "\nParameters\n" s += "----------\n\n" for key, opt in options.items(): s += "%s : %s\n %s [%s]\n" % (key, str(opt[2]), str(opt[1]), str(...
python
def construct_docstring(options): """Construct a docstring for a set of options""" s = "\nParameters\n" s += "----------\n\n" for key, opt in options.items(): s += "%s : %s\n %s [%s]\n" % (key, str(opt[2]), str(opt[1]), str(...
[ "def", "construct_docstring", "(", "options", ")", ":", "s", "=", "\"\\nParameters\\n\"", "s", "+=", "\"----------\\n\\n\"", "for", "key", ",", "opt", "in", "options", ".", "items", "(", ")", ":", "s", "+=", "\"%s : %s\\n %s [%s]\\n\"", "%", "(", "key", ...
Construct a docstring for a set of options
[ "Construct", "a", "docstring", "for", "a", "set", "of", "options" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L292-L299
fermiPy/fermipy
fermipy/jobs/link.py
Link.register_class
def register_class(cls): """Regsiter this class in the `LinkFactory` """ if cls.appname in LinkFactory._class_dict: return LinkFactory.register(cls.appname, cls)
python
def register_class(cls): """Regsiter this class in the `LinkFactory` """ if cls.appname in LinkFactory._class_dict: return LinkFactory.register(cls.appname, cls)
[ "def", "register_class", "(", "cls", ")", ":", "if", "cls", ".", "appname", "in", "LinkFactory", ".", "_class_dict", ":", "return", "LinkFactory", ".", "register", "(", "cls", ".", "appname", ",", "cls", ")" ]
Regsiter this class in the `LinkFactory`
[ "Regsiter", "this", "class", "in", "the", "LinkFactory" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L313-L317
fermiPy/fermipy
fermipy/jobs/link.py
Link._fill_argparser
def _fill_argparser(self, parser): """Fill an `argparser.ArgumentParser` with the options from this chain """ for key, val in self._options.items(): add_argument(parser, key, val)
python
def _fill_argparser(self, parser): """Fill an `argparser.ArgumentParser` with the options from this chain """ for key, val in self._options.items(): add_argument(parser, key, val)
[ "def", "_fill_argparser", "(", "self", ",", "parser", ")", ":", "for", "key", ",", "val", "in", "self", ".", "_options", ".", "items", "(", ")", ":", "add_argument", "(", "parser", ",", "key", ",", "val", ")" ]
Fill an `argparser.ArgumentParser` with the options from this chain
[ "Fill", "an", "argparser", ".", "ArgumentParser", "with", "the", "options", "from", "this", "chain" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L346-L350
fermiPy/fermipy
fermipy/jobs/link.py
Link._run_argparser
def _run_argparser(self, argv): """Initialize a link with a set of arguments using an `argparser.ArgumentParser` """ if self._parser is None: raise ValueError('Link was not given a parser on initialization') args = self._parser.parse_args(argv) self.update_args(args._...
python
def _run_argparser(self, argv): """Initialize a link with a set of arguments using an `argparser.ArgumentParser` """ if self._parser is None: raise ValueError('Link was not given a parser on initialization') args = self._parser.parse_args(argv) self.update_args(args._...
[ "def", "_run_argparser", "(", "self", ",", "argv", ")", ":", "if", "self", ".", "_parser", "is", "None", ":", "raise", "ValueError", "(", "'Link was not given a parser on initialization'", ")", "args", "=", "self", ".", "_parser", ".", "parse_args", "(", "argv...
Initialize a link with a set of arguments using an `argparser.ArgumentParser`
[ "Initialize", "a", "link", "with", "a", "set", "of", "arguments", "using", "an", "argparser", ".", "ArgumentParser" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L352-L359
fermiPy/fermipy
fermipy/jobs/link.py
Link._latch_file_info
def _latch_file_info(self): """Internal function to update the dictionaries keeping track of input and output files """ self.files.file_dict.clear() self.files.latch_file_info(self.args)
python
def _latch_file_info(self): """Internal function to update the dictionaries keeping track of input and output files """ self.files.file_dict.clear() self.files.latch_file_info(self.args)
[ "def", "_latch_file_info", "(", "self", ")", ":", "self", ".", "files", ".", "file_dict", ".", "clear", "(", ")", "self", ".", "files", ".", "latch_file_info", "(", "self", ".", "args", ")" ]
Internal function to update the dictionaries keeping track of input and output files
[ "Internal", "function", "to", "update", "the", "dictionaries", "keeping", "track", "of", "input", "and", "output", "files" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L361-L366
fermiPy/fermipy
fermipy/jobs/link.py
Link._update_sub_file_dict
def _update_sub_file_dict(self, sub_files): """Update a file dict with information from self""" sub_files.file_dict.clear() for job_details in self.jobs.values(): if job_details.file_dict is not None: sub_files.update(job_details.file_dict) if job_details....
python
def _update_sub_file_dict(self, sub_files): """Update a file dict with information from self""" sub_files.file_dict.clear() for job_details in self.jobs.values(): if job_details.file_dict is not None: sub_files.update(job_details.file_dict) if job_details....
[ "def", "_update_sub_file_dict", "(", "self", ",", "sub_files", ")", ":", "sub_files", ".", "file_dict", ".", "clear", "(", ")", "for", "job_details", "in", "self", ".", "jobs", ".", "values", "(", ")", ":", "if", "job_details", ".", "file_dict", "is", "n...
Update a file dict with information from self
[ "Update", "a", "file", "dict", "with", "information", "from", "self" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L368-L375
fermiPy/fermipy
fermipy/jobs/link.py
Link._pre_run_checks
def _pre_run_checks(self, stream=sys.stdout, dry_run=False): """Do some checks before running this link This checks if input and output files are present. If input files are missing this will raise `OSError` if dry_run is False If all output files are present this return False. ...
python
def _pre_run_checks(self, stream=sys.stdout, dry_run=False): """Do some checks before running this link This checks if input and output files are present. If input files are missing this will raise `OSError` if dry_run is False If all output files are present this return False. ...
[ "def", "_pre_run_checks", "(", "self", ",", "stream", "=", "sys", ".", "stdout", ",", "dry_run", "=", "False", ")", ":", "input_missing", "=", "self", ".", "check_input_files", "(", "return_found", "=", "False", ")", "if", "input_missing", ":", "if", "dry_...
Do some checks before running this link This checks if input and output files are present. If input files are missing this will raise `OSError` if dry_run is False If all output files are present this return False. Parameters ----------- stream : `file` Str...
[ "Do", "some", "checks", "before", "running", "this", "link" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L377-L419
fermiPy/fermipy
fermipy/jobs/link.py
Link._create_job_details
def _create_job_details(self, key, job_config, logfile, status): """Create a `JobDetails` for a single job Parameters ---------- key : str Key used to identify this particular job job_config : dict Dictionary with arguements passed to this particular jo...
python
def _create_job_details(self, key, job_config, logfile, status): """Create a `JobDetails` for a single job Parameters ---------- key : str Key used to identify this particular job job_config : dict Dictionary with arguements passed to this particular jo...
[ "def", "_create_job_details", "(", "self", ",", "key", ",", "job_config", ",", "logfile", ",", "status", ")", ":", "self", ".", "update_args", "(", "job_config", ")", "job_details", "=", "JobDetails", "(", "jobname", "=", "self", ".", "full_linkname", ",", ...
Create a `JobDetails` for a single job Parameters ---------- key : str Key used to identify this particular job job_config : dict Dictionary with arguements passed to this particular job logfile : str Name of the associated log file ...
[ "Create", "a", "JobDetails", "for", "a", "single", "job" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L427-L461
fermiPy/fermipy
fermipy/jobs/link.py
Link._map_scratch_files
def _map_scratch_files(self, file_dict): """Build and return the mapping for copying files to and from scratch area""" if self._file_stage is None: return ({}, {}) input_files = file_dict.input_files_to_stage output_files = file_dict.output_files_to_stage input_file_m...
python
def _map_scratch_files(self, file_dict): """Build and return the mapping for copying files to and from scratch area""" if self._file_stage is None: return ({}, {}) input_files = file_dict.input_files_to_stage output_files = file_dict.output_files_to_stage input_file_m...
[ "def", "_map_scratch_files", "(", "self", ",", "file_dict", ")", ":", "if", "self", ".", "_file_stage", "is", "None", ":", "return", "(", "{", "}", ",", "{", "}", ")", "input_files", "=", "file_dict", ".", "input_files_to_stage", "output_files", "=", "file...
Build and return the mapping for copying files to and from scratch area
[ "Build", "and", "return", "the", "mapping", "for", "copying", "files", "to", "and", "from", "scratch", "area" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L463-L473
fermiPy/fermipy
fermipy/jobs/link.py
Link._update_file_args
def _update_file_args(self, file_mapping): """Adjust the arguments to deal with staging files to the scratch area""" for key, value in self.args.items(): new_value = file_mapping.get(value, value) if new_value != value: self.args[key] = new_value
python
def _update_file_args(self, file_mapping): """Adjust the arguments to deal with staging files to the scratch area""" for key, value in self.args.items(): new_value = file_mapping.get(value, value) if new_value != value: self.args[key] = new_value
[ "def", "_update_file_args", "(", "self", ",", "file_mapping", ")", ":", "for", "key", ",", "value", "in", "self", ".", "args", ".", "items", "(", ")", ":", "new_value", "=", "file_mapping", ".", "get", "(", "value", ",", "value", ")", "if", "new_value"...
Adjust the arguments to deal with staging files to the scratch area
[ "Adjust", "the", "arguments", "to", "deal", "with", "staging", "files", "to", "the", "scratch", "area" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L475-L480
fermiPy/fermipy
fermipy/jobs/link.py
Link._stage_input_files
def _stage_input_files(self, file_mapping, dry_run=True): """Stage the input files to the scratch area and adjust the arguments accordingly""" # print ("Staging input ", file_mapping) if self._file_stage is None: return self._file_stage.copy_to_scratch(file_mapping, dry_run)
python
def _stage_input_files(self, file_mapping, dry_run=True): """Stage the input files to the scratch area and adjust the arguments accordingly""" # print ("Staging input ", file_mapping) if self._file_stage is None: return self._file_stage.copy_to_scratch(file_mapping, dry_run)
[ "def", "_stage_input_files", "(", "self", ",", "file_mapping", ",", "dry_run", "=", "True", ")", ":", "# print (\"Staging input \", file_mapping)", "if", "self", ".", "_file_stage", "is", "None", ":", "return", "self", ".", "_file_stage", ".", "copy_to_scratch", "...
Stage the input files to the scratch area and adjust the arguments accordingly
[ "Stage", "the", "input", "files", "to", "the", "scratch", "area", "and", "adjust", "the", "arguments", "accordingly" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L482-L487
fermiPy/fermipy
fermipy/jobs/link.py
Link._stage_output_files
def _stage_output_files(self, file_mapping, dry_run=True): """Stage the output files to the scratch area and adjust the arguments accordingly""" # print ("Staging output ", file_mapping) if self._file_stage is None: return self._file_stage.copy_from_scratch(file_mapping, dry_...
python
def _stage_output_files(self, file_mapping, dry_run=True): """Stage the output files to the scratch area and adjust the arguments accordingly""" # print ("Staging output ", file_mapping) if self._file_stage is None: return self._file_stage.copy_from_scratch(file_mapping, dry_...
[ "def", "_stage_output_files", "(", "self", ",", "file_mapping", ",", "dry_run", "=", "True", ")", ":", "# print (\"Staging output \", file_mapping)", "if", "self", ".", "_file_stage", "is", "None", ":", "return", "self", ".", "_file_stage", ".", "copy_from_scratch",...
Stage the output files to the scratch area and adjust the arguments accordingly
[ "Stage", "the", "output", "files", "to", "the", "scratch", "area", "and", "adjust", "the", "arguments", "accordingly" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L489-L494
fermiPy/fermipy
fermipy/jobs/link.py
Link._run_link
def _run_link(self, stream=sys.stdout, dry_run=False, stage_files=True, resubmit_failed=False): """Internal function that actually runs this link. This checks if input and output files are present. If input files are missing this will raise `OSError` if dry_run is False ...
python
def _run_link(self, stream=sys.stdout, dry_run=False, stage_files=True, resubmit_failed=False): """Internal function that actually runs this link. This checks if input and output files are present. If input files are missing this will raise `OSError` if dry_run is False ...
[ "def", "_run_link", "(", "self", ",", "stream", "=", "sys", ".", "stdout", ",", "dry_run", "=", "False", ",", "stage_files", "=", "True", ",", "resubmit_failed", "=", "False", ")", ":", "check_ok", "=", "self", ".", "_pre_run_checks", "(", "stream", ",",...
Internal function that actually runs this link. This checks if input and output files are present. If input files are missing this will raise `OSError` if dry_run is False If all output files are present this will skip execution. Parameters ----------- stream : `file` ...
[ "Internal", "function", "that", "actually", "runs", "this", "link", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L496-L547
fermiPy/fermipy
fermipy/jobs/link.py
Link._register_job
def _register_job(self, key, job_config, logfile, status): """Create a `JobDetails` for this link and add it to the self.jobs dictionary. Parameters ---------- key : str Key used to identify this particular job job_config : dict Dictionary with ...
python
def _register_job(self, key, job_config, logfile, status): """Create a `JobDetails` for this link and add it to the self.jobs dictionary. Parameters ---------- key : str Key used to identify this particular job job_config : dict Dictionary with ...
[ "def", "_register_job", "(", "self", ",", "key", ",", "job_config", ",", "logfile", ",", "status", ")", ":", "job_details", "=", "self", ".", "_create_job_details", "(", "key", ",", "job_config", ",", "logfile", ",", "status", ")", "self", ".", "jobs", "...
Create a `JobDetails` for this link and add it to the self.jobs dictionary. Parameters ---------- key : str Key used to identify this particular job job_config : dict Dictionary with arguments passed to this particular job logfile : str ...
[ "Create", "a", "JobDetails", "for", "this", "link", "and", "add", "it", "to", "the", "self", ".", "jobs", "dictionary", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L549-L577
fermiPy/fermipy
fermipy/jobs/link.py
Link._register_self
def _register_self(self, logfile, key=JobDetails.topkey, status=JobStatus.unknown): """Runs this link, captures output to logfile, and records the job in self.jobs""" fullkey = JobDetails.make_fullkey(self.full_linkname, key) if fullkey in self.jobs: job_details = self.jobs[f...
python
def _register_self(self, logfile, key=JobDetails.topkey, status=JobStatus.unknown): """Runs this link, captures output to logfile, and records the job in self.jobs""" fullkey = JobDetails.make_fullkey(self.full_linkname, key) if fullkey in self.jobs: job_details = self.jobs[f...
[ "def", "_register_self", "(", "self", ",", "logfile", ",", "key", "=", "JobDetails", ".", "topkey", ",", "status", "=", "JobStatus", ".", "unknown", ")", ":", "fullkey", "=", "JobDetails", ".", "make_fullkey", "(", "self", ".", "full_linkname", ",", "key",...
Runs this link, captures output to logfile, and records the job in self.jobs
[ "Runs", "this", "link", "captures", "output", "to", "logfile", "and", "records", "the", "job", "in", "self", ".", "jobs" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L579-L587
fermiPy/fermipy
fermipy/jobs/link.py
Link._archive_self
def _archive_self(self, logfile, key=JobDetails.topkey, status=JobStatus.unknown): """Write info about a job run by this `Link` to the job archive""" self._register_self(logfile, key, status) if self._job_archive is None: return self._job_archive.register_jobs(self.get_jobs()...
python
def _archive_self(self, logfile, key=JobDetails.topkey, status=JobStatus.unknown): """Write info about a job run by this `Link` to the job archive""" self._register_self(logfile, key, status) if self._job_archive is None: return self._job_archive.register_jobs(self.get_jobs()...
[ "def", "_archive_self", "(", "self", ",", "logfile", ",", "key", "=", "JobDetails", ".", "topkey", ",", "status", "=", "JobStatus", ".", "unknown", ")", ":", "self", ".", "_register_self", "(", "logfile", ",", "key", ",", "status", ")", "if", "self", "...
Write info about a job run by this `Link` to the job archive
[ "Write", "info", "about", "a", "job", "run", "by", "this", "Link", "to", "the", "job", "archive" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L589-L594
fermiPy/fermipy
fermipy/jobs/link.py
Link._set_status_self
def _set_status_self(self, key=JobDetails.topkey, status=JobStatus.unknown): """Set the status of this job, both in self.jobs and in the `JobArchive` if it is present. """ fullkey = JobDetails.make_fullkey(self.full_linkname, key) if fullkey in self.jobs: self.jobs[fullkey].s...
python
def _set_status_self(self, key=JobDetails.topkey, status=JobStatus.unknown): """Set the status of this job, both in self.jobs and in the `JobArchive` if it is present. """ fullkey = JobDetails.make_fullkey(self.full_linkname, key) if fullkey in self.jobs: self.jobs[fullkey].s...
[ "def", "_set_status_self", "(", "self", ",", "key", "=", "JobDetails", ".", "topkey", ",", "status", "=", "JobStatus", ".", "unknown", ")", ":", "fullkey", "=", "JobDetails", ".", "make_fullkey", "(", "self", ".", "full_linkname", ",", "key", ")", "if", ...
Set the status of this job, both in self.jobs and in the `JobArchive` if it is present.
[ "Set", "the", "status", "of", "this", "job", "both", "in", "self", ".", "jobs", "and", "in", "the", "JobArchive", "if", "it", "is", "present", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L596-L605
fermiPy/fermipy
fermipy/jobs/link.py
Link._write_status_to_log
def _write_status_to_log(self, return_code, stream=sys.stdout): """Write the status of this job to a log stream. This is used to check on job completion.""" stream.write("Timestamp: %i\n" % get_timestamp()) if return_code == 0: stream.write("%s\n" % self._interface.string_suc...
python
def _write_status_to_log(self, return_code, stream=sys.stdout): """Write the status of this job to a log stream. This is used to check on job completion.""" stream.write("Timestamp: %i\n" % get_timestamp()) if return_code == 0: stream.write("%s\n" % self._interface.string_suc...
[ "def", "_write_status_to_log", "(", "self", ",", "return_code", ",", "stream", "=", "sys", ".", "stdout", ")", ":", "stream", ".", "write", "(", "\"Timestamp: %i\\n\"", "%", "get_timestamp", "(", ")", ")", "if", "return_code", "==", "0", ":", "stream", "."...
Write the status of this job to a log stream. This is used to check on job completion.
[ "Write", "the", "status", "of", "this", "job", "to", "a", "log", "stream", ".", "This", "is", "used", "to", "check", "on", "job", "completion", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L607-L615
fermiPy/fermipy
fermipy/jobs/link.py
Link._finalize
def _finalize(self, dry_run=False): """Remove / compress files as requested """ for rmfile in self.files.temp_files: if dry_run: print("remove %s" % rmfile) else: os.remove(rmfile) for gzfile in self.files.gzip_files: if dry_run...
python
def _finalize(self, dry_run=False): """Remove / compress files as requested """ for rmfile in self.files.temp_files: if dry_run: print("remove %s" % rmfile) else: os.remove(rmfile) for gzfile in self.files.gzip_files: if dry_run...
[ "def", "_finalize", "(", "self", ",", "dry_run", "=", "False", ")", ":", "for", "rmfile", "in", "self", ".", "files", ".", "temp_files", ":", "if", "dry_run", ":", "print", "(", "\"remove %s\"", "%", "rmfile", ")", "else", ":", "os", ".", "remove", "...
Remove / compress files as requested
[ "Remove", "/", "compress", "files", "as", "requested" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L617-L629
fermiPy/fermipy
fermipy/jobs/link.py
Link.update_args
def update_args(self, override_args): """Update the argument used to invoke the application Note that this will also update the dictionary of input and output files. Parameters ----------- override_args : dict Dictionary of arguments to override the current values ...
python
def update_args(self, override_args): """Update the argument used to invoke the application Note that this will also update the dictionary of input and output files. Parameters ----------- override_args : dict Dictionary of arguments to override the current values ...
[ "def", "update_args", "(", "self", ",", "override_args", ")", ":", "self", ".", "args", "=", "extract_arguments", "(", "override_args", ",", "self", ".", "args", ")", "self", ".", "_latch_file_info", "(", ")", "scratch_dir", "=", "self", ".", "args", ".", ...
Update the argument used to invoke the application Note that this will also update the dictionary of input and output files. Parameters ----------- override_args : dict Dictionary of arguments to override the current values
[ "Update", "the", "argument", "used", "to", "invoke", "the", "application" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L631-L646
fermiPy/fermipy
fermipy/jobs/link.py
Link.get_failed_jobs
def get_failed_jobs(self, fail_running=False, fail_pending=False): """Return a dictionary with the subset of jobs that are marked as failed Parameters ---------- fail_running : `bool` If True, consider running jobs as failed fail_pending : `bool` If True...
python
def get_failed_jobs(self, fail_running=False, fail_pending=False): """Return a dictionary with the subset of jobs that are marked as failed Parameters ---------- fail_running : `bool` If True, consider running jobs as failed fail_pending : `bool` If True...
[ "def", "get_failed_jobs", "(", "self", ",", "fail_running", "=", "False", ",", "fail_pending", "=", "False", ")", ":", "failed_jobs", "=", "{", "}", "for", "job_key", ",", "job_details", "in", "self", ".", "jobs", ".", "items", "(", ")", ":", "if", "jo...
Return a dictionary with the subset of jobs that are marked as failed Parameters ---------- fail_running : `bool` If True, consider running jobs as failed fail_pending : `bool` If True, consider pending jobs as failed Returns ------- fai...
[ "Return", "a", "dictionary", "with", "the", "subset", "of", "jobs", "that", "are", "marked", "as", "failed" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L648-L675
fermiPy/fermipy
fermipy/jobs/link.py
Link.check_job_status
def check_job_status(self, key=JobDetails.topkey, fail_running=False, fail_pending=False, force_check=False): """Check the status of a particular job By default this checks the status of the top-level job, but can by mad...
python
def check_job_status(self, key=JobDetails.topkey, fail_running=False, fail_pending=False, force_check=False): """Check the status of a particular job By default this checks the status of the top-level job, but can by mad...
[ "def", "check_job_status", "(", "self", ",", "key", "=", "JobDetails", ".", "topkey", ",", "fail_running", "=", "False", ",", "fail_pending", "=", "False", ",", "force_check", "=", "False", ")", ":", "if", "key", "in", "self", ".", "jobs", ":", "status",...
Check the status of a particular job By default this checks the status of the top-level job, but can by made to drill into the sub-jobs. Parameters ---------- key : str Key associated to the job in question fail_running : `bool` If True, conside...
[ "Check", "the", "status", "of", "a", "particular", "job" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L677-L721
fermiPy/fermipy
fermipy/jobs/link.py
Link.check_jobs_status
def check_jobs_status(self, fail_running=False, fail_pending=False): """Check the status of all the jobs run from this link and return a status flag that summarizes that. Parameters ---------- fail_running : `bool` ...
python
def check_jobs_status(self, fail_running=False, fail_pending=False): """Check the status of all the jobs run from this link and return a status flag that summarizes that. Parameters ---------- fail_running : `bool` ...
[ "def", "check_jobs_status", "(", "self", ",", "fail_running", "=", "False", ",", "fail_pending", "=", "False", ")", ":", "n_failed", "=", "0", "n_partial", "=", "0", "n_passed", "=", "0", "n_total", "=", "0", "for", "job_details", "in", "self", ".", "job...
Check the status of all the jobs run from this link and return a status flag that summarizes that. Parameters ---------- fail_running : `bool` If True, consider running jobs as failed fail_pending : `bool` If True, consider pending jobs as failed ...
[ "Check", "the", "status", "of", "all", "the", "jobs", "run", "from", "this", "link", "and", "return", "a", "status", "flag", "that", "summarizes", "that", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L723-L767
fermiPy/fermipy
fermipy/jobs/link.py
Link.get_jobs
def get_jobs(self, recursive=True): """Return a dictionary with all the jobs For sub-classes, if recursive is True this will include jobs from any internal `Link` """ if recursive: ret_dict = self.jobs.copy() return ret_dict return self.jobs
python
def get_jobs(self, recursive=True): """Return a dictionary with all the jobs For sub-classes, if recursive is True this will include jobs from any internal `Link` """ if recursive: ret_dict = self.jobs.copy() return ret_dict return self.jobs
[ "def", "get_jobs", "(", "self", ",", "recursive", "=", "True", ")", ":", "if", "recursive", ":", "ret_dict", "=", "self", ".", "jobs", ".", "copy", "(", ")", "return", "ret_dict", "return", "self", ".", "jobs" ]
Return a dictionary with all the jobs For sub-classes, if recursive is True this will include jobs from any internal `Link`
[ "Return", "a", "dictionary", "with", "all", "the", "jobs" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L786-L795
fermiPy/fermipy
fermipy/jobs/link.py
Link.check_input_files
def check_input_files(self, return_found=True, return_missing=True): """Check if input files exist. Parameters ---------- return_found : list A list with the paths of the files that were found. return_missing : lis...
python
def check_input_files(self, return_found=True, return_missing=True): """Check if input files exist. Parameters ---------- return_found : list A list with the paths of the files that were found. return_missing : lis...
[ "def", "check_input_files", "(", "self", ",", "return_found", "=", "True", ",", "return_missing", "=", "True", ")", ":", "all_input_files", "=", "self", ".", "files", ".", "chain_input_files", "+", "self", ".", "sub_files", ".", "chain_input_files", "return", ...
Check if input files exist. Parameters ---------- return_found : list A list with the paths of the files that were found. return_missing : list A list with the paths of the files that were missing. Returns ------- found : list ...
[ "Check", "if", "input", "files", "exist", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L797-L821
fermiPy/fermipy
fermipy/jobs/link.py
Link.check_output_files
def check_output_files(self, return_found=True, return_missing=True): """Check if output files exist. Parameters ---------- return_found : list A list with the paths of the files that were found. return_missing :...
python
def check_output_files(self, return_found=True, return_missing=True): """Check if output files exist. Parameters ---------- return_found : list A list with the paths of the files that were found. return_missing :...
[ "def", "check_output_files", "(", "self", ",", "return_found", "=", "True", ",", "return_missing", "=", "True", ")", ":", "all_output_files", "=", "self", ".", "files", ".", "chain_output_files", "+", "self", ".", "sub_files", ".", "chain_output_files", "return"...
Check if output files exist. Parameters ---------- return_found : list A list with the paths of the files that were found. return_missing : list A list with the paths of the files that were missing. Returns ------- found : list ...
[ "Check", "if", "output", "files", "exist", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L823-L848
fermiPy/fermipy
fermipy/jobs/link.py
Link.missing_input_files
def missing_input_files(self): """Make and return a dictionary of the missing input files. This returns a dictionary mapping filepath to list of `Link` that use the file as input. """ missing = self.check_input_files(return_found=False) ret_dict = {} for miss_fil...
python
def missing_input_files(self): """Make and return a dictionary of the missing input files. This returns a dictionary mapping filepath to list of `Link` that use the file as input. """ missing = self.check_input_files(return_found=False) ret_dict = {} for miss_fil...
[ "def", "missing_input_files", "(", "self", ")", ":", "missing", "=", "self", ".", "check_input_files", "(", "return_found", "=", "False", ")", "ret_dict", "=", "{", "}", "for", "miss_file", "in", "missing", ":", "ret_dict", "[", "miss_file", "]", "=", "[",...
Make and return a dictionary of the missing input files. This returns a dictionary mapping filepath to list of `Link` that use the file as input.
[ "Make", "and", "return", "a", "dictionary", "of", "the", "missing", "input", "files", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L850-L860
fermiPy/fermipy
fermipy/jobs/link.py
Link.missing_output_files
def missing_output_files(self): """Make and return a dictionary of the missing output files. This returns a dictionary mapping filepath to list of links that produce the file as output. """ missing = self.check_output_files(return_found=False) ret_dict = {} for m...
python
def missing_output_files(self): """Make and return a dictionary of the missing output files. This returns a dictionary mapping filepath to list of links that produce the file as output. """ missing = self.check_output_files(return_found=False) ret_dict = {} for m...
[ "def", "missing_output_files", "(", "self", ")", ":", "missing", "=", "self", ".", "check_output_files", "(", "return_found", "=", "False", ")", "ret_dict", "=", "{", "}", "for", "miss_file", "in", "missing", ":", "ret_dict", "[", "miss_file", "]", "=", "[...
Make and return a dictionary of the missing output files. This returns a dictionary mapping filepath to list of links that produce the file as output.
[ "Make", "and", "return", "a", "dictionary", "of", "the", "missing", "output", "files", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L862-L872
fermiPy/fermipy
fermipy/jobs/link.py
Link.formatted_command
def formatted_command(self): """Build and return the formatted command for this `Link`. This is exactly the command as called from the Unix command line. """ # FIXME, this isn't really great as it force you to have all the arguments command_template = self.command_template() ...
python
def formatted_command(self): """Build and return the formatted command for this `Link`. This is exactly the command as called from the Unix command line. """ # FIXME, this isn't really great as it force you to have all the arguments command_template = self.command_template() ...
[ "def", "formatted_command", "(", "self", ")", ":", "# FIXME, this isn't really great as it force you to have all the arguments", "command_template", "=", "self", ".", "command_template", "(", ")", "format_dict", "=", "self", ".", "args", ".", "copy", "(", ")", "for", ...
Build and return the formatted command for this `Link`. This is exactly the command as called from the Unix command line.
[ "Build", "and", "return", "the", "formatted", "command", "for", "this", "Link", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L874-L902
fermiPy/fermipy
fermipy/jobs/link.py
Link.run_command
def run_command(self, stream=sys.stdout, dry_run=False): """Runs the command for this link. This method can be overridden by sub-classes to invoke a different command Parameters ---------- stream : `file` Stream that this `Link` will print to, Must have ...
python
def run_command(self, stream=sys.stdout, dry_run=False): """Runs the command for this link. This method can be overridden by sub-classes to invoke a different command Parameters ---------- stream : `file` Stream that this `Link` will print to, Must have ...
[ "def", "run_command", "(", "self", ",", "stream", "=", "sys", ".", "stdout", ",", "dry_run", "=", "False", ")", ":", "command", "=", "self", ".", "formatted_command", "(", ")", "if", "dry_run", ":", "stream", ".", "write", "(", "\"%s\\n\"", "%", "comma...
Runs the command for this link. This method can be overridden by sub-classes to invoke a different command Parameters ---------- stream : `file` Stream that this `Link` will print to, Must have 'write' function dry_run : bool Print command b...
[ "Runs", "the", "command", "for", "this", "link", ".", "This", "method", "can", "be", "overridden", "by", "sub", "-", "classes", "to", "invoke", "a", "different", "command" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L904-L932
fermiPy/fermipy
fermipy/jobs/link.py
Link.run_with_log
def run_with_log(self, dry_run=False, stage_files=True, resubmit_failed=False): """Runs this link with output sent to a pre-defined logfile Parameters ----------- dry_run : bool Print command but do not run it. stage_files : bool Copy files to and from s...
python
def run_with_log(self, dry_run=False, stage_files=True, resubmit_failed=False): """Runs this link with output sent to a pre-defined logfile Parameters ----------- dry_run : bool Print command but do not run it. stage_files : bool Copy files to and from s...
[ "def", "run_with_log", "(", "self", ",", "dry_run", "=", "False", ",", "stage_files", "=", "True", ",", "resubmit_failed", "=", "False", ")", ":", "fullkey", "=", "JobDetails", ".", "make_fullkey", "(", "self", ".", "full_linkname", ")", "job_details", "=", ...
Runs this link with output sent to a pre-defined logfile Parameters ----------- dry_run : bool Print command but do not run it. stage_files : bool Copy files to and from scratch staging area. resubmit_failed : bool Flag for sub-classes to re...
[ "Runs", "this", "link", "with", "output", "sent", "to", "a", "pre", "-", "defined", "logfile" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L959-L982
fermiPy/fermipy
fermipy/jobs/link.py
Link.command_template
def command_template(self): """Build and return a string that can be used as a template invoking this chain from the command line. The actual command can be obtainted by using `self.command_template().format(**self.args)` """ com_out = self.appname arg_string = "...
python
def command_template(self): """Build and return a string that can be used as a template invoking this chain from the command line. The actual command can be obtainted by using `self.command_template().format(**self.args)` """ com_out = self.appname arg_string = "...
[ "def", "command_template", "(", "self", ")", ":", "com_out", "=", "self", ".", "appname", "arg_string", "=", "\"\"", "flag_string", "=", "\"\"", "# Loop over the key, value pairs in self.args", "for", "key", ",", "val", "in", "self", ".", "args", ".", "items", ...
Build and return a string that can be used as a template invoking this chain from the command line. The actual command can be obtainted by using `self.command_template().format(**self.args)`
[ "Build", "and", "return", "a", "string", "that", "can", "be", "used", "as", "a", "template", "invoking", "this", "chain", "from", "the", "command", "line", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L984-L1022
fermiPy/fermipy
fermipy/jobs/link.py
Link.print_summary
def print_summary(self, stream=sys.stdout, indent="", recurse_level=2): """Print a summary of the activity done by this `Link`. Parameters ----------- stream : `file` Stream to print to, must have 'write' method. indent : str Indentation at start of line...
python
def print_summary(self, stream=sys.stdout, indent="", recurse_level=2): """Print a summary of the activity done by this `Link`. Parameters ----------- stream : `file` Stream to print to, must have 'write' method. indent : str Indentation at start of line...
[ "def", "print_summary", "(", "self", ",", "stream", "=", "sys", ".", "stdout", ",", "indent", "=", "\"\"", ",", "recurse_level", "=", "2", ")", ":", "if", "recurse_level", "<", "0", ":", "return", "stream", ".", "write", "(", "\"%sLink: %s\\n\"", "%", ...
Print a summary of the activity done by this `Link`. Parameters ----------- stream : `file` Stream to print to, must have 'write' method. indent : str Indentation at start of line recurse_level : int Number of recursion levels to print
[ "Print", "a", "summary", "of", "the", "activity", "done", "by", "this", "Link", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L1025-L1044
fermiPy/fermipy
fermipy/wcs_utils.py
distance_to_edge
def distance_to_edge(geom, skydir): """Return the angular distance from the given direction and the edge of the projection.""" # FIXME: We should add a pixel_size property in gammapy.maps # FIXME: We should make this into a MapGeom method xpix, ypix = skydir.to_pixel(geom.wcs, origin=0) d...
python
def distance_to_edge(geom, skydir): """Return the angular distance from the given direction and the edge of the projection.""" # FIXME: We should add a pixel_size property in gammapy.maps # FIXME: We should make this into a MapGeom method xpix, ypix = skydir.to_pixel(geom.wcs, origin=0) d...
[ "def", "distance_to_edge", "(", "geom", ",", "skydir", ")", ":", "# FIXME: We should add a pixel_size property in gammapy.maps", "# FIXME: We should make this into a MapGeom method ", "xpix", ",", "ypix", "=", "skydir", ".", "to_pixel", "(", "geom", ".", "wcs", ",", "orig...
Return the angular distance from the given direction and the edge of the projection.
[ "Return", "the", "angular", "distance", "from", "the", "given", "direction", "and", "the", "edge", "of", "the", "projection", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L94-L120
fermiPy/fermipy
fermipy/wcs_utils.py
create_wcs
def create_wcs(skydir, coordsys='CEL', projection='AIT', cdelt=1.0, crpix=1., naxis=2, energies=None): """Create a WCS object. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` Sky coordinate of the WCS reference point. coordsys : str projection : str c...
python
def create_wcs(skydir, coordsys='CEL', projection='AIT', cdelt=1.0, crpix=1., naxis=2, energies=None): """Create a WCS object. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` Sky coordinate of the WCS reference point. coordsys : str projection : str c...
[ "def", "create_wcs", "(", "skydir", ",", "coordsys", "=", "'CEL'", ",", "projection", "=", "'AIT'", ",", "cdelt", "=", "1.0", ",", "crpix", "=", "1.", ",", "naxis", "=", "2", ",", "energies", "=", "None", ")", ":", "w", "=", "WCS", "(", "naxis", ...
Create a WCS object. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` Sky coordinate of the WCS reference point. coordsys : str projection : str cdelt : float or (float,float) In the first case the same value is used for x and y axes crpix : float or (float,f...
[ "Create", "a", "WCS", "object", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L123-L182
fermiPy/fermipy
fermipy/wcs_utils.py
wcs_add_energy_axis
def wcs_add_energy_axis(wcs, energies): """Copy a WCS object, and add on the energy axis. Parameters ---------- wcs : `~astropy.wcs.WCS` WCS energies : array-like Array of energies. """ if wcs.naxis != 2: raise Exception( 'wcs_add_energy_axis, input WCS na...
python
def wcs_add_energy_axis(wcs, energies): """Copy a WCS object, and add on the energy axis. Parameters ---------- wcs : `~astropy.wcs.WCS` WCS energies : array-like Array of energies. """ if wcs.naxis != 2: raise Exception( 'wcs_add_energy_axis, input WCS na...
[ "def", "wcs_add_energy_axis", "(", "wcs", ",", "energies", ")", ":", "if", "wcs", ".", "naxis", "!=", "2", ":", "raise", "Exception", "(", "'wcs_add_energy_axis, input WCS naxis != 2 %i'", "%", "wcs", ".", "naxis", ")", "w", "=", "WCS", "(", "naxis", "=", ...
Copy a WCS object, and add on the energy axis. Parameters ---------- wcs : `~astropy.wcs.WCS` WCS energies : array-like Array of energies.
[ "Copy", "a", "WCS", "object", "and", "add", "on", "the", "energy", "axis", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L185-L212