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
Hackerfleet/hfos
modules/webguides/hfos/guides/guide_manager.py
GuideManager._translate
def _translate(self, input_filename, output_filename): """Translate KML file to geojson for import""" command = [ self.translate_binary, '-f', 'GeoJSON', output_filename, input_filename ] result = self._runcommand(command) self.log...
python
def _translate(self, input_filename, output_filename): """Translate KML file to geojson for import""" command = [ self.translate_binary, '-f', 'GeoJSON', output_filename, input_filename ] result = self._runcommand(command) self.log...
[ "def", "_translate", "(", "self", ",", "input_filename", ",", "output_filename", ")", ":", "command", "=", "[", "self", ".", "translate_binary", ",", "'-f'", ",", "'GeoJSON'", ",", "output_filename", ",", "input_filename", "]", "result", "=", "self", ".", "_...
Translate KML file to geojson for import
[ "Translate", "KML", "file", "to", "geojson", "for", "import" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/webguides/hfos/guides/guide_manager.py#L118-L128
Hackerfleet/hfos
modules/webguides/hfos/guides/guide_manager.py
GuideManager._update_guide
def _update_guide(self, guide, update=False, clear=True): """Update a single specified guide""" kml_filename = os.path.join(self.cache_path, guide + '.kml') geojson_filename = os.path.join(self.cache_path, guide + '.geojson') if not os.path.exists(geojson_filename) or update: ...
python
def _update_guide(self, guide, update=False, clear=True): """Update a single specified guide""" kml_filename = os.path.join(self.cache_path, guide + '.kml') geojson_filename = os.path.join(self.cache_path, guide + '.geojson') if not os.path.exists(geojson_filename) or update: ...
[ "def", "_update_guide", "(", "self", ",", "guide", ",", "update", "=", "False", ",", "clear", "=", "True", ")", ":", "kml_filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "cache_path", ",", "guide", "+", "'.kml'", ")", "geojson_filenam...
Update a single specified guide
[ "Update", "a", "single", "specified", "guide" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/webguides/hfos/guides/guide_manager.py#L136-L198
Hackerfleet/hfos
modules/mail/hfos/mail/transmitter.py
send_mail_worker
def send_mail_worker(config, mail, event): """Worker task to send out an email, which is a blocking process unless it is threaded""" log = "" try: if config.get('ssl', True): server = SMTP_SSL(config['server'], port=config['port'], timeout=30) else: server = SMTP(con...
python
def send_mail_worker(config, mail, event): """Worker task to send out an email, which is a blocking process unless it is threaded""" log = "" try: if config.get('ssl', True): server = SMTP_SSL(config['server'], port=config['port'], timeout=30) else: server = SMTP(con...
[ "def", "send_mail_worker", "(", "config", ",", "mail", ",", "event", ")", ":", "log", "=", "\"\"", "try", ":", "if", "config", ".", "get", "(", "'ssl'", ",", "True", ")", ":", "server", "=", "SMTP_SSL", "(", "config", "[", "'server'", "]", ",", "po...
Worker task to send out an email, which is a blocking process unless it is threaded
[ "Worker", "task", "to", "send", "out", "an", "email", "which", "is", "a", "blocking", "process", "unless", "it", "is", "threaded" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/mail/hfos/mail/transmitter.py#L47-L76
Hackerfleet/hfos
modules/mail/hfos/mail/transmitter.py
MailTransmitter.send_mail
def send_mail(self, event): """Connect to mail server and send actual email""" mime_mail = MIMEText(event.text) mime_mail['Subject'] = event.subject if event.account == 'default': account_name = self.config.default_account else: account_name = event.acco...
python
def send_mail(self, event): """Connect to mail server and send actual email""" mime_mail = MIMEText(event.text) mime_mail['Subject'] = event.subject if event.account == 'default': account_name = self.config.default_account else: account_name = event.acco...
[ "def", "send_mail", "(", "self", ",", "event", ")", ":", "mime_mail", "=", "MIMEText", "(", "event", ".", "text", ")", "mime_mail", "[", "'Subject'", "]", "=", "event", ".", "subject", "if", "event", ".", "account", "==", "'default'", ":", "account_name"...
Connect to mail server and send actual email
[ "Connect", "to", "mail", "server", "and", "send", "actual", "email" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/mail/hfos/mail/transmitter.py#L189-L211
Hackerfleet/hfos
hfos/provisions/user.py
provision_system_user
def provision_system_user(items, database_name, overwrite=False, clear=False, skip_user_check=False): """Provision a system user""" from hfos.provisions.base import provisionList from hfos.database import objectmodels # TODO: Add a root user and make sure owner can access it later. # Setting up de...
python
def provision_system_user(items, database_name, overwrite=False, clear=False, skip_user_check=False): """Provision a system user""" from hfos.provisions.base import provisionList from hfos.database import objectmodels # TODO: Add a root user and make sure owner can access it later. # Setting up de...
[ "def", "provision_system_user", "(", "items", ",", "database_name", ",", "overwrite", "=", "False", ",", "clear", "=", "False", ",", "skip_user_check", "=", "False", ")", ":", "from", "hfos", ".", "provisions", ".", "base", "import", "provisionList", "from", ...
Provision a system user
[ "Provision", "a", "system", "user" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/provisions/user.py#L48-L68
andychase/reparse
reparse/expression.py
AlternatesGroup
def AlternatesGroup(expressions, final_function, name=""): """ Group expressions using the OR character ``|`` >>> from collections import namedtuple >>> expr = namedtuple('expr', 'regex group_lengths run')('(1)', [1], None) >>> grouping = AlternatesGroup([expr, expr], lambda f: None, 'yeah') >>> gro...
python
def AlternatesGroup(expressions, final_function, name=""): """ Group expressions using the OR character ``|`` >>> from collections import namedtuple >>> expr = namedtuple('expr', 'regex group_lengths run')('(1)', [1], None) >>> grouping = AlternatesGroup([expr, expr], lambda f: None, 'yeah') >>> gro...
[ "def", "AlternatesGroup", "(", "expressions", ",", "final_function", ",", "name", "=", "\"\"", ")", ":", "inbetweens", "=", "[", "\"|\"", "]", "*", "(", "len", "(", "expressions", ")", "+", "1", ")", "inbetweens", "[", "0", "]", "=", "\"\"", "inbetween...
Group expressions using the OR character ``|`` >>> from collections import namedtuple >>> expr = namedtuple('expr', 'regex group_lengths run')('(1)', [1], None) >>> grouping = AlternatesGroup([expr, expr], lambda f: None, 'yeah') >>> grouping.regex # doctest: +IGNORE_UNICODE '(?:(1))|(?:(1))' >...
[ "Group", "expressions", "using", "the", "OR", "character", "|", ">>>", "from", "collections", "import", "namedtuple", ">>>", "expr", "=", "namedtuple", "(", "expr", "regex", "group_lengths", "run", ")", "(", "(", "1", ")", "[", "1", "]", "None", ")", ">>...
train
https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/expression.py#L108-L121
andychase/reparse
reparse/expression.py
Group
def Group(expressions, final_function, inbetweens, name=""): """ Group expressions together with ``inbetweens`` and with the output of a ``final_functions``. """ lengths = [] functions = [] regex = "" i = 0 for expression in expressions: regex += inbetweens[i] regex += "(?:" ...
python
def Group(expressions, final_function, inbetweens, name=""): """ Group expressions together with ``inbetweens`` and with the output of a ``final_functions``. """ lengths = [] functions = [] regex = "" i = 0 for expression in expressions: regex += inbetweens[i] regex += "(?:" ...
[ "def", "Group", "(", "expressions", ",", "final_function", ",", "inbetweens", ",", "name", "=", "\"\"", ")", ":", "lengths", "=", "[", "]", "functions", "=", "[", "]", "regex", "=", "\"\"", "i", "=", "0", "for", "expression", "in", "expressions", ":", ...
Group expressions together with ``inbetweens`` and with the output of a ``final_functions``.
[ "Group", "expressions", "together", "with", "inbetweens", "and", "with", "the", "output", "of", "a", "final_functions", "." ]
train
https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/expression.py#L124-L139
andychase/reparse
reparse/expression.py
Expression.findall
def findall(self, string): """ Parse string, returning all outputs as parsed by functions """ output = [] for match in self.pattern.findall(string): if hasattr(match, 'strip'): match = [match] self._list_add(output, self.run(match)) return ...
python
def findall(self, string): """ Parse string, returning all outputs as parsed by functions """ output = [] for match in self.pattern.findall(string): if hasattr(match, 'strip'): match = [match] self._list_add(output, self.run(match)) return ...
[ "def", "findall", "(", "self", ",", "string", ")", ":", "output", "=", "[", "]", "for", "match", "in", "self", ".", "pattern", ".", "findall", "(", "string", ")", ":", "if", "hasattr", "(", "match", ",", "'strip'", ")", ":", "match", "=", "[", "m...
Parse string, returning all outputs as parsed by functions
[ "Parse", "string", "returning", "all", "outputs", "as", "parsed", "by", "functions" ]
train
https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/expression.py#L47-L55
andychase/reparse
reparse/expression.py
Expression.scan
def scan(self, string): """ Like findall, but also returning matching start and end string locations """ return list(self._scanner_to_matches(self.pattern.scanner(string), self.run))
python
def scan(self, string): """ Like findall, but also returning matching start and end string locations """ return list(self._scanner_to_matches(self.pattern.scanner(string), self.run))
[ "def", "scan", "(", "self", ",", "string", ")", ":", "return", "list", "(", "self", ".", "_scanner_to_matches", "(", "self", ".", "pattern", ".", "scanner", "(", "string", ")", ",", "self", ".", "run", ")", ")" ]
Like findall, but also returning matching start and end string locations
[ "Like", "findall", "but", "also", "returning", "matching", "start", "and", "end", "string", "locations" ]
train
https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/expression.py#L57-L60
andychase/reparse
reparse/expression.py
Expression.run
def run(self, matches): """ Run group functions over matches """ def _run(matches): group_starting_pos = 0 for current_pos, (group_length, group_function) in enumerate(zip(self.group_lengths, self.group_functions)): start_pos = current_pos + group_starting...
python
def run(self, matches): """ Run group functions over matches """ def _run(matches): group_starting_pos = 0 for current_pos, (group_length, group_function) in enumerate(zip(self.group_lengths, self.group_functions)): start_pos = current_pos + group_starting...
[ "def", "run", "(", "self", ",", "matches", ")", ":", "def", "_run", "(", "matches", ")", ":", "group_starting_pos", "=", "0", "for", "current_pos", ",", "(", "group_length", ",", "group_function", ")", "in", "enumerate", "(", "zip", "(", "self", ".", "...
Run group functions over matches
[ "Run", "group", "functions", "over", "matches" ]
train
https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/expression.py#L62-L72
Hackerfleet/hfos
hfos/logger.py
set_logfile
def set_logfile(path, instance): """Specify logfile path""" global logfile logfile = os.path.normpath(path) + '/hfos.' + instance + '.log'
python
def set_logfile(path, instance): """Specify logfile path""" global logfile logfile = os.path.normpath(path) + '/hfos.' + instance + '.log'
[ "def", "set_logfile", "(", "path", ",", "instance", ")", ":", "global", "logfile", "logfile", "=", "os", ".", "path", ".", "normpath", "(", "path", ")", "+", "'/hfos.'", "+", "instance", "+", "'.log'" ]
Specify logfile path
[ "Specify", "logfile", "path" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/logger.py#L113-L117
Hackerfleet/hfos
hfos/logger.py
is_muted
def is_muted(what): """ Checks if a logged event is to be muted for debugging purposes. Also goes through the solo list - only items in there will be logged! :param what: :return: """ state = False for item in solo: if item not in what: state = True else: ...
python
def is_muted(what): """ Checks if a logged event is to be muted for debugging purposes. Also goes through the solo list - only items in there will be logged! :param what: :return: """ state = False for item in solo: if item not in what: state = True else: ...
[ "def", "is_muted", "(", "what", ")", ":", "state", "=", "False", "for", "item", "in", "solo", ":", "if", "item", "not", "in", "what", ":", "state", "=", "True", "else", ":", "state", "=", "False", "break", "for", "item", "in", "mute", ":", "if", ...
Checks if a logged event is to be muted for debugging purposes. Also goes through the solo list - only items in there will be logged! :param what: :return:
[ "Checks", "if", "a", "logged", "event", "is", "to", "be", "muted", "for", "debugging", "purposes", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/logger.py#L120-L144
Hackerfleet/hfos
hfos/logger.py
hfoslog
def hfoslog(*what, **kwargs): """Logs all *what arguments. :param *what: Loggable objects (i.e. they have a string representation) :param lvl: Debug message level :param exc: Switch to better handle exceptions, use if logging in an except clause :param emitter: Optional log source, ...
python
def hfoslog(*what, **kwargs): """Logs all *what arguments. :param *what: Loggable objects (i.e. they have a string representation) :param lvl: Debug message level :param exc: Switch to better handle exceptions, use if logging in an except clause :param emitter: Optional log source, ...
[ "def", "hfoslog", "(", "*", "what", ",", "*", "*", "kwargs", ")", ":", "# Count all messages (missing numbers give a hint at too high log level)", "global", "count", "global", "verbosity", "count", "+=", "1", "lvl", "=", "kwargs", ".", "get", "(", "'lvl'", ",", ...
Logs all *what arguments. :param *what: Loggable objects (i.e. they have a string representation) :param lvl: Debug message level :param exc: Switch to better handle exceptions, use if logging in an except clause :param emitter: Optional log source, where this can't be determined ...
[ "Logs", "all", "*", "what", "arguments", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/logger.py#L169-L301
Hackerfleet/hfos
hfos/ui/tagmanager.py
TagManager.get_tagged
def get_tagged(self, event): """Return a list of tagged objects for a schema""" self.log("Tagged objects request for", event.data, "from", event.user, lvl=debug) if event.data in self.tags: tagged = self._get_tagged(event.data) response = { ...
python
def get_tagged(self, event): """Return a list of tagged objects for a schema""" self.log("Tagged objects request for", event.data, "from", event.user, lvl=debug) if event.data in self.tags: tagged = self._get_tagged(event.data) response = { ...
[ "def", "get_tagged", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "\"Tagged objects request for\"", ",", "event", ".", "data", ",", "\"from\"", ",", "event", ".", "user", ",", "lvl", "=", "debug", ")", "if", "event", ".", "data", "in",...
Return a list of tagged objects for a schema
[ "Return", "a", "list", "of", "tagged", "objects", "for", "a", "schema" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/tagmanager.py#L83-L97
Hackerfleet/hfos
modules/navdata/hfos/navdata/provisions/vessel.py
provision_system_vessel
def provision_system_vessel(items, database_name, overwrite=False, clear=False, skip_user_check=False): """Provisions the default system vessel""" from hfos.provisions.base import provisionList from hfos.database import objectmodels vessel = objectmodels['vessel'].find_one({'name': 'Default System Ves...
python
def provision_system_vessel(items, database_name, overwrite=False, clear=False, skip_user_check=False): """Provisions the default system vessel""" from hfos.provisions.base import provisionList from hfos.database import objectmodels vessel = objectmodels['vessel'].find_one({'name': 'Default System Ves...
[ "def", "provision_system_vessel", "(", "items", ",", "database_name", ",", "overwrite", "=", "False", ",", "clear", "=", "False", ",", "skip_user_check", "=", "False", ")", ":", "from", "hfos", ".", "provisions", ".", "base", "import", "provisionList", "from",...
Provisions the default system vessel
[ "Provisions", "the", "default", "system", "vessel" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/navdata/hfos/navdata/provisions/vessel.py#L33-L54
Hackerfleet/hfos
modules/maps/hfos/map/maptileservice.py
get_tile
def get_tile(url): """ Threadable function to retrieve map tiles from the internet :param url: URL of tile to get """ log = "" connection = None try: if six.PY3: connection = urlopen(url=url, timeout=2) # NOQA else: connection = urlopen(url=url) ...
python
def get_tile(url): """ Threadable function to retrieve map tiles from the internet :param url: URL of tile to get """ log = "" connection = None try: if six.PY3: connection = urlopen(url=url, timeout=2) # NOQA else: connection = urlopen(url=url) ...
[ "def", "get_tile", "(", "url", ")", ":", "log", "=", "\"\"", "connection", "=", "None", "try", ":", "if", "six", ".", "PY3", ":", "connection", "=", "urlopen", "(", "url", "=", "url", ",", "timeout", "=", "2", ")", "# NOQA", "else", ":", "connectio...
Threadable function to retrieve map tiles from the internet :param url: URL of tile to get
[ "Threadable", "function", "to", "retrieve", "map", "tiles", "from", "the", "internet", ":", "param", "url", ":", "URL", "of", "tile", "to", "get" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/maptileservice.py#L63-L92
Hackerfleet/hfos
modules/maps/hfos/map/maptileservice.py
MaptileService.tilecache
def tilecache(self, event, *args, **kwargs): """Checks and caches a requested tile to disk, then delivers it to client""" request, response = event.args[:2] self.log(request.path, lvl=verbose) try: filename, url = self._split_cache_url(request.path, 'tilecache') ...
python
def tilecache(self, event, *args, **kwargs): """Checks and caches a requested tile to disk, then delivers it to client""" request, response = event.args[:2] self.log(request.path, lvl=verbose) try: filename, url = self._split_cache_url(request.path, 'tilecache') ...
[ "def", "tilecache", "(", "self", ",", "event", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "request", ",", "response", "=", "event", ".", "args", "[", ":", "2", "]", "self", ".", "log", "(", "request", ".", "path", ",", "lvl", "=", "ve...
Checks and caches a requested tile to disk, then delivers it to client
[ "Checks", "and", "caches", "a", "requested", "tile", "to", "disk", "then", "delivers", "it", "to", "client" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/maptileservice.py#L464-L543
yychen/twd97
twd97/converter.py
todegdec
def todegdec(origin): """ Convert from [+/-]DDD°MMM'SSS.SSSS" or [+/-]DDD°MMM.MMMM' to [+/-]DDD.DDDDD """ # if the input is already a float (or can be converted to float) try: return float(origin) except ValueError: pass # DMS format m = dms_re.search(origin) if m: ...
python
def todegdec(origin): """ Convert from [+/-]DDD°MMM'SSS.SSSS" or [+/-]DDD°MMM.MMMM' to [+/-]DDD.DDDDD """ # if the input is already a float (or can be converted to float) try: return float(origin) except ValueError: pass # DMS format m = dms_re.search(origin) if m: ...
[ "def", "todegdec", "(", "origin", ")", ":", "# if the input is already a float (or can be converted to float)", "try", ":", "return", "float", "(", "origin", ")", "except", "ValueError", ":", "pass", "# DMS format", "m", "=", "dms_re", ".", "search", "(", "origin", ...
Convert from [+/-]DDD°MMM'SSS.SSSS" or [+/-]DDD°MMM.MMMM' to [+/-]DDD.DDDDD
[ "Convert", "from", "[", "+", "/", "-", "]", "DDD°MMM", "SSS", ".", "SSSS", "or", "[", "+", "/", "-", "]", "DDD°MMM", ".", "MMMM", "to", "[", "+", "/", "-", "]", "DDD", ".", "DDDDD" ]
train
https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L41-L67
yychen/twd97
twd97/converter.py
tomindec
def tomindec(origin): """ Convert [+/-]DDD.DDDDD to a tuple (degrees, minutes) """ origin = float(origin) degrees = int(origin) minutes = (origin % 1) * 60 return degrees, minutes
python
def tomindec(origin): """ Convert [+/-]DDD.DDDDD to a tuple (degrees, minutes) """ origin = float(origin) degrees = int(origin) minutes = (origin % 1) * 60 return degrees, minutes
[ "def", "tomindec", "(", "origin", ")", ":", "origin", "=", "float", "(", "origin", ")", "degrees", "=", "int", "(", "origin", ")", "minutes", "=", "(", "origin", "%", "1", ")", "*", "60", "return", "degrees", ",", "minutes" ]
Convert [+/-]DDD.DDDDD to a tuple (degrees, minutes)
[ "Convert", "[", "+", "/", "-", "]", "DDD", ".", "DDDDD", "to", "a", "tuple", "(", "degrees", "minutes", ")" ]
train
https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L69-L78
yychen/twd97
twd97/converter.py
tomindecstr
def tomindecstr(origin): """ Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM.MMMM' """ degrees, minutes = tomindec(origin) return u'%d°%f\'' % (degrees, minutes)
python
def tomindecstr(origin): """ Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM.MMMM' """ degrees, minutes = tomindec(origin) return u'%d°%f\'' % (degrees, minutes)
[ "def", "tomindecstr", "(", "origin", ")", ":", "degrees", ",", "minutes", "=", "tomindec", "(", "origin", ")", "return", "u'%d°%f\\'' ", " ", "d", "egrees,", " ", "inutes)", "" ]
Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM.MMMM'
[ "Convert", "[", "+", "/", "-", "]", "DDD", ".", "DDDDD", "to", "[", "+", "/", "-", "]", "DDD°MMM", ".", "MMMM" ]
train
https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L80-L86
yychen/twd97
twd97/converter.py
todms
def todms(origin): """ Convert [+/-]DDD.DDDDD to a tuple (degrees, minutes, seconds) """ degrees, minutes = tomindec(origin) seconds = (minutes % 1) * 60 return degrees, int(minutes), seconds
python
def todms(origin): """ Convert [+/-]DDD.DDDDD to a tuple (degrees, minutes, seconds) """ degrees, minutes = tomindec(origin) seconds = (minutes % 1) * 60 return degrees, int(minutes), seconds
[ "def", "todms", "(", "origin", ")", ":", "degrees", ",", "minutes", "=", "tomindec", "(", "origin", ")", "seconds", "=", "(", "minutes", "%", "1", ")", "*", "60", "return", "degrees", ",", "int", "(", "minutes", ")", ",", "seconds" ]
Convert [+/-]DDD.DDDDD to a tuple (degrees, minutes, seconds)
[ "Convert", "[", "+", "/", "-", "]", "DDD", ".", "DDDDD", "to", "a", "tuple", "(", "degrees", "minutes", "seconds", ")" ]
train
https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L88-L96
yychen/twd97
twd97/converter.py
todmsstr
def todmsstr(origin): """ Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM'DDD.DDDDD" """ degrees, minutes, seconds = todms(origin) return u'%d°%d\'%f"' % (degrees, minutes, seconds)
python
def todmsstr(origin): """ Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM'DDD.DDDDD" """ degrees, minutes, seconds = todms(origin) return u'%d°%d\'%f"' % (degrees, minutes, seconds)
[ "def", "todmsstr", "(", "origin", ")", ":", "degrees", ",", "minutes", ",", "seconds", "=", "todms", "(", "origin", ")", "return", "u'%d°%d\\'%f\"' ", " ", "d", "egrees,", " ", "inutes,", " ", "econds)", "" ]
Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM'DDD.DDDDD"
[ "Convert", "[", "+", "/", "-", "]", "DDD", ".", "DDDDD", "to", "[", "+", "/", "-", "]", "DDD°MMM", "DDD", ".", "DDDDD" ]
train
https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L98-L104
yychen/twd97
twd97/converter.py
towgs84
def towgs84(E, N, pkm=False, presentation=None): """ Convert coordintes from TWD97 to WGS84 The east and north coordinates should be in meters and in float pkm true for Penghu, Kinmen and Matsu area You can specify one of the following presentations of the returned values: dms - A tuple wit...
python
def towgs84(E, N, pkm=False, presentation=None): """ Convert coordintes from TWD97 to WGS84 The east and north coordinates should be in meters and in float pkm true for Penghu, Kinmen and Matsu area You can specify one of the following presentations of the returned values: dms - A tuple wit...
[ "def", "towgs84", "(", "E", ",", "N", ",", "pkm", "=", "False", ",", "presentation", "=", "None", ")", ":", "_lng0", "=", "lng0pkm", "if", "pkm", "else", "lng0", "E", "/=", "1000.0", "N", "/=", "1000.0", "epsilon", "=", "(", "N", "-", "N0", ")", ...
Convert coordintes from TWD97 to WGS84 The east and north coordinates should be in meters and in float pkm true for Penghu, Kinmen and Matsu area You can specify one of the following presentations of the returned values: dms - A tuple with degrees (int), minutes (int) and seconds (float) dm...
[ "Convert", "coordintes", "from", "TWD97", "to", "WGS84" ]
train
https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L106-L156
yychen/twd97
twd97/converter.py
fromwgs84
def fromwgs84(lat, lng, pkm=False): """ Convert coordintes from WGS84 to TWD97 pkm true for Penghu, Kinmen and Matsu area The latitude and longitude can be in the following formats: [+/-]DDD°MMM'SSS.SSSS" (unicode) [+/-]DDD°MMM.MMMM' (unicode) [+/-]DDD.DDDDD (string, unicode or ...
python
def fromwgs84(lat, lng, pkm=False): """ Convert coordintes from WGS84 to TWD97 pkm true for Penghu, Kinmen and Matsu area The latitude and longitude can be in the following formats: [+/-]DDD°MMM'SSS.SSSS" (unicode) [+/-]DDD°MMM.MMMM' (unicode) [+/-]DDD.DDDDD (string, unicode or ...
[ "def", "fromwgs84", "(", "lat", ",", "lng", ",", "pkm", "=", "False", ")", ":", "_lng0", "=", "lng0pkm", "if", "pkm", "else", "lng0", "lat", "=", "radians", "(", "todegdec", "(", "lat", ")", ")", "lng", "=", "radians", "(", "todegdec", "(", "lng", ...
Convert coordintes from WGS84 to TWD97 pkm true for Penghu, Kinmen and Matsu area The latitude and longitude can be in the following formats: [+/-]DDD°MMM'SSS.SSSS" (unicode) [+/-]DDD°MMM.MMMM' (unicode) [+/-]DDD.DDDDD (string, unicode or float) The returned coordinates are in meter...
[ "Convert", "coordintes", "from", "WGS84", "to", "TWD97" ]
train
https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L158-L186
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.clipValue
def clipValue(self, value, minValue, maxValue): ''' Makes sure that value is within a specific range. If not, then the lower or upper bounds is returned ''' return min(max(value, minValue), maxValue)
python
def clipValue(self, value, minValue, maxValue): ''' Makes sure that value is within a specific range. If not, then the lower or upper bounds is returned ''' return min(max(value, minValue), maxValue)
[ "def", "clipValue", "(", "self", ",", "value", ",", "minValue", ",", "maxValue", ")", ":", "return", "min", "(", "max", "(", "value", ",", "minValue", ")", ",", "maxValue", ")" ]
Makes sure that value is within a specific range. If not, then the lower or upper bounds is returned
[ "Makes", "sure", "that", "value", "is", "within", "a", "specific", "range", ".", "If", "not", "then", "the", "lower", "or", "upper", "bounds", "is", "returned" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L16-L21
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.getGroundResolution
def getGroundResolution(self, latitude, level): ''' returns the ground resolution for based on latitude and zoom level. ''' latitude = self.clipValue(latitude, self.min_lat, self.max_lat); mapSize = self.getMapDimensionsByZoomLevel(level) return math.cos( lati...
python
def getGroundResolution(self, latitude, level): ''' returns the ground resolution for based on latitude and zoom level. ''' latitude = self.clipValue(latitude, self.min_lat, self.max_lat); mapSize = self.getMapDimensionsByZoomLevel(level) return math.cos( lati...
[ "def", "getGroundResolution", "(", "self", ",", "latitude", ",", "level", ")", ":", "latitude", "=", "self", ".", "clipValue", "(", "latitude", ",", "self", ".", "min_lat", ",", "self", ".", "max_lat", ")", "mapSize", "=", "self", ".", "getMapDimensionsByZ...
returns the ground resolution for based on latitude and zoom level.
[ "returns", "the", "ground", "resolution", "for", "based", "on", "latitude", "and", "zoom", "level", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L30-L38
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.getMapScale
def getMapScale(self, latitude, level, dpi=96): ''' returns the map scale on the dpi of the screen ''' dpm = dpi / 0.0254 # convert to dots per meter return self.getGroundResolution(latitude, level) * dpm
python
def getMapScale(self, latitude, level, dpi=96): ''' returns the map scale on the dpi of the screen ''' dpm = dpi / 0.0254 # convert to dots per meter return self.getGroundResolution(latitude, level) * dpm
[ "def", "getMapScale", "(", "self", ",", "latitude", ",", "level", ",", "dpi", "=", "96", ")", ":", "dpm", "=", "dpi", "/", "0.0254", "# convert to dots per meter", "return", "self", ".", "getGroundResolution", "(", "latitude", ",", "level", ")", "*", "dpm"...
returns the map scale on the dpi of the screen
[ "returns", "the", "map", "scale", "on", "the", "dpi", "of", "the", "screen" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L40-L45
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.convertLatLngToPixelXY
def convertLatLngToPixelXY(self, lat, lng, level): ''' returns the x and y values of the pixel corresponding to a latitude and longitude. ''' mapSize = self.getMapDimensionsByZoomLevel(level) lat = self.clipValue(lat, self.min_lat, self.max_lat) lng = self.clipVa...
python
def convertLatLngToPixelXY(self, lat, lng, level): ''' returns the x and y values of the pixel corresponding to a latitude and longitude. ''' mapSize = self.getMapDimensionsByZoomLevel(level) lat = self.clipValue(lat, self.min_lat, self.max_lat) lng = self.clipVa...
[ "def", "convertLatLngToPixelXY", "(", "self", ",", "lat", ",", "lng", ",", "level", ")", ":", "mapSize", "=", "self", ".", "getMapDimensionsByZoomLevel", "(", "level", ")", "lat", "=", "self", ".", "clipValue", "(", "lat", ",", "self", ".", "min_lat", ",...
returns the x and y values of the pixel corresponding to a latitude and longitude.
[ "returns", "the", "x", "and", "y", "values", "of", "the", "pixel", "corresponding", "to", "a", "latitude", "and", "longitude", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L47-L63
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.convertPixelXYToLngLat
def convertPixelXYToLngLat(self, pixelX, pixelY, level): ''' converts a pixel x, y to a latitude and longitude. ''' mapSize = self.getMapDimensionsByZoomLevel(level) x = (self.clipValue(pixelX, 0, mapSize - 1) / mapSize) - 0.5 y = 0.5 - (self.clipValue(pixelY, 0, mapSize ...
python
def convertPixelXYToLngLat(self, pixelX, pixelY, level): ''' converts a pixel x, y to a latitude and longitude. ''' mapSize = self.getMapDimensionsByZoomLevel(level) x = (self.clipValue(pixelX, 0, mapSize - 1) / mapSize) - 0.5 y = 0.5 - (self.clipValue(pixelY, 0, mapSize ...
[ "def", "convertPixelXYToLngLat", "(", "self", ",", "pixelX", ",", "pixelY", ",", "level", ")", ":", "mapSize", "=", "self", ".", "getMapDimensionsByZoomLevel", "(", "level", ")", "x", "=", "(", "self", ".", "clipValue", "(", "pixelX", ",", "0", ",", "map...
converts a pixel x, y to a latitude and longitude.
[ "converts", "a", "pixel", "x", "y", "to", "a", "latitude", "and", "longitude", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L65-L76
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.tileXYZToQuadKey
def tileXYZToQuadKey(self, x, y, z): ''' Computes quadKey value based on tile x, y and z values. ''' quadKey = '' for i in range(z, 0, -1): digit = 0 mask = 1 << (i - 1) if (x & mask) != 0: digit += 1 if (y & mask) !...
python
def tileXYZToQuadKey(self, x, y, z): ''' Computes quadKey value based on tile x, y and z values. ''' quadKey = '' for i in range(z, 0, -1): digit = 0 mask = 1 << (i - 1) if (x & mask) != 0: digit += 1 if (y & mask) !...
[ "def", "tileXYZToQuadKey", "(", "self", ",", "x", ",", "y", ",", "z", ")", ":", "quadKey", "=", "''", "for", "i", "in", "range", "(", "z", ",", "0", ",", "-", "1", ")", ":", "digit", "=", "0", "mask", "=", "1", "<<", "(", "i", "-", "1", "...
Computes quadKey value based on tile x, y and z values.
[ "Computes", "quadKey", "value", "based", "on", "tile", "x", "y", "and", "z", "values", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L92-L105
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.quadKeyToTileXYZ
def quadKeyToTileXYZ(self, quadKey): ''' Computes tile x, y and z values based on quadKey. ''' tileX = 0 tileY = 0 tileZ = len(quadKey) for i in range(tileZ, 0, -1): mask = 1 << (i - 1) value = quadKey[tileZ - i] if value == '...
python
def quadKeyToTileXYZ(self, quadKey): ''' Computes tile x, y and z values based on quadKey. ''' tileX = 0 tileY = 0 tileZ = len(quadKey) for i in range(tileZ, 0, -1): mask = 1 << (i - 1) value = quadKey[tileZ - i] if value == '...
[ "def", "quadKeyToTileXYZ", "(", "self", ",", "quadKey", ")", ":", "tileX", "=", "0", "tileY", "=", "0", "tileZ", "=", "len", "(", "quadKey", ")", "for", "i", "in", "range", "(", "tileZ", ",", "0", ",", "-", "1", ")", ":", "mask", "=", "1", "<<"...
Computes tile x, y and z values based on quadKey.
[ "Computes", "tile", "x", "y", "and", "z", "values", "based", "on", "quadKey", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L107-L135
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.getTileOrigin
def getTileOrigin(self, tileX, tileY, level): ''' Returns the upper-left hand corner lat/lng for a tile ''' pixelX, pixelY = self.convertTileXYToPixelXY(tileX, tileY) lng, lat = self.convertPixelXYToLngLat(pixelX, pixelY, level) return (lat, lng)
python
def getTileOrigin(self, tileX, tileY, level): ''' Returns the upper-left hand corner lat/lng for a tile ''' pixelX, pixelY = self.convertTileXYToPixelXY(tileX, tileY) lng, lat = self.convertPixelXYToLngLat(pixelX, pixelY, level) return (lat, lng)
[ "def", "getTileOrigin", "(", "self", ",", "tileX", ",", "tileY", ",", "level", ")", ":", "pixelX", ",", "pixelY", "=", "self", ".", "convertTileXYToPixelXY", "(", "tileX", ",", "tileY", ")", "lng", ",", "lat", "=", "self", ".", "convertPixelXYToLngLat", ...
Returns the upper-left hand corner lat/lng for a tile
[ "Returns", "the", "upper", "-", "left", "hand", "corner", "lat", "/", "lng", "for", "a", "tile" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L141-L147
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileFinder.getTileUrlsByLatLngExtent
def getTileUrlsByLatLngExtent(self, xmin, ymin, xmax, ymax, level): ''' Returns a list of tile urls by extent ''' # Upper-Left Tile tileXMin, tileYMin = self.tileUtils.convertLngLatToTileXY(xmin, ymax, level) ...
python
def getTileUrlsByLatLngExtent(self, xmin, ymin, xmax, ymax, level): ''' Returns a list of tile urls by extent ''' # Upper-Left Tile tileXMin, tileYMin = self.tileUtils.convertLngLatToTileXY(xmin, ymax, level) ...
[ "def", "getTileUrlsByLatLngExtent", "(", "self", ",", "xmin", ",", "ymin", ",", "xmax", ",", "ymax", ",", "level", ")", ":", "# Upper-Left Tile", "tileXMin", ",", "tileYMin", "=", "self", ".", "tileUtils", ".", "convertLngLatToTileXY", "(", "xmin", ",", "yma...
Returns a list of tile urls by extent
[ "Returns", "a", "list", "of", "tile", "urls", "by", "extent" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L160-L178
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileFinder.createTileUrl
def createTileUrl(self, x, y, z): ''' returns new tile url based on template ''' return self.tileTemplate.replace('{{x}}', str(x)).replace('{{y}}', str( y)).replace('{{z}}', str(z))
python
def createTileUrl(self, x, y, z): ''' returns new tile url based on template ''' return self.tileTemplate.replace('{{x}}', str(x)).replace('{{y}}', str( y)).replace('{{z}}', str(z))
[ "def", "createTileUrl", "(", "self", ",", "x", ",", "y", ",", "z", ")", ":", "return", "self", ".", "tileTemplate", ".", "replace", "(", "'{{x}}'", ",", "str", "(", "x", ")", ")", ".", "replace", "(", "'{{y}}'", ",", "str", "(", "y", ")", ")", ...
returns new tile url based on template
[ "returns", "new", "tile", "url", "based", "on", "template" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L180-L185
Hackerfleet/hfos
modules/alert/hfos/alert/manager.py
Manager.referenceframe
def referenceframe(self, event): """Handles navigational reference frame updates. These are necessary to assign geo coordinates to alerts and other misc things. :param event with incoming referenceframe message """ self.log("Got a reference frame update! ", event, lvl=e...
python
def referenceframe(self, event): """Handles navigational reference frame updates. These are necessary to assign geo coordinates to alerts and other misc things. :param event with incoming referenceframe message """ self.log("Got a reference frame update! ", event, lvl=e...
[ "def", "referenceframe", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "\"Got a reference frame update! \"", ",", "event", ",", "lvl", "=", "events", ")", "self", ".", "reference_frame", "=", "event", ".", "data" ]
Handles navigational reference frame updates. These are necessary to assign geo coordinates to alerts and other misc things. :param event with incoming referenceframe message
[ "Handles", "navigational", "reference", "frame", "updates", ".", "These", "are", "necessary", "to", "assign", "geo", "coordinates", "to", "alerts", "and", "other", "misc", "things", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/alert/hfos/alert/manager.py#L112-L122
Hackerfleet/hfos
modules/alert/hfos/alert/manager.py
Manager.userlogin
def userlogin(self, event): """Checks if an alert is ongoing and alerts the newly connected client, if so.""" client_uuid = event.clientuuid self.log(event.user, pretty=True, lvl=verbose) self.log('Adding client') self.clients[event.clientuuid] = event.user fo...
python
def userlogin(self, event): """Checks if an alert is ongoing and alerts the newly connected client, if so.""" client_uuid = event.clientuuid self.log(event.user, pretty=True, lvl=verbose) self.log('Adding client') self.clients[event.clientuuid] = event.user fo...
[ "def", "userlogin", "(", "self", ",", "event", ")", ":", "client_uuid", "=", "event", ".", "clientuuid", "self", ".", "log", "(", "event", ".", "user", ",", "pretty", "=", "True", ",", "lvl", "=", "verbose", ")", "self", ".", "log", "(", "'Adding cli...
Checks if an alert is ongoing and alerts the newly connected client, if so.
[ "Checks", "if", "an", "alert", "is", "ongoing", "and", "alerts", "the", "newly", "connected", "client", "if", "so", "." ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/alert/hfos/alert/manager.py#L153-L165
Hackerfleet/hfos
modules/alert/hfos/alert/manager.py
Manager.trigger
def trigger(self, event): """AlertManager event handler for incoming events :param event with incoming AlertManager message """ topic = event.data.get('topic', None) if topic is None: self.log('No alert topic to trigger', lvl=warn) return alert ...
python
def trigger(self, event): """AlertManager event handler for incoming events :param event with incoming AlertManager message """ topic = event.data.get('topic', None) if topic is None: self.log('No alert topic to trigger', lvl=warn) return alert ...
[ "def", "trigger", "(", "self", ",", "event", ")", ":", "topic", "=", "event", ".", "data", ".", "get", "(", "'topic'", ",", "None", ")", "if", "topic", "is", "None", ":", "self", ".", "log", "(", "'No alert topic to trigger'", ",", "lvl", "=", "warn"...
AlertManager event handler for incoming events :param event with incoming AlertManager message
[ "AlertManager", "event", "handler", "for", "incoming", "events" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/alert/hfos/alert/manager.py#L207-L224
Hackerfleet/hfos
modules/alert/hfos/alert/manager.py
Manager.cancel
def cancel(self, event): """AlertManager event handler for incoming events :param event with incoming AlertManager message """ topic = event.data.get('topic', None) if topic is None: self.log('No alert topic to cancel', lvl=warn) return self._can...
python
def cancel(self, event): """AlertManager event handler for incoming events :param event with incoming AlertManager message """ topic = event.data.get('topic', None) if topic is None: self.log('No alert topic to cancel', lvl=warn) return self._can...
[ "def", "cancel", "(", "self", ",", "event", ")", ":", "topic", "=", "event", ".", "data", ".", "get", "(", "'topic'", ",", "None", ")", "if", "topic", "is", "None", ":", "self", ".", "log", "(", "'No alert topic to cancel'", ",", "lvl", "=", "warn", ...
AlertManager event handler for incoming events :param event with incoming AlertManager message
[ "AlertManager", "event", "handler", "for", "incoming", "events" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/alert/hfos/alert/manager.py#L237-L247
Hackerfleet/hfos
hfos/tool/cli.py
cli
def cli(ctx, instance, quiet, verbose, log_level, dbhost, dbname): """Isomer Management Tool This tool supports various operations to manage isomer instances. Most of the commands are grouped. To obtain more information about the groups' available sub commands/groups, try iso [group] To disp...
python
def cli(ctx, instance, quiet, verbose, log_level, dbhost, dbname): """Isomer Management Tool This tool supports various operations to manage isomer instances. Most of the commands are grouped. To obtain more information about the groups' available sub commands/groups, try iso [group] To disp...
[ "def", "cli", "(", "ctx", ",", "instance", ",", "quiet", ",", "verbose", ",", "log_level", ",", "dbhost", ",", "dbname", ")", ":", "ctx", ".", "obj", "[", "'instance'", "]", "=", "instance", "if", "dbname", "==", "db_default", "and", "instance", "!=", ...
Isomer Management Tool This tool supports various operations to manage isomer instances. Most of the commands are grouped. To obtain more information about the groups' available sub commands/groups, try iso [group] To display details of a command or its sub groups, try iso [group] [subgroup...
[ "Isomer", "Management", "Tool" ]
train
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/cli.py#L48-L78
astrocatalogs/astrocats
astrocats/main.py
main
def main(): """Primary entry point for all AstroCats catalogs. From this entry point, all internal catalogs can be accessed and their public methods executed (for example: import scripts). """ from datetime import datetime # Initialize Command-Line and User-Config Settings, Log # --------...
python
def main(): """Primary entry point for all AstroCats catalogs. From this entry point, all internal catalogs can be accessed and their public methods executed (for example: import scripts). """ from datetime import datetime # Initialize Command-Line and User-Config Settings, Log # --------...
[ "def", "main", "(", ")", ":", "from", "datetime", "import", "datetime", "# Initialize Command-Line and User-Config Settings, Log", "# -----------------------------------------------------", "beg_time", "=", "datetime", ".", "now", "(", ")", "# Process command-line arguments to de...
Primary entry point for all AstroCats catalogs. From this entry point, all internal catalogs can be accessed and their public methods executed (for example: import scripts).
[ "Primary", "entry", "point", "for", "all", "AstroCats", "catalogs", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/main.py#L13-L73
astrocatalogs/astrocats
astrocats/main.py
setup_user_config
def setup_user_config(log): """Setup a configuration file in the user's home directory. Currently this method stores default values to a fixed configuration filename. It should be modified to run an interactive prompt session asking for parameters (or at least confirming the default ones). Argume...
python
def setup_user_config(log): """Setup a configuration file in the user's home directory. Currently this method stores default values to a fixed configuration filename. It should be modified to run an interactive prompt session asking for parameters (or at least confirming the default ones). Argume...
[ "def", "setup_user_config", "(", "log", ")", ":", "log", ".", "warning", "(", "\"AstroCats Setup\"", ")", "log", ".", "warning", "(", "\"Configure filepath: '{}'\"", ".", "format", "(", "_CONFIG_PATH", ")", ")", "# Create path to configuration file as needed", "config...
Setup a configuration file in the user's home directory. Currently this method stores default values to a fixed configuration filename. It should be modified to run an interactive prompt session asking for parameters (or at least confirming the default ones). Arguments --------- log : `loggin...
[ "Setup", "a", "configuration", "file", "in", "the", "user", "s", "home", "directory", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/main.py#L76-L113
astrocatalogs/astrocats
astrocats/main.py
load_user_config
def load_user_config(args, log): """Load settings from the user's confiuration file, and add them to `args`. Settings are loaded from the configuration file in the user's home directory. Those parameters are added (as attributes) to the `args` object. Arguments --------- args : `argparse....
python
def load_user_config(args, log): """Load settings from the user's confiuration file, and add them to `args`. Settings are loaded from the configuration file in the user's home directory. Those parameters are added (as attributes) to the `args` object. Arguments --------- args : `argparse....
[ "def", "load_user_config", "(", "args", ",", "log", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "_CONFIG_PATH", ")", ":", "err_str", "=", "(", "\"Configuration file does not exists ({}).\\n\"", ".", "format", "(", "_CONFIG_PATH", ")", "+", ...
Load settings from the user's confiuration file, and add them to `args`. Settings are loaded from the configuration file in the user's home directory. Those parameters are added (as attributes) to the `args` object. Arguments --------- args : `argparse.Namespace` Namespace object to w...
[ "Load", "settings", "from", "the", "user", "s", "confiuration", "file", "and", "add", "them", "to", "args", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/main.py#L116-L144
astrocatalogs/astrocats
astrocats/main.py
load_command_line_args
def load_command_line_args(clargs=None): """Load and parse command-line arguments. Arguments --------- args : str or None 'Faked' commandline arguments passed to `argparse`. Returns ------- args : `argparse.Namespace` object Namespace in which settings are stored - default ...
python
def load_command_line_args(clargs=None): """Load and parse command-line arguments. Arguments --------- args : str or None 'Faked' commandline arguments passed to `argparse`. Returns ------- args : `argparse.Namespace` object Namespace in which settings are stored - default ...
[ "def", "load_command_line_args", "(", "clargs", "=", "None", ")", ":", "import", "argparse", "git_vers", "=", "get_git", "(", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "'astrocats'", ",", "description", "=", "'Generate catalogs for...
Load and parse command-line arguments. Arguments --------- args : str or None 'Faked' commandline arguments passed to `argparse`. Returns ------- args : `argparse.Namespace` object Namespace in which settings are stored - default values modified by the given command-lin...
[ "Load", "and", "parse", "command", "-", "line", "arguments", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/main.py#L147-L259
astrocatalogs/astrocats
astrocats/main.py
load_log
def load_log(args): """Load a `logging.Logger` object. Arguments --------- args : `argparse.Namespace` object Namespace containing required settings: {`args.debug`, `args.verbose`, and `args.log_filename`}. Returns ------- log : `logging.Logger` object """ from ast...
python
def load_log(args): """Load a `logging.Logger` object. Arguments --------- args : `argparse.Namespace` object Namespace containing required settings: {`args.debug`, `args.verbose`, and `args.log_filename`}. Returns ------- log : `logging.Logger` object """ from ast...
[ "def", "load_log", "(", "args", ")", ":", "from", "astrocats", ".", "catalog", ".", "utils", "import", "logger", "# Determine verbosity ('None' means use default)", "log_stream_level", "=", "None", "if", "args", ".", "debug", ":", "log_stream_level", "=", "logger", ...
Load a `logging.Logger` object. Arguments --------- args : `argparse.Namespace` object Namespace containing required settings: {`args.debug`, `args.verbose`, and `args.log_filename`}. Returns ------- log : `logging.Logger` object
[ "Load", "a", "logging", ".", "Logger", "object", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/main.py#L262-L290
astrocatalogs/astrocats
compare.py
compare_dicts
def compare_dicts(old_full, new_full, old_data, new_data, depth=0): """Function compares dictionaries by key-value recursively. Old and new input data are both dictionaries """ depth = depth + 1 indent = " "*depth # Print with an indentation matching the nested-dictionary depth def my_pri...
python
def compare_dicts(old_full, new_full, old_data, new_data, depth=0): """Function compares dictionaries by key-value recursively. Old and new input data are both dictionaries """ depth = depth + 1 indent = " "*depth # Print with an indentation matching the nested-dictionary depth def my_pri...
[ "def", "compare_dicts", "(", "old_full", ",", "new_full", ",", "old_data", ",", "new_data", ",", "depth", "=", "0", ")", ":", "depth", "=", "depth", "+", "1", "indent", "=", "\" \"", "*", "depth", "# Print with an indentation matching the nested-dictionary depth"...
Function compares dictionaries by key-value recursively. Old and new input data are both dictionaries
[ "Function", "compares", "dictionaries", "by", "key", "-", "value", "recursively", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/compare.py#L99-L179
scivision/morecvutils
morecvutils/lineClipping.py
cohensutherland
def cohensutherland(xmin, ymax, xmax, ymin, x1, y1, x2, y2): """Clips a line to a rectangular area. This implements the Cohen-Sutherland line clipping algorithm. xmin, ymax, xmax and ymin denote the clipping area, into which the line defined by x1, y1 (start point) and x2, y2 (end point) will be c...
python
def cohensutherland(xmin, ymax, xmax, ymin, x1, y1, x2, y2): """Clips a line to a rectangular area. This implements the Cohen-Sutherland line clipping algorithm. xmin, ymax, xmax and ymin denote the clipping area, into which the line defined by x1, y1 (start point) and x2, y2 (end point) will be c...
[ "def", "cohensutherland", "(", "xmin", ",", "ymax", ",", "xmax", ",", "ymin", ",", "x1", ",", "y1", ",", "x2", ",", "y2", ")", ":", "INSIDE", ",", "LEFT", ",", "RIGHT", ",", "LOWER", ",", "UPPER", "=", "0", ",", "1", ",", "2", ",", "4", ",", ...
Clips a line to a rectangular area. This implements the Cohen-Sutherland line clipping algorithm. xmin, ymax, xmax and ymin denote the clipping area, into which the line defined by x1, y1 (start point) and x2, y2 (end point) will be clipped. If the line does not intersect with the rectangular cli...
[ "Clips", "a", "line", "to", "a", "rectangular", "area", "." ]
train
https://github.com/scivision/morecvutils/blob/03cd40ec9f4d577a6bc796185c3bec4a576c4d16/morecvutils/lineClipping.py#L16-L87
scivision/morecvutils
morecvutils/calcOptFlow.py
setupuv
def setupuv(rc): """ Horn Schunck legacy OpenCV function requires we use these old-fashioned cv matrices, not numpy array """ if cv is not None: (r, c) = rc u = cv.CreateMat(r, c, cv.CV_32FC1) v = cv.CreateMat(r, c, cv.CV_32FC1) return (u, v) else: return [Non...
python
def setupuv(rc): """ Horn Schunck legacy OpenCV function requires we use these old-fashioned cv matrices, not numpy array """ if cv is not None: (r, c) = rc u = cv.CreateMat(r, c, cv.CV_32FC1) v = cv.CreateMat(r, c, cv.CV_32FC1) return (u, v) else: return [Non...
[ "def", "setupuv", "(", "rc", ")", ":", "if", "cv", "is", "not", "None", ":", "(", "r", ",", "c", ")", "=", "rc", "u", "=", "cv", ".", "CreateMat", "(", "r", ",", "c", ",", "cv", ".", "CV_32FC1", ")", "v", "=", "cv", ".", "CreateMat", "(", ...
Horn Schunck legacy OpenCV function requires we use these old-fashioned cv matrices, not numpy array
[ "Horn", "Schunck", "legacy", "OpenCV", "function", "requires", "we", "use", "these", "old", "-", "fashioned", "cv", "matrices", "not", "numpy", "array" ]
train
https://github.com/scivision/morecvutils/blob/03cd40ec9f4d577a6bc796185c3bec4a576c4d16/morecvutils/calcOptFlow.py#L39-L49
astrocatalogs/astrocats
astrocats/catalog/model.py
Model._init_cat_dict
def _init_cat_dict(self, cat_dict_class, key_in_self, **kwargs): """Initialize a CatDict object, checking for errors. """ # Catch errors associated with crappy, but not unexpected data try: new_entry = cat_dict_class(self, key=key_in_self, **kwargs) except CatDictErro...
python
def _init_cat_dict(self, cat_dict_class, key_in_self, **kwargs): """Initialize a CatDict object, checking for errors. """ # Catch errors associated with crappy, but not unexpected data try: new_entry = cat_dict_class(self, key=key_in_self, **kwargs) except CatDictErro...
[ "def", "_init_cat_dict", "(", "self", ",", "cat_dict_class", ",", "key_in_self", ",", "*", "*", "kwargs", ")", ":", "# Catch errors associated with crappy, but not unexpected data", "try", ":", "new_entry", "=", "cat_dict_class", "(", "self", ",", "key", "=", "key_i...
Initialize a CatDict object, checking for errors.
[ "Initialize", "a", "CatDict", "object", "checking", "for", "errors", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/model.py#L68-L79
astrocatalogs/astrocats
astrocats/catalog/model.py
Model._add_cat_dict
def _add_cat_dict(self, cat_dict_class, key_in_self, check_for_dupes=True, **kwargs): """Add a CatDict to this Entry if initialization succeeds and it doesn't already exist within the Entry. """ # Try...
python
def _add_cat_dict(self, cat_dict_class, key_in_self, check_for_dupes=True, **kwargs): """Add a CatDict to this Entry if initialization succeeds and it doesn't already exist within the Entry. """ # Try...
[ "def", "_add_cat_dict", "(", "self", ",", "cat_dict_class", ",", "key_in_self", ",", "check_for_dupes", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# Try to create a new instance of this subclass of `CatDict`", "new_entry", "=", "self", ".", "_init_cat_dict", "("...
Add a CatDict to this Entry if initialization succeeds and it doesn't already exist within the Entry.
[ "Add", "a", "CatDict", "to", "this", "Entry", "if", "initialization", "succeeds", "and", "it", "doesn", "t", "already", "exist", "within", "the", "Entry", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/model.py#L81-L105
astrocatalogs/astrocats
astrocats/catalog/utils/tq_funcs.py
pbar
def pbar(iter, desc='', **kwargs): """Wrapper for `tqdm` progress bar. """ return tqdm( iter, desc=('<' + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + '> ' + desc), dynamic_ncols=True, **kwargs)
python
def pbar(iter, desc='', **kwargs): """Wrapper for `tqdm` progress bar. """ return tqdm( iter, desc=('<' + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + '> ' + desc), dynamic_ncols=True, **kwargs)
[ "def", "pbar", "(", "iter", ",", "desc", "=", "''", ",", "*", "*", "kwargs", ")", ":", "return", "tqdm", "(", "iter", ",", "desc", "=", "(", "'<'", "+", "str", "(", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "\"%Y-%m-%d %H:%M:%S\"", ...
Wrapper for `tqdm` progress bar.
[ "Wrapper", "for", "tqdm", "progress", "bar", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/utils/tq_funcs.py#L17-L25
astrocatalogs/astrocats
astrocats/catalog/utils/tq_funcs.py
pbar_strings
def pbar_strings(files, desc='', **kwargs): """Wrapper for `tqdm` progress bar which also sorts list of strings """ return tqdm( sorted(files, key=lambda s: s.lower()), desc=('<' + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + '> ' + desc), dynamic_ncols=True, ...
python
def pbar_strings(files, desc='', **kwargs): """Wrapper for `tqdm` progress bar which also sorts list of strings """ return tqdm( sorted(files, key=lambda s: s.lower()), desc=('<' + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + '> ' + desc), dynamic_ncols=True, ...
[ "def", "pbar_strings", "(", "files", ",", "desc", "=", "''", ",", "*", "*", "kwargs", ")", ":", "return", "tqdm", "(", "sorted", "(", "files", ",", "key", "=", "lambda", "s", ":", "s", ".", "lower", "(", ")", ")", ",", "desc", "=", "(", "'<'", ...
Wrapper for `tqdm` progress bar which also sorts list of strings
[ "Wrapper", "for", "tqdm", "progress", "bar", "which", "also", "sorts", "list", "of", "strings" ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/utils/tq_funcs.py#L28-L36
astrocatalogs/astrocats
astrocats/catalog/catalog.py
_get_task_priority
def _get_task_priority(tasks, task_priority): """Get the task `priority` corresponding to the given `task_priority`. If `task_priority` is an integer or 'None', return it. If `task_priority` is a str, return the priority of the task it matches. Otherwise, raise `ValueError`. """ if task_priorit...
python
def _get_task_priority(tasks, task_priority): """Get the task `priority` corresponding to the given `task_priority`. If `task_priority` is an integer or 'None', return it. If `task_priority` is a str, return the priority of the task it matches. Otherwise, raise `ValueError`. """ if task_priorit...
[ "def", "_get_task_priority", "(", "tasks", ",", "task_priority", ")", ":", "if", "task_priority", "is", "None", ":", "return", "None", "if", "is_integer", "(", "task_priority", ")", ":", "return", "task_priority", "if", "isinstance", "(", "task_priority", ",", ...
Get the task `priority` corresponding to the given `task_priority`. If `task_priority` is an integer or 'None', return it. If `task_priority` is a str, return the priority of the task it matches. Otherwise, raise `ValueError`.
[ "Get", "the", "task", "priority", "corresponding", "to", "the", "given", "task_priority", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L1376-L1391
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.import_data
def import_data(self): """Run all of the import tasks. This is executed by the 'scripts.main.py' when the module is run as an executable. This can also be run as a method, in which case default arguments are loaded, but can be overriden using `**kwargs`. """ tasks_list ...
python
def import_data(self): """Run all of the import tasks. This is executed by the 'scripts.main.py' when the module is run as an executable. This can also be run as a method, in which case default arguments are loaded, but can be overriden using `**kwargs`. """ tasks_list ...
[ "def", "import_data", "(", "self", ")", ":", "tasks_list", "=", "self", ".", "load_task_list", "(", ")", "warnings", ".", "filterwarnings", "(", "'ignore'", ",", "r'Warning: converting a masked element to nan.'", ")", "# FIX", "warnings", ".", "filterwarnings", "(",...
Run all of the import tasks. This is executed by the 'scripts.main.py' when the module is run as an executable. This can also be run as a method, in which case default arguments are loaded, but can be overriden using `**kwargs`.
[ "Run", "all", "of", "the", "import", "tasks", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L221-L288
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.load_task_list
def load_task_list(self): """Load the list of tasks in this catalog's 'input/tasks.json' file. A `Task` object is created for each entry, with the parameters filled in. These are placed in an OrderedDict, sorted by the `priority` parameter, with positive values and then negative values,...
python
def load_task_list(self): """Load the list of tasks in this catalog's 'input/tasks.json' file. A `Task` object is created for each entry, with the parameters filled in. These are placed in an OrderedDict, sorted by the `priority` parameter, with positive values and then negative values,...
[ "def", "load_task_list", "(", "self", ")", ":", "# In update mode, do not delete old files", "if", "self", ".", "args", ".", "update", ":", "self", ".", "log", ".", "info", "(", "\"Disabling `pre-delete` for 'update' mode.\"", ")", "self", ".", "args", ".", "delet...
Load the list of tasks in this catalog's 'input/tasks.json' file. A `Task` object is created for each entry, with the parameters filled in. These are placed in an OrderedDict, sorted by the `priority` parameter, with positive values and then negative values, e.g. [0, 2, 10, -10, -1]...
[ "Load", "the", "list", "of", "tasks", "in", "this", "catalog", "s", "input", "/", "tasks", ".", "json", "file", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L290-L406
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.add_entry
def add_entry(self, name, load=True, delete=True): """Find an existing entry in, or add a new one to, the `entries` dict. FIX: rename to `create_entry`??? Returns ------- entries : OrderedDict of Entry objects newname : str Name of matching entry found in `e...
python
def add_entry(self, name, load=True, delete=True): """Find an existing entry in, or add a new one to, the `entries` dict. FIX: rename to `create_entry`??? Returns ------- entries : OrderedDict of Entry objects newname : str Name of matching entry found in `e...
[ "def", "add_entry", "(", "self", ",", "name", ",", "load", "=", "True", ",", "delete", "=", "True", ")", ":", "newname", "=", "self", ".", "clean_entry_name", "(", "name", ")", "if", "not", "newname", ":", "raise", "(", "ValueError", "(", "'Fatal: Atte...
Find an existing entry in, or add a new one to, the `entries` dict. FIX: rename to `create_entry`??? Returns ------- entries : OrderedDict of Entry objects newname : str Name of matching entry found in `entries`, or new entry added to `entries`
[ "Find", "an", "existing", "entry", "in", "or", "add", "a", "new", "one", "to", "the", "entries", "dict", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L438-L492
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.find_entry_name_of_alias
def find_entry_name_of_alias(self, alias): """Return the first entry name with the given 'alias' included in its list of aliases. Returns ------- name of matching entry (str) or 'None' if no matches """ if alias in self.aliases: name = self.aliases[a...
python
def find_entry_name_of_alias(self, alias): """Return the first entry name with the given 'alias' included in its list of aliases. Returns ------- name of matching entry (str) or 'None' if no matches """ if alias in self.aliases: name = self.aliases[a...
[ "def", "find_entry_name_of_alias", "(", "self", ",", "alias", ")", ":", "if", "alias", "in", "self", ".", "aliases", ":", "name", "=", "self", ".", "aliases", "[", "alias", "]", "if", "name", "in", "self", ".", "entries", ":", "return", "name", "else",...
Return the first entry name with the given 'alias' included in its list of aliases. Returns ------- name of matching entry (str) or 'None' if no matches
[ "Return", "the", "first", "entry", "name", "with", "the", "given", "alias", "included", "in", "its", "list", "of", "aliases", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L517-L540
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.copy_entry_to_entry
def copy_entry_to_entry(self, fromentry, destentry, check_for_dupes=True, compare_to_existing=True): """Used by `merge_duplicates` """ self.log.info("Copy entry object '{}' to '{}'".fo...
python
def copy_entry_to_entry(self, fromentry, destentry, check_for_dupes=True, compare_to_existing=True): """Used by `merge_duplicates` """ self.log.info("Copy entry object '{}' to '{}'".fo...
[ "def", "copy_entry_to_entry", "(", "self", ",", "fromentry", ",", "destentry", ",", "check_for_dupes", "=", "True", ",", "compare_to_existing", "=", "True", ")", ":", "self", ".", "log", ".", "info", "(", "\"Copy entry object '{}' to '{}'\"", ".", "format", "(",...
Used by `merge_duplicates`
[ "Used", "by", "merge_duplicates" ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L546-L617
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.merge_duplicates
def merge_duplicates(self): """Merge and remove duplicate entries. Compares each entry ('name') in `stubs` to all later entries to check for duplicates in name or alias. If a duplicate is found, they are merged and written to file. """ if len(self.entries) == 0: ...
python
def merge_duplicates(self): """Merge and remove duplicate entries. Compares each entry ('name') in `stubs` to all later entries to check for duplicates in name or alias. If a duplicate is found, they are merged and written to file. """ if len(self.entries) == 0: ...
[ "def", "merge_duplicates", "(", "self", ")", ":", "if", "len", "(", "self", ".", "entries", ")", "==", "0", ":", "self", ".", "log", ".", "error", "(", "\"WARNING: `entries` is empty, loading stubs\"", ")", "if", "self", ".", "args", ".", "update", ":", ...
Merge and remove duplicate entries. Compares each entry ('name') in `stubs` to all later entries to check for duplicates in name or alias. If a duplicate is found, they are merged and written to file.
[ "Merge", "and", "remove", "duplicate", "entries", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L652-L746
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.load_stubs
def load_stubs(self, log_mem=False): """Load all events in their `stub` (name, alias, etc only) form. Used in `update` mode. """ # Initialize parameter related to diagnostic output of memory usage if log_mem: import psutil process = psutil.Process(os.getp...
python
def load_stubs(self, log_mem=False): """Load all events in their `stub` (name, alias, etc only) form. Used in `update` mode. """ # Initialize parameter related to diagnostic output of memory usage if log_mem: import psutil process = psutil.Process(os.getp...
[ "def", "load_stubs", "(", "self", ",", "log_mem", "=", "False", ")", ":", "# Initialize parameter related to diagnostic output of memory usage", "if", "log_mem", ":", "import", "psutil", "process", "=", "psutil", ".", "Process", "(", "os", ".", "getpid", "(", ")",...
Load all events in their `stub` (name, alias, etc only) form. Used in `update` mode.
[ "Load", "all", "events", "in", "their", "stub", "(", "name", "alias", "etc", "only", ")", "form", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L754-L851
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog._delete_entry_file
def _delete_entry_file(self, entry_name=None, entry=None): """Delete the file associated with the given entry. """ if entry_name is None and entry is None: raise RuntimeError("Either `entry_name` or `entry` must be given.") elif entry_name is not None and entry is not None: ...
python
def _delete_entry_file(self, entry_name=None, entry=None): """Delete the file associated with the given entry. """ if entry_name is None and entry is None: raise RuntimeError("Either `entry_name` or `entry` must be given.") elif entry_name is not None and entry is not None: ...
[ "def", "_delete_entry_file", "(", "self", ",", "entry_name", "=", "None", ",", "entry", "=", "None", ")", ":", "if", "entry_name", "is", "None", "and", "entry", "is", "None", ":", "raise", "RuntimeError", "(", "\"Either `entry_name` or `entry` must be given.\"", ...
Delete the file associated with the given entry.
[ "Delete", "the", "file", "associated", "with", "the", "given", "entry", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L857-L884
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.journal_entries
def journal_entries(self, clear=True, gz=False, bury=False, write_stubs=False, final=False): """Write all entries in `entries` to files, and clear. Depending on arguments and `tasks`....
python
def journal_entries(self, clear=True, gz=False, bury=False, write_stubs=False, final=False): """Write all entries in `entries` to files, and clear. Depending on arguments and `tasks`....
[ "def", "journal_entries", "(", "self", ",", "clear", "=", "True", ",", "gz", "=", "False", ",", "bury", "=", "False", ",", "write_stubs", "=", "False", ",", "final", "=", "False", ")", ":", "# if (self.current_task.priority >= 0 and", "# self.current_task...
Write all entries in `entries` to files, and clear. Depending on arguments and `tasks`. Iterates over all elements of `entries`, saving (possibly 'burying') and deleting. - If ``clear == True``, then each element of `entries` is deleted, and a `stubs` entry is added
[ "Write", "all", "entries", "in", "entries", "to", "files", "and", "clear", ".", "Depending", "on", "arguments", "and", "tasks", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L889-L945
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.set_preferred_names
def set_preferred_names(self): """Choose between each entries given name and its possible aliases for the best one. """ if len(self.entries) == 0: self.log.error("WARNING: `entries` is empty, loading stubs") self.load_stubs() task_str = self.get_current_t...
python
def set_preferred_names(self): """Choose between each entries given name and its possible aliases for the best one. """ if len(self.entries) == 0: self.log.error("WARNING: `entries` is empty, loading stubs") self.load_stubs() task_str = self.get_current_t...
[ "def", "set_preferred_names", "(", "self", ")", ":", "if", "len", "(", "self", ".", "entries", ")", "==", "0", ":", "self", ".", "log", ".", "error", "(", "\"WARNING: `entries` is empty, loading stubs\"", ")", "self", ".", "load_stubs", "(", ")", "task_str",...
Choose between each entries given name and its possible aliases for the best one.
[ "Choose", "between", "each", "entries", "given", "name", "and", "its", "possible", "aliases", "for", "the", "best", "one", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L975-L991
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog._prep_git_add_file_list
def _prep_git_add_file_list(self, repo, size_limit, fail=True, file_types=None): """Get a list of files which should be added to the given repository. Notes ----- ...
python
def _prep_git_add_file_list(self, repo, size_limit, fail=True, file_types=None): """Get a list of files which should be added to the given repository. Notes ----- ...
[ "def", "_prep_git_add_file_list", "(", "self", ",", "repo", ",", "size_limit", ",", "fail", "=", "True", ",", "file_types", "=", "None", ")", ":", "add_files", "=", "[", "]", "if", "file_types", "is", "None", ":", "file_patterns", "=", "[", "'*'", "]", ...
Get a list of files which should be added to the given repository. Notes ----- * Finds files in the *root* of the given repository path. * If `file_types` is given, only use those file types. * If an uncompressed file is above the `size_limit`, it is compressed. * If a c...
[ "Get", "a", "list", "of", "files", "which", "should", "be", "added", "to", "the", "given", "repository", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L993-L1067
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.load_url
def load_url(self, url, fname, repo=None, timeout=120, post=None, fail=False, write=True, json_sort=None, cache_only=False, archived_mode=None, ...
python
def load_url(self, url, fname, repo=None, timeout=120, post=None, fail=False, write=True, json_sort=None, cache_only=False, archived_mode=None, ...
[ "def", "load_url", "(", "self", ",", "url", ",", "fname", ",", "repo", "=", "None", ",", "timeout", "=", "120", ",", "post", "=", "None", ",", "fail", "=", "False", ",", "write", "=", "True", ",", "json_sort", "=", "None", ",", "cache_only", "=", ...
Load the given URL, or a cached-version. Load page from url or cached file, depending on the current settings. 'archived' mode applies when `args.archived` is true (from `--archived` CL argument), and when this task has `Task.archived` also set to True. 'archived' mode: ...
[ "Load", "the", "given", "URL", "or", "a", "cached", "-", "version", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L1093-L1276
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.download_url
def download_url(self, url, timeout, fail=False, post=None, verify=True): """Download text from the given url. Returns `None` on failure. Arguments --------- self url : str URL web address to download. timeout : int Duration after which U...
python
def download_url(self, url, timeout, fail=False, post=None, verify=True): """Download text from the given url. Returns `None` on failure. Arguments --------- self url : str URL web address to download. timeout : int Duration after which U...
[ "def", "download_url", "(", "self", ",", "url", ",", "timeout", ",", "fail", "=", "False", ",", "post", "=", "None", ",", "verify", "=", "True", ")", ":", "_CODE_ERRORS", "=", "[", "500", ",", "307", ",", "404", "]", "import", "requests", "session", ...
Download text from the given url. Returns `None` on failure. Arguments --------- self url : str URL web address to download. timeout : int Duration after which URL request should terminate. fail : bool If `True`, then an error...
[ "Download", "text", "from", "the", "given", "url", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L1296-L1373
astrocatalogs/astrocats
astrocats/catalog/catdict.py
CatDict.append_sources_from
def append_sources_from(self, other): """Merge the source alias lists of two CatDicts.""" # Get aliases lists from this `CatDict` and other self_aliases = self[self._KEYS.SOURCE].split(',') other_aliases = other[self._KEYS.SOURCE].split(',') # Store alias to `self` self[...
python
def append_sources_from(self, other): """Merge the source alias lists of two CatDicts.""" # Get aliases lists from this `CatDict` and other self_aliases = self[self._KEYS.SOURCE].split(',') other_aliases = other[self._KEYS.SOURCE].split(',') # Store alias to `self` self[...
[ "def", "append_sources_from", "(", "self", ",", "other", ")", ":", "# Get aliases lists from this `CatDict` and other", "self_aliases", "=", "self", "[", "self", ".", "_KEYS", ".", "SOURCE", "]", ".", "split", "(", "','", ")", "other_aliases", "=", "other", "[",...
Merge the source alias lists of two CatDicts.
[ "Merge", "the", "source", "alias", "lists", "of", "two", "CatDicts", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catdict.py#L202-L211
astrocatalogs/astrocats
astrocats/catalog/task.py
Task.current_task
def current_task(self, args): """Name of current action for progress-bar output. The specific task string is depends on the configuration via `args`. Returns ------- ctask : str String representation of this task. """ ctask = self.nice_name if self.n...
python
def current_task(self, args): """Name of current action for progress-bar output. The specific task string is depends on the configuration via `args`. Returns ------- ctask : str String representation of this task. """ ctask = self.nice_name if self.n...
[ "def", "current_task", "(", "self", ",", "args", ")", ":", "ctask", "=", "self", ".", "nice_name", "if", "self", ".", "nice_name", "is", "not", "None", "else", "self", ".", "name", "if", "args", "is", "not", "None", ":", "if", "args", ".", "update", ...
Name of current action for progress-bar output. The specific task string is depends on the configuration via `args`. Returns ------- ctask : str String representation of this task.
[ "Name", "of", "current", "action", "for", "progress", "-", "bar", "output", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/task.py#L77-L93
astrocatalogs/astrocats
astrocats/catalog/task.py
Task.load_archive
def load_archive(self, args): """Whether previously archived data should be loaded. """ import warnings warnings.warn("`Task.load_archive()` is deprecated! " "`Catalog.load_url` handles the same functionality.") return self.archived or args.archived
python
def load_archive(self, args): """Whether previously archived data should be loaded. """ import warnings warnings.warn("`Task.load_archive()` is deprecated! " "`Catalog.load_url` handles the same functionality.") return self.archived or args.archived
[ "def", "load_archive", "(", "self", ",", "args", ")", ":", "import", "warnings", "warnings", ".", "warn", "(", "\"`Task.load_archive()` is deprecated! \"", "\"`Catalog.load_url` handles the same functionality.\"", ")", "return", "self", ".", "archived", "or", "args", "...
Whether previously archived data should be loaded.
[ "Whether", "previously", "archived", "data", "should", "be", "loaded", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/task.py#L95-L101
astrocatalogs/astrocats
astrocats/catalog/gitter.py
get_sha
def get_sha(path=None, log=None, short=False, timeout=None): """Use `git rev-parse HEAD <REPO>` to get current SHA. """ # git_command = "git rev-parse HEAD {}".format(repo_name).split() # git_command = "git rev-parse HEAD".split() git_command = ["git", "rev-parse"] if short: git_command....
python
def get_sha(path=None, log=None, short=False, timeout=None): """Use `git rev-parse HEAD <REPO>` to get current SHA. """ # git_command = "git rev-parse HEAD {}".format(repo_name).split() # git_command = "git rev-parse HEAD".split() git_command = ["git", "rev-parse"] if short: git_command....
[ "def", "get_sha", "(", "path", "=", "None", ",", "log", "=", "None", ",", "short", "=", "False", ",", "timeout", "=", "None", ")", ":", "# git_command = \"git rev-parse HEAD {}\".format(repo_name).split()", "# git_command = \"git rev-parse HEAD\".split()", "git_command", ...
Use `git rev-parse HEAD <REPO>` to get current SHA.
[ "Use", "git", "rev", "-", "parse", "HEAD", "<REPO", ">", "to", "get", "current", "SHA", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L30-L56
astrocatalogs/astrocats
astrocats/catalog/gitter.py
git_add_commit_push_all_repos
def git_add_commit_push_all_repos(cat): """Add all files in each data repository tree, commit, push. Creates a commit message based on the current catalog version info. If either the `git add` or `git push` commands fail, an error will be raised. Currently, if `commit` fails an error *WILL NOT* be ra...
python
def git_add_commit_push_all_repos(cat): """Add all files in each data repository tree, commit, push. Creates a commit message based on the current catalog version info. If either the `git add` or `git push` commands fail, an error will be raised. Currently, if `commit` fails an error *WILL NOT* be ra...
[ "def", "git_add_commit_push_all_repos", "(", "cat", ")", ":", "log", "=", "cat", ".", "log", "log", ".", "debug", "(", "\"gitter.git_add_commit_push_all_repos()\"", ")", "# Do not commit/push private repos", "all_repos", "=", "cat", ".", "PATHS", ".", "get_all_repo_fo...
Add all files in each data repository tree, commit, push. Creates a commit message based on the current catalog version info. If either the `git add` or `git push` commands fail, an error will be raised. Currently, if `commit` fails an error *WILL NOT* be raised because the `commit` command will retu...
[ "Add", "all", "files", "in", "each", "data", "repository", "tree", "commit", "push", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L59-L117
astrocatalogs/astrocats
astrocats/catalog/gitter.py
git_pull_all_repos
def git_pull_all_repos(cat, strategy_recursive=True, strategy='theirs'): """Perform a 'git pull' in each data repository. > `git pull -s recursive -X theirs` """ # raise RuntimeError("THIS DOESNT WORK YET!") log = cat.log log.debug("gitter.git_pull_all_repos()") log.warning("WARNING: using ...
python
def git_pull_all_repos(cat, strategy_recursive=True, strategy='theirs'): """Perform a 'git pull' in each data repository. > `git pull -s recursive -X theirs` """ # raise RuntimeError("THIS DOESNT WORK YET!") log = cat.log log.debug("gitter.git_pull_all_repos()") log.warning("WARNING: using ...
[ "def", "git_pull_all_repos", "(", "cat", ",", "strategy_recursive", "=", "True", ",", "strategy", "=", "'theirs'", ")", ":", "# raise RuntimeError(\"THIS DOESNT WORK YET!\")", "log", "=", "cat", ".", "log", "log", ".", "debug", "(", "\"gitter.git_pull_all_repos()\"", ...
Perform a 'git pull' in each data repository. > `git pull -s recursive -X theirs`
[ "Perform", "a", "git", "pull", "in", "each", "data", "repository", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L120-L170
astrocatalogs/astrocats
astrocats/catalog/gitter.py
git_clone_all_repos
def git_clone_all_repos(cat): """Perform a 'git clone' for each data repository that doesnt exist. """ log = cat.log log.debug("gitter.git_clone_all_repos()") all_repos = cat.PATHS.get_all_repo_folders() out_repos = cat.PATHS.get_repo_output_folders() for repo in all_repos: log.info...
python
def git_clone_all_repos(cat): """Perform a 'git clone' for each data repository that doesnt exist. """ log = cat.log log.debug("gitter.git_clone_all_repos()") all_repos = cat.PATHS.get_all_repo_folders() out_repos = cat.PATHS.get_repo_output_folders() for repo in all_repos: log.info...
[ "def", "git_clone_all_repos", "(", "cat", ")", ":", "log", "=", "cat", ".", "log", "log", ".", "debug", "(", "\"gitter.git_clone_all_repos()\"", ")", "all_repos", "=", "cat", ".", "PATHS", ".", "get_all_repo_folders", "(", ")", "out_repos", "=", "cat", ".", ...
Perform a 'git clone' for each data repository that doesnt exist.
[ "Perform", "a", "git", "clone", "for", "each", "data", "repository", "that", "doesnt", "exist", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L173-L205
astrocatalogs/astrocats
astrocats/catalog/gitter.py
git_reset_all_repos
def git_reset_all_repos(cat, hard=True, origin=False, clean=True): """Perform a 'git reset' in each data repository. """ log = cat.log log.debug("gitter.git_reset_all_repos()") all_repos = cat.PATHS.get_all_repo_folders() for repo in all_repos: log.warning("Repo in: '{}'".format(repo)) ...
python
def git_reset_all_repos(cat, hard=True, origin=False, clean=True): """Perform a 'git reset' in each data repository. """ log = cat.log log.debug("gitter.git_reset_all_repos()") all_repos = cat.PATHS.get_all_repo_folders() for repo in all_repos: log.warning("Repo in: '{}'".format(repo)) ...
[ "def", "git_reset_all_repos", "(", "cat", ",", "hard", "=", "True", ",", "origin", "=", "False", ",", "clean", "=", "True", ")", ":", "log", "=", "cat", ".", "log", "log", ".", "debug", "(", "\"gitter.git_reset_all_repos()\"", ")", "all_repos", "=", "cat...
Perform a 'git reset' in each data repository.
[ "Perform", "a", "git", "reset", "in", "each", "data", "repository", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L208-L248
astrocatalogs/astrocats
astrocats/catalog/gitter.py
git_status_all_repos
def git_status_all_repos(cat, hard=True, origin=False, clean=True): """Perform a 'git status' in each data repository. """ log = cat.log log.debug("gitter.git_status_all_repos()") all_repos = cat.PATHS.get_all_repo_folders() for repo_name in all_repos: log.info("Repo in: '{}'".format(re...
python
def git_status_all_repos(cat, hard=True, origin=False, clean=True): """Perform a 'git status' in each data repository. """ log = cat.log log.debug("gitter.git_status_all_repos()") all_repos = cat.PATHS.get_all_repo_folders() for repo_name in all_repos: log.info("Repo in: '{}'".format(re...
[ "def", "git_status_all_repos", "(", "cat", ",", "hard", "=", "True", ",", "origin", "=", "False", ",", "clean", "=", "True", ")", ":", "log", "=", "cat", ".", "log", "log", ".", "debug", "(", "\"gitter.git_status_all_repos()\"", ")", "all_repos", "=", "c...
Perform a 'git status' in each data repository.
[ "Perform", "a", "git", "status", "in", "each", "data", "repository", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L251-L275
astrocatalogs/astrocats
astrocats/catalog/gitter.py
clone
def clone(repo, log, depth=1): """Given a list of repositories, make sure they're all cloned. Should be called from the subclassed `Catalog` objects, passed a list of specific repository names. Arguments --------- all_repos : list of str *Absolute* path specification of each target rep...
python
def clone(repo, log, depth=1): """Given a list of repositories, make sure they're all cloned. Should be called from the subclassed `Catalog` objects, passed a list of specific repository names. Arguments --------- all_repos : list of str *Absolute* path specification of each target rep...
[ "def", "clone", "(", "repo", ",", "log", ",", "depth", "=", "1", ")", ":", "kwargs", "=", "{", "}", "if", "depth", ">", "0", ":", "kwargs", "[", "'depth'", "]", "=", "depth", "try", ":", "repo_name", "=", "os", ".", "path", ".", "split", "(", ...
Given a list of repositories, make sure they're all cloned. Should be called from the subclassed `Catalog` objects, passed a list of specific repository names. Arguments --------- all_repos : list of str *Absolute* path specification of each target repository.
[ "Given", "a", "list", "of", "repositories", "make", "sure", "they", "re", "all", "cloned", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L278-L304
astrocatalogs/astrocats
astrocats/catalog/gitter.py
_call_command_in_repo
def _call_command_in_repo(comm, repo, log, fail=False, log_flag=True): """Use `subprocess` to call a command in a certain (repo) directory. Logs the output (both `stderr` and `stdout`) to the log, and checks the return codes to make sure they're valid. Raises error if not. Raises ------ excep...
python
def _call_command_in_repo(comm, repo, log, fail=False, log_flag=True): """Use `subprocess` to call a command in a certain (repo) directory. Logs the output (both `stderr` and `stdout`) to the log, and checks the return codes to make sure they're valid. Raises error if not. Raises ------ excep...
[ "def", "_call_command_in_repo", "(", "comm", ",", "repo", ",", "log", ",", "fail", "=", "False", ",", "log_flag", "=", "True", ")", ":", "if", "log_flag", ":", "log", ".", "debug", "(", "\"Running '{}'.\"", ".", "format", "(", "\" \"", ".", "join", "("...
Use `subprocess` to call a command in a certain (repo) directory. Logs the output (both `stderr` and `stdout`) to the log, and checks the return codes to make sure they're valid. Raises error if not. Raises ------ exception `subprocess.CalledProcessError`: if the command fails
[ "Use", "subprocess", "to", "call", "a", "command", "in", "a", "certain", "(", "repo", ")", "directory", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L307-L335
astrocatalogs/astrocats
astrocats/catalog/spectrum.py
Spectrum._check
def _check(self): """Check that spectrum has legal combination of attributes.""" # Run the super method super(Spectrum, self)._check() err_str = None has_data = self._KEYS.DATA in self has_wave = self._KEYS.WAVELENGTHS in self has_flux = self._KEYS.FLUXES in self...
python
def _check(self): """Check that spectrum has legal combination of attributes.""" # Run the super method super(Spectrum, self)._check() err_str = None has_data = self._KEYS.DATA in self has_wave = self._KEYS.WAVELENGTHS in self has_flux = self._KEYS.FLUXES in self...
[ "def", "_check", "(", "self", ")", ":", "# Run the super method", "super", "(", "Spectrum", ",", "self", ")", ".", "_check", "(", ")", "err_str", "=", "None", "has_data", "=", "self", ".", "_KEYS", ".", "DATA", "in", "self", "has_wave", "=", "self", "....
Check that spectrum has legal combination of attributes.
[ "Check", "that", "spectrum", "has", "legal", "combination", "of", "attributes", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/spectrum.py#L112-L133
astrocatalogs/astrocats
astrocats/catalog/spectrum.py
Spectrum.is_duplicate_of
def is_duplicate_of(self, other): """Check if spectrum is duplicate of another.""" if super(Spectrum, self).is_duplicate_of(other): return True row_matches = 0 for ri, row in enumerate(self.get(self._KEYS.DATA, [])): lambda1, flux1 = tuple(row[0:2]) if...
python
def is_duplicate_of(self, other): """Check if spectrum is duplicate of another.""" if super(Spectrum, self).is_duplicate_of(other): return True row_matches = 0 for ri, row in enumerate(self.get(self._KEYS.DATA, [])): lambda1, flux1 = tuple(row[0:2]) if...
[ "def", "is_duplicate_of", "(", "self", ",", "other", ")", ":", "if", "super", "(", "Spectrum", ",", "self", ")", ".", "is_duplicate_of", "(", "other", ")", ":", "return", "True", "row_matches", "=", "0", "for", "ri", ",", "row", "in", "enumerate", "(",...
Check if spectrum is duplicate of another.
[ "Check", "if", "spectrum", "is", "duplicate", "of", "another", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/spectrum.py#L135-L158
astrocatalogs/astrocats
astrocats/catalog/spectrum.py
Spectrum.sort_func
def sort_func(self, key): """Logic for sorting keys in a `Spectrum` relative to one another.""" if key == self._KEYS.TIME: return 'aaa' if key == self._KEYS.DATA: return 'zzy' if key == self._KEYS.SOURCE: return 'zzz' return key
python
def sort_func(self, key): """Logic for sorting keys in a `Spectrum` relative to one another.""" if key == self._KEYS.TIME: return 'aaa' if key == self._KEYS.DATA: return 'zzy' if key == self._KEYS.SOURCE: return 'zzz' return key
[ "def", "sort_func", "(", "self", ",", "key", ")", ":", "if", "key", "==", "self", ".", "_KEYS", ".", "TIME", ":", "return", "'aaa'", "if", "key", "==", "self", ".", "_KEYS", ".", "DATA", ":", "return", "'zzy'", "if", "key", "==", "self", ".", "_K...
Logic for sorting keys in a `Spectrum` relative to one another.
[ "Logic", "for", "sorting", "keys", "in", "a", "Spectrum", "relative", "to", "one", "another", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/spectrum.py#L160-L168
astrocatalogs/astrocats
astrocats/catalog/quantity.py
Quantity.sort_func
def sort_func(self, key): """Sorting logic for `Quantity` objects.""" if key == self._KEYS.VALUE: return 'aaa' if key == self._KEYS.SOURCE: return 'zzz' return key
python
def sort_func(self, key): """Sorting logic for `Quantity` objects.""" if key == self._KEYS.VALUE: return 'aaa' if key == self._KEYS.SOURCE: return 'zzz' return key
[ "def", "sort_func", "(", "self", ",", "key", ")", ":", "if", "key", "==", "self", ".", "_KEYS", ".", "VALUE", ":", "return", "'aaa'", "if", "key", "==", "self", ".", "_KEYS", ".", "SOURCE", ":", "return", "'zzz'", "return", "key" ]
Sorting logic for `Quantity` objects.
[ "Sorting", "logic", "for", "Quantity", "objects", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/quantity.py#L113-L119
astrocatalogs/astrocats
astrocats/catalog/key.py
KeyCollection.keys
def keys(cls): """Return this class's attribute names (those not stating with '_'). Also retrieves the attributes from base classes, e.g. For: ``ENTRY(KeyCollection)``, ``ENTRY.keys()`` gives just the attributes of `ENTRY` (`KeyCollection` has no keys). For: ``SUPERNOVA(ENT...
python
def keys(cls): """Return this class's attribute names (those not stating with '_'). Also retrieves the attributes from base classes, e.g. For: ``ENTRY(KeyCollection)``, ``ENTRY.keys()`` gives just the attributes of `ENTRY` (`KeyCollection` has no keys). For: ``SUPERNOVA(ENT...
[ "def", "keys", "(", "cls", ")", ":", "if", "cls", ".", "_keys", ":", "return", "cls", ".", "_keys", "# If `_keys` is not yet defined, create it", "# ----------------------------------------", "_keys", "=", "[", "]", "# get the keys from all base-classes aswell (when this is...
Return this class's attribute names (those not stating with '_'). Also retrieves the attributes from base classes, e.g. For: ``ENTRY(KeyCollection)``, ``ENTRY.keys()`` gives just the attributes of `ENTRY` (`KeyCollection` has no keys). For: ``SUPERNOVA(ENTRY)``, ``SUPERNOVA.keys()`...
[ "Return", "this", "class", "s", "attribute", "names", "(", "those", "not", "stating", "with", "_", ")", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/key.py#L20-L54
astrocatalogs/astrocats
astrocats/catalog/key.py
KeyCollection.vals
def vals(cls): """Return this class's attribute values (those not stating with '_'). Returns ------- _vals : list of objects List of values of internal attributes. Order is effectiely random. """ if cls._vals: return cls._vals # If `_val...
python
def vals(cls): """Return this class's attribute values (those not stating with '_'). Returns ------- _vals : list of objects List of values of internal attributes. Order is effectiely random. """ if cls._vals: return cls._vals # If `_val...
[ "def", "vals", "(", "cls", ")", ":", "if", "cls", ".", "_vals", ":", "return", "cls", ".", "_vals", "# If `_vals` is not yet defined, create it", "# ----------------------------------------", "_vals", "=", "[", "]", "# get the keys from all base-classes aswell (when this is...
Return this class's attribute values (those not stating with '_'). Returns ------- _vals : list of objects List of values of internal attributes. Order is effectiely random.
[ "Return", "this", "class", "s", "attribute", "values", "(", "those", "not", "stating", "with", "_", ")", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/key.py#L57-L85
astrocatalogs/astrocats
astrocats/catalog/key.py
KeyCollection.compare_vals
def compare_vals(cls, sort=True): """Return this class's attribute values (those not stating with '_'), but only for attributes with `compare` set to `True`. Returns ------- _compare_vals : list of objects List of values of internal attributes to use when comparing ...
python
def compare_vals(cls, sort=True): """Return this class's attribute values (those not stating with '_'), but only for attributes with `compare` set to `True`. Returns ------- _compare_vals : list of objects List of values of internal attributes to use when comparing ...
[ "def", "compare_vals", "(", "cls", ",", "sort", "=", "True", ")", ":", "if", "cls", ".", "_compare_vals", ":", "return", "cls", ".", "_compare_vals", "# If `_compare_vals` is not yet defined, create it", "# ----------------------------------------", "_compare_vals", "=", ...
Return this class's attribute values (those not stating with '_'), but only for attributes with `compare` set to `True`. Returns ------- _compare_vals : list of objects List of values of internal attributes to use when comparing `CatDict` objects. Order sorted by...
[ "Return", "this", "class", "s", "attribute", "values", "(", "those", "not", "stating", "with", "_", ")", "but", "only", "for", "attributes", "with", "compare", "set", "to", "True", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/key.py#L88-L128
astrocatalogs/astrocats
astrocats/catalog/key.py
Key.pretty
def pretty(self): """Return a 'pretty' string representation of this `Key`. note: do not override the builtin `__str__` or `__repr__` methods! """ retval = ("Key(name={}, type={}, listable={}, compare={}, " "priority={}, kind_preference={}, " "replace...
python
def pretty(self): """Return a 'pretty' string representation of this `Key`. note: do not override the builtin `__str__` or `__repr__` methods! """ retval = ("Key(name={}, type={}, listable={}, compare={}, " "priority={}, kind_preference={}, " "replace...
[ "def", "pretty", "(", "self", ")", ":", "retval", "=", "(", "\"Key(name={}, type={}, listable={}, compare={}, \"", "\"priority={}, kind_preference={}, \"", "\"replace_better={})\"", ")", ".", "format", "(", "self", ".", "name", ",", "self", ".", "type", ",", "self", ...
Return a 'pretty' string representation of this `Key`. note: do not override the builtin `__str__` or `__repr__` methods!
[ "Return", "a", "pretty", "string", "representation", "of", "this", "Key", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/key.py#L219-L229
astrocatalogs/astrocats
astrocats/catalog/key.py
Key.check
def check(self, val): """Make sure given value is consistent with this `Key` specification. NOTE: if `type` is 'None', then `listable` also is *not* checked. """ # If there is no `type` requirement, everything is allowed if self.type is None: return True is_...
python
def check(self, val): """Make sure given value is consistent with this `Key` specification. NOTE: if `type` is 'None', then `listable` also is *not* checked. """ # If there is no `type` requirement, everything is allowed if self.type is None: return True is_...
[ "def", "check", "(", "self", ",", "val", ")", ":", "# If there is no `type` requirement, everything is allowed", "if", "self", ".", "type", "is", "None", ":", "return", "True", "is_list", "=", "isinstance", "(", "val", ",", "list", ")", "# If lists are not allowed...
Make sure given value is consistent with this `Key` specification. NOTE: if `type` is 'None', then `listable` also is *not* checked.
[ "Make", "sure", "given", "value", "is", "consistent", "with", "this", "Key", "specification", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/key.py#L231-L265
astrocatalogs/astrocats
astrocats/catalog/utils/logger.py
get_logger
def get_logger(name=None, stream_fmt=None, file_fmt=None, date_fmt=None, stream_level=None, file_level=None, tofile=None, tostr=True): """Create a standard logger object which logs to file and or stdout stream. If a logger has already been created in this session, it is returned ...
python
def get_logger(name=None, stream_fmt=None, file_fmt=None, date_fmt=None, stream_level=None, file_level=None, tofile=None, tostr=True): """Create a standard logger object which logs to file and or stdout stream. If a logger has already been created in this session, it is returned ...
[ "def", "get_logger", "(", "name", "=", "None", ",", "stream_fmt", "=", "None", ",", "file_fmt", "=", "None", ",", "date_fmt", "=", "None", ",", "stream_level", "=", "None", ",", "file_level", "=", "None", ",", "tofile", "=", "None", ",", "tostr", "=", ...
Create a standard logger object which logs to file and or stdout stream. If a logger has already been created in this session, it is returned (unless `name` is given). Arguments --------- name : str, Handle for this logger, must be distinct for a distinct logger. stream_fmt : str or `N...
[ "Create", "a", "standard", "logger", "object", "which", "logs", "to", "file", "and", "or", "stdout", "stream", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/utils/logger.py#L39-L133
astrocatalogs/astrocats
astrocats/catalog/utils/logger.py
log_raise
def log_raise(log, err_str, err_type=RuntimeError): """Log an error message and raise an error. Arguments --------- log : `logging.Logger` object err_str : str Error message to be logged and raised. err_type : `Exception` object Type of error to raise. """ log.error(err...
python
def log_raise(log, err_str, err_type=RuntimeError): """Log an error message and raise an error. Arguments --------- log : `logging.Logger` object err_str : str Error message to be logged and raised. err_type : `Exception` object Type of error to raise. """ log.error(err...
[ "def", "log_raise", "(", "log", ",", "err_str", ",", "err_type", "=", "RuntimeError", ")", ":", "log", ".", "error", "(", "err_str", ")", "# Make sure output is flushed", "# (happens automatically to `StreamHandlers`, but not `FileHandlers`)", "for", "handle", "in", "lo...
Log an error message and raise an error. Arguments --------- log : `logging.Logger` object err_str : str Error message to be logged and raised. err_type : `Exception` object Type of error to raise.
[ "Log", "an", "error", "message", "and", "raise", "an", "error", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/utils/logger.py#L136-L154
astrocatalogs/astrocats
astrocats/catalog/utils/logger.py
log_memory
def log_memory(log, pref=None, lvl=logging.DEBUG, raise_flag=True): """Log the current memory usage. """ import os import sys cyc_str = "" KB = 1024.0 if pref is not None: cyc_str += "{}: ".format(pref) # Linux returns units in Bytes; OSX in kilobytes UNIT = KB*KB if sys.pla...
python
def log_memory(log, pref=None, lvl=logging.DEBUG, raise_flag=True): """Log the current memory usage. """ import os import sys cyc_str = "" KB = 1024.0 if pref is not None: cyc_str += "{}: ".format(pref) # Linux returns units in Bytes; OSX in kilobytes UNIT = KB*KB if sys.pla...
[ "def", "log_memory", "(", "log", ",", "pref", "=", "None", ",", "lvl", "=", "logging", ".", "DEBUG", ",", "raise_flag", "=", "True", ")", ":", "import", "os", "import", "sys", "cyc_str", "=", "\"\"", "KB", "=", "1024.0", "if", "pref", "is", "not", ...
Log the current memory usage.
[ "Log", "the", "current", "memory", "usage", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/utils/logger.py#L157-L207
scivision/morecvutils
morecvutils/connectedComponents.py
doblob
def doblob(morphed, blobdet, img, anno=True): """ img: can be RGB (MxNx3) or gray (MxN) http://docs.opencv.org/master/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html http://docs.opencv.org/trunk/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html """ keypo...
python
def doblob(morphed, blobdet, img, anno=True): """ img: can be RGB (MxNx3) or gray (MxN) http://docs.opencv.org/master/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html http://docs.opencv.org/trunk/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html """ keypo...
[ "def", "doblob", "(", "morphed", ",", "blobdet", ",", "img", ",", "anno", "=", "True", ")", ":", "keypoints", "=", "blobdet", ".", "detect", "(", "morphed", ")", "nkey", "=", "len", "(", "keypoints", ")", "kpsize", "=", "asarray", "(", "[", "k", "....
img: can be RGB (MxNx3) or gray (MxN) http://docs.opencv.org/master/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html http://docs.opencv.org/trunk/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html
[ "img", ":", "can", "be", "RGB", "(", "MxNx3", ")", "or", "gray", "(", "MxN", ")", "http", ":", "//", "docs", ".", "opencv", ".", "org", "/", "master", "/", "modules", "/", "features2d", "/", "doc", "/", "drawing_function_of_keypoints_and_matches", ".", ...
train
https://github.com/scivision/morecvutils/blob/03cd40ec9f4d577a6bc796185c3bec4a576c4d16/morecvutils/connectedComponents.py#L9-L28
astrocatalogs/astrocats
astrocats/catalog/argshandler.py
ArgsHandler.load_args
def load_args(self, args, clargs): """Parse arguments and return configuration settings. """ # Parse All Arguments args = self.parser.parse_args(args=clargs, namespace=args) # Print the help information if no subcommand is given # subcommand is required for operation ...
python
def load_args(self, args, clargs): """Parse arguments and return configuration settings. """ # Parse All Arguments args = self.parser.parse_args(args=clargs, namespace=args) # Print the help information if no subcommand is given # subcommand is required for operation ...
[ "def", "load_args", "(", "self", ",", "args", ",", "clargs", ")", ":", "# Parse All Arguments", "args", "=", "self", ".", "parser", ".", "parse_args", "(", "args", "=", "clargs", ",", "namespace", "=", "args", ")", "# Print the help information if no subcommand ...
Parse arguments and return configuration settings.
[ "Parse", "arguments", "and", "return", "configuration", "settings", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/argshandler.py#L56-L68
astrocatalogs/astrocats
astrocats/catalog/argshandler.py
ArgsHandler._setup_argparse
def _setup_argparse(self): """Create `argparse` instance, and setup with appropriate parameters. """ parser = argparse.ArgumentParser( prog='catalog', description='Parent Catalog class for astrocats.') subparsers = parser.add_subparsers( description='valid subcom...
python
def _setup_argparse(self): """Create `argparse` instance, and setup with appropriate parameters. """ parser = argparse.ArgumentParser( prog='catalog', description='Parent Catalog class for astrocats.') subparsers = parser.add_subparsers( description='valid subcom...
[ "def", "_setup_argparse", "(", "self", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "'catalog'", ",", "description", "=", "'Parent Catalog class for astrocats.'", ")", "subparsers", "=", "parser", ".", "add_subparsers", "(", "descr...
Create `argparse` instance, and setup with appropriate parameters.
[ "Create", "argparse", "instance", "and", "setup", "with", "appropriate", "parameters", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/argshandler.py#L70-L93
astrocatalogs/astrocats
astrocats/catalog/argshandler.py
ArgsHandler._add_parser_arguments_import
def _add_parser_arguments_import(self, subparsers): """Create parser for 'import' subcommand, and associated arguments. """ import_pars = subparsers.add_parser( "import", help="Import data.") import_pars.add_argument( '--update', '-u', dest='update', ...
python
def _add_parser_arguments_import(self, subparsers): """Create parser for 'import' subcommand, and associated arguments. """ import_pars = subparsers.add_parser( "import", help="Import data.") import_pars.add_argument( '--update', '-u', dest='update', ...
[ "def", "_add_parser_arguments_import", "(", "self", ",", "subparsers", ")", ":", "import_pars", "=", "subparsers", ".", "add_parser", "(", "\"import\"", ",", "help", "=", "\"Import data.\"", ")", "import_pars", ".", "add_argument", "(", "'--update'", ",", "'-u'", ...
Create parser for 'import' subcommand, and associated arguments.
[ "Create", "parser", "for", "import", "subcommand", "and", "associated", "arguments", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/argshandler.py#L95-L138
astrocatalogs/astrocats
astrocats/catalog/argshandler.py
ArgsHandler._add_parser_arguments_git
def _add_parser_arguments_git(self, subparsers): """Create a sub-parsers for git subcommands. """ subparsers.add_parser( "git-clone", help="Clone all defined data repositories if they dont exist.") subparsers.add_parser( "git-push", help="...
python
def _add_parser_arguments_git(self, subparsers): """Create a sub-parsers for git subcommands. """ subparsers.add_parser( "git-clone", help="Clone all defined data repositories if they dont exist.") subparsers.add_parser( "git-push", help="...
[ "def", "_add_parser_arguments_git", "(", "self", ",", "subparsers", ")", ":", "subparsers", ".", "add_parser", "(", "\"git-clone\"", ",", "help", "=", "\"Clone all defined data repositories if they dont exist.\"", ")", "subparsers", ".", "add_parser", "(", "\"git-push\"",...
Create a sub-parsers for git subcommands.
[ "Create", "a", "sub", "-", "parsers", "for", "git", "subcommands", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/argshandler.py#L140-L167
astrocatalogs/astrocats
astrocats/catalog/argshandler.py
ArgsHandler._add_parser_arguments_analyze
def _add_parser_arguments_analyze(self, subparsers): """Create a parser for the 'analyze' subcommand. """ lyze_pars = subparsers.add_parser( "analyze", help="Perform basic analysis on this catalog.") lyze_pars.add_argument( '--count', '-c', dest='coun...
python
def _add_parser_arguments_analyze(self, subparsers): """Create a parser for the 'analyze' subcommand. """ lyze_pars = subparsers.add_parser( "analyze", help="Perform basic analysis on this catalog.") lyze_pars.add_argument( '--count', '-c', dest='coun...
[ "def", "_add_parser_arguments_analyze", "(", "self", ",", "subparsers", ")", ":", "lyze_pars", "=", "subparsers", ".", "add_parser", "(", "\"analyze\"", ",", "help", "=", "\"Perform basic analysis on this catalog.\"", ")", "lyze_pars", ".", "add_argument", "(", "'--co...
Create a parser for the 'analyze' subcommand.
[ "Create", "a", "parser", "for", "the", "analyze", "subcommand", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/argshandler.py#L169-L181
astrocatalogs/astrocats
astrocats/catalog/utils/imports.py
compress_gz
def compress_gz(fname): """Compress the file with the given name and delete the uncompressed file. The compressed filename is simply the input filename with '.gz' appended. Arguments --------- fname : str Name of the file to compress and delete. Returns ------- comp_fname : st...
python
def compress_gz(fname): """Compress the file with the given name and delete the uncompressed file. The compressed filename is simply the input filename with '.gz' appended. Arguments --------- fname : str Name of the file to compress and delete. Returns ------- comp_fname : st...
[ "def", "compress_gz", "(", "fname", ")", ":", "import", "shutil", "import", "gzip", "comp_fname", "=", "fname", "+", "'.gz'", "with", "codecs", ".", "open", "(", "fname", ",", "'rb'", ")", "as", "f_in", ",", "gzip", ".", "open", "(", "comp_fname", ",",...
Compress the file with the given name and delete the uncompressed file. The compressed filename is simply the input filename with '.gz' appended. Arguments --------- fname : str Name of the file to compress and delete. Returns ------- comp_fname : str Name of the compresse...
[ "Compress", "the", "file", "with", "the", "given", "name", "and", "delete", "the", "uncompressed", "file", "." ]
train
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/utils/imports.py#L37-L60
scivision/morecvutils
morecvutils/cv2draw.py
draw_flow
def draw_flow(img, flow, step=16, dtype=uint8): """ draws flow vectors on image this came from opencv/examples directory another way: http://docs.opencv.org/trunk/doc/py_tutorials/py_gui/py_drawing_functions/py_drawing_functions.html """ maxval = iinfo(img.dtype).max # scaleFact = 1. #arbit...
python
def draw_flow(img, flow, step=16, dtype=uint8): """ draws flow vectors on image this came from opencv/examples directory another way: http://docs.opencv.org/trunk/doc/py_tutorials/py_gui/py_drawing_functions/py_drawing_functions.html """ maxval = iinfo(img.dtype).max # scaleFact = 1. #arbit...
[ "def", "draw_flow", "(", "img", ",", "flow", ",", "step", "=", "16", ",", "dtype", "=", "uint8", ")", ":", "maxval", "=", "iinfo", "(", "img", ".", "dtype", ")", ".", "max", "# scaleFact = 1. #arbitary factor to make flow visible", "canno", "=", "(", "0", ...
draws flow vectors on image this came from opencv/examples directory another way: http://docs.opencv.org/trunk/doc/py_tutorials/py_gui/py_drawing_functions/py_drawing_functions.html
[ "draws", "flow", "vectors", "on", "image", "this", "came", "from", "opencv", "/", "examples", "directory", "another", "way", ":", "http", ":", "//", "docs", ".", "opencv", ".", "org", "/", "trunk", "/", "doc", "/", "py_tutorials", "/", "py_gui", "/", "...
train
https://github.com/scivision/morecvutils/blob/03cd40ec9f4d577a6bc796185c3bec4a576c4d16/morecvutils/cv2draw.py#L7-L33
scivision/morecvutils
morecvutils/cv2draw.py
draw_hsv
def draw_hsv(mag, ang, dtype=uint8, fn=None): """ mag must be uint8, uint16, uint32 and 2-D ang is in radians (float) """ assert mag.shape == ang.shape assert mag.ndim == 2 maxval = iinfo(dtype).max hsv = dstack(((degrees(ang)/2).astype(dtype), # /2 to keep less than 255 ...
python
def draw_hsv(mag, ang, dtype=uint8, fn=None): """ mag must be uint8, uint16, uint32 and 2-D ang is in radians (float) """ assert mag.shape == ang.shape assert mag.ndim == 2 maxval = iinfo(dtype).max hsv = dstack(((degrees(ang)/2).astype(dtype), # /2 to keep less than 255 ...
[ "def", "draw_hsv", "(", "mag", ",", "ang", ",", "dtype", "=", "uint8", ",", "fn", "=", "None", ")", ":", "assert", "mag", ".", "shape", "==", "ang", ".", "shape", "assert", "mag", ".", "ndim", "==", "2", "maxval", "=", "iinfo", "(", "dtype", ")",...
mag must be uint8, uint16, uint32 and 2-D ang is in radians (float)
[ "mag", "must", "be", "uint8", "uint16", "uint32", "and", "2", "-", "D", "ang", "is", "in", "radians", "(", "float", ")" ]
train
https://github.com/scivision/morecvutils/blob/03cd40ec9f4d577a6bc796185c3bec4a576c4d16/morecvutils/cv2draw.py#L36-L54
scivision/morecvutils
morecvutils/cv2draw.py
flow2magang
def flow2magang(flow, dtype=uint8): """ flow dimensions y,x,2 3-D. flow[...,0] is magnitude, flow[...,1] is angle """ fx, fy = flow[..., 0], flow[..., 1] return hypot(fx, fy).astype(dtype), arctan2(fy, fx) + pi
python
def flow2magang(flow, dtype=uint8): """ flow dimensions y,x,2 3-D. flow[...,0] is magnitude, flow[...,1] is angle """ fx, fy = flow[..., 0], flow[..., 1] return hypot(fx, fy).astype(dtype), arctan2(fy, fx) + pi
[ "def", "flow2magang", "(", "flow", ",", "dtype", "=", "uint8", ")", ":", "fx", ",", "fy", "=", "flow", "[", "...", ",", "0", "]", ",", "flow", "[", "...", ",", "1", "]", "return", "hypot", "(", "fx", ",", "fy", ")", ".", "astype", "(", "dtype...
flow dimensions y,x,2 3-D. flow[...,0] is magnitude, flow[...,1] is angle
[ "flow", "dimensions", "y", "x", "2", "3", "-", "D", ".", "flow", "[", "...", "0", "]", "is", "magnitude", "flow", "[", "...", "1", "]", "is", "angle" ]
train
https://github.com/scivision/morecvutils/blob/03cd40ec9f4d577a6bc796185c3bec4a576c4d16/morecvutils/cv2draw.py#L57-L62
vpelletier/python-ioctl-opt
ioctl_opt/__init__.py
IOC
def IOC(dir, type, nr, size): """ dir One of IOC_NONE, IOC_WRITE, IOC_READ, or IOC_READ|IOC_WRITE. Direction is from the application's point of view, not kernel's. size (14-bits unsigned integer) Size of the buffer passed to ioctl's "arg" argument. """ assert dir <= _IOC_DIRM...
python
def IOC(dir, type, nr, size): """ dir One of IOC_NONE, IOC_WRITE, IOC_READ, or IOC_READ|IOC_WRITE. Direction is from the application's point of view, not kernel's. size (14-bits unsigned integer) Size of the buffer passed to ioctl's "arg" argument. """ assert dir <= _IOC_DIRM...
[ "def", "IOC", "(", "dir", ",", "type", ",", "nr", ",", "size", ")", ":", "assert", "dir", "<=", "_IOC_DIRMASK", ",", "dir", "assert", "type", "<=", "_IOC_TYPEMASK", ",", "type", "assert", "nr", "<=", "_IOC_NRMASK", ",", "nr", "assert", "size", "<=", ...
dir One of IOC_NONE, IOC_WRITE, IOC_READ, or IOC_READ|IOC_WRITE. Direction is from the application's point of view, not kernel's. size (14-bits unsigned integer) Size of the buffer passed to ioctl's "arg" argument.
[ "dir", "One", "of", "IOC_NONE", "IOC_WRITE", "IOC_READ", "or", "IOC_READ|IOC_WRITE", ".", "Direction", "is", "from", "the", "application", "s", "point", "of", "view", "not", "kernel", "s", ".", "size", "(", "14", "-", "bits", "unsigned", "integer", ")", "S...
train
https://github.com/vpelletier/python-ioctl-opt/blob/29ec5029af4a7de8709c449090529c4cc63d62b0/ioctl_opt/__init__.py#L50-L62
vpelletier/python-ioctl-opt
ioctl_opt/__init__.py
IOC_TYPECHECK
def IOC_TYPECHECK(t): """ Returns the size of given type, and check its suitability for use in an ioctl command number. """ result = ctypes.sizeof(t) assert result <= _IOC_SIZEMASK, result return result
python
def IOC_TYPECHECK(t): """ Returns the size of given type, and check its suitability for use in an ioctl command number. """ result = ctypes.sizeof(t) assert result <= _IOC_SIZEMASK, result return result
[ "def", "IOC_TYPECHECK", "(", "t", ")", ":", "result", "=", "ctypes", ".", "sizeof", "(", "t", ")", "assert", "result", "<=", "_IOC_SIZEMASK", ",", "result", "return", "result" ]
Returns the size of given type, and check its suitability for use in an ioctl command number.
[ "Returns", "the", "size", "of", "given", "type", "and", "check", "its", "suitability", "for", "use", "in", "an", "ioctl", "command", "number", "." ]
train
https://github.com/vpelletier/python-ioctl-opt/blob/29ec5029af4a7de8709c449090529c4cc63d62b0/ioctl_opt/__init__.py#L64-L71