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
tamasgal/km3pipe
km3pipe/plot.py
joint_hex
def joint_hex(x, y, **kwargs): """Seaborn Joint Hexplot with marginal KDE + hists.""" return sns.jointplot( x, y, kind='hex', stat_func=None, marginal_kws={'kde': True}, **kwargs )
python
def joint_hex(x, y, **kwargs): """Seaborn Joint Hexplot with marginal KDE + hists.""" return sns.jointplot( x, y, kind='hex', stat_func=None, marginal_kws={'kde': True}, **kwargs )
[ "def", "joint_hex", "(", "x", ",", "y", ",", "**", "kwargs", ")", ":", "return", "sns", ".", "jointplot", "(", "x", ",", "y", ",", "kind", "=", "'hex'", ",", "stat_func", "=", "None", ",", "marginal_kws", "=", "{", "'kde'", ":", "True", "}", ",",...
Seaborn Joint Hexplot with marginal KDE + hists.
[ "Seaborn", "Joint", "Hexplot", "with", "marginal", "KDE", "+", "hists", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/plot.py#L111-L115
train
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow.py
Workflow.execute
def execute(self, time_interval): """ Here we execute the factors over the streams in the workflow Execute the factors in reverse order. We can't just execute the last factor because there may be multiple "leaf" factors that aren't triggered by upstream computations. :param time...
python
def execute(self, time_interval): """ Here we execute the factors over the streams in the workflow Execute the factors in reverse order. We can't just execute the last factor because there may be multiple "leaf" factors that aren't triggered by upstream computations. :param time...
[ "def", "execute", "(", "self", ",", "time_interval", ")", ":", "with", "WorkflowMonitor", "(", "self", ")", ":", "for", "factor", "in", "self", ".", "factors", "[", ":", ":", "-", "1", "]", ":", "if", "factor", ".", "tool", ".", "name", "==", "\"as...
Here we execute the factors over the streams in the workflow Execute the factors in reverse order. We can't just execute the last factor because there may be multiple "leaf" factors that aren't triggered by upstream computations. :param time_interval: The time interval to execute this workflow ...
[ "Here", "we", "execute", "the", "factors", "over", "the", "streams", "in", "the", "workflow", "Execute", "the", "factors", "in", "reverse", "order", ".", "We", "can", "t", "just", "execute", "the", "last", "factor", "because", "there", "may", "be", "multip...
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L87-L107
train
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow.py
Workflow._add_node
def _add_node(self, node): """ Add a node to the workflow :param node: The node object :type node: Node :return: None """ self.nodes[node.node_id] = node logging.info("Added node with id {} containing {} streams".format(node.node_id, len(node.streams)))
python
def _add_node(self, node): """ Add a node to the workflow :param node: The node object :type node: Node :return: None """ self.nodes[node.node_id] = node logging.info("Added node with id {} containing {} streams".format(node.node_id, len(node.streams)))
[ "def", "_add_node", "(", "self", ",", "node", ")", ":", "self", ".", "nodes", "[", "node", ".", "node_id", "]", "=", "node", "logging", ".", "info", "(", "\"Added node with id {} containing {} streams\"", ".", "format", "(", "node", ".", "node_id", ",", "l...
Add a node to the workflow :param node: The node object :type node: Node :return: None
[ "Add", "a", "node", "to", "the", "workflow" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L109-L118
train
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow.py
Workflow._add_factor
def _add_factor(self, factor): """ Add a factor to the workflow :param factor: The factor object :type factor: Factor | MultiOutputFactor | NodeCreationFactor :return: None """ self.factors.append(factor) logging.info("Added factor with tool {} ".format(f...
python
def _add_factor(self, factor): """ Add a factor to the workflow :param factor: The factor object :type factor: Factor | MultiOutputFactor | NodeCreationFactor :return: None """ self.factors.append(factor) logging.info("Added factor with tool {} ".format(f...
[ "def", "_add_factor", "(", "self", ",", "factor", ")", ":", "self", ".", "factors", ".", "append", "(", "factor", ")", "logging", ".", "info", "(", "\"Added factor with tool {} \"", ".", "format", "(", "factor", ".", "tool", ")", ")" ]
Add a factor to the workflow :param factor: The factor object :type factor: Factor | MultiOutputFactor | NodeCreationFactor :return: None
[ "Add", "a", "factor", "to", "the", "workflow" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L120-L129
train
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow.py
Workflow.create_factor_general
def create_factor_general(self, *args, **kwargs): """ General signature for factor creation that tries each of the factor creation types using duck typing :param args: The positional arguments :param kwargs: The named arguments :return: The created factor """ try...
python
def create_factor_general(self, *args, **kwargs): """ General signature for factor creation that tries each of the factor creation types using duck typing :param args: The positional arguments :param kwargs: The named arguments :return: The created factor """ try...
[ "def", "create_factor_general", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "try", ":", "return", "self", ".", "create_factor", "(", "*", "args", ",", "**", "kwargs", ")", "except", "TypeError", ":", "pass", "try", ":", "return", "sel...
General signature for factor creation that tries each of the factor creation types using duck typing :param args: The positional arguments :param kwargs: The named arguments :return: The created factor
[ "General", "signature", "for", "factor", "creation", "that", "tries", "each", "of", "the", "factor", "creation", "types", "using", "duck", "typing" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L164-L184
train
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow.py
Workflow.create_multi_output_factor
def create_multi_output_factor(self, tool, source, splitting_node, sink): """ Creates a multi-output factor. This takes a single node, applies a MultiOutputTool to create multiple nodes on a new plate Instantiates a single tool for all of the input plate values, and connects the ...
python
def create_multi_output_factor(self, tool, source, splitting_node, sink): """ Creates a multi-output factor. This takes a single node, applies a MultiOutputTool to create multiple nodes on a new plate Instantiates a single tool for all of the input plate values, and connects the ...
[ "def", "create_multi_output_factor", "(", "self", ",", "tool", ",", "source", ",", "splitting_node", ",", "sink", ")", ":", "if", "source", "and", "not", "isinstance", "(", "source", ",", "Node", ")", ":", "raise", "ValueError", "(", "\"Expected Node, got {}\"...
Creates a multi-output factor. This takes a single node, applies a MultiOutputTool to create multiple nodes on a new plate Instantiates a single tool for all of the input plate values, and connects the source and sink nodes with that tool. Note that the tool parameters these are current...
[ "Creates", "a", "multi", "-", "output", "factor", ".", "This", "takes", "a", "single", "node", "applies", "a", "MultiOutputTool", "to", "create", "multiple", "nodes", "on", "a", "new", "plate", "Instantiates", "a", "single", "tool", "for", "all", "of", "th...
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L287-L374
train
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow.py
Workflow.create_node_creation_factor
def create_node_creation_factor(self, tool, source, output_plate, plate_manager): """ Creates a factor that itself creates an output node, and ensures that the plate for the output node exists along with all relevant meta-data :param tool: The tool :param source: The source node...
python
def create_node_creation_factor(self, tool, source, output_plate, plate_manager): """ Creates a factor that itself creates an output node, and ensures that the plate for the output node exists along with all relevant meta-data :param tool: The tool :param source: The source node...
[ "def", "create_node_creation_factor", "(", "self", ",", "tool", ",", "source", ",", "output_plate", ",", "plate_manager", ")", ":", "if", "not", "isinstance", "(", "tool", ",", "PlateCreationTool", ")", ":", "raise", "ValueError", "(", "\"Expected PlateCreationToo...
Creates a factor that itself creates an output node, and ensures that the plate for the output node exists along with all relevant meta-data :param tool: The tool :param source: The source node :param output_plate: The details of the plate that will be created (dict) :param plat...
[ "Creates", "a", "factor", "that", "itself", "creates", "an", "output", "node", "and", "ensures", "that", "the", "plate", "for", "the", "output", "node", "exists", "along", "with", "all", "relevant", "meta", "-", "data" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L376-L409
train
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow.py
Workflow.check_plate_compatibility
def check_plate_compatibility(tool, source_plate, sink_plate): """ Checks whether the source and sink plate are compatible given the tool :param tool: The tool :param source_plate: The source plate :param sink_plate: The sink plate :return: Either an error, or None ...
python
def check_plate_compatibility(tool, source_plate, sink_plate): """ Checks whether the source and sink plate are compatible given the tool :param tool: The tool :param source_plate: The source plate :param sink_plate: The sink plate :return: Either an error, or None ...
[ "def", "check_plate_compatibility", "(", "tool", ",", "source_plate", ",", "sink_plate", ")", ":", "if", "sink_plate", "==", "source_plate", ".", "parent", ":", "return", "None", "if", "sink_plate", ".", "meta_data_id", "==", "source_plate", ".", "meta_data_id", ...
Checks whether the source and sink plate are compatible given the tool :param tool: The tool :param source_plate: The source plate :param sink_plate: The sink plate :return: Either an error, or None :type tool: Tool :type source_plate: Plate :type sink_plate: Pla...
[ "Checks", "whether", "the", "source", "and", "sink", "plate", "are", "compatible", "given", "the", "tool" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L412-L445
train
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow.py
Workflow.check_multi_output_plate_compatibility
def check_multi_output_plate_compatibility(source_plates, sink_plate): """ Check multi-output plate compatibility. This ensures that the source plates and sink plates match for a multi- output plate :param source_plates: The source plates :param sink_plate: The sink plate ...
python
def check_multi_output_plate_compatibility(source_plates, sink_plate): """ Check multi-output plate compatibility. This ensures that the source plates and sink plates match for a multi- output plate :param source_plates: The source plates :param sink_plate: The sink plate ...
[ "def", "check_multi_output_plate_compatibility", "(", "source_plates", ",", "sink_plate", ")", ":", "if", "len", "(", "source_plates", ")", "==", "0", ":", "if", "sink_plate", ".", "parent", "is", "not", "None", ":", "return", "False", "else", ":", "if", "si...
Check multi-output plate compatibility. This ensures that the source plates and sink plates match for a multi- output plate :param source_plates: The source plates :param sink_plate: The sink plate :return: True if the plates are compatible
[ "Check", "multi", "-", "output", "plate", "compatibility", ".", "This", "ensures", "that", "the", "source", "plates", "and", "sink", "plates", "match", "for", "a", "multi", "-", "output", "plate" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L448-L466
train
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow.py
Workflow.to_dict
def to_dict(self, tool_long_names=True): """ Get a representation of the workflow as a dictionary for display purposes :param tool_long_names: Indicates whether to use long names, such as SplitterFromStream(element=None, use_mapping_keys_only=True) ...
python
def to_dict(self, tool_long_names=True): """ Get a representation of the workflow as a dictionary for display purposes :param tool_long_names: Indicates whether to use long names, such as SplitterFromStream(element=None, use_mapping_keys_only=True) ...
[ "def", "to_dict", "(", "self", ",", "tool_long_names", "=", "True", ")", ":", "d", "=", "dict", "(", "nodes", "=", "[", "]", ",", "factors", "=", "[", "]", ",", "plates", "=", "defaultdict", "(", "list", ")", ")", "for", "node", "in", "self", "."...
Get a representation of the workflow as a dictionary for display purposes :param tool_long_names: Indicates whether to use long names, such as SplitterFromStream(element=None, use_mapping_keys_only=True) or short names, such as ...
[ "Get", "a", "representation", "of", "the", "workflow", "as", "a", "dictionary", "for", "display", "purposes" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L510-L553
train
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow.py
Workflow.to_json
def to_json(self, formatter=None, tool_long_names=True, **kwargs): """ Get a JSON representation of the workflow :param tool_long_names: Indicates whether to use long names, such as SplitterFromStream(element=None, use_mapping_keys_only=True) ...
python
def to_json(self, formatter=None, tool_long_names=True, **kwargs): """ Get a JSON representation of the workflow :param tool_long_names: Indicates whether to use long names, such as SplitterFromStream(element=None, use_mapping_keys_only=True) ...
[ "def", "to_json", "(", "self", ",", "formatter", "=", "None", ",", "tool_long_names", "=", "True", ",", "**", "kwargs", ")", ":", "d", "=", "self", ".", "to_dict", "(", "tool_long_names", "=", "tool_long_names", ")", "if", "formatter", ":", "d", "=", "...
Get a JSON representation of the workflow :param tool_long_names: Indicates whether to use long names, such as SplitterFromStream(element=None, use_mapping_keys_only=True) or short names, such as splitter_from_strea...
[ "Get", "a", "JSON", "representation", "of", "the", "workflow" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow.py#L555-L570
train
IRC-SPHERE/HyperStream
hyperstream/tool/base_tool.py
BaseTool.parameters_dict
def parameters_dict(self): """ Get the tool parameters as a simple dictionary :return: The tool parameters """ d = {} for k, v in self.__dict__.items(): if not k.startswith("_"): d[k] = v return d
python
def parameters_dict(self): """ Get the tool parameters as a simple dictionary :return: The tool parameters """ d = {} for k, v in self.__dict__.items(): if not k.startswith("_"): d[k] = v return d
[ "def", "parameters_dict", "(", "self", ")", ":", "d", "=", "{", "}", "for", "k", ",", "v", "in", "self", ".", "__dict__", ".", "items", "(", ")", ":", "if", "not", "k", ".", "startswith", "(", "\"_\"", ")", ":", "d", "[", "k", "]", "=", "v", ...
Get the tool parameters as a simple dictionary :return: The tool parameters
[ "Get", "the", "tool", "parameters", "as", "a", "simple", "dictionary" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/base_tool.py#L85-L95
train
IRC-SPHERE/HyperStream
hyperstream/tool/base_tool.py
BaseTool.parameters
def parameters(self): """ Get the tool parameters :return: The tool parameters along with additional information (whether they are functions or sets) """ parameters = [] for k, v in self.__dict__.items(): if k.startswith("_"): continue ...
python
def parameters(self): """ Get the tool parameters :return: The tool parameters along with additional information (whether they are functions or sets) """ parameters = [] for k, v in self.__dict__.items(): if k.startswith("_"): continue ...
[ "def", "parameters", "(", "self", ")", ":", "parameters", "=", "[", "]", "for", "k", ",", "v", "in", "self", ".", "__dict__", ".", "items", "(", ")", ":", "if", "k", ".", "startswith", "(", "\"_\"", ")", ":", "continue", "is_function", "=", "False"...
Get the tool parameters :return: The tool parameters along with additional information (whether they are functions or sets)
[ "Get", "the", "tool", "parameters" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/base_tool.py#L98-L128
train
IRC-SPHERE/HyperStream
hyperstream/tool/base_tool.py
BaseTool.parameters_from_model
def parameters_from_model(parameters_model): """ Get the tool parameters model from dictionaries :param parameters_model: The parameters as a mongoengine model :return: The tool parameters as a dictionary """ parameters = {} for p in parameters_model: ...
python
def parameters_from_model(parameters_model): """ Get the tool parameters model from dictionaries :param parameters_model: The parameters as a mongoengine model :return: The tool parameters as a dictionary """ parameters = {} for p in parameters_model: ...
[ "def", "parameters_from_model", "(", "parameters_model", ")", ":", "parameters", "=", "{", "}", "for", "p", "in", "parameters_model", ":", "if", "p", ".", "is_function", ":", "code", ",", "defaults", ",", "closure", "=", "pickle", ".", "loads", "(", "p", ...
Get the tool parameters model from dictionaries :param parameters_model: The parameters as a mongoengine model :return: The tool parameters as a dictionary
[ "Get", "the", "tool", "parameters", "model", "from", "dictionaries" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/base_tool.py#L131-L147
train
IRC-SPHERE/HyperStream
hyperstream/tool/base_tool.py
BaseTool.get_model
def get_model(self): """ Gets the mongoengine model for this tool, which serializes parameters that are functions :return: The mongoengine model. TODO: Note that the tool version is currently incorrect (0.0.0) """ return ToolModel( name=self.name, versio...
python
def get_model(self): """ Gets the mongoengine model for this tool, which serializes parameters that are functions :return: The mongoengine model. TODO: Note that the tool version is currently incorrect (0.0.0) """ return ToolModel( name=self.name, versio...
[ "def", "get_model", "(", "self", ")", ":", "return", "ToolModel", "(", "name", "=", "self", ".", "name", ",", "version", "=", "\"0.0.0\"", ",", "parameters", "=", "self", ".", "parameters_from_dicts", "(", "self", ".", "parameters", ")", ")" ]
Gets the mongoengine model for this tool, which serializes parameters that are functions :return: The mongoengine model. TODO: Note that the tool version is currently incorrect (0.0.0)
[ "Gets", "the", "mongoengine", "model", "for", "this", "tool", "which", "serializes", "parameters", "that", "are", "functions" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/base_tool.py#L159-L170
train
IRC-SPHERE/HyperStream
hyperstream/tool/base_tool.py
BaseTool.write_to_history
def write_to_history(**kwargs): """ Write to the history of executions of this tool :param kwargs: keyword arguments describing the executions :return: None """ from hyperstream import HyperStream hs = HyperStream(loglevel=logging.CRITICAL, file_logger=False, con...
python
def write_to_history(**kwargs): """ Write to the history of executions of this tool :param kwargs: keyword arguments describing the executions :return: None """ from hyperstream import HyperStream hs = HyperStream(loglevel=logging.CRITICAL, file_logger=False, con...
[ "def", "write_to_history", "(", "**", "kwargs", ")", ":", "from", "hyperstream", "import", "HyperStream", "hs", "=", "HyperStream", "(", "loglevel", "=", "logging", ".", "CRITICAL", ",", "file_logger", "=", "False", ",", "console_logger", "=", "False", ",", ...
Write to the history of executions of this tool :param kwargs: keyword arguments describing the executions :return: None
[ "Write", "to", "the", "history", "of", "executions", "of", "this", "tool" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/base_tool.py#L173-L183
train
tamasgal/km3pipe
km3modules/plot.py
plot_dom_parameters
def plot_dom_parameters( data, detector, filename, label, title, vmin=0.0, vmax=10.0, cmap='RdYlGn_r', under='deepskyblue', over='deeppink', underfactor=1.0, overfactor=1.0, missing='lightgray', hide_limits=F...
python
def plot_dom_parameters( data, detector, filename, label, title, vmin=0.0, vmax=10.0, cmap='RdYlGn_r', under='deepskyblue', over='deeppink', underfactor=1.0, overfactor=1.0, missing='lightgray', hide_limits=F...
[ "def", "plot_dom_parameters", "(", "data", ",", "detector", ",", "filename", ",", "label", ",", "title", ",", "vmin", "=", "0.0", ",", "vmax", "=", "10.0", ",", "cmap", "=", "'RdYlGn_r'", ",", "under", "=", "'deepskyblue'", ",", "over", "=", "'deeppink'"...
Creates a plot in the classical monitoring.km3net.de style. Parameters ---------- data: dict((du, floor) -> value) detector: km3pipe.hardware.Detector() instance filename: filename or filepath label: str title: str underfactor: a scale factor for the points used for underflow values ...
[ "Creates", "a", "plot", "in", "the", "classical", "monitoring", ".", "km3net", ".", "de", "style", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3modules/plot.py#L27-L129
train
tamasgal/km3pipe
km3modules/plot.py
make_dom_map
def make_dom_map(pmt_directions, values, nside=512, d=0.2, smoothing=0.1): """Create a mollweide projection of a DOM with given PMTs. The output can be used to call the `healpy.mollview` function. """ import healpy as hp discs = [hp.query_disc(nside, dir, 0.2) for dir in pmt_directions] npix = ...
python
def make_dom_map(pmt_directions, values, nside=512, d=0.2, smoothing=0.1): """Create a mollweide projection of a DOM with given PMTs. The output can be used to call the `healpy.mollview` function. """ import healpy as hp discs = [hp.query_disc(nside, dir, 0.2) for dir in pmt_directions] npix = ...
[ "def", "make_dom_map", "(", "pmt_directions", ",", "values", ",", "nside", "=", "512", ",", "d", "=", "0.2", ",", "smoothing", "=", "0.1", ")", ":", "import", "healpy", "as", "hp", "discs", "=", "[", "hp", ".", "query_disc", "(", "nside", ",", "dir",...
Create a mollweide projection of a DOM with given PMTs. The output can be used to call the `healpy.mollview` function.
[ "Create", "a", "mollweide", "projection", "of", "a", "DOM", "with", "given", "PMTs", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3modules/plot.py#L132-L146
train
IRC-SPHERE/HyperStream
hyperstream/stream/stream.py
Stream.calculated_intervals
def calculated_intervals(self, value): """ Set the calculated intervals This will be written to the stream_status collection if it's in the database channel :param value: The calculated intervals :type value: TimeIntervals, TimeInterval, list[TimeInterval] """ if...
python
def calculated_intervals(self, value): """ Set the calculated intervals This will be written to the stream_status collection if it's in the database channel :param value: The calculated intervals :type value: TimeIntervals, TimeInterval, list[TimeInterval] """ if...
[ "def", "calculated_intervals", "(", "self", ",", "value", ")", ":", "if", "not", "value", ":", "self", ".", "_calculated_intervals", "=", "TimeIntervals", "(", ")", "return", "if", "isinstance", "(", "value", ",", "TimeInterval", ")", ":", "value", "=", "T...
Set the calculated intervals This will be written to the stream_status collection if it's in the database channel :param value: The calculated intervals :type value: TimeIntervals, TimeInterval, list[TimeInterval]
[ "Set", "the", "calculated", "intervals", "This", "will", "be", "written", "to", "the", "stream_status", "collection", "if", "it", "s", "in", "the", "database", "channel" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream.py#L115-L140
train
IRC-SPHERE/HyperStream
hyperstream/stream/stream.py
Stream.purge
def purge(self): """ Purge the stream. This removes all data and clears the calculated intervals :return: None """ self.channel.purge_stream(self.stream_id, remove_definition=False, sandbox=None)
python
def purge(self): """ Purge the stream. This removes all data and clears the calculated intervals :return: None """ self.channel.purge_stream(self.stream_id, remove_definition=False, sandbox=None)
[ "def", "purge", "(", "self", ")", ":", "self", ".", "channel", ".", "purge_stream", "(", "self", ".", "stream_id", ",", "remove_definition", "=", "False", ",", "sandbox", "=", "None", ")" ]
Purge the stream. This removes all data and clears the calculated intervals :return: None
[ "Purge", "the", "stream", ".", "This", "removes", "all", "data", "and", "clears", "the", "calculated", "intervals" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream.py#L142-L148
train
IRC-SPHERE/HyperStream
hyperstream/stream/stream.py
Stream.window
def window(self, time_interval=None, force_calculation=False): """ Gets a view on this stream for the time interval given :param time_interval: either a TimeInterval object or (start, end) tuple of type str or datetime :param force_calculation: Whether we should force calculation for th...
python
def window(self, time_interval=None, force_calculation=False): """ Gets a view on this stream for the time interval given :param time_interval: either a TimeInterval object or (start, end) tuple of type str or datetime :param force_calculation: Whether we should force calculation for th...
[ "def", "window", "(", "self", ",", "time_interval", "=", "None", ",", "force_calculation", "=", "False", ")", ":", "if", "not", "time_interval", ":", "if", "self", ".", "calculated_intervals", ":", "time_interval", "=", "self", ".", "calculated_intervals", "["...
Gets a view on this stream for the time interval given :param time_interval: either a TimeInterval object or (start, end) tuple of type str or datetime :param force_calculation: Whether we should force calculation for this stream view if data does not exist :type time_interval: None | Iterable ...
[ "Gets", "a", "view", "on", "this", "stream", "for", "the", "time", "interval", "given" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream.py#L154-L180
train
IRC-SPHERE/HyperStream
hyperstream/stream/stream.py
DatabaseStream.load
def load(self): """ Load the stream definition from the database :return: None """ with switch_db(StreamDefinitionModel, 'hyperstream'): self.mongo_model = StreamDefinitionModel.objects.get(__raw__=self.stream_id.as_raw()) self._calculated_intervals = sel...
python
def load(self): """ Load the stream definition from the database :return: None """ with switch_db(StreamDefinitionModel, 'hyperstream'): self.mongo_model = StreamDefinitionModel.objects.get(__raw__=self.stream_id.as_raw()) self._calculated_intervals = sel...
[ "def", "load", "(", "self", ")", ":", "with", "switch_db", "(", "StreamDefinitionModel", ",", "'hyperstream'", ")", ":", "self", ".", "mongo_model", "=", "StreamDefinitionModel", ".", "objects", ".", "get", "(", "__raw__", "=", "self", ".", "stream_id", ".",...
Load the stream definition from the database :return: None
[ "Load", "the", "stream", "definition", "from", "the", "database" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream.py#L212-L220
train
IRC-SPHERE/HyperStream
hyperstream/stream/stream.py
DatabaseStream.calculated_intervals
def calculated_intervals(self): """ Gets the calculated intervals from the database :return: The calculated intervals """ if self._calculated_intervals is None: logging.debug("get calculated intervals") self.load() return self.mongo_model.get_...
python
def calculated_intervals(self): """ Gets the calculated intervals from the database :return: The calculated intervals """ if self._calculated_intervals is None: logging.debug("get calculated intervals") self.load() return self.mongo_model.get_...
[ "def", "calculated_intervals", "(", "self", ")", ":", "if", "self", ".", "_calculated_intervals", "is", "None", ":", "logging", ".", "debug", "(", "\"get calculated intervals\"", ")", "self", ".", "load", "(", ")", "return", "self", ".", "mongo_model", ".", ...
Gets the calculated intervals from the database :return: The calculated intervals
[ "Gets", "the", "calculated", "intervals", "from", "the", "database" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/stream/stream.py#L233-L243
train
tamasgal/km3pipe
km3pipe/io/__init__.py
GenericPump
def GenericPump(filenames, use_jppy=False, name="GenericPump", **kwargs): """A generic pump which utilises the appropriate pump.""" if isinstance(filenames, str): filenames = [filenames] try: iter(filenames) except TypeError: log.critical("Don't know how to iterate through filen...
python
def GenericPump(filenames, use_jppy=False, name="GenericPump", **kwargs): """A generic pump which utilises the appropriate pump.""" if isinstance(filenames, str): filenames = [filenames] try: iter(filenames) except TypeError: log.critical("Don't know how to iterate through filen...
[ "def", "GenericPump", "(", "filenames", ",", "use_jppy", "=", "False", ",", "name", "=", "\"GenericPump\"", ",", "**", "kwargs", ")", ":", "if", "isinstance", "(", "filenames", ",", "str", ")", ":", "filenames", "=", "[", "filenames", "]", "try", ":", ...
A generic pump which utilises the appropriate pump.
[ "A", "generic", "pump", "which", "utilises", "the", "appropriate", "pump", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/__init__.py#L36-L87
train
tamasgal/km3pipe
km3pipe/io/__init__.py
read_calibration
def read_calibration( detx=None, det_id=None, from_file=False, det_id_table=None ): """Retrive calibration from file, the DB.""" from km3pipe.calib import Calibration # noqa if not (detx or det_id or from_file): return None if detx is not None: return Calibration(filename=det...
python
def read_calibration( detx=None, det_id=None, from_file=False, det_id_table=None ): """Retrive calibration from file, the DB.""" from km3pipe.calib import Calibration # noqa if not (detx or det_id or from_file): return None if detx is not None: return Calibration(filename=det...
[ "def", "read_calibration", "(", "detx", "=", "None", ",", "det_id", "=", "None", ",", "from_file", "=", "False", ",", "det_id_table", "=", "None", ")", ":", "from", "km3pipe", ".", "calib", "import", "Calibration", "if", "not", "(", "detx", "or", "det_id...
Retrive calibration from file, the DB.
[ "Retrive", "calibration", "from", "file", "the", "DB", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/__init__.py#L90-L113
train
NaPs/Kolekto
kolekto/printer.py
KolektoPrinter.edit
def edit(self, text): """ Edit a text using an external editor. """ if isinstance(text, unicode): text = text.encode(self._encoding) if self._editor is None: printer.p('Warning: no editor found, skipping edit') return text with tempfile.NamedTe...
python
def edit(self, text): """ Edit a text using an external editor. """ if isinstance(text, unicode): text = text.encode(self._encoding) if self._editor is None: printer.p('Warning: no editor found, skipping edit') return text with tempfile.NamedTe...
[ "def", "edit", "(", "self", ",", "text", ")", ":", "if", "isinstance", "(", "text", ",", "unicode", ")", ":", "text", "=", "text", ".", "encode", "(", "self", ".", "_encoding", ")", "if", "self", ".", "_editor", "is", "None", ":", "printer", ".", ...
Edit a text using an external editor.
[ "Edit", "a", "text", "using", "an", "external", "editor", "." ]
29c5469da8782780a06bf9a76c59414bb6fd8fe3
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/printer.py#L276-L290
train
jdodds/feather
feather/application.py
Application.register
def register(self, plugin): """Take a feather.plugin.Plugin and tell our dispatcher about it. Plugins are expected to provide a list of the messages that they listen for and generate. If registering this plugin makes it so we have at least one plugin listening for and generating our exp...
python
def register(self, plugin): """Take a feather.plugin.Plugin and tell our dispatcher about it. Plugins are expected to provide a list of the messages that they listen for and generate. If registering this plugin makes it so we have at least one plugin listening for and generating our exp...
[ "def", "register", "(", "self", ",", "plugin", ")", ":", "self", ".", "needed_listeners", "-=", "plugin", ".", "listeners", "self", ".", "needed_messengers", "-=", "plugin", ".", "messengers", "if", "self", ".", "needed_messengers", "==", "self", ".", "neede...
Take a feather.plugin.Plugin and tell our dispatcher about it. Plugins are expected to provide a list of the messages that they listen for and generate. If registering this plugin makes it so we have at least one plugin listening for and generating our expected messages, set self.valid ...
[ "Take", "a", "feather", ".", "plugin", ".", "Plugin", "and", "tell", "our", "dispatcher", "about", "it", "." ]
92a9426e692b33c7fddf758df8dbc99a9a1ba8ef
https://github.com/jdodds/feather/blob/92a9426e692b33c7fddf758df8dbc99a9a1ba8ef/feather/application.py#L29-L43
train
jdodds/feather
feather/application.py
Application.start
def start(self): """If we have a set of plugins that provide our expected listeners and messengers, tell our dispatcher to start up. Otherwise, raise InvalidApplication """ if not self.valid: err = ("\nMessengers and listeners that still need set:\n\n" ...
python
def start(self): """If we have a set of plugins that provide our expected listeners and messengers, tell our dispatcher to start up. Otherwise, raise InvalidApplication """ if not self.valid: err = ("\nMessengers and listeners that still need set:\n\n" ...
[ "def", "start", "(", "self", ")", ":", "if", "not", "self", ".", "valid", ":", "err", "=", "(", "\"\\nMessengers and listeners that still need set:\\n\\n\"", "\"messengers : %s\\n\\n\"", "\"listeners : %s\\n\"", ")", "raise", "InvalidApplication", "(", "err", "%", "("...
If we have a set of plugins that provide our expected listeners and messengers, tell our dispatcher to start up. Otherwise, raise InvalidApplication
[ "If", "we", "have", "a", "set", "of", "plugins", "that", "provide", "our", "expected", "listeners", "and", "messengers", "tell", "our", "dispatcher", "to", "start", "up", ".", "Otherwise", "raise", "InvalidApplication" ]
92a9426e692b33c7fddf758df8dbc99a9a1ba8ef
https://github.com/jdodds/feather/blob/92a9426e692b33c7fddf758df8dbc99a9a1ba8ef/feather/application.py#L45-L56
train
baranbartu/rulengine
rulengine/conditions.py
execute_condition
def execute_condition(cond): """ Get a rule instance for given operator and return condition lambda func """ condition_method = 'rulengine.conditions.c_{0}_{1}'.format( cond.data_type, cond.operator) try: func = import_class(condition_method) except AttributeError: c...
python
def execute_condition(cond): """ Get a rule instance for given operator and return condition lambda func """ condition_method = 'rulengine.conditions.c_{0}_{1}'.format( cond.data_type, cond.operator) try: func = import_class(condition_method) except AttributeError: c...
[ "def", "execute_condition", "(", "cond", ")", ":", "condition_method", "=", "'rulengine.conditions.c_{0}_{1}'", ".", "format", "(", "cond", ".", "data_type", ",", "cond", ".", "operator", ")", "try", ":", "func", "=", "import_class", "(", "condition_method", ")"...
Get a rule instance for given operator and return condition lambda func
[ "Get", "a", "rule", "instance", "for", "given", "operator", "and", "return", "condition", "lambda", "func" ]
f4d1e6258927cb171cb7fc8a90a3cba546a2aee5
https://github.com/baranbartu/rulengine/blob/f4d1e6258927cb171cb7fc8a90a3cba546a2aee5/rulengine/conditions.py#L5-L21
train
abiiranathan/db2
db2/session.py
Session.makemigrations
def makemigrations(self): ''' Do database migrations 1. Creates new tables from models 2. Updates columns and columns Returns True if no exception else raises an unhandled exception ''' UNCHANGED = [] with Session(self.settings) as conn: cursor = co...
python
def makemigrations(self): ''' Do database migrations 1. Creates new tables from models 2. Updates columns and columns Returns True if no exception else raises an unhandled exception ''' UNCHANGED = [] with Session(self.settings) as conn: cursor = co...
[ "def", "makemigrations", "(", "self", ")", ":", "UNCHANGED", "=", "[", "]", "with", "Session", "(", "self", ".", "settings", ")", "as", "conn", ":", "cursor", "=", "conn", ".", "cursor", "(", ")", "for", "name", ",", "model", "in", "self", ".", "mo...
Do database migrations 1. Creates new tables from models 2. Updates columns and columns Returns True if no exception else raises an unhandled exception
[ "Do", "database", "migrations", "1", ".", "Creates", "new", "tables", "from", "models", "2", ".", "Updates", "columns", "and", "columns" ]
347319e421921517bcae7639f524c3c3eb5446e6
https://github.com/abiiranathan/db2/blob/347319e421921517bcae7639f524c3c3eb5446e6/db2/session.py#L307-L342
train
abiiranathan/db2
db2/session.py
Session.UpdateColums
def UpdateColums(self, cursor, field, FieldType, model, columns, UNCHANGED): '''Updates the columns. Dont call directly ''' table = model.__name__.lower() if field not in columns: n = UNCHANGED.pop() new_sql = f"ALTER TABLE {table} ADD COLUMN {field} {FieldType} A...
python
def UpdateColums(self, cursor, field, FieldType, model, columns, UNCHANGED): '''Updates the columns. Dont call directly ''' table = model.__name__.lower() if field not in columns: n = UNCHANGED.pop() new_sql = f"ALTER TABLE {table} ADD COLUMN {field} {FieldType} A...
[ "def", "UpdateColums", "(", "self", ",", "cursor", ",", "field", ",", "FieldType", ",", "model", ",", "columns", ",", "UNCHANGED", ")", ":", "table", "=", "model", ".", "__name__", ".", "lower", "(", ")", "if", "field", "not", "in", "columns", ":", "...
Updates the columns. Dont call directly
[ "Updates", "the", "columns", ".", "Dont", "call", "directly" ]
347319e421921517bcae7639f524c3c3eb5446e6
https://github.com/abiiranathan/db2/blob/347319e421921517bcae7639f524c3c3eb5446e6/db2/session.py#L344-L364
train
tamasgal/km3pipe
km3pipe/srv.py
srv_event
def srv_event(token, hits, url=RBA_URL): """Serve event to RainbowAlga""" if url is None: log.error("Please provide a valid RainbowAlga URL.") return ws_url = url + '/message' if isinstance(hits, pd.core.frame.DataFrame): pos = [tuple(x) for x in hits[['x', 'y', 'z']].values] ...
python
def srv_event(token, hits, url=RBA_URL): """Serve event to RainbowAlga""" if url is None: log.error("Please provide a valid RainbowAlga URL.") return ws_url = url + '/message' if isinstance(hits, pd.core.frame.DataFrame): pos = [tuple(x) for x in hits[['x', 'y', 'z']].values] ...
[ "def", "srv_event", "(", "token", ",", "hits", ",", "url", "=", "RBA_URL", ")", ":", "if", "url", "is", "None", ":", "log", ".", "error", "(", "\"Please provide a valid RainbowAlga URL.\"", ")", "return", "ws_url", "=", "url", "+", "'/message'", "if", "isi...
Serve event to RainbowAlga
[ "Serve", "event", "to", "RainbowAlga" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/srv.py#L289-L322
train
tamasgal/km3pipe
km3pipe/srv.py
srv_data
def srv_data(url, token, data, kind): """Serve data to RainbowAlga""" ws = websocket.create_connection(url) message = {'token': token, 'data': data, 'kind': kind} ws.send(pd.io.json.dumps(message)) ws.close()
python
def srv_data(url, token, data, kind): """Serve data to RainbowAlga""" ws = websocket.create_connection(url) message = {'token': token, 'data': data, 'kind': kind} ws.send(pd.io.json.dumps(message)) ws.close()
[ "def", "srv_data", "(", "url", ",", "token", ",", "data", ",", "kind", ")", ":", "ws", "=", "websocket", ".", "create_connection", "(", "url", ")", "message", "=", "{", "'token'", ":", "token", ",", "'data'", ":", "data", ",", "'kind'", ":", "kind", ...
Serve data to RainbowAlga
[ "Serve", "data", "to", "RainbowAlga" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/srv.py#L325-L330
train
tamasgal/km3pipe
km3pipe/srv.py
ClientManager.raw_message_to
def raw_message_to(self, token, message): """Convert message to JSON and send it to the client with token""" if token not in self._clients: log.critical("Client with token '{0}' not found!".format(token)) return client = self._clients[token] try: clien...
python
def raw_message_to(self, token, message): """Convert message to JSON and send it to the client with token""" if token not in self._clients: log.critical("Client with token '{0}' not found!".format(token)) return client = self._clients[token] try: clien...
[ "def", "raw_message_to", "(", "self", ",", "token", ",", "message", ")", ":", "if", "token", "not", "in", "self", ".", "_clients", ":", "log", ".", "critical", "(", "\"Client with token '{0}' not found!\"", ".", "format", "(", "token", ")", ")", "return", ...
Convert message to JSON and send it to the client with token
[ "Convert", "message", "to", "JSON", "and", "send", "it", "to", "the", "client", "with", "token" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/srv.py#L114-L125
train
tamasgal/km3pipe
km3pipe/srv.py
EchoWebSocket.message
def message(self, data, kind="info"): """Convert message to json and send it to the clients""" message = pd.io.json.dumps({'kind': kind, 'data': data}) print("Sent {0} bytes.".format(len(message))) self.write_message(message)
python
def message(self, data, kind="info"): """Convert message to json and send it to the clients""" message = pd.io.json.dumps({'kind': kind, 'data': data}) print("Sent {0} bytes.".format(len(message))) self.write_message(message)
[ "def", "message", "(", "self", ",", "data", ",", "kind", "=", "\"info\"", ")", ":", "message", "=", "pd", ".", "io", ".", "json", ".", "dumps", "(", "{", "'kind'", ":", "kind", ",", "'data'", ":", "data", "}", ")", "print", "(", "\"Sent {0} bytes.\...
Convert message to json and send it to the clients
[ "Convert", "message", "to", "json", "and", "send", "it", "to", "the", "clients" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/srv.py#L282-L286
train
vslutov/turingmarkov
turingmarkov/markov.py
Algorithm.execute_once
def execute_once(self, string): """Execute only one rule.""" for rule in self.rules: if rule[0] in string: pos = string.find(rule[0]) self.last_rule = rule return string[:pos] + rule[1] + string[pos+len(rule[0]):] self.last_rule = None ...
python
def execute_once(self, string): """Execute only one rule.""" for rule in self.rules: if rule[0] in string: pos = string.find(rule[0]) self.last_rule = rule return string[:pos] + rule[1] + string[pos+len(rule[0]):] self.last_rule = None ...
[ "def", "execute_once", "(", "self", ",", "string", ")", ":", "for", "rule", "in", "self", ".", "rules", ":", "if", "rule", "[", "0", "]", "in", "string", ":", "pos", "=", "string", ".", "find", "(", "rule", "[", "0", "]", ")", "self", ".", "las...
Execute only one rule.
[ "Execute", "only", "one", "rule", "." ]
63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce
https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/markov.py#L51-L59
train
vslutov/turingmarkov
turingmarkov/markov.py
Algorithm.compile
def compile(self): """Return python code for create and execute algo.""" result = TEMPLATE for rule in self.rules: if rule[2]: arrow = '=>' else: arrow = '->' repr_rule = repr(rule[0] + arrow + rule[1]) result += "...
python
def compile(self): """Return python code for create and execute algo.""" result = TEMPLATE for rule in self.rules: if rule[2]: arrow = '=>' else: arrow = '->' repr_rule = repr(rule[0] + arrow + rule[1]) result += "...
[ "def", "compile", "(", "self", ")", ":", "result", "=", "TEMPLATE", "for", "rule", "in", "self", ".", "rules", ":", "if", "rule", "[", "2", "]", ":", "arrow", "=", "'=>'", "else", ":", "arrow", "=", "'->'", "repr_rule", "=", "repr", "(", "rule", ...
Return python code for create and execute algo.
[ "Return", "python", "code", "for", "create", "and", "execute", "algo", "." ]
63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce
https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/markov.py#L76-L91
train
IRC-SPHERE/HyperStream
hyperstream/factor/factor.py
Factor.get_sources
def get_sources(self, plate, plate_value, sources=None): """ Gets the source streams for a given plate value on a plate. Also populates with source streams that are valid for the parent plates of this plate, with the appropriate meta-data for the parent plate. :param plate: The ...
python
def get_sources(self, plate, plate_value, sources=None): """ Gets the source streams for a given plate value on a plate. Also populates with source streams that are valid for the parent plates of this plate, with the appropriate meta-data for the parent plate. :param plate: The ...
[ "def", "get_sources", "(", "self", ",", "plate", ",", "plate_value", ",", "sources", "=", "None", ")", ":", "if", "sources", "is", "None", ":", "sources", "=", "[", "]", "if", "self", ".", "sources", ":", "for", "si", ",", "source", "in", "enumerate"...
Gets the source streams for a given plate value on a plate. Also populates with source streams that are valid for the parent plates of this plate, with the appropriate meta-data for the parent plate. :param plate: The plate being operated on :param plate_value: The specific plate value ...
[ "Gets", "the", "source", "streams", "for", "a", "given", "plate", "value", "on", "a", "plate", ".", "Also", "populates", "with", "source", "streams", "that", "are", "valid", "for", "the", "parent", "plates", "of", "this", "plate", "with", "the", "appropria...
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L204-L240
train
IRC-SPHERE/HyperStream
hyperstream/factor/factor.py
Factor.get_global_sources
def get_global_sources(self): """ Gets streams that live outside of the plates :return: Global streams """ sources = [] if self.sources: for source in self.sources: if None in source.streams: sources.append(source.streams[N...
python
def get_global_sources(self): """ Gets streams that live outside of the plates :return: Global streams """ sources = [] if self.sources: for source in self.sources: if None in source.streams: sources.append(source.streams[N...
[ "def", "get_global_sources", "(", "self", ")", ":", "sources", "=", "[", "]", "if", "self", ".", "sources", ":", "for", "source", "in", "self", ".", "sources", ":", "if", "None", "in", "source", ".", "streams", ":", "sources", ".", "append", "(", "so...
Gets streams that live outside of the plates :return: Global streams
[ "Gets", "streams", "that", "live", "outside", "of", "the", "plates" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L242-L253
train
IRC-SPHERE/HyperStream
hyperstream/factor/factor.py
Factor.get_alignment_stream
def get_alignment_stream(self, plate=None, plate_value=None): """ Gets the alignment stream for a particular plate value :param plate: The plate on which the alignment node lives :param plate_value: The plate value to select the stream from the node :return: The alignment stream...
python
def get_alignment_stream(self, plate=None, plate_value=None): """ Gets the alignment stream for a particular plate value :param plate: The plate on which the alignment node lives :param plate_value: The plate value to select the stream from the node :return: The alignment stream...
[ "def", "get_alignment_stream", "(", "self", ",", "plate", "=", "None", ",", "plate_value", "=", "None", ")", ":", "if", "not", "self", ".", "alignment_node", ":", "return", "None", "if", "plate", "is", "not", "None", "or", "plate_value", "is", "not", "No...
Gets the alignment stream for a particular plate value :param plate: The plate on which the alignment node lives :param plate_value: The plate value to select the stream from the node :return: The alignment stream
[ "Gets", "the", "alignment", "stream", "for", "a", "particular", "plate", "value" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L255-L268
train
IRC-SPHERE/HyperStream
hyperstream/factor/factor.py
MultiOutputFactor.get_splitting_stream
def get_splitting_stream(self, input_plate_value): """ Get the splitting stream :param input_plate_value: The input plate value :return: The splitting stream """ if not self.splitting_node: return None if len(self.splitting_node.plates) == 0: ...
python
def get_splitting_stream(self, input_plate_value): """ Get the splitting stream :param input_plate_value: The input plate value :return: The splitting stream """ if not self.splitting_node: return None if len(self.splitting_node.plates) == 0: ...
[ "def", "get_splitting_stream", "(", "self", ",", "input_plate_value", ")", ":", "if", "not", "self", ".", "splitting_node", ":", "return", "None", "if", "len", "(", "self", ".", "splitting_node", ".", "plates", ")", "==", "0", ":", "return", "self", ".", ...
Get the splitting stream :param input_plate_value: The input plate value :return: The splitting stream
[ "Get", "the", "splitting", "stream" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L390-L436
train
IRC-SPHERE/HyperStream
hyperstream/factor/factor.py
MultiOutputFactor.update_computed_intervals
def update_computed_intervals(sinks, time_interval): """ Update computed intervals :param sinks: The streams to update :param time_interval: The time interval """ for sink in sinks: sink.calculated_intervals += time_interval required_intervals = T...
python
def update_computed_intervals(sinks, time_interval): """ Update computed intervals :param sinks: The streams to update :param time_interval: The time interval """ for sink in sinks: sink.calculated_intervals += time_interval required_intervals = T...
[ "def", "update_computed_intervals", "(", "sinks", ",", "time_interval", ")", ":", "for", "sink", "in", "sinks", ":", "sink", ".", "calculated_intervals", "+=", "time_interval", "required_intervals", "=", "TimeIntervals", "(", "[", "time_interval", "]", ")", "-", ...
Update computed intervals :param sinks: The streams to update :param time_interval: The time interval
[ "Update", "computed", "intervals" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/factor/factor.py#L439-L451
train
lexibank/pylexibank
src/pylexibank/util.py
getEvoBibAsBibtex
def getEvoBibAsBibtex(*keys, **kw): """Download bibtex format and parse it from EvoBib""" res = [] for key in keys: bib = get_url( "http://bibliography.lingpy.org/raw.php?key=" + key, log=kw.get('log')).text try: res.append('@' + bib.split('@')[1].split('<...
python
def getEvoBibAsBibtex(*keys, **kw): """Download bibtex format and parse it from EvoBib""" res = [] for key in keys: bib = get_url( "http://bibliography.lingpy.org/raw.php?key=" + key, log=kw.get('log')).text try: res.append('@' + bib.split('@')[1].split('<...
[ "def", "getEvoBibAsBibtex", "(", "*", "keys", ",", "**", "kw", ")", ":", "res", "=", "[", "]", "for", "key", "in", "keys", ":", "bib", "=", "get_url", "(", "\"http://bibliography.lingpy.org/raw.php?key=\"", "+", "key", ",", "log", "=", "kw", ".", "get", ...
Download bibtex format and parse it from EvoBib
[ "Download", "bibtex", "format", "and", "parse", "it", "from", "EvoBib" ]
c28e7f122f20de1232623dd7003cb5b01535e581
https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/util.py#L233-L244
train
lexibank/pylexibank
src/pylexibank/util.py
DataDir.download_and_unpack
def download_and_unpack(self, url, *paths, **kw): """ Download a zipfile and immediately unpack selected content. :param url: :param paths: :param kw: :return: """ with self.temp_download(url, 'ds.zip', log=kw.pop('log', None)) as zipp: with T...
python
def download_and_unpack(self, url, *paths, **kw): """ Download a zipfile and immediately unpack selected content. :param url: :param paths: :param kw: :return: """ with self.temp_download(url, 'ds.zip', log=kw.pop('log', None)) as zipp: with T...
[ "def", "download_and_unpack", "(", "self", ",", "url", ",", "*", "paths", ",", "**", "kw", ")", ":", "with", "self", ".", "temp_download", "(", "url", ",", "'ds.zip'", ",", "log", "=", "kw", ".", "pop", "(", "'log'", ",", "None", ")", ")", "as", ...
Download a zipfile and immediately unpack selected content. :param url: :param paths: :param kw: :return:
[ "Download", "a", "zipfile", "and", "immediately", "unpack", "selected", "content", "." ]
c28e7f122f20de1232623dd7003cb5b01535e581
https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/util.py#L216-L230
train
PrefPy/prefpy
prefpy/mechanismMcmc.py
MechanismMcmc.getRanking
def getRanking(self, profile, sampleFileName = None): """ Returns a list of lists that orders all candidates in tiers from best to worst when we use MCMC approximation to compute Bayesian utilities for an election profile. :ivar Profile profile: A Profile object that represents an elec...
python
def getRanking(self, profile, sampleFileName = None): """ Returns a list of lists that orders all candidates in tiers from best to worst when we use MCMC approximation to compute Bayesian utilities for an election profile. :ivar Profile profile: A Profile object that represents an elec...
[ "def", "getRanking", "(", "self", ",", "profile", ",", "sampleFileName", "=", "None", ")", ":", "if", "sampleFileName", "!=", "None", ":", "candScoresMap", "=", "self", ".", "getCandScoresMapFromSamplesFile", "(", "profile", ",", "sampleFileName", ")", "else", ...
Returns a list of lists that orders all candidates in tiers from best to worst when we use MCMC approximation to compute Bayesian utilities for an election profile. :ivar Profile profile: A Profile object that represents an election profile. :ivar str sampleFileName: An optional argument for t...
[ "Returns", "a", "list", "of", "lists", "that", "orders", "all", "candidates", "in", "tiers", "from", "best", "to", "worst", "when", "we", "use", "MCMC", "approximation", "to", "compute", "Bayesian", "utilities", "for", "an", "election", "profile", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L48-L84
train
PrefPy/prefpy
prefpy/mechanismMcmc.py
MechanismMcmc.getCandScoresMap
def getCandScoresMap(self, profile): """ Returns a dictonary that associates the integer representation of each candidate with the Bayesian utilities we approximate from our sampling of the profile. :ivar Profile profile: A Profile object that represents an election profile. ""...
python
def getCandScoresMap(self, profile): """ Returns a dictonary that associates the integer representation of each candidate with the Bayesian utilities we approximate from our sampling of the profile. :ivar Profile profile: A Profile object that represents an election profile. ""...
[ "def", "getCandScoresMap", "(", "self", ",", "profile", ")", ":", "wmg", "=", "profile", ".", "getWmg", "(", "True", ")", "V", "=", "self", ".", "getInitialSample", "(", "wmg", ")", "utilities", "=", "dict", "(", ")", "for", "cand", "in", "profile", ...
Returns a dictonary that associates the integer representation of each candidate with the Bayesian utilities we approximate from our sampling of the profile. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "a", "dictonary", "that", "associates", "the", "integer", "representation", "of", "each", "candidate", "with", "the", "Bayesian", "utilities", "we", "approximate", "from", "our", "sampling", "of", "the", "profile", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L86-L113
train
PrefPy/prefpy
prefpy/mechanismMcmc.py
MechanismMcmc.getCandScoresMapFromSamplesFile
def getCandScoresMapFromSamplesFile(self, profile, sampleFileName): """ Returns a dictonary that associates the integer representation of each candidate with the Bayesian utilities we approximate from the samples we generated into a file. :ivar Profile profile: A Profile object that re...
python
def getCandScoresMapFromSamplesFile(self, profile, sampleFileName): """ Returns a dictonary that associates the integer representation of each candidate with the Bayesian utilities we approximate from the samples we generated into a file. :ivar Profile profile: A Profile object that re...
[ "def", "getCandScoresMapFromSamplesFile", "(", "self", ",", "profile", ",", "sampleFileName", ")", ":", "wmg", "=", "profile", ".", "getWmg", "(", "True", ")", "utilities", "=", "dict", "(", ")", "for", "cand", "in", "wmg", ".", "keys", "(", ")", ":", ...
Returns a dictonary that associates the integer representation of each candidate with the Bayesian utilities we approximate from the samples we generated into a file. :ivar Profile profile: A Profile object that represents an election profile. :ivar str sampleFileName: The name of the input fi...
[ "Returns", "a", "dictonary", "that", "associates", "the", "integer", "representation", "of", "each", "candidate", "with", "the", "Bayesian", "utilities", "we", "approximate", "from", "the", "samples", "we", "generated", "into", "a", "file", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L176-L212
train
PrefPy/prefpy
prefpy/mechanismMcmc.py
MechanismMcmc.printMcmcSamplesToFile
def printMcmcSamplesToFile(self, profile, numSamples, outFileName): """ Generate samples to a file. :ivar Profile profile: A Profile object that represents an election profile. :ivar int numSamples: The number of samples to be generated. :ivar str outFileName: The name of the fi...
python
def printMcmcSamplesToFile(self, profile, numSamples, outFileName): """ Generate samples to a file. :ivar Profile profile: A Profile object that represents an election profile. :ivar int numSamples: The number of samples to be generated. :ivar str outFileName: The name of the fi...
[ "def", "printMcmcSamplesToFile", "(", "self", ",", "profile", ",", "numSamples", ",", "outFileName", ")", ":", "wmg", "=", "profile", ".", "getWmg", "(", "True", ")", "V", "=", "self", ".", "getInitialSample", "(", "wmg", ")", "outFile", "=", "open", "("...
Generate samples to a file. :ivar Profile profile: A Profile object that represents an election profile. :ivar int numSamples: The number of samples to be generated. :ivar str outFileName: The name of the file to be output.
[ "Generate", "samples", "to", "a", "file", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L214-L235
train
PrefPy/prefpy
prefpy/mechanismMcmc.py
MechanismMcmcMallows.kendallTau
def kendallTau(self, orderVector, wmgMap): """ Given a ranking for a single vote and a wmg for the entire election, calculate the kendall-tau distance. a.k.a the number of discordant pairs between the wmg for the vote and the wmg for the election. Currently, we expect the vote to be a st...
python
def kendallTau(self, orderVector, wmgMap): """ Given a ranking for a single vote and a wmg for the entire election, calculate the kendall-tau distance. a.k.a the number of discordant pairs between the wmg for the vote and the wmg for the election. Currently, we expect the vote to be a st...
[ "def", "kendallTau", "(", "self", ",", "orderVector", ",", "wmgMap", ")", ":", "discordantPairs", "=", "0.0", "for", "i", "in", "itertools", ".", "combinations", "(", "orderVector", ",", "2", ")", ":", "discordantPairs", "=", "discordantPairs", "+", "max", ...
Given a ranking for a single vote and a wmg for the entire election, calculate the kendall-tau distance. a.k.a the number of discordant pairs between the wmg for the vote and the wmg for the election. Currently, we expect the vote to be a strict complete ordering over the candidates. :ivar list...
[ "Given", "a", "ranking", "for", "a", "single", "vote", "and", "a", "wmg", "for", "the", "entire", "election", "calculate", "the", "kendall", "-", "tau", "distance", ".", "a", ".", "k", ".", "a", "the", "number", "of", "discordant", "pairs", "between", ...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L253-L270
train
PrefPy/prefpy
prefpy/mechanismMcmc.py
MechanismMcmcMallows.getInitialSample
def getInitialSample(self, wmg): """ Generate an initial sample for the Markov chain. This function will return a list containing integer representations of each candidate in order of their rank in the current vote, from first to last. The list will be a complete strict ordering over t...
python
def getInitialSample(self, wmg): """ Generate an initial sample for the Markov chain. This function will return a list containing integer representations of each candidate in order of their rank in the current vote, from first to last. The list will be a complete strict ordering over t...
[ "def", "getInitialSample", "(", "self", ",", "wmg", ")", ":", "V", "=", "copy", ".", "deepcopy", "(", "wmg", ".", "keys", "(", ")", ")", "random", ".", "shuffle", "(", "V", ")", "return", "V" ]
Generate an initial sample for the Markov chain. This function will return a list containing integer representations of each candidate in order of their rank in the current vote, from first to last. The list will be a complete strict ordering over the candidates. Initially, we rank the candida...
[ "Generate", "an", "initial", "sample", "for", "the", "Markov", "chain", ".", "This", "function", "will", "return", "a", "list", "containing", "integer", "representations", "of", "each", "candidate", "in", "order", "of", "their", "rank", "in", "the", "current",...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L272-L287
train
PrefPy/prefpy
prefpy/mechanismMcmc.py
MechanismMcmcCondorcet.getInitialSample
def getInitialSample(self, wmg): """ Generate an initial sample for the Markov chain. This function will return a two-dimensional array of integers, such that for each pair of candidates, cand1 and cand2, the array contains 1 if more votes rank cand1 above cand2 and 0 otherwise. ...
python
def getInitialSample(self, wmg): """ Generate an initial sample for the Markov chain. This function will return a two-dimensional array of integers, such that for each pair of candidates, cand1 and cand2, the array contains 1 if more votes rank cand1 above cand2 and 0 otherwise. ...
[ "def", "getInitialSample", "(", "self", ",", "wmg", ")", ":", "cands", "=", "range", "(", "len", "(", "wmg", ")", ")", "allPairs", "=", "itertools", ".", "combinations", "(", "cands", ",", "2", ")", "V", "=", "self", ".", "createBinaryRelation", "(", ...
Generate an initial sample for the Markov chain. This function will return a two-dimensional array of integers, such that for each pair of candidates, cand1 and cand2, the array contains 1 if more votes rank cand1 above cand2 and 0 otherwise. ivar: dict<int,<dict,<int,int>>> wmg: A two-dimensi...
[ "Generate", "an", "initial", "sample", "for", "the", "Markov", "chain", ".", "This", "function", "will", "return", "a", "two", "-", "dimensional", "array", "of", "integers", "such", "that", "for", "each", "pair", "of", "candidates", "cand1", "and", "cand2", ...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L341-L363
train
tamasgal/km3pipe
pipeinspector/app.py
filter_input
def filter_input(keys, raw): """Adds fancy mouse wheel functionality and VI navigation to ListBox""" if len(keys) == 1: if keys[0] in UI.keys['up']: keys[0] = 'up' elif keys[0] in UI.keys['down']: keys[0] = 'down' elif len(keys[0]) == 4 and keys[0][0] == 'mouse pr...
python
def filter_input(keys, raw): """Adds fancy mouse wheel functionality and VI navigation to ListBox""" if len(keys) == 1: if keys[0] in UI.keys['up']: keys[0] = 'up' elif keys[0] in UI.keys['down']: keys[0] = 'down' elif len(keys[0]) == 4 and keys[0][0] == 'mouse pr...
[ "def", "filter_input", "(", "keys", ",", "raw", ")", ":", "if", "len", "(", "keys", ")", "==", "1", ":", "if", "keys", "[", "0", "]", "in", "UI", ".", "keys", "[", "'up'", "]", ":", "keys", "[", "0", "]", "=", "'up'", "elif", "keys", "[", "...
Adds fancy mouse wheel functionality and VI navigation to ListBox
[ "Adds", "fancy", "mouse", "wheel", "functionality", "and", "VI", "navigation", "to", "ListBox" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/pipeinspector/app.py#L39-L51
train
lexibank/pylexibank
src/pylexibank/lingpy_util.py
wordlist2cognates
def wordlist2cognates(wordlist, source, expert='expert', ref='cogid'): """Turn a wordlist into a cognate set list, using the cldf parameters.""" for k in wordlist: yield dict( Form_ID=wordlist[k, 'lid'], ID=k, Form=wordlist[k, 'ipa'], Cognateset_ID='{0}-{1...
python
def wordlist2cognates(wordlist, source, expert='expert', ref='cogid'): """Turn a wordlist into a cognate set list, using the cldf parameters.""" for k in wordlist: yield dict( Form_ID=wordlist[k, 'lid'], ID=k, Form=wordlist[k, 'ipa'], Cognateset_ID='{0}-{1...
[ "def", "wordlist2cognates", "(", "wordlist", ",", "source", ",", "expert", "=", "'expert'", ",", "ref", "=", "'cogid'", ")", ":", "for", "k", "in", "wordlist", ":", "yield", "dict", "(", "Form_ID", "=", "wordlist", "[", "k", ",", "'lid'", "]", ",", "...
Turn a wordlist into a cognate set list, using the cldf parameters.
[ "Turn", "a", "wordlist", "into", "a", "cognate", "set", "list", "using", "the", "cldf", "parameters", "." ]
c28e7f122f20de1232623dd7003cb5b01535e581
https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/lingpy_util.py#L9-L19
train
lexibank/pylexibank
src/pylexibank/lingpy_util.py
_cldf2wld
def _cldf2wld(dataset): """Make lingpy-compatible dictinary out of cldf main data.""" header = [f for f in dataset.dataset.lexeme_class.fieldnames() if f != 'ID'] D = {0: ['lid'] + [h.lower() for h in header]} for idx, row in enumerate(dataset.objects['FormTable']): row = deepcopy(row) r...
python
def _cldf2wld(dataset): """Make lingpy-compatible dictinary out of cldf main data.""" header = [f for f in dataset.dataset.lexeme_class.fieldnames() if f != 'ID'] D = {0: ['lid'] + [h.lower() for h in header]} for idx, row in enumerate(dataset.objects['FormTable']): row = deepcopy(row) r...
[ "def", "_cldf2wld", "(", "dataset", ")", ":", "header", "=", "[", "f", "for", "f", "in", "dataset", ".", "dataset", ".", "lexeme_class", ".", "fieldnames", "(", ")", "if", "f", "!=", "'ID'", "]", "D", "=", "{", "0", ":", "[", "'lid'", "]", "+", ...
Make lingpy-compatible dictinary out of cldf main data.
[ "Make", "lingpy", "-", "compatible", "dictinary", "out", "of", "cldf", "main", "data", "." ]
c28e7f122f20de1232623dd7003cb5b01535e581
https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/lingpy_util.py#L22-L30
train
lexibank/pylexibank
src/pylexibank/lingpy_util.py
_cldf2lexstat
def _cldf2lexstat( dataset, segments='segments', transcription='value', row='parameter_id', col='language_id'): """Read LexStat object from cldf dataset.""" D = _cldf2wld(dataset) return lingpy.LexStat(D, segments=segments, transcription=transcription, row=row, col=co...
python
def _cldf2lexstat( dataset, segments='segments', transcription='value', row='parameter_id', col='language_id'): """Read LexStat object from cldf dataset.""" D = _cldf2wld(dataset) return lingpy.LexStat(D, segments=segments, transcription=transcription, row=row, col=co...
[ "def", "_cldf2lexstat", "(", "dataset", ",", "segments", "=", "'segments'", ",", "transcription", "=", "'value'", ",", "row", "=", "'parameter_id'", ",", "col", "=", "'language_id'", ")", ":", "D", "=", "_cldf2wld", "(", "dataset", ")", "return", "lingpy", ...
Read LexStat object from cldf dataset.
[ "Read", "LexStat", "object", "from", "cldf", "dataset", "." ]
c28e7f122f20de1232623dd7003cb5b01535e581
https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/lingpy_util.py#L33-L41
train
lexibank/pylexibank
src/pylexibank/lingpy_util.py
_cldf2wordlist
def _cldf2wordlist(dataset, row='parameter_id', col='language_id'): """Read worldist object from cldf dataset.""" return lingpy.Wordlist(_cldf2wld(dataset), row=row, col=col)
python
def _cldf2wordlist(dataset, row='parameter_id', col='language_id'): """Read worldist object from cldf dataset.""" return lingpy.Wordlist(_cldf2wld(dataset), row=row, col=col)
[ "def", "_cldf2wordlist", "(", "dataset", ",", "row", "=", "'parameter_id'", ",", "col", "=", "'language_id'", ")", ":", "return", "lingpy", ".", "Wordlist", "(", "_cldf2wld", "(", "dataset", ")", ",", "row", "=", "row", ",", "col", "=", "col", ")" ]
Read worldist object from cldf dataset.
[ "Read", "worldist", "object", "from", "cldf", "dataset", "." ]
c28e7f122f20de1232623dd7003cb5b01535e581
https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/lingpy_util.py#L44-L46
train
lexibank/pylexibank
src/pylexibank/lingpy_util.py
iter_cognates
def iter_cognates(dataset, column='Segments', method='turchin', threshold=0.5, **kw): """ Compute cognates automatically for a given dataset. """ if method == 'turchin': for row in dataset.objects['FormTable']: sounds = ''.join(lingpy.tokens2class(row[column], 'dolgo')) i...
python
def iter_cognates(dataset, column='Segments', method='turchin', threshold=0.5, **kw): """ Compute cognates automatically for a given dataset. """ if method == 'turchin': for row in dataset.objects['FormTable']: sounds = ''.join(lingpy.tokens2class(row[column], 'dolgo')) i...
[ "def", "iter_cognates", "(", "dataset", ",", "column", "=", "'Segments'", ",", "method", "=", "'turchin'", ",", "threshold", "=", "0.5", ",", "**", "kw", ")", ":", "if", "method", "==", "'turchin'", ":", "for", "row", "in", "dataset", ".", "objects", "...
Compute cognates automatically for a given dataset.
[ "Compute", "cognates", "automatically", "for", "a", "given", "dataset", "." ]
c28e7f122f20de1232623dd7003cb5b01535e581
https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/lingpy_util.py#L49-L77
train
lexibank/pylexibank
src/pylexibank/lingpy_util.py
iter_alignments
def iter_alignments(dataset, cognate_sets, column='Segments', method='library'): """ Function computes automatic alignments and writes them to file. """ if not isinstance(dataset, lingpy.basic.parser.QLCParser): wordlist = _cldf2wordlist(dataset) cognates = {r['Form_ID']: r for r in cogn...
python
def iter_alignments(dataset, cognate_sets, column='Segments', method='library'): """ Function computes automatic alignments and writes them to file. """ if not isinstance(dataset, lingpy.basic.parser.QLCParser): wordlist = _cldf2wordlist(dataset) cognates = {r['Form_ID']: r for r in cogn...
[ "def", "iter_alignments", "(", "dataset", ",", "cognate_sets", ",", "column", "=", "'Segments'", ",", "method", "=", "'library'", ")", ":", "if", "not", "isinstance", "(", "dataset", ",", "lingpy", ".", "basic", ".", "parser", ".", "QLCParser", ")", ":", ...
Function computes automatic alignments and writes them to file.
[ "Function", "computes", "automatic", "alignments", "and", "writes", "them", "to", "file", "." ]
c28e7f122f20de1232623dd7003cb5b01535e581
https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/lingpy_util.py#L80-L110
train
tamasgal/km3pipe
km3pipe/utils/tohdf5.py
tohdf5
def tohdf5(input_files, output_file, n_events, conv_times_to_jte, **kwargs): """Convert Any file to HDF5 file""" if len(input_files) > 1: cprint( "Preparing to convert {} files to HDF5.".format(len(input_files)) ) from km3pipe import Pipeline # noqa from km3pipe.io import...
python
def tohdf5(input_files, output_file, n_events, conv_times_to_jte, **kwargs): """Convert Any file to HDF5 file""" if len(input_files) > 1: cprint( "Preparing to convert {} files to HDF5.".format(len(input_files)) ) from km3pipe import Pipeline # noqa from km3pipe.io import...
[ "def", "tohdf5", "(", "input_files", ",", "output_file", ",", "n_events", ",", "conv_times_to_jte", ",", "**", "kwargs", ")", ":", "if", "len", "(", "input_files", ")", ">", "1", ":", "cprint", "(", "\"Preparing to convert {} files to HDF5.\"", ".", "format", ...
Convert Any file to HDF5 file
[ "Convert", "Any", "file", "to", "HDF5", "file" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/utils/tohdf5.py#L46-L73
train
IRC-SPHERE/HyperStream
hyperstream/channels/channel_manager.py
ChannelManager.update_channels
def update_channels(self): """ Pulls out all of the stream definitions from the database, and populates the channels with stream references """ logging.info("Updating channels") with switch_db(StreamDefinitionModel, 'hyperstream'): for s in StreamDefinitionModel.objec...
python
def update_channels(self): """ Pulls out all of the stream definitions from the database, and populates the channels with stream references """ logging.info("Updating channels") with switch_db(StreamDefinitionModel, 'hyperstream'): for s in StreamDefinitionModel.objec...
[ "def", "update_channels", "(", "self", ")", ":", "logging", ".", "info", "(", "\"Updating channels\"", ")", "with", "switch_db", "(", "StreamDefinitionModel", ",", "'hyperstream'", ")", ":", "for", "s", "in", "StreamDefinitionModel", ".", "objects", "(", ")", ...
Pulls out all of the stream definitions from the database, and populates the channels with stream references
[ "Pulls", "out", "all", "of", "the", "stream", "definitions", "from", "the", "database", "and", "populates", "the", "channels", "with", "stream", "references" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/channel_manager.py#L97-L146
train
IRC-SPHERE/HyperStream
hyperstream/channels/channel_manager.py
ChannelManager.get_tool_class
def get_tool_class(self, tool): """ Gets the actual class which can then be instantiated with its parameters :param tool: The tool name or id :type tool: str | unicode | StreamId :rtype: Tool | MultiOutputTool :return: The tool class """ if isinstance(too...
python
def get_tool_class(self, tool): """ Gets the actual class which can then be instantiated with its parameters :param tool: The tool name or id :type tool: str | unicode | StreamId :rtype: Tool | MultiOutputTool :return: The tool class """ if isinstance(too...
[ "def", "get_tool_class", "(", "self", ",", "tool", ")", ":", "if", "isinstance", "(", "tool", ",", "string_types", ")", ":", "tool_id", "=", "StreamId", "(", "tool", ")", "elif", "isinstance", "(", "tool", ",", "StreamId", ")", ":", "tool_id", "=", "to...
Gets the actual class which can then be instantiated with its parameters :param tool: The tool name or id :type tool: str | unicode | StreamId :rtype: Tool | MultiOutputTool :return: The tool class
[ "Gets", "the", "actual", "class", "which", "can", "then", "be", "instantiated", "with", "its", "parameters" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/channel_manager.py#L148-L186
train
IRC-SPHERE/HyperStream
hyperstream/plate/plate.py
Plate.is_sub_plate
def is_sub_plate(self, other): """ Determines if this plate is a sub-plate of another plate - i.e. has the same meta data but a restricted set of values :param other: The other plate :return: True if this plate is a sub-plate of the other plate """ if all(v in se...
python
def is_sub_plate(self, other): """ Determines if this plate is a sub-plate of another plate - i.e. has the same meta data but a restricted set of values :param other: The other plate :return: True if this plate is a sub-plate of the other plate """ if all(v in se...
[ "def", "is_sub_plate", "(", "self", ",", "other", ")", ":", "if", "all", "(", "v", "in", "set", "(", "other", ".", "values", ")", "for", "v", "in", "self", ".", "values", ")", ":", "return", "True", "if", "all", "(", "any", "(", "all", "(", "sp...
Determines if this plate is a sub-plate of another plate - i.e. has the same meta data but a restricted set of values :param other: The other plate :return: True if this plate is a sub-plate of the other plate
[ "Determines", "if", "this", "plate", "is", "a", "sub", "-", "plate", "of", "another", "plate", "-", "i", ".", "e", ".", "has", "the", "same", "meta", "data", "but", "a", "restricted", "set", "of", "values" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/plate/plate.py#L130-L144
train
thebigmunch/google-music-utils
src/google_music_utils/utils.py
normalize_value
def normalize_value(value): """Normalize metadata value to improve match accuracy.""" value = str(value) value = value.casefold() value = re.sub(r'\/\s*\d+', '', value) # Remove "/<totaltracks>" from track number. value = re.sub(r'^0+([0-9]+)', r'\1', value) # Remove leading zero(s) from track number. value =...
python
def normalize_value(value): """Normalize metadata value to improve match accuracy.""" value = str(value) value = value.casefold() value = re.sub(r'\/\s*\d+', '', value) # Remove "/<totaltracks>" from track number. value = re.sub(r'^0+([0-9]+)', r'\1', value) # Remove leading zero(s) from track number. value =...
[ "def", "normalize_value", "(", "value", ")", ":", "value", "=", "str", "(", "value", ")", "value", "=", "value", ".", "casefold", "(", ")", "value", "=", "re", ".", "sub", "(", "r'\\/\\s*\\d+'", ",", "''", ",", "value", ")", "value", "=", "re", "."...
Normalize metadata value to improve match accuracy.
[ "Normalize", "metadata", "value", "to", "improve", "match", "accuracy", "." ]
2e8873defe7d5aab7321b9d5ec8a80d72687578e
https://github.com/thebigmunch/google-music-utils/blob/2e8873defe7d5aab7321b9d5ec8a80d72687578e/src/google_music_utils/utils.py#L53-L68
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector._init_from_file
def _init_from_file(self, filename): """Create detector from detx file.""" if not filename.endswith("detx"): raise NotImplementedError('Only the detx format is supported.') self._open_file(filename) self._extract_comments() self._parse_header() self._parse_dom...
python
def _init_from_file(self, filename): """Create detector from detx file.""" if not filename.endswith("detx"): raise NotImplementedError('Only the detx format is supported.') self._open_file(filename) self._extract_comments() self._parse_header() self._parse_dom...
[ "def", "_init_from_file", "(", "self", ",", "filename", ")", ":", "if", "not", "filename", ".", "endswith", "(", "\"detx\"", ")", ":", "raise", "NotImplementedError", "(", "'Only the detx format is supported.'", ")", "self", ".", "_open_file", "(", "filename", "...
Create detector from detx file.
[ "Create", "detector", "from", "detx", "file", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L92-L100
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector._readline
def _readline(self, ignore_comments=True): """The next line of the DETX file, optionally ignores comments""" while True: line = self._det_file.readline() if line == '': return line # To conform the EOF behaviour of .readline() line = line.strip() ...
python
def _readline(self, ignore_comments=True): """The next line of the DETX file, optionally ignores comments""" while True: line = self._det_file.readline() if line == '': return line # To conform the EOF behaviour of .readline() line = line.strip() ...
[ "def", "_readline", "(", "self", ",", "ignore_comments", "=", "True", ")", ":", "while", "True", ":", "line", "=", "self", ".", "_det_file", ".", "readline", "(", ")", "if", "line", "==", "''", ":", "return", "line", "line", "=", "line", ".", "strip"...
The next line of the DETX file, optionally ignores comments
[ "The", "next", "line", "of", "the", "DETX", "file", "optionally", "ignores", "comments" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L106-L119
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector._extract_comments
def _extract_comments(self): """Retrieve all comments from the file""" self._det_file.seek(0, 0) for line in self._det_file.readlines(): line = line.strip() if line.startswith('#'): self.add_comment(line[1:])
python
def _extract_comments(self): """Retrieve all comments from the file""" self._det_file.seek(0, 0) for line in self._det_file.readlines(): line = line.strip() if line.startswith('#'): self.add_comment(line[1:])
[ "def", "_extract_comments", "(", "self", ")", ":", "self", ".", "_det_file", ".", "seek", "(", "0", ",", "0", ")", "for", "line", "in", "self", ".", "_det_file", ".", "readlines", "(", ")", ":", "line", "=", "line", ".", "strip", "(", ")", "if", ...
Retrieve all comments from the file
[ "Retrieve", "all", "comments", "from", "the", "file" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L121-L127
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector._parse_header
def _parse_header(self): """Extract information from the header of the detector file""" self.print("Parsing the DETX header") self._det_file.seek(0, 0) first_line = self._readline() try: self.det_id, self.n_doms = split(first_line, int) self.version = 'v1'...
python
def _parse_header(self): """Extract information from the header of the detector file""" self.print("Parsing the DETX header") self._det_file.seek(0, 0) first_line = self._readline() try: self.det_id, self.n_doms = split(first_line, int) self.version = 'v1'...
[ "def", "_parse_header", "(", "self", ")", ":", "self", ".", "print", "(", "\"Parsing the DETX header\"", ")", "self", ".", "_det_file", ".", "seek", "(", "0", ",", "0", ")", "first_line", "=", "self", ".", "_readline", "(", ")", "try", ":", "self", "."...
Extract information from the header of the detector file
[ "Extract", "information", "from", "the", "header", "of", "the", "detector", "file" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L129-L148
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector.dom_positions
def dom_positions(self): """The positions of the DOMs, calculated from PMT directions.""" if not self._dom_positions: for dom_id in self.dom_ids: mask = self.pmts.dom_id == dom_id pmt_pos = self.pmts[mask].pos pmt_dir = self.pmts[mask].dir ...
python
def dom_positions(self): """The positions of the DOMs, calculated from PMT directions.""" if not self._dom_positions: for dom_id in self.dom_ids: mask = self.pmts.dom_id == dom_id pmt_pos = self.pmts[mask].pos pmt_dir = self.pmts[mask].dir ...
[ "def", "dom_positions", "(", "self", ")", ":", "if", "not", "self", ".", "_dom_positions", ":", "for", "dom_id", "in", "self", ".", "dom_ids", ":", "mask", "=", "self", ".", "pmts", ".", "dom_id", "==", "dom_id", "pmt_pos", "=", "self", ".", "pmts", ...
The positions of the DOMs, calculated from PMT directions.
[ "The", "positions", "of", "the", "DOMs", "calculated", "from", "PMT", "directions", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L252-L261
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector.dom_table
def dom_table(self): """A `Table` containing DOM attributes""" if self._dom_table is None: data = defaultdict(list) for dom_id, (du, floor, _) in self.doms.items(): data['dom_id'].append(dom_id) data['du'].append(du) data['floor'].a...
python
def dom_table(self): """A `Table` containing DOM attributes""" if self._dom_table is None: data = defaultdict(list) for dom_id, (du, floor, _) in self.doms.items(): data['dom_id'].append(dom_id) data['du'].append(du) data['floor'].a...
[ "def", "dom_table", "(", "self", ")", ":", "if", "self", ".", "_dom_table", "is", "None", ":", "data", "=", "defaultdict", "(", "list", ")", "for", "dom_id", ",", "(", "du", ",", "floor", ",", "_", ")", "in", "self", ".", "doms", ".", "items", "(...
A `Table` containing DOM attributes
[ "A", "Table", "containing", "DOM", "attributes" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L264-L277
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector.com
def com(self): """Center of mass, calculated from the mean of the PMT positions""" if self._com is None: self._com = np.mean(self.pmts.pos, axis=0) return self._com
python
def com(self): """Center of mass, calculated from the mean of the PMT positions""" if self._com is None: self._com = np.mean(self.pmts.pos, axis=0) return self._com
[ "def", "com", "(", "self", ")", ":", "if", "self", ".", "_com", "is", "None", ":", "self", ".", "_com", "=", "np", ".", "mean", "(", "self", ".", "pmts", ".", "pos", ",", "axis", "=", "0", ")", "return", "self", ".", "_com" ]
Center of mass, calculated from the mean of the PMT positions
[ "Center", "of", "mass", "calculated", "from", "the", "mean", "of", "the", "PMT", "positions" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L280-L284
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector.xy_positions
def xy_positions(self): """XY positions of the DUs, given by the DOMs on floor 1.""" if self._xy_positions is None or len(self._xy_positions) == 0: xy_pos = [] for dom_id, pos in self.dom_positions.items(): if self.domid2floor(dom_id) == 1: xy_...
python
def xy_positions(self): """XY positions of the DUs, given by the DOMs on floor 1.""" if self._xy_positions is None or len(self._xy_positions) == 0: xy_pos = [] for dom_id, pos in self.dom_positions.items(): if self.domid2floor(dom_id) == 1: xy_...
[ "def", "xy_positions", "(", "self", ")", ":", "if", "self", ".", "_xy_positions", "is", "None", "or", "len", "(", "self", ".", "_xy_positions", ")", "==", "0", ":", "xy_pos", "=", "[", "]", "for", "dom_id", ",", "pos", "in", "self", ".", "dom_positio...
XY positions of the DUs, given by the DOMs on floor 1.
[ "XY", "positions", "of", "the", "DUs", "given", "by", "the", "DOMs", "on", "floor", "1", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L287-L295
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector.translate_detector
def translate_detector(self, vector): """Translate the detector by a given vector""" vector = np.array(vector, dtype=float) self.pmts.pos_x += vector[0] self.pmts.pos_y += vector[1] self.pmts.pos_z += vector[2] self.reset_caches()
python
def translate_detector(self, vector): """Translate the detector by a given vector""" vector = np.array(vector, dtype=float) self.pmts.pos_x += vector[0] self.pmts.pos_y += vector[1] self.pmts.pos_z += vector[2] self.reset_caches()
[ "def", "translate_detector", "(", "self", ",", "vector", ")", ":", "vector", "=", "np", ".", "array", "(", "vector", ",", "dtype", "=", "float", ")", "self", ".", "pmts", ".", "pos_x", "+=", "vector", "[", "0", "]", "self", ".", "pmts", ".", "pos_y...
Translate the detector by a given vector
[ "Translate", "the", "detector", "by", "a", "given", "vector" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L297-L303
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector.pmt_angles
def pmt_angles(self): """A list of PMT directions sorted by PMT channel, on DU-1, floor-1""" if self._pmt_angles == []: mask = (self.pmts.du == 1) & (self.pmts.floor == 1) self._pmt_angles = self.pmts.dir[mask] return self._pmt_angles
python
def pmt_angles(self): """A list of PMT directions sorted by PMT channel, on DU-1, floor-1""" if self._pmt_angles == []: mask = (self.pmts.du == 1) & (self.pmts.floor == 1) self._pmt_angles = self.pmts.dir[mask] return self._pmt_angles
[ "def", "pmt_angles", "(", "self", ")", ":", "if", "self", ".", "_pmt_angles", "==", "[", "]", ":", "mask", "=", "(", "self", ".", "pmts", ".", "du", "==", "1", ")", "&", "(", "self", ".", "pmts", ".", "floor", "==", "1", ")", "self", ".", "_p...
A list of PMT directions sorted by PMT channel, on DU-1, floor-1
[ "A", "list", "of", "PMT", "directions", "sorted", "by", "PMT", "channel", "on", "DU", "-", "1", "floor", "-", "1" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L351-L356
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector.ascii
def ascii(self): """The ascii representation of the detector""" comments = '' if self.version == 'v3': for comment in self.comments: if not comment.startswith(' '): comment = ' ' + comment comments += "#" + comment + "\n" i...
python
def ascii(self): """The ascii representation of the detector""" comments = '' if self.version == 'v3': for comment in self.comments: if not comment.startswith(' '): comment = ' ' + comment comments += "#" + comment + "\n" i...
[ "def", "ascii", "(", "self", ")", ":", "comments", "=", "''", "if", "self", ".", "version", "==", "'v3'", ":", "for", "comment", "in", "self", ".", "comments", ":", "if", "not", "comment", ".", "startswith", "(", "' '", ")", ":", "comment", "=", "'...
The ascii representation of the detector
[ "The", "ascii", "representation", "of", "the", "detector" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L359-L389
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector.write
def write(self, filename): """Save detx file.""" with open(filename, 'w') as f: f.write(self.ascii) self.print("Detector file saved as '{0}'".format(filename))
python
def write(self, filename): """Save detx file.""" with open(filename, 'w') as f: f.write(self.ascii) self.print("Detector file saved as '{0}'".format(filename))
[ "def", "write", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "f", ".", "write", "(", "self", ".", "ascii", ")", "self", ".", "print", "(", "\"Detector file saved as '{0}'\"", ".", "format", ...
Save detx file.
[ "Save", "detx", "file", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L391-L395
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector.pmt_with_id
def pmt_with_id(self, pmt_id): """Get PMT with global pmt_id""" try: return self.pmts[self._pmt_index_by_pmt_id[pmt_id]] except KeyError: raise KeyError("No PMT found for ID: {0}".format(pmt_id))
python
def pmt_with_id(self, pmt_id): """Get PMT with global pmt_id""" try: return self.pmts[self._pmt_index_by_pmt_id[pmt_id]] except KeyError: raise KeyError("No PMT found for ID: {0}".format(pmt_id))
[ "def", "pmt_with_id", "(", "self", ",", "pmt_id", ")", ":", "try", ":", "return", "self", ".", "pmts", "[", "self", ".", "_pmt_index_by_pmt_id", "[", "pmt_id", "]", "]", "except", "KeyError", ":", "raise", "KeyError", "(", "\"No PMT found for ID: {0}\"", "."...
Get PMT with global pmt_id
[ "Get", "PMT", "with", "global", "pmt_id" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L397-L402
train
tamasgal/km3pipe
km3pipe/hardware.py
Detector.get_pmt
def get_pmt(self, dom_id, channel_id): """Return PMT with DOM ID and DAQ channel ID""" du, floor, _ = self.doms[dom_id] pmt = self.pmts[self._pmt_index_by_omkey[(du, floor, channel_id)]] return pmt
python
def get_pmt(self, dom_id, channel_id): """Return PMT with DOM ID and DAQ channel ID""" du, floor, _ = self.doms[dom_id] pmt = self.pmts[self._pmt_index_by_omkey[(du, floor, channel_id)]] return pmt
[ "def", "get_pmt", "(", "self", ",", "dom_id", ",", "channel_id", ")", ":", "du", ",", "floor", ",", "_", "=", "self", ".", "doms", "[", "dom_id", "]", "pmt", "=", "self", ".", "pmts", "[", "self", ".", "_pmt_index_by_omkey", "[", "(", "du", ",", ...
Return PMT with DOM ID and DAQ channel ID
[ "Return", "PMT", "with", "DOM", "ID", "and", "DAQ", "channel", "ID" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L404-L408
train
tamasgal/km3pipe
km3modules/mc.py
convert_mc_times_to_jte_times
def convert_mc_times_to_jte_times(times_mc, evt_timestamp_in_ns, evt_mc_time): """ Function that converts MC times to JTE times. Parameters ---------- times_mc : np.ndarray Time array with MC times. evt_timestamp_in_ns : int Total timestamp of the event in nanoseconds. evt_m...
python
def convert_mc_times_to_jte_times(times_mc, evt_timestamp_in_ns, evt_mc_time): """ Function that converts MC times to JTE times. Parameters ---------- times_mc : np.ndarray Time array with MC times. evt_timestamp_in_ns : int Total timestamp of the event in nanoseconds. evt_m...
[ "def", "convert_mc_times_to_jte_times", "(", "times_mc", ",", "evt_timestamp_in_ns", ",", "evt_mc_time", ")", ":", "times_mc", "=", "np", ".", "array", "(", "times_mc", ")", ".", "astype", "(", "float", ")", "times_jte", "=", "times_mc", "-", "evt_timestamp_in_n...
Function that converts MC times to JTE times. Parameters ---------- times_mc : np.ndarray Time array with MC times. evt_timestamp_in_ns : int Total timestamp of the event in nanoseconds. evt_mc_time : int Mc time of the event in nanoseconds. Returns ------- ndar...
[ "Function", "that", "converts", "MC", "times", "to", "JTE", "times", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3modules/mc.py#L86-L108
train
tamasgal/km3pipe
km3pipe/tools.py
iexists
def iexists(irods_path): """Returns True of iRODS path exists, otherwise False""" try: subprocess.check_output( 'ils {}'.format(irods_path), shell=True, stderr=subprocess.PIPE, ) return True except subprocess.CalledProcessError: return Fals...
python
def iexists(irods_path): """Returns True of iRODS path exists, otherwise False""" try: subprocess.check_output( 'ils {}'.format(irods_path), shell=True, stderr=subprocess.PIPE, ) return True except subprocess.CalledProcessError: return Fals...
[ "def", "iexists", "(", "irods_path", ")", ":", "try", ":", "subprocess", ".", "check_output", "(", "'ils {}'", ".", "format", "(", "irods_path", ")", ",", "shell", "=", "True", ",", "stderr", "=", "subprocess", ".", "PIPE", ",", ")", "return", "True", ...
Returns True of iRODS path exists, otherwise False
[ "Returns", "True", "of", "iRODS", "path", "exists", "otherwise", "False" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L42-L52
train
tamasgal/km3pipe
km3pipe/tools.py
token_urlsafe
def token_urlsafe(nbytes=32): """Return a random URL-safe text string, in Base64 encoding. This is taken and slightly modified from the Python 3.6 stdlib. The string has *nbytes* random bytes. If *nbytes* is ``None`` or not supplied, a reasonable default is used. >>> token_urlsafe(16) #doctest:...
python
def token_urlsafe(nbytes=32): """Return a random URL-safe text string, in Base64 encoding. This is taken and slightly modified from the Python 3.6 stdlib. The string has *nbytes* random bytes. If *nbytes* is ``None`` or not supplied, a reasonable default is used. >>> token_urlsafe(16) #doctest:...
[ "def", "token_urlsafe", "(", "nbytes", "=", "32", ")", ":", "tok", "=", "os", ".", "urandom", "(", "nbytes", ")", "return", "base64", ".", "urlsafe_b64encode", "(", "tok", ")", ".", "rstrip", "(", "b'='", ")", ".", "decode", "(", "'ascii'", ")" ]
Return a random URL-safe text string, in Base64 encoding. This is taken and slightly modified from the Python 3.6 stdlib. The string has *nbytes* random bytes. If *nbytes* is ``None`` or not supplied, a reasonable default is used. >>> token_urlsafe(16) #doctest:+SKIP 'Drmhze6EPcv0fN_81Bj-nA'
[ "Return", "a", "random", "URL", "-", "safe", "text", "string", "in", "Base64", "encoding", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L55-L68
train
tamasgal/km3pipe
km3pipe/tools.py
prettyln
def prettyln(text, fill='-', align='^', prefix='[ ', suffix=' ]', length=69): """Wrap `text` in a pretty line with maximum length.""" text = '{prefix}{0}{suffix}'.format(text, prefix=prefix, suffix=suffix) print( "{0:{fill}{align}{length}}".format( text, fill=fill, align=align, length=le...
python
def prettyln(text, fill='-', align='^', prefix='[ ', suffix=' ]', length=69): """Wrap `text` in a pretty line with maximum length.""" text = '{prefix}{0}{suffix}'.format(text, prefix=prefix, suffix=suffix) print( "{0:{fill}{align}{length}}".format( text, fill=fill, align=align, length=le...
[ "def", "prettyln", "(", "text", ",", "fill", "=", "'-'", ",", "align", "=", "'^'", ",", "prefix", "=", "'[ '", ",", "suffix", "=", "' ]'", ",", "length", "=", "69", ")", ":", "text", "=", "'{prefix}{0}{suffix}'", ".", "format", "(", "text", ",", "p...
Wrap `text` in a pretty line with maximum length.
[ "Wrap", "text", "in", "a", "pretty", "line", "with", "maximum", "length", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L77-L84
train
tamasgal/km3pipe
km3pipe/tools.py
unpack_nfirst
def unpack_nfirst(seq, nfirst): """Unpack the nfrist items from the list and return the rest. >>> a, b, c, rest = unpack_nfirst((1, 2, 3, 4, 5), 3) >>> a, b, c (1, 2, 3) >>> rest (4, 5) """ iterator = iter(seq) for _ in range(nfirst): yield next(iterator, None) yield tu...
python
def unpack_nfirst(seq, nfirst): """Unpack the nfrist items from the list and return the rest. >>> a, b, c, rest = unpack_nfirst((1, 2, 3, 4, 5), 3) >>> a, b, c (1, 2, 3) >>> rest (4, 5) """ iterator = iter(seq) for _ in range(nfirst): yield next(iterator, None) yield tu...
[ "def", "unpack_nfirst", "(", "seq", ",", "nfirst", ")", ":", "iterator", "=", "iter", "(", "seq", ")", "for", "_", "in", "range", "(", "nfirst", ")", ":", "yield", "next", "(", "iterator", ",", "None", ")", "yield", "tuple", "(", "iterator", ")" ]
Unpack the nfrist items from the list and return the rest. >>> a, b, c, rest = unpack_nfirst((1, 2, 3, 4, 5), 3) >>> a, b, c (1, 2, 3) >>> rest (4, 5)
[ "Unpack", "the", "nfrist", "items", "from", "the", "list", "and", "return", "the", "rest", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L98-L111
train
tamasgal/km3pipe
km3pipe/tools.py
split
def split(string, callback=None, sep=None): """Split the string and execute the callback function on each part. >>> string = "1 2 3 4" >>> parts = split(string, int) >>> parts [1, 2, 3, 4] """ if callback is not None: return [callback(i) for i in string.split(sep)] else: ...
python
def split(string, callback=None, sep=None): """Split the string and execute the callback function on each part. >>> string = "1 2 3 4" >>> parts = split(string, int) >>> parts [1, 2, 3, 4] """ if callback is not None: return [callback(i) for i in string.split(sep)] else: ...
[ "def", "split", "(", "string", ",", "callback", "=", "None", ",", "sep", "=", "None", ")", ":", "if", "callback", "is", "not", "None", ":", "return", "[", "callback", "(", "i", ")", "for", "i", "in", "string", ".", "split", "(", "sep", ")", "]", ...
Split the string and execute the callback function on each part. >>> string = "1 2 3 4" >>> parts = split(string, int) >>> parts [1, 2, 3, 4]
[ "Split", "the", "string", "and", "execute", "the", "callback", "function", "on", "each", "part", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L114-L126
train
tamasgal/km3pipe
km3pipe/tools.py
namedtuple_with_defaults
def namedtuple_with_defaults(typename, field_names, default_values=[]): """Create a namedtuple with default values >>> Node = namedtuple_with_defaults('Node', 'val left right') >>> Node() Node(val=None, left=None, right=None) >>> Node = namedtuple_with_defaults('Node', 'val left right', [1, 2, 3]) ...
python
def namedtuple_with_defaults(typename, field_names, default_values=[]): """Create a namedtuple with default values >>> Node = namedtuple_with_defaults('Node', 'val left right') >>> Node() Node(val=None, left=None, right=None) >>> Node = namedtuple_with_defaults('Node', 'val left right', [1, 2, 3]) ...
[ "def", "namedtuple_with_defaults", "(", "typename", ",", "field_names", ",", "default_values", "=", "[", "]", ")", ":", "the_tuple", "=", "collections", ".", "namedtuple", "(", "typename", ",", "field_names", ")", "the_tuple", ".", "__new__", ".", "__defaults__"...
Create a namedtuple with default values >>> Node = namedtuple_with_defaults('Node', 'val left right') >>> Node() Node(val=None, left=None, right=None) >>> Node = namedtuple_with_defaults('Node', 'val left right', [1, 2, 3]) >>> Node() Node(val=1, left=2, right=3) >>> Node = namedtuple_with_...
[ "Create", "a", "namedtuple", "with", "default", "values" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L129-L151
train
tamasgal/km3pipe
km3pipe/tools.py
remain_file_pointer
def remain_file_pointer(function): """Remain the file pointer position after calling the decorated function This decorator assumes that the last argument is the file handler. """ def wrapper(*args, **kwargs): """Wrap the function and remain its parameters and return values""" file_obj...
python
def remain_file_pointer(function): """Remain the file pointer position after calling the decorated function This decorator assumes that the last argument is the file handler. """ def wrapper(*args, **kwargs): """Wrap the function and remain its parameters and return values""" file_obj...
[ "def", "remain_file_pointer", "(", "function", ")", ":", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "file_obj", "=", "args", "[", "-", "1", "]", "old_position", "=", "file_obj", ".", "tell", "(", ")", "return_value", "=", "funct...
Remain the file pointer position after calling the decorated function This decorator assumes that the last argument is the file handler.
[ "Remain", "the", "file", "pointer", "position", "after", "calling", "the", "decorated", "function" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L154-L169
train
tamasgal/km3pipe
km3pipe/tools.py
decamelise
def decamelise(text): """Convert CamelCase to lower_and_underscore.""" s = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s).lower()
python
def decamelise(text): """Convert CamelCase to lower_and_underscore.""" s = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s).lower()
[ "def", "decamelise", "(", "text", ")", ":", "s", "=", "re", ".", "sub", "(", "'(.)([A-Z][a-z]+)'", ",", "r'\\1_\\2'", ",", "text", ")", "return", "re", ".", "sub", "(", "'([a-z0-9])([A-Z])'", ",", "r'\\1_\\2'", ",", "s", ")", ".", "lower", "(", ")" ]
Convert CamelCase to lower_and_underscore.
[ "Convert", "CamelCase", "to", "lower_and_underscore", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L180-L183
train
tamasgal/km3pipe
km3pipe/tools.py
camelise
def camelise(text, capital_first=True): """Convert lower_underscore to CamelCase.""" def camelcase(): if not capital_first: yield str.lower while True: yield str.capitalize if istype(text, 'unicode'): text = text.encode('utf8') c = camelcase() return...
python
def camelise(text, capital_first=True): """Convert lower_underscore to CamelCase.""" def camelcase(): if not capital_first: yield str.lower while True: yield str.capitalize if istype(text, 'unicode'): text = text.encode('utf8') c = camelcase() return...
[ "def", "camelise", "(", "text", ",", "capital_first", "=", "True", ")", ":", "def", "camelcase", "(", ")", ":", "if", "not", "capital_first", ":", "yield", "str", ".", "lower", "while", "True", ":", "yield", "str", ".", "capitalize", "if", "istype", "(...
Convert lower_underscore to CamelCase.
[ "Convert", "lower_underscore", "to", "CamelCase", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L186-L198
train
tamasgal/km3pipe
km3pipe/tools.py
colored
def colored(text, color=None, on_color=None, attrs=None, ansi_code=None): """Colorize text, while stripping nested ANSI color sequences. Author: Konstantin Lepa <konstantin.lepa@gmail.com> / termcolor Available text colors: red, green, yellow, blue, magenta, cyan, white. Available text highli...
python
def colored(text, color=None, on_color=None, attrs=None, ansi_code=None): """Colorize text, while stripping nested ANSI color sequences. Author: Konstantin Lepa <konstantin.lepa@gmail.com> / termcolor Available text colors: red, green, yellow, blue, magenta, cyan, white. Available text highli...
[ "def", "colored", "(", "text", ",", "color", "=", "None", ",", "on_color", "=", "None", ",", "attrs", "=", "None", ",", "ansi_code", "=", "None", ")", ":", "if", "os", ".", "getenv", "(", "'ANSI_COLORS_DISABLED'", ")", "is", "None", ":", "if", "ansi_...
Colorize text, while stripping nested ANSI color sequences. Author: Konstantin Lepa <konstantin.lepa@gmail.com> / termcolor Available text colors: red, green, yellow, blue, magenta, cyan, white. Available text highlights: on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white...
[ "Colorize", "text", "while", "stripping", "nested", "ANSI", "color", "sequences", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L247-L278
train
tamasgal/km3pipe
km3pipe/tools.py
zero_pad
def zero_pad(m, n=1): """Pad a matrix with zeros, on all sides.""" return np.pad(m, (n, n), mode='constant', constant_values=[0])
python
def zero_pad(m, n=1): """Pad a matrix with zeros, on all sides.""" return np.pad(m, (n, n), mode='constant', constant_values=[0])
[ "def", "zero_pad", "(", "m", ",", "n", "=", "1", ")", ":", "return", "np", ".", "pad", "(", "m", ",", "(", "n", ",", "n", ")", ",", "mode", "=", "'constant'", ",", "constant_values", "=", "[", "0", "]", ")" ]
Pad a matrix with zeros, on all sides.
[ "Pad", "a", "matrix", "with", "zeros", "on", "all", "sides", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L332-L334
train
tamasgal/km3pipe
km3pipe/tools.py
supports_color
def supports_color(): """Checks if the terminal supports color.""" if isnotebook(): return True supported_platform = sys.platform != 'win32' or 'ANSICON' in os.environ is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() if not supported_platform or not is_a_tty: return ...
python
def supports_color(): """Checks if the terminal supports color.""" if isnotebook(): return True supported_platform = sys.platform != 'win32' or 'ANSICON' in os.environ is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() if not supported_platform or not is_a_tty: return ...
[ "def", "supports_color", "(", ")", ":", "if", "isnotebook", "(", ")", ":", "return", "True", "supported_platform", "=", "sys", ".", "platform", "!=", "'win32'", "or", "'ANSICON'", "in", "os", ".", "environ", "is_a_tty", "=", "hasattr", "(", "sys", ".", "...
Checks if the terminal supports color.
[ "Checks", "if", "the", "terminal", "supports", "color", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L356-L366
train
tamasgal/km3pipe
km3pipe/tools.py
get_jpp_revision
def get_jpp_revision(via_command='JPrint'): """Retrieves the Jpp revision number""" try: output = subprocess.check_output([via_command, '-v'], stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: if e.returncode == 1: outpu...
python
def get_jpp_revision(via_command='JPrint'): """Retrieves the Jpp revision number""" try: output = subprocess.check_output([via_command, '-v'], stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: if e.returncode == 1: outpu...
[ "def", "get_jpp_revision", "(", "via_command", "=", "'JPrint'", ")", ":", "try", ":", "output", "=", "subprocess", ".", "check_output", "(", "[", "via_command", ",", "'-v'", "]", ",", "stderr", "=", "subprocess", ".", "STDOUT", ")", "except", "subprocess", ...
Retrieves the Jpp revision number
[ "Retrieves", "the", "Jpp", "revision", "number" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L369-L382
train
tamasgal/km3pipe
km3pipe/tools.py
timed_cache
def timed_cache(**timed_cache_kwargs): """LRU cache decorator with timeout. Parameters ---------- days: int seconds: int microseconds: int milliseconds: int minutes: int hours: int weeks: int maxsise: int [default: 128] typed: bool [default: False] """ def _wrap...
python
def timed_cache(**timed_cache_kwargs): """LRU cache decorator with timeout. Parameters ---------- days: int seconds: int microseconds: int milliseconds: int minutes: int hours: int weeks: int maxsise: int [default: 128] typed: bool [default: False] """ def _wrap...
[ "def", "timed_cache", "(", "**", "timed_cache_kwargs", ")", ":", "def", "_wrapper", "(", "f", ")", ":", "maxsize", "=", "timed_cache_kwargs", ".", "pop", "(", "'maxsize'", ",", "128", ")", "typed", "=", "timed_cache_kwargs", ".", "pop", "(", "'typed'", ","...
LRU cache decorator with timeout. Parameters ---------- days: int seconds: int microseconds: int milliseconds: int minutes: int hours: int weeks: int maxsise: int [default: 128] typed: bool [default: False]
[ "LRU", "cache", "decorator", "with", "timeout", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L385-L430
train
ioos/pyoos
pyoos/parsers/ioos/one/timeseries_profile.py
ProfileCache._get_point
def _get_point(self, profile, point): """ Finds the given point in the profile, or adds it in sorted z order. """ cur_points_z = [p.location.z for p in profile.elements] try: cur_idx = cur_points_z.index(point.z) return profile.elements[cur_idx] ex...
python
def _get_point(self, profile, point): """ Finds the given point in the profile, or adds it in sorted z order. """ cur_points_z = [p.location.z for p in profile.elements] try: cur_idx = cur_points_z.index(point.z) return profile.elements[cur_idx] ex...
[ "def", "_get_point", "(", "self", ",", "profile", ",", "point", ")", ":", "cur_points_z", "=", "[", "p", ".", "location", ".", "z", "for", "p", "in", "profile", ".", "elements", "]", "try", ":", "cur_idx", "=", "cur_points_z", ".", "index", "(", "poi...
Finds the given point in the profile, or adds it in sorted z order.
[ "Finds", "the", "given", "point", "in", "the", "profile", "or", "adds", "it", "in", "sorted", "z", "order", "." ]
908660385029ecd8eccda8ab3a6b20b47b915c77
https://github.com/ioos/pyoos/blob/908660385029ecd8eccda8ab3a6b20b47b915c77/pyoos/parsers/ioos/one/timeseries_profile.py#L74-L88
train
ioos/pyoos
pyoos/parsers/ioos/one/timeseries_profile.py
TimeSeriesProfile._parse_data_array
def _parse_data_array(self, data_array): """ Parses a general DataArray. """ # decimalSeparator = data_array.encoding.decimalSeparator tokenSeparator = data_array.encoding.tokenSeparator blockSeparator = data_array.encoding.blockSeparator # collapseWhiteSpaces = d...
python
def _parse_data_array(self, data_array): """ Parses a general DataArray. """ # decimalSeparator = data_array.encoding.decimalSeparator tokenSeparator = data_array.encoding.tokenSeparator blockSeparator = data_array.encoding.blockSeparator # collapseWhiteSpaces = d...
[ "def", "_parse_data_array", "(", "self", ",", "data_array", ")", ":", "tokenSeparator", "=", "data_array", ".", "encoding", ".", "tokenSeparator", "blockSeparator", "=", "data_array", ".", "encoding", ".", "blockSeparator", "data_values", "=", "data_array", ".", "...
Parses a general DataArray.
[ "Parses", "a", "general", "DataArray", "." ]
908660385029ecd8eccda8ab3a6b20b47b915c77
https://github.com/ioos/pyoos/blob/908660385029ecd8eccda8ab3a6b20b47b915c77/pyoos/parsers/ioos/one/timeseries_profile.py#L280-L306
train
ioos/pyoos
pyoos/parsers/ioos/one/timeseries_profile.py
TimeSeriesProfile._parse_sensor_record
def _parse_sensor_record(self, sensor_data_rec, sensor_info, rem_values): """ Parses values via sensor data record passed in. Returns parsed values AND how many items it consumed out of rem_values. """ val_idx = 0 # @TODO seems there is only a single field in each of the...
python
def _parse_sensor_record(self, sensor_data_rec, sensor_info, rem_values): """ Parses values via sensor data record passed in. Returns parsed values AND how many items it consumed out of rem_values. """ val_idx = 0 # @TODO seems there is only a single field in each of the...
[ "def", "_parse_sensor_record", "(", "self", ",", "sensor_data_rec", ",", "sensor_info", ",", "rem_values", ")", ":", "val_idx", "=", "0", "assert", "len", "(", "sensor_data_rec", ".", "field", ")", "==", "1", "sensor_data_array", "=", "sensor_data_rec", ".", "...
Parses values via sensor data record passed in. Returns parsed values AND how many items it consumed out of rem_values.
[ "Parses", "values", "via", "sensor", "data", "record", "passed", "in", ".", "Returns", "parsed", "values", "AND", "how", "many", "items", "it", "consumed", "out", "of", "rem_values", "." ]
908660385029ecd8eccda8ab3a6b20b47b915c77
https://github.com/ioos/pyoos/blob/908660385029ecd8eccda8ab3a6b20b47b915c77/pyoos/parsers/ioos/one/timeseries_profile.py#L393-L446
train
IRC-SPHERE/HyperStream
hyperstream/online_engine.py
OnlineEngine.execute
def execute(self, debug=False): """ Execute the engine - currently simple executes all workflows. """ if debug: # Set some default times for execution (debugging) start_time = datetime(year=2016, month=10, day=19, hour=12, minute=28, tzinfo=UTC) durat...
python
def execute(self, debug=False): """ Execute the engine - currently simple executes all workflows. """ if debug: # Set some default times for execution (debugging) start_time = datetime(year=2016, month=10, day=19, hour=12, minute=28, tzinfo=UTC) durat...
[ "def", "execute", "(", "self", ",", "debug", "=", "False", ")", ":", "if", "debug", ":", "start_time", "=", "datetime", "(", "year", "=", "2016", ",", "month", "=", "10", ",", "day", "=", "19", ",", "hour", "=", "12", ",", "minute", "=", "28", ...
Execute the engine - currently simple executes all workflows.
[ "Execute", "the", "engine", "-", "currently", "simple", "executes", "all", "workflows", "." ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/online_engine.py#L47-L85
train
NaPs/Kolekto
kolekto/commands/show.py
show
def show(movie): """ Show the movie metadata. """ for key, value in sorted(movie.iteritems(), cmp=metadata_sorter, key=lambda x: x[0]): if isinstance(value, list): if not value: continue other = value[1:] value = value[0] else: ...
python
def show(movie): """ Show the movie metadata. """ for key, value in sorted(movie.iteritems(), cmp=metadata_sorter, key=lambda x: x[0]): if isinstance(value, list): if not value: continue other = value[1:] value = value[0] else: ...
[ "def", "show", "(", "movie", ")", ":", "for", "key", ",", "value", "in", "sorted", "(", "movie", ".", "iteritems", "(", ")", ",", "cmp", "=", "metadata_sorter", ",", "key", "=", "lambda", "x", ":", "x", "[", "0", "]", ")", ":", "if", "isinstance"...
Show the movie metadata.
[ "Show", "the", "movie", "metadata", "." ]
29c5469da8782780a06bf9a76c59414bb6fd8fe3
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/show.py#L11-L24
train
NaPs/Kolekto
kolekto/commands/show.py
metadata_sorter
def metadata_sorter(x, y): """ Sort metadata keys by priority. """ if x == y: return 0 if x in METADATA_SORTER_FIRST and y in METADATA_SORTER_FIRST: return -1 if METADATA_SORTER_FIRST.index(x) < METADATA_SORTER_FIRST.index(y) else 1 elif x in METADATA_SORTER_FIRST: return -1 ...
python
def metadata_sorter(x, y): """ Sort metadata keys by priority. """ if x == y: return 0 if x in METADATA_SORTER_FIRST and y in METADATA_SORTER_FIRST: return -1 if METADATA_SORTER_FIRST.index(x) < METADATA_SORTER_FIRST.index(y) else 1 elif x in METADATA_SORTER_FIRST: return -1 ...
[ "def", "metadata_sorter", "(", "x", ",", "y", ")", ":", "if", "x", "==", "y", ":", "return", "0", "if", "x", "in", "METADATA_SORTER_FIRST", "and", "y", "in", "METADATA_SORTER_FIRST", ":", "return", "-", "1", "if", "METADATA_SORTER_FIRST", ".", "index", "...
Sort metadata keys by priority.
[ "Sort", "metadata", "keys", "by", "priority", "." ]
29c5469da8782780a06bf9a76c59414bb6fd8fe3
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/show.py#L27-L46
train
finklabs/korg
korg/korg.py
parse_lines
def parse_lines(log_parsers, fileinp): """parse lines from the fileinput and send them to the log_parsers""" while 1: logentry = fileinp.readline() if not logentry: break elif not logentry.rstrip(): continue # skip newlines processed = False for ...
python
def parse_lines(log_parsers, fileinp): """parse lines from the fileinput and send them to the log_parsers""" while 1: logentry = fileinp.readline() if not logentry: break elif not logentry.rstrip(): continue # skip newlines processed = False for ...
[ "def", "parse_lines", "(", "log_parsers", ",", "fileinp", ")", ":", "while", "1", ":", "logentry", "=", "fileinp", ".", "readline", "(", ")", "if", "not", "logentry", ":", "break", "elif", "not", "logentry", ".", "rstrip", "(", ")", ":", "continue", "p...
parse lines from the fileinput and send them to the log_parsers
[ "parse", "lines", "from", "the", "fileinput", "and", "send", "them", "to", "the", "log_parsers" ]
e931a673ce4bc79cdf26cb4f697fa23fa8a72e4f
https://github.com/finklabs/korg/blob/e931a673ce4bc79cdf26cb4f697fa23fa8a72e4f/korg/korg.py#L24-L44
train
NaPs/Kolekto
kolekto/profiles/__init__.py
Profile.load_commands
def load_commands(self, parser): """ Load commands of this profile. :param parser: argparse parser on which to add commands """ entrypoints = self._get_entrypoints() already_loaded = set() for entrypoint in entrypoints: if entrypoint.name not in already_loa...
python
def load_commands(self, parser): """ Load commands of this profile. :param parser: argparse parser on which to add commands """ entrypoints = self._get_entrypoints() already_loaded = set() for entrypoint in entrypoints: if entrypoint.name not in already_loa...
[ "def", "load_commands", "(", "self", ",", "parser", ")", ":", "entrypoints", "=", "self", ".", "_get_entrypoints", "(", ")", "already_loaded", "=", "set", "(", ")", "for", "entrypoint", "in", "entrypoints", ":", "if", "entrypoint", ".", "name", "not", "in"...
Load commands of this profile. :param parser: argparse parser on which to add commands
[ "Load", "commands", "of", "this", "profile", "." ]
29c5469da8782780a06bf9a76c59414bb6fd8fe3
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/profiles/__init__.py#L19-L32
train