repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
amelchio/pysonos
pysonos/discovery.py
discover_thread
def discover_thread(callback, timeout=5, include_invisible=False, interface_addr=None): """ Return a started thread with a discovery callback. """ thread = StoppableThread( target=_discover_thread, args=(callback, timeout, include_invis...
python
def discover_thread(callback, timeout=5, include_invisible=False, interface_addr=None): """ Return a started thread with a discovery callback. """ thread = StoppableThread( target=_discover_thread, args=(callback, timeout, include_invis...
[ "def", "discover_thread", "(", "callback", ",", "timeout", "=", "5", ",", "include_invisible", "=", "False", ",", "interface_addr", "=", "None", ")", ":", "thread", "=", "StoppableThread", "(", "target", "=", "_discover_thread", ",", "args", "=", "(", "callb...
Return a started thread with a discovery callback.
[ "Return", "a", "started", "thread", "with", "a", "discovery", "callback", "." ]
23527c445a00e198fbb94d44b92f7f99d139e325
https://github.com/amelchio/pysonos/blob/23527c445a00e198fbb94d44b92f7f99d139e325/pysonos/discovery.py#L162-L171
train
amelchio/pysonos
pysonos/discovery.py
by_name
def by_name(name): """Return a device by name. Args: name (str): The name of the device to return. Returns: :class:`~.SoCo`: The first device encountered among all zone with the given player name. If none are found `None` is returned. """ devices = discover(all_househol...
python
def by_name(name): """Return a device by name. Args: name (str): The name of the device to return. Returns: :class:`~.SoCo`: The first device encountered among all zone with the given player name. If none are found `None` is returned. """ devices = discover(all_househol...
[ "def", "by_name", "(", "name", ")", ":", "devices", "=", "discover", "(", "all_households", "=", "True", ")", "for", "device", "in", "(", "devices", "or", "[", "]", ")", ":", "if", "device", ".", "player_name", "==", "name", ":", "return", "device", ...
Return a device by name. Args: name (str): The name of the device to return. Returns: :class:`~.SoCo`: The first device encountered among all zone with the given player name. If none are found `None` is returned.
[ "Return", "a", "device", "by", "name", "." ]
23527c445a00e198fbb94d44b92f7f99d139e325
https://github.com/amelchio/pysonos/blob/23527c445a00e198fbb94d44b92f7f99d139e325/pysonos/discovery.py#L262-L276
train
vsoch/pokemon
pokemon/master.py
get_trainer
def get_trainer(name): '''return the unique id for a trainer, determined by the md5 sum ''' name = name.lower() return int(hashlib.md5(name.encode('utf-8')).hexdigest(), 16) % 10**8
python
def get_trainer(name): '''return the unique id for a trainer, determined by the md5 sum ''' name = name.lower() return int(hashlib.md5(name.encode('utf-8')).hexdigest(), 16) % 10**8
[ "def", "get_trainer", "(", "name", ")", ":", "name", "=", "name", ".", "lower", "(", ")", "return", "int", "(", "hashlib", ".", "md5", "(", "name", ".", "encode", "(", "'utf-8'", ")", ")", ".", "hexdigest", "(", ")", ",", "16", ")", "%", "10", ...
return the unique id for a trainer, determined by the md5 sum
[ "return", "the", "unique", "id", "for", "a", "trainer", "determined", "by", "the", "md5", "sum" ]
c9cd8c5d64897617867d38d45183476ea64a0620
https://github.com/vsoch/pokemon/blob/c9cd8c5d64897617867d38d45183476ea64a0620/pokemon/master.py#L64-L68
train
vsoch/pokemon
pokemon/convert.py
scale_image
def scale_image(image, new_width): """Resizes an image preserving the aspect ratio. """ (original_width, original_height) = image.size aspect_ratio = original_height/float(original_width) new_height = int(aspect_ratio * new_width) # This scales it wider than tall, since characters are biased ...
python
def scale_image(image, new_width): """Resizes an image preserving the aspect ratio. """ (original_width, original_height) = image.size aspect_ratio = original_height/float(original_width) new_height = int(aspect_ratio * new_width) # This scales it wider than tall, since characters are biased ...
[ "def", "scale_image", "(", "image", ",", "new_width", ")", ":", "(", "original_width", ",", "original_height", ")", "=", "image", ".", "size", "aspect_ratio", "=", "original_height", "/", "float", "(", "original_width", ")", "new_height", "=", "int", "(", "a...
Resizes an image preserving the aspect ratio.
[ "Resizes", "an", "image", "preserving", "the", "aspect", "ratio", "." ]
c9cd8c5d64897617867d38d45183476ea64a0620
https://github.com/vsoch/pokemon/blob/c9cd8c5d64897617867d38d45183476ea64a0620/pokemon/convert.py#L34-L43
train
vsoch/pokemon
pokemon/convert.py
map_pixels_to_ascii_chars
def map_pixels_to_ascii_chars(image, range_width=25): """Maps each pixel to an ascii char based on the range in which it lies. 0-255 is divided into 11 ranges of 25 pixels each. """ pixels_in_image = list(image.getdata()) pixels_to_chars = [ASCII_CHARS[pixel_value/range_width] for pixel_value ...
python
def map_pixels_to_ascii_chars(image, range_width=25): """Maps each pixel to an ascii char based on the range in which it lies. 0-255 is divided into 11 ranges of 25 pixels each. """ pixels_in_image = list(image.getdata()) pixels_to_chars = [ASCII_CHARS[pixel_value/range_width] for pixel_value ...
[ "def", "map_pixels_to_ascii_chars", "(", "image", ",", "range_width", "=", "25", ")", ":", "pixels_in_image", "=", "list", "(", "image", ".", "getdata", "(", ")", ")", "pixels_to_chars", "=", "[", "ASCII_CHARS", "[", "pixel_value", "/", "range_width", "]", "...
Maps each pixel to an ascii char based on the range in which it lies. 0-255 is divided into 11 ranges of 25 pixels each.
[ "Maps", "each", "pixel", "to", "an", "ascii", "char", "based", "on", "the", "range", "in", "which", "it", "lies", "." ]
c9cd8c5d64897617867d38d45183476ea64a0620
https://github.com/vsoch/pokemon/blob/c9cd8c5d64897617867d38d45183476ea64a0620/pokemon/convert.py#L48-L59
train
NLeSC/scriptcwl
scriptcwl/library.py
load_steps
def load_steps(working_dir=None, steps_dir=None, step_file=None, step_list=None): """Return a dictionary containing Steps read from file. Args: steps_dir (str, optional): path to directory containing CWL files. step_file (str, optional): path or http(s) url to a single CWL file. ...
python
def load_steps(working_dir=None, steps_dir=None, step_file=None, step_list=None): """Return a dictionary containing Steps read from file. Args: steps_dir (str, optional): path to directory containing CWL files. step_file (str, optional): path or http(s) url to a single CWL file. ...
[ "def", "load_steps", "(", "working_dir", "=", "None", ",", "steps_dir", "=", "None", ",", "step_file", "=", "None", ",", "step_list", "=", "None", ")", ":", "if", "steps_dir", "is", "not", "None", ":", "step_files", "=", "glob", ".", "glob", "(", "os",...
Return a dictionary containing Steps read from file. Args: steps_dir (str, optional): path to directory containing CWL files. step_file (str, optional): path or http(s) url to a single CWL file. step_list (list, optional): a list of directories, urls or local file paths to CWL f...
[ "Return", "a", "dictionary", "containing", "Steps", "read", "from", "file", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/library.py#L83-L131
train
NLeSC/scriptcwl
scriptcwl/library.py
load_yaml
def load_yaml(filename): """Return object in yaml file.""" with open(filename) as myfile: content = myfile.read() if "win" in sys.platform: content = content.replace("\\", "/") return yaml.safe_load(content)
python
def load_yaml(filename): """Return object in yaml file.""" with open(filename) as myfile: content = myfile.read() if "win" in sys.platform: content = content.replace("\\", "/") return yaml.safe_load(content)
[ "def", "load_yaml", "(", "filename", ")", ":", "with", "open", "(", "filename", ")", "as", "myfile", ":", "content", "=", "myfile", ".", "read", "(", ")", "if", "\"win\"", "in", "sys", ".", "platform", ":", "content", "=", "content", ".", "replace", ...
Return object in yaml file.
[ "Return", "object", "in", "yaml", "file", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/library.py#L134-L140
train
NLeSC/scriptcwl
scriptcwl/library.py
sort_loading_order
def sort_loading_order(step_files): """Sort step files into correct loading order. The correct loading order is first tools, then workflows without subworkflows, and then workflows with subworkflows. This order is required to avoid error messages when a working directory is used. """ tools = []...
python
def sort_loading_order(step_files): """Sort step files into correct loading order. The correct loading order is first tools, then workflows without subworkflows, and then workflows with subworkflows. This order is required to avoid error messages when a working directory is used. """ tools = []...
[ "def", "sort_loading_order", "(", "step_files", ")", ":", "tools", "=", "[", "]", "workflows", "=", "[", "]", "workflows_with_subworkflows", "=", "[", "]", "for", "f", "in", "step_files", ":", "if", "f", ".", "startswith", "(", "'http://'", ")", "or", "f...
Sort step files into correct loading order. The correct loading order is first tools, then workflows without subworkflows, and then workflows with subworkflows. This order is required to avoid error messages when a working directory is used.
[ "Sort", "step", "files", "into", "correct", "loading", "order", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/library.py#L143-L171
train
NLeSC/scriptcwl
scriptcwl/scriptcwl.py
load_cwl
def load_cwl(fname): """Load and validate CWL file using cwltool """ logger.debug('Loading CWL file "{}"'.format(fname)) # Fetching, preprocessing and validating cwl # Older versions of cwltool if legacy_cwltool: try: (document_loader, workflowobj, uri) = fetch_document(fnam...
python
def load_cwl(fname): """Load and validate CWL file using cwltool """ logger.debug('Loading CWL file "{}"'.format(fname)) # Fetching, preprocessing and validating cwl # Older versions of cwltool if legacy_cwltool: try: (document_loader, workflowobj, uri) = fetch_document(fnam...
[ "def", "load_cwl", "(", "fname", ")", ":", "logger", ".", "debug", "(", "'Loading CWL file \"{}\"'", ".", "format", "(", "fname", ")", ")", "if", "legacy_cwltool", ":", "try", ":", "(", "document_loader", ",", "workflowobj", ",", "uri", ")", "=", "fetch_do...
Load and validate CWL file using cwltool
[ "Load", "and", "validate", "CWL", "file", "using", "cwltool" ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/scriptcwl.py#L42-L93
train
NLeSC/scriptcwl
scriptcwl/step.py
Step.set_input
def set_input(self, p_name, value): """Set a Step's input variable to a certain value. The value comes either from a workflow input or output of a previous step. Args: name (str): the name of the Step input value (str): the name of the output variable that p...
python
def set_input(self, p_name, value): """Set a Step's input variable to a certain value. The value comes either from a workflow input or output of a previous step. Args: name (str): the name of the Step input value (str): the name of the output variable that p...
[ "def", "set_input", "(", "self", ",", "p_name", ",", "value", ")", ":", "name", "=", "self", ".", "python_names", ".", "get", "(", "p_name", ")", "if", "p_name", "is", "None", "or", "name", "not", "in", "self", ".", "get_input_names", "(", ")", ":", ...
Set a Step's input variable to a certain value. The value comes either from a workflow input or output of a previous step. Args: name (str): the name of the Step input value (str): the name of the output variable that provides the value for this inpu...
[ "Set", "a", "Step", "s", "input", "variable", "to", "a", "certain", "value", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/step.py#L90-L108
train
NLeSC/scriptcwl
scriptcwl/step.py
Step.output_reference
def output_reference(self, name): """Return a reference to the given output for use in an input of a next Step. For a Step named `echo` that has an output called `echoed`, the reference `echo/echoed` is returned. Args: name (str): the name of the Step output ...
python
def output_reference(self, name): """Return a reference to the given output for use in an input of a next Step. For a Step named `echo` that has an output called `echoed`, the reference `echo/echoed` is returned. Args: name (str): the name of the Step output ...
[ "def", "output_reference", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "output_names", ":", "raise", "ValueError", "(", "'Invalid output \"{}\"'", ".", "format", "(", "name", ")", ")", "return", "Reference", "(", "step_name", ...
Return a reference to the given output for use in an input of a next Step. For a Step named `echo` that has an output called `echoed`, the reference `echo/echoed` is returned. Args: name (str): the name of the Step output Raises: ValueError: The name...
[ "Return", "a", "reference", "to", "the", "given", "output", "for", "use", "in", "an", "input", "of", "a", "next", "Step", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/step.py#L113-L128
train
NLeSC/scriptcwl
scriptcwl/step.py
Step._input_optional
def _input_optional(inp): """Returns True if a step input parameter is optional. Args: inp (dict): a dictionary representation of an input. Raises: ValueError: The inp provided is not valid. """ if 'default' in inp.keys(): return True ...
python
def _input_optional(inp): """Returns True if a step input parameter is optional. Args: inp (dict): a dictionary representation of an input. Raises: ValueError: The inp provided is not valid. """ if 'default' in inp.keys(): return True ...
[ "def", "_input_optional", "(", "inp", ")", ":", "if", "'default'", "in", "inp", ".", "keys", "(", ")", ":", "return", "True", "typ", "=", "inp", ".", "get", "(", "'type'", ")", "if", "isinstance", "(", "typ", ",", "six", ".", "string_types", ")", "...
Returns True if a step input parameter is optional. Args: inp (dict): a dictionary representation of an input. Raises: ValueError: The inp provided is not valid.
[ "Returns", "True", "if", "a", "step", "input", "parameter", "is", "optional", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/step.py#L131-L154
train
NLeSC/scriptcwl
scriptcwl/step.py
Step.to_obj
def to_obj(self, wd=False, pack=False, relpath=None): """Return the step as an dict that can be written to a yaml file. Returns: dict: yaml representation of the step. """ obj = CommentedMap() if pack: obj['run'] = self.orig elif relpath is not No...
python
def to_obj(self, wd=False, pack=False, relpath=None): """Return the step as an dict that can be written to a yaml file. Returns: dict: yaml representation of the step. """ obj = CommentedMap() if pack: obj['run'] = self.orig elif relpath is not No...
[ "def", "to_obj", "(", "self", ",", "wd", "=", "False", ",", "pack", "=", "False", ",", "relpath", "=", "None", ")", ":", "obj", "=", "CommentedMap", "(", ")", "if", "pack", ":", "obj", "[", "'run'", "]", "=", "self", ".", "orig", "elif", "relpath...
Return the step as an dict that can be written to a yaml file. Returns: dict: yaml representation of the step.
[ "Return", "the", "step", "as", "an", "dict", "that", "can", "be", "written", "to", "a", "yaml", "file", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/step.py#L205-L234
train
NLeSC/scriptcwl
scriptcwl/step.py
Step.list_inputs
def list_inputs(self): """Return a string listing all the Step's input names and their types. The types are returned in a copy/pastable format, so if the type is `string`, `'string'` (with single quotes) is returned. Returns: str containing all input names and types. ...
python
def list_inputs(self): """Return a string listing all the Step's input names and their types. The types are returned in a copy/pastable format, so if the type is `string`, `'string'` (with single quotes) is returned. Returns: str containing all input names and types. ...
[ "def", "list_inputs", "(", "self", ")", ":", "doc", "=", "[", "]", "for", "inp", ",", "typ", "in", "self", ".", "input_types", ".", "items", "(", ")", ":", "if", "isinstance", "(", "typ", ",", "six", ".", "string_types", ")", ":", "typ", "=", "\"...
Return a string listing all the Step's input names and their types. The types are returned in a copy/pastable format, so if the type is `string`, `'string'` (with single quotes) is returned. Returns: str containing all input names and types.
[ "Return", "a", "string", "listing", "all", "the", "Step", "s", "input", "names", "and", "their", "types", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/step.py#L251-L265
train
NLeSC/scriptcwl
scriptcwl/workflow.py
WorkflowGenerator.load
def load(self, steps_dir=None, step_file=None, step_list=None): """Load CWL steps into the WorkflowGenerator's steps library. Adds steps (command line tools and workflows) to the ``WorkflowGenerator``'s steps library. These steps can be used to create workflows. Args: ...
python
def load(self, steps_dir=None, step_file=None, step_list=None): """Load CWL steps into the WorkflowGenerator's steps library. Adds steps (command line tools and workflows) to the ``WorkflowGenerator``'s steps library. These steps can be used to create workflows. Args: ...
[ "def", "load", "(", "self", ",", "steps_dir", "=", "None", ",", "step_file", "=", "None", ",", "step_list", "=", "None", ")", ":", "self", ".", "_closed", "(", ")", "self", ".", "steps_library", ".", "load", "(", "steps_dir", "=", "steps_dir", ",", "...
Load CWL steps into the WorkflowGenerator's steps library. Adds steps (command line tools and workflows) to the ``WorkflowGenerator``'s steps library. These steps can be used to create workflows. Args: steps_dir (str): path to directory containing CWL files. All CWL in ...
[ "Load", "CWL", "steps", "into", "the", "WorkflowGenerator", "s", "steps", "library", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L160-L176
train
NLeSC/scriptcwl
scriptcwl/workflow.py
WorkflowGenerator._has_requirements
def _has_requirements(self): """Returns True if the workflow needs a requirements section. Returns: bool: True if the workflow needs a requirements section, False otherwise. """ self._closed() return any([self.has_workflow_step, self.has_scatter_requ...
python
def _has_requirements(self): """Returns True if the workflow needs a requirements section. Returns: bool: True if the workflow needs a requirements section, False otherwise. """ self._closed() return any([self.has_workflow_step, self.has_scatter_requ...
[ "def", "_has_requirements", "(", "self", ")", ":", "self", ".", "_closed", "(", ")", "return", "any", "(", "[", "self", ".", "has_workflow_step", ",", "self", ".", "has_scatter_requirement", ",", "self", ".", "has_multiple_inputs", "]", ")" ]
Returns True if the workflow needs a requirements section. Returns: bool: True if the workflow needs a requirements section, False otherwise.
[ "Returns", "True", "if", "the", "workflow", "needs", "a", "requirements", "section", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L185-L195
train
NLeSC/scriptcwl
scriptcwl/workflow.py
WorkflowGenerator.inputs
def inputs(self, name): """List input names and types of a step in the steps library. Args: name (str): name of a step in the steps library. """ self._closed() step = self._get_step(name, make_copy=False) return step.list_inputs()
python
def inputs(self, name): """List input names and types of a step in the steps library. Args: name (str): name of a step in the steps library. """ self._closed() step = self._get_step(name, make_copy=False) return step.list_inputs()
[ "def", "inputs", "(", "self", ",", "name", ")", ":", "self", ".", "_closed", "(", ")", "step", "=", "self", ".", "_get_step", "(", "name", ",", "make_copy", "=", "False", ")", "return", "step", ".", "list_inputs", "(", ")" ]
List input names and types of a step in the steps library. Args: name (str): name of a step in the steps library.
[ "List", "input", "names", "and", "types", "of", "a", "step", "in", "the", "steps", "library", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L197-L206
train
NLeSC/scriptcwl
scriptcwl/workflow.py
WorkflowGenerator._add_step
def _add_step(self, step): """Add a step to the workflow. Args: step (Step): a step from the steps library. """ self._closed() self.has_workflow_step = self.has_workflow_step or step.is_workflow self.wf_steps[step.name_in_workflow] = step
python
def _add_step(self, step): """Add a step to the workflow. Args: step (Step): a step from the steps library. """ self._closed() self.has_workflow_step = self.has_workflow_step or step.is_workflow self.wf_steps[step.name_in_workflow] = step
[ "def", "_add_step", "(", "self", ",", "step", ")", ":", "self", ".", "_closed", "(", ")", "self", ".", "has_workflow_step", "=", "self", ".", "has_workflow_step", "or", "step", ".", "is_workflow", "self", ".", "wf_steps", "[", "step", ".", "name_in_workflo...
Add a step to the workflow. Args: step (Step): a step from the steps library.
[ "Add", "a", "step", "to", "the", "workflow", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L208-L217
train
NLeSC/scriptcwl
scriptcwl/workflow.py
WorkflowGenerator.add_input
def add_input(self, **kwargs): """Add workflow input. Args: kwargs (dict): A dict with a `name: type` item and optionally a `default: value` item, where name is the name (id) of the workflow input (e.g., `dir_in`) and type is the type of the i...
python
def add_input(self, **kwargs): """Add workflow input. Args: kwargs (dict): A dict with a `name: type` item and optionally a `default: value` item, where name is the name (id) of the workflow input (e.g., `dir_in`) and type is the type of the i...
[ "def", "add_input", "(", "self", ",", "**", "kwargs", ")", ":", "self", ".", "_closed", "(", ")", "def", "_get_item", "(", "args", ")", ":", "if", "not", "args", ":", "raise", "ValueError", "(", "\"No parameter specified.\"", ")", "item", "=", "args", ...
Add workflow input. Args: kwargs (dict): A dict with a `name: type` item and optionally a `default: value` item, where name is the name (id) of the workflow input (e.g., `dir_in`) and type is the type of the input (e.g., `'Directory'`). ...
[ "Add", "workflow", "input", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L219-L299
train
NLeSC/scriptcwl
scriptcwl/workflow.py
WorkflowGenerator.add_outputs
def add_outputs(self, **kwargs): """Add workflow outputs. The output type is added automatically, based on the steps in the steps library. Args: kwargs (dict): A dict containing ``name=source name`` pairs. ``name`` is the name of the workflow output (e.g., ...
python
def add_outputs(self, **kwargs): """Add workflow outputs. The output type is added automatically, based on the steps in the steps library. Args: kwargs (dict): A dict containing ``name=source name`` pairs. ``name`` is the name of the workflow output (e.g., ...
[ "def", "add_outputs", "(", "self", ",", "**", "kwargs", ")", ":", "self", ".", "_closed", "(", ")", "for", "name", ",", "source_name", "in", "kwargs", ".", "items", "(", ")", ":", "obj", "=", "{", "}", "obj", "[", "'outputSource'", "]", "=", "sourc...
Add workflow outputs. The output type is added automatically, based on the steps in the steps library. Args: kwargs (dict): A dict containing ``name=source name`` pairs. ``name`` is the name of the workflow output (e.g., ``txt_files``) and source nam...
[ "Add", "workflow", "outputs", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L301-L320
train
NLeSC/scriptcwl
scriptcwl/workflow.py
WorkflowGenerator._get_step
def _get_step(self, name, make_copy=True): """Return step from steps library. Optionally, the step returned is a deep copy from the step in the steps library, so additional information (e.g., about whether the step was scattered) can be stored in the copy. Args: nam...
python
def _get_step(self, name, make_copy=True): """Return step from steps library. Optionally, the step returned is a deep copy from the step in the steps library, so additional information (e.g., about whether the step was scattered) can be stored in the copy. Args: nam...
[ "def", "_get_step", "(", "self", ",", "name", ",", "make_copy", "=", "True", ")", ":", "self", ".", "_closed", "(", ")", "s", "=", "self", ".", "steps_library", ".", "get_step", "(", "name", ")", "if", "s", "is", "None", ":", "msg", "=", "'\"{}\" n...
Return step from steps library. Optionally, the step returned is a deep copy from the step in the steps library, so additional information (e.g., about whether the step was scattered) can be stored in the copy. Args: name (str): name of the step in the steps library. ...
[ "Return", "step", "from", "steps", "library", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L342-L370
train
NLeSC/scriptcwl
scriptcwl/workflow.py
WorkflowGenerator.to_obj
def to_obj(self, wd=False, pack=False, relpath=None): """Return the created workflow as a dict. The dict can be written to a yaml file. Returns: A yaml-compatible dict representing the workflow. """ self._closed() obj = CommentedMap() obj['cwlVersio...
python
def to_obj(self, wd=False, pack=False, relpath=None): """Return the created workflow as a dict. The dict can be written to a yaml file. Returns: A yaml-compatible dict representing the workflow. """ self._closed() obj = CommentedMap() obj['cwlVersio...
[ "def", "to_obj", "(", "self", ",", "wd", "=", "False", ",", "pack", "=", "False", ",", "relpath", "=", "None", ")", ":", "self", ".", "_closed", "(", ")", "obj", "=", "CommentedMap", "(", ")", "obj", "[", "'cwlVersion'", "]", "=", "'v1.0'", "obj", ...
Return the created workflow as a dict. The dict can be written to a yaml file. Returns: A yaml-compatible dict representing the workflow.
[ "Return", "the", "created", "workflow", "as", "a", "dict", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L382-L423
train
NLeSC/scriptcwl
scriptcwl/workflow.py
WorkflowGenerator.to_script
def to_script(self, wf_name='wf'): """Generated and print the scriptcwl script for the currunt workflow. Args: wf_name (str): string used for the WorkflowGenerator object in the generated script (default: ``wf``). """ self._closed() script = [] ...
python
def to_script(self, wf_name='wf'): """Generated and print the scriptcwl script for the currunt workflow. Args: wf_name (str): string used for the WorkflowGenerator object in the generated script (default: ``wf``). """ self._closed() script = [] ...
[ "def", "to_script", "(", "self", ",", "wf_name", "=", "'wf'", ")", ":", "self", ".", "_closed", "(", ")", "script", "=", "[", "]", "params", "=", "[", "]", "returns", "=", "[", "]", "for", "name", ",", "typ", "in", "self", ".", "wf_inputs", ".", ...
Generated and print the scriptcwl script for the currunt workflow. Args: wf_name (str): string used for the WorkflowGenerator object in the generated script (default: ``wf``).
[ "Generated", "and", "print", "the", "scriptcwl", "script", "for", "the", "currunt", "workflow", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L425-L473
train
NLeSC/scriptcwl
scriptcwl/workflow.py
WorkflowGenerator._types_match
def _types_match(type1, type2): """Returns False only if it can show that no value of type1 can possibly match type2. Supports only a limited selection of types. """ if isinstance(type1, six.string_types) and \ isinstance(type2, six.string_types): typ...
python
def _types_match(type1, type2): """Returns False only if it can show that no value of type1 can possibly match type2. Supports only a limited selection of types. """ if isinstance(type1, six.string_types) and \ isinstance(type2, six.string_types): typ...
[ "def", "_types_match", "(", "type1", ",", "type2", ")", ":", "if", "isinstance", "(", "type1", ",", "six", ".", "string_types", ")", "and", "isinstance", "(", "type2", ",", "six", ".", "string_types", ")", ":", "type1", "=", "type1", ".", "rstrip", "("...
Returns False only if it can show that no value of type1 can possibly match type2. Supports only a limited selection of types.
[ "Returns", "False", "only", "if", "it", "can", "show", "that", "no", "value", "of", "type1", "can", "possibly", "match", "type2", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L506-L519
train
NLeSC/scriptcwl
scriptcwl/workflow.py
WorkflowGenerator.validate
def validate(self): """Validate workflow object. This method currently validates the workflow object with the use of cwltool. It writes the workflow to a tmp CWL file, reads it, validates it and removes the tmp file again. By default, the workflow is written to file using absolu...
python
def validate(self): """Validate workflow object. This method currently validates the workflow object with the use of cwltool. It writes the workflow to a tmp CWL file, reads it, validates it and removes the tmp file again. By default, the workflow is written to file using absolu...
[ "def", "validate", "(", "self", ")", ":", "(", "fd", ",", "tmpfile", ")", "=", "tempfile", ".", "mkstemp", "(", ")", "os", ".", "close", "(", "fd", ")", "try", ":", "self", ".", "save", "(", "tmpfile", ",", "mode", "=", "'abs'", ",", "validate", ...
Validate workflow object. This method currently validates the workflow object with the use of cwltool. It writes the workflow to a tmp CWL file, reads it, validates it and removes the tmp file again. By default, the workflow is written to file using absolute paths to the steps.
[ "Validate", "workflow", "object", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L652-L671
train
NLeSC/scriptcwl
scriptcwl/workflow.py
WorkflowGenerator.save
def save(self, fname, mode=None, validate=True, encoding='utf-8', wd=False, inline=False, relative=False, pack=False): """Save the workflow to file. Save the workflow to a CWL file that can be run with a CWL runner. Args: fname (str): file to save the workflow to. ...
python
def save(self, fname, mode=None, validate=True, encoding='utf-8', wd=False, inline=False, relative=False, pack=False): """Save the workflow to file. Save the workflow to a CWL file that can be run with a CWL runner. Args: fname (str): file to save the workflow to. ...
[ "def", "save", "(", "self", ",", "fname", ",", "mode", "=", "None", ",", "validate", "=", "True", ",", "encoding", "=", "'utf-8'", ",", "wd", "=", "False", ",", "inline", "=", "False", ",", "relative", "=", "False", ",", "pack", "=", "False", ")", ...
Save the workflow to file. Save the workflow to a CWL file that can be run with a CWL runner. Args: fname (str): file to save the workflow to. mode (str): one of (rel, abs, wd, inline, pack) encoding (str): file encoding to use (default: ``utf-8``).
[ "Save", "the", "workflow", "to", "file", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/workflow.py#L692-L764
train
NLeSC/scriptcwl
scriptcwl/yamlutils.py
str_presenter
def str_presenter(dmpr, data): """Return correct str_presenter to write multiple lines to a yaml field. Source: http://stackoverflow.com/a/33300001 """ if is_multiline(data): return dmpr.represent_scalar('tag:yaml.org,2002:str', data, style='|') return dmpr.represent_scalar('tag:yaml.org,2...
python
def str_presenter(dmpr, data): """Return correct str_presenter to write multiple lines to a yaml field. Source: http://stackoverflow.com/a/33300001 """ if is_multiline(data): return dmpr.represent_scalar('tag:yaml.org,2002:str', data, style='|') return dmpr.represent_scalar('tag:yaml.org,2...
[ "def", "str_presenter", "(", "dmpr", ",", "data", ")", ":", "if", "is_multiline", "(", "data", ")", ":", "return", "dmpr", ".", "represent_scalar", "(", "'tag:yaml.org,2002:str'", ",", "data", ",", "style", "=", "'|'", ")", "return", "dmpr", ".", "represen...
Return correct str_presenter to write multiple lines to a yaml field. Source: http://stackoverflow.com/a/33300001
[ "Return", "correct", "str_presenter", "to", "write", "multiple", "lines", "to", "a", "yaml", "field", "." ]
33bb847a875379da3a5702c7a98dfa585306b960
https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/yamlutils.py#L22-L30
train
nschloe/colorio
experiments/new-cs.py
build_grad_matrices
def build_grad_matrices(V, points): """Build the sparse m-by-n matrices that map a coefficient set for a function in V to the values of dx and dy at a number m of points. """ # See <https://www.allanswered.com/post/lkbkm/#zxqgk> mesh = V.mesh() bbt = BoundingBoxTree() bbt.build(mesh) do...
python
def build_grad_matrices(V, points): """Build the sparse m-by-n matrices that map a coefficient set for a function in V to the values of dx and dy at a number m of points. """ # See <https://www.allanswered.com/post/lkbkm/#zxqgk> mesh = V.mesh() bbt = BoundingBoxTree() bbt.build(mesh) do...
[ "def", "build_grad_matrices", "(", "V", ",", "points", ")", ":", "mesh", "=", "V", ".", "mesh", "(", ")", "bbt", "=", "BoundingBoxTree", "(", ")", "bbt", ".", "build", "(", "mesh", ")", "dofmap", "=", "V", ".", "dofmap", "(", ")", "el", "=", "V",...
Build the sparse m-by-n matrices that map a coefficient set for a function in V to the values of dx and dy at a number m of points.
[ "Build", "the", "sparse", "m", "-", "by", "-", "n", "matrices", "that", "map", "a", "coefficient", "set", "for", "a", "function", "in", "V", "to", "the", "values", "of", "dx", "and", "dy", "at", "a", "number", "m", "of", "points", "." ]
357d6001b3cf30f752e23726bf429dc1d1c60b3a
https://github.com/nschloe/colorio/blob/357d6001b3cf30f752e23726bf429dc1d1c60b3a/experiments/new-cs.py#L309-L346
train
nschloe/colorio
experiments/new-cs.py
PiecewiseEllipse.apply_M
def apply_M(self, ax, ay): """Linear operator that converts ax, ay to abcd. """ jac = numpy.array( [[self.dx.dot(ax), self.dy.dot(ax)], [self.dx.dot(ay), self.dy.dot(ay)]] ) # jacs and J are of shape (2, 2, k). M must be of the same shape and # contain the re...
python
def apply_M(self, ax, ay): """Linear operator that converts ax, ay to abcd. """ jac = numpy.array( [[self.dx.dot(ax), self.dy.dot(ax)], [self.dx.dot(ay), self.dy.dot(ay)]] ) # jacs and J are of shape (2, 2, k). M must be of the same shape and # contain the re...
[ "def", "apply_M", "(", "self", ",", "ax", ",", "ay", ")", ":", "jac", "=", "numpy", ".", "array", "(", "[", "[", "self", ".", "dx", ".", "dot", "(", "ax", ")", ",", "self", ".", "dy", ".", "dot", "(", "ax", ")", "]", ",", "[", "self", "."...
Linear operator that converts ax, ay to abcd.
[ "Linear", "operator", "that", "converts", "ax", "ay", "to", "abcd", "." ]
357d6001b3cf30f752e23726bf429dc1d1c60b3a
https://github.com/nschloe/colorio/blob/357d6001b3cf30f752e23726bf429dc1d1c60b3a/experiments/new-cs.py#L423-L458
train
nschloe/colorio
experiments/new-cs.py
PiecewiseEllipse.cost_min2
def cost_min2(self, alpha): """Residual formulation, Hessian is a low-rank update of the identity. """ n = self.V.dim() ax = alpha[:n] ay = alpha[n:] # ml = pyamg.ruge_stuben_solver(self.L) # # ml = pyamg.smoothed_aggregation_solver(self.L) # print(ml) ...
python
def cost_min2(self, alpha): """Residual formulation, Hessian is a low-rank update of the identity. """ n = self.V.dim() ax = alpha[:n] ay = alpha[n:] # ml = pyamg.ruge_stuben_solver(self.L) # # ml = pyamg.smoothed_aggregation_solver(self.L) # print(ml) ...
[ "def", "cost_min2", "(", "self", ",", "alpha", ")", ":", "n", "=", "self", ".", "V", ".", "dim", "(", ")", "ax", "=", "alpha", "[", ":", "n", "]", "ay", "=", "alpha", "[", "n", ":", "]", "q2", ",", "r2", "=", "self", ".", "get_q2_r2", "(", ...
Residual formulation, Hessian is a low-rank update of the identity.
[ "Residual", "formulation", "Hessian", "is", "a", "low", "-", "rank", "update", "of", "the", "identity", "." ]
357d6001b3cf30f752e23726bf429dc1d1c60b3a
https://github.com/nschloe/colorio/blob/357d6001b3cf30f752e23726bf429dc1d1c60b3a/experiments/new-cs.py#L757-L798
train
nschloe/colorio
colorio/tools.py
delta
def delta(a, b): """Computes the distances between two colors or color sets. The shape of `a` and `b` must be equal. """ diff = a - b return numpy.einsum("i...,i...->...", diff, diff)
python
def delta(a, b): """Computes the distances between two colors or color sets. The shape of `a` and `b` must be equal. """ diff = a - b return numpy.einsum("i...,i...->...", diff, diff)
[ "def", "delta", "(", "a", ",", "b", ")", ":", "diff", "=", "a", "-", "b", "return", "numpy", ".", "einsum", "(", "\"i...,i...->...\"", ",", "diff", ",", "diff", ")" ]
Computes the distances between two colors or color sets. The shape of `a` and `b` must be equal.
[ "Computes", "the", "distances", "between", "two", "colors", "or", "color", "sets", ".", "The", "shape", "of", "a", "and", "b", "must", "be", "equal", "." ]
357d6001b3cf30f752e23726bf429dc1d1c60b3a
https://github.com/nschloe/colorio/blob/357d6001b3cf30f752e23726bf429dc1d1c60b3a/colorio/tools.py#L24-L29
train
nschloe/colorio
colorio/tools.py
plot_flat_gamut
def plot_flat_gamut( xy_to_2d=lambda xy: xy, axes_labels=("x", "y"), plot_rgb_triangle=True, fill_horseshoe=True, plot_planckian_locus=True, ): """Show a flat color gamut, by default xy. There exists a chroma gamut for all color models which transform lines in XYZ to lines, and hence have a...
python
def plot_flat_gamut( xy_to_2d=lambda xy: xy, axes_labels=("x", "y"), plot_rgb_triangle=True, fill_horseshoe=True, plot_planckian_locus=True, ): """Show a flat color gamut, by default xy. There exists a chroma gamut for all color models which transform lines in XYZ to lines, and hence have a...
[ "def", "plot_flat_gamut", "(", "xy_to_2d", "=", "lambda", "xy", ":", "xy", ",", "axes_labels", "=", "(", "\"x\"", ",", "\"y\"", ")", ",", "plot_rgb_triangle", "=", "True", ",", "fill_horseshoe", "=", "True", ",", "plot_planckian_locus", "=", "True", ",", "...
Show a flat color gamut, by default xy. There exists a chroma gamut for all color models which transform lines in XYZ to lines, and hence have a natural decomposition into lightness and chroma components. Also, the flat gamut is the same for every lightness value. Examples for color models with this p...
[ "Show", "a", "flat", "color", "gamut", "by", "default", "xy", ".", "There", "exists", "a", "chroma", "gamut", "for", "all", "color", "models", "which", "transform", "lines", "in", "XYZ", "to", "lines", "and", "hence", "have", "a", "natural", "decomposition...
357d6001b3cf30f752e23726bf429dc1d1c60b3a
https://github.com/nschloe/colorio/blob/357d6001b3cf30f752e23726bf429dc1d1c60b3a/colorio/tools.py#L199-L228
train
nschloe/colorio
experiments/pade2d.py
_get_xy_tree
def _get_xy_tree(xy, degree): """Evaluates the entire tree of 2d mononomials. The return value is a list of arrays, where `out[k]` hosts the `2*k+1` values of the `k`th level of the tree (0, 0) (1, 0) (0, 1) (2, 0) (1, 1) (0, 2) ... ... ... """ x, ...
python
def _get_xy_tree(xy, degree): """Evaluates the entire tree of 2d mononomials. The return value is a list of arrays, where `out[k]` hosts the `2*k+1` values of the `k`th level of the tree (0, 0) (1, 0) (0, 1) (2, 0) (1, 1) (0, 2) ... ... ... """ x, ...
[ "def", "_get_xy_tree", "(", "xy", ",", "degree", ")", ":", "x", ",", "y", "=", "xy", "tree", "=", "[", "numpy", ".", "array", "(", "[", "numpy", ".", "ones", "(", "x", ".", "shape", ",", "dtype", "=", "int", ")", "]", ")", "]", "for", "d", ...
Evaluates the entire tree of 2d mononomials. The return value is a list of arrays, where `out[k]` hosts the `2*k+1` values of the `k`th level of the tree (0, 0) (1, 0) (0, 1) (2, 0) (1, 1) (0, 2) ... ... ...
[ "Evaluates", "the", "entire", "tree", "of", "2d", "mononomials", "." ]
357d6001b3cf30f752e23726bf429dc1d1c60b3a
https://github.com/nschloe/colorio/blob/357d6001b3cf30f752e23726bf429dc1d1c60b3a/experiments/pade2d.py#L17-L32
train
nschloe/colorio
colorio/illuminants.py
spectrum_to_xyz100
def spectrum_to_xyz100(spectrum, observer): """Computes the tristimulus values XYZ from a given spectrum for a given observer via X_i = int_lambda spectrum_i(lambda) * observer_i(lambda) dlambda. In section 7, the technical report CIE Standard Illuminants for Colorimetry, 1999, gives a recommendat...
python
def spectrum_to_xyz100(spectrum, observer): """Computes the tristimulus values XYZ from a given spectrum for a given observer via X_i = int_lambda spectrum_i(lambda) * observer_i(lambda) dlambda. In section 7, the technical report CIE Standard Illuminants for Colorimetry, 1999, gives a recommendat...
[ "def", "spectrum_to_xyz100", "(", "spectrum", ",", "observer", ")", ":", "lambda_o", ",", "data_o", "=", "observer", "lambda_s", ",", "data_s", "=", "spectrum", "lmbda", "=", "numpy", ".", "sort", "(", "numpy", ".", "unique", "(", "numpy", ".", "concatenat...
Computes the tristimulus values XYZ from a given spectrum for a given observer via X_i = int_lambda spectrum_i(lambda) * observer_i(lambda) dlambda. In section 7, the technical report CIE Standard Illuminants for Colorimetry, 1999, gives a recommendation on how to perform the computation.
[ "Computes", "the", "tristimulus", "values", "XYZ", "from", "a", "given", "spectrum", "for", "a", "given", "observer", "via" ]
357d6001b3cf30f752e23726bf429dc1d1c60b3a
https://github.com/nschloe/colorio/blob/357d6001b3cf30f752e23726bf429dc1d1c60b3a/colorio/illuminants.py#L36-L84
train
nschloe/colorio
colorio/illuminants.py
d
def d(nominal_temperature): """CIE D-series illuminants. The technical report `Colorimetry, 3rd edition, 2004` gives the data for D50, D55, and D65 explicitly, but also explains how it's computed for S0, S1, S2. Values are given at 5nm resolution in the document, but really every other value is jus...
python
def d(nominal_temperature): """CIE D-series illuminants. The technical report `Colorimetry, 3rd edition, 2004` gives the data for D50, D55, and D65 explicitly, but also explains how it's computed for S0, S1, S2. Values are given at 5nm resolution in the document, but really every other value is jus...
[ "def", "d", "(", "nominal_temperature", ")", ":", "tcp", "=", "1.4388e-2", "/", "1.4380e-2", "*", "nominal_temperature", "if", "4000", "<=", "tcp", "<=", "7000", ":", "xd", "=", "(", "(", "-", "4.6070e9", "/", "tcp", "+", "2.9678e6", ")", "/", "tcp", ...
CIE D-series illuminants. The technical report `Colorimetry, 3rd edition, 2004` gives the data for D50, D55, and D65 explicitly, but also explains how it's computed for S0, S1, S2. Values are given at 5nm resolution in the document, but really every other value is just interpolated. Hence, only provide...
[ "CIE", "D", "-", "series", "illuminants", "." ]
357d6001b3cf30f752e23726bf429dc1d1c60b3a
https://github.com/nschloe/colorio/blob/357d6001b3cf30f752e23726bf429dc1d1c60b3a/colorio/illuminants.py#L137-L186
train
nschloe/colorio
colorio/illuminants.py
e
def e(): """This is a hypothetical reference radiator. All wavelengths in CIE illuminant E are weighted equally with a relative spectral power of 100.0. """ lmbda = 1.0e-9 * numpy.arange(300, 831) data = numpy.full(lmbda.shape, 100.0) return lmbda, data
python
def e(): """This is a hypothetical reference radiator. All wavelengths in CIE illuminant E are weighted equally with a relative spectral power of 100.0. """ lmbda = 1.0e-9 * numpy.arange(300, 831) data = numpy.full(lmbda.shape, 100.0) return lmbda, data
[ "def", "e", "(", ")", ":", "lmbda", "=", "1.0e-9", "*", "numpy", ".", "arange", "(", "300", ",", "831", ")", "data", "=", "numpy", ".", "full", "(", "lmbda", ".", "shape", ",", "100.0", ")", "return", "lmbda", ",", "data" ]
This is a hypothetical reference radiator. All wavelengths in CIE illuminant E are weighted equally with a relative spectral power of 100.0.
[ "This", "is", "a", "hypothetical", "reference", "radiator", ".", "All", "wavelengths", "in", "CIE", "illuminant", "E", "are", "weighted", "equally", "with", "a", "relative", "spectral", "power", "of", "100", ".", "0", "." ]
357d6001b3cf30f752e23726bf429dc1d1c60b3a
https://github.com/nschloe/colorio/blob/357d6001b3cf30f752e23726bf429dc1d1c60b3a/colorio/illuminants.py#L215-L221
train
nschloe/colorio
colorio/linalg.py
dot
def dot(a, b): """Take arrays `a` and `b` and form the dot product between the last axis of `a` and the first of `b`. """ b = numpy.asarray(b) return numpy.dot(a, b.reshape(b.shape[0], -1)).reshape(a.shape[:-1] + b.shape[1:])
python
def dot(a, b): """Take arrays `a` and `b` and form the dot product between the last axis of `a` and the first of `b`. """ b = numpy.asarray(b) return numpy.dot(a, b.reshape(b.shape[0], -1)).reshape(a.shape[:-1] + b.shape[1:])
[ "def", "dot", "(", "a", ",", "b", ")", ":", "b", "=", "numpy", ".", "asarray", "(", "b", ")", "return", "numpy", ".", "dot", "(", "a", ",", "b", ".", "reshape", "(", "b", ".", "shape", "[", "0", "]", ",", "-", "1", ")", ")", ".", "reshape...
Take arrays `a` and `b` and form the dot product between the last axis of `a` and the first of `b`.
[ "Take", "arrays", "a", "and", "b", "and", "form", "the", "dot", "product", "between", "the", "last", "axis", "of", "a", "and", "the", "first", "of", "b", "." ]
357d6001b3cf30f752e23726bf429dc1d1c60b3a
https://github.com/nschloe/colorio/blob/357d6001b3cf30f752e23726bf429dc1d1c60b3a/colorio/linalg.py#L6-L11
train
dshean/demcoreg
demcoreg/dem_mask.py
get_nlcd_mask
def get_nlcd_mask(nlcd_ds, filter='not_forest', out_fn=None): """Generate raster mask for specified NLCD LULC filter """ print("Loading NLCD LULC") b = nlcd_ds.GetRasterBand(1) l = b.ReadAsArray() print("Filtering NLCD LULC with: %s" % filter) #Original nlcd products have nan as ndv ...
python
def get_nlcd_mask(nlcd_ds, filter='not_forest', out_fn=None): """Generate raster mask for specified NLCD LULC filter """ print("Loading NLCD LULC") b = nlcd_ds.GetRasterBand(1) l = b.ReadAsArray() print("Filtering NLCD LULC with: %s" % filter) #Original nlcd products have nan as ndv ...
[ "def", "get_nlcd_mask", "(", "nlcd_ds", ",", "filter", "=", "'not_forest'", ",", "out_fn", "=", "None", ")", ":", "print", "(", "\"Loading NLCD LULC\"", ")", "b", "=", "nlcd_ds", ".", "GetRasterBand", "(", "1", ")", "l", "=", "b", ".", "ReadAsArray", "("...
Generate raster mask for specified NLCD LULC filter
[ "Generate", "raster", "mask", "for", "specified", "NLCD", "LULC", "filter" ]
abd6be75d326b35f52826ee30dff01f9e86b4b52
https://github.com/dshean/demcoreg/blob/abd6be75d326b35f52826ee30dff01f9e86b4b52/demcoreg/dem_mask.py#L108-L141
train
dshean/demcoreg
demcoreg/dem_mask.py
get_bareground_mask
def get_bareground_mask(bareground_ds, bareground_thresh=60, out_fn=None): """Generate raster mask for exposed bare ground from global bareground data """ print("Loading bareground") b = bareground_ds.GetRasterBand(1) l = b.ReadAsArray() print("Masking pixels with <%0.1f%% bare ground" % baregro...
python
def get_bareground_mask(bareground_ds, bareground_thresh=60, out_fn=None): """Generate raster mask for exposed bare ground from global bareground data """ print("Loading bareground") b = bareground_ds.GetRasterBand(1) l = b.ReadAsArray() print("Masking pixels with <%0.1f%% bare ground" % baregro...
[ "def", "get_bareground_mask", "(", "bareground_ds", ",", "bareground_thresh", "=", "60", ",", "out_fn", "=", "None", ")", ":", "print", "(", "\"Loading bareground\"", ")", "b", "=", "bareground_ds", ".", "GetRasterBand", "(", "1", ")", "l", "=", "b", ".", ...
Generate raster mask for exposed bare ground from global bareground data
[ "Generate", "raster", "mask", "for", "exposed", "bare", "ground", "from", "global", "bareground", "data" ]
abd6be75d326b35f52826ee30dff01f9e86b4b52
https://github.com/dshean/demcoreg/blob/abd6be75d326b35f52826ee30dff01f9e86b4b52/demcoreg/dem_mask.py#L143-L158
train
dshean/demcoreg
demcoreg/dem_mask.py
get_snodas_ds
def get_snodas_ds(dem_dt, code=1036): """Function to fetch and process SNODAS snow depth products for input datetime http://nsidc.org/data/docs/noaa/g02158_snodas_snow_cover_model/index.html Product codes: 1036 is snow depth 1034 is SWE filename format: us_ssmv11036tS__T0001TTNATS2015042205HP...
python
def get_snodas_ds(dem_dt, code=1036): """Function to fetch and process SNODAS snow depth products for input datetime http://nsidc.org/data/docs/noaa/g02158_snodas_snow_cover_model/index.html Product codes: 1036 is snow depth 1034 is SWE filename format: us_ssmv11036tS__T0001TTNATS2015042205HP...
[ "def", "get_snodas_ds", "(", "dem_dt", ",", "code", "=", "1036", ")", ":", "import", "tarfile", "import", "gzip", "snodas_ds", "=", "None", "snodas_url_str", "=", "None", "outdir", "=", "os", ".", "path", ".", "join", "(", "datadir", ",", "'snodas'", ")"...
Function to fetch and process SNODAS snow depth products for input datetime http://nsidc.org/data/docs/noaa/g02158_snodas_snow_cover_model/index.html Product codes: 1036 is snow depth 1034 is SWE filename format: us_ssmv11036tS__T0001TTNATS2015042205HP001.Hdr
[ "Function", "to", "fetch", "and", "process", "SNODAS", "snow", "depth", "products", "for", "input", "datetime" ]
abd6be75d326b35f52826ee30dff01f9e86b4b52
https://github.com/dshean/demcoreg/blob/abd6be75d326b35f52826ee30dff01f9e86b4b52/demcoreg/dem_mask.py#L160-L228
train
dshean/demcoreg
demcoreg/dem_mask.py
get_modis_tile_list
def get_modis_tile_list(ds): """Helper function to identify MODIS tiles that intersect input geometry modis_gird.py contains dictionary of tile boundaries (tile name and WKT polygon ring from bbox) See: https://modis-land.gsfc.nasa.gov/MODLAND_grid.html """ from demcoreg import modis_grid modi...
python
def get_modis_tile_list(ds): """Helper function to identify MODIS tiles that intersect input geometry modis_gird.py contains dictionary of tile boundaries (tile name and WKT polygon ring from bbox) See: https://modis-land.gsfc.nasa.gov/MODLAND_grid.html """ from demcoreg import modis_grid modi...
[ "def", "get_modis_tile_list", "(", "ds", ")", ":", "from", "demcoreg", "import", "modis_grid", "modis_dict", "=", "{", "}", "for", "key", "in", "modis_grid", ".", "modis_dict", ":", "modis_dict", "[", "key", "]", "=", "ogr", ".", "CreateGeometryFromWkt", "("...
Helper function to identify MODIS tiles that intersect input geometry modis_gird.py contains dictionary of tile boundaries (tile name and WKT polygon ring from bbox) See: https://modis-land.gsfc.nasa.gov/MODLAND_grid.html
[ "Helper", "function", "to", "identify", "MODIS", "tiles", "that", "intersect", "input", "geometry" ]
abd6be75d326b35f52826ee30dff01f9e86b4b52
https://github.com/dshean/demcoreg/blob/abd6be75d326b35f52826ee30dff01f9e86b4b52/demcoreg/dem_mask.py#L230-L249
train
dshean/demcoreg
demcoreg/dem_mask.py
get_modscag_fn_list
def get_modscag_fn_list(dem_dt, tile_list=('h08v04', 'h09v04', 'h10v04', 'h08v05', 'h09v05'), pad_days=7): """Function to fetch and process MODSCAG fractional snow cover products for input datetime Products are tiled in MODIS sinusoidal projection example url: https://snow-data.jpl.nasa.gov/modscag-histor...
python
def get_modscag_fn_list(dem_dt, tile_list=('h08v04', 'h09v04', 'h10v04', 'h08v05', 'h09v05'), pad_days=7): """Function to fetch and process MODSCAG fractional snow cover products for input datetime Products are tiled in MODIS sinusoidal projection example url: https://snow-data.jpl.nasa.gov/modscag-histor...
[ "def", "get_modscag_fn_list", "(", "dem_dt", ",", "tile_list", "=", "(", "'h08v04'", ",", "'h09v04'", ",", "'h10v04'", ",", "'h08v05'", ",", "'h09v05'", ")", ",", "pad_days", "=", "7", ")", ":", "import", "re", "import", "requests", "from", "bs4", "import"...
Function to fetch and process MODSCAG fractional snow cover products for input datetime Products are tiled in MODIS sinusoidal projection example url: https://snow-data.jpl.nasa.gov/modscag-historic/2015/001/MOD09GA.A2015001.h07v03.005.2015006001833.snow_fraction.tif
[ "Function", "to", "fetch", "and", "process", "MODSCAG", "fractional", "snow", "cover", "products", "for", "input", "datetime" ]
abd6be75d326b35f52826ee30dff01f9e86b4b52
https://github.com/dshean/demcoreg/blob/abd6be75d326b35f52826ee30dff01f9e86b4b52/demcoreg/dem_mask.py#L251-L331
train
dshean/demcoreg
demcoreg/dem_mask.py
proc_modscag
def proc_modscag(fn_list, extent=None, t_srs=None): """Process the MODSCAG products for full date range, create composites and reproject """ #Use cubic spline here for improve upsampling ds_list = warplib.memwarp_multi_fn(fn_list, res='min', extent=extent, t_srs=t_srs, r='cubicspline') stack_fn = o...
python
def proc_modscag(fn_list, extent=None, t_srs=None): """Process the MODSCAG products for full date range, create composites and reproject """ #Use cubic spline here for improve upsampling ds_list = warplib.memwarp_multi_fn(fn_list, res='min', extent=extent, t_srs=t_srs, r='cubicspline') stack_fn = o...
[ "def", "proc_modscag", "(", "fn_list", ",", "extent", "=", "None", ",", "t_srs", "=", "None", ")", ":", "ds_list", "=", "warplib", ".", "memwarp_multi_fn", "(", "fn_list", ",", "res", "=", "'min'", ",", "extent", "=", "extent", ",", "t_srs", "=", "t_sr...
Process the MODSCAG products for full date range, create composites and reproject
[ "Process", "the", "MODSCAG", "products", "for", "full", "date", "range", "create", "composites", "and", "reproject" ]
abd6be75d326b35f52826ee30dff01f9e86b4b52
https://github.com/dshean/demcoreg/blob/abd6be75d326b35f52826ee30dff01f9e86b4b52/demcoreg/dem_mask.py#L333-L362
train
iotile/coretools
iotilebuild/iotile/build/tilebus/descriptor.py
TBDescriptor._value_length
def _value_length(self, value, t): """Given an integer or list of them, convert it to an array of bytes.""" if isinstance(value, int): fmt = '<%s' % (type_codes[t]) output = struct.pack(fmt, value) return len(output) elif isinstance(value, str): r...
python
def _value_length(self, value, t): """Given an integer or list of them, convert it to an array of bytes.""" if isinstance(value, int): fmt = '<%s' % (type_codes[t]) output = struct.pack(fmt, value) return len(output) elif isinstance(value, str): r...
[ "def", "_value_length", "(", "self", ",", "value", ",", "t", ")", ":", "if", "isinstance", "(", "value", ",", "int", ")", ":", "fmt", "=", "'<%s'", "%", "(", "type_codes", "[", "t", "]", ")", "output", "=", "struct", ".", "pack", "(", "fmt", ",",...
Given an integer or list of them, convert it to an array of bytes.
[ "Given", "an", "integer", "or", "list", "of", "them", "convert", "it", "to", "an", "array", "of", "bytes", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/tilebus/descriptor.py#L152-L166
train
iotile/coretools
iotilebuild/iotile/build/tilebus/descriptor.py
TBDescriptor._parse_line
def _parse_line(self, line_no, line): """Parse a line in a TileBus file Args: line_no (int): The line number for printing useful error messages line (string): The line that we are trying to parse """ try: matched = statement.parseString(line) ...
python
def _parse_line(self, line_no, line): """Parse a line in a TileBus file Args: line_no (int): The line number for printing useful error messages line (string): The line that we are trying to parse """ try: matched = statement.parseString(line) ...
[ "def", "_parse_line", "(", "self", ",", "line_no", ",", "line", ")", ":", "try", ":", "matched", "=", "statement", ".", "parseString", "(", "line", ")", "except", "ParseException", "as", "exc", ":", "raise", "DataError", "(", "\"Error parsing line in TileBus f...
Parse a line in a TileBus file Args: line_no (int): The line number for printing useful error messages line (string): The line that we are trying to parse
[ "Parse", "a", "line", "in", "a", "TileBus", "file" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/tilebus/descriptor.py#L213-L233
train
iotile/coretools
iotilebuild/iotile/build/tilebus/descriptor.py
TBDescriptor._validate_information
def _validate_information(self): """Validate that all information has been filled in""" needed_variables = ["ModuleName", "ModuleVersion", "APIVersion"] for var in needed_variables: if var not in self.variables: raise DataError("Needed variable was not defined in mi...
python
def _validate_information(self): """Validate that all information has been filled in""" needed_variables = ["ModuleName", "ModuleVersion", "APIVersion"] for var in needed_variables: if var not in self.variables: raise DataError("Needed variable was not defined in mi...
[ "def", "_validate_information", "(", "self", ")", ":", "needed_variables", "=", "[", "\"ModuleName\"", ",", "\"ModuleVersion\"", ",", "\"APIVersion\"", "]", "for", "var", "in", "needed_variables", ":", "if", "var", "not", "in", "self", ".", "variables", ":", "...
Validate that all information has been filled in
[ "Validate", "that", "all", "information", "has", "been", "filled", "in" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/tilebus/descriptor.py#L235-L260
train
iotile/coretools
iotilebuild/iotile/build/tilebus/descriptor.py
TBDescriptor.get_block
def get_block(self, config_only=False): """Create a TileBus Block based on the information in this descriptor""" mib = TBBlock() for cid, config in self.configs.items(): mib.add_config(cid, config) if not config_only: for key, val in self.commands.items(): ...
python
def get_block(self, config_only=False): """Create a TileBus Block based on the information in this descriptor""" mib = TBBlock() for cid, config in self.configs.items(): mib.add_config(cid, config) if not config_only: for key, val in self.commands.items(): ...
[ "def", "get_block", "(", "self", ",", "config_only", "=", "False", ")", ":", "mib", "=", "TBBlock", "(", ")", "for", "cid", ",", "config", "in", "self", ".", "configs", ".", "items", "(", ")", ":", "mib", ".", "add_config", "(", "cid", ",", "config...
Create a TileBus Block based on the information in this descriptor
[ "Create", "a", "TileBus", "Block", "based", "on", "the", "information", "in", "this", "descriptor" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/tilebus/descriptor.py#L286-L305
train
iotile/coretools
iotilegateway/iotilegateway/device.py
AggregatingDeviceAdapter.add_adapter
def add_adapter(self, adapter): """Add a device adapter to this aggregating adapter.""" if self._started: raise InternalError("New adapters cannot be added after start() is called") if isinstance(adapter, DeviceAdapter): self._logger.warning("Wrapping legacy device adap...
python
def add_adapter(self, adapter): """Add a device adapter to this aggregating adapter.""" if self._started: raise InternalError("New adapters cannot be added after start() is called") if isinstance(adapter, DeviceAdapter): self._logger.warning("Wrapping legacy device adap...
[ "def", "add_adapter", "(", "self", ",", "adapter", ")", ":", "if", "self", ".", "_started", ":", "raise", "InternalError", "(", "\"New adapters cannot be added after start() is called\"", ")", "if", "isinstance", "(", "adapter", ",", "DeviceAdapter", ")", ":", "se...
Add a device adapter to this aggregating adapter.
[ "Add", "a", "device", "adapter", "to", "this", "aggregating", "adapter", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/device.py#L78-L95
train
iotile/coretools
iotilegateway/iotilegateway/device.py
AggregatingDeviceAdapter.get_config
def get_config(self, name, default=_MISSING): """Get a configuration setting from this DeviceAdapter. See :meth:`AbstractDeviceAdapter.get_config`. """ val = self._config.get(name, default) if val is _MISSING: raise ArgumentError("DeviceAdapter config {} did not exi...
python
def get_config(self, name, default=_MISSING): """Get a configuration setting from this DeviceAdapter. See :meth:`AbstractDeviceAdapter.get_config`. """ val = self._config.get(name, default) if val is _MISSING: raise ArgumentError("DeviceAdapter config {} did not exi...
[ "def", "get_config", "(", "self", ",", "name", ",", "default", "=", "_MISSING", ")", ":", "val", "=", "self", ".", "_config", ".", "get", "(", "name", ",", "default", ")", "if", "val", "is", "_MISSING", ":", "raise", "ArgumentError", "(", "\"DeviceAdap...
Get a configuration setting from this DeviceAdapter. See :meth:`AbstractDeviceAdapter.get_config`.
[ "Get", "a", "configuration", "setting", "from", "this", "DeviceAdapter", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/device.py#L110-L120
train
iotile/coretools
iotilegateway/iotilegateway/device.py
AggregatingDeviceAdapter.start
async def start(self): """Start all adapters managed by this device adapter. If there is an error starting one or more adapters, this method will stop any adapters that we successfully started and raise an exception. """ successful = 0 try: for adapter in s...
python
async def start(self): """Start all adapters managed by this device adapter. If there is an error starting one or more adapters, this method will stop any adapters that we successfully started and raise an exception. """ successful = 0 try: for adapter in s...
[ "async", "def", "start", "(", "self", ")", ":", "successful", "=", "0", "try", ":", "for", "adapter", "in", "self", ".", "adapters", ":", "await", "adapter", ".", "start", "(", ")", "successful", "+=", "1", "self", ".", "_started", "=", "True", "exce...
Start all adapters managed by this device adapter. If there is an error starting one or more adapters, this method will stop any adapters that we successfully started and raise an exception.
[ "Start", "all", "adapters", "managed", "by", "this", "device", "adapter", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/device.py#L141-L160
train
iotile/coretools
iotilegateway/iotilegateway/device.py
AggregatingDeviceAdapter.visible_devices
def visible_devices(self): """Unify all visible devices across all connected adapters Returns: dict: A dictionary mapping UUIDs to device information dictionaries """ devs = {} for device_id, adapters in self._devices.items(): dev = None max...
python
def visible_devices(self): """Unify all visible devices across all connected adapters Returns: dict: A dictionary mapping UUIDs to device information dictionaries """ devs = {} for device_id, adapters in self._devices.items(): dev = None max...
[ "def", "visible_devices", "(", "self", ")", ":", "devs", "=", "{", "}", "for", "device_id", ",", "adapters", "in", "self", ".", "_devices", ".", "items", "(", ")", ":", "dev", "=", "None", "max_signal", "=", "None", "best_adapter", "=", "None", "for", ...
Unify all visible devices across all connected adapters Returns: dict: A dictionary mapping UUIDs to device information dictionaries
[ "Unify", "all", "visible", "devices", "across", "all", "connected", "adapters" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/device.py#L168-L212
train
iotile/coretools
iotilegateway/iotilegateway/device.py
AggregatingDeviceAdapter.probe
async def probe(self): """Probe for devices. This method will probe all adapters that can probe and will send a notification for all devices that we have seen from all adapters. See :meth:`AbstractDeviceAdapter.probe`. """ for adapter in self.adapters: if a...
python
async def probe(self): """Probe for devices. This method will probe all adapters that can probe and will send a notification for all devices that we have seen from all adapters. See :meth:`AbstractDeviceAdapter.probe`. """ for adapter in self.adapters: if a...
[ "async", "def", "probe", "(", "self", ")", ":", "for", "adapter", "in", "self", ".", "adapters", ":", "if", "adapter", ".", "get_config", "(", "'probe_supported'", ",", "False", ")", ":", "await", "adapter", ".", "probe", "(", ")" ]
Probe for devices. This method will probe all adapters that can probe and will send a notification for all devices that we have seen from all adapters. See :meth:`AbstractDeviceAdapter.probe`.
[ "Probe", "for", "devices", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/device.py#L275-L286
train
iotile/coretools
iotilegateway/iotilegateway/device.py
AggregatingDeviceAdapter.send_script
async def send_script(self, conn_id, data): """Send a script to a device. See :meth:`AbstractDeviceAdapter.send_script`. """ adapter_id = self._get_property(conn_id, 'adapter') return await self.adapters[adapter_id].send_script(conn_id, data)
python
async def send_script(self, conn_id, data): """Send a script to a device. See :meth:`AbstractDeviceAdapter.send_script`. """ adapter_id = self._get_property(conn_id, 'adapter') return await self.adapters[adapter_id].send_script(conn_id, data)
[ "async", "def", "send_script", "(", "self", ",", "conn_id", ",", "data", ")", ":", "adapter_id", "=", "self", ".", "_get_property", "(", "conn_id", ",", "'adapter'", ")", "return", "await", "self", ".", "adapters", "[", "adapter_id", "]", ".", "send_script...
Send a script to a device. See :meth:`AbstractDeviceAdapter.send_script`.
[ "Send", "a", "script", "to", "a", "device", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/device.py#L306-L313
train
iotile/coretools
iotilegateway/iotilegateway/device.py
AggregatingDeviceAdapter.handle_adapter_event
async def handle_adapter_event(self, adapter_id, conn_string, conn_id, name, event): """Handle an event received from an adapter.""" if name == 'device_seen': self._track_device_seen(adapter_id, conn_string, event) event = self._translate_device_seen(adapter_id, conn_string, eve...
python
async def handle_adapter_event(self, adapter_id, conn_string, conn_id, name, event): """Handle an event received from an adapter.""" if name == 'device_seen': self._track_device_seen(adapter_id, conn_string, event) event = self._translate_device_seen(adapter_id, conn_string, eve...
[ "async", "def", "handle_adapter_event", "(", "self", ",", "adapter_id", ",", "conn_string", ",", "conn_id", ",", "name", ",", "event", ")", ":", "if", "name", "==", "'device_seen'", ":", "self", ".", "_track_device_seen", "(", "adapter_id", ",", "conn_string",...
Handle an event received from an adapter.
[ "Handle", "an", "event", "received", "from", "an", "adapter", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/device.py#L315-L328
train
iotile/coretools
iotilegateway/iotilegateway/device.py
AggregatingDeviceAdapter._device_expiry_callback
def _device_expiry_callback(self): """Periodic callback to remove expired devices from visible_devices.""" expired = 0 for adapters in self._devices.values(): to_remove = [] now = monotonic() for adapter_id, dev in adapters.items(): if 'expir...
python
def _device_expiry_callback(self): """Periodic callback to remove expired devices from visible_devices.""" expired = 0 for adapters in self._devices.values(): to_remove = [] now = monotonic() for adapter_id, dev in adapters.items(): if 'expir...
[ "def", "_device_expiry_callback", "(", "self", ")", ":", "expired", "=", "0", "for", "adapters", "in", "self", ".", "_devices", ".", "values", "(", ")", ":", "to_remove", "=", "[", "]", "now", "=", "monotonic", "(", ")", "for", "adapter_id", ",", "dev"...
Periodic callback to remove expired devices from visible_devices.
[ "Periodic", "callback", "to", "remove", "expired", "devices", "from", "visible_devices", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/device.py#L361-L385
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Variables/PathVariable.py
_PathVariableClass.PathIsDir
def PathIsDir(self, key, val, env): """Validator to check if Path is a directory.""" if not os.path.isdir(val): if os.path.isfile(val): m = 'Directory path for option %s is a file: %s' else: m = 'Directory path for option %s does not exist: %s' ...
python
def PathIsDir(self, key, val, env): """Validator to check if Path is a directory.""" if not os.path.isdir(val): if os.path.isfile(val): m = 'Directory path for option %s is a file: %s' else: m = 'Directory path for option %s does not exist: %s' ...
[ "def", "PathIsDir", "(", "self", ",", "key", ",", "val", ",", "env", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "val", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "val", ")", ":", "m", "=", "'Directory path for option...
Validator to check if Path is a directory.
[ "Validator", "to", "check", "if", "Path", "is", "a", "directory", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Variables/PathVariable.py#L85-L92
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Variables/PathVariable.py
_PathVariableClass.PathExists
def PathExists(self, key, val, env): """Validator to check if Path exists""" if not os.path.exists(val): m = 'Path for option %s does not exist: %s' raise SCons.Errors.UserError(m % (key, val))
python
def PathExists(self, key, val, env): """Validator to check if Path exists""" if not os.path.exists(val): m = 'Path for option %s does not exist: %s' raise SCons.Errors.UserError(m % (key, val))
[ "def", "PathExists", "(", "self", ",", "key", ",", "val", ",", "env", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "val", ")", ":", "m", "=", "'Path for option %s does not exist: %s'", "raise", "SCons", ".", "Errors", ".", "UserError", ...
Validator to check if Path exists
[ "Validator", "to", "check", "if", "Path", "exists" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Variables/PathVariable.py#L112-L116
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem._reset_vector
async def _reset_vector(self): """Background task to initialize this system in the event loop.""" self._logger.debug("sensor_graph subsystem task starting") # If there is a persistent sgf loaded, send reset information. self.initialized.set() while True: stream, r...
python
async def _reset_vector(self): """Background task to initialize this system in the event loop.""" self._logger.debug("sensor_graph subsystem task starting") # If there is a persistent sgf loaded, send reset information. self.initialized.set() while True: stream, r...
[ "async", "def", "_reset_vector", "(", "self", ")", ":", "self", ".", "_logger", ".", "debug", "(", "\"sensor_graph subsystem task starting\"", ")", "self", ".", "initialized", ".", "set", "(", ")", "while", "True", ":", "stream", ",", "reading", "=", "await"...
Background task to initialize this system in the event loop.
[ "Background", "task", "to", "initialize", "this", "system", "in", "the", "event", "loop", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L140-L158
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem.process_input
def process_input(self, encoded_stream, value): """Process or drop a graph input. This method asynchronously queued an item to be processed by the sensorgraph worker task in _reset_vector. It must be called from inside the emulation loop and returns immediately before the input is ...
python
def process_input(self, encoded_stream, value): """Process or drop a graph input. This method asynchronously queued an item to be processed by the sensorgraph worker task in _reset_vector. It must be called from inside the emulation loop and returns immediately before the input is ...
[ "def", "process_input", "(", "self", ",", "encoded_stream", ",", "value", ")", ":", "if", "not", "self", ".", "enabled", ":", "return", "if", "isinstance", "(", "encoded_stream", ",", "str", ")", ":", "stream", "=", "DataStream", ".", "FromString", "(", ...
Process or drop a graph input. This method asynchronously queued an item to be processed by the sensorgraph worker task in _reset_vector. It must be called from inside the emulation loop and returns immediately before the input is processed.
[ "Process", "or", "drop", "a", "graph", "input", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L196-L219
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem._seek_streamer
def _seek_streamer(self, index, value): """Complex logic for actually seeking a streamer to a reading_id. This routine hides all of the gnarly logic of the various edge cases. In particular, the behavior depends on whether the reading id is found, and if it is found, whether it belongs ...
python
def _seek_streamer(self, index, value): """Complex logic for actually seeking a streamer to a reading_id. This routine hides all of the gnarly logic of the various edge cases. In particular, the behavior depends on whether the reading id is found, and if it is found, whether it belongs ...
[ "def", "_seek_streamer", "(", "self", ",", "index", ",", "value", ")", ":", "highest_id", "=", "self", ".", "_rsl", ".", "highest_stored_id", "(", ")", "streamer", "=", "self", ".", "graph", ".", "streamers", "[", "index", "]", "if", "not", "streamer", ...
Complex logic for actually seeking a streamer to a reading_id. This routine hides all of the gnarly logic of the various edge cases. In particular, the behavior depends on whether the reading id is found, and if it is found, whether it belongs to the indicated streamer or not. If not, ...
[ "Complex", "logic", "for", "actually", "seeking", "a", "streamer", "to", "a", "reading_id", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L221-L270
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem.acknowledge_streamer
def acknowledge_streamer(self, index, ack, force): """Acknowledge a streamer value as received from the remote side.""" if index >= len(self.graph.streamers): return _pack_sgerror(SensorGraphError.STREAMER_NOT_ALLOCATED) old_ack = self.streamer_acks.get(index, 0) if ack !=...
python
def acknowledge_streamer(self, index, ack, force): """Acknowledge a streamer value as received from the remote side.""" if index >= len(self.graph.streamers): return _pack_sgerror(SensorGraphError.STREAMER_NOT_ALLOCATED) old_ack = self.streamer_acks.get(index, 0) if ack !=...
[ "def", "acknowledge_streamer", "(", "self", ",", "index", ",", "ack", ",", "force", ")", ":", "if", "index", ">=", "len", "(", "self", ".", "graph", ".", "streamers", ")", ":", "return", "_pack_sgerror", "(", "SensorGraphError", ".", "STREAMER_NOT_ALLOCATED"...
Acknowledge a streamer value as received from the remote side.
[ "Acknowledge", "a", "streamer", "value", "as", "received", "from", "the", "remote", "side", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L272-L287
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem._handle_streamer_finished
def _handle_streamer_finished(self, index, succeeded, highest_ack): """Callback when a streamer finishes processing.""" self._logger.debug("Rolling back streamer %d after streaming, highest ack from streaming subsystem was %d", index, highest_ack) self.acknowledge_streamer(index, highest_ack, F...
python
def _handle_streamer_finished(self, index, succeeded, highest_ack): """Callback when a streamer finishes processing.""" self._logger.debug("Rolling back streamer %d after streaming, highest ack from streaming subsystem was %d", index, highest_ack) self.acknowledge_streamer(index, highest_ack, F...
[ "def", "_handle_streamer_finished", "(", "self", ",", "index", ",", "succeeded", ",", "highest_ack", ")", ":", "self", ".", "_logger", ".", "debug", "(", "\"Rolling back streamer %d after streaming, highest ack from streaming subsystem was %d\"", ",", "index", ",", "highe...
Callback when a streamer finishes processing.
[ "Callback", "when", "a", "streamer", "finishes", "processing", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L289-L293
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem.process_streamers
def process_streamers(self): """Check if any streamers should be handed to the stream manager.""" # Check for any triggered streamers and pass them to stream manager in_progress = self._stream_manager.in_progress() triggered = self.graph.check_streamers(blacklist=in_progress) f...
python
def process_streamers(self): """Check if any streamers should be handed to the stream manager.""" # Check for any triggered streamers and pass them to stream manager in_progress = self._stream_manager.in_progress() triggered = self.graph.check_streamers(blacklist=in_progress) f...
[ "def", "process_streamers", "(", "self", ")", ":", "in_progress", "=", "self", ".", "_stream_manager", ".", "in_progress", "(", ")", "triggered", "=", "self", ".", "graph", ".", "check_streamers", "(", "blacklist", "=", "in_progress", ")", "for", "streamer", ...
Check if any streamers should be handed to the stream manager.
[ "Check", "if", "any", "streamers", "should", "be", "handed", "to", "the", "stream", "manager", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L295-L303
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem.trigger_streamer
def trigger_streamer(self, index): """Pass a streamer to the stream manager if it has data.""" self._logger.debug("trigger_streamer RPC called on streamer %d", index) if index >= len(self.graph.streamers): return _pack_sgerror(SensorGraphError.STREAMER_NOT_ALLOCATED) if in...
python
def trigger_streamer(self, index): """Pass a streamer to the stream manager if it has data.""" self._logger.debug("trigger_streamer RPC called on streamer %d", index) if index >= len(self.graph.streamers): return _pack_sgerror(SensorGraphError.STREAMER_NOT_ALLOCATED) if in...
[ "def", "trigger_streamer", "(", "self", ",", "index", ")", ":", "self", ".", "_logger", ".", "debug", "(", "\"trigger_streamer RPC called on streamer %d\"", ",", "index", ")", "if", "index", ">=", "len", "(", "self", ".", "graph", ".", "streamers", ")", ":",...
Pass a streamer to the stream manager if it has data.
[ "Pass", "a", "streamer", "to", "the", "stream", "manager", "if", "it", "has", "data", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L305-L325
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem.persist
def persist(self): """Trigger saving the current sensorgraph to persistent storage.""" self.persisted_nodes = self.graph.dump_nodes() self.persisted_streamers = self.graph.dump_streamers() self.persisted_exists = True self.persisted_constants = self._sensor_log.dump_constants()
python
def persist(self): """Trigger saving the current sensorgraph to persistent storage.""" self.persisted_nodes = self.graph.dump_nodes() self.persisted_streamers = self.graph.dump_streamers() self.persisted_exists = True self.persisted_constants = self._sensor_log.dump_constants()
[ "def", "persist", "(", "self", ")", ":", "self", ".", "persisted_nodes", "=", "self", ".", "graph", ".", "dump_nodes", "(", ")", "self", ".", "persisted_streamers", "=", "self", ".", "graph", ".", "dump_streamers", "(", ")", "self", ".", "persisted_exists"...
Trigger saving the current sensorgraph to persistent storage.
[ "Trigger", "saving", "the", "current", "sensorgraph", "to", "persistent", "storage", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L332-L338
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem.reset
def reset(self): """Clear the sensorgraph from RAM and flash.""" self.persisted_exists = False self.persisted_nodes = [] self.persisted_streamers = [] self.persisted_constants = [] self.graph.clear() self.streamer_status = {}
python
def reset(self): """Clear the sensorgraph from RAM and flash.""" self.persisted_exists = False self.persisted_nodes = [] self.persisted_streamers = [] self.persisted_constants = [] self.graph.clear() self.streamer_status = {}
[ "def", "reset", "(", "self", ")", ":", "self", ".", "persisted_exists", "=", "False", "self", ".", "persisted_nodes", "=", "[", "]", "self", ".", "persisted_streamers", "=", "[", "]", "self", ".", "persisted_constants", "=", "[", "]", "self", ".", "graph...
Clear the sensorgraph from RAM and flash.
[ "Clear", "the", "sensorgraph", "from", "RAM", "and", "flash", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L340-L349
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem.add_node
def add_node(self, binary_descriptor): """Add a node to the sensor_graph using a binary node descriptor. Args: binary_descriptor (bytes): An encoded binary node descriptor. Returns: int: A packed error code. """ try: node_string = parse_bina...
python
def add_node(self, binary_descriptor): """Add a node to the sensor_graph using a binary node descriptor. Args: binary_descriptor (bytes): An encoded binary node descriptor. Returns: int: A packed error code. """ try: node_string = parse_bina...
[ "def", "add_node", "(", "self", ",", "binary_descriptor", ")", ":", "try", ":", "node_string", "=", "parse_binary_descriptor", "(", "binary_descriptor", ")", "except", ":", "self", ".", "_logger", ".", "exception", "(", "\"Error parsing binary node descriptor: %s\"", ...
Add a node to the sensor_graph using a binary node descriptor. Args: binary_descriptor (bytes): An encoded binary node descriptor. Returns: int: A packed error code.
[ "Add", "a", "node", "to", "the", "sensor_graph", "using", "a", "binary", "node", "descriptor", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L351-L376
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem.add_streamer
def add_streamer(self, binary_descriptor): """Add a streamer to the sensor_graph using a binary streamer descriptor. Args: binary_descriptor (bytes): An encoded binary streamer descriptor. Returns: int: A packed error code """ streamer = streamer_descri...
python
def add_streamer(self, binary_descriptor): """Add a streamer to the sensor_graph using a binary streamer descriptor. Args: binary_descriptor (bytes): An encoded binary streamer descriptor. Returns: int: A packed error code """ streamer = streamer_descri...
[ "def", "add_streamer", "(", "self", ",", "binary_descriptor", ")", ":", "streamer", "=", "streamer_descriptor", ".", "parse_binary_descriptor", "(", "binary_descriptor", ")", "try", ":", "self", ".", "graph", ".", "add_streamer", "(", "streamer", ")", "self", "....
Add a streamer to the sensor_graph using a binary streamer descriptor. Args: binary_descriptor (bytes): An encoded binary streamer descriptor. Returns: int: A packed error code
[ "Add", "a", "streamer", "to", "the", "sensor_graph", "using", "a", "binary", "streamer", "descriptor", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L378-L396
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem.inspect_streamer
def inspect_streamer(self, index): """Inspect the streamer at the given index.""" if index >= len(self.graph.streamers): return [_pack_sgerror(SensorGraphError.STREAMER_NOT_ALLOCATED), b'\0'*14] return [Error.NO_ERROR, streamer_descriptor.create_binary_descriptor(self.graph.streame...
python
def inspect_streamer(self, index): """Inspect the streamer at the given index.""" if index >= len(self.graph.streamers): return [_pack_sgerror(SensorGraphError.STREAMER_NOT_ALLOCATED), b'\0'*14] return [Error.NO_ERROR, streamer_descriptor.create_binary_descriptor(self.graph.streame...
[ "def", "inspect_streamer", "(", "self", ",", "index", ")", ":", "if", "index", ">=", "len", "(", "self", ".", "graph", ".", "streamers", ")", ":", "return", "[", "_pack_sgerror", "(", "SensorGraphError", ".", "STREAMER_NOT_ALLOCATED", ")", ",", "b'\\0'", "...
Inspect the streamer at the given index.
[ "Inspect", "the", "streamer", "at", "the", "given", "index", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L398-L404
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem.inspect_node
def inspect_node(self, index): """Inspect the graph node at the given index.""" if index >= len(self.graph.nodes): raise RPCErrorCode(6) #FIXME: use actual error code here for UNKNOWN_ERROR status return create_binary_descriptor(str(self.graph.nodes[index]))
python
def inspect_node(self, index): """Inspect the graph node at the given index.""" if index >= len(self.graph.nodes): raise RPCErrorCode(6) #FIXME: use actual error code here for UNKNOWN_ERROR status return create_binary_descriptor(str(self.graph.nodes[index]))
[ "def", "inspect_node", "(", "self", ",", "index", ")", ":", "if", "index", ">=", "len", "(", "self", ".", "graph", ".", "nodes", ")", ":", "raise", "RPCErrorCode", "(", "6", ")", "return", "create_binary_descriptor", "(", "str", "(", "self", ".", "grap...
Inspect the graph node at the given index.
[ "Inspect", "the", "graph", "node", "at", "the", "given", "index", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L406-L412
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphSubsystem.query_streamer
def query_streamer(self, index): """Query the status of the streamer at the given index.""" if index >= len(self.graph.streamers): return None info = self.streamer_status[index] highest_ack = self.streamer_acks.get(index, 0) return [info.last_attempt_time, info.las...
python
def query_streamer(self, index): """Query the status of the streamer at the given index.""" if index >= len(self.graph.streamers): return None info = self.streamer_status[index] highest_ack = self.streamer_acks.get(index, 0) return [info.last_attempt_time, info.las...
[ "def", "query_streamer", "(", "self", ",", "index", ")", ":", "if", "index", ">=", "len", "(", "self", ".", "graph", ".", "streamers", ")", ":", "return", "None", "info", "=", "self", ".", "streamer_status", "[", "index", "]", "highest_ack", "=", "self...
Query the status of the streamer at the given index.
[ "Query", "the", "status", "of", "the", "streamer", "at", "the", "given", "index", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L414-L423
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphMixin.sg_graph_input
def sg_graph_input(self, value, stream_id): """"Present a graph input to the sensor_graph subsystem.""" self.sensor_graph.process_input(stream_id, value) return [Error.NO_ERROR]
python
def sg_graph_input(self, value, stream_id): """"Present a graph input to the sensor_graph subsystem.""" self.sensor_graph.process_input(stream_id, value) return [Error.NO_ERROR]
[ "def", "sg_graph_input", "(", "self", ",", "value", ",", "stream_id", ")", ":", "self", ".", "sensor_graph", ".", "process_input", "(", "stream_id", ",", "value", ")", "return", "[", "Error", ".", "NO_ERROR", "]" ]
Present a graph input to the sensor_graph subsystem.
[ "Present", "a", "graph", "input", "to", "the", "sensor_graph", "subsystem", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L461-L465
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphMixin.sg_add_streamer
def sg_add_streamer(self, desc): """Add a graph streamer using a binary descriptor.""" if len(desc) == 13: desc += b'\0' err = self.sensor_graph.add_streamer(desc) return [err]
python
def sg_add_streamer(self, desc): """Add a graph streamer using a binary descriptor.""" if len(desc) == 13: desc += b'\0' err = self.sensor_graph.add_streamer(desc) return [err]
[ "def", "sg_add_streamer", "(", "self", ",", "desc", ")", ":", "if", "len", "(", "desc", ")", "==", "13", ":", "desc", "+=", "b'\\0'", "err", "=", "self", ".", "sensor_graph", ".", "add_streamer", "(", "desc", ")", "return", "[", "err", "]" ]
Add a graph streamer using a binary descriptor.
[ "Add", "a", "graph", "streamer", "using", "a", "binary", "descriptor", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L488-L495
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphMixin.sg_seek_streamer
def sg_seek_streamer(self, index, force, value): """Ackowledge a streamer.""" force = bool(force) err = self.sensor_graph.acknowledge_streamer(index, value, force) return [err]
python
def sg_seek_streamer(self, index, force, value): """Ackowledge a streamer.""" force = bool(force) err = self.sensor_graph.acknowledge_streamer(index, value, force) return [err]
[ "def", "sg_seek_streamer", "(", "self", ",", "index", ",", "force", ",", "value", ")", ":", "force", "=", "bool", "(", "force", ")", "err", "=", "self", ".", "sensor_graph", ".", "acknowledge_streamer", "(", "index", ",", "value", ",", "force", ")", "r...
Ackowledge a streamer.
[ "Ackowledge", "a", "streamer", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L512-L517
train
iotile/coretools
iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py
SensorGraphMixin.sg_query_streamer
def sg_query_streamer(self, index): """Query the current status of a streamer.""" resp = self.sensor_graph.query_streamer(index) if resp is None: return [struct.pack("<L", _pack_sgerror(SensorGraphError.STREAMER_NOT_ALLOCATED))] return [struct.pack("<LLLLBBBx", *resp)]
python
def sg_query_streamer(self, index): """Query the current status of a streamer.""" resp = self.sensor_graph.query_streamer(index) if resp is None: return [struct.pack("<L", _pack_sgerror(SensorGraphError.STREAMER_NOT_ALLOCATED))] return [struct.pack("<LLLLBBBx", *resp)]
[ "def", "sg_query_streamer", "(", "self", ",", "index", ")", ":", "resp", "=", "self", ".", "sensor_graph", ".", "query_streamer", "(", "index", ")", "if", "resp", "is", "None", ":", "return", "[", "struct", ".", "pack", "(", "\"<L\"", ",", "_pack_sgerror...
Query the current status of a streamer.
[ "Query", "the", "current", "status", "of", "a", "streamer", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/sensor_graph.py#L520-L527
train
iotile/coretools
iotilecore/iotile/core/utilities/workqueue_thread.py
WorkQueueThread.dispatch
def dispatch(self, value, callback=None): """Dispatch an item to the workqueue and optionally wait. This is the only way to add work to the background work queue. Unless you also pass a callback object, this method will synchronously wait for the work to finish and return the result. If...
python
def dispatch(self, value, callback=None): """Dispatch an item to the workqueue and optionally wait. This is the only way to add work to the background work queue. Unless you also pass a callback object, this method will synchronously wait for the work to finish and return the result. If...
[ "def", "dispatch", "(", "self", ",", "value", ",", "callback", "=", "None", ")", ":", "done", "=", "None", "if", "callback", "is", "None", ":", "done", "=", "threading", ".", "Event", "(", ")", "shared_data", "=", "[", "None", ",", "None", "]", "de...
Dispatch an item to the workqueue and optionally wait. This is the only way to add work to the background work queue. Unless you also pass a callback object, this method will synchronously wait for the work to finish and return the result. If the work raises an exception, the exception ...
[ "Dispatch", "an", "item", "to", "the", "workqueue", "and", "optionally", "wait", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/workqueue_thread.py#L85-L142
train
iotile/coretools
iotilecore/iotile/core/utilities/workqueue_thread.py
WorkQueueThread.future_raise
def future_raise(self, tp, value=None, tb=None): """raise_ implementation from future.utils""" if value is not None and isinstance(tp, Exception): raise TypeError("instance exception may not have a separate value") if value is not None: exc = tp(value) else: ...
python
def future_raise(self, tp, value=None, tb=None): """raise_ implementation from future.utils""" if value is not None and isinstance(tp, Exception): raise TypeError("instance exception may not have a separate value") if value is not None: exc = tp(value) else: ...
[ "def", "future_raise", "(", "self", ",", "tp", ",", "value", "=", "None", ",", "tb", "=", "None", ")", ":", "if", "value", "is", "not", "None", "and", "isinstance", "(", "tp", ",", "Exception", ")", ":", "raise", "TypeError", "(", "\"instance exception...
raise_ implementation from future.utils
[ "raise_", "implementation", "from", "future", ".", "utils" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/workqueue_thread.py#L144-L154
train
iotile/coretools
iotilecore/iotile/core/utilities/workqueue_thread.py
WorkQueueThread.flush
def flush(self): """Synchronously wait until this work item is processed. This has the effect of waiting until all work items queued before this method has been called have finished. """ done = threading.Event() def _callback(): done.set() self.def...
python
def flush(self): """Synchronously wait until this work item is processed. This has the effect of waiting until all work items queued before this method has been called have finished. """ done = threading.Event() def _callback(): done.set() self.def...
[ "def", "flush", "(", "self", ")", ":", "done", "=", "threading", ".", "Event", "(", ")", "def", "_callback", "(", ")", ":", "done", ".", "set", "(", ")", "self", ".", "defer", "(", "_callback", ")", "done", ".", "wait", "(", ")" ]
Synchronously wait until this work item is processed. This has the effect of waiting until all work items queued before this method has been called have finished.
[ "Synchronously", "wait", "until", "this", "work", "item", "is", "processed", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/workqueue_thread.py#L156-L169
train
iotile/coretools
iotilecore/iotile/core/utilities/workqueue_thread.py
WorkQueueThread.direct_dispatch
def direct_dispatch(self, arg, callback): """Directly dispatch a work item. This method MUST only be called from inside of another work item and will synchronously invoke the work item as if it was passed to dispatch(). Calling this method from any other thread has undefined co...
python
def direct_dispatch(self, arg, callback): """Directly dispatch a work item. This method MUST only be called from inside of another work item and will synchronously invoke the work item as if it was passed to dispatch(). Calling this method from any other thread has undefined co...
[ "def", "direct_dispatch", "(", "self", ",", "arg", ",", "callback", ")", ":", "try", ":", "self", ".", "_current_callbacks", ".", "appendleft", "(", "callback", ")", "exc_info", "=", "None", "retval", "=", "None", "retval", "=", "self", ".", "_routine", ...
Directly dispatch a work item. This method MUST only be called from inside of another work item and will synchronously invoke the work item as if it was passed to dispatch(). Calling this method from any other thread has undefined consequences since it will be unsynchronized with respe...
[ "Directly", "dispatch", "a", "work", "item", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/workqueue_thread.py#L237-L262
train
iotile/coretools
iotilecore/iotile/core/utilities/workqueue_thread.py
WorkQueueThread.stop
def stop(self, timeout=None, force=False): """Stop the worker thread and synchronously wait for it to finish. Args: timeout (float): The maximum time to wait for the thread to stop before raising a TimeoutExpiredError. If force is True, TimeoutExpiredError i...
python
def stop(self, timeout=None, force=False): """Stop the worker thread and synchronously wait for it to finish. Args: timeout (float): The maximum time to wait for the thread to stop before raising a TimeoutExpiredError. If force is True, TimeoutExpiredError i...
[ "def", "stop", "(", "self", ",", "timeout", "=", "None", ",", "force", "=", "False", ")", ":", "self", ".", "signal_stop", "(", ")", "self", ".", "wait_stopped", "(", "timeout", ",", "force", ")" ]
Stop the worker thread and synchronously wait for it to finish. Args: timeout (float): The maximum time to wait for the thread to stop before raising a TimeoutExpiredError. If force is True, TimeoutExpiredError is not raised and the thread is just marked as a daemon...
[ "Stop", "the", "worker", "thread", "and", "synchronously", "wait", "for", "it", "to", "finish", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/workqueue_thread.py#L300-L314
train
iotile/coretools
iotilecore/iotile/core/utilities/workqueue_thread.py
WorkQueueThread.wait_stopped
def wait_stopped(self, timeout=None, force=False): """Wait for the thread to stop. You must have previously called signal_stop or this function will hang. Args: timeout (float): The maximum time to wait for the thread to stop before raising a TimeoutExpired...
python
def wait_stopped(self, timeout=None, force=False): """Wait for the thread to stop. You must have previously called signal_stop or this function will hang. Args: timeout (float): The maximum time to wait for the thread to stop before raising a TimeoutExpired...
[ "def", "wait_stopped", "(", "self", ",", "timeout", "=", "None", ",", "force", "=", "False", ")", ":", "self", ".", "join", "(", "timeout", ")", "if", "self", ".", "is_alive", "(", ")", "and", "force", "is", "False", ":", "raise", "TimeoutExpiredError"...
Wait for the thread to stop. You must have previously called signal_stop or this function will hang. Args: timeout (float): The maximum time to wait for the thread to stop before raising a TimeoutExpiredError. If force is True, TimeoutExpiredError ...
[ "Wait", "for", "the", "thread", "to", "stop", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/workqueue_thread.py#L325-L346
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/wix.py
generate
def generate(env): """Add Builders and construction variables for WiX to an Environment.""" if not exists(env): return env['WIXCANDLEFLAGS'] = ['-nologo'] env['WIXCANDLEINCLUDE'] = [] env['WIXCANDLECOM'] = '$WIXCANDLE $WIXCANDLEFLAGS -I $WIXCANDLEINCLUDE -o ${TARGET} ${SOURCE}' env['WIXL...
python
def generate(env): """Add Builders and construction variables for WiX to an Environment.""" if not exists(env): return env['WIXCANDLEFLAGS'] = ['-nologo'] env['WIXCANDLEINCLUDE'] = [] env['WIXCANDLECOM'] = '$WIXCANDLE $WIXCANDLEFLAGS -I $WIXCANDLEINCLUDE -o ${TARGET} ${SOURCE}' env['WIXL...
[ "def", "generate", "(", "env", ")", ":", "if", "not", "exists", "(", "env", ")", ":", "return", "env", "[", "'WIXCANDLEFLAGS'", "]", "=", "[", "'-nologo'", "]", "env", "[", "'WIXCANDLEINCLUDE'", "]", "=", "[", "]", "env", "[", "'WIXCANDLECOM'", "]", ...
Add Builders and construction variables for WiX to an Environment.
[ "Add", "Builders", "and", "construction", "variables", "for", "WiX", "to", "an", "Environment", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/wix.py#L39-L63
train
iotile/coretools
iotilesensorgraph/iotile/sg/sim/stimulus.py
SimulationStimulus.FromString
def FromString(cls, desc): """Create a new stimulus from a description string. The string must have the format: [time: ][system ]input X = Y where X and Y are integers. The time, if given must be a time_interval, which is an integer followed by a time unit such as seco...
python
def FromString(cls, desc): """Create a new stimulus from a description string. The string must have the format: [time: ][system ]input X = Y where X and Y are integers. The time, if given must be a time_interval, which is an integer followed by a time unit such as seco...
[ "def", "FromString", "(", "cls", ",", "desc", ")", ":", "if", "language", ".", "stream", "is", "None", ":", "language", ".", "get_language", "(", ")", "parse_exp", "=", "Optional", "(", "time_interval", "(", "'time'", ")", "-", "Literal", "(", "':'", "...
Create a new stimulus from a description string. The string must have the format: [time: ][system ]input X = Y where X and Y are integers. The time, if given must be a time_interval, which is an integer followed by a time unit such as second(s), minute(s), etc. Args: ...
[ "Create", "a", "new", "stimulus", "from", "a", "description", "string", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sim/stimulus.py#L27-L56
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py
ConnectionManager.get_connection_id
def get_connection_id(self, conn_or_int_id): """Get the connection id. Args: conn_or_int_id (int, string): The external integer connection id or and internal string connection id Returns: dict: The context data associated with that connection or None if ...
python
def get_connection_id(self, conn_or_int_id): """Get the connection id. Args: conn_or_int_id (int, string): The external integer connection id or and internal string connection id Returns: dict: The context data associated with that connection or None if ...
[ "def", "get_connection_id", "(", "self", ",", "conn_or_int_id", ")", ":", "key", "=", "conn_or_int_id", "if", "isinstance", "(", "key", ",", "str", ")", ":", "table", "=", "self", ".", "_int_connections", "elif", "isinstance", "(", "key", ",", "int", ")", ...
Get the connection id. Args: conn_or_int_id (int, string): The external integer connection id or and internal string connection id Returns: dict: The context data associated with that connection or None if it cannot be found. Raises: ...
[ "Get", "the", "connection", "id", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py#L174-L203
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py
ConnectionManager._get_connection
def _get_connection(self, conn_or_int_id): """Get the data for a connection by either conn_id or internal_id Args: conn_or_int_id (int, string): The external integer connection id or and internal string connection id Returns: dict: The context data assoc...
python
def _get_connection(self, conn_or_int_id): """Get the data for a connection by either conn_id or internal_id Args: conn_or_int_id (int, string): The external integer connection id or and internal string connection id Returns: dict: The context data assoc...
[ "def", "_get_connection", "(", "self", ",", "conn_or_int_id", ")", ":", "key", "=", "conn_or_int_id", "if", "isinstance", "(", "key", ",", "str", ")", ":", "table", "=", "self", ".", "_int_connections", "elif", "isinstance", "(", "key", ",", "int", ")", ...
Get the data for a connection by either conn_id or internal_id Args: conn_or_int_id (int, string): The external integer connection id or and internal string connection id Returns: dict: The context data associated with that connection or None if it cannot ...
[ "Get", "the", "data", "for", "a", "connection", "by", "either", "conn_id", "or", "internal_id" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py#L205-L234
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py
ConnectionManager._get_connection_state
def _get_connection_state(self, conn_or_int_id): """Get a connection's state by either conn_id or internal_id This routine must only be called from the internal worker thread. Args: conn_or_int_id (int, string): The external integer connection id or and internal str...
python
def _get_connection_state(self, conn_or_int_id): """Get a connection's state by either conn_id or internal_id This routine must only be called from the internal worker thread. Args: conn_or_int_id (int, string): The external integer connection id or and internal str...
[ "def", "_get_connection_state", "(", "self", ",", "conn_or_int_id", ")", ":", "key", "=", "conn_or_int_id", "if", "isinstance", "(", "key", ",", "str", ")", ":", "table", "=", "self", ".", "_int_connections", "elif", "isinstance", "(", "key", ",", "int", "...
Get a connection's state by either conn_id or internal_id This routine must only be called from the internal worker thread. Args: conn_or_int_id (int, string): The external integer connection id or and internal string connection id
[ "Get", "a", "connection", "s", "state", "by", "either", "conn_id", "or", "internal_id" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py#L236-L258
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py
ConnectionManager._check_timeouts
def _check_timeouts(self): """Check if any operations in progress need to be timed out Adds the corresponding finish action that fails the request due to a timeout. """ for conn_id, data in self._connections.items(): if 'timeout' in data and data['timeout'].expired:...
python
def _check_timeouts(self): """Check if any operations in progress need to be timed out Adds the corresponding finish action that fails the request due to a timeout. """ for conn_id, data in self._connections.items(): if 'timeout' in data and data['timeout'].expired:...
[ "def", "_check_timeouts", "(", "self", ")", ":", "for", "conn_id", ",", "data", "in", "self", ".", "_connections", ".", "items", "(", ")", ":", "if", "'timeout'", "in", "data", "and", "data", "[", "'timeout'", "]", ".", "expired", ":", "if", "data", ...
Check if any operations in progress need to be timed out Adds the corresponding finish action that fails the request due to a timeout.
[ "Check", "if", "any", "operations", "in", "progress", "need", "to", "be", "timed", "out" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py#L260-L277
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py
ConnectionManager.unexpected_disconnect
def unexpected_disconnect(self, conn_or_internal_id): """Notify that there was an unexpected disconnection of the device. Any in progress operations are canceled cleanly and the device is transitioned to a disconnected state. Args: conn_or_internal_id (string, int): Either ...
python
def unexpected_disconnect(self, conn_or_internal_id): """Notify that there was an unexpected disconnection of the device. Any in progress operations are canceled cleanly and the device is transitioned to a disconnected state. Args: conn_or_internal_id (string, int): Either ...
[ "def", "unexpected_disconnect", "(", "self", ",", "conn_or_internal_id", ")", ":", "data", "=", "{", "'id'", ":", "conn_or_internal_id", "}", "action", "=", "ConnectionAction", "(", "'force_disconnect'", ",", "data", ",", "sync", "=", "False", ")", "self", "."...
Notify that there was an unexpected disconnection of the device. Any in progress operations are canceled cleanly and the device is transitioned to a disconnected state. Args: conn_or_internal_id (string, int): Either an integer connection id or a string internal_id
[ "Notify", "that", "there", "was", "an", "unexpected", "disconnection", "of", "the", "device", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py#L393-L409
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py
ConnectionManager.finish_operation
def finish_operation(self, conn_or_internal_id, success, *args): """Finish an operation on a connection. Args: conn_or_internal_id (string, int): Either an integer connection id or a string internal_id success (bool): Whether the operation was successful ...
python
def finish_operation(self, conn_or_internal_id, success, *args): """Finish an operation on a connection. Args: conn_or_internal_id (string, int): Either an integer connection id or a string internal_id success (bool): Whether the operation was successful ...
[ "def", "finish_operation", "(", "self", ",", "conn_or_internal_id", ",", "success", ",", "*", "args", ")", ":", "data", "=", "{", "'id'", ":", "conn_or_internal_id", ",", "'success'", ":", "success", ",", "'callback_args'", ":", "args", "}", "action", "=", ...
Finish an operation on a connection. Args: conn_or_internal_id (string, int): Either an integer connection id or a string internal_id success (bool): Whether the operation was successful failure_reason (string): Optional reason why the operation failed ...
[ "Finish", "an", "operation", "on", "a", "connection", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py#L593-L611
train
iotile/coretools
transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py
ConnectionManager._finish_operation_action
def _finish_operation_action(self, action): """Finish an attempted operation. Args: action (ConnectionAction): the action object describing the result of the operation that we are finishing """ success = action.data['success'] conn_key = action.data[...
python
def _finish_operation_action(self, action): """Finish an attempted operation. Args: action (ConnectionAction): the action object describing the result of the operation that we are finishing """ success = action.data['success'] conn_key = action.data[...
[ "def", "_finish_operation_action", "(", "self", ",", "action", ")", ":", "success", "=", "action", ".", "data", "[", "'success'", "]", "conn_key", "=", "action", ".", "data", "[", "'id'", "]", "if", "self", ".", "_get_connection_state", "(", "conn_key", ")...
Finish an attempted operation. Args: action (ConnectionAction): the action object describing the result of the operation that we are finishing
[ "Finish", "an", "attempted", "operation", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/connection_manager.py#L613-L637
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Scanner/LaTeX.py
LaTeX.canonical_text
def canonical_text(self, text): """Standardize an input TeX-file contents. Currently: * removes comments, unwrapping comment-wrapped lines. """ out = [] line_continues_a_comment = False for line in text.splitlines(): line,comment = self.comment_re.f...
python
def canonical_text(self, text): """Standardize an input TeX-file contents. Currently: * removes comments, unwrapping comment-wrapped lines. """ out = [] line_continues_a_comment = False for line in text.splitlines(): line,comment = self.comment_re.f...
[ "def", "canonical_text", "(", "self", ",", "text", ")", ":", "out", "=", "[", "]", "line_continues_a_comment", "=", "False", "for", "line", "in", "text", ".", "splitlines", "(", ")", ":", "line", ",", "comment", "=", "self", ".", "comment_re", ".", "fi...
Standardize an input TeX-file contents. Currently: * removes comments, unwrapping comment-wrapped lines.
[ "Standardize", "an", "input", "TeX", "-", "file", "contents", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Scanner/LaTeX.py#L326-L341
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Scanner/LaTeX.py
LaTeX.scan_recurse
def scan_recurse(self, node, path=()): """ do a recursive scan of the top level target file This lets us search for included files based on the directory of the main file just as latex does""" path_dict = dict(list(path)) queue = [] queue.extend( self.scan(node...
python
def scan_recurse(self, node, path=()): """ do a recursive scan of the top level target file This lets us search for included files based on the directory of the main file just as latex does""" path_dict = dict(list(path)) queue = [] queue.extend( self.scan(node...
[ "def", "scan_recurse", "(", "self", ",", "node", ",", "path", "=", "(", ")", ")", ":", "path_dict", "=", "dict", "(", "list", "(", "path", ")", ")", "queue", "=", "[", "]", "queue", ".", "extend", "(", "self", ".", "scan", "(", "node", ")", ")"...
do a recursive scan of the top level target file This lets us search for included files based on the directory of the main file just as latex does
[ "do", "a", "recursive", "scan", "of", "the", "top", "level", "target", "file", "This", "lets", "us", "search", "for", "included", "files", "based", "on", "the", "directory", "of", "the", "main", "file", "just", "as", "latex", "does" ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Scanner/LaTeX.py#L383-L431
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Debug.py
caller_trace
def caller_trace(back=0): """ Trace caller stack and save info into global dicts, which are printed automatically at the end of SCons execution. """ global caller_bases, caller_dicts import traceback tb = traceback.extract_stack(limit=3+back) tb.reverse() callee = tb[1][:3] calle...
python
def caller_trace(back=0): """ Trace caller stack and save info into global dicts, which are printed automatically at the end of SCons execution. """ global caller_bases, caller_dicts import traceback tb = traceback.extract_stack(limit=3+back) tb.reverse() callee = tb[1][:3] calle...
[ "def", "caller_trace", "(", "back", "=", "0", ")", ":", "global", "caller_bases", ",", "caller_dicts", "import", "traceback", "tb", "=", "traceback", ".", "extract_stack", "(", "limit", "=", "3", "+", "back", ")", "tb", ".", "reverse", "(", ")", "callee"...
Trace caller stack and save info into global dicts, which are printed automatically at the end of SCons execution.
[ "Trace", "caller", "stack", "and", "save", "info", "into", "global", "dicts", "which", "are", "printed", "automatically", "at", "the", "end", "of", "SCons", "execution", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Debug.py#L144-L162
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
diff_dumps
def diff_dumps(ih1, ih2, tofile=None, name1="a", name2="b", n_context=3): """Diff 2 IntelHex objects and produce unified diff output for their hex dumps. @param ih1 first IntelHex object to compare @param ih2 second IntelHex object to compare @param tofile file-like object to writ...
python
def diff_dumps(ih1, ih2, tofile=None, name1="a", name2="b", n_context=3): """Diff 2 IntelHex objects and produce unified diff output for their hex dumps. @param ih1 first IntelHex object to compare @param ih2 second IntelHex object to compare @param tofile file-like object to writ...
[ "def", "diff_dumps", "(", "ih1", ",", "ih2", ",", "tofile", "=", "None", ",", "name1", "=", "\"a\"", ",", "name2", "=", "\"b\"", ",", "n_context", "=", "3", ")", ":", "def", "prepare_lines", "(", "ih", ")", ":", "sio", "=", "StringIO", "(", ")", ...
Diff 2 IntelHex objects and produce unified diff output for their hex dumps. @param ih1 first IntelHex object to compare @param ih2 second IntelHex object to compare @param tofile file-like object to write output @param name1 name of the first hex file to show in the diff hea...
[ "Diff", "2", "IntelHex", "objects", "and", "produce", "unified", "diff", "output", "for", "their", "hex", "dumps", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L1100-L1124
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex._decode_record
def _decode_record(self, s, line=0): '''Decode one record of HEX file. @param s line with HEX record. @param line line number (for error messages). @raise EndOfFile if EOF record encountered. ''' s = s.rstrip('\r\n') if not s: return ...
python
def _decode_record(self, s, line=0): '''Decode one record of HEX file. @param s line with HEX record. @param line line number (for error messages). @raise EndOfFile if EOF record encountered. ''' s = s.rstrip('\r\n') if not s: return ...
[ "def", "_decode_record", "(", "self", ",", "s", ",", "line", "=", "0", ")", ":", "s", "=", "s", ".", "rstrip", "(", "'\\r\\n'", ")", "if", "not", "s", ":", "return", "if", "s", "[", "0", "]", "==", "':'", ":", "try", ":", "bin", "=", "array",...
Decode one record of HEX file. @param s line with HEX record. @param line line number (for error messages). @raise EndOfFile if EOF record encountered.
[ "Decode", "one", "record", "of", "HEX", "file", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L109-L197
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.loadhex
def loadhex(self, fobj): """Load hex file into internal buffer. This is not necessary if object was initialized with source set. This will overwrite addresses if object was already initialized. @param fobj file name or file-like object """ if getattr(fobj, "read"...
python
def loadhex(self, fobj): """Load hex file into internal buffer. This is not necessary if object was initialized with source set. This will overwrite addresses if object was already initialized. @param fobj file name or file-like object """ if getattr(fobj, "read"...
[ "def", "loadhex", "(", "self", ",", "fobj", ")", ":", "if", "getattr", "(", "fobj", ",", "\"read\"", ",", "None", ")", "is", "None", ":", "fobj", "=", "open", "(", "fobj", ",", "\"r\"", ")", "fclose", "=", "fobj", ".", "close", "else", ":", "fclo...
Load hex file into internal buffer. This is not necessary if object was initialized with source set. This will overwrite addresses if object was already initialized. @param fobj file name or file-like object
[ "Load", "hex", "file", "into", "internal", "buffer", ".", "This", "is", "not", "necessary", "if", "object", "was", "initialized", "with", "source", "set", ".", "This", "will", "overwrite", "addresses", "if", "object", "was", "already", "initialized", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L199-L225
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.loadbin
def loadbin(self, fobj, offset=0): """Load bin file into internal buffer. Not needed if source set in constructor. This will overwrite addresses without warning if object was already initialized. @param fobj file name or file-like object @param offset starting addr...
python
def loadbin(self, fobj, offset=0): """Load bin file into internal buffer. Not needed if source set in constructor. This will overwrite addresses without warning if object was already initialized. @param fobj file name or file-like object @param offset starting addr...
[ "def", "loadbin", "(", "self", ",", "fobj", ",", "offset", "=", "0", ")", ":", "fread", "=", "getattr", "(", "fobj", ",", "\"read\"", ",", "None", ")", "if", "fread", "is", "None", ":", "f", "=", "open", "(", "fobj", ",", "\"rb\"", ")", "fread", ...
Load bin file into internal buffer. Not needed if source set in constructor. This will overwrite addresses without warning if object was already initialized. @param fobj file name or file-like object @param offset starting address offset
[ "Load", "bin", "file", "into", "internal", "buffer", ".", "Not", "needed", "if", "source", "set", "in", "constructor", ".", "This", "will", "overwrite", "addresses", "without", "warning", "if", "object", "was", "already", "initialized", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L227-L247
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.loadfile
def loadfile(self, fobj, format): """Load data file into internal buffer. Preferred wrapper over loadbin or loadhex. @param fobj file name or file-like object @param format file format ("hex" or "bin") """ if format == "hex": self.loadhex(fobj) ...
python
def loadfile(self, fobj, format): """Load data file into internal buffer. Preferred wrapper over loadbin or loadhex. @param fobj file name or file-like object @param format file format ("hex" or "bin") """ if format == "hex": self.loadhex(fobj) ...
[ "def", "loadfile", "(", "self", ",", "fobj", ",", "format", ")", ":", "if", "format", "==", "\"hex\"", ":", "self", ".", "loadhex", "(", "fobj", ")", "elif", "format", "==", "\"bin\"", ":", "self", ".", "loadbin", "(", "fobj", ")", "else", ":", "ra...
Load data file into internal buffer. Preferred wrapper over loadbin or loadhex. @param fobj file name or file-like object @param format file format ("hex" or "bin")
[ "Load", "data", "file", "into", "internal", "buffer", ".", "Preferred", "wrapper", "over", "loadbin", "or", "loadhex", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L249-L262
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex._get_start_end
def _get_start_end(self, start=None, end=None, size=None): """Return default values for start and end if they are None. If this IntelHex object is empty then it's error to invoke this method with both start and end as None. """ if (start,end) == (None,None) and self._buf == {}: ...
python
def _get_start_end(self, start=None, end=None, size=None): """Return default values for start and end if they are None. If this IntelHex object is empty then it's error to invoke this method with both start and end as None. """ if (start,end) == (None,None) and self._buf == {}: ...
[ "def", "_get_start_end", "(", "self", ",", "start", "=", "None", ",", "end", "=", "None", ",", "size", "=", "None", ")", ":", "if", "(", "start", ",", "end", ")", "==", "(", "None", ",", "None", ")", "and", "self", ".", "_buf", "==", "{", "}", ...
Return default values for start and end if they are None. If this IntelHex object is empty then it's error to invoke this method with both start and end as None.
[ "Return", "default", "values", "for", "start", "and", "end", "if", "they", "are", "None", ".", "If", "this", "IntelHex", "object", "is", "empty", "then", "it", "s", "error", "to", "invoke", "this", "method", "with", "both", "start", "and", "end", "as", ...
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L297-L324
train
iotile/coretools
iotilecore/iotile/core/utilities/intelhex/__init__.py
IntelHex.tobinarray
def tobinarray(self, start=None, end=None, pad=_DEPRECATED, size=None): ''' Convert this object to binary form as array. If start and end unspecified, they will be inferred from the data. @param start start address of output bytes. @param end end address of output bytes (inclusiv...
python
def tobinarray(self, start=None, end=None, pad=_DEPRECATED, size=None): ''' Convert this object to binary form as array. If start and end unspecified, they will be inferred from the data. @param start start address of output bytes. @param end end address of output bytes (inclusiv...
[ "def", "tobinarray", "(", "self", ",", "start", "=", "None", ",", "end", "=", "None", ",", "pad", "=", "_DEPRECATED", ",", "size", "=", "None", ")", ":", "if", "not", "isinstance", "(", "pad", ",", "_DeprecatedParam", ")", ":", "print", "(", "\"Intel...
Convert this object to binary form as array. If start and end unspecified, they will be inferred from the data. @param start start address of output bytes. @param end end address of output bytes (inclusive). @param pad [DEPRECATED PARAMETER, please use self.padding instead] ...
[ "Convert", "this", "object", "to", "binary", "form", "as", "array", ".", "If", "start", "and", "end", "unspecified", "they", "will", "be", "inferred", "from", "the", "data", "." ]
2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L326-L346
train