repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
Duke-GCB/DukeDSClient
ddsc/core/parallel.py
TaskRunner._add_sub_tasks_to_executor
def _add_sub_tasks_to_executor(self, parent_task, parent_task_result): """ Add all subtasks for parent_task to the executor. :param parent_task: Task: task that has just finished :param parent_task_result: object: result of task that is finished """ for sub_task in self.w...
python
def _add_sub_tasks_to_executor(self, parent_task, parent_task_result): """ Add all subtasks for parent_task to the executor. :param parent_task: Task: task that has just finished :param parent_task_result: object: result of task that is finished """ for sub_task in self.w...
[ "def", "_add_sub_tasks_to_executor", "(", "self", ",", "parent_task", ",", "parent_task_result", ")", ":", "for", "sub_task", "in", "self", ".", "waiting_task_list", ".", "get_next_tasks", "(", "parent_task", ".", "id", ")", ":", "self", ".", "executor", ".", ...
Add all subtasks for parent_task to the executor. :param parent_task: Task: task that has just finished :param parent_task_result: object: result of task that is finished
[ "Add", "all", "subtasks", "for", "parent_task", "to", "the", "executor", ".", ":", "param", "parent_task", ":", "Task", ":", "task", "that", "has", "just", "finished", ":", "param", "parent_task_result", ":", "object", ":", "result", "of", "task", "that", ...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/parallel.py#L143-L150
Duke-GCB/DukeDSClient
ddsc/core/parallel.py
TaskExecutor.add_task
def add_task(self, task, parent_task_result): """ Add a task to run with the specified result from this tasks parent(can be None) :param task: Task: task that should be run :param parent_task_result: object: value to be passed to task for setup """ self.tasks.append((task...
python
def add_task(self, task, parent_task_result): """ Add a task to run with the specified result from this tasks parent(can be None) :param task: Task: task that should be run :param parent_task_result: object: value to be passed to task for setup """ self.tasks.append((task...
[ "def", "add_task", "(", "self", ",", "task", ",", "parent_task_result", ")", ":", "self", ".", "tasks", ".", "append", "(", "(", "task", ",", "parent_task_result", ")", ")", "self", ".", "task_id_to_task", "[", "task", ".", "id", "]", "=", "task" ]
Add a task to run with the specified result from this tasks parent(can be None) :param task: Task: task that should be run :param parent_task_result: object: value to be passed to task for setup
[ "Add", "a", "task", "to", "run", "with", "the", "specified", "result", "from", "this", "tasks", "parent", "(", "can", "be", "None", ")", ":", "param", "task", ":", "Task", ":", "task", "that", "should", "be", "run", ":", "param", "parent_task_result", ...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/parallel.py#L169-L176
Duke-GCB/DukeDSClient
ddsc/core/parallel.py
TaskExecutor.wait_for_tasks
def wait_for_tasks(self): """ Wait for one or more tasks to finish or return empty list if we are done. Starts new tasks if we have less than task_at_once currently running. :return: [(Task,object)]: list of (task,result) for finished tasks """ finished_tasks_and_results ...
python
def wait_for_tasks(self): """ Wait for one or more tasks to finish or return empty list if we are done. Starts new tasks if we have less than task_at_once currently running. :return: [(Task,object)]: list of (task,result) for finished tasks """ finished_tasks_and_results ...
[ "def", "wait_for_tasks", "(", "self", ")", ":", "finished_tasks_and_results", "=", "[", "]", "while", "len", "(", "finished_tasks_and_results", ")", "==", "0", ":", "if", "self", ".", "is_done", "(", ")", ":", "break", "self", ".", "start_tasks", "(", ")",...
Wait for one or more tasks to finish or return empty list if we are done. Starts new tasks if we have less than task_at_once currently running. :return: [(Task,object)]: list of (task,result) for finished tasks
[ "Wait", "for", "one", "or", "more", "tasks", "to", "finish", "or", "return", "empty", "list", "if", "we", "are", "done", ".", "Starts", "new", "tasks", "if", "we", "have", "less", "than", "task_at_once", "currently", "running", ".", ":", "return", ":", ...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/parallel.py#L191-L204
Duke-GCB/DukeDSClient
ddsc/core/parallel.py
TaskExecutor.start_tasks
def start_tasks(self): """ Start however many tasks we can based on our limits and what we have left to finish. """ while self.tasks_at_once > len(self.pending_results) and self._has_more_tasks(): task, parent_result = self.tasks.popleft() self.execute_task(task, ...
python
def start_tasks(self): """ Start however many tasks we can based on our limits and what we have left to finish. """ while self.tasks_at_once > len(self.pending_results) and self._has_more_tasks(): task, parent_result = self.tasks.popleft() self.execute_task(task, ...
[ "def", "start_tasks", "(", "self", ")", ":", "while", "self", ".", "tasks_at_once", ">", "len", "(", "self", ".", "pending_results", ")", "and", "self", ".", "_has_more_tasks", "(", ")", ":", "task", ",", "parent_result", "=", "self", ".", "tasks", ".", ...
Start however many tasks we can based on our limits and what we have left to finish.
[ "Start", "however", "many", "tasks", "we", "can", "based", "on", "our", "limits", "and", "what", "we", "have", "left", "to", "finish", "." ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/parallel.py#L206-L212
Duke-GCB/DukeDSClient
ddsc/core/parallel.py
TaskExecutor.execute_task
def execute_task(self, task, parent_result): """ Run a single task in another process saving the result to our list of pending results. :param task: Task: function and data we can run in another process :param parent_result: object: result from our parent task """ task.be...
python
def execute_task(self, task, parent_result): """ Run a single task in another process saving the result to our list of pending results. :param task: Task: function and data we can run in another process :param parent_result: object: result from our parent task """ task.be...
[ "def", "execute_task", "(", "self", ",", "task", ",", "parent_result", ")", ":", "task", ".", "before_run", "(", "parent_result", ")", "context", "=", "task", ".", "create_context", "(", "self", ".", "message_queue", ")", "pending_result", "=", "self", ".", ...
Run a single task in another process saving the result to our list of pending results. :param task: Task: function and data we can run in another process :param parent_result: object: result from our parent task
[ "Run", "a", "single", "task", "in", "another", "process", "saving", "the", "result", "to", "our", "list", "of", "pending", "results", ".", ":", "param", "task", ":", "Task", ":", "function", "and", "data", "we", "can", "run", "in", "another", "process", ...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/parallel.py#L214-L223
Duke-GCB/DukeDSClient
ddsc/core/parallel.py
TaskExecutor.process_single_message_from_queue
def process_single_message_from_queue(self): """ Tries to read a single message from the queue and let the associated task process it. :return: bool: True if we processed a message, otherwise False """ try: message = self.message_queue.get_nowait() task_id...
python
def process_single_message_from_queue(self): """ Tries to read a single message from the queue and let the associated task process it. :return: bool: True if we processed a message, otherwise False """ try: message = self.message_queue.get_nowait() task_id...
[ "def", "process_single_message_from_queue", "(", "self", ")", ":", "try", ":", "message", "=", "self", ".", "message_queue", ".", "get_nowait", "(", ")", "task_id", ",", "data", "=", "message", "task", "=", "self", ".", "task_id_to_task", "[", "task_id", "]"...
Tries to read a single message from the queue and let the associated task process it. :return: bool: True if we processed a message, otherwise False
[ "Tries", "to", "read", "a", "single", "message", "from", "the", "queue", "and", "let", "the", "associated", "task", "process", "it", ".", ":", "return", ":", "bool", ":", "True", "if", "we", "processed", "a", "message", "otherwise", "False" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/parallel.py#L233-L245
Duke-GCB/DukeDSClient
ddsc/core/parallel.py
TaskExecutor.get_finished_results
def get_finished_results(self): """ Go through pending results and retrieve the results if they are done. Then start child tasks for the task that finished. """ task_and_results = [] for pending_result in self.pending_results: if pending_result.ready(): ...
python
def get_finished_results(self): """ Go through pending results and retrieve the results if they are done. Then start child tasks for the task that finished. """ task_and_results = [] for pending_result in self.pending_results: if pending_result.ready(): ...
[ "def", "get_finished_results", "(", "self", ")", ":", "task_and_results", "=", "[", "]", "for", "pending_result", "in", "self", ".", "pending_results", ":", "if", "pending_result", ".", "ready", "(", ")", ":", "ret", "=", "pending_result", ".", "get", "(", ...
Go through pending results and retrieve the results if they are done. Then start child tasks for the task that finished.
[ "Go", "through", "pending", "results", "and", "retrieve", "the", "results", "if", "they", "are", "done", ".", "Then", "start", "child", "tasks", "for", "the", "task", "that", "finished", "." ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/parallel.py#L247-L263
twisted/txaws
txaws/route53/_util.py
to_xml
def to_xml(body_element): """ Serialize a L{twisted.web.template.Tag} to a UTF-8 encoded XML document with an XML doctype header. """ doctype = b"""<?xml version="1.0" encoding="UTF-8"?>\n""" if body_element is None: return succeed(b"") d = flattenString(None, body_element) d.add...
python
def to_xml(body_element): """ Serialize a L{twisted.web.template.Tag} to a UTF-8 encoded XML document with an XML doctype header. """ doctype = b"""<?xml version="1.0" encoding="UTF-8"?>\n""" if body_element is None: return succeed(b"") d = flattenString(None, body_element) d.add...
[ "def", "to_xml", "(", "body_element", ")", ":", "doctype", "=", "b\"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n\"\"\"", "if", "body_element", "is", "None", ":", "return", "succeed", "(", "b\"\"", ")", "d", "=", "flattenString", "(", "None", ",", "body_element"...
Serialize a L{twisted.web.template.Tag} to a UTF-8 encoded XML document with an XML doctype header.
[ "Serialize", "a", "L", "{", "twisted", ".", "web", ".", "template", ".", "Tag", "}", "to", "a", "UTF", "-", "8", "encoded", "XML", "document", "with", "an", "XML", "doctype", "header", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/route53/_util.py#L31-L41
twisted/txaws
txaws/route53/client.py
get_route53_client
def get_route53_client(agent, region, cooperator=None): """ Get a non-registration Route53 client. """ if cooperator is None: cooperator = task return region.get_client( _Route53Client, agent=agent, creds=region.creds, region=REGION_US_EAST_1, endpoint...
python
def get_route53_client(agent, region, cooperator=None): """ Get a non-registration Route53 client. """ if cooperator is None: cooperator = task return region.get_client( _Route53Client, agent=agent, creds=region.creds, region=REGION_US_EAST_1, endpoint...
[ "def", "get_route53_client", "(", "agent", ",", "region", ",", "cooperator", "=", "None", ")", ":", "if", "cooperator", "is", "None", ":", "cooperator", "=", "task", "return", "region", ".", "get_client", "(", "_Route53Client", ",", "agent", "=", "agent", ...
Get a non-registration Route53 client.
[ "Get", "a", "non", "-", "registration", "Route53", "client", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/route53/client.py#L60-L73
twisted/txaws
txaws/route53/client.py
_route53_op
def _route53_op(body=None, **kw): """ Construct an L{_Operation} representing a I{Route53} service API call. """ op = _Operation(service=b"route53", **kw) if body is None: return succeed(op) d = to_xml(body) d.addCallback(lambda body: attr.assoc(op, body=body)) return d
python
def _route53_op(body=None, **kw): """ Construct an L{_Operation} representing a I{Route53} service API call. """ op = _Operation(service=b"route53", **kw) if body is None: return succeed(op) d = to_xml(body) d.addCallback(lambda body: attr.assoc(op, body=body)) return d
[ "def", "_route53_op", "(", "body", "=", "None", ",", "*", "*", "kw", ")", ":", "op", "=", "_Operation", "(", "service", "=", "b\"route53\"", ",", "*", "*", "kw", ")", "if", "body", "is", "None", ":", "return", "succeed", "(", "op", ")", "d", "=",...
Construct an L{_Operation} representing a I{Route53} service API call.
[ "Construct", "an", "L", "{", "_Operation", "}", "representing", "a", "I", "{", "Route53", "}", "service", "API", "call", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/route53/client.py#L340-L349
twisted/txaws
txaws/route53/client.py
hostedzone_from_element
def hostedzone_from_element(zone): """ Construct a L{HostedZone} instance from a I{HostedZone} XML element. """ return HostedZone( name=maybe_bytes_to_unicode(zone.find("Name").text).encode("ascii").decode("idna"), identifier=maybe_bytes_to_unicode(zone.find("Id").text).replace(u"/hosted...
python
def hostedzone_from_element(zone): """ Construct a L{HostedZone} instance from a I{HostedZone} XML element. """ return HostedZone( name=maybe_bytes_to_unicode(zone.find("Name").text).encode("ascii").decode("idna"), identifier=maybe_bytes_to_unicode(zone.find("Id").text).replace(u"/hosted...
[ "def", "hostedzone_from_element", "(", "zone", ")", ":", "return", "HostedZone", "(", "name", "=", "maybe_bytes_to_unicode", "(", "zone", ".", "find", "(", "\"Name\"", ")", ".", "text", ")", ".", "encode", "(", "\"ascii\"", ")", ".", "decode", "(", "\"idna...
Construct a L{HostedZone} instance from a I{HostedZone} XML element.
[ "Construct", "a", "L", "{", "HostedZone", "}", "instance", "from", "a", "I", "{", "HostedZone", "}", "XML", "element", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/route53/client.py#L388-L397
twisted/txaws
txaws/route53/client.py
to_element
def to_element(change): """ @param change: An L{txaws.route53.interface.IRRSetChange} provider. @return: The L{twisted.web.template} element which describes this change. """ return tags.Change( tags.Action( change.action, ), tags.ResourceRecordSet( ...
python
def to_element(change): """ @param change: An L{txaws.route53.interface.IRRSetChange} provider. @return: The L{twisted.web.template} element which describes this change. """ return tags.Change( tags.Action( change.action, ), tags.ResourceRecordSet( ...
[ "def", "to_element", "(", "change", ")", ":", "return", "tags", ".", "Change", "(", "tags", ".", "Action", "(", "change", ".", "action", ",", ")", ",", "tags", ".", "ResourceRecordSet", "(", "tags", ".", "Name", "(", "unicode", "(", "change", ".", "r...
@param change: An L{txaws.route53.interface.IRRSetChange} provider. @return: The L{twisted.web.template} element which describes this change.
[ "@param", "change", ":", "An", "L", "{", "txaws", ".", "route53", ".", "interface", ".", "IRRSetChange", "}", "provider", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/route53/client.py#L400-L427
twisted/txaws
txaws/server/registry.py
Registry.add
def add(self, method_class, action, version=None): """Add a method class to the regitry. @param method_class: The method class to add @param action: The action that the method class can handle @param version: The version that the method class can handle """ by_version = ...
python
def add(self, method_class, action, version=None): """Add a method class to the regitry. @param method_class: The method class to add @param action: The action that the method class can handle @param version: The version that the method class can handle """ by_version = ...
[ "def", "add", "(", "self", ",", "method_class", ",", "action", ",", "version", "=", "None", ")", ":", "by_version", "=", "self", ".", "_by_action", ".", "setdefault", "(", "action", ",", "{", "}", ")", "if", "version", "in", "by_version", ":", "raise",...
Add a method class to the regitry. @param method_class: The method class to add @param action: The action that the method class can handle @param version: The version that the method class can handle
[ "Add", "a", "method", "class", "to", "the", "regitry", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/registry.py#L10-L21
twisted/txaws
txaws/server/registry.py
Registry.check
def check(self, action, version=None): """Check if the given action is supported in the given version. @raises APIError: If there's no method class registered for handling the given action or version. """ if action not in self._by_action: raise APIError(400, "Inv...
python
def check(self, action, version=None): """Check if the given action is supported in the given version. @raises APIError: If there's no method class registered for handling the given action or version. """ if action not in self._by_action: raise APIError(400, "Inv...
[ "def", "check", "(", "self", ",", "action", ",", "version", "=", "None", ")", ":", "if", "action", "not", "in", "self", ".", "_by_action", ":", "raise", "APIError", "(", "400", ",", "\"InvalidAction\"", ",", "\"The action %s is not valid \"", "\"for this web s...
Check if the given action is supported in the given version. @raises APIError: If there's no method class registered for handling the given action or version.
[ "Check", "if", "the", "given", "action", "is", "supported", "in", "the", "given", "version", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/registry.py#L23-L36
twisted/txaws
txaws/server/registry.py
Registry.get
def get(self, action, version=None): """Get the method class handing the given action and version.""" by_version = self._by_action[action] if version in by_version: return by_version[version] else: return by_version[None]
python
def get(self, action, version=None): """Get the method class handing the given action and version.""" by_version = self._by_action[action] if version in by_version: return by_version[version] else: return by_version[None]
[ "def", "get", "(", "self", ",", "action", ",", "version", "=", "None", ")", ":", "by_version", "=", "self", ".", "_by_action", "[", "action", "]", "if", "version", "in", "by_version", ":", "return", "by_version", "[", "version", "]", "else", ":", "retu...
Get the method class handing the given action and version.
[ "Get", "the", "method", "class", "handing", "the", "given", "action", "and", "version", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/registry.py#L38-L44
twisted/txaws
txaws/server/registry.py
Registry.scan
def scan(self, module, onerror=None, ignore=None): """Scan the given module object for L{Method}s and register them.""" from venusian import Scanner scanner = Scanner(registry=self) kwargs = {"onerror": onerror, "categories": ["method"]} if ignore is not None: # Only ...
python
def scan(self, module, onerror=None, ignore=None): """Scan the given module object for L{Method}s and register them.""" from venusian import Scanner scanner = Scanner(registry=self) kwargs = {"onerror": onerror, "categories": ["method"]} if ignore is not None: # Only ...
[ "def", "scan", "(", "self", ",", "module", ",", "onerror", "=", "None", ",", "ignore", "=", "None", ")", ":", "from", "venusian", "import", "Scanner", "scanner", "=", "Scanner", "(", "registry", "=", "self", ")", "kwargs", "=", "{", "\"onerror\"", ":",...
Scan the given module object for L{Method}s and register them.
[ "Scan", "the", "given", "module", "object", "for", "L", "{", "Method", "}", "s", "and", "register", "them", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/registry.py#L46-L54
T-002/pycast
pycast/methods/regression.py
Regression.calculate_parameters
def calculate_parameters(self, independentTs, dependentTs): """Calculate and return the parameters for the regression line Return the parameter for the line describing the relationship between the input variables. :param Timeseries independentTs: The Timeseries used for the ...
python
def calculate_parameters(self, independentTs, dependentTs): """Calculate and return the parameters for the regression line Return the parameter for the line describing the relationship between the input variables. :param Timeseries independentTs: The Timeseries used for the ...
[ "def", "calculate_parameters", "(", "self", ",", "independentTs", ",", "dependentTs", ")", ":", "listX", ",", "listY", "=", "self", ".", "match_time_series", "(", "independentTs", ",", "dependentTs", ")", "if", "len", "(", "listX", ")", "==", "0", "or", "l...
Calculate and return the parameters for the regression line Return the parameter for the line describing the relationship between the input variables. :param Timeseries independentTs: The Timeseries used for the independent variable (x-axis). The Timeseries must have at...
[ "Calculate", "and", "return", "the", "parameters", "for", "the", "regression", "line" ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/regression.py#L35-L79
T-002/pycast
pycast/methods/regression.py
Regression.calculate_parameters_with_confidence
def calculate_parameters_with_confidence(self, independentTs, dependentTs, confidenceLevel, samplePercentage=.1): """Same functionality as calculate_parameters, just that additionally the confidence interval for a given confidenceLevel is calculated. This is done based on a sample of the depende...
python
def calculate_parameters_with_confidence(self, independentTs, dependentTs, confidenceLevel, samplePercentage=.1): """Same functionality as calculate_parameters, just that additionally the confidence interval for a given confidenceLevel is calculated. This is done based on a sample of the depende...
[ "def", "calculate_parameters_with_confidence", "(", "self", ",", "independentTs", ",", "dependentTs", ",", "confidenceLevel", ",", "samplePercentage", "=", ".1", ")", ":", "#First split the time series into sample and training data", "sampleY", ",", "trainingY", "=", "depen...
Same functionality as calculate_parameters, just that additionally the confidence interval for a given confidenceLevel is calculated. This is done based on a sample of the dependentTs training data that is validated against the prediction. The signed error of the predictions and the sample is th...
[ "Same", "functionality", "as", "calculate_parameters", "just", "that", "additionally", "the", "confidence", "interval", "for", "a", "given", "confidenceLevel", "is", "calculated", ".", "This", "is", "done", "based", "on", "a", "sample", "of", "the", "dependentTs",...
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/regression.py#L81-L128
T-002/pycast
pycast/methods/regression.py
Regression.predict
def predict(self, timeseriesX, n, m): """ Calculates the dependent timeseries Y for the given parameters and independent timeseries. (y=m*x + n) :param TimeSeries timeseriesX: the independent Timeseries. :param float n: The interception with the x access that has be...
python
def predict(self, timeseriesX, n, m): """ Calculates the dependent timeseries Y for the given parameters and independent timeseries. (y=m*x + n) :param TimeSeries timeseriesX: the independent Timeseries. :param float n: The interception with the x access that has be...
[ "def", "predict", "(", "self", ",", "timeseriesX", ",", "n", ",", "m", ")", ":", "new_entries", "=", "[", "]", "for", "entry", "in", "timeseriesX", ":", "predicted_value", "=", "m", "*", "entry", "[", "1", "]", "+", "n", "new_entries", ".", "append",...
Calculates the dependent timeseries Y for the given parameters and independent timeseries. (y=m*x + n) :param TimeSeries timeseriesX: the independent Timeseries. :param float n: The interception with the x access that has been calculated during regression :param float m: T...
[ "Calculates", "the", "dependent", "timeseries", "Y", "for", "the", "given", "parameters", "and", "independent", "timeseries", ".", "(", "y", "=", "m", "*", "x", "+", "n", ")" ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/regression.py#L130-L151
T-002/pycast
pycast/methods/regression.py
Regression.match_time_series
def match_time_series(self, timeseries1, timeseries2): """Return two lists of the two input time series with matching dates :param TimeSeries timeseries1: The first timeseries :param TimeSeries timeseries2: The second timeseries :return: Two two dimensional lists containing the match...
python
def match_time_series(self, timeseries1, timeseries2): """Return two lists of the two input time series with matching dates :param TimeSeries timeseries1: The first timeseries :param TimeSeries timeseries2: The second timeseries :return: Two two dimensional lists containing the match...
[ "def", "match_time_series", "(", "self", ",", "timeseries1", ",", "timeseries2", ")", ":", "time1", "=", "map", "(", "lambda", "item", ":", "item", "[", "0", "]", ",", "timeseries1", ".", "to_twodim_list", "(", ")", ")", "time2", "=", "map", "(", "lamb...
Return two lists of the two input time series with matching dates :param TimeSeries timeseries1: The first timeseries :param TimeSeries timeseries2: The second timeseries :return: Two two dimensional lists containing the matched values, :rtype: two List
[ "Return", "two", "lists", "of", "the", "two", "input", "time", "series", "with", "matching", "dates" ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/regression.py#L153-L168
T-002/pycast
pycast/methods/regression.py
LinearRegression.lstsq
def lstsq(cls, a, b): """Return the least-squares solution to a linear matrix equation. :param Matrix a: Design matrix with the values of the independent variables. :param Matrix b: Matrix with the "dependent variable" values. b can only have one column. ...
python
def lstsq(cls, a, b): """Return the least-squares solution to a linear matrix equation. :param Matrix a: Design matrix with the values of the independent variables. :param Matrix b: Matrix with the "dependent variable" values. b can only have one column. ...
[ "def", "lstsq", "(", "cls", ",", "a", ",", "b", ")", ":", "# Check if the size of the input matrices matches", "if", "a", ".", "get_height", "(", ")", "!=", "b", ".", "get_height", "(", ")", ":", "raise", "ValueError", "(", "\"Size of input matrices does not mat...
Return the least-squares solution to a linear matrix equation. :param Matrix a: Design matrix with the values of the independent variables. :param Matrix b: Matrix with the "dependent variable" values. b can only have one column. :raise: Raises an ...
[ "Return", "the", "least", "-", "squares", "solution", "to", "a", "linear", "matrix", "equation", "." ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/regression.py#L174-L200
T-002/pycast
pycast/errors/meanabsolutepercentageerror.py
MeanAbsolutePercentageError._calculate
def _calculate(self, startingPercentage, endPercentage, startDate, endDate): """This is the error calculation function that gets called by :py:meth:`BaseErrorMeasure.get_error`. Both parameters will be correct at this time. :param float startingPercentage: Defines the start of the interval. Th...
python
def _calculate(self, startingPercentage, endPercentage, startDate, endDate): """This is the error calculation function that gets called by :py:meth:`BaseErrorMeasure.get_error`. Both parameters will be correct at this time. :param float startingPercentage: Defines the start of the interval. Th...
[ "def", "_calculate", "(", "self", ",", "startingPercentage", ",", "endPercentage", ",", "startDate", ",", "endDate", ")", ":", "# get the defined subset of error values", "errorValues", "=", "self", ".", "_get_error_values", "(", "startingPercentage", ",", "endPercentag...
This is the error calculation function that gets called by :py:meth:`BaseErrorMeasure.get_error`. Both parameters will be correct at this time. :param float startingPercentage: Defines the start of the interval. This has to be a value in [0.0, 100.0]. It represents the value, where the err...
[ "This", "is", "the", "error", "calculation", "function", "that", "gets", "called", "by", ":", "py", ":", "meth", ":", "BaseErrorMeasure", ".", "get_error", "." ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/errors/meanabsolutepercentageerror.py#L30-L51
T-002/pycast
pycast/errors/meanabsolutepercentageerror.py
MeanAbsolutePercentageError.local_error
def local_error(self, originalValue, calculatedValue): """Calculates the error between the two given values. :param list originalValue: List containing the values of the original data. :param list calculatedValue: List containing the values of the calculated TimeSeries that co...
python
def local_error(self, originalValue, calculatedValue): """Calculates the error between the two given values. :param list originalValue: List containing the values of the original data. :param list calculatedValue: List containing the values of the calculated TimeSeries that co...
[ "def", "local_error", "(", "self", ",", "originalValue", ",", "calculatedValue", ")", ":", "originalValue", "=", "originalValue", "[", "0", "]", "calculatedValue", "=", "calculatedValue", "[", "0", "]", "if", "0", "==", "originalValue", ":", "return", "None", ...
Calculates the error between the two given values. :param list originalValue: List containing the values of the original data. :param list calculatedValue: List containing the values of the calculated TimeSeries that corresponds to originalValue. :return: Returns the error...
[ "Calculates", "the", "error", "between", "the", "two", "given", "values", "." ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/errors/meanabsolutepercentageerror.py#L53-L69
T-002/pycast
pycast/errors/meanabsolutescalederror.py
MeanAbsoluteScaledError._get_historic_means
def _get_historic_means(self, timeSeries): """Calculates the mean value for the history of the MeanAbsoluteScaledError. :param TimeSeries timeSeries: Original TimeSeries used to calculate the mean historic values. :return: Returns a list containing the historic means. :rtype: lis...
python
def _get_historic_means(self, timeSeries): """Calculates the mean value for the history of the MeanAbsoluteScaledError. :param TimeSeries timeSeries: Original TimeSeries used to calculate the mean historic values. :return: Returns a list containing the historic means. :rtype: lis...
[ "def", "_get_historic_means", "(", "self", ",", "timeSeries", ")", ":", "# calculate the history values", "historyLength", "=", "self", ".", "_historyLength", "historicMeans", "=", "[", "]", "append", "=", "historicMeans", ".", "append", "# not most optimized loop in ca...
Calculates the mean value for the history of the MeanAbsoluteScaledError. :param TimeSeries timeSeries: Original TimeSeries used to calculate the mean historic values. :return: Returns a list containing the historic means. :rtype: list
[ "Calculates", "the", "mean", "value", "for", "the", "history", "of", "the", "MeanAbsoluteScaledError", "." ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/errors/meanabsolutescalederror.py#L63-L84
T-002/pycast
pycast/errors/meanabsolutescalederror.py
MeanAbsoluteScaledError.initialize
def initialize(self, originalTimeSeries, calculatedTimeSeries): """Initializes the ErrorMeasure. During initialization, all :py:meth:`BaseErrorMeasure.local_error()` are calculated. :param TimeSeries originalTimeSeries: TimeSeries containing the original data. :param TimeSeries calc...
python
def initialize(self, originalTimeSeries, calculatedTimeSeries): """Initializes the ErrorMeasure. During initialization, all :py:meth:`BaseErrorMeasure.local_error()` are calculated. :param TimeSeries originalTimeSeries: TimeSeries containing the original data. :param TimeSeries calc...
[ "def", "initialize", "(", "self", ",", "originalTimeSeries", ",", "calculatedTimeSeries", ")", ":", "# ErrorMeasure was already initialized.", "if", "0", "<", "len", "(", "self", ".", "_errorValues", ")", ":", "raise", "StandardError", "(", "\"An ErrorMeasure can only...
Initializes the ErrorMeasure. During initialization, all :py:meth:`BaseErrorMeasure.local_error()` are calculated. :param TimeSeries originalTimeSeries: TimeSeries containing the original data. :param TimeSeries calculatedTimeSeries: TimeSeries containing calculated data. Cal...
[ "Initializes", "the", "ErrorMeasure", "." ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/errors/meanabsolutescalederror.py#L86-L140
T-002/pycast
pycast/errors/meanabsolutescalederror.py
MeanAbsoluteScaledError._calculate
def _calculate(self, startingPercentage, endPercentage, startDate, endDate): """This is the error calculation function that gets called by :py:meth:`BaseErrorMeasure.get_error`. Both parameters will be correct at this time. :param float startingPercentage: Defines the start of the interval. Th...
python
def _calculate(self, startingPercentage, endPercentage, startDate, endDate): """This is the error calculation function that gets called by :py:meth:`BaseErrorMeasure.get_error`. Both parameters will be correct at this time. :param float startingPercentage: Defines the start of the interval. Th...
[ "def", "_calculate", "(", "self", ",", "startingPercentage", ",", "endPercentage", ",", "startDate", ",", "endDate", ")", ":", "# get the defined subset of error values", "errorValues", "=", "self", ".", "_get_error_values", "(", "startingPercentage", ",", "endPercentag...
This is the error calculation function that gets called by :py:meth:`BaseErrorMeasure.get_error`. Both parameters will be correct at this time. :param float startingPercentage: Defines the start of the interval. This has to be a value in [0.0, 100.0]. It represents the value, where the err...
[ "This", "is", "the", "error", "calculation", "function", "that", "gets", "called", "by", ":", "py", ":", "meth", ":", "BaseErrorMeasure", ".", "get_error", "." ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/errors/meanabsolutescalederror.py#L142-L178
pdkit/pdkit
pdkit/updrs.py
UPDRS.__train
def __train(self, n_clusters=4): """ Calculate cluster's centroids and standard deviations. If there are at least the number of threshold rows \ then: * Observations will be normalised. * Standard deviations will be returned. * Clusters will be retu...
python
def __train(self, n_clusters=4): """ Calculate cluster's centroids and standard deviations. If there are at least the number of threshold rows \ then: * Observations will be normalised. * Standard deviations will be returned. * Clusters will be retu...
[ "def", "__train", "(", "self", ",", "n_clusters", "=", "4", ")", ":", "try", ":", "for", "obs", "in", "self", ".", "observations", ":", "features", ",", "ids", "=", "self", ".", "__get_features_for_observation", "(", "observation", "=", "obs", ",", "last...
Calculate cluster's centroids and standard deviations. If there are at least the number of threshold rows \ then: * Observations will be normalised. * Standard deviations will be returned. * Clusters will be returned. * Centroids are ordered based on their...
[ "Calculate", "cluster", "s", "centroids", "and", "standard", "deviations", ".", "If", "there", "are", "at", "least", "the", "number", "of", "threshold", "rows", "\\", "then", ":" ]
train
https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/updrs.py#L91-L140
pdkit/pdkit
pdkit/updrs.py
UPDRS.get_single_score
def get_single_score(self, point, centroids=None, sd=None): """ Get a single score is a wrapper around the result of classifying a Point against a group of centroids. \ Attributes: observation_score (dict): Original received point and normalised point. :Example:...
python
def get_single_score(self, point, centroids=None, sd=None): """ Get a single score is a wrapper around the result of classifying a Point against a group of centroids. \ Attributes: observation_score (dict): Original received point and normalised point. :Example:...
[ "def", "get_single_score", "(", "self", ",", "point", ",", "centroids", "=", "None", ",", "sd", "=", "None", ")", ":", "normalised_point", "=", "array", "(", "point", ")", "/", "array", "(", "sd", ")", "observation_score", "=", "{", "'original'", ":", ...
Get a single score is a wrapper around the result of classifying a Point against a group of centroids. \ Attributes: observation_score (dict): Original received point and normalised point. :Example: >>> { "original": [0.40369016, 0.65217912], "normalised": [1.65915104,...
[ "Get", "a", "single", "score", "is", "a", "wrapper", "around", "the", "result", "of", "classifying", "a", "Point", "against", "a", "group", "of", "centroids", ".", "\\", "Attributes", ":" ]
train
https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/updrs.py#L198-L242
pdkit/pdkit
pdkit/updrs.py
UPDRS.write_model
def write_model(self, filename='scores', filepath='', output_format='csv'): """ This method calculates the scores and writes them to a file the data frame received. If the output format is other than 'csv' it will print the scores. :param filename: the name to give to the fi...
python
def write_model(self, filename='scores', filepath='', output_format='csv'): """ This method calculates the scores and writes them to a file the data frame received. If the output format is other than 'csv' it will print the scores. :param filename: the name to give to the fi...
[ "def", "write_model", "(", "self", ",", "filename", "=", "'scores'", ",", "filepath", "=", "''", ",", "output_format", "=", "'csv'", ")", ":", "scores_array", "=", "np", ".", "array", "(", "[", "]", ")", "for", "obs", "in", "self", ".", "observations",...
This method calculates the scores and writes them to a file the data frame received. If the output format is other than 'csv' it will print the scores. :param filename: the name to give to the file :type filename: string :param filepath: the path to save the file ...
[ "This", "method", "calculates", "the", "scores", "and", "writes", "them", "to", "a", "file", "the", "data", "frame", "received", ".", "If", "the", "output", "format", "is", "other", "than", "csv", "it", "will", "print", "the", "scores", "." ]
train
https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/updrs.py#L244-L277
pdkit/pdkit
pdkit/updrs.py
UPDRS.score
def score(self, measurement, output_format='array'): """ Method to score/classify a measurement against the trained knn clusters :param measurement: the point to classify :type measurement: pandas.DataFrame :param output_format: the format to return the scores ('...
python
def score(self, measurement, output_format='array'): """ Method to score/classify a measurement against the trained knn clusters :param measurement: the point to classify :type measurement: pandas.DataFrame :param output_format: the format to return the scores ('...
[ "def", "score", "(", "self", ",", "measurement", ",", "output_format", "=", "'array'", ")", ":", "scores", "=", "np", ".", "array", "(", "[", "]", ")", "for", "obs", "in", "self", ".", "observations", ":", "c", ",", "sd", "=", "self", ".", "__get_c...
Method to score/classify a measurement against the trained knn clusters :param measurement: the point to classify :type measurement: pandas.DataFrame :param output_format: the format to return the scores ('array' or 'str') :type output_format: string :return ...
[ "Method", "to", "score", "/", "classify", "a", "measurement", "against", "the", "trained", "knn", "clusters" ]
train
https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/updrs.py#L279-L301
Duke-GCB/DukeDSClient
ddsc/core/download.py
download_file_part_run
def download_file_part_run(download_context): """ Function run by CreateProjectCommand to create the project. Runs in a background process. :param download_context: UploadContext: contains data service setup and project name to create. """ destination_dir, file_url_data_dict, seek_amt, bytes_to_...
python
def download_file_part_run(download_context): """ Function run by CreateProjectCommand to create the project. Runs in a background process. :param download_context: UploadContext: contains data service setup and project name to create. """ destination_dir, file_url_data_dict, seek_amt, bytes_to_...
[ "def", "download_file_part_run", "(", "download_context", ")", ":", "destination_dir", ",", "file_url_data_dict", ",", "seek_amt", ",", "bytes_to_read", "=", "download_context", ".", "params", "project_file", "=", "ProjectFile", "(", "file_url_data_dict", ")", "local_pa...
Function run by CreateProjectCommand to create the project. Runs in a background process. :param download_context: UploadContext: contains data service setup and project name to create.
[ "Function", "run", "by", "CreateProjectCommand", "to", "create", "the", "project", ".", "Runs", "in", "a", "background", "process", ".", ":", "param", "download_context", ":", "UploadContext", ":", "contains", "data", "service", "setup", "and", "project", "name"...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L366-L379
Duke-GCB/DukeDSClient
ddsc/core/download.py
ProjectDownload.run
def run(self): """ Download the contents of the specified project name or id to dest_directory. """ files_to_download = self.get_files_to_download() total_files_size = self.get_total_files_size(files_to_download) if self.file_download_pre_processor: self.run_p...
python
def run(self): """ Download the contents of the specified project name or id to dest_directory. """ files_to_download = self.get_files_to_download() total_files_size = self.get_total_files_size(files_to_download) if self.file_download_pre_processor: self.run_p...
[ "def", "run", "(", "self", ")", ":", "files_to_download", "=", "self", ".", "get_files_to_download", "(", ")", "total_files_size", "=", "self", ".", "get_total_files_size", "(", "files_to_download", ")", "if", "self", ".", "file_download_pre_processor", ":", "self...
Download the contents of the specified project name or id to dest_directory.
[ "Download", "the", "contents", "of", "the", "specified", "project", "name", "or", "id", "to", "dest_directory", "." ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L38-L54
Duke-GCB/DukeDSClient
ddsc/core/download.py
ProjectDownload.run_preprocessor
def run_preprocessor(self, files_to_download): """ Run file_download_pre_processor for each file we are about to download. :param files_to_download: [ProjectFile]: files that will be downloaded """ for project_file in files_to_download: self.file_download_pre_processo...
python
def run_preprocessor(self, files_to_download): """ Run file_download_pre_processor for each file we are about to download. :param files_to_download: [ProjectFile]: files that will be downloaded """ for project_file in files_to_download: self.file_download_pre_processo...
[ "def", "run_preprocessor", "(", "self", ",", "files_to_download", ")", ":", "for", "project_file", "in", "files_to_download", ":", "self", ".", "file_download_pre_processor", ".", "run", "(", "self", ".", "remote_store", ".", "data_service", ",", "project_file", "...
Run file_download_pre_processor for each file we are about to download. :param files_to_download: [ProjectFile]: files that will be downloaded
[ "Run", "file_download_pre_processor", "for", "each", "file", "we", "are", "about", "to", "download", ".", ":", "param", "files_to_download", ":", "[", "ProjectFile", "]", ":", "files", "that", "will", "be", "downloaded" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L83-L89
Duke-GCB/DukeDSClient
ddsc/core/download.py
ProjectDownload.try_create_dir
def try_create_dir(self, path): """ Try to create a directory if it doesn't exist and raise error if there is a non-directory with the same name. :param path: str path to the directory """ if not os.path.exists(path): os.mkdir(path) elif not os.path.isdir(path...
python
def try_create_dir(self, path): """ Try to create a directory if it doesn't exist and raise error if there is a non-directory with the same name. :param path: str path to the directory """ if not os.path.exists(path): os.mkdir(path) elif not os.path.isdir(path...
[ "def", "try_create_dir", "(", "self", ",", "path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "os", ".", "mkdir", "(", "path", ")", "elif", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "Val...
Try to create a directory if it doesn't exist and raise error if there is a non-directory with the same name. :param path: str path to the directory
[ "Try", "to", "create", "a", "directory", "if", "it", "doesn", "t", "exist", "and", "raise", "error", "if", "there", "is", "a", "non", "-", "directory", "with", "the", "same", "name", ".", ":", "param", "path", ":", "str", "path", "to", "the", "direct...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L99-L107
Duke-GCB/DukeDSClient
ddsc/core/download.py
FileUrlDownloader._get_parent_remote_paths
def _get_parent_remote_paths(self): """ Get list of remote folders based on the list of all file urls :return: set([str]): set of remote folders (that contain files) """ parent_paths = set([item.get_remote_parent_path() for item in self.file_urls]) if '' in parent_paths: ...
python
def _get_parent_remote_paths(self): """ Get list of remote folders based on the list of all file urls :return: set([str]): set of remote folders (that contain files) """ parent_paths = set([item.get_remote_parent_path() for item in self.file_urls]) if '' in parent_paths: ...
[ "def", "_get_parent_remote_paths", "(", "self", ")", ":", "parent_paths", "=", "set", "(", "[", "item", ".", "get_remote_parent_path", "(", ")", "for", "item", "in", "self", ".", "file_urls", "]", ")", "if", "''", "in", "parent_paths", ":", "parent_paths", ...
Get list of remote folders based on the list of all file urls :return: set([str]): set of remote folders (that contain files)
[ "Get", "list", "of", "remote", "folders", "based", "on", "the", "list", "of", "all", "file", "urls", ":", "return", ":", "set", "(", "[", "str", "]", ")", ":", "set", "of", "remote", "folders", "(", "that", "contain", "files", ")" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L187-L195
Duke-GCB/DukeDSClient
ddsc/core/download.py
FileUrlDownloader.make_local_directories
def make_local_directories(self): """ Create directories necessary to download the files into dest_directory """ for remote_path in self._get_parent_remote_paths(): local_path = os.path.join(self.dest_directory, remote_path) self._assure_dir_exists(local_path)
python
def make_local_directories(self): """ Create directories necessary to download the files into dest_directory """ for remote_path in self._get_parent_remote_paths(): local_path = os.path.join(self.dest_directory, remote_path) self._assure_dir_exists(local_path)
[ "def", "make_local_directories", "(", "self", ")", ":", "for", "remote_path", "in", "self", ".", "_get_parent_remote_paths", "(", ")", ":", "local_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "dest_directory", ",", "remote_path", ")", "self"...
Create directories necessary to download the files into dest_directory
[ "Create", "directories", "necessary", "to", "download", "the", "files", "into", "dest_directory" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L197-L203
Duke-GCB/DukeDSClient
ddsc/core/download.py
FileUrlDownloader.make_big_empty_files
def make_big_empty_files(self): """ Write out a empty file so the workers can seek to where they should write and write their data. """ for file_url in self.file_urls: local_path = file_url.get_local_path(self.dest_directory) with open(local_path, "wb") as outfile...
python
def make_big_empty_files(self): """ Write out a empty file so the workers can seek to where they should write and write their data. """ for file_url in self.file_urls: local_path = file_url.get_local_path(self.dest_directory) with open(local_path, "wb") as outfile...
[ "def", "make_big_empty_files", "(", "self", ")", ":", "for", "file_url", "in", "self", ".", "file_urls", ":", "local_path", "=", "file_url", ".", "get_local_path", "(", "self", ".", "dest_directory", ")", "with", "open", "(", "local_path", ",", "\"wb\"", ")"...
Write out a empty file so the workers can seek to where they should write and write their data.
[ "Write", "out", "a", "empty", "file", "so", "the", "workers", "can", "seek", "to", "where", "they", "should", "write", "and", "write", "their", "data", "." ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L205-L214
Duke-GCB/DukeDSClient
ddsc/core/download.py
FileUrlDownloader.make_ranges
def make_ranges(self, file_url): """ Divides file_url size into an array of ranges to be downloaded by workers. :param: file_url: ProjectFileUrl: file url to download :return: [(int,int)]: array of (start, end) tuples """ size = file_url.size bytes_per_chunk = sel...
python
def make_ranges(self, file_url): """ Divides file_url size into an array of ranges to be downloaded by workers. :param: file_url: ProjectFileUrl: file url to download :return: [(int,int)]: array of (start, end) tuples """ size = file_url.size bytes_per_chunk = sel...
[ "def", "make_ranges", "(", "self", ",", "file_url", ")", ":", "size", "=", "file_url", ".", "size", "bytes_per_chunk", "=", "self", ".", "determine_bytes_per_chunk", "(", "size", ")", "start", "=", "0", "ranges", "=", "[", "]", "while", "size", ">", "0",...
Divides file_url size into an array of ranges to be downloaded by workers. :param: file_url: ProjectFileUrl: file url to download :return: [(int,int)]: array of (start, end) tuples
[ "Divides", "file_url", "size", "into", "an", "array", "of", "ranges", "to", "be", "downloaded", "by", "workers", ".", ":", "param", ":", "file_url", ":", "ProjectFileUrl", ":", "file", "url", "to", "download", ":", "return", ":", "[", "(", "int", "int", ...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L242-L259
Duke-GCB/DukeDSClient
ddsc/core/download.py
FileUrlDownloader.determine_bytes_per_chunk
def determine_bytes_per_chunk(self, size): """ Calculate the size of chunk a worker should download. The last worker may download less than this depending on file size. :return: int: byte size for a worker """ workers = self.settings.config.download_workers if not...
python
def determine_bytes_per_chunk(self, size): """ Calculate the size of chunk a worker should download. The last worker may download less than this depending on file size. :return: int: byte size for a worker """ workers = self.settings.config.download_workers if not...
[ "def", "determine_bytes_per_chunk", "(", "self", ",", "size", ")", ":", "workers", "=", "self", ".", "settings", ".", "config", ".", "download_workers", "if", "not", "workers", "or", "workers", "==", "'None'", ":", "workers", "=", "1", "bytes_per_chunk", "="...
Calculate the size of chunk a worker should download. The last worker may download less than this depending on file size. :return: int: byte size for a worker
[ "Calculate", "the", "size", "of", "chunk", "a", "worker", "should", "download", ".", "The", "last", "worker", "may", "download", "less", "than", "this", "depending", "on", "file", "size", ".", ":", "return", ":", "int", ":", "byte", "size", "for", "a", ...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L261-L273
Duke-GCB/DukeDSClient
ddsc/core/download.py
FileUrlDownloader.split_file_urls_by_size
def split_file_urls_by_size(self, size): """ Return tuple that contains a list large files and a list of small files based on size parameter :param size: int: size (in bytes) that determines if a file is large or small :return: ([ProjectFileUrl],[ProjectFileUrl]): (large file urls, small...
python
def split_file_urls_by_size(self, size): """ Return tuple that contains a list large files and a list of small files based on size parameter :param size: int: size (in bytes) that determines if a file is large or small :return: ([ProjectFileUrl],[ProjectFileUrl]): (large file urls, small...
[ "def", "split_file_urls_by_size", "(", "self", ",", "size", ")", ":", "large_items", "=", "[", "]", "small_items", "=", "[", "]", "for", "file_url", "in", "self", ".", "file_urls", ":", "if", "file_url", ".", "size", ">=", "size", ":", "large_items", "."...
Return tuple that contains a list large files and a list of small files based on size parameter :param size: int: size (in bytes) that determines if a file is large or small :return: ([ProjectFileUrl],[ProjectFileUrl]): (large file urls, small file urls)
[ "Return", "tuple", "that", "contains", "a", "list", "large", "files", "and", "a", "list", "of", "small", "files", "based", "on", "size", "parameter", ":", "param", "size", ":", "int", ":", "size", "(", "in", "bytes", ")", "that", "determines", "if", "a...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L284-L297
Duke-GCB/DukeDSClient
ddsc/core/download.py
FileUrlDownloader.check_downloaded_files_sizes
def check_downloaded_files_sizes(self): """ Make sure the files sizes are correct. Since we manually create the files this will only catch overruns. Raises ValueError if there is a problematic file. """ for file_url in self.file_urls: local_path = file_url.get_local_p...
python
def check_downloaded_files_sizes(self): """ Make sure the files sizes are correct. Since we manually create the files this will only catch overruns. Raises ValueError if there is a problematic file. """ for file_url in self.file_urls: local_path = file_url.get_local_p...
[ "def", "check_downloaded_files_sizes", "(", "self", ")", ":", "for", "file_url", "in", "self", ".", "file_urls", ":", "local_path", "=", "file_url", ".", "get_local_path", "(", "self", ".", "dest_directory", ")", "self", ".", "check_file_size", "(", "file_url", ...
Make sure the files sizes are correct. Since we manually create the files this will only catch overruns. Raises ValueError if there is a problematic file.
[ "Make", "sure", "the", "files", "sizes", "are", "correct", ".", "Since", "we", "manually", "create", "the", "files", "this", "will", "only", "catch", "overruns", ".", "Raises", "ValueError", "if", "there", "is", "a", "problematic", "file", "." ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L299-L306
Duke-GCB/DukeDSClient
ddsc/core/download.py
FileUrlDownloader.check_file_size
def check_file_size(file_size, path): """ Raise an error if we didn't get all of the file. :param file_size: int: size of this file :param path: str path where we downloaded the file to """ stat_info = os.stat(path) if stat_info.st_size != file_size: f...
python
def check_file_size(file_size, path): """ Raise an error if we didn't get all of the file. :param file_size: int: size of this file :param path: str path where we downloaded the file to """ stat_info = os.stat(path) if stat_info.st_size != file_size: f...
[ "def", "check_file_size", "(", "file_size", ",", "path", ")", ":", "stat_info", "=", "os", ".", "stat", "(", "path", ")", "if", "stat_info", ".", "st_size", "!=", "file_size", ":", "format_str", "=", "\"Error occurred downloading {}. Got a file size {}. Expected fil...
Raise an error if we didn't get all of the file. :param file_size: int: size of this file :param path: str path where we downloaded the file to
[ "Raise", "an", "error", "if", "we", "didn", "t", "get", "all", "of", "the", "file", ".", ":", "param", "file_size", ":", "int", ":", "size", "of", "this", "file", ":", "param", "path", ":", "str", "path", "where", "we", "downloaded", "the", "file", ...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L309-L319
Duke-GCB/DukeDSClient
ddsc/core/download.py
DownloadFilePartCommand.create_context
def create_context(self, message_queue, task_id): """ Create data needed by upload_project_run(DukeDS connection info). :param message_queue: Queue: queue background process can send messages to us on :param task_id: int: id of this command's task so message will be routed correctly ...
python
def create_context(self, message_queue, task_id): """ Create data needed by upload_project_run(DukeDS connection info). :param message_queue: Queue: queue background process can send messages to us on :param task_id: int: id of this command's task so message will be routed correctly ...
[ "def", "create_context", "(", "self", ",", "message_queue", ",", "task_id", ")", ":", "params", "=", "(", "self", ".", "settings", ".", "dest_directory", ",", "self", ".", "file_url", ".", "json_data", ",", "self", ".", "seek_amt", ",", "self", ".", "byt...
Create data needed by upload_project_run(DukeDS connection info). :param message_queue: Queue: queue background process can send messages to us on :param task_id: int: id of this command's task so message will be routed correctly
[ "Create", "data", "needed", "by", "upload_project_run", "(", "DukeDS", "connection", "info", ")", ".", ":", "param", "message_queue", ":", "Queue", ":", "queue", "background", "process", "can", "send", "messages", "to", "us", "on", ":", "param", "task_id", "...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L343-L350
Duke-GCB/DukeDSClient
ddsc/core/download.py
RetryChunkDownloader.get_url_and_headers_for_range
def get_url_and_headers_for_range(self, file_download): """ Return url and headers to use for downloading part of a file, adding range headers. :param file_download: FileDownload: contains data about file we will download :return: str, dict: url to download and headers to use """...
python
def get_url_and_headers_for_range(self, file_download): """ Return url and headers to use for downloading part of a file, adding range headers. :param file_download: FileDownload: contains data about file we will download :return: str, dict: url to download and headers to use """...
[ "def", "get_url_and_headers_for_range", "(", "self", ",", "file_download", ")", ":", "headers", "=", "self", ".", "get_range_headers", "(", ")", "if", "file_download", ".", "http_headers", ":", "headers", ".", "update", "(", "file_download", ".", "http_headers", ...
Return url and headers to use for downloading part of a file, adding range headers. :param file_download: FileDownload: contains data about file we will download :return: str, dict: url to download and headers to use
[ "Return", "url", "and", "headers", "to", "use", "for", "downloading", "part", "of", "a", "file", "adding", "range", "headers", ".", ":", "param", "file_download", ":", "FileDownload", ":", "contains", "data", "about", "file", "we", "will", "download", ":", ...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L417-L430
Duke-GCB/DukeDSClient
ddsc/core/download.py
RetryChunkDownloader.download_chunk
def download_chunk(self, url, headers): """ Download part of a file and write to our file :param url: str: URL to download this file :param headers: dict: headers used to download this file chunk """ response = requests.get(url, headers=headers, stream=True) if re...
python
def download_chunk(self, url, headers): """ Download part of a file and write to our file :param url: str: URL to download this file :param headers: dict: headers used to download this file chunk """ response = requests.get(url, headers=headers, stream=True) if re...
[ "def", "download_chunk", "(", "self", ",", "url", ",", "headers", ")", ":", "response", "=", "requests", ".", "get", "(", "url", ",", "headers", "=", "headers", ",", "stream", "=", "True", ")", "if", "response", ".", "status_code", "==", "SWIFT_EXPIRED_S...
Download part of a file and write to our file :param url: str: URL to download this file :param headers: dict: headers used to download this file chunk
[ "Download", "part", "of", "a", "file", "and", "write", "to", "our", "file", ":", "param", "url", ":", "str", ":", "URL", "to", "download", "this", "file", ":", "param", "headers", ":", "dict", ":", "headers", "used", "to", "download", "this", "file", ...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L437-L450
Duke-GCB/DukeDSClient
ddsc/core/download.py
RetryChunkDownloader._write_response_to_file
def _write_response_to_file(self, response): """ Write response to the appropriate section of the file at self.local_path. :param response: requests.Response: response containing stream-able data """ with open(self.local_path, 'r+b') as outfile: # open file for read/write (no tr...
python
def _write_response_to_file(self, response): """ Write response to the appropriate section of the file at self.local_path. :param response: requests.Response: response containing stream-able data """ with open(self.local_path, 'r+b') as outfile: # open file for read/write (no tr...
[ "def", "_write_response_to_file", "(", "self", ",", "response", ")", ":", "with", "open", "(", "self", ".", "local_path", ",", "'r+b'", ")", "as", "outfile", ":", "# open file for read/write (no truncate)", "outfile", ".", "seek", "(", "self", ".", "seek_amt", ...
Write response to the appropriate section of the file at self.local_path. :param response: requests.Response: response containing stream-able data
[ "Write", "response", "to", "the", "appropriate", "section", "of", "the", "file", "at", "self", ".", "local_path", ".", ":", "param", "response", ":", "requests", ".", "Response", ":", "response", "containing", "stream", "-", "able", "data" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L452-L462
Duke-GCB/DukeDSClient
ddsc/core/download.py
RetryChunkDownloader._on_bytes_read
def _on_bytes_read(self, num_bytes_read): """ Record our progress so we can validate that we receive all the data :param num_bytes_read: int: number of bytes we received as part of one chunk """ self.actual_bytes_read += num_bytes_read if self.actual_bytes_read > self.byt...
python
def _on_bytes_read(self, num_bytes_read): """ Record our progress so we can validate that we receive all the data :param num_bytes_read: int: number of bytes we received as part of one chunk """ self.actual_bytes_read += num_bytes_read if self.actual_bytes_read > self.byt...
[ "def", "_on_bytes_read", "(", "self", ",", "num_bytes_read", ")", ":", "self", ".", "actual_bytes_read", "+=", "num_bytes_read", "if", "self", ".", "actual_bytes_read", ">", "self", ".", "bytes_to_read", ":", "raise", "TooLargeChunkDownloadError", "(", "self", "."...
Record our progress so we can validate that we receive all the data :param num_bytes_read: int: number of bytes we received as part of one chunk
[ "Record", "our", "progress", "so", "we", "can", "validate", "that", "we", "receive", "all", "the", "data", ":", "param", "num_bytes_read", ":", "int", ":", "number", "of", "bytes", "we", "received", "as", "part", "of", "one", "chunk" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L464-L472
Duke-GCB/DukeDSClient
ddsc/core/download.py
RetryChunkDownloader._verify_download_complete
def _verify_download_complete(self): """ Make sure we received all the data """ if self.actual_bytes_read > self.bytes_to_read: raise TooLargeChunkDownloadError(self.actual_bytes_read, self.bytes_to_read, self.local_path) elif self.actual_bytes_read < self.bytes_to_re...
python
def _verify_download_complete(self): """ Make sure we received all the data """ if self.actual_bytes_read > self.bytes_to_read: raise TooLargeChunkDownloadError(self.actual_bytes_read, self.bytes_to_read, self.local_path) elif self.actual_bytes_read < self.bytes_to_re...
[ "def", "_verify_download_complete", "(", "self", ")", ":", "if", "self", ".", "actual_bytes_read", ">", "self", ".", "bytes_to_read", ":", "raise", "TooLargeChunkDownloadError", "(", "self", ".", "actual_bytes_read", ",", "self", ".", "bytes_to_read", ",", "self",...
Make sure we received all the data
[ "Make", "sure", "we", "received", "all", "the", "data" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/download.py#L474-L481
T-002/pycast
pycast/optimization/gridsearch.py
GridSearch.optimize
def optimize(self, timeSeries, forecastingMethods=None, startingPercentage=0.0, endPercentage=100.0): """Runs the optimization of the given TimeSeries. :param TimeSeries timeSeries: TimeSeries instance that requires an optimized forecast. :param list forecastingMethods: List of forecastin...
python
def optimize(self, timeSeries, forecastingMethods=None, startingPercentage=0.0, endPercentage=100.0): """Runs the optimization of the given TimeSeries. :param TimeSeries timeSeries: TimeSeries instance that requires an optimized forecast. :param list forecastingMethods: List of forecastin...
[ "def", "optimize", "(", "self", ",", "timeSeries", ",", "forecastingMethods", "=", "None", ",", "startingPercentage", "=", "0.0", ",", "endPercentage", "=", "100.0", ")", ":", "if", "forecastingMethods", "is", "None", "or", "len", "(", "forecastingMethods", ")...
Runs the optimization of the given TimeSeries. :param TimeSeries timeSeries: TimeSeries instance that requires an optimized forecast. :param list forecastingMethods: List of forecastingMethods that will be used for optimization. :param float startingPercentage: Defines the start of the in...
[ "Runs", "the", "optimization", "of", "the", "given", "TimeSeries", "." ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/optimization/gridsearch.py#L34-L69
T-002/pycast
pycast/optimization/gridsearch.py
GridSearch._generate_next_parameter_value
def _generate_next_parameter_value(self, parameter, forecastingMethod): """Generator for a specific parameter of the given forecasting method. :param string parameter: Name of the parameter the generator is used for. :param BaseForecastingMethod forecastingMethod: Instance of a Forecastin...
python
def _generate_next_parameter_value(self, parameter, forecastingMethod): """Generator for a specific parameter of the given forecasting method. :param string parameter: Name of the parameter the generator is used for. :param BaseForecastingMethod forecastingMethod: Instance of a Forecastin...
[ "def", "_generate_next_parameter_value", "(", "self", ",", "parameter", ",", "forecastingMethod", ")", ":", "interval", "=", "forecastingMethod", ".", "get_interval", "(", "parameter", ")", "precision", "=", "10", "**", "self", ".", "_precison", "startValue", "=",...
Generator for a specific parameter of the given forecasting method. :param string parameter: Name of the parameter the generator is used for. :param BaseForecastingMethod forecastingMethod: Instance of a ForecastingMethod. :return: Creates a generator used to iterate over possible par...
[ "Generator", "for", "a", "specific", "parameter", "of", "the", "given", "forecasting", "method", "." ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/optimization/gridsearch.py#L72-L98
T-002/pycast
pycast/optimization/gridsearch.py
GridSearch.optimize_forecasting_method
def optimize_forecasting_method(self, timeSeries, forecastingMethod): """Optimizes the parameters for the given timeSeries and forecastingMethod. :param TimeSeries timeSeries: TimeSeries instance, containing hte original data. :param BaseForecastingMethod forecastingMethod: ForecastingMet...
python
def optimize_forecasting_method(self, timeSeries, forecastingMethod): """Optimizes the parameters for the given timeSeries and forecastingMethod. :param TimeSeries timeSeries: TimeSeries instance, containing hte original data. :param BaseForecastingMethod forecastingMethod: ForecastingMet...
[ "def", "optimize_forecasting_method", "(", "self", ",", "timeSeries", ",", "forecastingMethod", ")", ":", "tuneableParameters", "=", "forecastingMethod", ".", "get_optimizable_parameters", "(", ")", "remainingParameters", "=", "[", "]", "for", "tuneableParameter", "in",...
Optimizes the parameters for the given timeSeries and forecastingMethod. :param TimeSeries timeSeries: TimeSeries instance, containing hte original data. :param BaseForecastingMethod forecastingMethod: ForecastingMethod that is used to optimize the parameters. :return: Returns a tuple co...
[ "Optimizes", "the", "parameters", "for", "the", "given", "timeSeries", "and", "forecastingMethod", "." ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/optimization/gridsearch.py#L100-L135
T-002/pycast
pycast/optimization/gridsearch.py
GridSearch.optimization_loop
def optimization_loop(self, timeSeries, forecastingMethod, remainingParameters, currentParameterValues=None): """The optimization loop. This function is called recursively, until all parameter values were evaluated. :param TimeSeries timeSeries: TimeSeries instance that requires an optimize...
python
def optimization_loop(self, timeSeries, forecastingMethod, remainingParameters, currentParameterValues=None): """The optimization loop. This function is called recursively, until all parameter values were evaluated. :param TimeSeries timeSeries: TimeSeries instance that requires an optimize...
[ "def", "optimization_loop", "(", "self", ",", "timeSeries", ",", "forecastingMethod", ",", "remainingParameters", ",", "currentParameterValues", "=", "None", ")", ":", "if", "currentParameterValues", "is", "None", ":", "currentParameterValues", "=", "{", "}", "# The...
The optimization loop. This function is called recursively, until all parameter values were evaluated. :param TimeSeries timeSeries: TimeSeries instance that requires an optimized forecast. :param BaseForecastingMethod forecastingMethod: ForecastingMethod that is used to optimize the par...
[ "The", "optimization", "loop", "." ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/optimization/gridsearch.py#L137-L198
T-002/pycast
bin/examples/LivingRoomEnergy/server.py
energy_data
def energy_data(): """ Connects to the database and loads Readings for device 8. """ cur = db.cursor().execute("""SELECT timestamp, current FROM Readings""") original = TimeSeries() original.initialize_from_sql_cursor(cur) original.normalize("day", fusionMethod = "sum") return itty.R...
python
def energy_data(): """ Connects to the database and loads Readings for device 8. """ cur = db.cursor().execute("""SELECT timestamp, current FROM Readings""") original = TimeSeries() original.initialize_from_sql_cursor(cur) original.normalize("day", fusionMethod = "sum") return itty.R...
[ "def", "energy_data", "(", ")", ":", "cur", "=", "db", ".", "cursor", "(", ")", ".", "execute", "(", "\"\"\"SELECT timestamp, current FROM Readings\"\"\"", ")", "original", "=", "TimeSeries", "(", ")", "original", ".", "initialize_from_sql_cursor", "(", "cur", "...
Connects to the database and loads Readings for device 8.
[ "Connects", "to", "the", "database", "and", "loads", "Readings", "for", "device", "8", "." ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/bin/examples/LivingRoomEnergy/server.py#L43-L51
T-002/pycast
bin/examples/LivingRoomEnergy/server.py
optimize
def optimize(request): """ Performs Holt Winters Parameter Optimization on the given post data. Expects the following values set in the post of the request: seasonLength - integer valuesToForecast - integer data - two dimensional array of [timestamp, value] """ #Parse argumen...
python
def optimize(request): """ Performs Holt Winters Parameter Optimization on the given post data. Expects the following values set in the post of the request: seasonLength - integer valuesToForecast - integer data - two dimensional array of [timestamp, value] """ #Parse argumen...
[ "def", "optimize", "(", "request", ")", ":", "#Parse arguments", "seasonLength", "=", "int", "(", "request", ".", "POST", ".", "get", "(", "'seasonLength'", ",", "6", ")", ")", "valuesToForecast", "=", "int", "(", "request", ".", "POST", ".", "get", "(",...
Performs Holt Winters Parameter Optimization on the given post data. Expects the following values set in the post of the request: seasonLength - integer valuesToForecast - integer data - two dimensional array of [timestamp, value]
[ "Performs", "Holt", "Winters", "Parameter", "Optimization", "on", "the", "given", "post", "data", ".", "Expects", "the", "following", "values", "set", "in", "the", "post", "of", "the", "request", ":", "seasonLength", "-", "integer", "valuesToForecast", "-", "i...
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/bin/examples/LivingRoomEnergy/server.py#L54-L84
T-002/pycast
bin/examples/LivingRoomEnergy/server.py
holtWinters
def holtWinters(request): """ Performs Holt Winters Smoothing on the given post data. Expects the following values set in the post of the request: smoothingFactor - float trendSmoothingFactor - float seasonSmoothingFactor - float seasonLength - integer valuesToForecas...
python
def holtWinters(request): """ Performs Holt Winters Smoothing on the given post data. Expects the following values set in the post of the request: smoothingFactor - float trendSmoothingFactor - float seasonSmoothingFactor - float seasonLength - integer valuesToForecas...
[ "def", "holtWinters", "(", "request", ")", ":", "#Parse arguments", "smoothingFactor", "=", "float", "(", "request", ".", "POST", ".", "get", "(", "'smoothingFactor'", ",", "0.2", ")", ")", "trendSmoothingFactor", "=", "float", "(", "request", ".", "POST", "...
Performs Holt Winters Smoothing on the given post data. Expects the following values set in the post of the request: smoothingFactor - float trendSmoothingFactor - float seasonSmoothingFactor - float seasonLength - integer valuesToForecast - integer data - two dimensi...
[ "Performs", "Holt", "Winters", "Smoothing", "on", "the", "given", "post", "data", ".", "Expects", "the", "following", "values", "set", "in", "the", "post", "of", "the", "request", ":", "smoothingFactor", "-", "float", "trendSmoothingFactor", "-", "float", "sea...
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/bin/examples/LivingRoomEnergy/server.py#L87-L125
twisted/txaws
txaws/server/call.py
Call.parse
def parse(self, schema, strict=True): """Update C{args} and C{rest}, parsing the raw request arguments. @param schema: The L{Schema} the parameters must be extracted with. @param strict: If C{True} an error is raised if parameters not included in the schema are found, otherwise the ...
python
def parse(self, schema, strict=True): """Update C{args} and C{rest}, parsing the raw request arguments. @param schema: The L{Schema} the parameters must be extracted with. @param strict: If C{True} an error is raised if parameters not included in the schema are found, otherwise the ...
[ "def", "parse", "(", "self", ",", "schema", ",", "strict", "=", "True", ")", ":", "self", ".", "args", ",", "self", ".", "rest", "=", "schema", ".", "extract", "(", "self", ".", "_raw_params", ")", "if", "strict", "and", "self", ".", "rest", ":", ...
Update C{args} and C{rest}, parsing the raw request arguments. @param schema: The L{Schema} the parameters must be extracted with. @param strict: If C{True} an error is raised if parameters not included in the schema are found, otherwise the extra parameters will be saved in the...
[ "Update", "C", "{", "args", "}", "and", "C", "{", "rest", "}", "parsing", "the", "raw", "request", "arguments", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/call.py#L40-L52
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
_name_to_child_map
def _name_to_child_map(children): """ Create a map of name to child based on a list. :param children [LocalFolder/LocalFile] list of children: :return: map child.name -> child """ name_to_child = {} for child in children: name_to_child[child.name] = child return name_to_child
python
def _name_to_child_map(children): """ Create a map of name to child based on a list. :param children [LocalFolder/LocalFile] list of children: :return: map child.name -> child """ name_to_child = {} for child in children: name_to_child[child.name] = child return name_to_child
[ "def", "_name_to_child_map", "(", "children", ")", ":", "name_to_child", "=", "{", "}", "for", "child", "in", "children", ":", "name_to_child", "[", "child", ".", "name", "]", "=", "child", "return", "name_to_child" ]
Create a map of name to child based on a list. :param children [LocalFolder/LocalFile] list of children: :return: map child.name -> child
[ "Create", "a", "map", "of", "name", "to", "child", "based", "on", "a", "list", ".", ":", "param", "children", "[", "LocalFolder", "/", "LocalFile", "]", "list", "of", "children", ":", ":", "return", ":", "map", "child", ".", "name", "-", ">", "child"...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L65-L74
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
_update_remote_children
def _update_remote_children(remote_parent, children): """ Update remote_ids based on on parent matching up the names of children. :param remote_parent: RemoteProject/RemoteFolder who has children :param children: [LocalFolder,LocalFile] children to set remote_ids based on remote children """ nam...
python
def _update_remote_children(remote_parent, children): """ Update remote_ids based on on parent matching up the names of children. :param remote_parent: RemoteProject/RemoteFolder who has children :param children: [LocalFolder,LocalFile] children to set remote_ids based on remote children """ nam...
[ "def", "_update_remote_children", "(", "remote_parent", ",", "children", ")", ":", "name_to_child", "=", "_name_to_child_map", "(", "children", ")", "for", "remote_child", "in", "remote_parent", ".", "children", ":", "local_child", "=", "name_to_child", ".", "get", ...
Update remote_ids based on on parent matching up the names of children. :param remote_parent: RemoteProject/RemoteFolder who has children :param children: [LocalFolder,LocalFile] children to set remote_ids based on remote children
[ "Update", "remote_ids", "based", "on", "on", "parent", "matching", "up", "the", "names", "of", "children", ".", ":", "param", "remote_parent", ":", "RemoteProject", "/", "RemoteFolder", "who", "has", "children", ":", "param", "children", ":", "[", "LocalFolder...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L77-L87
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
_build_project_tree
def _build_project_tree(path, followsymlinks, file_filter): """ Build a tree of LocalFolder with children or just a LocalFile based on a path. :param path: str path to a directory to walk :param followsymlinks: bool should we follow symlinks when walking :param file_filter: FileFilter: include metho...
python
def _build_project_tree(path, followsymlinks, file_filter): """ Build a tree of LocalFolder with children or just a LocalFile based on a path. :param path: str path to a directory to walk :param followsymlinks: bool should we follow symlinks when walking :param file_filter: FileFilter: include metho...
[ "def", "_build_project_tree", "(", "path", ",", "followsymlinks", ",", "file_filter", ")", ":", "result", "=", "None", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "result", "=", "LocalFile", "(", "path", ")", "else", ":", "result", "...
Build a tree of LocalFolder with children or just a LocalFile based on a path. :param path: str path to a directory to walk :param followsymlinks: bool should we follow symlinks when walking :param file_filter: FileFilter: include method returns True if we should include a file/folder :return: the top n...
[ "Build", "a", "tree", "of", "LocalFolder", "with", "children", "or", "just", "a", "LocalFile", "based", "on", "a", "path", ".", ":", "param", "path", ":", "str", "path", "to", "a", "directory", "to", "walk", ":", "param", "followsymlinks", ":", "bool", ...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L90-L103
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
_build_folder_tree
def _build_folder_tree(top_abspath, followsymlinks, file_filter): """ Build a tree of LocalFolder with children based on a path. :param top_abspath: str path to a directory to walk :param followsymlinks: bool should we follow symlinks when walking :param file_filter: FileFilter: include method retur...
python
def _build_folder_tree(top_abspath, followsymlinks, file_filter): """ Build a tree of LocalFolder with children based on a path. :param top_abspath: str path to a directory to walk :param followsymlinks: bool should we follow symlinks when walking :param file_filter: FileFilter: include method retur...
[ "def", "_build_folder_tree", "(", "top_abspath", ",", "followsymlinks", ",", "file_filter", ")", ":", "path_to_content", "=", "{", "}", "child_to_parent", "=", "{", "}", "ignore_file_patterns", "=", "IgnoreFilePatterns", "(", "file_filter", ")", "ignore_file_patterns"...
Build a tree of LocalFolder with children based on a path. :param top_abspath: str path to a directory to walk :param followsymlinks: bool should we follow symlinks when walking :param file_filter: FileFilter: include method returns True if we should include a file/folder :return: the top node of the tr...
[ "Build", "a", "tree", "of", "LocalFolder", "with", "children", "based", "on", "a", "path", ".", ":", "param", "top_abspath", ":", "str", "path", "to", "a", "directory", "to", "walk", ":", "param", "followsymlinks", ":", "bool", "should", "we", "follow", ...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L106-L140
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
LocalProject.add_path
def add_path(self, path): """ Add the path and any children files/folders to the list of content. :param path: str path to add """ abspath = os.path.abspath(path) self.children.append(_build_project_tree(abspath, self.followsymlinks, self.file_filter))
python
def add_path(self, path): """ Add the path and any children files/folders to the list of content. :param path: str path to add """ abspath = os.path.abspath(path) self.children.append(_build_project_tree(abspath, self.followsymlinks, self.file_filter))
[ "def", "add_path", "(", "self", ",", "path", ")", ":", "abspath", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "self", ".", "children", ".", "append", "(", "_build_project_tree", "(", "abspath", ",", "self", ".", "followsymlinks", ",", "se...
Add the path and any children files/folders to the list of content. :param path: str path to add
[ "Add", "the", "path", "and", "any", "children", "files", "/", "folders", "to", "the", "list", "of", "content", ".", ":", "param", "path", ":", "str", "path", "to", "add" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L27-L33
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
LocalProject.update_remote_ids
def update_remote_ids(self, remote_project): """ Compare against remote_project saving off the matching uuids of of matching content. :param remote_project: RemoteProject project to compare against """ if remote_project: self.remote_id = remote_project.id ...
python
def update_remote_ids(self, remote_project): """ Compare against remote_project saving off the matching uuids of of matching content. :param remote_project: RemoteProject project to compare against """ if remote_project: self.remote_id = remote_project.id ...
[ "def", "update_remote_ids", "(", "self", ",", "remote_project", ")", ":", "if", "remote_project", ":", "self", ".", "remote_id", "=", "remote_project", ".", "id", "_update_remote_children", "(", "remote_project", ",", "self", ".", "children", ")" ]
Compare against remote_project saving off the matching uuids of of matching content. :param remote_project: RemoteProject project to compare against
[ "Compare", "against", "remote_project", "saving", "off", "the", "matching", "uuids", "of", "of", "matching", "content", ".", ":", "param", "remote_project", ":", "RemoteProject", "project", "to", "compare", "against" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L43-L50
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
LocalFolder.update_remote_ids
def update_remote_ids(self, remote_folder): """ Set remote id based on remote_folder and check children against this folder's children. :param remote_folder: RemoteFolder to compare against """ self.remote_id = remote_folder.id _update_remote_children(remote_folder, self....
python
def update_remote_ids(self, remote_folder): """ Set remote id based on remote_folder and check children against this folder's children. :param remote_folder: RemoteFolder to compare against """ self.remote_id = remote_folder.id _update_remote_children(remote_folder, self....
[ "def", "update_remote_ids", "(", "self", ",", "remote_folder", ")", ":", "self", ".", "remote_id", "=", "remote_folder", ".", "id", "_update_remote_children", "(", "remote_folder", ",", "self", ".", "children", ")" ]
Set remote id based on remote_folder and check children against this folder's children. :param remote_folder: RemoteFolder to compare against
[ "Set", "remote", "id", "based", "on", "remote_folder", "and", "check", "children", "against", "this", "folder", "s", "children", ".", ":", "param", "remote_folder", ":", "RemoteFolder", "to", "compare", "against" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L168-L174
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
LocalFile.update_remote_ids
def update_remote_ids(self, remote_file): """ Based on a remote file try to assign a remote_id and compare hash info. :param remote_file: RemoteFile remote data pull remote_id from """ self.remote_id = remote_file.id hash_data = self.path_data.get_hash() if hash_d...
python
def update_remote_ids(self, remote_file): """ Based on a remote file try to assign a remote_id and compare hash info. :param remote_file: RemoteFile remote data pull remote_id from """ self.remote_id = remote_file.id hash_data = self.path_data.get_hash() if hash_d...
[ "def", "update_remote_ids", "(", "self", ",", "remote_file", ")", ":", "self", ".", "remote_id", "=", "remote_file", ".", "id", "hash_data", "=", "self", ".", "path_data", ".", "get_hash", "(", ")", "if", "hash_data", ".", "matches", "(", "remote_file", "....
Based on a remote file try to assign a remote_id and compare hash info. :param remote_file: RemoteFile remote data pull remote_id from
[ "Based", "on", "a", "remote", "file", "try", "to", "assign", "a", "remote_id", "and", "compare", "hash", "info", ".", ":", "param", "remote_file", ":", "RemoteFile", "remote", "data", "pull", "remote_id", "from" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L223-L231
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
LocalFile.count_chunks
def count_chunks(self, bytes_per_chunk): """ Based on the size of the file determine how many chunks we will need to upload. For empty files 1 chunk is returned (DukeDS requires an empty chunk for empty files). :param bytes_per_chunk: int: how many bytes should chunks to spglit the file ...
python
def count_chunks(self, bytes_per_chunk): """ Based on the size of the file determine how many chunks we will need to upload. For empty files 1 chunk is returned (DukeDS requires an empty chunk for empty files). :param bytes_per_chunk: int: how many bytes should chunks to spglit the file ...
[ "def", "count_chunks", "(", "self", ",", "bytes_per_chunk", ")", ":", "chunks", "=", "math", ".", "ceil", "(", "float", "(", "self", ".", "size", ")", "/", "float", "(", "bytes_per_chunk", ")", ")", "return", "max", "(", "chunks", ",", "1", ")" ]
Based on the size of the file determine how many chunks we will need to upload. For empty files 1 chunk is returned (DukeDS requires an empty chunk for empty files). :param bytes_per_chunk: int: how many bytes should chunks to spglit the file into :return: int: number of chunks that will need to...
[ "Based", "on", "the", "size", "of", "the", "file", "determine", "how", "many", "chunks", "we", "will", "need", "to", "upload", ".", "For", "empty", "files", "1", "chunk", "is", "returned", "(", "DukeDS", "requires", "an", "empty", "chunk", "for", "empty"...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L241-L249
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
HashData.matches
def matches(self, hash_alg, hash_value): """ Does our algorithm and hash value match the specified arguments. :param hash_alg: str: hash algorithm :param hash_value: str: hash value :return: boolean """ return self.alg == hash_alg and self.value == hash_value
python
def matches(self, hash_alg, hash_value): """ Does our algorithm and hash value match the specified arguments. :param hash_alg: str: hash algorithm :param hash_value: str: hash value :return: boolean """ return self.alg == hash_alg and self.value == hash_value
[ "def", "matches", "(", "self", ",", "hash_alg", ",", "hash_value", ")", ":", "return", "self", ".", "alg", "==", "hash_alg", "and", "self", ".", "value", "==", "hash_value" ]
Does our algorithm and hash value match the specified arguments. :param hash_alg: str: hash algorithm :param hash_value: str: hash value :return: boolean
[ "Does", "our", "algorithm", "and", "hash", "value", "match", "the", "specified", "arguments", ".", ":", "param", "hash_alg", ":", "str", ":", "hash", "algorithm", ":", "param", "hash_value", ":", "str", ":", "hash", "value", ":", "return", ":", "boolean" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L268-L275
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
PathData.mime_type
def mime_type(self): """ Guess the mimetype of a file or 'application/octet-stream' if unable to guess. :return: str: mimetype """ mime_type, encoding = mimetypes.guess_type(self.path) if not mime_type: mime_type = 'application/octet-stream' return mim...
python
def mime_type(self): """ Guess the mimetype of a file or 'application/octet-stream' if unable to guess. :return: str: mimetype """ mime_type, encoding = mimetypes.guess_type(self.path) if not mime_type: mime_type = 'application/octet-stream' return mim...
[ "def", "mime_type", "(", "self", ")", ":", "mime_type", ",", "encoding", "=", "mimetypes", ".", "guess_type", "(", "self", ".", "path", ")", "if", "not", "mime_type", ":", "mime_type", "=", "'application/octet-stream'", "return", "mime_type" ]
Guess the mimetype of a file or 'application/octet-stream' if unable to guess. :return: str: mimetype
[ "Guess", "the", "mimetype", "of", "a", "file", "or", "application", "/", "octet", "-", "stream", "if", "unable", "to", "guess", ".", ":", "return", ":", "str", ":", "mimetype" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L318-L326
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
PathData.read_whole_file
def read_whole_file(self): """ Slurp the whole file into memory. Should only be used with relatively small files. :return: str: file contents """ chunk = None with open(self.path, 'rb') as infile: chunk = infile.read() return chunk
python
def read_whole_file(self): """ Slurp the whole file into memory. Should only be used with relatively small files. :return: str: file contents """ chunk = None with open(self.path, 'rb') as infile: chunk = infile.read() return chunk
[ "def", "read_whole_file", "(", "self", ")", ":", "chunk", "=", "None", "with", "open", "(", "self", ".", "path", ",", "'rb'", ")", "as", "infile", ":", "chunk", "=", "infile", ".", "read", "(", ")", "return", "chunk" ]
Slurp the whole file into memory. Should only be used with relatively small files. :return: str: file contents
[ "Slurp", "the", "whole", "file", "into", "memory", ".", "Should", "only", "be", "used", "with", "relatively", "small", "files", ".", ":", "return", ":", "str", ":", "file", "contents" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L342-L351
Duke-GCB/DukeDSClient
ddsc/core/localstore.py
HashUtil.add_file
def add_file(self, filename, block_size=4096): """ Add an entire file to this hash. :param filename: str filename of the file to hash :param block_size: int size of chunks when reading the file """ with open(filename, "rb") as f: for chunk in iter(lambda: f.re...
python
def add_file(self, filename, block_size=4096): """ Add an entire file to this hash. :param filename: str filename of the file to hash :param block_size: int size of chunks when reading the file """ with open(filename, "rb") as f: for chunk in iter(lambda: f.re...
[ "def", "add_file", "(", "self", ",", "filename", ",", "block_size", "=", "4096", ")", ":", "with", "open", "(", "filename", ",", "\"rb\"", ")", "as", "f", ":", "for", "chunk", "in", "iter", "(", "lambda", ":", "f", ".", "read", "(", "block_size", "...
Add an entire file to this hash. :param filename: str filename of the file to hash :param block_size: int size of chunks when reading the file
[ "Add", "an", "entire", "file", "to", "this", "hash", ".", ":", "param", "filename", ":", "str", "filename", "of", "the", "file", "to", "hash", ":", "param", "block_size", ":", "int", "size", "of", "chunks", "when", "reading", "the", "file" ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/localstore.py#L362-L370
Staffjoy/client_python
staffjoy/resource.py
Resource.get
def get(cls, parent=None, id=None, data=None): """Inherit info from parent and return new object""" # TODO - allow fetching of parent based on child? if parent is not None: route = copy(parent.route) else: route = {} if id is not None and cls.ID_NAME is ...
python
def get(cls, parent=None, id=None, data=None): """Inherit info from parent and return new object""" # TODO - allow fetching of parent based on child? if parent is not None: route = copy(parent.route) else: route = {} if id is not None and cls.ID_NAME is ...
[ "def", "get", "(", "cls", ",", "parent", "=", "None", ",", "id", "=", "None", ",", "data", "=", "None", ")", ":", "# TODO - allow fetching of parent based on child?", "if", "parent", "is", "not", "None", ":", "route", "=", "copy", "(", "parent", ".", "ro...
Inherit info from parent and return new object
[ "Inherit", "info", "from", "parent", "and", "return", "new", "object" ]
train
https://github.com/Staffjoy/client_python/blob/e8811b0c06651a15e691c96cbfd41e7da4f7f213/staffjoy/resource.py#L48-L68
Staffjoy/client_python
staffjoy/resource.py
Resource.get_all
def get_all(cls, parent=None, **params): if parent is not None: route = copy(parent.route) else: route = {} if cls.ID_NAME is not None: # Empty string triggers "get all resources" route[cls.ID_NAME] = "" base_obj = cls(key=parent.key, rou...
python
def get_all(cls, parent=None, **params): if parent is not None: route = copy(parent.route) else: route = {} if cls.ID_NAME is not None: # Empty string triggers "get all resources" route[cls.ID_NAME] = "" base_obj = cls(key=parent.key, rou...
[ "def", "get_all", "(", "cls", ",", "parent", "=", "None", ",", "*", "*", "params", ")", ":", "if", "parent", "is", "not", "None", ":", "route", "=", "copy", "(", "parent", ".", "route", ")", "else", ":", "route", "=", "{", "}", "if", "cls", "."...
Perform a read request against the resource
[ "Perform", "a", "read", "request", "against", "the", "resource" ]
train
https://github.com/Staffjoy/client_python/blob/e8811b0c06651a15e691c96cbfd41e7da4f7f213/staffjoy/resource.py#L71-L104
Staffjoy/client_python
staffjoy/resource.py
Resource._url
def _url(self): """Get the URL for the resource""" if self.ID_NAME not in self.route.keys() and "id" in self.data.keys(): self.route[self.ID_NAME] = self.data["id"] return self.config.BASE + self.PATH.format(**self.route)
python
def _url(self): """Get the URL for the resource""" if self.ID_NAME not in self.route.keys() and "id" in self.data.keys(): self.route[self.ID_NAME] = self.data["id"] return self.config.BASE + self.PATH.format(**self.route)
[ "def", "_url", "(", "self", ")", ":", "if", "self", ".", "ID_NAME", "not", "in", "self", ".", "route", ".", "keys", "(", ")", "and", "\"id\"", "in", "self", ".", "data", ".", "keys", "(", ")", ":", "self", ".", "route", "[", "self", ".", "ID_NA...
Get the URL for the resource
[ "Get", "the", "URL", "for", "the", "resource" ]
train
https://github.com/Staffjoy/client_python/blob/e8811b0c06651a15e691c96cbfd41e7da4f7f213/staffjoy/resource.py#L106-L110
Staffjoy/client_python
staffjoy/resource.py
Resource._handle_request_exception
def _handle_request_exception(request): """Raise the proper exception based on the response""" try: data = request.json() except: data = {} code = request.status_code if code == requests.codes.bad: raise BadRequestException(response=data) ...
python
def _handle_request_exception(request): """Raise the proper exception based on the response""" try: data = request.json() except: data = {} code = request.status_code if code == requests.codes.bad: raise BadRequestException(response=data) ...
[ "def", "_handle_request_exception", "(", "request", ")", ":", "try", ":", "data", "=", "request", ".", "json", "(", ")", "except", ":", "data", "=", "{", "}", "code", "=", "request", ".", "status_code", "if", "code", "==", "requests", ".", "codes", "."...
Raise the proper exception based on the response
[ "Raise", "the", "proper", "exception", "based", "on", "the", "response" ]
train
https://github.com/Staffjoy/client_python/blob/e8811b0c06651a15e691c96cbfd41e7da4f7f213/staffjoy/resource.py#L113-L131
Staffjoy/client_python
staffjoy/resource.py
Resource.fetch
def fetch(self): """Perform a read request against the resource""" start = datetime.now() r = requests.get(self._url(), auth=(self.key, "")) self._delay_for_ratelimits(start) if r.status_code not in self.TRUTHY_CODES: return self._handle_request_exception(r) ...
python
def fetch(self): """Perform a read request against the resource""" start = datetime.now() r = requests.get(self._url(), auth=(self.key, "")) self._delay_for_ratelimits(start) if r.status_code not in self.TRUTHY_CODES: return self._handle_request_exception(r) ...
[ "def", "fetch", "(", "self", ")", ":", "start", "=", "datetime", ".", "now", "(", ")", "r", "=", "requests", ".", "get", "(", "self", ".", "_url", "(", ")", ",", "auth", "=", "(", "self", ".", "key", ",", "\"\"", ")", ")", "self", ".", "_dela...
Perform a read request against the resource
[ "Perform", "a", "read", "request", "against", "the", "resource" ]
train
https://github.com/Staffjoy/client_python/blob/e8811b0c06651a15e691c96cbfd41e7da4f7f213/staffjoy/resource.py#L133-L149
Staffjoy/client_python
staffjoy/resource.py
Resource._process_meta
def _process_meta(self, response): """Process additional data sent in response""" for key in self.META_ENVELOPES: self.meta[key] = response.get(key)
python
def _process_meta(self, response): """Process additional data sent in response""" for key in self.META_ENVELOPES: self.meta[key] = response.get(key)
[ "def", "_process_meta", "(", "self", ",", "response", ")", ":", "for", "key", "in", "self", ".", "META_ENVELOPES", ":", "self", ".", "meta", "[", "key", "]", "=", "response", ".", "get", "(", "key", ")" ]
Process additional data sent in response
[ "Process", "additional", "data", "sent", "in", "response" ]
train
https://github.com/Staffjoy/client_python/blob/e8811b0c06651a15e691c96cbfd41e7da4f7f213/staffjoy/resource.py#L151-L154
Staffjoy/client_python
staffjoy/resource.py
Resource.delete
def delete(self): """Delete the object""" start = datetime.now() r = requests.delete(self._url(), auth=(self.key, "")) self._delay_for_ratelimits(start) if r.status_code not in self.TRUTHY_CODES: return self._handle_request_exception(r)
python
def delete(self): """Delete the object""" start = datetime.now() r = requests.delete(self._url(), auth=(self.key, "")) self._delay_for_ratelimits(start) if r.status_code not in self.TRUTHY_CODES: return self._handle_request_exception(r)
[ "def", "delete", "(", "self", ")", ":", "start", "=", "datetime", ".", "now", "(", ")", "r", "=", "requests", ".", "delete", "(", "self", ".", "_url", "(", ")", ",", "auth", "=", "(", "self", ".", "key", ",", "\"\"", ")", ")", "self", ".", "_...
Delete the object
[ "Delete", "the", "object" ]
train
https://github.com/Staffjoy/client_python/blob/e8811b0c06651a15e691c96cbfd41e7da4f7f213/staffjoy/resource.py#L156-L164
Staffjoy/client_python
staffjoy/resource.py
Resource.patch
def patch(self, **kwargs): """Change attributes of the item""" start = datetime.now() r = requests.patch(self._url(), auth=(self.key, ""), data=kwargs) self._delay_for_ratelimits(start) if r.status_code not in self.TRUTHY_CODES: return self._handle_request_exception(...
python
def patch(self, **kwargs): """Change attributes of the item""" start = datetime.now() r = requests.patch(self._url(), auth=(self.key, ""), data=kwargs) self._delay_for_ratelimits(start) if r.status_code not in self.TRUTHY_CODES: return self._handle_request_exception(...
[ "def", "patch", "(", "self", ",", "*", "*", "kwargs", ")", ":", "start", "=", "datetime", ".", "now", "(", ")", "r", "=", "requests", ".", "patch", "(", "self", ".", "_url", "(", ")", ",", "auth", "=", "(", "self", ".", "key", ",", "\"\"", ")...
Change attributes of the item
[ "Change", "attributes", "of", "the", "item" ]
train
https://github.com/Staffjoy/client_python/blob/e8811b0c06651a15e691c96cbfd41e7da4f7f213/staffjoy/resource.py#L166-L177
Staffjoy/client_python
staffjoy/resource.py
Resource.create
def create(cls, parent=None, **kwargs): """Create an object and return it""" if parent is None: raise Exception("Parent class is required") route = copy(parent.route) if cls.ID_NAME is not None: route[cls.ID_NAME] = "" obj = cls(key=parent.key, route=ro...
python
def create(cls, parent=None, **kwargs): """Create an object and return it""" if parent is None: raise Exception("Parent class is required") route = copy(parent.route) if cls.ID_NAME is not None: route[cls.ID_NAME] = "" obj = cls(key=parent.key, route=ro...
[ "def", "create", "(", "cls", ",", "parent", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "parent", "is", "None", ":", "raise", "Exception", "(", "\"Parent class is required\"", ")", "route", "=", "copy", "(", "parent", ".", "route", ")", "if",...
Create an object and return it
[ "Create", "an", "object", "and", "return", "it" ]
train
https://github.com/Staffjoy/client_python/blob/e8811b0c06651a15e691c96cbfd41e7da4f7f213/staffjoy/resource.py#L180-L204
Staffjoy/client_python
staffjoy/resource.py
Resource._delay_for_ratelimits
def _delay_for_ratelimits(cls, start): """If request was shorter than max request time, delay""" stop = datetime.now() duration_microseconds = (stop - start).microseconds if duration_microseconds < cls.REQUEST_TIME_MICROSECONDS: time.sleep((cls.REQUEST_TIME_MICROSECONDS - dur...
python
def _delay_for_ratelimits(cls, start): """If request was shorter than max request time, delay""" stop = datetime.now() duration_microseconds = (stop - start).microseconds if duration_microseconds < cls.REQUEST_TIME_MICROSECONDS: time.sleep((cls.REQUEST_TIME_MICROSECONDS - dur...
[ "def", "_delay_for_ratelimits", "(", "cls", ",", "start", ")", ":", "stop", "=", "datetime", ".", "now", "(", ")", "duration_microseconds", "=", "(", "stop", "-", "start", ")", ".", "microseconds", "if", "duration_microseconds", "<", "cls", ".", "REQUEST_TIM...
If request was shorter than max request time, delay
[ "If", "request", "was", "shorter", "than", "max", "request", "time", "delay" ]
train
https://github.com/Staffjoy/client_python/blob/e8811b0c06651a15e691c96cbfd41e7da4f7f213/staffjoy/resource.py#L210-L216
pdkit/pdkit
pdkit/gait_time_series.py
GaitTimeSeries.load_data
def load_data(filename, format_file='cloudupdrs'): """ This is a general load data method where the format of data to load can be passed as a parameter, :param str filename: The path to load data from :param str format_file: format of the file. Default is CloudUPDRS ('cloudu...
python
def load_data(filename, format_file='cloudupdrs'): """ This is a general load data method where the format of data to load can be passed as a parameter, :param str filename: The path to load data from :param str format_file: format of the file. Default is CloudUPDRS ('cloudu...
[ "def", "load_data", "(", "filename", ",", "format_file", "=", "'cloudupdrs'", ")", ":", "logging", ".", "debug", "(", "\"{} data --> Loaded\"", ".", "format", "(", "format_file", ")", ")", "data_frame", "=", "load_data", "(", "filename", ",", "format_file", ")...
This is a general load data method where the format of data to load can be passed as a parameter, :param str filename: The path to load data from :param str format_file: format of the file. Default is CloudUPDRS ('cloudupdrs'). Set to 'mpower' for mpower data. :return DataFrame dat...
[ "This", "is", "a", "general", "load", "data", "method", "where", "the", "format", "of", "data", "to", "load", "can", "be", "passed", "as", "a", "parameter" ]
train
https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/gait_time_series.py#L22-L37
twisted/txaws
txaws/client/discover/command.py
Command.run
def run(self): """ Run the configured method and write the HTTP response status and text to the output stream. """ region = AWSServiceRegion(access_key=self.key, secret_key=self.secret, uri=self.endpoint) query = self.query_factory(action...
python
def run(self): """ Run the configured method and write the HTTP response status and text to the output stream. """ region = AWSServiceRegion(access_key=self.key, secret_key=self.secret, uri=self.endpoint) query = self.query_factory(action...
[ "def", "run", "(", "self", ")", ":", "region", "=", "AWSServiceRegion", "(", "access_key", "=", "self", ".", "key", ",", "secret_key", "=", "self", ".", "secret", ",", "uri", "=", "self", ".", "endpoint", ")", "query", "=", "self", ".", "query_factory"...
Run the configured method and write the HTTP response status and text to the output stream.
[ "Run", "the", "configured", "method", "and", "write", "the", "HTTP", "response", "status", "and", "text", "to", "the", "output", "stream", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/client/discover/command.py#L46-L87
pdkit/pdkit
pdkit/processor.py
Processor.resample_signal
def resample_signal(self, data_frame): """ Convenience method for frequency conversion and resampling of data frame. Object must have a DatetimeIndex. After re-sampling, this methods interpolate the time magnitude sum acceleration values and the x,y,z values of the data fra...
python
def resample_signal(self, data_frame): """ Convenience method for frequency conversion and resampling of data frame. Object must have a DatetimeIndex. After re-sampling, this methods interpolate the time magnitude sum acceleration values and the x,y,z values of the data fra...
[ "def", "resample_signal", "(", "self", ",", "data_frame", ")", ":", "new_freq", "=", "np", ".", "round", "(", "1", "/", "self", ".", "sampling_frequency", ",", "decimals", "=", "6", ")", "df_resampled", "=", "data_frame", ".", "resample", "(", "str", "("...
Convenience method for frequency conversion and resampling of data frame. Object must have a DatetimeIndex. After re-sampling, this methods interpolate the time magnitude sum acceleration values and the x,y,z values of the data frame acceleration :param data_frame: the data frame ...
[ "Convenience", "method", "for", "frequency", "conversion", "and", "resampling", "of", "data", "frame", ".", "Object", "must", "have", "a", "DatetimeIndex", ".", "After", "re", "-", "sampling", "this", "methods", "interpolate", "the", "time", "magnitude", "sum", ...
train
https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/processor.py#L65-L88
pdkit/pdkit
pdkit/processor.py
Processor.filter_data_frame
def filter_data_frame(self, data_frame, centre=False, keep_cols=['anno']): """ This method filters a data frame signal as suggested in [1]. First step is to high pass filter the data frame using a butter Butterworth digital and analog filter (https://docs.scipy.org/doc/scipy...
python
def filter_data_frame(self, data_frame, centre=False, keep_cols=['anno']): """ This method filters a data frame signal as suggested in [1]. First step is to high pass filter the data frame using a butter Butterworth digital and analog filter (https://docs.scipy.org/doc/scipy...
[ "def", "filter_data_frame", "(", "self", ",", "data_frame", ",", "centre", "=", "False", ",", "keep_cols", "=", "[", "'anno'", "]", ")", ":", "b_f", "=", "lambda", "x", ":", "butter_lowpass_filter", "(", "x", ".", "values", ",", "self", ".", "sampling_fr...
This method filters a data frame signal as suggested in [1]. First step is to high pass filter the data frame using a butter Butterworth digital and analog filter (https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.signal.butter.html). Then the method filter the data...
[ "This", "method", "filters", "a", "data", "frame", "signal", "as", "suggested", "in", "[", "1", "]", ".", "First", "step", "is", "to", "high", "pass", "filter", "the", "data", "frame", "using", "a", "butter", "Butterworth", "digital", "and", "analog", "f...
train
https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/processor.py#L99-L137
twisted/txaws
txaws/service.py
AWSServiceEndpoint.get_canonical_host
def get_canonical_host(self): """ Return the canonical host as for the Host HTTP header specification. """ host = self.host.lower() if self.port is not None: host = "%s:%s" % (host, self.port) return host
python
def get_canonical_host(self): """ Return the canonical host as for the Host HTTP header specification. """ host = self.host.lower() if self.port is not None: host = "%s:%s" % (host, self.port) return host
[ "def", "get_canonical_host", "(", "self", ")", ":", "host", "=", "self", ".", "host", ".", "lower", "(", ")", "if", "self", ".", "port", "is", "not", "None", ":", "host", "=", "\"%s:%s\"", "%", "(", "host", ",", "self", ".", "port", ")", "return", ...
Return the canonical host as for the Host HTTP header specification.
[ "Return", "the", "canonical", "host", "as", "for", "the", "Host", "HTTP", "header", "specification", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/service.py#L75-L82
twisted/txaws
txaws/service.py
AWSServiceEndpoint.set_canonical_host
def set_canonical_host(self, canonical_host): """ Set host and port from a canonical host string as for the Host HTTP header specification. """ parts = canonical_host.lower().split(":") self.host = parts[0] if len(parts) > 1 and parts[1]: self.port = i...
python
def set_canonical_host(self, canonical_host): """ Set host and port from a canonical host string as for the Host HTTP header specification. """ parts = canonical_host.lower().split(":") self.host = parts[0] if len(parts) > 1 and parts[1]: self.port = i...
[ "def", "set_canonical_host", "(", "self", ",", "canonical_host", ")", ":", "parts", "=", "canonical_host", ".", "lower", "(", ")", ".", "split", "(", "\":\"", ")", "self", ".", "host", "=", "parts", "[", "0", "]", "if", "len", "(", "parts", ")", ">",...
Set host and port from a canonical host string as for the Host HTTP header specification.
[ "Set", "host", "and", "port", "from", "a", "canonical", "host", "string", "as", "for", "the", "Host", "HTTP", "header", "specification", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/service.py#L84-L94
twisted/txaws
txaws/service.py
AWSServiceEndpoint.get_uri
def get_uri(self): """Get a URL representation of the service.""" uri = "%s://%s%s" % (self.scheme, self.get_canonical_host(), self.path) return uri
python
def get_uri(self): """Get a URL representation of the service.""" uri = "%s://%s%s" % (self.scheme, self.get_canonical_host(), self.path) return uri
[ "def", "get_uri", "(", "self", ")", ":", "uri", "=", "\"%s://%s%s\"", "%", "(", "self", ".", "scheme", ",", "self", ".", "get_canonical_host", "(", ")", ",", "self", ".", "path", ")", "return", "uri" ]
Get a URL representation of the service.
[ "Get", "a", "URL", "representation", "of", "the", "service", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/service.py#L99-L102
twisted/txaws
txaws/service.py
AWSServiceRegion.get_client
def get_client(self, cls, purge_cache=False, *args, **kwds): """ This is a general method for getting a client: if present, it is pulled from the cache; if not, a new one is instantiated and then put into the cache. This method should not be called directly, but rather by other c...
python
def get_client(self, cls, purge_cache=False, *args, **kwds): """ This is a general method for getting a client: if present, it is pulled from the cache; if not, a new one is instantiated and then put into the cache. This method should not be called directly, but rather by other c...
[ "def", "get_client", "(", "self", ",", "cls", ",", "purge_cache", "=", "False", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "key", "=", "str", "(", "cls", ")", "+", "str", "(", "args", ")", "+", "str", "(", "kwds", ")", "instance", "=", ...
This is a general method for getting a client: if present, it is pulled from the cache; if not, a new one is instantiated and then put into the cache. This method should not be called directly, but rather by other client-specific methods (e.g., get_ec2_client).
[ "This", "is", "a", "general", "method", "for", "getting", "a", "client", ":", "if", "present", "it", "is", "pulled", "from", "the", "cache", ";", "if", "not", "a", "new", "one", "is", "instantiated", "and", "then", "put", "into", "the", "cache", ".", ...
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/service.py#L145-L157
T-002/pycast
pycast/common/decorators.py
optimized
def optimized(fn): """Decorator that will call the optimized c++ version of a pycast function if available rather than theo original pycast function :param function fn: original pycast function :return: return the wrapped function :rtype: function """ def _optimized(self, *args, **kwa...
python
def optimized(fn): """Decorator that will call the optimized c++ version of a pycast function if available rather than theo original pycast function :param function fn: original pycast function :return: return the wrapped function :rtype: function """ def _optimized(self, *args, **kwa...
[ "def", "optimized", "(", "fn", ")", ":", "def", "_optimized", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\" This method calls the pycastC function if\n optimization is enabled and the pycastC function\n is available.\n\n :param: ...
Decorator that will call the optimized c++ version of a pycast function if available rather than theo original pycast function :param function fn: original pycast function :return: return the wrapped function :rtype: function
[ "Decorator", "that", "will", "call", "the", "optimized", "c", "++", "version", "of", "a", "pycast", "function", "if", "available", "rather", "than", "theo", "original", "pycast", "function" ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/decorators.py#L25-L68
T-002/pycast
pycast/optimization/baseoptimizationmethod.py
BaseOptimizationMethod.optimize
def optimize(self, timeSeries, forecastingMethods=None, startingPercentage=0.0, endPercentage=100.0): """Runs the optimization on the given TimeSeries. :param TimeSeries timeSeries: TimeSeries instance that requires an optimized forecast. :param list forecastingMethods: List of forecastin...
python
def optimize(self, timeSeries, forecastingMethods=None, startingPercentage=0.0, endPercentage=100.0): """Runs the optimization on the given TimeSeries. :param TimeSeries timeSeries: TimeSeries instance that requires an optimized forecast. :param list forecastingMethods: List of forecastin...
[ "def", "optimize", "(", "self", ",", "timeSeries", ",", "forecastingMethods", "=", "None", ",", "startingPercentage", "=", "0.0", ",", "endPercentage", "=", "100.0", ")", ":", "# no forecasting methods provided", "if", "forecastingMethods", "is", "None", "or", "le...
Runs the optimization on the given TimeSeries. :param TimeSeries timeSeries: TimeSeries instance that requires an optimized forecast. :param list forecastingMethods: List of forecastingMethods that will be used for optimization. :param float startingPercentage: Defines the start of the in...
[ "Runs", "the", "optimization", "on", "the", "given", "TimeSeries", "." ]
train
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/optimization/baseoptimizationmethod.py#L64-L84
Duke-GCB/DukeDSClient
ddsc/core/pathfilter.py
PathFilter.include_path
def include_path(self, path): """ Should this path be included based on the include_paths or exclude_paths. Keeps track of paths seen to allow finding unused filters. :param path: str: remote path to be filtered :return: bool: True if we should include the path """ ...
python
def include_path(self, path): """ Should this path be included based on the include_paths or exclude_paths. Keeps track of paths seen to allow finding unused filters. :param path: str: remote path to be filtered :return: bool: True if we should include the path """ ...
[ "def", "include_path", "(", "self", ",", "path", ")", ":", "self", ".", "seen_paths", ".", "add", "(", "path", ")", "return", "self", ".", "filter", ".", "include", "(", "path", ")" ]
Should this path be included based on the include_paths or exclude_paths. Keeps track of paths seen to allow finding unused filters. :param path: str: remote path to be filtered :return: bool: True if we should include the path
[ "Should", "this", "path", "be", "included", "based", "on", "the", "include_paths", "or", "exclude_paths", ".", "Keeps", "track", "of", "paths", "seen", "to", "allow", "finding", "unused", "filters", ".", ":", "param", "path", ":", "str", ":", "remote", "pa...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/pathfilter.py#L33-L41
Duke-GCB/DukeDSClient
ddsc/core/pathfilter.py
PathFilter.get_unused_paths
def get_unused_paths(self): """ Returns which include_paths or exclude_paths that were not used via include_path method. :return: [str] list of filtering paths that were not used. """ return [path for path in self.filter.paths if path not in self.seen_paths]
python
def get_unused_paths(self): """ Returns which include_paths or exclude_paths that were not used via include_path method. :return: [str] list of filtering paths that were not used. """ return [path for path in self.filter.paths if path not in self.seen_paths]
[ "def", "get_unused_paths", "(", "self", ")", ":", "return", "[", "path", "for", "path", "in", "self", ".", "filter", ".", "paths", "if", "path", "not", "in", "self", ".", "seen_paths", "]" ]
Returns which include_paths or exclude_paths that were not used via include_path method. :return: [str] list of filtering paths that were not used.
[ "Returns", "which", "include_paths", "or", "exclude_paths", "that", "were", "not", "used", "via", "include_path", "method", ".", ":", "return", ":", "[", "str", "]", "list", "of", "filtering", "paths", "that", "were", "not", "used", "." ]
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/pathfilter.py#L49-L54
Duke-GCB/DukeDSClient
ddsc/core/pathfilter.py
PathFilterUtil.is_child
def is_child(child_path, parent_path): """ Is parent_path a parent(or grandparent) directory of child_path. :param child_path: str: remote file path :param parent_path: str: remote file path :return: bool: True when parent_path is child_path's parent """ parent_di...
python
def is_child(child_path, parent_path): """ Is parent_path a parent(or grandparent) directory of child_path. :param child_path: str: remote file path :param parent_path: str: remote file path :return: bool: True when parent_path is child_path's parent """ parent_di...
[ "def", "is_child", "(", "child_path", ",", "parent_path", ")", ":", "parent_dir", "=", "os", ".", "path", ".", "join", "(", "parent_path", ",", "''", ")", "child_dir", "=", "os", ".", "path", ".", "join", "(", "child_path", ",", "''", ")", "return", ...
Is parent_path a parent(or grandparent) directory of child_path. :param child_path: str: remote file path :param parent_path: str: remote file path :return: bool: True when parent_path is child_path's parent
[ "Is", "parent_path", "a", "parent", "(", "or", "grandparent", ")", "directory", "of", "child_path", ".", ":", "param", "child_path", ":", "str", ":", "remote", "file", "path", ":", "param", "parent_path", ":", "str", ":", "remote", "file", "path", ":", "...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/pathfilter.py#L62-L71
Duke-GCB/DukeDSClient
ddsc/core/pathfilter.py
PathFilterUtil.parent_child_paths
def parent_child_paths(path, some_path): """ Is path a parent of some_path or some_path is a parent of path. :param path: str: remote file path :param some_path: str: remote file path :return: bool: True when they are parents """ return PathFilterUtil.is_child(pat...
python
def parent_child_paths(path, some_path): """ Is path a parent of some_path or some_path is a parent of path. :param path: str: remote file path :param some_path: str: remote file path :return: bool: True when they are parents """ return PathFilterUtil.is_child(pat...
[ "def", "parent_child_paths", "(", "path", ",", "some_path", ")", ":", "return", "PathFilterUtil", ".", "is_child", "(", "path", ",", "some_path", ")", "or", "PathFilterUtil", ".", "is_child", "(", "some_path", ",", "path", ")" ]
Is path a parent of some_path or some_path is a parent of path. :param path: str: remote file path :param some_path: str: remote file path :return: bool: True when they are parents
[ "Is", "path", "a", "parent", "of", "some_path", "or", "some_path", "is", "a", "parent", "of", "path", ".", ":", "param", "path", ":", "str", ":", "remote", "file", "path", ":", "param", "some_path", ":", "str", ":", "remote", "file", "path", ":", "re...
train
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/pathfilter.py#L74-L81
twisted/txaws
txaws/server/method.py
method
def method(method_class): """Decorator to use to mark an API method. When invoking L{Registry.scan} the classes marked with this decorator will be added to the registry. @param method_class: The L{Method} class to register. """ def callback(scanner, name, method_class): if method_clas...
python
def method(method_class): """Decorator to use to mark an API method. When invoking L{Registry.scan} the classes marked with this decorator will be added to the registry. @param method_class: The L{Method} class to register. """ def callback(scanner, name, method_class): if method_clas...
[ "def", "method", "(", "method_class", ")", ":", "def", "callback", "(", "scanner", ",", "name", ",", "method_class", ")", ":", "if", "method_class", ".", "actions", "is", "not", "None", ":", "actions", "=", "method_class", ".", "actions", "else", ":", "a...
Decorator to use to mark an API method. When invoking L{Registry.scan} the classes marked with this decorator will be added to the registry. @param method_class: The L{Method} class to register.
[ "Decorator", "to", "use", "to", "mark", "an", "API", "method", "." ]
train
https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/method.py#L1-L29
ntoll/uflash
uflash.py
hexlify
def hexlify(script, minify=False): """ Takes the byte content of a Python script and returns a hex encoded version of it. Based on the hexlify script in the microbit-micropython repository. """ if not script: return '' # Convert line endings in case the file was created on Windows. ...
python
def hexlify(script, minify=False): """ Takes the byte content of a Python script and returns a hex encoded version of it. Based on the hexlify script in the microbit-micropython repository. """ if not script: return '' # Convert line endings in case the file was created on Windows. ...
[ "def", "hexlify", "(", "script", ",", "minify", "=", "False", ")", ":", "if", "not", "script", ":", "return", "''", "# Convert line endings in case the file was created on Windows.", "script", "=", "script", ".", "replace", "(", "b'\\r\\n'", ",", "b'\\n'", ")", ...
Takes the byte content of a Python script and returns a hex encoded version of it. Based on the hexlify script in the microbit-micropython repository.
[ "Takes", "the", "byte", "content", "of", "a", "Python", "script", "and", "returns", "a", "hex", "encoded", "version", "of", "it", "." ]
train
https://github.com/ntoll/uflash/blob/867468d386da0aa20212b69a152ce8bfc0972366/uflash.py#L81-L115
ntoll/uflash
uflash.py
unhexlify
def unhexlify(blob): """ Takes a hexlified script and turns it back into a string of Python code. """ lines = blob.split('\n')[1:] output = [] for line in lines: # Discard the address, length etc. and reverse the hexlification output.append(binascii.unhexlify(line[9:-2])) # C...
python
def unhexlify(blob): """ Takes a hexlified script and turns it back into a string of Python code. """ lines = blob.split('\n')[1:] output = [] for line in lines: # Discard the address, length etc. and reverse the hexlification output.append(binascii.unhexlify(line[9:-2])) # C...
[ "def", "unhexlify", "(", "blob", ")", ":", "lines", "=", "blob", ".", "split", "(", "'\\n'", ")", "[", "1", ":", "]", "output", "=", "[", "]", "for", "line", "in", "lines", ":", "# Discard the address, length etc. and reverse the hexlification", "output", "....
Takes a hexlified script and turns it back into a string of Python code.
[ "Takes", "a", "hexlified", "script", "and", "turns", "it", "back", "into", "a", "string", "of", "Python", "code", "." ]
train
https://github.com/ntoll/uflash/blob/867468d386da0aa20212b69a152ce8bfc0972366/uflash.py#L118-L142
ntoll/uflash
uflash.py
embed_hex
def embed_hex(runtime_hex, python_hex=None): """ Given a string representing the MicroPython runtime hex, will embed a string representing a hex encoded Python script into it. Returns a string representation of the resulting combination. Will raise a ValueError if the runtime_hex is missing. ...
python
def embed_hex(runtime_hex, python_hex=None): """ Given a string representing the MicroPython runtime hex, will embed a string representing a hex encoded Python script into it. Returns a string representation of the resulting combination. Will raise a ValueError if the runtime_hex is missing. ...
[ "def", "embed_hex", "(", "runtime_hex", ",", "python_hex", "=", "None", ")", ":", "if", "not", "runtime_hex", ":", "raise", "ValueError", "(", "'MicroPython runtime hex required.'", ")", "if", "not", "python_hex", ":", "return", "runtime_hex", "py_list", "=", "p...
Given a string representing the MicroPython runtime hex, will embed a string representing a hex encoded Python script into it. Returns a string representation of the resulting combination. Will raise a ValueError if the runtime_hex is missing. If the python_hex is missing, it will return the unmodifi...
[ "Given", "a", "string", "representing", "the", "MicroPython", "runtime", "hex", "will", "embed", "a", "string", "representing", "a", "hex", "encoded", "Python", "script", "into", "it", "." ]
train
https://github.com/ntoll/uflash/blob/867468d386da0aa20212b69a152ce8bfc0972366/uflash.py#L145-L168
ntoll/uflash
uflash.py
extract_script
def extract_script(embedded_hex): """ Given a hex file containing the MicroPython runtime and an embedded Python script, will extract the original Python script. Returns a string containing the original embedded script. """ hex_lines = embedded_hex.split('\n') script_addr_high = hex((_SCRIP...
python
def extract_script(embedded_hex): """ Given a hex file containing the MicroPython runtime and an embedded Python script, will extract the original Python script. Returns a string containing the original embedded script. """ hex_lines = embedded_hex.split('\n') script_addr_high = hex((_SCRIP...
[ "def", "extract_script", "(", "embedded_hex", ")", ":", "hex_lines", "=", "embedded_hex", ".", "split", "(", "'\\n'", ")", "script_addr_high", "=", "hex", "(", "(", "_SCRIPT_ADDR", ">>", "16", ")", "&", "0xffff", ")", "[", "2", ":", "]", ".", "upper", ...
Given a hex file containing the MicroPython runtime and an embedded Python script, will extract the original Python script. Returns a string containing the original embedded script.
[ "Given", "a", "hex", "file", "containing", "the", "MicroPython", "runtime", "and", "an", "embedded", "Python", "script", "will", "extract", "the", "original", "Python", "script", "." ]
train
https://github.com/ntoll/uflash/blob/867468d386da0aa20212b69a152ce8bfc0972366/uflash.py#L171-L202
ntoll/uflash
uflash.py
find_microbit
def find_microbit(): """ Returns a path on the filesystem that represents the plugged in BBC micro:bit that is to be flashed. If no micro:bit is found, it returns None. Works on Linux, OSX and Windows. Will raise a NotImplementedError exception if run on any other operating system. """ ...
python
def find_microbit(): """ Returns a path on the filesystem that represents the plugged in BBC micro:bit that is to be flashed. If no micro:bit is found, it returns None. Works on Linux, OSX and Windows. Will raise a NotImplementedError exception if run on any other operating system. """ ...
[ "def", "find_microbit", "(", ")", ":", "# Check what sort of operating system we're on.", "if", "os", ".", "name", "==", "'posix'", ":", "# 'posix' means we're on Linux or OSX (Mac).", "# Call the unix \"mount\" command to list the mounted volumes.", "mount_output", "=", "check_out...
Returns a path on the filesystem that represents the plugged in BBC micro:bit that is to be flashed. If no micro:bit is found, it returns None. Works on Linux, OSX and Windows. Will raise a NotImplementedError exception if run on any other operating system.
[ "Returns", "a", "path", "on", "the", "filesystem", "that", "represents", "the", "plugged", "in", "BBC", "micro", ":", "bit", "that", "is", "to", "be", "flashed", ".", "If", "no", "micro", ":", "bit", "is", "found", "it", "returns", "None", "." ]
train
https://github.com/ntoll/uflash/blob/867468d386da0aa20212b69a152ce8bfc0972366/uflash.py#L205-L262
ntoll/uflash
uflash.py
save_hex
def save_hex(hex_file, path): """ Given a string representation of a hex file, this function copies it to the specified path thus causing the device mounted at that point to be flashed. If the hex_file is empty it will raise a ValueError. If the filename at the end of the path does not end in ...
python
def save_hex(hex_file, path): """ Given a string representation of a hex file, this function copies it to the specified path thus causing the device mounted at that point to be flashed. If the hex_file is empty it will raise a ValueError. If the filename at the end of the path does not end in ...
[ "def", "save_hex", "(", "hex_file", ",", "path", ")", ":", "if", "not", "hex_file", ":", "raise", "ValueError", "(", "'Cannot flash an empty .hex file.'", ")", "if", "not", "path", ".", "endswith", "(", "'.hex'", ")", ":", "raise", "ValueError", "(", "'The p...
Given a string representation of a hex file, this function copies it to the specified path thus causing the device mounted at that point to be flashed. If the hex_file is empty it will raise a ValueError. If the filename at the end of the path does not end in '.hex' it will raise a ValueError.
[ "Given", "a", "string", "representation", "of", "a", "hex", "file", "this", "function", "copies", "it", "to", "the", "specified", "path", "thus", "causing", "the", "device", "mounted", "at", "that", "point", "to", "be", "flashed", "." ]
train
https://github.com/ntoll/uflash/blob/867468d386da0aa20212b69a152ce8bfc0972366/uflash.py#L265-L281