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 |
|---|---|---|---|---|---|---|---|---|---|---|
GoogleCloudPlatform/httplib2shim | httplib2shim/__init__.py | _map_exception | def _map_exception(e):
"""Maps an exception from urlib3 to httplib2."""
if isinstance(e, urllib3.exceptions.MaxRetryError):
if not e.reason:
return e
e = e.reason
message = e.args[0] if e.args else ''
if isinstance(e, urllib3.exceptions.ResponseError):
if 'too many re... | python | def _map_exception(e):
"""Maps an exception from urlib3 to httplib2."""
if isinstance(e, urllib3.exceptions.MaxRetryError):
if not e.reason:
return e
e = e.reason
message = e.args[0] if e.args else ''
if isinstance(e, urllib3.exceptions.ResponseError):
if 'too many re... | [
"def",
"_map_exception",
"(",
"e",
")",
":",
"if",
"isinstance",
"(",
"e",
",",
"urllib3",
".",
"exceptions",
".",
"MaxRetryError",
")",
":",
"if",
"not",
"e",
".",
"reason",
":",
"return",
"e",
"e",
"=",
"e",
".",
"reason",
"message",
"=",
"e",
".... | Maps an exception from urlib3 to httplib2. | [
"Maps",
"an",
"exception",
"from",
"urlib3",
"to",
"httplib2",
"."
] | train | https://github.com/GoogleCloudPlatform/httplib2shim/blob/e034530c551f11cf5690ef78a24c66087976c310/httplib2shim/__init__.py#L227-L253 |
zetaops/zengine | zengine/wf_daemon.py | run_workers | def run_workers(no_subprocess, watch_paths=None, is_background=False):
"""
subprocess handler
"""
import atexit, os, subprocess, signal
if watch_paths:
from watchdog.observers import Observer
# from watchdog.observers.fsevents import FSEventsObserver as Observer
# from watchd... | python | def run_workers(no_subprocess, watch_paths=None, is_background=False):
"""
subprocess handler
"""
import atexit, os, subprocess, signal
if watch_paths:
from watchdog.observers import Observer
# from watchdog.observers.fsevents import FSEventsObserver as Observer
# from watchd... | [
"def",
"run_workers",
"(",
"no_subprocess",
",",
"watch_paths",
"=",
"None",
",",
"is_background",
"=",
"False",
")",
":",
"import",
"atexit",
",",
"os",
",",
"subprocess",
",",
"signal",
"if",
"watch_paths",
":",
"from",
"watchdog",
".",
"observers",
"impor... | subprocess handler | [
"subprocess",
"handler"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/wf_daemon.py#L235-L300 |
zetaops/zengine | zengine/wf_daemon.py | Worker.exit | def exit(self, signal=None, frame=None):
"""
Properly close the AMQP connections
"""
self.input_channel.close()
self.client_queue.close()
self.connection.close()
log.info("Worker exiting")
sys.exit(0) | python | def exit(self, signal=None, frame=None):
"""
Properly close the AMQP connections
"""
self.input_channel.close()
self.client_queue.close()
self.connection.close()
log.info("Worker exiting")
sys.exit(0) | [
"def",
"exit",
"(",
"self",
",",
"signal",
"=",
"None",
",",
"frame",
"=",
"None",
")",
":",
"self",
".",
"input_channel",
".",
"close",
"(",
")",
"self",
".",
"client_queue",
".",
"close",
"(",
")",
"self",
".",
"connection",
".",
"close",
"(",
")... | Properly close the AMQP connections | [
"Properly",
"close",
"the",
"AMQP",
"connections"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/wf_daemon.py#L48-L56 |
zetaops/zengine | zengine/wf_daemon.py | Worker.connect | def connect(self):
"""
make amqp connection and create channels and queue binding
"""
self.connection = pika.BlockingConnection(BLOCKING_MQ_PARAMS)
self.client_queue = ClientQueue()
self.input_channel = self.connection.channel()
self.input_channel.exchange_declar... | python | def connect(self):
"""
make amqp connection and create channels and queue binding
"""
self.connection = pika.BlockingConnection(BLOCKING_MQ_PARAMS)
self.client_queue = ClientQueue()
self.input_channel = self.connection.channel()
self.input_channel.exchange_declar... | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"connection",
"=",
"pika",
".",
"BlockingConnection",
"(",
"BLOCKING_MQ_PARAMS",
")",
"self",
".",
"client_queue",
"=",
"ClientQueue",
"(",
")",
"self",
".",
"input_channel",
"=",
"self",
".",
"connection... | make amqp connection and create channels and queue binding | [
"make",
"amqp",
"connection",
"and",
"create",
"channels",
"and",
"queue",
"binding"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/wf_daemon.py#L58-L72 |
zetaops/zengine | zengine/wf_daemon.py | Worker.clear_queue | def clear_queue(self):
"""
clear outs all messages from INPUT_QUEUE_NAME
"""
def remove_message(ch, method, properties, body):
print("Removed message: %s" % body)
self.input_channel.basic_consume(remove_message, queue=self.INPUT_QUEUE_NAME, no_ack=True)
try:
... | python | def clear_queue(self):
"""
clear outs all messages from INPUT_QUEUE_NAME
"""
def remove_message(ch, method, properties, body):
print("Removed message: %s" % body)
self.input_channel.basic_consume(remove_message, queue=self.INPUT_QUEUE_NAME, no_ack=True)
try:
... | [
"def",
"clear_queue",
"(",
"self",
")",
":",
"def",
"remove_message",
"(",
"ch",
",",
"method",
",",
"properties",
",",
"body",
")",
":",
"print",
"(",
"\"Removed message: %s\"",
"%",
"body",
")",
"self",
".",
"input_channel",
".",
"basic_consume",
"(",
"r... | clear outs all messages from INPUT_QUEUE_NAME | [
"clear",
"outs",
"all",
"messages",
"from",
"INPUT_QUEUE_NAME"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/wf_daemon.py#L76-L87 |
zetaops/zengine | zengine/wf_daemon.py | Worker.run | def run(self):
"""
actual consuming of incoming works starts here
"""
self.input_channel.basic_consume(self.handle_message,
queue=self.INPUT_QUEUE_NAME,
no_ack=True
... | python | def run(self):
"""
actual consuming of incoming works starts here
"""
self.input_channel.basic_consume(self.handle_message,
queue=self.INPUT_QUEUE_NAME,
no_ack=True
... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"input_channel",
".",
"basic_consume",
"(",
"self",
".",
"handle_message",
",",
"queue",
"=",
"self",
".",
"INPUT_QUEUE_NAME",
",",
"no_ack",
"=",
"True",
")",
"try",
":",
"self",
".",
"input_channel",
".... | actual consuming of incoming works starts here | [
"actual",
"consuming",
"of",
"incoming",
"works",
"starts",
"here"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/wf_daemon.py#L89-L101 |
zetaops/zengine | zengine/wf_daemon.py | Worker.handle_message | def handle_message(self, ch, method, properties, body):
"""
this is a pika.basic_consumer callback
handles client inputs, runs appropriate workflows and views
Args:
ch: amqp channel
method: amqp method
properties:
body: message body
... | python | def handle_message(self, ch, method, properties, body):
"""
this is a pika.basic_consumer callback
handles client inputs, runs appropriate workflows and views
Args:
ch: amqp channel
method: amqp method
properties:
body: message body
... | [
"def",
"handle_message",
"(",
"self",
",",
"ch",
",",
"method",
",",
"properties",
",",
"body",
")",
":",
"input",
"=",
"{",
"}",
"headers",
"=",
"{",
"}",
"try",
":",
"self",
".",
"sessid",
"=",
"method",
".",
"routing_key",
"input",
"=",
"json_deco... | this is a pika.basic_consumer callback
handles client inputs, runs appropriate workflows and views
Args:
ch: amqp channel
method: amqp method
properties:
body: message body | [
"this",
"is",
"a",
"pika",
".",
"basic_consumer",
"callback",
"handles",
"client",
"inputs",
"runs",
"appropriate",
"workflows",
"and",
"views"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/wf_daemon.py#L165-L224 |
zetaops/zengine | zengine/models/workflow_manager.py | get_progress | def get_progress(start, finish):
"""
Args:
start (DateTime): start date
finish (DateTime): finish date
Returns:
"""
now = datetime.now()
dif_time_start = start - now
dif_time_finish = finish - now
if dif_time_start.days < 0 and dif_time_finish.days < 0:
return P... | python | def get_progress(start, finish):
"""
Args:
start (DateTime): start date
finish (DateTime): finish date
Returns:
"""
now = datetime.now()
dif_time_start = start - now
dif_time_finish = finish - now
if dif_time_start.days < 0 and dif_time_finish.days < 0:
return P... | [
"def",
"get_progress",
"(",
"start",
",",
"finish",
")",
":",
"now",
"=",
"datetime",
".",
"now",
"(",
")",
"dif_time_start",
"=",
"start",
"-",
"now",
"dif_time_finish",
"=",
"finish",
"-",
"now",
"if",
"dif_time_start",
".",
"days",
"<",
"0",
"and",
... | Args:
start (DateTime): start date
finish (DateTime): finish date
Returns: | [
"Args",
":",
"start",
"(",
"DateTime",
")",
":",
"start",
"date",
"finish",
"(",
"DateTime",
")",
":",
"finish",
"date",
"Returns",
":"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L230-L249 |
zetaops/zengine | zengine/models/workflow_manager.py | sync_wf_cache | def sync_wf_cache(current):
"""
BG Job for storing wf state to DB
"""
wf_cache = WFCache(current)
wf_state = wf_cache.get() # unicode serialized json to dict, all values are unicode
if 'role_id' in wf_state:
# role_id inserted by engine, so it's a sign that we get it from cache not db
... | python | def sync_wf_cache(current):
"""
BG Job for storing wf state to DB
"""
wf_cache = WFCache(current)
wf_state = wf_cache.get() # unicode serialized json to dict, all values are unicode
if 'role_id' in wf_state:
# role_id inserted by engine, so it's a sign that we get it from cache not db
... | [
"def",
"sync_wf_cache",
"(",
"current",
")",
":",
"wf_cache",
"=",
"WFCache",
"(",
"current",
")",
"wf_state",
"=",
"wf_cache",
".",
"get",
"(",
")",
"# unicode serialized json to dict, all values are unicode",
"if",
"'role_id'",
"in",
"wf_state",
":",
"# role_id in... | BG Job for storing wf state to DB | [
"BG",
"Job",
"for",
"storing",
"wf",
"state",
"to",
"DB"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L759-L797 |
zetaops/zengine | zengine/models/workflow_manager.py | DiagramXML.get_or_create_by_content | def get_or_create_by_content(cls, name, content):
"""
if xml content updated, create a new entry for given wf name
Args:
name: name of wf
content: xml content
Returns (DiagramXML(), bool): A tuple with two members.
(DiagramXML instance and True if it's ne... | python | def get_or_create_by_content(cls, name, content):
"""
if xml content updated, create a new entry for given wf name
Args:
name: name of wf
content: xml content
Returns (DiagramXML(), bool): A tuple with two members.
(DiagramXML instance and True if it's ne... | [
"def",
"get_or_create_by_content",
"(",
"cls",
",",
"name",
",",
"content",
")",
":",
"new",
"=",
"False",
"diagrams",
"=",
"cls",
".",
"objects",
".",
"filter",
"(",
"name",
"=",
"name",
")",
"if",
"diagrams",
":",
"diagram",
"=",
"diagrams",
"[",
"0"... | if xml content updated, create a new entry for given wf name
Args:
name: name of wf
content: xml content
Returns (DiagramXML(), bool): A tuple with two members.
(DiagramXML instance and True if it's new or False it's already exists | [
"if",
"xml",
"content",
"updated",
"create",
"a",
"new",
"entry",
"for",
"given",
"wf",
"name",
"Args",
":",
"name",
":",
"name",
"of",
"wf",
"content",
":",
"xml",
"content"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L43-L63 |
zetaops/zengine | zengine/models/workflow_manager.py | BPMNParser.get_description | def get_description(self):
"""
Tries to get WF description from 'collabration' or 'process' or 'pariticipant'
Returns str: WF description
"""
paths = ['bpmn:collaboration/bpmn:participant/bpmn:documentation',
'bpmn:collaboration/bpmn:documentation',
... | python | def get_description(self):
"""
Tries to get WF description from 'collabration' or 'process' or 'pariticipant'
Returns str: WF description
"""
paths = ['bpmn:collaboration/bpmn:participant/bpmn:documentation',
'bpmn:collaboration/bpmn:documentation',
... | [
"def",
"get_description",
"(",
"self",
")",
":",
"paths",
"=",
"[",
"'bpmn:collaboration/bpmn:participant/bpmn:documentation'",
",",
"'bpmn:collaboration/bpmn:documentation'",
",",
"'bpmn:process/bpmn:documentation'",
"]",
"for",
"path",
"in",
"paths",
":",
"elm",
"=",
"s... | Tries to get WF description from 'collabration' or 'process' or 'pariticipant'
Returns str: WF description | [
"Tries",
"to",
"get",
"WF",
"description",
"from",
"collabration",
"or",
"process",
"or",
"pariticipant"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L96-L109 |
zetaops/zengine | zengine/models/workflow_manager.py | BPMNParser.get_name | def get_name(self):
"""
Tries to get WF name from 'process' or 'collobration' or 'pariticipant'
Returns:
str. WF name.
"""
paths = ['bpmn:process',
'bpmn:collaboration/bpmn:participant/',
'bpmn:collaboration',
]
... | python | def get_name(self):
"""
Tries to get WF name from 'process' or 'collobration' or 'pariticipant'
Returns:
str. WF name.
"""
paths = ['bpmn:process',
'bpmn:collaboration/bpmn:participant/',
'bpmn:collaboration',
]
... | [
"def",
"get_name",
"(",
"self",
")",
":",
"paths",
"=",
"[",
"'bpmn:process'",
",",
"'bpmn:collaboration/bpmn:participant/'",
",",
"'bpmn:collaboration'",
",",
"]",
"for",
"path",
"in",
"paths",
":",
"tag",
"=",
"self",
".",
"root",
".",
"find",
"(",
"path",... | Tries to get WF name from 'process' or 'collobration' or 'pariticipant'
Returns:
str. WF name. | [
"Tries",
"to",
"get",
"WF",
"name",
"from",
"process",
"or",
"collobration",
"or",
"pariticipant"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L111-L127 |
zetaops/zengine | zengine/models/workflow_manager.py | BPMNWorkflow.set_xml | def set_xml(self, diagram, force=False):
"""
updates xml link if there aren't any running instances of this wf
Args:
diagram: XMLDiagram object
"""
no_of_running = WFInstance.objects.filter(wf=self, finished=False, started=True).count()
if no_of_running and no... | python | def set_xml(self, diagram, force=False):
"""
updates xml link if there aren't any running instances of this wf
Args:
diagram: XMLDiagram object
"""
no_of_running = WFInstance.objects.filter(wf=self, finished=False, started=True).count()
if no_of_running and no... | [
"def",
"set_xml",
"(",
"self",
",",
"diagram",
",",
"force",
"=",
"False",
")",
":",
"no_of_running",
"=",
"WFInstance",
".",
"objects",
".",
"filter",
"(",
"wf",
"=",
"self",
",",
"finished",
"=",
"False",
",",
"started",
"=",
"True",
")",
".",
"cou... | updates xml link if there aren't any running instances of this wf
Args:
diagram: XMLDiagram object | [
"updates",
"xml",
"link",
"if",
"there",
"aren",
"t",
"any",
"running",
"instances",
"of",
"this",
"wf",
"Args",
":",
"diagram",
":",
"XMLDiagram",
"object"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L184-L205 |
zetaops/zengine | zengine/models/workflow_manager.py | Task.create_wf_instances | def create_wf_instances(self, roles=None):
"""
Creates wf instances.
Args:
roles (list): role list
Returns:
(list): wf instances
"""
# if roles specified then create an instance for each role
# else create only one instance
if ro... | python | def create_wf_instances(self, roles=None):
"""
Creates wf instances.
Args:
roles (list): role list
Returns:
(list): wf instances
"""
# if roles specified then create an instance for each role
# else create only one instance
if ro... | [
"def",
"create_wf_instances",
"(",
"self",
",",
"roles",
"=",
"None",
")",
":",
"# if roles specified then create an instance for each role",
"# else create only one instance",
"if",
"roles",
":",
"wf_instances",
"=",
"[",
"WFInstance",
"(",
"wf",
"=",
"self",
".",
"w... | Creates wf instances.
Args:
roles (list): role list
Returns:
(list): wf instances | [
"Creates",
"wf",
"instances",
".",
"Args",
":",
"roles",
"(",
"list",
")",
":",
"role",
"list"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L286-L338 |
zetaops/zengine | zengine/models/workflow_manager.py | Task.create_tasks | def create_tasks(self):
"""
will create a WFInstance per object
and per TaskInvitation for each role and WFInstance
"""
roles = self.get_roles()
if self.task_type in ["A", "D"]:
instances = self.create_wf_instances(roles=roles)
self.create_task_in... | python | def create_tasks(self):
"""
will create a WFInstance per object
and per TaskInvitation for each role and WFInstance
"""
roles = self.get_roles()
if self.task_type in ["A", "D"]:
instances = self.create_wf_instances(roles=roles)
self.create_task_in... | [
"def",
"create_tasks",
"(",
"self",
")",
":",
"roles",
"=",
"self",
".",
"get_roles",
"(",
")",
"if",
"self",
".",
"task_type",
"in",
"[",
"\"A\"",
",",
"\"D\"",
"]",
":",
"instances",
"=",
"self",
".",
"create_wf_instances",
"(",
"roles",
"=",
"roles"... | will create a WFInstance per object
and per TaskInvitation for each role and WFInstance | [
"will",
"create",
"a",
"WFInstance",
"per",
"object",
"and",
"per",
"TaskInvitation",
"for",
"each",
"role",
"and",
"WFInstance"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L354-L367 |
zetaops/zengine | zengine/models/workflow_manager.py | Task.get_object_query_dict | def get_object_query_dict(self):
"""returns objects keys according to self.object_query_code
which can be json encoded queryset filter dict or key=value set
in the following format: ```"key=val, key2 = val2 , key3= value with spaces"```
Returns:
(dict): Queryset filtering ... | python | def get_object_query_dict(self):
"""returns objects keys according to self.object_query_code
which can be json encoded queryset filter dict or key=value set
in the following format: ```"key=val, key2 = val2 , key3= value with spaces"```
Returns:
(dict): Queryset filtering ... | [
"def",
"get_object_query_dict",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"object_query_code",
",",
"dict",
")",
":",
"# _DATE_ _DATETIME_",
"return",
"self",
".",
"object_query_code",
"else",
":",
"# comma separated, key=value pairs. wrapping spaces ... | returns objects keys according to self.object_query_code
which can be json encoded queryset filter dict or key=value set
in the following format: ```"key=val, key2 = val2 , key3= value with spaces"```
Returns:
(dict): Queryset filtering dicqt | [
"returns",
"objects",
"keys",
"according",
"to",
"self",
".",
"object_query_code",
"which",
"can",
"be",
"json",
"encoded",
"queryset",
"filter",
"dict",
"or",
"key",
"=",
"value",
"set",
"in",
"the",
"following",
"format",
":",
"key",
"=",
"val",
"key2",
... | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L369-L383 |
zetaops/zengine | zengine/models/workflow_manager.py | Task.get_object_keys | def get_object_keys(self, wfi_role=None):
"""returns object keys according to task definition
which can be explicitly selected one object (self.object_key) or
result of a queryset filter.
Returns:
list of object keys
"""
if self.object_key:
return... | python | def get_object_keys(self, wfi_role=None):
"""returns object keys according to task definition
which can be explicitly selected one object (self.object_key) or
result of a queryset filter.
Returns:
list of object keys
"""
if self.object_key:
return... | [
"def",
"get_object_keys",
"(",
"self",
",",
"wfi_role",
"=",
"None",
")",
":",
"if",
"self",
".",
"object_key",
":",
"return",
"[",
"self",
".",
"object_key",
"]",
"if",
"self",
".",
"object_query_code",
":",
"model",
"=",
"model_registry",
".",
"get_model... | returns object keys according to task definition
which can be explicitly selected one object (self.object_key) or
result of a queryset filter.
Returns:
list of object keys | [
"returns",
"object",
"keys",
"according",
"to",
"task",
"definition",
"which",
"can",
"be",
"explicitly",
"selected",
"one",
"object",
"(",
"self",
".",
"object_key",
")",
"or",
"result",
"of",
"a",
"queryset",
"filter",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L385-L398 |
zetaops/zengine | zengine/models/workflow_manager.py | Task.get_model_objects | def get_model_objects(model, wfi_role=None, **kwargs):
"""
Fetches model objects by filtering with kwargs
If wfi_role is specified, then we expect kwargs contains a
filter value starting with role,
e.g. {'user': 'role.program.user'}
We replace this `role` key with role... | python | def get_model_objects(model, wfi_role=None, **kwargs):
"""
Fetches model objects by filtering with kwargs
If wfi_role is specified, then we expect kwargs contains a
filter value starting with role,
e.g. {'user': 'role.program.user'}
We replace this `role` key with role... | [
"def",
"get_model_objects",
"(",
"model",
",",
"wfi_role",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"query_dict",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"list",
... | Fetches model objects by filtering with kwargs
If wfi_role is specified, then we expect kwargs contains a
filter value starting with role,
e.g. {'user': 'role.program.user'}
We replace this `role` key with role instance parameter `wfi_role` and try to get
object that filter va... | [
"Fetches",
"model",
"objects",
"by",
"filtering",
"with",
"kwargs"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L401-L435 |
zetaops/zengine | zengine/models/workflow_manager.py | Task.get_roles | def get_roles(self):
"""
Returns:
Role instances according to task definition.
"""
if self.role.exist:
# return explicitly selected role
return [self.role]
else:
roles = []
if self.role_query_code:
# use... | python | def get_roles(self):
"""
Returns:
Role instances according to task definition.
"""
if self.role.exist:
# return explicitly selected role
return [self.role]
else:
roles = []
if self.role_query_code:
# use... | [
"def",
"get_roles",
"(",
"self",
")",
":",
"if",
"self",
".",
"role",
".",
"exist",
":",
"# return explicitly selected role",
"return",
"[",
"self",
".",
"role",
"]",
"else",
":",
"roles",
"=",
"[",
"]",
"if",
"self",
".",
"role_query_code",
":",
"# use... | Returns:
Role instances according to task definition. | [
"Returns",
":",
"Role",
"instances",
"according",
"to",
"task",
"definition",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L437-L471 |
zetaops/zengine | zengine/models/workflow_manager.py | Task.post_save | def post_save(self):
"""can be removed when a proper task manager admin interface implemented"""
if self.run:
self.run = False
self.create_tasks()
self.save() | python | def post_save(self):
"""can be removed when a proper task manager admin interface implemented"""
if self.run:
self.run = False
self.create_tasks()
self.save() | [
"def",
"post_save",
"(",
"self",
")",
":",
"if",
"self",
".",
"run",
":",
"self",
".",
"run",
"=",
"False",
"self",
".",
"create_tasks",
"(",
")",
"self",
".",
"save",
"(",
")"
] | can be removed when a proper task manager admin interface implemented | [
"can",
"be",
"removed",
"when",
"a",
"proper",
"task",
"manager",
"admin",
"interface",
"implemented"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L553-L558 |
zetaops/zengine | zengine/models/workflow_manager.py | TaskInvitation.delete_other_invitations | def delete_other_invitations(self):
"""
When one person use an invitation, we should delete other invitations
"""
# TODO: Signal logged-in users to remove the task from their task list
self.objects.filter(instance=self.instance).exclude(key=self.key).delete() | python | def delete_other_invitations(self):
"""
When one person use an invitation, we should delete other invitations
"""
# TODO: Signal logged-in users to remove the task from their task list
self.objects.filter(instance=self.instance).exclude(key=self.key).delete() | [
"def",
"delete_other_invitations",
"(",
"self",
")",
":",
"# TODO: Signal logged-in users to remove the task from their task list",
"self",
".",
"objects",
".",
"filter",
"(",
"instance",
"=",
"self",
".",
"instance",
")",
".",
"exclude",
"(",
"key",
"=",
"self",
".... | When one person use an invitation, we should delete other invitations | [
"When",
"one",
"person",
"use",
"an",
"invitation",
"we",
"should",
"delete",
"other",
"invitations"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L664-L669 |
zetaops/zengine | zengine/models/workflow_manager.py | WFCache.save | def save(self, wf_state):
"""
write wf state to DB through MQ >> Worker >> _zops_sync_wf_cache
Args:
wf_state dict: wf state
"""
self.wf_state = wf_state
self.wf_state['role_id'] = self.current.role_id
self.set(self.wf_state)
if self.wf_state[... | python | def save(self, wf_state):
"""
write wf state to DB through MQ >> Worker >> _zops_sync_wf_cache
Args:
wf_state dict: wf state
"""
self.wf_state = wf_state
self.wf_state['role_id'] = self.current.role_id
self.set(self.wf_state)
if self.wf_state[... | [
"def",
"save",
"(",
"self",
",",
"wf_state",
")",
":",
"self",
".",
"wf_state",
"=",
"wf_state",
"self",
".",
"wf_state",
"[",
"'role_id'",
"]",
"=",
"self",
".",
"current",
".",
"role_id",
"self",
".",
"set",
"(",
"self",
".",
"wf_state",
")",
"if",... | write wf state to DB through MQ >> Worker >> _zops_sync_wf_cache
Args:
wf_state dict: wf state | [
"write",
"wf",
"state",
"to",
"DB",
"through",
"MQ",
">>",
"Worker",
">>",
"_zops_sync_wf_cache"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/workflow_manager.py#L743-L755 |
zetaops/zengine | zengine/client_queue.py | ClientQueue.send_to_default_exchange | def send_to_default_exchange(self, sess_id, message=None):
"""
Send messages through RabbitMQ's default exchange,
which will be delivered through routing_key (sess_id).
This method only used for un-authenticated users, i.e. login process.
Args:
sess_id string: Sessi... | python | def send_to_default_exchange(self, sess_id, message=None):
"""
Send messages through RabbitMQ's default exchange,
which will be delivered through routing_key (sess_id).
This method only used for un-authenticated users, i.e. login process.
Args:
sess_id string: Sessi... | [
"def",
"send_to_default_exchange",
"(",
"self",
",",
"sess_id",
",",
"message",
"=",
"None",
")",
":",
"msg",
"=",
"json",
".",
"dumps",
"(",
"message",
",",
"cls",
"=",
"ZEngineJSONEncoder",
")",
"log",
".",
"debug",
"(",
"\"Sending following message to %s qu... | Send messages through RabbitMQ's default exchange,
which will be delivered through routing_key (sess_id).
This method only used for un-authenticated users, i.e. login process.
Args:
sess_id string: Session id
message dict: Message object. | [
"Send",
"messages",
"through",
"RabbitMQ",
"s",
"default",
"exchange",
"which",
"will",
"be",
"delivered",
"through",
"routing_key",
"(",
"sess_id",
")",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/client_queue.py#L59-L73 |
zetaops/zengine | zengine/client_queue.py | ClientQueue.send_to_prv_exchange | def send_to_prv_exchange(self, user_id, message=None):
"""
Send messages through logged in users private exchange.
Args:
user_id string: User key
message dict: Message object
"""
exchange = 'prv_%s' % user_id.lower()
msg = json.dumps(message, cls... | python | def send_to_prv_exchange(self, user_id, message=None):
"""
Send messages through logged in users private exchange.
Args:
user_id string: User key
message dict: Message object
"""
exchange = 'prv_%s' % user_id.lower()
msg = json.dumps(message, cls... | [
"def",
"send_to_prv_exchange",
"(",
"self",
",",
"user_id",
",",
"message",
"=",
"None",
")",
":",
"exchange",
"=",
"'prv_%s'",
"%",
"user_id",
".",
"lower",
"(",
")",
"msg",
"=",
"json",
".",
"dumps",
"(",
"message",
",",
"cls",
"=",
"ZEngineJSONEncoder... | Send messages through logged in users private exchange.
Args:
user_id string: User key
message dict: Message object | [
"Send",
"messages",
"through",
"logged",
"in",
"users",
"private",
"exchange",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/client_queue.py#L75-L87 |
cimm-kzn/CGRtools | CGRtools/algorithms/compose.py | Compose.compose | def compose(self, other):
"""
compose 2 graphs to CGR
:param other: Molecule or CGR Container
:return: CGRContainer
"""
if not isinstance(other, Compose):
raise TypeError('CGRContainer or MoleculeContainer [sub]class expected')
cgr = self._get_subcla... | python | def compose(self, other):
"""
compose 2 graphs to CGR
:param other: Molecule or CGR Container
:return: CGRContainer
"""
if not isinstance(other, Compose):
raise TypeError('CGRContainer or MoleculeContainer [sub]class expected')
cgr = self._get_subcla... | [
"def",
"compose",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Compose",
")",
":",
"raise",
"TypeError",
"(",
"'CGRContainer or MoleculeContainer [sub]class expected'",
")",
"cgr",
"=",
"self",
".",
"_get_subclass",
"(",
... | compose 2 graphs to CGR
:param other: Molecule or CGR Container
:return: CGRContainer | [
"compose",
"2",
"graphs",
"to",
"CGR"
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/compose.py#L30-L172 |
cimm-kzn/CGRtools | CGRtools/algorithms/compose.py | CGRCompose.decompose | def decompose(self):
"""
decompose CGR to pair of Molecules, which represents reactants and products state of reaction
:return: tuple of two molecules
"""
mc = self._get_subclass('MoleculeContainer')
reactants = mc()
products = mc()
for n, atom in self.a... | python | def decompose(self):
"""
decompose CGR to pair of Molecules, which represents reactants and products state of reaction
:return: tuple of two molecules
"""
mc = self._get_subclass('MoleculeContainer')
reactants = mc()
products = mc()
for n, atom in self.a... | [
"def",
"decompose",
"(",
"self",
")",
":",
"mc",
"=",
"self",
".",
"_get_subclass",
"(",
"'MoleculeContainer'",
")",
"reactants",
"=",
"mc",
"(",
")",
"products",
"=",
"mc",
"(",
")",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
"... | decompose CGR to pair of Molecules, which represents reactants and products state of reaction
:return: tuple of two molecules | [
"decompose",
"CGR",
"to",
"pair",
"of",
"Molecules",
"which",
"represents",
"reactants",
"and",
"products",
"state",
"of",
"reaction"
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/compose.py#L182-L201 |
rnwolf/jira-metrics-extract | jira_metrics_extract/cycletime.py | CycleTimeQueries.cycle_data | def cycle_data(self, verbose=False, result_cycle=None, result_size=None, result_edges=None,changelog=True):
"""Get data from JIRA for cycle/flow times and story points size change.
Build a numerically indexed data frame with the following 'fixed'
columns: `key`, 'url', 'issue_type', `summary`, ... | python | def cycle_data(self, verbose=False, result_cycle=None, result_size=None, result_edges=None,changelog=True):
"""Get data from JIRA for cycle/flow times and story points size change.
Build a numerically indexed data frame with the following 'fixed'
columns: `key`, 'url', 'issue_type', `summary`, ... | [
"def",
"cycle_data",
"(",
"self",
",",
"verbose",
"=",
"False",
",",
"result_cycle",
"=",
"None",
",",
"result_size",
"=",
"None",
",",
"result_edges",
"=",
"None",
",",
"changelog",
"=",
"True",
")",
":",
"cycle_names",
"=",
"[",
"s",
"[",
"'name'",
"... | Get data from JIRA for cycle/flow times and story points size change.
Build a numerically indexed data frame with the following 'fixed'
columns: `key`, 'url', 'issue_type', `summary`, `status`, and
`resolution` from JIRA, as well as the value of any fields set in
the `fields` dict in `s... | [
"Get",
"data",
"from",
"JIRA",
"for",
"cycle",
"/",
"flow",
"times",
"and",
"story",
"points",
"size",
"change",
"."
] | train | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/cycletime.py#L86-L357 |
rnwolf/jira-metrics-extract | jira_metrics_extract/cycletime.py | CycleTimeQueries.size_history | def size_history(self,size_data):
"""Return the a DataFrame,
indexed by day, with columns containing story size for each issue.
In addition, columns are soted by Jira Issue key. First by Project and then by id number.
"""
def my_merge(df1, df2):
# http://stackoverfl... | python | def size_history(self,size_data):
"""Return the a DataFrame,
indexed by day, with columns containing story size for each issue.
In addition, columns are soted by Jira Issue key. First by Project and then by id number.
"""
def my_merge(df1, df2):
# http://stackoverfl... | [
"def",
"size_history",
"(",
"self",
",",
"size_data",
")",
":",
"def",
"my_merge",
"(",
"df1",
",",
"df2",
")",
":",
"# http://stackoverflow.com/questions/34411495/pandas-merge-several-dataframes",
"res",
"=",
"pd",
".",
"merge",
"(",
"df1",
",",
"df2",
",",
"ho... | Return the a DataFrame,
indexed by day, with columns containing story size for each issue.
In addition, columns are soted by Jira Issue key. First by Project and then by id number. | [
"Return",
"the",
"a",
"DataFrame",
"indexed",
"by",
"day",
"with",
"columns",
"containing",
"story",
"size",
"for",
"each",
"issue",
"."
] | train | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/cycletime.py#L359-L407 |
rnwolf/jira-metrics-extract | jira_metrics_extract/cycletime.py | CycleTimeQueries.cfd | def cfd(self, cycle_data,size_history= None, pointscolumn= None, stacked = True ):
"""Return the data to build a cumulative flow diagram: a DataFrame,
indexed by day, with columns containing cumulative counts for each
of the items in the configured cycle.
In addition, a column called `c... | python | def cfd(self, cycle_data,size_history= None, pointscolumn= None, stacked = True ):
"""Return the data to build a cumulative flow diagram: a DataFrame,
indexed by day, with columns containing cumulative counts for each
of the items in the configured cycle.
In addition, a column called `c... | [
"def",
"cfd",
"(",
"self",
",",
"cycle_data",
",",
"size_history",
"=",
"None",
",",
"pointscolumn",
"=",
"None",
",",
"stacked",
"=",
"True",
")",
":",
"# Define helper function",
"def",
"cumulativeColumnStates",
"(",
"df",
",",
"stacked",
")",
":",
"\"\"\"... | Return the data to build a cumulative flow diagram: a DataFrame,
indexed by day, with columns containing cumulative counts for each
of the items in the configured cycle.
In addition, a column called `cycle_time` contains the approximate
average cycle time of that day based on the first ... | [
"Return",
"the",
"data",
"to",
"build",
"a",
"cumulative",
"flow",
"diagram",
":",
"a",
"DataFrame",
"indexed",
"by",
"day",
"with",
"columns",
"containing",
"cumulative",
"counts",
"for",
"each",
"of",
"the",
"items",
"in",
"the",
"configured",
"cycle",
"."... | train | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/cycletime.py#L410-L641 |
rnwolf/jira-metrics-extract | jira_metrics_extract/cycletime.py | CycleTimeQueries.histogram | def histogram(self, cycle_data, bins=10):
"""Return histogram data for the cycle times in `cycle_data`. Returns
a dictionary with keys `bin_values` and `bin_edges` of numpy arrays
"""
values, edges = np.histogram(cycle_data['cycle_time'].astype('timedelta64[D]').dropna(), bins=bins)
... | python | def histogram(self, cycle_data, bins=10):
"""Return histogram data for the cycle times in `cycle_data`. Returns
a dictionary with keys `bin_values` and `bin_edges` of numpy arrays
"""
values, edges = np.histogram(cycle_data['cycle_time'].astype('timedelta64[D]').dropna(), bins=bins)
... | [
"def",
"histogram",
"(",
"self",
",",
"cycle_data",
",",
"bins",
"=",
"10",
")",
":",
"values",
",",
"edges",
"=",
"np",
".",
"histogram",
"(",
"cycle_data",
"[",
"'cycle_time'",
"]",
".",
"astype",
"(",
"'timedelta64[D]'",
")",
".",
"dropna",
"(",
")"... | Return histogram data for the cycle times in `cycle_data`. Returns
a dictionary with keys `bin_values` and `bin_edges` of numpy arrays | [
"Return",
"histogram",
"data",
"for",
"the",
"cycle",
"times",
"in",
"cycle_data",
".",
"Returns",
"a",
"dictionary",
"with",
"keys",
"bin_values",
"and",
"bin_edges",
"of",
"numpy",
"arrays"
] | train | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/cycletime.py#L644-L656 |
rnwolf/jira-metrics-extract | jira_metrics_extract/cycletime.py | CycleTimeQueries.throughput_data | def throughput_data(self, cycle_data, frequency='1D',pointscolumn= None):
"""Return a data frame with columns `completed_timestamp` of the
given frequency, either
`count`, where count is the number of items
'sum', where sum is the sum of value specified by pointscolumn. Expected to be 'S... | python | def throughput_data(self, cycle_data, frequency='1D',pointscolumn= None):
"""Return a data frame with columns `completed_timestamp` of the
given frequency, either
`count`, where count is the number of items
'sum', where sum is the sum of value specified by pointscolumn. Expected to be 'S... | [
"def",
"throughput_data",
"(",
"self",
",",
"cycle_data",
",",
"frequency",
"=",
"'1D'",
",",
"pointscolumn",
"=",
"None",
")",
":",
"if",
"len",
"(",
"cycle_data",
")",
"<",
"1",
":",
"return",
"None",
"# Note completed items yet, return None",
"if",
"pointsc... | Return a data frame with columns `completed_timestamp` of the
given frequency, either
`count`, where count is the number of items
'sum', where sum is the sum of value specified by pointscolumn. Expected to be 'StoryPoints'
completed at that timestamp (e.g. daily). | [
"Return",
"a",
"data",
"frame",
"with",
"columns",
"completed_timestamp",
"of",
"the",
"given",
"frequency",
"either",
"count",
"where",
"count",
"is",
"the",
"number",
"of",
"items",
"sum",
"where",
"sum",
"is",
"the",
"sum",
"of",
"value",
"specified",
"by... | train | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/cycletime.py#L658-L679 |
rnwolf/jira-metrics-extract | jira_metrics_extract/cycletime.py | CycleTimeQueries.scatterplot | def scatterplot(self, cycle_data):
"""Return scatterplot data for the cycle times in `cycle_data`. Returns
a data frame containing only those items in `cycle_data` where values
are set for `completed_timestamp` and `cycle_time`, and with those two
columns as the first two, both normalise... | python | def scatterplot(self, cycle_data):
"""Return scatterplot data for the cycle times in `cycle_data`. Returns
a data frame containing only those items in `cycle_data` where values
are set for `completed_timestamp` and `cycle_time`, and with those two
columns as the first two, both normalise... | [
"def",
"scatterplot",
"(",
"self",
",",
"cycle_data",
")",
":",
"columns",
"=",
"list",
"(",
"cycle_data",
".",
"columns",
")",
"columns",
".",
"remove",
"(",
"'cycle_time'",
")",
"columns",
".",
"remove",
"(",
"'completed_timestamp'",
")",
"columns",
"=",
... | Return scatterplot data for the cycle times in `cycle_data`. Returns
a data frame containing only those items in `cycle_data` where values
are set for `completed_timestamp` and `cycle_time`, and with those two
columns as the first two, both normalised to whole days, and with
`completed_t... | [
"Return",
"scatterplot",
"data",
"for",
"the",
"cycle",
"times",
"in",
"cycle_data",
".",
"Returns",
"a",
"data",
"frame",
"containing",
"only",
"those",
"items",
"in",
"cycle_data",
"where",
"values",
"are",
"set",
"for",
"completed_timestamp",
"and",
"cycle_ti... | train | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/cycletime.py#L681-L703 |
deep-compute/logagg | logagg/nsqsender.py | NSQSender._is_ready | def _is_ready(self, topic_name):
'''
Is NSQ running and have space to receive messages?
'''
url = 'http://%s/stats?format=json&topic=%s' % (self.nsqd_http_address, topic_name)
#Cheacking for ephmeral channels
if '#' in topic_name:
topic_name, tag =topic_name.s... | python | def _is_ready(self, topic_name):
'''
Is NSQ running and have space to receive messages?
'''
url = 'http://%s/stats?format=json&topic=%s' % (self.nsqd_http_address, topic_name)
#Cheacking for ephmeral channels
if '#' in topic_name:
topic_name, tag =topic_name.s... | [
"def",
"_is_ready",
"(",
"self",
",",
"topic_name",
")",
":",
"url",
"=",
"'http://%s/stats?format=json&topic=%s'",
"%",
"(",
"self",
".",
"nsqd_http_address",
",",
"topic_name",
")",
"#Cheacking for ephmeral channels",
"if",
"'#'",
"in",
"topic_name",
":",
"topic_n... | Is NSQ running and have space to receive messages? | [
"Is",
"NSQ",
"running",
"and",
"have",
"space",
"to",
"receive",
"messages?"
] | train | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/nsqsender.py#L39-L74 |
cimm-kzn/CGRtools | CGRtools/containers/query.py | QueryContainer._matcher | def _matcher(self, other):
"""
QueryContainer < MoleculeContainer
QueryContainer < QueryContainer[more general]
QueryContainer < QueryCGRContainer[more general]
"""
if isinstance(other, MoleculeContainer):
return GraphMatcher(other, self, lambda x, y: y == x, ... | python | def _matcher(self, other):
"""
QueryContainer < MoleculeContainer
QueryContainer < QueryContainer[more general]
QueryContainer < QueryCGRContainer[more general]
"""
if isinstance(other, MoleculeContainer):
return GraphMatcher(other, self, lambda x, y: y == x, ... | [
"def",
"_matcher",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"MoleculeContainer",
")",
":",
"return",
"GraphMatcher",
"(",
"other",
",",
"self",
",",
"lambda",
"x",
",",
"y",
":",
"y",
"==",
"x",
",",
"lambda",
"x",
... | QueryContainer < MoleculeContainer
QueryContainer < QueryContainer[more general]
QueryContainer < QueryCGRContainer[more general] | [
"QueryContainer",
"<",
"MoleculeContainer",
"QueryContainer",
"<",
"QueryContainer",
"[",
"more",
"general",
"]",
"QueryContainer",
"<",
"QueryCGRContainer",
"[",
"more",
"general",
"]"
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/query.py#L31-L41 |
cimm-kzn/CGRtools | CGRtools/containers/query.py | QueryCGRContainer._matcher | def _matcher(self, other):
"""
QueryCGRContainer < CGRContainer
QueryContainer < QueryCGRContainer[more general]
"""
if isinstance(other, CGRContainer):
return GraphMatcher(other, self, lambda x, y: y == x, lambda x, y: y == x)
elif isinstance(other, QueryCGRC... | python | def _matcher(self, other):
"""
QueryCGRContainer < CGRContainer
QueryContainer < QueryCGRContainer[more general]
"""
if isinstance(other, CGRContainer):
return GraphMatcher(other, self, lambda x, y: y == x, lambda x, y: y == x)
elif isinstance(other, QueryCGRC... | [
"def",
"_matcher",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"CGRContainer",
")",
":",
"return",
"GraphMatcher",
"(",
"other",
",",
"self",
",",
"lambda",
"x",
",",
"y",
":",
"y",
"==",
"x",
",",
"lambda",
"x",
","... | QueryCGRContainer < CGRContainer
QueryContainer < QueryCGRContainer[more general] | [
"QueryCGRContainer",
"<",
"CGRContainer",
"QueryContainer",
"<",
"QueryCGRContainer",
"[",
"more",
"general",
"]"
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/query.py#L48-L57 |
cimm-kzn/CGRtools | CGRtools/algorithms/calculate2d.py | Calculate2D.calculate2d | def calculate2d(self, force=False, scale=1):
"""
recalculate 2d coordinates. currently rings can be calculated badly.
:param scale: rescale calculated positions.
:param force: ignore existing coordinates of atoms
"""
dist = {}
# length forces
for n, m_bon... | python | def calculate2d(self, force=False, scale=1):
"""
recalculate 2d coordinates. currently rings can be calculated badly.
:param scale: rescale calculated positions.
:param force: ignore existing coordinates of atoms
"""
dist = {}
# length forces
for n, m_bon... | [
"def",
"calculate2d",
"(",
"self",
",",
"force",
"=",
"False",
",",
"scale",
"=",
"1",
")",
":",
"dist",
"=",
"{",
"}",
"# length forces",
"for",
"n",
",",
"m_bond",
"in",
"self",
".",
"_adj",
".",
"items",
"(",
")",
":",
"dist",
"[",
"n",
"]",
... | recalculate 2d coordinates. currently rings can be calculated badly.
:param scale: rescale calculated positions.
:param force: ignore existing coordinates of atoms | [
"recalculate",
"2d",
"coordinates",
".",
"currently",
"rings",
"can",
"be",
"calculated",
"badly",
"."
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/calculate2d.py#L24-L79 |
LordDarkula/chess_py | chess_py/pieces/knight.py | Knight.possible_moves | def possible_moves(self, position):
"""
Finds all possible knight moves
:type: position Board
:rtype: list
"""
for direction in [0, 1, 2, 3]:
angles = self._rotate_direction_ninety_degrees(direction)
for angle in angles:
try:
... | python | def possible_moves(self, position):
"""
Finds all possible knight moves
:type: position Board
:rtype: list
"""
for direction in [0, 1, 2, 3]:
angles = self._rotate_direction_ninety_degrees(direction)
for angle in angles:
try:
... | [
"def",
"possible_moves",
"(",
"self",
",",
"position",
")",
":",
"for",
"direction",
"in",
"[",
"0",
",",
"1",
",",
"2",
",",
"3",
"]",
":",
"angles",
"=",
"self",
".",
"_rotate_direction_ninety_degrees",
"(",
"direction",
")",
"for",
"angle",
"in",
"a... | Finds all possible knight moves
:type: position Board
:rtype: list | [
"Finds",
"all",
"possible",
"knight",
"moves",
":",
"type",
":",
"position",
"Board",
":",
"rtype",
":",
"list"
] | train | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/knight.py#L57-L81 |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer.centers_list | def centers_list(self):
""" get a list of lists of atoms of reaction centers
"""
center = set()
adj = defaultdict(set)
for n, atom in self.atoms():
if atom._reactant != atom._product:
center.add(n)
for n, m, bond in self.bonds():
i... | python | def centers_list(self):
""" get a list of lists of atoms of reaction centers
"""
center = set()
adj = defaultdict(set)
for n, atom in self.atoms():
if atom._reactant != atom._product:
center.add(n)
for n, m, bond in self.bonds():
i... | [
"def",
"centers_list",
"(",
"self",
")",
":",
"center",
"=",
"set",
"(",
")",
"adj",
"=",
"defaultdict",
"(",
"set",
")",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"if",
"atom",
".",
"_reactant",
"!=",
"atom",
".",
"_pro... | get a list of lists of atoms of reaction centers | [
"get",
"a",
"list",
"of",
"lists",
"of",
"atoms",
"of",
"reaction",
"centers"
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L37-L63 |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer.center_atoms | def center_atoms(self):
""" get list of atoms of reaction center (atoms with dynamic: bonds, charges, radicals).
"""
nodes = set()
for n, atom in self.atoms():
if atom._reactant != atom._product:
nodes.add(n)
for n, m, bond in self.bonds():
... | python | def center_atoms(self):
""" get list of atoms of reaction center (atoms with dynamic: bonds, charges, radicals).
"""
nodes = set()
for n, atom in self.atoms():
if atom._reactant != atom._product:
nodes.add(n)
for n, m, bond in self.bonds():
... | [
"def",
"center_atoms",
"(",
"self",
")",
":",
"nodes",
"=",
"set",
"(",
")",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"if",
"atom",
".",
"_reactant",
"!=",
"atom",
".",
"_product",
":",
"nodes",
".",
"add",
"(",
"n",
... | get list of atoms of reaction center (atoms with dynamic: bonds, charges, radicals). | [
"get",
"list",
"of",
"atoms",
"of",
"reaction",
"center",
"(",
"atoms",
"with",
"dynamic",
":",
"bonds",
"charges",
"radicals",
")",
"."
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L66-L79 |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer.center_bonds | def center_bonds(self):
""" get list of bonds of reaction center (bonds with dynamic orders).
"""
return [(n, m) for n, m, bond in self.bonds() if bond._reactant != bond._product] | python | def center_bonds(self):
""" get list of bonds of reaction center (bonds with dynamic orders).
"""
return [(n, m) for n, m, bond in self.bonds() if bond._reactant != bond._product] | [
"def",
"center_bonds",
"(",
"self",
")",
":",
"return",
"[",
"(",
"n",
",",
"m",
")",
"for",
"n",
",",
"m",
",",
"bond",
"in",
"self",
".",
"bonds",
"(",
")",
"if",
"bond",
".",
"_reactant",
"!=",
"bond",
".",
"_product",
"]"
] | get list of bonds of reaction center (bonds with dynamic orders). | [
"get",
"list",
"of",
"bonds",
"of",
"reaction",
"center",
"(",
"bonds",
"with",
"dynamic",
"orders",
")",
"."
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L82-L85 |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer.reset_query_marks | def reset_query_marks(self):
"""
set or reset hyb and neighbors marks to atoms.
"""
for i, atom in self.atoms():
neighbors = 0
hybridization = 1
p_neighbors = 0
p_hybridization = 1
# hyb 1- sp3; 2- sp2; 3- sp1; 4- aromatic
... | python | def reset_query_marks(self):
"""
set or reset hyb and neighbors marks to atoms.
"""
for i, atom in self.atoms():
neighbors = 0
hybridization = 1
p_neighbors = 0
p_hybridization = 1
# hyb 1- sp3; 2- sp2; 3- sp1; 4- aromatic
... | [
"def",
"reset_query_marks",
"(",
"self",
")",
":",
"for",
"i",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"neighbors",
"=",
"0",
"hybridization",
"=",
"1",
"p_neighbors",
"=",
"0",
"p_hybridization",
"=",
"1",
"# hyb 1- sp3; 2- sp2; 3- sp1; 4- a... | set or reset hyb and neighbors marks to atoms. | [
"set",
"or",
"reset",
"hyb",
"and",
"neighbors",
"marks",
"to",
"atoms",
"."
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L87-L134 |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer.substructure | def substructure(self, atoms, meta=False, as_view=True):
"""
create substructure containing atoms from nbunch list
:param atoms: list of atoms numbers of substructure
:param meta: if True metadata will be copied to substructure
:param as_view: If True, the returned graph-view pr... | python | def substructure(self, atoms, meta=False, as_view=True):
"""
create substructure containing atoms from nbunch list
:param atoms: list of atoms numbers of substructure
:param meta: if True metadata will be copied to substructure
:param as_view: If True, the returned graph-view pr... | [
"def",
"substructure",
"(",
"self",
",",
"atoms",
",",
"meta",
"=",
"False",
",",
"as_view",
"=",
"True",
")",
":",
"s",
"=",
"super",
"(",
")",
".",
"substructure",
"(",
"atoms",
",",
"meta",
",",
"as_view",
")",
"if",
"as_view",
":",
"s",
".",
... | create substructure containing atoms from nbunch list
:param atoms: list of atoms numbers of substructure
:param meta: if True metadata will be copied to substructure
:param as_view: If True, the returned graph-view provides a read-only view
of the original structure scaffold withou... | [
"create",
"substructure",
"containing",
"atoms",
"from",
"nbunch",
"list"
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L136-L148 |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer._matcher | def _matcher(self, other):
"""
CGRContainer < CGRContainer
"""
if isinstance(other, CGRContainer):
return GraphMatcher(other, self, lambda x, y: x == y, lambda x, y: x == y)
raise TypeError('only cgr-cgr possible') | python | def _matcher(self, other):
"""
CGRContainer < CGRContainer
"""
if isinstance(other, CGRContainer):
return GraphMatcher(other, self, lambda x, y: x == y, lambda x, y: x == y)
raise TypeError('only cgr-cgr possible') | [
"def",
"_matcher",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"CGRContainer",
")",
":",
"return",
"GraphMatcher",
"(",
"other",
",",
"self",
",",
"lambda",
"x",
",",
"y",
":",
"x",
"==",
"y",
",",
"lambda",
"x",
","... | CGRContainer < CGRContainer | [
"CGRContainer",
"<",
"CGRContainer"
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L150-L156 |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer.__plain_bfs | def __plain_bfs(adj, source):
"""modified NX fast BFS node generator"""
seen = set()
nextlevel = {source}
while nextlevel:
thislevel = nextlevel
nextlevel = set()
for v in thislevel:
if v not in seen:
yield v
... | python | def __plain_bfs(adj, source):
"""modified NX fast BFS node generator"""
seen = set()
nextlevel = {source}
while nextlevel:
thislevel = nextlevel
nextlevel = set()
for v in thislevel:
if v not in seen:
yield v
... | [
"def",
"__plain_bfs",
"(",
"adj",
",",
"source",
")",
":",
"seen",
"=",
"set",
"(",
")",
"nextlevel",
"=",
"{",
"source",
"}",
"while",
"nextlevel",
":",
"thislevel",
"=",
"nextlevel",
"nextlevel",
"=",
"set",
"(",
")",
"for",
"v",
"in",
"thislevel",
... | modified NX fast BFS node generator | [
"modified",
"NX",
"fast",
"BFS",
"node",
"generator"
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L159-L170 |
cocaine/cocaine-framework-python | cocaine/detail/defaults.py | DefaultOptions.token | def token(self):
"""
Returns authorization token provided by Cocaine.
The real meaning of the token is determined by its type. For example OAUTH2 token will
have "bearer" type.
:return: A tuple of token type and body.
"""
if self._token is None:
toke... | python | def token(self):
"""
Returns authorization token provided by Cocaine.
The real meaning of the token is determined by its type. For example OAUTH2 token will
have "bearer" type.
:return: A tuple of token type and body.
"""
if self._token is None:
toke... | [
"def",
"token",
"(",
"self",
")",
":",
"if",
"self",
".",
"_token",
"is",
"None",
":",
"token_type",
"=",
"os",
".",
"getenv",
"(",
"TOKEN_TYPE_KEY",
",",
"''",
")",
"token_body",
"=",
"os",
".",
"getenv",
"(",
"TOKEN_BODY_KEY",
",",
"''",
")",
"self... | Returns authorization token provided by Cocaine.
The real meaning of the token is determined by its type. For example OAUTH2 token will
have "bearer" type.
:return: A tuple of token type and body. | [
"Returns",
"authorization",
"token",
"provided",
"by",
"Cocaine",
"."
] | train | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/defaults.py#L116-L129 |
cocaine/cocaine-framework-python | cocaine/detail/logger.py | Logger._send | def _send(self):
""" Send a message lazy formatted with args.
External log attributes can be passed via named attribute `extra`,
like in logging from the standart library.
Note:
* Attrs must be dict, otherwise the whole message would be skipped.
* The key field i... | python | def _send(self):
""" Send a message lazy formatted with args.
External log attributes can be passed via named attribute `extra`,
like in logging from the standart library.
Note:
* Attrs must be dict, otherwise the whole message would be skipped.
* The key field i... | [
"def",
"_send",
"(",
"self",
")",
":",
"buff",
"=",
"BytesIO",
"(",
")",
"while",
"True",
":",
"msgs",
"=",
"list",
"(",
")",
"try",
":",
"msg",
"=",
"yield",
"self",
".",
"queue",
".",
"get",
"(",
")",
"# we need to connect first, as we issue verbosity ... | Send a message lazy formatted with args.
External log attributes can be passed via named attribute `extra`,
like in logging from the standart library.
Note:
* Attrs must be dict, otherwise the whole message would be skipped.
* The key field in an attr is converted to str... | [
"Send",
"a",
"message",
"lazy",
"formatted",
"with",
"args",
".",
"External",
"log",
"attributes",
"can",
"be",
"passed",
"via",
"named",
"attribute",
"extra",
"like",
"in",
"logging",
"from",
"the",
"standart",
"library",
"."
] | train | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/logger.py#L147-L186 |
LordDarkula/chess_py | chess_py/pieces/rook.py | Rook.moves_in_direction | def moves_in_direction(self, direction, position):
"""
Finds moves in a given direction
:type: direction: lambda
:type: position: Board
:rtype: list
"""
current_square = self.location
while True:
try:
current_square = directio... | python | def moves_in_direction(self, direction, position):
"""
Finds moves in a given direction
:type: direction: lambda
:type: position: Board
:rtype: list
"""
current_square = self.location
while True:
try:
current_square = directio... | [
"def",
"moves_in_direction",
"(",
"self",
",",
"direction",
",",
"position",
")",
":",
"current_square",
"=",
"self",
".",
"location",
"while",
"True",
":",
"try",
":",
"current_square",
"=",
"direction",
"(",
"current_square",
")",
"except",
"IndexError",
":"... | Finds moves in a given direction
:type: direction: lambda
:type: position: Board
:rtype: list | [
"Finds",
"moves",
"in",
"a",
"given",
"direction"
] | train | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/rook.py#L48-L70 |
LordDarkula/chess_py | chess_py/pieces/rook.py | Rook.possible_moves | def possible_moves(self, position):
"""
Returns all possible rook moves.
:type: position: Board
:rtype: list
"""
for move in itertools.chain(*[self.moves_in_direction(fn, position) for fn in self.cross_fn]):
yield move | python | def possible_moves(self, position):
"""
Returns all possible rook moves.
:type: position: Board
:rtype: list
"""
for move in itertools.chain(*[self.moves_in_direction(fn, position) for fn in self.cross_fn]):
yield move | [
"def",
"possible_moves",
"(",
"self",
",",
"position",
")",
":",
"for",
"move",
"in",
"itertools",
".",
"chain",
"(",
"*",
"[",
"self",
".",
"moves_in_direction",
"(",
"fn",
",",
"position",
")",
"for",
"fn",
"in",
"self",
".",
"cross_fn",
"]",
")",
... | Returns all possible rook moves.
:type: position: Board
:rtype: list | [
"Returns",
"all",
"possible",
"rook",
"moves",
"."
] | train | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/rook.py#L72-L80 |
spacetelescope/synphot_refactor | synphot/utils.py | overlap_status | def overlap_status(a, b):
"""Check overlap between two arrays.
Parameters
----------
a, b : array-like
Arrays to check. Assumed to be in the same unit.
Returns
-------
result : {'full', 'partial', 'none'}
* 'full' - ``a`` is within or same as ``b``
* 'partial' - ``a... | python | def overlap_status(a, b):
"""Check overlap between two arrays.
Parameters
----------
a, b : array-like
Arrays to check. Assumed to be in the same unit.
Returns
-------
result : {'full', 'partial', 'none'}
* 'full' - ``a`` is within or same as ``b``
* 'partial' - ``a... | [
"def",
"overlap_status",
"(",
"a",
",",
"b",
")",
":",
"# Get the endpoints",
"a1",
",",
"a2",
"=",
"a",
".",
"min",
"(",
")",
",",
"a",
".",
"max",
"(",
")",
"b1",
",",
"b2",
"=",
"b",
".",
"min",
"(",
")",
",",
"b",
".",
"max",
"(",
")",
... | Check overlap between two arrays.
Parameters
----------
a, b : array-like
Arrays to check. Assumed to be in the same unit.
Returns
-------
result : {'full', 'partial', 'none'}
* 'full' - ``a`` is within or same as ``b``
* 'partial' - ``a`` partially overlaps with ``b``
... | [
"Check",
"overlap",
"between",
"two",
"arrays",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/utils.py#L23-L51 |
spacetelescope/synphot_refactor | synphot/utils.py | validate_totalflux | def validate_totalflux(totalflux):
"""Check integrated flux for invalid values.
Parameters
----------
totalflux : float
Integrated flux.
Raises
------
synphot.exceptions.SynphotError
Input is zero, negative, or not a number.
"""
if totalflux <= 0.0:
raise e... | python | def validate_totalflux(totalflux):
"""Check integrated flux for invalid values.
Parameters
----------
totalflux : float
Integrated flux.
Raises
------
synphot.exceptions.SynphotError
Input is zero, negative, or not a number.
"""
if totalflux <= 0.0:
raise e... | [
"def",
"validate_totalflux",
"(",
"totalflux",
")",
":",
"if",
"totalflux",
"<=",
"0.0",
":",
"raise",
"exceptions",
".",
"SynphotError",
"(",
"'Integrated flux is <= 0'",
")",
"elif",
"np",
".",
"isnan",
"(",
"totalflux",
")",
":",
"raise",
"exceptions",
".",... | Check integrated flux for invalid values.
Parameters
----------
totalflux : float
Integrated flux.
Raises
------
synphot.exceptions.SynphotError
Input is zero, negative, or not a number. | [
"Check",
"integrated",
"flux",
"for",
"invalid",
"values",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/utils.py#L54-L73 |
spacetelescope/synphot_refactor | synphot/utils.py | validate_wavelengths | def validate_wavelengths(wavelengths):
"""Check wavelengths for ``synphot`` compatibility.
Wavelengths must satisfy these conditions:
* valid unit type, if given
* no zeroes
* monotonic ascending or descending
* no duplicate values
Parameters
----------
wavelengths... | python | def validate_wavelengths(wavelengths):
"""Check wavelengths for ``synphot`` compatibility.
Wavelengths must satisfy these conditions:
* valid unit type, if given
* no zeroes
* monotonic ascending or descending
* no duplicate values
Parameters
----------
wavelengths... | [
"def",
"validate_wavelengths",
"(",
"wavelengths",
")",
":",
"if",
"isinstance",
"(",
"wavelengths",
",",
"u",
".",
"Quantity",
")",
":",
"units",
".",
"validate_wave_unit",
"(",
"wavelengths",
".",
"unit",
")",
"wave",
"=",
"wavelengths",
".",
"value",
"els... | Check wavelengths for ``synphot`` compatibility.
Wavelengths must satisfy these conditions:
* valid unit type, if given
* no zeroes
* monotonic ascending or descending
* no duplicate values
Parameters
----------
wavelengths : array-like or `~astropy.units.quantity.Quan... | [
"Check",
"wavelengths",
"for",
"synphot",
"compatibility",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/utils.py#L76-L139 |
spacetelescope/synphot_refactor | synphot/utils.py | generate_wavelengths | def generate_wavelengths(minwave=500, maxwave=26000, num=10000, delta=None,
log=True, wave_unit=u.AA):
"""Generate wavelength array to be used for spectrum sampling.
.. math::
minwave \\le \\lambda < maxwave
Parameters
----------
minwave, maxwave : float
L... | python | def generate_wavelengths(minwave=500, maxwave=26000, num=10000, delta=None,
log=True, wave_unit=u.AA):
"""Generate wavelength array to be used for spectrum sampling.
.. math::
minwave \\le \\lambda < maxwave
Parameters
----------
minwave, maxwave : float
L... | [
"def",
"generate_wavelengths",
"(",
"minwave",
"=",
"500",
",",
"maxwave",
"=",
"26000",
",",
"num",
"=",
"10000",
",",
"delta",
"=",
"None",
",",
"log",
"=",
"True",
",",
"wave_unit",
"=",
"u",
".",
"AA",
")",
":",
"wave_unit",
"=",
"units",
".",
... | Generate wavelength array to be used for spectrum sampling.
.. math::
minwave \\le \\lambda < maxwave
Parameters
----------
minwave, maxwave : float
Lower and upper limits of the wavelengths.
These must be values in linear space regardless of ``log``.
num : int
Th... | [
"Generate",
"wavelength",
"array",
"to",
"be",
"used",
"for",
"spectrum",
"sampling",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/utils.py#L142-L205 |
spacetelescope/synphot_refactor | synphot/utils.py | merge_wavelengths | def merge_wavelengths(waveset1, waveset2, threshold=1e-12):
"""Return the union of the two sets of wavelengths using
:func:`numpy.union1d`.
The merged wavelengths may sometimes contain numbers which are nearly
equal but differ at levels as small as 1e-14. Having values this
close together can cause... | python | def merge_wavelengths(waveset1, waveset2, threshold=1e-12):
"""Return the union of the two sets of wavelengths using
:func:`numpy.union1d`.
The merged wavelengths may sometimes contain numbers which are nearly
equal but differ at levels as small as 1e-14. Having values this
close together can cause... | [
"def",
"merge_wavelengths",
"(",
"waveset1",
",",
"waveset2",
",",
"threshold",
"=",
"1e-12",
")",
":",
"if",
"waveset1",
"is",
"None",
"and",
"waveset2",
"is",
"None",
":",
"out_wavelengths",
"=",
"None",
"elif",
"waveset1",
"is",
"not",
"None",
"and",
"w... | Return the union of the two sets of wavelengths using
:func:`numpy.union1d`.
The merged wavelengths may sometimes contain numbers which are nearly
equal but differ at levels as small as 1e-14. Having values this
close together can cause problems down the line. So, here we test
whether any such smal... | [
"Return",
"the",
"union",
"of",
"the",
"two",
"sets",
"of",
"wavelengths",
"using",
":",
"func",
":",
"numpy",
".",
"union1d",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/utils.py#L208-L252 |
spacetelescope/synphot_refactor | synphot/utils.py | download_data | def download_data(cdbs_root, verbose=True, dry_run=False):
"""Download CDBS data files to given root directory.
Download is skipped if a data file already exists.
Parameters
----------
cdbs_root : str
Root directory for CDBS data files.
verbose : bool
Print extra information to... | python | def download_data(cdbs_root, verbose=True, dry_run=False):
"""Download CDBS data files to given root directory.
Download is skipped if a data file already exists.
Parameters
----------
cdbs_root : str
Root directory for CDBS data files.
verbose : bool
Print extra information to... | [
"def",
"download_data",
"(",
"cdbs_root",
",",
"verbose",
"=",
"True",
",",
"dry_run",
"=",
"False",
")",
":",
"from",
".",
"config",
"import",
"conf",
"# Avoid potential circular import",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"cdbs_root",
")",... | Download CDBS data files to given root directory.
Download is skipped if a data file already exists.
Parameters
----------
cdbs_root : str
Root directory for CDBS data files.
verbose : bool
Print extra information to screen.
dry_run : bool
Go through the logic but skip... | [
"Download",
"CDBS",
"data",
"files",
"to",
"given",
"root",
"directory",
".",
"Download",
"is",
"skipped",
"if",
"a",
"data",
"file",
"already",
"exists",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/utils.py#L255-L336 |
Julius2342/pyvlx | examples/demo.py | main | async def main(loop):
"""Demonstrate functionality of PyVLX."""
pyvlx = PyVLX('pyvlx.yaml', loop=loop)
# Alternative:
# pyvlx = PyVLX(host="192.168.2.127", password="velux123", loop=loop)
# Runing scenes:
await pyvlx.load_scenes()
await pyvlx.scenes["All Windows Closed"].run()
# Changi... | python | async def main(loop):
"""Demonstrate functionality of PyVLX."""
pyvlx = PyVLX('pyvlx.yaml', loop=loop)
# Alternative:
# pyvlx = PyVLX(host="192.168.2.127", password="velux123", loop=loop)
# Runing scenes:
await pyvlx.load_scenes()
await pyvlx.scenes["All Windows Closed"].run()
# Changi... | [
"async",
"def",
"main",
"(",
"loop",
")",
":",
"pyvlx",
"=",
"PyVLX",
"(",
"'pyvlx.yaml'",
",",
"loop",
"=",
"loop",
")",
"# Alternative:",
"# pyvlx = PyVLX(host=\"192.168.2.127\", password=\"velux123\", loop=loop)",
"# Runing scenes:",
"await",
"pyvlx",
".",
"load_scen... | Demonstrate functionality of PyVLX. | [
"Demonstrate",
"functionality",
"of",
"PyVLX",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/examples/demo.py#L7-L30 |
Julius2342/pyvlx | pyvlx/frames/frame_password_enter.py | FramePasswordEnterRequest.get_payload | def get_payload(self):
"""Return Payload."""
if self.password is None:
raise PyVLXException("password is none")
if len(self.password) > self.MAX_SIZE:
raise PyVLXException("password is too long")
return string_to_bytes(self.password, self.MAX_SIZE) | python | def get_payload(self):
"""Return Payload."""
if self.password is None:
raise PyVLXException("password is none")
if len(self.password) > self.MAX_SIZE:
raise PyVLXException("password is too long")
return string_to_bytes(self.password, self.MAX_SIZE) | [
"def",
"get_payload",
"(",
"self",
")",
":",
"if",
"self",
".",
"password",
"is",
"None",
":",
"raise",
"PyVLXException",
"(",
"\"password is none\"",
")",
"if",
"len",
"(",
"self",
".",
"password",
")",
">",
"self",
".",
"MAX_SIZE",
":",
"raise",
"PyVLX... | Return Payload. | [
"Return",
"Payload",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_password_enter.py#L22-L28 |
Julius2342/pyvlx | pyvlx/nodes.py | Nodes.add | def add(self, node):
"""Add Node, replace existing node if node with node_id is present."""
if not isinstance(node, Node):
raise TypeError()
for i, j in enumerate(self.__nodes):
if j.node_id == node.node_id:
self.__nodes[i] = node
return
... | python | def add(self, node):
"""Add Node, replace existing node if node with node_id is present."""
if not isinstance(node, Node):
raise TypeError()
for i, j in enumerate(self.__nodes):
if j.node_id == node.node_id:
self.__nodes[i] = node
return
... | [
"def",
"add",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"isinstance",
"(",
"node",
",",
"Node",
")",
":",
"raise",
"TypeError",
"(",
")",
"for",
"i",
",",
"j",
"in",
"enumerate",
"(",
"self",
".",
"__nodes",
")",
":",
"if",
"j",
".",
"no... | Add Node, replace existing node if node with node_id is present. | [
"Add",
"Node",
"replace",
"existing",
"node",
"if",
"node",
"with",
"node_id",
"is",
"present",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/nodes.py#L51-L59 |
Julius2342/pyvlx | pyvlx/nodes.py | Nodes.load | async def load(self, node_id=None):
"""Load nodes from KLF 200, if no node_id is specified all nodes are loaded."""
if node_id is not None:
await self._load_node(node_id=node_id)
else:
await self._load_all_nodes() | python | async def load(self, node_id=None):
"""Load nodes from KLF 200, if no node_id is specified all nodes are loaded."""
if node_id is not None:
await self._load_node(node_id=node_id)
else:
await self._load_all_nodes() | [
"async",
"def",
"load",
"(",
"self",
",",
"node_id",
"=",
"None",
")",
":",
"if",
"node_id",
"is",
"not",
"None",
":",
"await",
"self",
".",
"_load_node",
"(",
"node_id",
"=",
"node_id",
")",
"else",
":",
"await",
"self",
".",
"_load_all_nodes",
"(",
... | Load nodes from KLF 200, if no node_id is specified all nodes are loaded. | [
"Load",
"nodes",
"from",
"KLF",
"200",
"if",
"no",
"node_id",
"is",
"specified",
"all",
"nodes",
"are",
"loaded",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/nodes.py#L65-L70 |
Julius2342/pyvlx | pyvlx/nodes.py | Nodes._load_node | async def _load_node(self, node_id):
"""Load single node via API."""
get_node_information = GetNodeInformation(pyvlx=self.pyvlx, node_id=node_id)
await get_node_information.do_api_call()
if not get_node_information.success:
raise PyVLXException("Unable to retrieve node inform... | python | async def _load_node(self, node_id):
"""Load single node via API."""
get_node_information = GetNodeInformation(pyvlx=self.pyvlx, node_id=node_id)
await get_node_information.do_api_call()
if not get_node_information.success:
raise PyVLXException("Unable to retrieve node inform... | [
"async",
"def",
"_load_node",
"(",
"self",
",",
"node_id",
")",
":",
"get_node_information",
"=",
"GetNodeInformation",
"(",
"pyvlx",
"=",
"self",
".",
"pyvlx",
",",
"node_id",
"=",
"node_id",
")",
"await",
"get_node_information",
".",
"do_api_call",
"(",
")",... | Load single node via API. | [
"Load",
"single",
"node",
"via",
"API",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/nodes.py#L72-L81 |
Julius2342/pyvlx | pyvlx/nodes.py | Nodes._load_all_nodes | async def _load_all_nodes(self):
"""Load all nodes via API."""
get_all_nodes_information = GetAllNodesInformation(pyvlx=self.pyvlx)
await get_all_nodes_information.do_api_call()
if not get_all_nodes_information.success:
raise PyVLXException("Unable to retrieve node informatio... | python | async def _load_all_nodes(self):
"""Load all nodes via API."""
get_all_nodes_information = GetAllNodesInformation(pyvlx=self.pyvlx)
await get_all_nodes_information.do_api_call()
if not get_all_nodes_information.success:
raise PyVLXException("Unable to retrieve node informatio... | [
"async",
"def",
"_load_all_nodes",
"(",
"self",
")",
":",
"get_all_nodes_information",
"=",
"GetAllNodesInformation",
"(",
"pyvlx",
"=",
"self",
".",
"pyvlx",
")",
"await",
"get_all_nodes_information",
".",
"do_api_call",
"(",
")",
"if",
"not",
"get_all_nodes_inform... | Load all nodes via API. | [
"Load",
"all",
"nodes",
"via",
"API",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/nodes.py#L83-L93 |
Julius2342/pyvlx | pyvlx/get_all_nodes_information.py | GetAllNodesInformation.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameGetAllNodesInformationConfirmation):
self.number_of_nodes = frame.number_of_nodes
# We are still waiting for FrameGetAllNodesInformationNoti... | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameGetAllNodesInformationConfirmation):
self.number_of_nodes = frame.number_of_nodes
# We are still waiting for FrameGetAllNodesInformationNoti... | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"isinstance",
"(",
"frame",
",",
"FrameGetAllNodesInformationConfirmation",
")",
":",
"self",
".",
"number_of_nodes",
"=",
"frame",
".",
"number_of_nodes",
"# We are still waiting for FrameGetA... | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/get_all_nodes_information.py#L21-L34 |
Julius2342/pyvlx | pyvlx/get_node_information.py | GetNodeInformation.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameGetNodeInformationConfirmation) and frame.node_id == self.node_id:
# We are still waiting for GetNodeInformationNotification
return False
... | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameGetNodeInformationConfirmation) and frame.node_id == self.node_id:
# We are still waiting for GetNodeInformationNotification
return False
... | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"isinstance",
"(",
"frame",
",",
"FrameGetNodeInformationConfirmation",
")",
"and",
"frame",
".",
"node_id",
"==",
"self",
".",
"node_id",
":",
"# We are still waiting for GetNodeInformationN... | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/get_node_information.py#L18-L27 |
Julius2342/pyvlx | pyvlx/heartbeat.py | Heartbeat.start | def start(self):
"""Create loop task."""
self.run_task = self.pyvlx.loop.create_task(
self.loop()) | python | def start(self):
"""Create loop task."""
self.run_task = self.pyvlx.loop.create_task(
self.loop()) | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"run_task",
"=",
"self",
".",
"pyvlx",
".",
"loop",
".",
"create_task",
"(",
"self",
".",
"loop",
"(",
")",
")"
] | Create loop task. | [
"Create",
"loop",
"task",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/heartbeat.py#L25-L28 |
Julius2342/pyvlx | pyvlx/heartbeat.py | Heartbeat.stop | async def stop(self):
"""Stop heartbeat."""
self.stopped = True
self.loop_event.set()
# Waiting for shutdown of loop()
await self.stopped_event.wait() | python | async def stop(self):
"""Stop heartbeat."""
self.stopped = True
self.loop_event.set()
# Waiting for shutdown of loop()
await self.stopped_event.wait() | [
"async",
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"stopped",
"=",
"True",
"self",
".",
"loop_event",
".",
"set",
"(",
")",
"# Waiting for shutdown of loop()",
"await",
"self",
".",
"stopped_event",
".",
"wait",
"(",
")"
] | Stop heartbeat. | [
"Stop",
"heartbeat",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/heartbeat.py#L30-L35 |
Julius2342/pyvlx | pyvlx/heartbeat.py | Heartbeat.loop | async def loop(self):
"""Pulse every timeout seconds until stopped."""
while not self.stopped:
self.timeout_handle = self.pyvlx.connection.loop.call_later(
self.timeout_in_seconds, self.loop_timeout)
await self.loop_event.wait()
if not self.stopped:
... | python | async def loop(self):
"""Pulse every timeout seconds until stopped."""
while not self.stopped:
self.timeout_handle = self.pyvlx.connection.loop.call_later(
self.timeout_in_seconds, self.loop_timeout)
await self.loop_event.wait()
if not self.stopped:
... | [
"async",
"def",
"loop",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"stopped",
":",
"self",
".",
"timeout_handle",
"=",
"self",
".",
"pyvlx",
".",
"connection",
".",
"loop",
".",
"call_later",
"(",
"self",
".",
"timeout_in_seconds",
",",
"self",
... | Pulse every timeout seconds until stopped. | [
"Pulse",
"every",
"timeout",
"seconds",
"until",
"stopped",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/heartbeat.py#L37-L47 |
Julius2342/pyvlx | pyvlx/heartbeat.py | Heartbeat.pulse | async def pulse(self):
"""Send get state request to API to keep the connection alive."""
get_state = GetState(pyvlx=self.pyvlx)
await get_state.do_api_call()
if not get_state.success:
raise PyVLXException("Unable to send get state.") | python | async def pulse(self):
"""Send get state request to API to keep the connection alive."""
get_state = GetState(pyvlx=self.pyvlx)
await get_state.do_api_call()
if not get_state.success:
raise PyVLXException("Unable to send get state.") | [
"async",
"def",
"pulse",
"(",
"self",
")",
":",
"get_state",
"=",
"GetState",
"(",
"pyvlx",
"=",
"self",
".",
"pyvlx",
")",
"await",
"get_state",
".",
"do_api_call",
"(",
")",
"if",
"not",
"get_state",
".",
"success",
":",
"raise",
"PyVLXException",
"(",... | Send get state request to API to keep the connection alive. | [
"Send",
"get",
"state",
"request",
"to",
"API",
"to",
"keep",
"the",
"connection",
"alive",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/heartbeat.py#L59-L64 |
Julius2342/pyvlx | pyvlx/frames/frame_get_state.py | FrameGetStateConfirmation.get_payload | def get_payload(self):
"""Return Payload."""
payload = bytes([self.gateway_state.value, self.gateway_sub_state.value])
payload += bytes(4) # State date, reserved for future use
return payload | python | def get_payload(self):
"""Return Payload."""
payload = bytes([self.gateway_state.value, self.gateway_sub_state.value])
payload += bytes(4) # State date, reserved for future use
return payload | [
"def",
"get_payload",
"(",
"self",
")",
":",
"payload",
"=",
"bytes",
"(",
"[",
"self",
".",
"gateway_state",
".",
"value",
",",
"self",
".",
"gateway_sub_state",
".",
"value",
"]",
")",
"payload",
"+=",
"bytes",
"(",
"4",
")",
"# State date, reserved for ... | Return Payload. | [
"Return",
"Payload",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_state.py#L53-L57 |
Julius2342/pyvlx | pyvlx/frames/frame_get_state.py | FrameGetStateConfirmation.from_payload | def from_payload(self, payload):
"""Init frame from binary data."""
self.gateway_state = GatewayState(payload[0])
self.gateway_sub_state = GatewaySubState(payload[1]) | python | def from_payload(self, payload):
"""Init frame from binary data."""
self.gateway_state = GatewayState(payload[0])
self.gateway_sub_state = GatewaySubState(payload[1]) | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"gateway_state",
"=",
"GatewayState",
"(",
"payload",
"[",
"0",
"]",
")",
"self",
".",
"gateway_sub_state",
"=",
"GatewaySubState",
"(",
"payload",
"[",
"1",
"]",
")"
] | Init frame from binary data. | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_state.py#L59-L62 |
Julius2342/pyvlx | pyvlx/string_helper.py | string_to_bytes | def string_to_bytes(string, size):
"""Convert string to bytes add padding."""
if len(string) > size:
raise PyVLXException("string_to_bytes::string_to_large")
encoded = bytes(string, encoding='utf-8')
return encoded + bytes(size-len(encoded)) | python | def string_to_bytes(string, size):
"""Convert string to bytes add padding."""
if len(string) > size:
raise PyVLXException("string_to_bytes::string_to_large")
encoded = bytes(string, encoding='utf-8')
return encoded + bytes(size-len(encoded)) | [
"def",
"string_to_bytes",
"(",
"string",
",",
"size",
")",
":",
"if",
"len",
"(",
"string",
")",
">",
"size",
":",
"raise",
"PyVLXException",
"(",
"\"string_to_bytes::string_to_large\"",
")",
"encoded",
"=",
"bytes",
"(",
"string",
",",
"encoding",
"=",
"'ut... | Convert string to bytes add padding. | [
"Convert",
"string",
"to",
"bytes",
"add",
"padding",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/string_helper.py#L5-L10 |
Julius2342/pyvlx | pyvlx/string_helper.py | bytes_to_string | def bytes_to_string(raw):
"""Convert bytes to string."""
ret = bytes()
for byte in raw:
if byte == 0x00:
return ret.decode("utf-8")
ret += bytes([byte])
return ret.decode("utf-8") | python | def bytes_to_string(raw):
"""Convert bytes to string."""
ret = bytes()
for byte in raw:
if byte == 0x00:
return ret.decode("utf-8")
ret += bytes([byte])
return ret.decode("utf-8") | [
"def",
"bytes_to_string",
"(",
"raw",
")",
":",
"ret",
"=",
"bytes",
"(",
")",
"for",
"byte",
"in",
"raw",
":",
"if",
"byte",
"==",
"0x00",
":",
"return",
"ret",
".",
"decode",
"(",
"\"utf-8\"",
")",
"ret",
"+=",
"bytes",
"(",
"[",
"byte",
"]",
"... | Convert bytes to string. | [
"Convert",
"bytes",
"to",
"string",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/string_helper.py#L13-L20 |
Julius2342/pyvlx | pyvlx/frames/frame_node_state_position_changed_notification.py | FrameNodeStatePositionChangedNotification.get_payload | def get_payload(self):
"""Return Payload."""
payload = bytes([self.node_id])
payload += bytes([self.state])
payload += bytes(self.current_position.raw)
payload += bytes(self.target.raw)
payload += bytes(self.current_position_fp1.raw)
payload += bytes(self.current_... | python | def get_payload(self):
"""Return Payload."""
payload = bytes([self.node_id])
payload += bytes([self.state])
payload += bytes(self.current_position.raw)
payload += bytes(self.target.raw)
payload += bytes(self.current_position_fp1.raw)
payload += bytes(self.current_... | [
"def",
"get_payload",
"(",
"self",
")",
":",
"payload",
"=",
"bytes",
"(",
"[",
"self",
".",
"node_id",
"]",
")",
"payload",
"+=",
"bytes",
"(",
"[",
"self",
".",
"state",
"]",
")",
"payload",
"+=",
"bytes",
"(",
"self",
".",
"current_position",
".",... | Return Payload. | [
"Return",
"Payload",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_node_state_position_changed_notification.py#L30-L42 |
Julius2342/pyvlx | pyvlx/frames/frame_node_state_position_changed_notification.py | FrameNodeStatePositionChangedNotification.from_payload | def from_payload(self, payload):
"""Init frame from binary data."""
self.node_id = payload[0]
self.state = payload[1]
self.current_position = Parameter(payload[2:4])
self.target = Parameter(payload[4:6])
self.current_position_fp1 = Parameter(payload[6:8])
self.cur... | python | def from_payload(self, payload):
"""Init frame from binary data."""
self.node_id = payload[0]
self.state = payload[1]
self.current_position = Parameter(payload[2:4])
self.target = Parameter(payload[4:6])
self.current_position_fp1 = Parameter(payload[6:8])
self.cur... | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"node_id",
"=",
"payload",
"[",
"0",
"]",
"self",
".",
"state",
"=",
"payload",
"[",
"1",
"]",
"self",
".",
"current_position",
"=",
"Parameter",
"(",
"payload",
"[",
"2",
":"... | Init frame from binary data. | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_node_state_position_changed_notification.py#L44-L57 |
Julius2342/pyvlx | pyvlx/house_status_monitor.py | house_status_monitor_enable | async def house_status_monitor_enable(pyvlx):
"""Enable house status monitor."""
status_monitor_enable = HouseStatusMonitorEnable(pyvlx=pyvlx)
await status_monitor_enable.do_api_call()
if not status_monitor_enable.success:
raise PyVLXException("Unable enable house status monitor.") | python | async def house_status_monitor_enable(pyvlx):
"""Enable house status monitor."""
status_monitor_enable = HouseStatusMonitorEnable(pyvlx=pyvlx)
await status_monitor_enable.do_api_call()
if not status_monitor_enable.success:
raise PyVLXException("Unable enable house status monitor.") | [
"async",
"def",
"house_status_monitor_enable",
"(",
"pyvlx",
")",
":",
"status_monitor_enable",
"=",
"HouseStatusMonitorEnable",
"(",
"pyvlx",
"=",
"pyvlx",
")",
"await",
"status_monitor_enable",
".",
"do_api_call",
"(",
")",
"if",
"not",
"status_monitor_enable",
".",... | Enable house status monitor. | [
"Enable",
"house",
"status",
"monitor",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/house_status_monitor.py#L51-L56 |
Julius2342/pyvlx | pyvlx/house_status_monitor.py | house_status_monitor_disable | async def house_status_monitor_disable(pyvlx):
"""Disable house status monitor."""
status_monitor_disable = HouseStatusMonitorDisable(pyvlx=pyvlx)
await status_monitor_disable.do_api_call()
if not status_monitor_disable.success:
raise PyVLXException("Unable disable house status monitor.") | python | async def house_status_monitor_disable(pyvlx):
"""Disable house status monitor."""
status_monitor_disable = HouseStatusMonitorDisable(pyvlx=pyvlx)
await status_monitor_disable.do_api_call()
if not status_monitor_disable.success:
raise PyVLXException("Unable disable house status monitor.") | [
"async",
"def",
"house_status_monitor_disable",
"(",
"pyvlx",
")",
":",
"status_monitor_disable",
"=",
"HouseStatusMonitorDisable",
"(",
"pyvlx",
"=",
"pyvlx",
")",
"await",
"status_monitor_disable",
".",
"do_api_call",
"(",
")",
"if",
"not",
"status_monitor_disable",
... | Disable house status monitor. | [
"Disable",
"house",
"status",
"monitor",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/house_status_monitor.py#L59-L64 |
Julius2342/pyvlx | pyvlx/house_status_monitor.py | HouseStatusMonitorEnable.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameHouseStatusMonitorEnableConfirmation):
return False
self.success = True
return True | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameHouseStatusMonitorEnableConfirmation):
return False
self.success = True
return True | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"isinstance",
"(",
"frame",
",",
"FrameHouseStatusMonitorEnableConfirmation",
")",
":",
"return",
"False",
"self",
".",
"success",
"=",
"True",
"return",
"True"
] | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/house_status_monitor.py#L19-L24 |
Julius2342/pyvlx | pyvlx/house_status_monitor.py | HouseStatusMonitorDisable.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameHouseStatusMonitorDisableConfirmation):
return False
self.success = True
return True | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameHouseStatusMonitorDisableConfirmation):
return False
self.success = True
return True | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"isinstance",
"(",
"frame",
",",
"FrameHouseStatusMonitorDisableConfirmation",
")",
":",
"return",
"False",
"self",
".",
"success",
"=",
"True",
"return",
"True"
] | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/house_status_monitor.py#L39-L44 |
tbielawa/bitmath | bitmath/integrations.py | BitmathType | def BitmathType(bmstring):
"""An 'argument type' for integrations with the argparse module.
For more information, see
https://docs.python.org/2/library/argparse.html#type Of particular
interest to us is this bit:
``type=`` can take any callable that takes a single string
argument and returns the converted v... | python | def BitmathType(bmstring):
"""An 'argument type' for integrations with the argparse module.
For more information, see
https://docs.python.org/2/library/argparse.html#type Of particular
interest to us is this bit:
``type=`` can take any callable that takes a single string
argument and returns the converted v... | [
"def",
"BitmathType",
"(",
"bmstring",
")",
":",
"try",
":",
"argvalue",
"=",
"bitmath",
".",
"parse_string",
"(",
"bmstring",
")",
"except",
"ValueError",
":",
"raise",
"argparse",
".",
"ArgumentTypeError",
"(",
"\"'%s' can not be parsed into a valid bitmath object\"... | An 'argument type' for integrations with the argparse module.
For more information, see
https://docs.python.org/2/library/argparse.html#type Of particular
interest to us is this bit:
``type=`` can take any callable that takes a single string
argument and returns the converted value
I.e., ``type`` can be a func... | [
"An",
"argument",
"type",
"for",
"integrations",
"with",
"the",
"argparse",
"module",
"."
] | train | https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/integrations.py#L33-L80 |
tbielawa/bitmath | bitmath/integrations.py | BitmathFileTransferSpeed.update | def update(self, pbar):
"""Updates the widget with the current NIST/SI speed.
Basically, this calculates the average rate of update and figures out
how to make a "pretty" prefix unit"""
if pbar.seconds_elapsed < 2e-6 or pbar.currval < 2e-6:
scaled = bitmath.Byte()
else:
... | python | def update(self, pbar):
"""Updates the widget with the current NIST/SI speed.
Basically, this calculates the average rate of update and figures out
how to make a "pretty" prefix unit"""
if pbar.seconds_elapsed < 2e-6 or pbar.currval < 2e-6:
scaled = bitmath.Byte()
else:
... | [
"def",
"update",
"(",
"self",
",",
"pbar",
")",
":",
"if",
"pbar",
".",
"seconds_elapsed",
"<",
"2e-6",
"or",
"pbar",
".",
"currval",
"<",
"2e-6",
":",
"scaled",
"=",
"bitmath",
".",
"Byte",
"(",
")",
"else",
":",
"speed",
"=",
"pbar",
".",
"currva... | Updates the widget with the current NIST/SI speed.
Basically, this calculates the average rate of update and figures out
how to make a "pretty" prefix unit | [
"Updates",
"the",
"widget",
"with",
"the",
"current",
"NIST",
"/",
"SI",
"speed",
"."
] | train | https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/integrations.py#L92-L104 |
Julius2342/pyvlx | pyvlx/command_send.py | CommandSend.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameCommandSendConfirmation) and frame.session_id == self.session_id:
if frame.status == CommandSendConfirmationStatus.ACCEPTED:
self.succes... | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameCommandSendConfirmation) and frame.session_id == self.session_id:
if frame.status == CommandSendConfirmationStatus.ACCEPTED:
self.succes... | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"isinstance",
"(",
"frame",
",",
"FrameCommandSendConfirmation",
")",
"and",
"frame",
".",
"session_id",
"==",
"self",
".",
"session_id",
":",
"if",
"frame",
".",
"status",
"==",
"C... | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/command_send.py#L22-L37 |
Julius2342/pyvlx | pyvlx/command_send.py | CommandSend.request_frame | def request_frame(self):
"""Construct initiating frame."""
self.session_id = get_new_session_id()
return FrameCommandSendRequest(node_ids=[self.node_id], parameter=self.parameter, session_id=self.session_id) | python | def request_frame(self):
"""Construct initiating frame."""
self.session_id = get_new_session_id()
return FrameCommandSendRequest(node_ids=[self.node_id], parameter=self.parameter, session_id=self.session_id) | [
"def",
"request_frame",
"(",
"self",
")",
":",
"self",
".",
"session_id",
"=",
"get_new_session_id",
"(",
")",
"return",
"FrameCommandSendRequest",
"(",
"node_ids",
"=",
"[",
"self",
".",
"node_id",
"]",
",",
"parameter",
"=",
"self",
".",
"parameter",
",",
... | Construct initiating frame. | [
"Construct",
"initiating",
"frame",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/command_send.py#L39-L42 |
Julius2342/pyvlx | pyvlx/config.py | Config.read_config | def read_config(self, path):
"""Read configuration file."""
PYVLXLOG.info('Reading config file: %s', path)
try:
with open(path, 'r') as filehandle:
doc = yaml.safe_load(filehandle)
self.test_configuration(doc, path)
self.host = doc['con... | python | def read_config(self, path):
"""Read configuration file."""
PYVLXLOG.info('Reading config file: %s', path)
try:
with open(path, 'r') as filehandle:
doc = yaml.safe_load(filehandle)
self.test_configuration(doc, path)
self.host = doc['con... | [
"def",
"read_config",
"(",
"self",
",",
"path",
")",
":",
"PYVLXLOG",
".",
"info",
"(",
"'Reading config file: %s'",
",",
"path",
")",
"try",
":",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"filehandle",
":",
"doc",
"=",
"yaml",
".",
"safe_loa... | Read configuration file. | [
"Read",
"configuration",
"file",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/config.py#L22-L34 |
pyQode/pyqode.qt | pyqode/qt/__init__.py | setup_apiv2 | def setup_apiv2():
"""
Setup apiv2 when using PyQt4 and Python2.
"""
# setup PyQt api to version 2
if sys.version_info[0] == 2:
logging.getLogger(__name__).debug(
'setting up SIP API to version 2')
import sip
try:
sip.setapi("QString", 2)
s... | python | def setup_apiv2():
"""
Setup apiv2 when using PyQt4 and Python2.
"""
# setup PyQt api to version 2
if sys.version_info[0] == 2:
logging.getLogger(__name__).debug(
'setting up SIP API to version 2')
import sip
try:
sip.setapi("QString", 2)
s... | [
"def",
"setup_apiv2",
"(",
")",
":",
"# setup PyQt api to version 2",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"2",
":",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
"debug",
"(",
"'setting up SIP API to version 2'",
")",
"import",
"si... | Setup apiv2 when using PyQt4 and Python2. | [
"Setup",
"apiv2",
"when",
"using",
"PyQt4",
"and",
"Python2",
"."
] | train | https://github.com/pyQode/pyqode.qt/blob/56ee08fdcd4d9c4441dcf85f89b51d4ae3a727bd/pyqode/qt/__init__.py#L79-L94 |
pyQode/pyqode.qt | pyqode/qt/__init__.py | autodetect | def autodetect():
"""
Auto-detects and use the first available QT_API by importing them in the
following order:
1) PyQt5
2) PyQt4
3) PySide
"""
logging.getLogger(__name__).debug('auto-detecting QT_API')
try:
logging.getLogger(__name__).debug('trying PyQt5')
import Py... | python | def autodetect():
"""
Auto-detects and use the first available QT_API by importing them in the
following order:
1) PyQt5
2) PyQt4
3) PySide
"""
logging.getLogger(__name__).debug('auto-detecting QT_API')
try:
logging.getLogger(__name__).debug('trying PyQt5')
import Py... | [
"def",
"autodetect",
"(",
")",
":",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
"debug",
"(",
"'auto-detecting QT_API'",
")",
"try",
":",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
"debug",
"(",
"'trying PyQt5'",
")",
"import",
"Py... | Auto-detects and use the first available QT_API by importing them in the
following order:
1) PyQt5
2) PyQt4
3) PySide | [
"Auto",
"-",
"detects",
"and",
"use",
"the",
"first",
"available",
"QT_API",
"by",
"importing",
"them",
"in",
"the",
"following",
"order",
":"
] | train | https://github.com/pyQode/pyqode.qt/blob/56ee08fdcd4d9c4441dcf85f89b51d4ae3a727bd/pyqode/qt/__init__.py#L97-L126 |
Julius2342/pyvlx | old_api/pyvlx/rollershutter.py | RollerShutter.from_config | def from_config(cls, pyvlx, item):
"""Read roller shutter from config."""
name = item['name']
ident = item['id']
subtype = item['subtype']
typeid = item['typeId']
return cls(pyvlx, ident, name, subtype, typeid) | python | def from_config(cls, pyvlx, item):
"""Read roller shutter from config."""
name = item['name']
ident = item['id']
subtype = item['subtype']
typeid = item['typeId']
return cls(pyvlx, ident, name, subtype, typeid) | [
"def",
"from_config",
"(",
"cls",
",",
"pyvlx",
",",
"item",
")",
":",
"name",
"=",
"item",
"[",
"'name'",
"]",
"ident",
"=",
"item",
"[",
"'id'",
"]",
"subtype",
"=",
"item",
"[",
"'subtype'",
"]",
"typeid",
"=",
"item",
"[",
"'typeId'",
"]",
"ret... | Read roller shutter from config. | [
"Read",
"roller",
"shutter",
"from",
"config",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/rollershutter.py#L19-L25 |
Julius2342/pyvlx | pyvlx/get_scene_list.py | GetSceneList.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameGetSceneListConfirmation):
self.count_scenes = frame.count_scenes
if self.count_scenes == 0:
self.success = True
... | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameGetSceneListConfirmation):
self.count_scenes = frame.count_scenes
if self.count_scenes == 0:
self.success = True
... | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"isinstance",
"(",
"frame",
",",
"FrameGetSceneListConfirmation",
")",
":",
"self",
".",
"count_scenes",
"=",
"frame",
".",
"count_scenes",
"if",
"self",
".",
"count_scenes",
"==",
"0... | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/get_scene_list.py#L19-L37 |
Julius2342/pyvlx | pyvlx/frames/frame_get_scene_list.py | FrameGetSceneListNotification.get_payload | def get_payload(self):
"""Return Payload."""
ret = bytes([len(self.scenes)])
for number, name in self.scenes:
ret += bytes([number])
ret += string_to_bytes(name, 64)
ret += bytes([self.remaining_scenes])
return ret | python | def get_payload(self):
"""Return Payload."""
ret = bytes([len(self.scenes)])
for number, name in self.scenes:
ret += bytes([number])
ret += string_to_bytes(name, 64)
ret += bytes([self.remaining_scenes])
return ret | [
"def",
"get_payload",
"(",
"self",
")",
":",
"ret",
"=",
"bytes",
"(",
"[",
"len",
"(",
"self",
".",
"scenes",
")",
"]",
")",
"for",
"number",
",",
"name",
"in",
"self",
".",
"scenes",
":",
"ret",
"+=",
"bytes",
"(",
"[",
"number",
"]",
")",
"r... | Return Payload. | [
"Return",
"Payload",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_scene_list.py#L51-L58 |
Julius2342/pyvlx | pyvlx/frames/frame_get_scene_list.py | FrameGetSceneListNotification.from_payload | def from_payload(self, payload):
"""Init frame from binary data."""
number_of_objects = payload[0]
self.remaining_scenes = payload[-1]
predicted_len = number_of_objects * 65 + 2
if len(payload) != predicted_len:
raise PyVLXException('scene_list_notification_wrong_leng... | python | def from_payload(self, payload):
"""Init frame from binary data."""
number_of_objects = payload[0]
self.remaining_scenes = payload[-1]
predicted_len = number_of_objects * 65 + 2
if len(payload) != predicted_len:
raise PyVLXException('scene_list_notification_wrong_leng... | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"number_of_objects",
"=",
"payload",
"[",
"0",
"]",
"self",
".",
"remaining_scenes",
"=",
"payload",
"[",
"-",
"1",
"]",
"predicted_len",
"=",
"number_of_objects",
"*",
"65",
"+",
"2",
"if",
"... | Init frame from binary data. | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_scene_list.py#L60-L72 |
spacetelescope/synphot_refactor | synphot/specio.py | read_remote_spec | def read_remote_spec(filename, encoding='binary', cache=True,
show_progress=True, **kwargs):
"""Read FITS or ASCII spectrum from a remote location.
Parameters
----------
filename : str
Spectrum filename.
encoding, cache, show_progress
See :func:`~astropy.utils.... | python | def read_remote_spec(filename, encoding='binary', cache=True,
show_progress=True, **kwargs):
"""Read FITS or ASCII spectrum from a remote location.
Parameters
----------
filename : str
Spectrum filename.
encoding, cache, show_progress
See :func:`~astropy.utils.... | [
"def",
"read_remote_spec",
"(",
"filename",
",",
"encoding",
"=",
"'binary'",
",",
"cache",
"=",
"True",
",",
"show_progress",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"get_readable_fileobj",
"(",
"filename",
",",
"encoding",
"=",
"encoding",
... | Read FITS or ASCII spectrum from a remote location.
Parameters
----------
filename : str
Spectrum filename.
encoding, cache, show_progress
See :func:`~astropy.utils.data.get_readable_fileobj`.
kwargs : dict
Keywords acceptable by :func:`read_fits_spec` (if FITS) or
... | [
"Read",
"FITS",
"or",
"ASCII",
"spectrum",
"from",
"a",
"remote",
"location",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/specio.py#L26-L55 |
spacetelescope/synphot_refactor | synphot/specio.py | read_spec | def read_spec(filename, fname='', **kwargs):
"""Read FITS or ASCII spectrum.
Parameters
----------
filename : str or file pointer
Spectrum file name or pointer.
fname : str
Filename. This is *only* used if ``filename`` is a pointer.
kwargs : dict
Keywords acceptable by... | python | def read_spec(filename, fname='', **kwargs):
"""Read FITS or ASCII spectrum.
Parameters
----------
filename : str or file pointer
Spectrum file name or pointer.
fname : str
Filename. This is *only* used if ``filename`` is a pointer.
kwargs : dict
Keywords acceptable by... | [
"def",
"read_spec",
"(",
"filename",
",",
"fname",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"str",
")",
":",
"fname",
"=",
"filename",
"elif",
"not",
"fname",
":",
"# pragma: no cover",
"raise",
"exceptions"... | Read FITS or ASCII spectrum.
Parameters
----------
filename : str or file pointer
Spectrum file name or pointer.
fname : str
Filename. This is *only* used if ``filename`` is a pointer.
kwargs : dict
Keywords acceptable by :func:`read_fits_spec` (if FITS) or
:func:`... | [
"Read",
"FITS",
"or",
"ASCII",
"spectrum",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/specio.py#L58-L97 |
spacetelescope/synphot_refactor | synphot/specio.py | read_ascii_spec | def read_ascii_spec(filename, wave_unit=u.AA, flux_unit=units.FLAM, **kwargs):
"""Read ASCII spectrum.
ASCII table must have following columns:
#. Wavelength data
#. Flux data
It can have more than 2 columns but the rest is ignored.
Comments are discarded.
Parameters
--------... | python | def read_ascii_spec(filename, wave_unit=u.AA, flux_unit=units.FLAM, **kwargs):
"""Read ASCII spectrum.
ASCII table must have following columns:
#. Wavelength data
#. Flux data
It can have more than 2 columns but the rest is ignored.
Comments are discarded.
Parameters
--------... | [
"def",
"read_ascii_spec",
"(",
"filename",
",",
"wave_unit",
"=",
"u",
".",
"AA",
",",
"flux_unit",
"=",
"units",
".",
"FLAM",
",",
"*",
"*",
"kwargs",
")",
":",
"header",
"=",
"{",
"}",
"dat",
"=",
"ascii",
".",
"read",
"(",
"filename",
",",
"*",
... | Read ASCII spectrum.
ASCII table must have following columns:
#. Wavelength data
#. Flux data
It can have more than 2 columns but the rest is ignored.
Comments are discarded.
Parameters
----------
filename : str or file pointer
Spectrum file name or pointer.
wave... | [
"Read",
"ASCII",
"spectrum",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/specio.py#L100-L144 |
spacetelescope/synphot_refactor | synphot/specio.py | read_fits_spec | def read_fits_spec(filename, ext=1, wave_col='WAVELENGTH', flux_col='FLUX',
wave_unit=u.AA, flux_unit=units.FLAM):
"""Read FITS spectrum.
Wavelength and flux units are extracted from ``TUNIT1`` and ``TUNIT2``
keywords, respectively, from data table (not primary) header.
If these keyw... | python | def read_fits_spec(filename, ext=1, wave_col='WAVELENGTH', flux_col='FLUX',
wave_unit=u.AA, flux_unit=units.FLAM):
"""Read FITS spectrum.
Wavelength and flux units are extracted from ``TUNIT1`` and ``TUNIT2``
keywords, respectively, from data table (not primary) header.
If these keyw... | [
"def",
"read_fits_spec",
"(",
"filename",
",",
"ext",
"=",
"1",
",",
"wave_col",
"=",
"'WAVELENGTH'",
",",
"flux_col",
"=",
"'FLUX'",
",",
"wave_unit",
"=",
"u",
".",
"AA",
",",
"flux_unit",
"=",
"units",
".",
"FLAM",
")",
":",
"fs",
"=",
"fits",
"."... | Read FITS spectrum.
Wavelength and flux units are extracted from ``TUNIT1`` and ``TUNIT2``
keywords, respectively, from data table (not primary) header.
If these keywords are not present, units are taken from
``wave_unit`` and ``flux_unit`` instead.
Parameters
----------
filename : str or ... | [
"Read",
"FITS",
"spectrum",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/specio.py#L147-L215 |
spacetelescope/synphot_refactor | synphot/specio.py | write_fits_spec | def write_fits_spec(filename, wavelengths, fluxes, pri_header={},
ext_header={}, overwrite=False, trim_zero=True,
pad_zero_ends=True, precision=None, epsilon=0.00032,
wave_col='WAVELENGTH', flux_col='FLUX',
wave_unit=u.AA, flux_unit=units.F... | python | def write_fits_spec(filename, wavelengths, fluxes, pri_header={},
ext_header={}, overwrite=False, trim_zero=True,
pad_zero_ends=True, precision=None, epsilon=0.00032,
wave_col='WAVELENGTH', flux_col='FLUX',
wave_unit=u.AA, flux_unit=units.F... | [
"def",
"write_fits_spec",
"(",
"filename",
",",
"wavelengths",
",",
"fluxes",
",",
"pri_header",
"=",
"{",
"}",
",",
"ext_header",
"=",
"{",
"}",
",",
"overwrite",
"=",
"False",
",",
"trim_zero",
"=",
"True",
",",
"pad_zero_ends",
"=",
"True",
",",
"prec... | Write FITS spectrum.
.. warning::
If data is being written out as single-precision but wavelengths
are in double-precision, some rows may be omitted.
Parameters
----------
filename : str
Output spectrum filename.
wavelengths, fluxes : array-like or `~astropy.units.quantit... | [
"Write",
"FITS",
"spectrum",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/specio.py#L218-L384 |
spacetelescope/synphot_refactor | synphot/units.py | spectral_density_vega | def spectral_density_vega(wav, vegaflux):
"""Flux equivalencies between PHOTLAM and VEGAMAG.
Parameters
----------
wav : `~astropy.units.quantity.Quantity`
Quantity associated with values being converted
(e.g., wavelength or frequency).
vegaflux : `~astropy.units.quantity.Quantity`... | python | def spectral_density_vega(wav, vegaflux):
"""Flux equivalencies between PHOTLAM and VEGAMAG.
Parameters
----------
wav : `~astropy.units.quantity.Quantity`
Quantity associated with values being converted
(e.g., wavelength or frequency).
vegaflux : `~astropy.units.quantity.Quantity`... | [
"def",
"spectral_density_vega",
"(",
"wav",
",",
"vegaflux",
")",
":",
"vega_photlam",
"=",
"vegaflux",
".",
"to",
"(",
"PHOTLAM",
",",
"equivalencies",
"=",
"u",
".",
"spectral_density",
"(",
"wav",
")",
")",
".",
"value",
"def",
"converter",
"(",
"x",
... | Flux equivalencies between PHOTLAM and VEGAMAG.
Parameters
----------
wav : `~astropy.units.quantity.Quantity`
Quantity associated with values being converted
(e.g., wavelength or frequency).
vegaflux : `~astropy.units.quantity.Quantity`
Flux of Vega at ``wav``.
Returns
... | [
"Flux",
"equivalencies",
"between",
"PHOTLAM",
"and",
"VEGAMAG",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L64-L99 |
spacetelescope/synphot_refactor | synphot/units.py | spectral_density_count | def spectral_density_count(wav, area):
"""Flux equivalencies between PHOTLAM and count/OBMAG.
Parameters
----------
wav : `~astropy.units.quantity.Quantity`
Quantity associated with values being converted
(e.g., wavelength or frequency).
area : `~astropy.units.quantity.Quantity`
... | python | def spectral_density_count(wav, area):
"""Flux equivalencies between PHOTLAM and count/OBMAG.
Parameters
----------
wav : `~astropy.units.quantity.Quantity`
Quantity associated with values being converted
(e.g., wavelength or frequency).
area : `~astropy.units.quantity.Quantity`
... | [
"def",
"spectral_density_count",
"(",
"wav",
",",
"area",
")",
":",
"from",
".",
"binning",
"import",
"calculate_bin_widths",
",",
"calculate_bin_edges",
"wav",
"=",
"wav",
".",
"to",
"(",
"u",
".",
"AA",
",",
"equivalencies",
"=",
"u",
".",
"spectral",
"(... | Flux equivalencies between PHOTLAM and count/OBMAG.
Parameters
----------
wav : `~astropy.units.quantity.Quantity`
Quantity associated with values being converted
(e.g., wavelength or frequency).
area : `~astropy.units.quantity.Quantity`
Telescope collecting area.
Returns
... | [
"Flux",
"equivalencies",
"between",
"PHOTLAM",
"and",
"count",
"/",
"OBMAG",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L102-L140 |
spacetelescope/synphot_refactor | synphot/units.py | convert_flux | def convert_flux(wavelengths, fluxes, out_flux_unit, **kwargs):
"""Perform conversion for :ref:`supported flux units <synphot-flux-units>`.
Parameters
----------
wavelengths : array-like or `~astropy.units.quantity.Quantity`
Wavelength values. If not a Quantity, assumed to be in
Angstro... | python | def convert_flux(wavelengths, fluxes, out_flux_unit, **kwargs):
"""Perform conversion for :ref:`supported flux units <synphot-flux-units>`.
Parameters
----------
wavelengths : array-like or `~astropy.units.quantity.Quantity`
Wavelength values. If not a Quantity, assumed to be in
Angstro... | [
"def",
"convert_flux",
"(",
"wavelengths",
",",
"fluxes",
",",
"out_flux_unit",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"fluxes",
",",
"u",
".",
"Quantity",
")",
":",
"fluxes",
"=",
"fluxes",
"*",
"PHOTLAM",
"out_flux_unit",
"=... | Perform conversion for :ref:`supported flux units <synphot-flux-units>`.
Parameters
----------
wavelengths : array-like or `~astropy.units.quantity.Quantity`
Wavelength values. If not a Quantity, assumed to be in
Angstrom.
fluxes : array-like or `~astropy.units.quantity.Quantity`
... | [
"Perform",
"conversion",
"for",
":",
"ref",
":",
"supported",
"flux",
"units",
"<synphot",
"-",
"flux",
"-",
"units",
">",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L143-L225 |
spacetelescope/synphot_refactor | synphot/units.py | _convert_flux | def _convert_flux(wavelengths, fluxes, out_flux_unit, area=None,
vegaspec=None):
"""Flux conversion for PHOTLAM <-> X."""
flux_unit_names = (fluxes.unit.to_string(), out_flux_unit.to_string())
if PHOTLAM.to_string() not in flux_unit_names:
raise exceptions.SynphotError(
... | python | def _convert_flux(wavelengths, fluxes, out_flux_unit, area=None,
vegaspec=None):
"""Flux conversion for PHOTLAM <-> X."""
flux_unit_names = (fluxes.unit.to_string(), out_flux_unit.to_string())
if PHOTLAM.to_string() not in flux_unit_names:
raise exceptions.SynphotError(
... | [
"def",
"_convert_flux",
"(",
"wavelengths",
",",
"fluxes",
",",
"out_flux_unit",
",",
"area",
"=",
"None",
",",
"vegaspec",
"=",
"None",
")",
":",
"flux_unit_names",
"=",
"(",
"fluxes",
".",
"unit",
".",
"to_string",
"(",
")",
",",
"out_flux_unit",
".",
... | Flux conversion for PHOTLAM <-> X. | [
"Flux",
"conversion",
"for",
"PHOTLAM",
"<",
"-",
">",
"X",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L228-L268 |
spacetelescope/synphot_refactor | synphot/units.py | validate_unit | def validate_unit(input_unit):
"""Validate unit.
To be compatible with existing SYNPHOT data files:
* 'angstroms' and 'inversemicrons' are accepted although
unrecognized by astropy units
* 'transmission', 'extinction', and 'emissivity' are
converted to astropy dimensionless... | python | def validate_unit(input_unit):
"""Validate unit.
To be compatible with existing SYNPHOT data files:
* 'angstroms' and 'inversemicrons' are accepted although
unrecognized by astropy units
* 'transmission', 'extinction', and 'emissivity' are
converted to astropy dimensionless... | [
"def",
"validate_unit",
"(",
"input_unit",
")",
":",
"if",
"isinstance",
"(",
"input_unit",
",",
"str",
")",
":",
"input_unit_lowcase",
"=",
"input_unit",
".",
"lower",
"(",
")",
"# Backward-compatibility",
"if",
"input_unit_lowcase",
"==",
"'angstroms'",
":",
"... | Validate unit.
To be compatible with existing SYNPHOT data files:
* 'angstroms' and 'inversemicrons' are accepted although
unrecognized by astropy units
* 'transmission', 'extinction', and 'emissivity' are
converted to astropy dimensionless unit
Parameters
----------
... | [
"Validate",
"unit",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L275-L335 |
spacetelescope/synphot_refactor | synphot/units.py | validate_wave_unit | def validate_wave_unit(wave_unit):
"""Like :func:`validate_unit` but specific to wavelength."""
output_unit = validate_unit(wave_unit)
unit_type = output_unit.physical_type
if unit_type not in ('length', 'wavenumber', 'frequency'):
raise exceptions.SynphotError(
'wavelength physical... | python | def validate_wave_unit(wave_unit):
"""Like :func:`validate_unit` but specific to wavelength."""
output_unit = validate_unit(wave_unit)
unit_type = output_unit.physical_type
if unit_type not in ('length', 'wavenumber', 'frequency'):
raise exceptions.SynphotError(
'wavelength physical... | [
"def",
"validate_wave_unit",
"(",
"wave_unit",
")",
":",
"output_unit",
"=",
"validate_unit",
"(",
"wave_unit",
")",
"unit_type",
"=",
"output_unit",
".",
"physical_type",
"if",
"unit_type",
"not",
"in",
"(",
"'length'",
",",
"'wavenumber'",
",",
"'frequency'",
... | Like :func:`validate_unit` but specific to wavelength. | [
"Like",
":",
"func",
":",
"validate_unit",
"but",
"specific",
"to",
"wavelength",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L338-L348 |
spacetelescope/synphot_refactor | synphot/units.py | validate_quantity | def validate_quantity(input_value, output_unit, equivalencies=[]):
"""Validate quantity (value and unit).
.. note::
For flux conversion, use :func:`convert_flux` instead.
Parameters
----------
input_value : number, array-like, or `~astropy.units.quantity.Quantity`
Quantity to vali... | python | def validate_quantity(input_value, output_unit, equivalencies=[]):
"""Validate quantity (value and unit).
.. note::
For flux conversion, use :func:`convert_flux` instead.
Parameters
----------
input_value : number, array-like, or `~astropy.units.quantity.Quantity`
Quantity to vali... | [
"def",
"validate_quantity",
"(",
"input_value",
",",
"output_unit",
",",
"equivalencies",
"=",
"[",
"]",
")",
":",
"output_unit",
"=",
"validate_unit",
"(",
"output_unit",
")",
"if",
"isinstance",
"(",
"input_value",
",",
"u",
".",
"Quantity",
")",
":",
"out... | Validate quantity (value and unit).
.. note::
For flux conversion, use :func:`convert_flux` instead.
Parameters
----------
input_value : number, array-like, or `~astropy.units.quantity.Quantity`
Quantity to validate. If not a Quantity, assumed to be
already in output unit.
... | [
"Validate",
"quantity",
"(",
"value",
"and",
"unit",
")",
"."
] | train | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L351-L383 |
Julius2342/pyvlx | old_api/pyvlx/devices.py | Devices.add | def add(self, device):
"""Add device."""
if not isinstance(device, Device):
raise TypeError()
self.__devices.append(device) | python | def add(self, device):
"""Add device."""
if not isinstance(device, Device):
raise TypeError()
self.__devices.append(device) | [
"def",
"add",
"(",
"self",
",",
"device",
")",
":",
"if",
"not",
"isinstance",
"(",
"device",
",",
"Device",
")",
":",
"raise",
"TypeError",
"(",
")",
"self",
".",
"__devices",
".",
"append",
"(",
"device",
")"
] | Add device. | [
"Add",
"device",
"."
] | train | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/devices.py#L36-L40 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.