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/d4s2.py | D4S2Project._is_current_user | def _is_current_user(self, some_user):
"""
Is the specified user the current user?
:param some_user: RemoteUser user we want to check against the current user
:return: boolean: True if the current user is the passed in user
"""
current_user = self.remote_store.get_current... | python | def _is_current_user(self, some_user):
"""
Is the specified user the current user?
:param some_user: RemoteUser user we want to check against the current user
:return: boolean: True if the current user is the passed in user
"""
current_user = self.remote_store.get_current... | [
"def",
"_is_current_user",
"(",
"self",
",",
"some_user",
")",
":",
"current_user",
"=",
"self",
".",
"remote_store",
".",
"get_current_user",
"(",
")",
"return",
"current_user",
".",
"id",
"==",
"some_user",
".",
"id"
] | Is the specified user the current user?
:param some_user: RemoteUser user we want to check against the current user
:return: boolean: True if the current user is the passed in user | [
"Is",
"the",
"specified",
"user",
"the",
"current",
"user?",
":",
"param",
"some_user",
":",
"RemoteUser",
"user",
"we",
"want",
"to",
"check",
"against",
"the",
"current",
"user",
":",
"return",
":",
"boolean",
":",
"True",
"if",
"the",
"current",
"user",... | train | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/d4s2.py#L381-L388 |
Duke-GCB/DukeDSClient | ddsc/core/d4s2.py | CopyActivity.finished | def finished(self):
"""
Mark the activity as finished
"""
self.data_service.update_activity(self.id, self.name, self.desc,
started_on=self.started,
ended_on=self._current_timestamp_str()) | python | def finished(self):
"""
Mark the activity as finished
"""
self.data_service.update_activity(self.id, self.name, self.desc,
started_on=self.started,
ended_on=self._current_timestamp_str()) | [
"def",
"finished",
"(",
"self",
")",
":",
"self",
".",
"data_service",
".",
"update_activity",
"(",
"self",
".",
"id",
",",
"self",
".",
"name",
",",
"self",
".",
"desc",
",",
"started_on",
"=",
"self",
".",
"started",
",",
"ended_on",
"=",
"self",
"... | Mark the activity as finished | [
"Mark",
"the",
"activity",
"as",
"finished"
] | train | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/d4s2.py#L413-L419 |
Duke-GCB/DukeDSClient | ddsc/core/d4s2.py | DownloadedFileRelations.run | def run(self, data_service, project_file):
"""
Attach a remote file to activity with used relationship.
:param data_service: DataServiceApi: service used to attach relationship
:param project_file: ProjectFile: contains details about a file we will attach
"""
remote_path ... | python | def run(self, data_service, project_file):
"""
Attach a remote file to activity with used relationship.
:param data_service: DataServiceApi: service used to attach relationship
:param project_file: ProjectFile: contains details about a file we will attach
"""
remote_path ... | [
"def",
"run",
"(",
"self",
",",
"data_service",
",",
"project_file",
")",
":",
"remote_path",
"=",
"project_file",
".",
"path",
"file_dict",
"=",
"data_service",
".",
"get_file",
"(",
"project_file",
".",
"id",
")",
".",
"json",
"(",
")",
"file_version_id",
... | Attach a remote file to activity with used relationship.
:param data_service: DataServiceApi: service used to attach relationship
:param project_file: ProjectFile: contains details about a file we will attach | [
"Attach",
"a",
"remote",
"file",
"to",
"activity",
"with",
"used",
"relationship",
".",
":",
"param",
"data_service",
":",
"DataServiceApi",
":",
"service",
"used",
"to",
"attach",
"relationship",
":",
"param",
"project_file",
":",
"ProjectFile",
":",
"contains"... | train | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/d4s2.py#L436-L446 |
Duke-GCB/DukeDSClient | ddsc/core/d4s2.py | UploadedFileRelations.run | def run(self, data_service, file_details):
"""
Attach a remote file to activity with was generated by relationship.
:param data_service: DataServiceApi: service used to attach relationship
:param file_details: dict: response from DukeDS POST to /files/ containing current_version id
... | python | def run(self, data_service, file_details):
"""
Attach a remote file to activity with was generated by relationship.
:param data_service: DataServiceApi: service used to attach relationship
:param file_details: dict: response from DukeDS POST to /files/ containing current_version id
... | [
"def",
"run",
"(",
"self",
",",
"data_service",
",",
"file_details",
")",
":",
"file_version_id",
"=",
"file_details",
"[",
"'current_version'",
"]",
"[",
"'id'",
"]",
"data_service",
".",
"create_was_generated_by_relation",
"(",
"self",
".",
"activity",
".",
"i... | Attach a remote file to activity with was generated by relationship.
:param data_service: DataServiceApi: service used to attach relationship
:param file_details: dict: response from DukeDS POST to /files/ containing current_version id | [
"Attach",
"a",
"remote",
"file",
"to",
"activity",
"with",
"was",
"generated",
"by",
"relationship",
".",
":",
"param",
"data_service",
":",
"DataServiceApi",
":",
"service",
"used",
"to",
"attach",
"relationship",
":",
"param",
"file_details",
":",
"dict",
":... | train | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/d4s2.py#L459-L469 |
Duke-GCB/DukeDSClient | ddsc/core/d4s2.py | UploadedFileRelations._lookup_used_entity_id | def _lookup_used_entity_id(self, file_details):
"""
Return the file_version_id associated with the path from file_details.
The file_version_id is looked up from a dictionary in the activity.
:param file_details: dict: response from DukeDS POST to /files/
:return: str: file_versio... | python | def _lookup_used_entity_id(self, file_details):
"""
Return the file_version_id associated with the path from file_details.
The file_version_id is looked up from a dictionary in the activity.
:param file_details: dict: response from DukeDS POST to /files/
:return: str: file_versio... | [
"def",
"_lookup_used_entity_id",
"(",
"self",
",",
"file_details",
")",
":",
"# Since this uses the response from POST to /files/ this will include the ancestors and not be",
"# effected by exclude_response_fields that were used when listing the project",
"name_parts",
"=",
"[",
"ancestor"... | Return the file_version_id associated with the path from file_details.
The file_version_id is looked up from a dictionary in the activity.
:param file_details: dict: response from DukeDS POST to /files/
:return: str: file_version_id uuid | [
"Return",
"the",
"file_version_id",
"associated",
"with",
"the",
"path",
"from",
"file_details",
".",
"The",
"file_version_id",
"is",
"looked",
"up",
"from",
"a",
"dictionary",
"in",
"the",
"activity",
".",
":",
"param",
"file_details",
":",
"dict",
":",
"resp... | train | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/d4s2.py#L471-L484 |
Duke-GCB/DukeDSClient | ddsc/config.py | create_config | def create_config(allow_insecure_config_file=False):
"""
Create config based on /etc/ddsclient.conf and ~/.ddsclient.conf($DDSCLIENT_CONF)
:param allow_insecure_config_file: bool: when true we will not check ~/.ddsclient permissions.
:return: Config with the configuration to use for DDSClient.
"""
... | python | def create_config(allow_insecure_config_file=False):
"""
Create config based on /etc/ddsclient.conf and ~/.ddsclient.conf($DDSCLIENT_CONF)
:param allow_insecure_config_file: bool: when true we will not check ~/.ddsclient permissions.
:return: Config with the configuration to use for DDSClient.
"""
... | [
"def",
"create_config",
"(",
"allow_insecure_config_file",
"=",
"False",
")",
":",
"config",
"=",
"Config",
"(",
")",
"config",
".",
"add_properties",
"(",
"GLOBAL_CONFIG_FILENAME",
")",
"user_config_filename",
"=",
"get_user_config_filename",
"(",
")",
"if",
"user_... | Create config based on /etc/ddsclient.conf and ~/.ddsclient.conf($DDSCLIENT_CONF)
:param allow_insecure_config_file: bool: when true we will not check ~/.ddsclient permissions.
:return: Config with the configuration to use for DDSClient. | [
"Create",
"config",
"based",
"on",
"/",
"etc",
"/",
"ddsclient",
".",
"conf",
"and",
"~",
"/",
".",
"ddsclient",
".",
"conf",
"(",
"$DDSCLIENT_CONF",
")",
":",
"param",
"allow_insecure_config_file",
":",
"bool",
":",
"when",
"true",
"we",
"will",
"not",
... | train | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/config.py#L37-L49 |
Duke-GCB/DukeDSClient | ddsc/config.py | Config.add_properties | def add_properties(self, filename):
"""
Add properties to config based on filename replacing previous values.
:param filename: str path to YAML file to pull top level properties from
"""
filename = os.path.expanduser(filename)
if os.path.exists(filename):
with... | python | def add_properties(self, filename):
"""
Add properties to config based on filename replacing previous values.
:param filename: str path to YAML file to pull top level properties from
"""
filename = os.path.expanduser(filename)
if os.path.exists(filename):
with... | [
"def",
"add_properties",
"(",
"self",
",",
"filename",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"filename",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r... | Add properties to config based on filename replacing previous values.
:param filename: str path to YAML file to pull top level properties from | [
"Add",
"properties",
"to",
"config",
"based",
"on",
"filename",
"replacing",
"previous",
"values",
".",
":",
"param",
"filename",
":",
"str",
"path",
"to",
"YAML",
"file",
"to",
"pull",
"top",
"level",
"properties",
"from"
] | train | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/config.py#L81-L89 |
Duke-GCB/DukeDSClient | ddsc/config.py | Config.get_portal_url_base | def get_portal_url_base(self):
"""
Determine root url of the data service from the url specified.
:return: str root url of the data service (eg: https://dataservice.duke.edu)
"""
api_url = urlparse(self.url).hostname
portal_url = re.sub('^api\.', '', api_url)
port... | python | def get_portal_url_base(self):
"""
Determine root url of the data service from the url specified.
:return: str root url of the data service (eg: https://dataservice.duke.edu)
"""
api_url = urlparse(self.url).hostname
portal_url = re.sub('^api\.', '', api_url)
port... | [
"def",
"get_portal_url_base",
"(",
"self",
")",
":",
"api_url",
"=",
"urlparse",
"(",
"self",
".",
"url",
")",
".",
"hostname",
"portal_url",
"=",
"re",
".",
"sub",
"(",
"'^api\\.'",
",",
"''",
",",
"api_url",
")",
"portal_url",
"=",
"re",
".",
"sub",
... | Determine root url of the data service from the url specified.
:return: str root url of the data service (eg: https://dataservice.duke.edu) | [
"Determine",
"root",
"url",
"of",
"the",
"data",
"service",
"from",
"the",
"url",
"specified",
".",
":",
"return",
":",
"str",
"root",
"url",
"of",
"the",
"data",
"service",
"(",
"eg",
":",
"https",
":",
"//",
"dataservice",
".",
"duke",
".",
"edu",
... | train | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/config.py#L106-L114 |
Duke-GCB/DukeDSClient | ddsc/config.py | Config.auth | def auth(self):
"""
Contains the auth token for use with connecting to the dataservice.
:return:
"""
return self.values.get(Config.AUTH, os.environ.get(AUTH_ENV_KEY_NAME, None)) | python | def auth(self):
"""
Contains the auth token for use with connecting to the dataservice.
:return:
"""
return self.values.get(Config.AUTH, os.environ.get(AUTH_ENV_KEY_NAME, None)) | [
"def",
"auth",
"(",
"self",
")",
":",
"return",
"self",
".",
"values",
".",
"get",
"(",
"Config",
".",
"AUTH",
",",
"os",
".",
"environ",
".",
"get",
"(",
"AUTH_ENV_KEY_NAME",
",",
"None",
")",
")"
] | Contains the auth token for use with connecting to the dataservice.
:return: | [
"Contains",
"the",
"auth",
"token",
"for",
"use",
"with",
"connecting",
"to",
"the",
"dataservice",
".",
":",
"return",
":"
] | train | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/config.py#L133-L138 |
Duke-GCB/DukeDSClient | ddsc/config.py | Config.upload_bytes_per_chunk | def upload_bytes_per_chunk(self):
"""
Return the bytes per chunk to be sent to external store.
:return: int bytes per upload chunk
"""
value = self.values.get(Config.UPLOAD_BYTES_PER_CHUNK, DDS_DEFAULT_UPLOAD_CHUNKS)
return Config.parse_bytes_str(value) | python | def upload_bytes_per_chunk(self):
"""
Return the bytes per chunk to be sent to external store.
:return: int bytes per upload chunk
"""
value = self.values.get(Config.UPLOAD_BYTES_PER_CHUNK, DDS_DEFAULT_UPLOAD_CHUNKS)
return Config.parse_bytes_str(value) | [
"def",
"upload_bytes_per_chunk",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"values",
".",
"get",
"(",
"Config",
".",
"UPLOAD_BYTES_PER_CHUNK",
",",
"DDS_DEFAULT_UPLOAD_CHUNKS",
")",
"return",
"Config",
".",
"parse_bytes_str",
"(",
"value",
")"
] | Return the bytes per chunk to be sent to external store.
:return: int bytes per upload chunk | [
"Return",
"the",
"bytes",
"per",
"chunk",
"to",
"be",
"sent",
"to",
"external",
"store",
".",
":",
"return",
":",
"int",
"bytes",
"per",
"upload",
"chunk"
] | train | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/config.py#L141-L147 |
Duke-GCB/DukeDSClient | ddsc/config.py | Config.download_workers | def download_workers(self):
"""
Return the number of parallel works to use when downloading a file.
:return: int number of workers. Specify None or 1 to disable parallel downloading
"""
# Profiling download on different servers showed half the number of CPUs to be optimum for spe... | python | def download_workers(self):
"""
Return the number of parallel works to use when downloading a file.
:return: int number of workers. Specify None or 1 to disable parallel downloading
"""
# Profiling download on different servers showed half the number of CPUs to be optimum for spe... | [
"def",
"download_workers",
"(",
"self",
")",
":",
"# Profiling download on different servers showed half the number of CPUs to be optimum for speed.",
"default_workers",
"=",
"int",
"(",
"math",
".",
"ceil",
"(",
"default_num_workers",
"(",
")",
"/",
"2",
")",
")",
"retur... | Return the number of parallel works to use when downloading a file.
:return: int number of workers. Specify None or 1 to disable parallel downloading | [
"Return",
"the",
"number",
"of",
"parallel",
"works",
"to",
"use",
"when",
"downloading",
"a",
"file",
".",
":",
"return",
":",
"int",
"number",
"of",
"workers",
".",
"Specify",
"None",
"or",
"1",
"to",
"disable",
"parallel",
"downloading"
] | train | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/config.py#L158-L165 |
Duke-GCB/DukeDSClient | ddsc/config.py | Config.parse_bytes_str | def parse_bytes_str(value):
"""
Given a value return the integer number of bytes it represents.
Trailing "MB" causes the value multiplied by 1024*1024
:param value:
:return: int number of bytes represented by value.
"""
if type(value) == str:
if "MB" i... | python | def parse_bytes_str(value):
"""
Given a value return the integer number of bytes it represents.
Trailing "MB" causes the value multiplied by 1024*1024
:param value:
:return: int number of bytes represented by value.
"""
if type(value) == str:
if "MB" i... | [
"def",
"parse_bytes_str",
"(",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"==",
"str",
":",
"if",
"\"MB\"",
"in",
"value",
":",
"return",
"int",
"(",
"value",
".",
"replace",
"(",
"\"MB\"",
",",
"\"\"",
")",
")",
"*",
"MB_TO_BYTES",
"else",
... | Given a value return the integer number of bytes it represents.
Trailing "MB" causes the value multiplied by 1024*1024
:param value:
:return: int number of bytes represented by value. | [
"Given",
"a",
"value",
"return",
"the",
"integer",
"number",
"of",
"bytes",
"it",
"represents",
".",
"Trailing",
"MB",
"causes",
"the",
"value",
"multiplied",
"by",
"1024",
"*",
"1024",
":",
"param",
"value",
":",
":",
"return",
":",
"int",
"number",
"of... | train | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/config.py#L188-L201 |
T-002/pycast | pycast/errors/meanabsolutedeviationerror.py | MeanAbsoluteDeviationError.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",
"]",
"return",
"abs",
"(",
"originalValue",
"-",
"calculatedValu... | 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/meanabsolutedeviationerror.py#L53-L66 |
twisted/txaws | txaws/ec2/client.py | EC2Client.describe_instances | def describe_instances(self, *instance_ids):
"""Describe current instances."""
instances = {}
for pos, instance_id in enumerate(instance_ids):
instances["InstanceId.%d" % (pos + 1)] = instance_id
query = self.query_factory(
action="DescribeInstances", creds=self.c... | python | def describe_instances(self, *instance_ids):
"""Describe current instances."""
instances = {}
for pos, instance_id in enumerate(instance_ids):
instances["InstanceId.%d" % (pos + 1)] = instance_id
query = self.query_factory(
action="DescribeInstances", creds=self.c... | [
"def",
"describe_instances",
"(",
"self",
",",
"*",
"instance_ids",
")",
":",
"instances",
"=",
"{",
"}",
"for",
"pos",
",",
"instance_id",
"in",
"enumerate",
"(",
"instance_ids",
")",
":",
"instances",
"[",
"\"InstanceId.%d\"",
"%",
"(",
"pos",
"+",
"1",
... | Describe current instances. | [
"Describe",
"current",
"instances",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L39-L48 |
twisted/txaws | txaws/ec2/client.py | EC2Client.run_instances | def run_instances(self, image_id, min_count, max_count,
security_groups=None, key_name=None, instance_type=None,
user_data=None, availability_zone=None, kernel_id=None,
ramdisk_id=None, subnet_id=None, security_group_ids=None):
"""Run new instances.
TODO: blockDeviceMapping, mon... | python | def run_instances(self, image_id, min_count, max_count,
security_groups=None, key_name=None, instance_type=None,
user_data=None, availability_zone=None, kernel_id=None,
ramdisk_id=None, subnet_id=None, security_group_ids=None):
"""Run new instances.
TODO: blockDeviceMapping, mon... | [
"def",
"run_instances",
"(",
"self",
",",
"image_id",
",",
"min_count",
",",
"max_count",
",",
"security_groups",
"=",
"None",
",",
"key_name",
"=",
"None",
",",
"instance_type",
"=",
"None",
",",
"user_data",
"=",
"None",
",",
"availability_zone",
"=",
"Non... | Run new instances.
TODO: blockDeviceMapping, monitoring, subnetId | [
"Run",
"new",
"instances",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L50-L91 |
twisted/txaws | txaws/ec2/client.py | EC2Client.get_console_output | def get_console_output(self, instance_id):
"""Get the console output for a single instance."""
InstanceIDParam = {"InstanceId": instance_id}
query = self.query_factory(
action="GetConsoleOutput", creds=self.creds,
endpoint=self.endpoint, other_params=InstanceIDParam)
... | python | def get_console_output(self, instance_id):
"""Get the console output for a single instance."""
InstanceIDParam = {"InstanceId": instance_id}
query = self.query_factory(
action="GetConsoleOutput", creds=self.creds,
endpoint=self.endpoint, other_params=InstanceIDParam)
... | [
"def",
"get_console_output",
"(",
"self",
",",
"instance_id",
")",
":",
"InstanceIDParam",
"=",
"{",
"\"InstanceId\"",
":",
"instance_id",
"}",
"query",
"=",
"self",
".",
"query_factory",
"(",
"action",
"=",
"\"GetConsoleOutput\"",
",",
"creds",
"=",
"self",
"... | Get the console output for a single instance. | [
"Get",
"the",
"console",
"output",
"for",
"a",
"single",
"instance",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L109-L116 |
twisted/txaws | txaws/ec2/client.py | EC2Client.describe_security_groups | def describe_security_groups(self, *names):
"""Describe security groups.
@param names: Optionally, a list of security group names to describe.
Defaults to all security groups in the account.
@return: A C{Deferred} that will fire with a list of L{SecurityGroup}s
retrieved... | python | def describe_security_groups(self, *names):
"""Describe security groups.
@param names: Optionally, a list of security group names to describe.
Defaults to all security groups in the account.
@return: A C{Deferred} that will fire with a list of L{SecurityGroup}s
retrieved... | [
"def",
"describe_security_groups",
"(",
"self",
",",
"*",
"names",
")",
":",
"group_names",
"=",
"{",
"}",
"if",
"names",
":",
"group_names",
"=",
"dict",
"(",
"[",
"(",
"\"GroupName.%d\"",
"%",
"(",
"i",
"+",
"1",
")",
",",
"name",
")",
"for",
"i",
... | Describe security groups.
@param names: Optionally, a list of security group names to describe.
Defaults to all security groups in the account.
@return: A C{Deferred} that will fire with a list of L{SecurityGroup}s
retrieved from the cloud. | [
"Describe",
"security",
"groups",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L118-L134 |
twisted/txaws | txaws/ec2/client.py | EC2Client.create_security_group | def create_security_group(self, name, description, vpc_id=None):
"""Create security group.
@param name: Name of the new security group.
@param description: Description of the new security group.
@param vpc_id: ID of the VPC to which the security group will belong.
@return: A C{D... | python | def create_security_group(self, name, description, vpc_id=None):
"""Create security group.
@param name: Name of the new security group.
@param description: Description of the new security group.
@param vpc_id: ID of the VPC to which the security group will belong.
@return: A C{D... | [
"def",
"create_security_group",
"(",
"self",
",",
"name",
",",
"description",
",",
"vpc_id",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"\"GroupName\"",
":",
"name",
",",
"\"GroupDescription\"",
":",
"description",
"}",
"if",
"vpc_id",
":",
"parameters",
... | Create security group.
@param name: Name of the new security group.
@param description: Description of the new security group.
@param vpc_id: ID of the VPC to which the security group will belong.
@return: A C{Deferred} that will fire with a truth value for the
success of th... | [
"Create",
"security",
"group",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L136-L152 |
twisted/txaws | txaws/ec2/client.py | EC2Client.authorize_security_group | def authorize_security_group(
self, group_name=None, group_id=None, source_group_name="", source_group_owner_id="",
ip_protocol="", from_port="", to_port="", cidr_ip=""):
"""
There are two ways to use C{authorize_security_group}:
1) associate an existing group (source group) ... | python | def authorize_security_group(
self, group_name=None, group_id=None, source_group_name="", source_group_owner_id="",
ip_protocol="", from_port="", to_port="", cidr_ip=""):
"""
There are two ways to use C{authorize_security_group}:
1) associate an existing group (source group) ... | [
"def",
"authorize_security_group",
"(",
"self",
",",
"group_name",
"=",
"None",
",",
"group_id",
"=",
"None",
",",
"source_group_name",
"=",
"\"\"",
",",
"source_group_owner_id",
"=",
"\"\"",
",",
"ip_protocol",
"=",
"\"\"",
",",
"from_port",
"=",
"\"\"",
",",... | There are two ways to use C{authorize_security_group}:
1) associate an existing group (source group) with the one that you
are targeting (group_name) with an authorization update; or
2) associate a set of IP permissions with the group you are
targeting with an authorizati... | [
"There",
"are",
"two",
"ways",
"to",
"use",
"C",
"{",
"authorize_security_group",
"}",
":",
"1",
")",
"associate",
"an",
"existing",
"group",
"(",
"source",
"group",
")",
"with",
"the",
"one",
"that",
"you",
"are",
"targeting",
"(",
"group_name",
")",
"w... | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L173-L235 |
twisted/txaws | txaws/ec2/client.py | EC2Client.authorize_group_permission | def authorize_group_permission(
self, group_name, source_group_name, source_group_owner_id):
"""
This is a convenience function that wraps the "authorize group"
functionality of the C{authorize_security_group} method.
For an explanation of the parameters, see C{authorize_securit... | python | def authorize_group_permission(
self, group_name, source_group_name, source_group_owner_id):
"""
This is a convenience function that wraps the "authorize group"
functionality of the C{authorize_security_group} method.
For an explanation of the parameters, see C{authorize_securit... | [
"def",
"authorize_group_permission",
"(",
"self",
",",
"group_name",
",",
"source_group_name",
",",
"source_group_owner_id",
")",
":",
"d",
"=",
"self",
".",
"authorize_security_group",
"(",
"group_name",
",",
"source_group_name",
"=",
"source_group_name",
",",
"sourc... | This is a convenience function that wraps the "authorize group"
functionality of the C{authorize_security_group} method.
For an explanation of the parameters, see C{authorize_security_group}. | [
"This",
"is",
"a",
"convenience",
"function",
"that",
"wraps",
"the",
"authorize",
"group",
"functionality",
"of",
"the",
"C",
"{",
"authorize_security_group",
"}",
"method",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L237-L249 |
twisted/txaws | txaws/ec2/client.py | EC2Client.authorize_ip_permission | def authorize_ip_permission(
self, group_name, ip_protocol, from_port, to_port, cidr_ip):
"""
This is a convenience function that wraps the "authorize ip
permission" functionality of the C{authorize_security_group} method.
For an explanation of the parameters, see C{authorize_se... | python | def authorize_ip_permission(
self, group_name, ip_protocol, from_port, to_port, cidr_ip):
"""
This is a convenience function that wraps the "authorize ip
permission" functionality of the C{authorize_security_group} method.
For an explanation of the parameters, see C{authorize_se... | [
"def",
"authorize_ip_permission",
"(",
"self",
",",
"group_name",
",",
"ip_protocol",
",",
"from_port",
",",
"to_port",
",",
"cidr_ip",
")",
":",
"d",
"=",
"self",
".",
"authorize_security_group",
"(",
"group_name",
",",
"ip_protocol",
"=",
"ip_protocol",
",",
... | This is a convenience function that wraps the "authorize ip
permission" functionality of the C{authorize_security_group} method.
For an explanation of the parameters, see C{authorize_security_group}. | [
"This",
"is",
"a",
"convenience",
"function",
"that",
"wraps",
"the",
"authorize",
"ip",
"permission",
"functionality",
"of",
"the",
"C",
"{",
"authorize_security_group",
"}",
"method",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L251-L263 |
twisted/txaws | txaws/ec2/client.py | EC2Client.revoke_group_permission | def revoke_group_permission(
self, group_name, source_group_name, source_group_owner_id):
"""
This is a convenience function that wraps the "authorize group"
functionality of the C{authorize_security_group} method.
For an explanation of the parameters, see C{revoke_security_grou... | python | def revoke_group_permission(
self, group_name, source_group_name, source_group_owner_id):
"""
This is a convenience function that wraps the "authorize group"
functionality of the C{authorize_security_group} method.
For an explanation of the parameters, see C{revoke_security_grou... | [
"def",
"revoke_group_permission",
"(",
"self",
",",
"group_name",
",",
"source_group_name",
",",
"source_group_owner_id",
")",
":",
"d",
"=",
"self",
".",
"revoke_security_group",
"(",
"group_name",
",",
"source_group_name",
"=",
"source_group_name",
",",
"source_grou... | This is a convenience function that wraps the "authorize group"
functionality of the C{authorize_security_group} method.
For an explanation of the parameters, see C{revoke_security_group}. | [
"This",
"is",
"a",
"convenience",
"function",
"that",
"wraps",
"the",
"authorize",
"group",
"functionality",
"of",
"the",
"C",
"{",
"authorize_security_group",
"}",
"method",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L327-L339 |
twisted/txaws | txaws/ec2/client.py | EC2Client.revoke_ip_permission | def revoke_ip_permission(
self, group_name, ip_protocol, from_port, to_port, cidr_ip):
"""
This is a convenience function that wraps the "authorize ip
permission" functionality of the C{authorize_security_group} method.
For an explanation of the parameters, see C{revoke_security... | python | def revoke_ip_permission(
self, group_name, ip_protocol, from_port, to_port, cidr_ip):
"""
This is a convenience function that wraps the "authorize ip
permission" functionality of the C{authorize_security_group} method.
For an explanation of the parameters, see C{revoke_security... | [
"def",
"revoke_ip_permission",
"(",
"self",
",",
"group_name",
",",
"ip_protocol",
",",
"from_port",
",",
"to_port",
",",
"cidr_ip",
")",
":",
"d",
"=",
"self",
".",
"revoke_security_group",
"(",
"group_name",
",",
"ip_protocol",
"=",
"ip_protocol",
",",
"from... | This is a convenience function that wraps the "authorize ip
permission" functionality of the C{authorize_security_group} method.
For an explanation of the parameters, see C{revoke_security_group}. | [
"This",
"is",
"a",
"convenience",
"function",
"that",
"wraps",
"the",
"authorize",
"ip",
"permission",
"functionality",
"of",
"the",
"C",
"{",
"authorize_security_group",
"}",
"method",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L341-L353 |
twisted/txaws | txaws/ec2/client.py | EC2Client.describe_volumes | def describe_volumes(self, *volume_ids):
"""Describe available volumes."""
volumeset = {}
for pos, volume_id in enumerate(volume_ids):
volumeset["VolumeId.%d" % (pos + 1)] = volume_id
query = self.query_factory(
action="DescribeVolumes", creds=self.creds, endpoint... | python | def describe_volumes(self, *volume_ids):
"""Describe available volumes."""
volumeset = {}
for pos, volume_id in enumerate(volume_ids):
volumeset["VolumeId.%d" % (pos + 1)] = volume_id
query = self.query_factory(
action="DescribeVolumes", creds=self.creds, endpoint... | [
"def",
"describe_volumes",
"(",
"self",
",",
"*",
"volume_ids",
")",
":",
"volumeset",
"=",
"{",
"}",
"for",
"pos",
",",
"volume_id",
"in",
"enumerate",
"(",
"volume_ids",
")",
":",
"volumeset",
"[",
"\"VolumeId.%d\"",
"%",
"(",
"pos",
"+",
"1",
")",
"... | Describe available volumes. | [
"Describe",
"available",
"volumes",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L355-L364 |
twisted/txaws | txaws/ec2/client.py | EC2Client.create_volume | def create_volume(self, availability_zone, size=None, snapshot_id=None):
"""Create a new volume."""
params = {"AvailabilityZone": availability_zone}
if ((snapshot_id is None and size is None) or
(snapshot_id is not None and size is not None)):
raise ValueError("Please pro... | python | def create_volume(self, availability_zone, size=None, snapshot_id=None):
"""Create a new volume."""
params = {"AvailabilityZone": availability_zone}
if ((snapshot_id is None and size is None) or
(snapshot_id is not None and size is not None)):
raise ValueError("Please pro... | [
"def",
"create_volume",
"(",
"self",
",",
"availability_zone",
",",
"size",
"=",
"None",
",",
"snapshot_id",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"AvailabilityZone\"",
":",
"availability_zone",
"}",
"if",
"(",
"(",
"snapshot_id",
"is",
"None",
"and",... | Create a new volume. | [
"Create",
"a",
"new",
"volume",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L366-L380 |
twisted/txaws | txaws/ec2/client.py | EC2Client.describe_snapshots | def describe_snapshots(self, *snapshot_ids):
"""Describe available snapshots.
TODO: ownerSet, restorableBySet
"""
snapshot_set = {}
for pos, snapshot_id in enumerate(snapshot_ids):
snapshot_set["SnapshotId.%d" % (pos + 1)] = snapshot_id
query = self.query_fac... | python | def describe_snapshots(self, *snapshot_ids):
"""Describe available snapshots.
TODO: ownerSet, restorableBySet
"""
snapshot_set = {}
for pos, snapshot_id in enumerate(snapshot_ids):
snapshot_set["SnapshotId.%d" % (pos + 1)] = snapshot_id
query = self.query_fac... | [
"def",
"describe_snapshots",
"(",
"self",
",",
"*",
"snapshot_ids",
")",
":",
"snapshot_set",
"=",
"{",
"}",
"for",
"pos",
",",
"snapshot_id",
"in",
"enumerate",
"(",
"snapshot_ids",
")",
":",
"snapshot_set",
"[",
"\"SnapshotId.%d\"",
"%",
"(",
"pos",
"+",
... | Describe available snapshots.
TODO: ownerSet, restorableBySet | [
"Describe",
"available",
"snapshots",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L389-L401 |
twisted/txaws | txaws/ec2/client.py | EC2Client.delete_snapshot | def delete_snapshot(self, snapshot_id):
"""Remove a previously created snapshot."""
query = self.query_factory(
action="DeleteSnapshot", creds=self.creds, endpoint=self.endpoint,
other_params={"SnapshotId": snapshot_id})
d = query.submit()
return d.addCallback(sel... | python | def delete_snapshot(self, snapshot_id):
"""Remove a previously created snapshot."""
query = self.query_factory(
action="DeleteSnapshot", creds=self.creds, endpoint=self.endpoint,
other_params={"SnapshotId": snapshot_id})
d = query.submit()
return d.addCallback(sel... | [
"def",
"delete_snapshot",
"(",
"self",
",",
"snapshot_id",
")",
":",
"query",
"=",
"self",
".",
"query_factory",
"(",
"action",
"=",
"\"DeleteSnapshot\"",
",",
"creds",
"=",
"self",
".",
"creds",
",",
"endpoint",
"=",
"self",
".",
"endpoint",
",",
"other_p... | Remove a previously created snapshot. | [
"Remove",
"a",
"previously",
"created",
"snapshot",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L414-L420 |
twisted/txaws | txaws/ec2/client.py | EC2Client.attach_volume | def attach_volume(self, volume_id, instance_id, device):
"""Attach the given volume to the specified instance at C{device}."""
query = self.query_factory(
action="AttachVolume", creds=self.creds, endpoint=self.endpoint,
other_params={"VolumeId": volume_id, "InstanceId": instance_... | python | def attach_volume(self, volume_id, instance_id, device):
"""Attach the given volume to the specified instance at C{device}."""
query = self.query_factory(
action="AttachVolume", creds=self.creds, endpoint=self.endpoint,
other_params={"VolumeId": volume_id, "InstanceId": instance_... | [
"def",
"attach_volume",
"(",
"self",
",",
"volume_id",
",",
"instance_id",
",",
"device",
")",
":",
"query",
"=",
"self",
".",
"query_factory",
"(",
"action",
"=",
"\"AttachVolume\"",
",",
"creds",
"=",
"self",
".",
"creds",
",",
"endpoint",
"=",
"self",
... | Attach the given volume to the specified instance at C{device}. | [
"Attach",
"the",
"given",
"volume",
"to",
"the",
"specified",
"instance",
"at",
"C",
"{",
"device",
"}",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L422-L429 |
twisted/txaws | txaws/ec2/client.py | EC2Client.describe_keypairs | def describe_keypairs(self, *keypair_names):
"""Returns information about key pairs available."""
keypairs = {}
for index, keypair_name in enumerate(keypair_names):
keypairs["KeyName.%d" % (index + 1)] = keypair_name
query = self.query_factory(
action="DescribeKey... | python | def describe_keypairs(self, *keypair_names):
"""Returns information about key pairs available."""
keypairs = {}
for index, keypair_name in enumerate(keypair_names):
keypairs["KeyName.%d" % (index + 1)] = keypair_name
query = self.query_factory(
action="DescribeKey... | [
"def",
"describe_keypairs",
"(",
"self",
",",
"*",
"keypair_names",
")",
":",
"keypairs",
"=",
"{",
"}",
"for",
"index",
",",
"keypair_name",
"in",
"enumerate",
"(",
"keypair_names",
")",
":",
"keypairs",
"[",
"\"KeyName.%d\"",
"%",
"(",
"index",
"+",
"1",... | Returns information about key pairs available. | [
"Returns",
"information",
"about",
"key",
"pairs",
"available",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L431-L440 |
twisted/txaws | txaws/ec2/client.py | EC2Client.create_keypair | def create_keypair(self, keypair_name):
"""
Create a new 2048 bit RSA key pair and return a unique ID that can be
used to reference the created key pair when launching new instances.
"""
query = self.query_factory(
action="CreateKeyPair", creds=self.creds, endpoint=se... | python | def create_keypair(self, keypair_name):
"""
Create a new 2048 bit RSA key pair and return a unique ID that can be
used to reference the created key pair when launching new instances.
"""
query = self.query_factory(
action="CreateKeyPair", creds=self.creds, endpoint=se... | [
"def",
"create_keypair",
"(",
"self",
",",
"keypair_name",
")",
":",
"query",
"=",
"self",
".",
"query_factory",
"(",
"action",
"=",
"\"CreateKeyPair\"",
",",
"creds",
"=",
"self",
".",
"creds",
",",
"endpoint",
"=",
"self",
".",
"endpoint",
",",
"other_pa... | Create a new 2048 bit RSA key pair and return a unique ID that can be
used to reference the created key pair when launching new instances. | [
"Create",
"a",
"new",
"2048",
"bit",
"RSA",
"key",
"pair",
"and",
"return",
"a",
"unique",
"ID",
"that",
"can",
"be",
"used",
"to",
"reference",
"the",
"created",
"key",
"pair",
"when",
"launching",
"new",
"instances",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L442-L451 |
twisted/txaws | txaws/ec2/client.py | EC2Client.import_keypair | def import_keypair(self, keypair_name, key_material):
"""
Import an existing SSH key into EC2. It supports:
* OpenSSH public key format (e.g., the format in
~/.ssh/authorized_keys)
* Base64 encoded DER format
* SSH public key file format as specified in ... | python | def import_keypair(self, keypair_name, key_material):
"""
Import an existing SSH key into EC2. It supports:
* OpenSSH public key format (e.g., the format in
~/.ssh/authorized_keys)
* Base64 encoded DER format
* SSH public key file format as specified in ... | [
"def",
"import_keypair",
"(",
"self",
",",
"keypair_name",
",",
"key_material",
")",
":",
"query",
"=",
"self",
".",
"query_factory",
"(",
"action",
"=",
"\"ImportKeyPair\"",
",",
"creds",
"=",
"self",
".",
"creds",
",",
"endpoint",
"=",
"self",
".",
"endp... | Import an existing SSH key into EC2. It supports:
* OpenSSH public key format (e.g., the format in
~/.ssh/authorized_keys)
* Base64 encoded DER format
* SSH public key file format as specified in RFC4716
@param keypair_name: The name of the key to create.
... | [
"Import",
"an",
"existing",
"SSH",
"key",
"into",
"EC2",
".",
"It",
"supports",
":",
"*",
"OpenSSH",
"public",
"key",
"format",
"(",
"e",
".",
"g",
".",
"the",
"format",
"in",
"~",
"/",
".",
"ssh",
"/",
"authorized_keys",
")",
"*",
"Base64",
"encoded... | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L461-L483 |
twisted/txaws | txaws/ec2/client.py | EC2Client.allocate_address | def allocate_address(self):
"""
Acquire an elastic IP address to be attached subsequently to EC2
instances.
@return: the IP address allocated.
"""
# XXX remove empty other_params
query = self.query_factory(
action="AllocateAddress", creds=self.creds, ... | python | def allocate_address(self):
"""
Acquire an elastic IP address to be attached subsequently to EC2
instances.
@return: the IP address allocated.
"""
# XXX remove empty other_params
query = self.query_factory(
action="AllocateAddress", creds=self.creds, ... | [
"def",
"allocate_address",
"(",
"self",
")",
":",
"# XXX remove empty other_params",
"query",
"=",
"self",
".",
"query_factory",
"(",
"action",
"=",
"\"AllocateAddress\"",
",",
"creds",
"=",
"self",
".",
"creds",
",",
"endpoint",
"=",
"self",
".",
"endpoint",
... | Acquire an elastic IP address to be attached subsequently to EC2
instances.
@return: the IP address allocated. | [
"Acquire",
"an",
"elastic",
"IP",
"address",
"to",
"be",
"attached",
"subsequently",
"to",
"EC2",
"instances",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L485-L497 |
twisted/txaws | txaws/ec2/client.py | EC2Client.release_address | def release_address(self, address):
"""
Release a previously allocated address returned by C{allocate_address}.
@return: C{True} if the operation succeeded.
"""
query = self.query_factory(
action="ReleaseAddress", creds=self.creds, endpoint=self.endpoint,
... | python | def release_address(self, address):
"""
Release a previously allocated address returned by C{allocate_address}.
@return: C{True} if the operation succeeded.
"""
query = self.query_factory(
action="ReleaseAddress", creds=self.creds, endpoint=self.endpoint,
... | [
"def",
"release_address",
"(",
"self",
",",
"address",
")",
":",
"query",
"=",
"self",
".",
"query_factory",
"(",
"action",
"=",
"\"ReleaseAddress\"",
",",
"creds",
"=",
"self",
".",
"creds",
",",
"endpoint",
"=",
"self",
".",
"endpoint",
",",
"other_param... | Release a previously allocated address returned by C{allocate_address}.
@return: C{True} if the operation succeeded. | [
"Release",
"a",
"previously",
"allocated",
"address",
"returned",
"by",
"C",
"{",
"allocate_address",
"}",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L499-L509 |
twisted/txaws | txaws/ec2/client.py | EC2Client.describe_addresses | def describe_addresses(self, *addresses):
"""
List the elastic IPs allocated in this account.
@param addresses: if specified, the addresses to get information about.
@return: a C{list} of (address, instance_id). If the elastic IP is not
associated currently, C{instance_id} ... | python | def describe_addresses(self, *addresses):
"""
List the elastic IPs allocated in this account.
@param addresses: if specified, the addresses to get information about.
@return: a C{list} of (address, instance_id). If the elastic IP is not
associated currently, C{instance_id} ... | [
"def",
"describe_addresses",
"(",
"self",
",",
"*",
"addresses",
")",
":",
"address_set",
"=",
"{",
"}",
"for",
"pos",
",",
"address",
"in",
"enumerate",
"(",
"addresses",
")",
":",
"address_set",
"[",
"\"PublicIp.%d\"",
"%",
"(",
"pos",
"+",
"1",
")",
... | List the elastic IPs allocated in this account.
@param addresses: if specified, the addresses to get information about.
@return: a C{list} of (address, instance_id). If the elastic IP is not
associated currently, C{instance_id} will be C{None}. | [
"List",
"the",
"elastic",
"IPs",
"allocated",
"in",
"this",
"account",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L537-L553 |
twisted/txaws | txaws/ec2/client.py | Parser.instances_set | def instances_set(self, root, reservation):
"""Parse instance data out of an XML payload.
@param root: The root node of the XML payload.
@param reservation: The L{Reservation} associated with the instances
from the response.
@return: A C{list} of L{Instance}s.
"""
... | python | def instances_set(self, root, reservation):
"""Parse instance data out of an XML payload.
@param root: The root node of the XML payload.
@param reservation: The L{Reservation} associated with the instances
from the response.
@return: A C{list} of L{Instance}s.
"""
... | [
"def",
"instances_set",
"(",
"self",
",",
"root",
",",
"reservation",
")",
":",
"instances",
"=",
"[",
"]",
"for",
"instance_data",
"in",
"root",
".",
"find",
"(",
"\"instancesSet\"",
")",
":",
"instances",
".",
"append",
"(",
"self",
".",
"instance",
"(... | Parse instance data out of an XML payload.
@param root: The root node of the XML payload.
@param reservation: The L{Reservation} associated with the instances
from the response.
@return: A C{list} of L{Instance}s. | [
"Parse",
"instance",
"data",
"out",
"of",
"an",
"XML",
"payload",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L570-L581 |
twisted/txaws | txaws/ec2/client.py | Parser.instance | def instance(self, instance_data, reservation):
"""Parse instance data out of an XML payload.
@param instance_data: An XML node containing instance data.
@param reservation: The L{Reservation} associated with the instance.
@return: An L{Instance}.
TODO: reason, platform, monito... | python | def instance(self, instance_data, reservation):
"""Parse instance data out of an XML payload.
@param instance_data: An XML node containing instance data.
@param reservation: The L{Reservation} associated with the instance.
@return: An L{Instance}.
TODO: reason, platform, monito... | [
"def",
"instance",
"(",
"self",
",",
"instance_data",
",",
"reservation",
")",
":",
"for",
"group_data",
"in",
"instance_data",
".",
"find",
"(",
"\"groupSet\"",
")",
":",
"group_id",
"=",
"group_data",
".",
"findtext",
"(",
"\"groupId\"",
")",
"group_name",
... | Parse instance data out of an XML payload.
@param instance_data: An XML node containing instance data.
@param reservation: The L{Reservation} associated with the instance.
@return: An L{Instance}.
TODO: reason, platform, monitoring, subnetId, vpcId, privateIpAddress,
ipAd... | [
"Parse",
"instance",
"data",
"out",
"of",
"an",
"XML",
"payload",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L583-L624 |
twisted/txaws | txaws/ec2/client.py | Parser.describe_instances | def describe_instances(self, xml_bytes):
"""
Parse the reservations XML payload that is returned from an AWS
describeInstances API call.
Instead of returning the reservations as the "top-most" object, we
return the object that most developers and their code will be
inter... | python | def describe_instances(self, xml_bytes):
"""
Parse the reservations XML payload that is returned from an AWS
describeInstances API call.
Instead of returning the reservations as the "top-most" object, we
return the object that most developers and their code will be
inter... | [
"def",
"describe_instances",
"(",
"self",
",",
"xml_bytes",
")",
":",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"results",
"=",
"[",
"]",
"# May be a more elegant way to do this:",
"for",
"reservation_data",
"in",
"root",
".",
"find",
"(",
"\"reservationSet\"",
... | Parse the reservations XML payload that is returned from an AWS
describeInstances API call.
Instead of returning the reservations as the "top-most" object, we
return the object that most developers and their code will be
interested in: the instances. In instances reservation is availabl... | [
"Parse",
"the",
"reservations",
"XML",
"payload",
"that",
"is",
"returned",
"from",
"an",
"AWS",
"describeInstances",
"API",
"call",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L626-L658 |
twisted/txaws | txaws/ec2/client.py | Parser.run_instances | def run_instances(self, xml_bytes):
"""
Parse the reservations XML payload that is returned from an AWS
RunInstances API call.
@param xml_bytes: raw XML bytes with a C{RunInstancesResponse} root
element.
"""
root = XML(xml_bytes)
# Get the security gr... | python | def run_instances(self, xml_bytes):
"""
Parse the reservations XML payload that is returned from an AWS
RunInstances API call.
@param xml_bytes: raw XML bytes with a C{RunInstancesResponse} root
element.
"""
root = XML(xml_bytes)
# Get the security gr... | [
"def",
"run_instances",
"(",
"self",
",",
"xml_bytes",
")",
":",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"# Get the security group information.",
"groups",
"=",
"[",
"]",
"for",
"group_data",
"in",
"root",
".",
"find",
"(",
"\"groupSet\"",
")",
":",
"grou... | Parse the reservations XML payload that is returned from an AWS
RunInstances API call.
@param xml_bytes: raw XML bytes with a C{RunInstancesResponse} root
element. | [
"Parse",
"the",
"reservations",
"XML",
"payload",
"that",
"is",
"returned",
"from",
"an",
"AWS",
"RunInstances",
"API",
"call",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L660-L681 |
twisted/txaws | txaws/ec2/client.py | Parser.terminate_instances | def terminate_instances(self, xml_bytes):
"""Parse the XML returned by the C{TerminateInstances} function.
@param xml_bytes: XML bytes with a C{TerminateInstancesResponse} root
element.
@return: An iterable of C{tuple} of (instanceId, previousState,
currentState) for the... | python | def terminate_instances(self, xml_bytes):
"""Parse the XML returned by the C{TerminateInstances} function.
@param xml_bytes: XML bytes with a C{TerminateInstancesResponse} root
element.
@return: An iterable of C{tuple} of (instanceId, previousState,
currentState) for the... | [
"def",
"terminate_instances",
"(",
"self",
",",
"xml_bytes",
")",
":",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"result",
"=",
"[",
"]",
"# May be a more elegant way to do this:",
"instances",
"=",
"root",
".",
"find",
"(",
"\"instancesSet\"",
")",
"if",
"in... | Parse the XML returned by the C{TerminateInstances} function.
@param xml_bytes: XML bytes with a C{TerminateInstancesResponse} root
element.
@return: An iterable of C{tuple} of (instanceId, previousState,
currentState) for the ec2 instances that where terminated. | [
"Parse",
"the",
"XML",
"returned",
"by",
"the",
"C",
"{",
"TerminateInstances",
"}",
"function",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L683-L703 |
twisted/txaws | txaws/ec2/client.py | Parser.describe_security_groups | def describe_security_groups(self, xml_bytes):
"""Parse the XML returned by the C{DescribeSecurityGroups} function.
@param xml_bytes: XML bytes with a C{DescribeSecurityGroupsResponse}
root element.
@return: A list of L{SecurityGroup} instances.
"""
root = XML(xml_by... | python | def describe_security_groups(self, xml_bytes):
"""Parse the XML returned by the C{DescribeSecurityGroups} function.
@param xml_bytes: XML bytes with a C{DescribeSecurityGroupsResponse}
root element.
@return: A list of L{SecurityGroup} instances.
"""
root = XML(xml_by... | [
"def",
"describe_security_groups",
"(",
"self",
",",
"xml_bytes",
")",
":",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"result",
"=",
"[",
"]",
"for",
"group_info",
"in",
"root",
".",
"findall",
"(",
"\"securityGroupInfo/item\"",
")",
":",
"id",
"=",
"grou... | Parse the XML returned by the C{DescribeSecurityGroups} function.
@param xml_bytes: XML bytes with a C{DescribeSecurityGroupsResponse}
root element.
@return: A list of L{SecurityGroup} instances. | [
"Parse",
"the",
"XML",
"returned",
"by",
"the",
"C",
"{",
"DescribeSecurityGroups",
"}",
"function",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L717-L770 |
twisted/txaws | txaws/ec2/client.py | Parser.describe_volumes | def describe_volumes(self, xml_bytes):
"""Parse the XML returned by the C{DescribeVolumes} function.
@param xml_bytes: XML bytes with a C{DescribeVolumesResponse} root
element.
@return: A list of L{Volume} instances.
TODO: attachementSetItemResponseType#deleteOnTermination
... | python | def describe_volumes(self, xml_bytes):
"""Parse the XML returned by the C{DescribeVolumes} function.
@param xml_bytes: XML bytes with a C{DescribeVolumesResponse} root
element.
@return: A list of L{Volume} instances.
TODO: attachementSetItemResponseType#deleteOnTermination
... | [
"def",
"describe_volumes",
"(",
"self",
",",
"xml_bytes",
")",
":",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"result",
"=",
"[",
"]",
"for",
"volume_data",
"in",
"root",
".",
"find",
"(",
"\"volumeSet\"",
")",
":",
"volume_id",
"=",
"volume_data",
".",... | Parse the XML returned by the C{DescribeVolumes} function.
@param xml_bytes: XML bytes with a C{DescribeVolumesResponse} root
element.
@return: A list of L{Volume} instances.
TODO: attachementSetItemResponseType#deleteOnTermination | [
"Parse",
"the",
"XML",
"returned",
"by",
"the",
"C",
"{",
"DescribeVolumes",
"}",
"function",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L785-L819 |
twisted/txaws | txaws/ec2/client.py | Parser.create_volume | def create_volume(self, xml_bytes):
"""Parse the XML returned by the C{CreateVolume} function.
@param xml_bytes: XML bytes with a C{CreateVolumeResponse} root
element.
@return: The L{Volume} instance created.
"""
root = XML(xml_bytes)
volume_id = root.findtex... | python | def create_volume(self, xml_bytes):
"""Parse the XML returned by the C{CreateVolume} function.
@param xml_bytes: XML bytes with a C{CreateVolumeResponse} root
element.
@return: The L{Volume} instance created.
"""
root = XML(xml_bytes)
volume_id = root.findtex... | [
"def",
"create_volume",
"(",
"self",
",",
"xml_bytes",
")",
":",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"volume_id",
"=",
"root",
".",
"findtext",
"(",
"\"volumeId\"",
")",
"size",
"=",
"int",
"(",
"root",
".",
"findtext",
"(",
"\"size\"",
")",
")"... | Parse the XML returned by the C{CreateVolume} function.
@param xml_bytes: XML bytes with a C{CreateVolumeResponse} root
element.
@return: The L{Volume} instance created. | [
"Parse",
"the",
"XML",
"returned",
"by",
"the",
"C",
"{",
"CreateVolume",
"}",
"function",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L821-L840 |
twisted/txaws | txaws/ec2/client.py | Parser.snapshots | def snapshots(self, xml_bytes):
"""Parse the XML returned by the C{DescribeSnapshots} function.
@param xml_bytes: XML bytes with a C{DescribeSnapshotsResponse} root
element.
@return: A list of L{Snapshot} instances.
TODO: ownersSet, restorableBySet, ownerId, volumeSize, des... | python | def snapshots(self, xml_bytes):
"""Parse the XML returned by the C{DescribeSnapshots} function.
@param xml_bytes: XML bytes with a C{DescribeSnapshotsResponse} root
element.
@return: A list of L{Snapshot} instances.
TODO: ownersSet, restorableBySet, ownerId, volumeSize, des... | [
"def",
"snapshots",
"(",
"self",
",",
"xml_bytes",
")",
":",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"result",
"=",
"[",
"]",
"for",
"snapshot_data",
"in",
"root",
".",
"find",
"(",
"\"snapshotSet\"",
")",
":",
"snapshot_id",
"=",
"snapshot_data",
"."... | Parse the XML returned by the C{DescribeSnapshots} function.
@param xml_bytes: XML bytes with a C{DescribeSnapshotsResponse} root
element.
@return: A list of L{Snapshot} instances.
TODO: ownersSet, restorableBySet, ownerId, volumeSize, description,
ownerAlias. | [
"Parse",
"the",
"XML",
"returned",
"by",
"the",
"C",
"{",
"DescribeSnapshots",
"}",
"function",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L842-L866 |
twisted/txaws | txaws/ec2/client.py | Parser.create_snapshot | def create_snapshot(self, xml_bytes):
"""Parse the XML returned by the C{CreateSnapshot} function.
@param xml_bytes: XML bytes with a C{CreateSnapshotResponse} root
element.
@return: The L{Snapshot} instance created.
TODO: ownerId, volumeSize, description.
"""
... | python | def create_snapshot(self, xml_bytes):
"""Parse the XML returned by the C{CreateSnapshot} function.
@param xml_bytes: XML bytes with a C{CreateSnapshotResponse} root
element.
@return: The L{Snapshot} instance created.
TODO: ownerId, volumeSize, description.
"""
... | [
"def",
"create_snapshot",
"(",
"self",
",",
"xml_bytes",
")",
":",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"snapshot_id",
"=",
"root",
".",
"findtext",
"(",
"\"snapshotId\"",
")",
"volume_id",
"=",
"root",
".",
"findtext",
"(",
"\"volumeId\"",
")",
"sta... | Parse the XML returned by the C{CreateSnapshot} function.
@param xml_bytes: XML bytes with a C{CreateSnapshotResponse} root
element.
@return: The L{Snapshot} instance created.
TODO: ownerId, volumeSize, description. | [
"Parse",
"the",
"XML",
"returned",
"by",
"the",
"C",
"{",
"CreateSnapshot",
"}",
"function",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L868-L887 |
twisted/txaws | txaws/ec2/client.py | Parser.attach_volume | def attach_volume(self, xml_bytes):
"""Parse the XML returned by the C{AttachVolume} function.
@param xml_bytes: XML bytes with a C{AttachVolumeResponse} root
element.
@return: a C{dict} with status and attach_time keys.
TODO: volumeId, instanceId, device
"""
... | python | def attach_volume(self, xml_bytes):
"""Parse the XML returned by the C{AttachVolume} function.
@param xml_bytes: XML bytes with a C{AttachVolumeResponse} root
element.
@return: a C{dict} with status and attach_time keys.
TODO: volumeId, instanceId, device
"""
... | [
"def",
"attach_volume",
"(",
"self",
",",
"xml_bytes",
")",
":",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"status",
"=",
"root",
".",
"findtext",
"(",
"\"status\"",
")",
"attach_time",
"=",
"root",
".",
"findtext",
"(",
"\"attachTime\"",
")",
"attach_tim... | Parse the XML returned by the C{AttachVolume} function.
@param xml_bytes: XML bytes with a C{AttachVolumeResponse} root
element.
@return: a C{dict} with status and attach_time keys.
TODO: volumeId, instanceId, device | [
"Parse",
"the",
"XML",
"returned",
"by",
"the",
"C",
"{",
"AttachVolume",
"}",
"function",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L889-L903 |
twisted/txaws | txaws/ec2/client.py | Parser.describe_keypairs | def describe_keypairs(self, xml_bytes):
"""Parse the XML returned by the C{DescribeKeyPairs} function.
@param xml_bytes: XML bytes with a C{DescribeKeyPairsResponse} root
element.
@return: a C{list} of L{Keypair}.
"""
results = []
root = XML(xml_bytes)
... | python | def describe_keypairs(self, xml_bytes):
"""Parse the XML returned by the C{DescribeKeyPairs} function.
@param xml_bytes: XML bytes with a C{DescribeKeyPairsResponse} root
element.
@return: a C{list} of L{Keypair}.
"""
results = []
root = XML(xml_bytes)
... | [
"def",
"describe_keypairs",
"(",
"self",
",",
"xml_bytes",
")",
":",
"results",
"=",
"[",
"]",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"keypairs",
"=",
"root",
".",
"find",
"(",
"\"keySet\"",
")",
"if",
"keypairs",
"is",
"None",
":",
"return",
"resu... | Parse the XML returned by the C{DescribeKeyPairs} function.
@param xml_bytes: XML bytes with a C{DescribeKeyPairsResponse} root
element.
@return: a C{list} of L{Keypair}. | [
"Parse",
"the",
"XML",
"returned",
"by",
"the",
"C",
"{",
"DescribeKeyPairs",
"}",
"function",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L905-L921 |
twisted/txaws | txaws/ec2/client.py | Parser.create_keypair | def create_keypair(self, xml_bytes):
"""Parse the XML returned by the C{CreateKeyPair} function.
@param xml_bytes: XML bytes with a C{CreateKeyPairResponse} root
element.
@return: The L{Keypair} instance created.
"""
keypair_data = XML(xml_bytes)
key_name = k... | python | def create_keypair(self, xml_bytes):
"""Parse the XML returned by the C{CreateKeyPair} function.
@param xml_bytes: XML bytes with a C{CreateKeyPairResponse} root
element.
@return: The L{Keypair} instance created.
"""
keypair_data = XML(xml_bytes)
key_name = k... | [
"def",
"create_keypair",
"(",
"self",
",",
"xml_bytes",
")",
":",
"keypair_data",
"=",
"XML",
"(",
"xml_bytes",
")",
"key_name",
"=",
"keypair_data",
".",
"findtext",
"(",
"\"keyName\"",
")",
"key_fingerprint",
"=",
"keypair_data",
".",
"findtext",
"(",
"\"key... | Parse the XML returned by the C{CreateKeyPair} function.
@param xml_bytes: XML bytes with a C{CreateKeyPairResponse} root
element.
@return: The L{Keypair} instance created. | [
"Parse",
"the",
"XML",
"returned",
"by",
"the",
"C",
"{",
"CreateKeyPair",
"}",
"function",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L923-L934 |
twisted/txaws | txaws/ec2/client.py | Parser.describe_addresses | def describe_addresses(self, xml_bytes):
"""Parse the XML returned by the C{DescribeAddresses} function.
@param xml_bytes: XML bytes with a C{DescribeAddressesResponse} root
element.
@return: a C{list} of L{tuple} of (publicIp, instancId).
"""
results = []
ro... | python | def describe_addresses(self, xml_bytes):
"""Parse the XML returned by the C{DescribeAddresses} function.
@param xml_bytes: XML bytes with a C{DescribeAddressesResponse} root
element.
@return: a C{list} of L{tuple} of (publicIp, instancId).
"""
results = []
ro... | [
"def",
"describe_addresses",
"(",
"self",
",",
"xml_bytes",
")",
":",
"results",
"=",
"[",
"]",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"for",
"address_data",
"in",
"root",
".",
"find",
"(",
"\"addressesSet\"",
")",
":",
"address",
"=",
"address_data",
... | Parse the XML returned by the C{DescribeAddresses} function.
@param xml_bytes: XML bytes with a C{DescribeAddressesResponse} root
element.
@return: a C{list} of L{tuple} of (publicIp, instancId). | [
"Parse",
"the",
"XML",
"returned",
"by",
"the",
"C",
"{",
"DescribeAddresses",
"}",
"function",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L956-L969 |
twisted/txaws | txaws/ec2/client.py | Parser.describe_availability_zones | def describe_availability_zones(self, xml_bytes):
"""Parse the XML returned by the C{DescribeAvailibilityZones} function.
@param xml_bytes: XML bytes with a C{DescribeAvailibilityZonesResponse}
root element.
@return: a C{list} of L{AvailabilityZone}.
TODO: regionName, messa... | python | def describe_availability_zones(self, xml_bytes):
"""Parse the XML returned by the C{DescribeAvailibilityZones} function.
@param xml_bytes: XML bytes with a C{DescribeAvailibilityZonesResponse}
root element.
@return: a C{list} of L{AvailabilityZone}.
TODO: regionName, messa... | [
"def",
"describe_availability_zones",
"(",
"self",
",",
"xml_bytes",
")",
":",
"results",
"=",
"[",
"]",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"for",
"zone_data",
"in",
"root",
".",
"find",
"(",
"\"availabilityZoneInfo\"",
")",
":",
"zone_name",
"=",
... | Parse the XML returned by the C{DescribeAvailibilityZones} function.
@param xml_bytes: XML bytes with a C{DescribeAvailibilityZonesResponse}
root element.
@return: a C{list} of L{AvailabilityZone}.
TODO: regionName, messageSet | [
"Parse",
"the",
"XML",
"returned",
"by",
"the",
"C",
"{",
"DescribeAvailibilityZones",
"}",
"function",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L971-L986 |
twisted/txaws | txaws/ec2/client.py | Query.sign | def sign(self, hash_type="sha256"):
"""Sign this query using its built in credentials.
@param hash_type: if the SignatureVersion is 2, specify the type of
hash to use, either "sha1" or "sha256". It defaults to the latter.
This prepares it to be sent, and should be done as the last ... | python | def sign(self, hash_type="sha256"):
"""Sign this query using its built in credentials.
@param hash_type: if the SignatureVersion is 2, specify the type of
hash to use, either "sha1" or "sha256". It defaults to the latter.
This prepares it to be sent, and should be done as the last ... | [
"def",
"sign",
"(",
"self",
",",
"hash_type",
"=",
"\"sha256\"",
")",
":",
"version",
"=",
"self",
".",
"params",
"[",
"\"SignatureVersion\"",
"]",
"if",
"version",
"==",
"\"2\"",
":",
"self",
".",
"params",
"[",
"\"SignatureMethod\"",
"]",
"=",
"\"Hmac%s\... | Sign this query using its built in credentials.
@param hash_type: if the SignatureVersion is 2, specify the type of
hash to use, either "sha1" or "sha256". It defaults to the latter.
This prepares it to be sent, and should be done as the last step before
submitting the query. Signi... | [
"Sign",
"this",
"query",
"using",
"its",
"built",
"in",
"credentials",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L1015-L1028 |
twisted/txaws | txaws/ec2/client.py | Query.submit | def submit(self):
"""Submit this query.
@return: A deferred from get_page
"""
self.sign()
url = self.endpoint.get_uri()
method = self.endpoint.method
params = self.signature.get_canonical_query_params()
headers = {}
kwargs = {"method": method}
... | python | def submit(self):
"""Submit this query.
@return: A deferred from get_page
"""
self.sign()
url = self.endpoint.get_uri()
method = self.endpoint.method
params = self.signature.get_canonical_query_params()
headers = {}
kwargs = {"method": method}
... | [
"def",
"submit",
"(",
"self",
")",
":",
"self",
".",
"sign",
"(",
")",
"url",
"=",
"self",
".",
"endpoint",
".",
"get_uri",
"(",
")",
"method",
"=",
"self",
".",
"endpoint",
".",
"method",
"params",
"=",
"self",
".",
"signature",
".",
"get_canonical_... | Submit this query.
@return: A deferred from get_page | [
"Submit",
"this",
"query",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L1030-L1053 |
twisted/txaws | txaws/ec2/client.py | Signature.compute | def compute(self):
"""Compute and return the signature according to the given data."""
if "Signature" in self.params:
raise RuntimeError("Existing signature in parameters")
if self.signature_version is not None:
version = self.signature_version
else:
v... | python | def compute(self):
"""Compute and return the signature according to the given data."""
if "Signature" in self.params:
raise RuntimeError("Existing signature in parameters")
if self.signature_version is not None:
version = self.signature_version
else:
v... | [
"def",
"compute",
"(",
"self",
")",
":",
"if",
"\"Signature\"",
"in",
"self",
".",
"params",
":",
"raise",
"RuntimeError",
"(",
"\"Existing signature in parameters\"",
")",
"if",
"self",
".",
"signature_version",
"is",
"not",
"None",
":",
"version",
"=",
"self... | Compute and return the signature according to the given data. | [
"Compute",
"and",
"return",
"the",
"signature",
"according",
"to",
"the",
"given",
"data",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L1077-L1097 |
twisted/txaws | txaws/ec2/client.py | Signature.old_signing_text | def old_signing_text(self):
"""Return the text needed for signing using SignatureVersion 1."""
result = []
lower_cmp = lambda x, y: cmp(x[0].lower(), y[0].lower())
for key, value in sorted(self.params.items(), cmp=lower_cmp):
result.append("%s%s" % (key, value))
retur... | python | def old_signing_text(self):
"""Return the text needed for signing using SignatureVersion 1."""
result = []
lower_cmp = lambda x, y: cmp(x[0].lower(), y[0].lower())
for key, value in sorted(self.params.items(), cmp=lower_cmp):
result.append("%s%s" % (key, value))
retur... | [
"def",
"old_signing_text",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"lower_cmp",
"=",
"lambda",
"x",
",",
"y",
":",
"cmp",
"(",
"x",
"[",
"0",
"]",
".",
"lower",
"(",
")",
",",
"y",
"[",
"0",
"]",
".",
"lower",
"(",
")",
")",
"for",
... | Return the text needed for signing using SignatureVersion 1. | [
"Return",
"the",
"text",
"needed",
"for",
"signing",
"using",
"SignatureVersion",
"1",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L1099-L1105 |
twisted/txaws | txaws/ec2/client.py | Signature.signing_text | def signing_text(self):
"""Return the text to be signed when signing the query."""
result = "%s\n%s\n%s\n%s" % (self.endpoint.method,
self.endpoint.get_canonical_host(),
self.endpoint.path,
sel... | python | def signing_text(self):
"""Return the text to be signed when signing the query."""
result = "%s\n%s\n%s\n%s" % (self.endpoint.method,
self.endpoint.get_canonical_host(),
self.endpoint.path,
sel... | [
"def",
"signing_text",
"(",
"self",
")",
":",
"result",
"=",
"\"%s\\n%s\\n%s\\n%s\"",
"%",
"(",
"self",
".",
"endpoint",
".",
"method",
",",
"self",
".",
"endpoint",
".",
"get_canonical_host",
"(",
")",
",",
"self",
".",
"endpoint",
".",
"path",
",",
"se... | Return the text to be signed when signing the query. | [
"Return",
"the",
"text",
"to",
"be",
"signed",
"when",
"signing",
"the",
"query",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L1107-L1113 |
twisted/txaws | txaws/ec2/client.py | Signature.get_canonical_query_params | def get_canonical_query_params(self):
"""Return the canonical query params (used in signing)."""
result = []
for key, value in self.sorted_params():
result.append("%s=%s" % (self.encode(key), self.encode(value)))
return "&".join(result) | python | def get_canonical_query_params(self):
"""Return the canonical query params (used in signing)."""
result = []
for key, value in self.sorted_params():
result.append("%s=%s" % (self.encode(key), self.encode(value)))
return "&".join(result) | [
"def",
"get_canonical_query_params",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"self",
".",
"sorted_params",
"(",
")",
":",
"result",
".",
"append",
"(",
"\"%s=%s\"",
"%",
"(",
"self",
".",
"encode",
"(",
"key",
... | Return the canonical query params (used in signing). | [
"Return",
"the",
"canonical",
"query",
"params",
"(",
"used",
"in",
"signing",
")",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L1115-L1120 |
twisted/txaws | txaws/ec2/client.py | Signature.encode | def encode(self, string):
"""Encode a_string as per the canonicalisation encoding rules.
See the AWS dev reference page 186 (2009-11-30 version).
@return: a_string encoded.
"""
if isinstance(string, unicode):
string = string.encode("utf-8")
return quote(strin... | python | def encode(self, string):
"""Encode a_string as per the canonicalisation encoding rules.
See the AWS dev reference page 186 (2009-11-30 version).
@return: a_string encoded.
"""
if isinstance(string, unicode):
string = string.encode("utf-8")
return quote(strin... | [
"def",
"encode",
"(",
"self",
",",
"string",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"unicode",
")",
":",
"string",
"=",
"string",
".",
"encode",
"(",
"\"utf-8\"",
")",
"return",
"quote",
"(",
"string",
",",
"safe",
"=",
"\"~\"",
")"
] | Encode a_string as per the canonicalisation encoding rules.
See the AWS dev reference page 186 (2009-11-30 version).
@return: a_string encoded. | [
"Encode",
"a_string",
"as",
"per",
"the",
"canonicalisation",
"encoding",
"rules",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/ec2/client.py#L1122-L1130 |
twisted/txaws | txaws/s3/model.py | MultipartInitiationResponse.from_xml | def from_xml(cls, xml_bytes):
"""
Create an instance of this from XML bytes.
@param xml_bytes: C{str} bytes of XML to parse
@return: an instance of L{MultipartInitiationResponse}
"""
root = XML(xml_bytes)
return cls(root.findtext('Bucket'),
roo... | python | def from_xml(cls, xml_bytes):
"""
Create an instance of this from XML bytes.
@param xml_bytes: C{str} bytes of XML to parse
@return: an instance of L{MultipartInitiationResponse}
"""
root = XML(xml_bytes)
return cls(root.findtext('Bucket'),
roo... | [
"def",
"from_xml",
"(",
"cls",
",",
"xml_bytes",
")",
":",
"root",
"=",
"XML",
"(",
"xml_bytes",
")",
"return",
"cls",
"(",
"root",
".",
"findtext",
"(",
"'Bucket'",
")",
",",
"root",
".",
"findtext",
"(",
"'Key'",
")",
",",
"root",
".",
"findtext",
... | Create an instance of this from XML bytes.
@param xml_bytes: C{str} bytes of XML to parse
@return: an instance of L{MultipartInitiationResponse} | [
"Create",
"an",
"instance",
"of",
"this",
"from",
"XML",
"bytes",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/s3/model.py#L178-L188 |
T-002/pycast | pycast/common/matrix.py | pythag | def pythag(a, b):
"""Computer c = (a^2 + b^2)^0.5 without destructive underflow or overflow
It solves the Pythagorean theorem a^2 + b^2 = c^2
"""
absA = abs(a)
absB = abs(b)
if absA > absB:
return absA * sqrt(1.0 + (absB / float(absA)) ** 2)
elif absB == 0.0:
return 0.0
... | python | def pythag(a, b):
"""Computer c = (a^2 + b^2)^0.5 without destructive underflow or overflow
It solves the Pythagorean theorem a^2 + b^2 = c^2
"""
absA = abs(a)
absB = abs(b)
if absA > absB:
return absA * sqrt(1.0 + (absB / float(absA)) ** 2)
elif absB == 0.0:
return 0.0
... | [
"def",
"pythag",
"(",
"a",
",",
"b",
")",
":",
"absA",
"=",
"abs",
"(",
"a",
")",
"absB",
"=",
"abs",
"(",
"b",
")",
"if",
"absA",
">",
"absB",
":",
"return",
"absA",
"*",
"sqrt",
"(",
"1.0",
"+",
"(",
"absB",
"/",
"float",
"(",
"absA",
")"... | Computer c = (a^2 + b^2)^0.5 without destructive underflow or overflow
It solves the Pythagorean theorem a^2 + b^2 = c^2 | [
"Computer",
"c",
"=",
"(",
"a^2",
"+",
"b^2",
")",
"^0",
".",
"5",
"without",
"destructive",
"underflow",
"or",
"overflow"
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L40-L52 |
T-002/pycast | pycast/common/matrix.py | Matrix._initialize_with_array | def _initialize_with_array(self, data, rowBased=True):
"""Set the matrix values from a two dimensional list."""
if rowBased:
self.matrix = []
if len(data) != self._rows:
raise ValueError("Size of Matrix does not match")
for col in xrange(self._columns)... | python | def _initialize_with_array(self, data, rowBased=True):
"""Set the matrix values from a two dimensional list."""
if rowBased:
self.matrix = []
if len(data) != self._rows:
raise ValueError("Size of Matrix does not match")
for col in xrange(self._columns)... | [
"def",
"_initialize_with_array",
"(",
"self",
",",
"data",
",",
"rowBased",
"=",
"True",
")",
":",
"if",
"rowBased",
":",
"self",
".",
"matrix",
"=",
"[",
"]",
"if",
"len",
"(",
"data",
")",
"!=",
"self",
".",
"_rows",
":",
"raise",
"ValueError",
"("... | Set the matrix values from a two dimensional list. | [
"Set",
"the",
"matrix",
"values",
"from",
"a",
"two",
"dimensional",
"list",
"."
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L154-L172 |
T-002/pycast | pycast/common/matrix.py | Matrix.from_timeseries | def from_timeseries(cls, timeSeries):
"""Create a new Matrix instance from a TimeSeries or MultiDimensionalTimeSeries
:param TimeSeries timeSeries: The TimeSeries, which should be used to
create a new Matrix.
:return: A Matrix with the values of the timeSeries. Each row of
... | python | def from_timeseries(cls, timeSeries):
"""Create a new Matrix instance from a TimeSeries or MultiDimensionalTimeSeries
:param TimeSeries timeSeries: The TimeSeries, which should be used to
create a new Matrix.
:return: A Matrix with the values of the timeSeries. Each row of
... | [
"def",
"from_timeseries",
"(",
"cls",
",",
"timeSeries",
")",
":",
"width",
"=",
"1",
"if",
"isinstance",
"(",
"timeSeries",
",",
"MultiDimensionalTimeSeries",
")",
":",
"width",
"=",
"timeSeries",
".",
"dimension_count",
"(",
")",
"matrixData",
"=",
"[",
"[... | Create a new Matrix instance from a TimeSeries or MultiDimensionalTimeSeries
:param TimeSeries timeSeries: The TimeSeries, which should be used to
create a new Matrix.
:return: A Matrix with the values of the timeSeries. Each row of
the Matrix represents one entry... | [
"Create",
"a",
"new",
"Matrix",
"instance",
"from",
"a",
"TimeSeries",
"or",
"MultiDimensionalTimeSeries"
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L175-L202 |
T-002/pycast | pycast/common/matrix.py | Matrix.from_two_dim_array | def from_two_dim_array(cls, cols, rows, twoDimArray):
"""Create a new Matrix instance from a two dimensional array.
:param integer columns: The number of columns for the Matrix.
:param integer rows: The number of rows for the Matrix.
:param list twoDimArray: A two dimensio... | python | def from_two_dim_array(cls, cols, rows, twoDimArray):
"""Create a new Matrix instance from a two dimensional array.
:param integer columns: The number of columns for the Matrix.
:param integer rows: The number of rows for the Matrix.
:param list twoDimArray: A two dimensio... | [
"def",
"from_two_dim_array",
"(",
"cls",
",",
"cols",
",",
"rows",
",",
"twoDimArray",
")",
":",
"return",
"Matrix",
"(",
"cols",
",",
"rows",
",",
"twoDimArray",
",",
"rowBased",
"=",
"False",
",",
"isOneDimArray",
"=",
"False",
")"
] | Create a new Matrix instance from a two dimensional array.
:param integer columns: The number of columns for the Matrix.
:param integer rows: The number of rows for the Matrix.
:param list twoDimArray: A two dimensional column based array
with t... | [
"Create",
"a",
"new",
"Matrix",
"instance",
"from",
"a",
"two",
"dimensional",
"array",
"."
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L205-L218 |
T-002/pycast | pycast/common/matrix.py | Matrix.to_multi_dim_timeseries | def to_multi_dim_timeseries(self):
"""Return a TimeSeries with the values of :py:obj:`self`
The index of the row is used for the timestamp
:return: Return a new MultiDimensionalTimeSeries with the values
of the Matrix
:rtype: MultiDimensionalTimeSeries
... | python | def to_multi_dim_timeseries(self):
"""Return a TimeSeries with the values of :py:obj:`self`
The index of the row is used for the timestamp
:return: Return a new MultiDimensionalTimeSeries with the values
of the Matrix
:rtype: MultiDimensionalTimeSeries
... | [
"def",
"to_multi_dim_timeseries",
"(",
"self",
")",
":",
"ts",
"=",
"MultiDimensionalTimeSeries",
"(",
"dimensions",
"=",
"self",
".",
"get_width",
"(",
")",
")",
"for",
"row",
"in",
"xrange",
"(",
"self",
".",
"get_height",
"(",
")",
")",
":",
"newEntry",... | Return a TimeSeries with the values of :py:obj:`self`
The index of the row is used for the timestamp
:return: Return a new MultiDimensionalTimeSeries with the values
of the Matrix
:rtype: MultiDimensionalTimeSeries | [
"Return",
"a",
"TimeSeries",
"with",
"the",
"values",
"of",
":",
"py",
":",
"obj",
":",
"self"
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L236-L251 |
T-002/pycast | pycast/common/matrix.py | Matrix.get_array | def get_array(self, rowBased=True):
"""Return a two dimensional list with the values of the :py:obj:`self`.
:param boolean rowBased: Indicates wether the returned list should be
row or column based. Has to be True if list[i] should be the i'th
row, False if list[i] should be the... | python | def get_array(self, rowBased=True):
"""Return a two dimensional list with the values of the :py:obj:`self`.
:param boolean rowBased: Indicates wether the returned list should be
row or column based. Has to be True if list[i] should be the i'th
row, False if list[i] should be the... | [
"def",
"get_array",
"(",
"self",
",",
"rowBased",
"=",
"True",
")",
":",
"if",
"rowBased",
":",
"array",
"=",
"[",
"]",
"for",
"row",
"in",
"xrange",
"(",
"self",
".",
"_rows",
")",
":",
"newRow",
"=",
"[",
"]",
"for",
"col",
"in",
"xrange",
"(",... | Return a two dimensional list with the values of the :py:obj:`self`.
:param boolean rowBased: Indicates wether the returned list should be
row or column based. Has to be True if list[i] should be the i'th
row, False if list[i] should be the i'th column.
:return: Returns a li... | [
"Return",
"a",
"two",
"dimensional",
"list",
"with",
"the",
"values",
"of",
"the",
":",
"py",
":",
"obj",
":",
"self",
"."
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L253-L272 |
T-002/pycast | pycast/common/matrix.py | Matrix.get_matrix_from_list | def get_matrix_from_list(self, rows, columns, matrix_list, rowBased=True):
"""Create a new Matrix instance from a matrix_list.
:note: This method is used to create a Matrix instance using cpython.
:param integer rows: The height of the Matrix.
:param integer columns: The widt... | python | def get_matrix_from_list(self, rows, columns, matrix_list, rowBased=True):
"""Create a new Matrix instance from a matrix_list.
:note: This method is used to create a Matrix instance using cpython.
:param integer rows: The height of the Matrix.
:param integer columns: The widt... | [
"def",
"get_matrix_from_list",
"(",
"self",
",",
"rows",
",",
"columns",
",",
"matrix_list",
",",
"rowBased",
"=",
"True",
")",
":",
"resultMatrix",
"=",
"Matrix",
"(",
"columns",
",",
"rows",
",",
"matrix_list",
",",
"rowBased",
")",
"return",
"resultMatrix... | Create a new Matrix instance from a matrix_list.
:note: This method is used to create a Matrix instance using cpython.
:param integer rows: The height of the Matrix.
:param integer columns: The width of the Matrix.
:param matrix_list: A one dimensional list containing... | [
"Create",
"a",
"new",
"Matrix",
"instance",
"from",
"a",
"matrix_list",
"."
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L274-L290 |
T-002/pycast | pycast/common/matrix.py | Matrix.set_value | def set_value(self, column, row, value):
"""Set the value of the Matrix at the specified column and row.
:param integer column: The index for the column (starting at 0)
:param integer row: The index for the row (starting at 0)
:param numeric value: The new value at the given colu... | python | def set_value(self, column, row, value):
"""Set the value of the Matrix at the specified column and row.
:param integer column: The index for the column (starting at 0)
:param integer row: The index for the row (starting at 0)
:param numeric value: The new value at the given colu... | [
"def",
"set_value",
"(",
"self",
",",
"column",
",",
"row",
",",
"value",
")",
":",
"self",
".",
"matrix",
"[",
"column",
"]",
"[",
"row",
"]",
"=",
"value"
] | Set the value of the Matrix at the specified column and row.
:param integer column: The index for the column (starting at 0)
:param integer row: The index for the row (starting at 0)
:param numeric value: The new value at the given column/row
:raise: Raises an :py:exc:`Index... | [
"Set",
"the",
"value",
"of",
"the",
"Matrix",
"at",
"the",
"specified",
"column",
"and",
"row",
"."
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L292-L301 |
T-002/pycast | pycast/common/matrix.py | Matrix.invers | def invers(self):
"""Return the invers matrix, if it can be calculated
:return: Returns a new Matrix containing the invers
:rtype: Matrix
:raise: Raises an :py:exc:`ValueError` if the matrix is not inversible
:note: Only a squared matrix with a determinant != 0... | python | def invers(self):
"""Return the invers matrix, if it can be calculated
:return: Returns a new Matrix containing the invers
:rtype: Matrix
:raise: Raises an :py:exc:`ValueError` if the matrix is not inversible
:note: Only a squared matrix with a determinant != 0... | [
"def",
"invers",
"(",
"self",
")",
":",
"if",
"self",
".",
"_columns",
"!=",
"self",
".",
"_rows",
":",
"raise",
"ValueError",
"(",
"\"A square matrix is needed\"",
")",
"mArray",
"=",
"self",
".",
"get_array",
"(",
"False",
")",
"appList",
"=",
"[",
"0"... | Return the invers matrix, if it can be calculated
:return: Returns a new Matrix containing the invers
:rtype: Matrix
:raise: Raises an :py:exc:`ValueError` if the matrix is not inversible
:note: Only a squared matrix with a determinant != 0 can be inverted.
:to... | [
"Return",
"the",
"invers",
"matrix",
"if",
"it",
"can",
"be",
"calculated"
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L333-L361 |
T-002/pycast | pycast/common/matrix.py | Matrix.matrix_multiplication | def matrix_multiplication(self, matrix):
"""Multiply :py:obj:`self` with the given matrix and return result matrix.
param Matrix matrix: The matrix, which should be multiplied.
:return: Returns a new Matrix with the result of the multiplication
:rtype: Matrix
:note: Mak... | python | def matrix_multiplication(self, matrix):
"""Multiply :py:obj:`self` with the given matrix and return result matrix.
param Matrix matrix: The matrix, which should be multiplied.
:return: Returns a new Matrix with the result of the multiplication
:rtype: Matrix
:note: Mak... | [
"def",
"matrix_multiplication",
"(",
"self",
",",
"matrix",
")",
":",
"resultMatrix",
"=",
"Matrix",
"(",
"matrix",
".",
"get_width",
"(",
")",
",",
"self",
".",
"get_height",
"(",
")",
")",
"for",
"r_row",
"in",
"xrange",
"(",
"self",
".",
"_rows",
")... | Multiply :py:obj:`self` with the given matrix and return result matrix.
param Matrix matrix: The matrix, which should be multiplied.
:return: Returns a new Matrix with the result of the multiplication
:rtype: Matrix
:note: Make sure, that the matrices can be multiplied.
... | [
"Multiply",
":",
"py",
":",
"obj",
":",
"self",
"with",
"the",
"given",
"matrix",
"and",
"return",
"result",
"matrix",
"."
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L418-L443 |
T-002/pycast | pycast/common/matrix.py | Matrix.matrix_multiplication_blockwise | def matrix_multiplication_blockwise(self, matrix, blocksize):
"""
http://en.wikipedia.org/wiki/Block_matrix#Block_matrix_multiplication
"""
#Create the blockwise version of self and matrix
selfBlockwise = self.matrix_to_blockmatrix(blocksize)
matrixBlockwise = matrix.matr... | python | def matrix_multiplication_blockwise(self, matrix, blocksize):
"""
http://en.wikipedia.org/wiki/Block_matrix#Block_matrix_multiplication
"""
#Create the blockwise version of self and matrix
selfBlockwise = self.matrix_to_blockmatrix(blocksize)
matrixBlockwise = matrix.matr... | [
"def",
"matrix_multiplication_blockwise",
"(",
"self",
",",
"matrix",
",",
"blocksize",
")",
":",
"#Create the blockwise version of self and matrix",
"selfBlockwise",
"=",
"self",
".",
"matrix_to_blockmatrix",
"(",
"blocksize",
")",
"matrixBlockwise",
"=",
"matrix",
".",
... | http://en.wikipedia.org/wiki/Block_matrix#Block_matrix_multiplication | [
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Block_matrix#Block_matrix_multiplication"
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L445-L453 |
T-002/pycast | pycast/common/matrix.py | Matrix.flatten | def flatten(self):
"""
If the current Matrix consists of Blockmatrixes as elementes method
flattens the Matrix into one Matrix only consisting of the 2nd level
elements
[[[1 2] [[3 4] to [[1 2 3 4]
[5 6]] [7 8]]] [5 6 7 8]]
"""
blocksize = self.ge... | python | def flatten(self):
"""
If the current Matrix consists of Blockmatrixes as elementes method
flattens the Matrix into one Matrix only consisting of the 2nd level
elements
[[[1 2] [[3 4] to [[1 2 3 4]
[5 6]] [7 8]]] [5 6 7 8]]
"""
blocksize = self.ge... | [
"def",
"flatten",
"(",
"self",
")",
":",
"blocksize",
"=",
"self",
".",
"get_array",
"(",
")",
"[",
"0",
"]",
"[",
"0",
"]",
".",
"get_width",
"(",
")",
"width",
"=",
"self",
".",
"get_width",
"(",
")",
"*",
"blocksize",
"columnsNew",
"=",
"[",
"... | If the current Matrix consists of Blockmatrixes as elementes method
flattens the Matrix into one Matrix only consisting of the 2nd level
elements
[[[1 2] [[3 4] to [[1 2 3 4]
[5 6]] [7 8]]] [5 6 7 8]] | [
"If",
"the",
"current",
"Matrix",
"consists",
"of",
"Blockmatrixes",
"as",
"elementes",
"method",
"flattens",
"the",
"Matrix",
"into",
"one",
"Matrix",
"only",
"consisting",
"of",
"the",
"2nd",
"level",
"elements"
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L455-L477 |
T-002/pycast | pycast/common/matrix.py | Matrix.matrix_to_blockmatrix | def matrix_to_blockmatrix(self, blocksize):
"""
turns an n*m Matrix into a (n/blocksize)*(m/blocksize matrix).
Each element is another blocksize*blocksize matrix.
"""
if self.get_width() % blocksize or self.get_height() % blocksize:
raise ValueError("Number of rows an... | python | def matrix_to_blockmatrix(self, blocksize):
"""
turns an n*m Matrix into a (n/blocksize)*(m/blocksize matrix).
Each element is another blocksize*blocksize matrix.
"""
if self.get_width() % blocksize or self.get_height() % blocksize:
raise ValueError("Number of rows an... | [
"def",
"matrix_to_blockmatrix",
"(",
"self",
",",
"blocksize",
")",
":",
"if",
"self",
".",
"get_width",
"(",
")",
"%",
"blocksize",
"or",
"self",
".",
"get_height",
"(",
")",
"%",
"blocksize",
":",
"raise",
"ValueError",
"(",
"\"Number of rows and columns hav... | turns an n*m Matrix into a (n/blocksize)*(m/blocksize matrix).
Each element is another blocksize*blocksize matrix. | [
"turns",
"an",
"n",
"*",
"m",
"Matrix",
"into",
"a",
"(",
"n",
"/",
"blocksize",
")",
"*",
"(",
"m",
"/",
"blocksize",
"matrix",
")",
".",
"Each",
"element",
"is",
"another",
"blocksize",
"*",
"blocksize",
"matrix",
"."
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L479-L493 |
T-002/pycast | pycast/common/matrix.py | Matrix.multiply | def multiply(self, multiplicator):
"""Return a new Matrix with a multiple.
:param Number multiplicator: The number to calculate the multiple
:return: The Matrix with the the multiple.
:rtype: Matrix
"""
result = Matrix(self.get_width(), self.get_height())
... | python | def multiply(self, multiplicator):
"""Return a new Matrix with a multiple.
:param Number multiplicator: The number to calculate the multiple
:return: The Matrix with the the multiple.
:rtype: Matrix
"""
result = Matrix(self.get_width(), self.get_height())
... | [
"def",
"multiply",
"(",
"self",
",",
"multiplicator",
")",
":",
"result",
"=",
"Matrix",
"(",
"self",
".",
"get_width",
"(",
")",
",",
"self",
".",
"get_height",
"(",
")",
")",
"for",
"row",
"in",
"xrange",
"(",
"self",
".",
"get_height",
"(",
")",
... | Return a new Matrix with a multiple.
:param Number multiplicator: The number to calculate the multiple
:return: The Matrix with the the multiple.
:rtype: Matrix | [
"Return",
"a",
"new",
"Matrix",
"with",
"a",
"multiple",
"."
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L504-L516 |
T-002/pycast | pycast/common/matrix.py | Matrix.transform | def transform(self):
"""Return a new transformed matrix.
:return: Returns a new transformed Matrix
:rtype: Matrix
"""
t_matrix = Matrix(self._rows, self._columns)
for col_i, col in enumerate(self.matrix):
for row_i, entry in enumerate(col):
... | python | def transform(self):
"""Return a new transformed matrix.
:return: Returns a new transformed Matrix
:rtype: Matrix
"""
t_matrix = Matrix(self._rows, self._columns)
for col_i, col in enumerate(self.matrix):
for row_i, entry in enumerate(col):
... | [
"def",
"transform",
"(",
"self",
")",
":",
"t_matrix",
"=",
"Matrix",
"(",
"self",
".",
"_rows",
",",
"self",
".",
"_columns",
")",
"for",
"col_i",
",",
"col",
"in",
"enumerate",
"(",
"self",
".",
"matrix",
")",
":",
"for",
"row_i",
",",
"entry",
"... | Return a new transformed matrix.
:return: Returns a new transformed Matrix
:rtype: Matrix | [
"Return",
"a",
"new",
"transformed",
"matrix",
"."
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L518-L528 |
T-002/pycast | pycast/common/matrix.py | Matrix.gauss_jordan | def gauss_jordan(self):
"""Reduce :py:obj:`self` to row echelon form.
:return: Returns :py:obj:`self` in row echelon form for convenience.
:rtype: Matrix
:raise: Raises an :py:exc:`ValueError` if:
- the matrix rows < columns
- t... | python | def gauss_jordan(self):
"""Reduce :py:obj:`self` to row echelon form.
:return: Returns :py:obj:`self` in row echelon form for convenience.
:rtype: Matrix
:raise: Raises an :py:exc:`ValueError` if:
- the matrix rows < columns
- t... | [
"def",
"gauss_jordan",
"(",
"self",
")",
":",
"mArray",
"=",
"self",
".",
"get_array",
"(",
"rowBased",
"=",
"False",
")",
"width",
"=",
"self",
".",
"get_width",
"(",
")",
"height",
"=",
"self",
".",
"get_height",
"(",
")",
"if",
"not",
"height",
"<... | Reduce :py:obj:`self` to row echelon form.
:return: Returns :py:obj:`self` in row echelon form for convenience.
:rtype: Matrix
:raise: Raises an :py:exc:`ValueError` if:
- the matrix rows < columns
- the matrix is not invertible
... | [
"Reduce",
":",
"py",
":",
"obj",
":",
"self",
"to",
"row",
"echelon",
"form",
"."
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L530-L590 |
T-002/pycast | pycast/common/matrix.py | Matrix.householder | def householder(self):
"""Return Matrices u,b,v with self = ubv and b is in bidiagonal form
The algorithm uses householder transformations.
:return tuple (u,b,v): A tuple with the Matrix u, b and v.
and self = ubv (except some rounding errors)
u is a unitary mat... | python | def householder(self):
"""Return Matrices u,b,v with self = ubv and b is in bidiagonal form
The algorithm uses householder transformations.
:return tuple (u,b,v): A tuple with the Matrix u, b and v.
and self = ubv (except some rounding errors)
u is a unitary mat... | [
"def",
"householder",
"(",
"self",
")",
":",
"# copy instance to transform it to bidiagonal form.",
"bidiagMatrix",
"=",
"Matrix",
".",
"from_two_dim_array",
"(",
"self",
".",
"get_width",
"(",
")",
",",
"self",
".",
"get_height",
"(",
")",
",",
"self",
".",
"ma... | Return Matrices u,b,v with self = ubv and b is in bidiagonal form
The algorithm uses householder transformations.
:return tuple (u,b,v): A tuple with the Matrix u, b and v.
and self = ubv (except some rounding errors)
u is a unitary matrix
b is a bidiago... | [
"Return",
"Matrices",
"u",
"b",
"v",
"with",
"self",
"=",
"ubv",
"and",
"b",
"is",
"in",
"bidiagonal",
"form"
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L642-L729 |
T-002/pycast | pycast/common/matrix.py | Matrix.svd | def svd(self, maxIteration=50):
"""Return the singular value decomposition of the Matrix instance
:param integer maxIteration: The maximmum number of iterations,
which are executed in the qr decomposition
:return: A tuple with Matrices u, sigma, v with
so that u... | python | def svd(self, maxIteration=50):
"""Return the singular value decomposition of the Matrix instance
:param integer maxIteration: The maximmum number of iterations,
which are executed in the qr decomposition
:return: A tuple with Matrices u, sigma, v with
so that u... | [
"def",
"svd",
"(",
"self",
",",
"maxIteration",
"=",
"50",
")",
":",
"if",
"(",
"self",
".",
"get_width",
"(",
")",
">",
"self",
".",
"get_height",
"(",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"Matrix has more columns than rows.\"",
")",
"eps",
"=",... | Return the singular value decomposition of the Matrix instance
:param integer maxIteration: The maximmum number of iterations,
which are executed in the qr decomposition
:return: A tuple with Matrices u, sigma, v with
so that u * sigma * v^T = self
:rtype: tuple... | [
"Return",
"the",
"singular",
"value",
"decomposition",
"of",
"the",
"Matrix",
"instance"
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L731-L938 |
T-002/pycast | pycast/common/matrix.py | Matrix.pseudoinverse | def pseudoinverse(self):
"""Return the pseudoinverse (Moore-Penrose-Inverse).
The singular value decomposition is used to calculate the pseudoinverse.
"""
transform = False
if self.get_width() > self.get_height():
transform = True
u, sigma, v = self.trans... | python | def pseudoinverse(self):
"""Return the pseudoinverse (Moore-Penrose-Inverse).
The singular value decomposition is used to calculate the pseudoinverse.
"""
transform = False
if self.get_width() > self.get_height():
transform = True
u, sigma, v = self.trans... | [
"def",
"pseudoinverse",
"(",
"self",
")",
":",
"transform",
"=",
"False",
"if",
"self",
".",
"get_width",
"(",
")",
">",
"self",
".",
"get_height",
"(",
")",
":",
"transform",
"=",
"True",
"u",
",",
"sigma",
",",
"v",
"=",
"self",
".",
"transform",
... | Return the pseudoinverse (Moore-Penrose-Inverse).
The singular value decomposition is used to calculate the pseudoinverse. | [
"Return",
"the",
"pseudoinverse",
"(",
"Moore",
"-",
"Penrose",
"-",
"Inverse",
")",
"."
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L940-L961 |
T-002/pycast | pycast/common/matrix.py | Vector.initialize_from_matrix | def initialize_from_matrix(cls, matrix, column):
"""Create vector from matrix
:param Matrix matrix: The Matrix, which should be used to create the vector.
:param integer column: The column of the matrix, which should be used
to create the new vector.
:rai... | python | def initialize_from_matrix(cls, matrix, column):
"""Create vector from matrix
:param Matrix matrix: The Matrix, which should be used to create the vector.
:param integer column: The column of the matrix, which should be used
to create the new vector.
:rai... | [
"def",
"initialize_from_matrix",
"(",
"cls",
",",
"matrix",
",",
"column",
")",
":",
"vec",
"=",
"Vector",
"(",
"matrix",
".",
"get_height",
"(",
")",
")",
"for",
"row",
"in",
"xrange",
"(",
"matrix",
".",
"get_height",
"(",
")",
")",
":",
"vec",
"."... | Create vector from matrix
:param Matrix matrix: The Matrix, which should be used to create the vector.
:param integer column: The column of the matrix, which should be used
to create the new vector.
:raise: Raises an :py:exc:`IndexError` if the matrix does not ha... | [
"Create",
"vector",
"from",
"matrix"
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L974-L985 |
T-002/pycast | pycast/common/matrix.py | Vector.unify | def unify(self):
"""Unifies the vector. The length of the vector will be 1.
:return: Return the instance itself
:rtype: Vector
"""
length = float(self.norm())
for row in xrange(self.get_height()):
self.set_value(0, row, self.get_value(0, row) / length)
... | python | def unify(self):
"""Unifies the vector. The length of the vector will be 1.
:return: Return the instance itself
:rtype: Vector
"""
length = float(self.norm())
for row in xrange(self.get_height()):
self.set_value(0, row, self.get_value(0, row) / length)
... | [
"def",
"unify",
"(",
"self",
")",
":",
"length",
"=",
"float",
"(",
"self",
".",
"norm",
"(",
")",
")",
"for",
"row",
"in",
"xrange",
"(",
"self",
".",
"get_height",
"(",
")",
")",
":",
"self",
".",
"set_value",
"(",
"0",
",",
"row",
",",
"self... | Unifies the vector. The length of the vector will be 1.
:return: Return the instance itself
:rtype: Vector | [
"Unifies",
"the",
"vector",
".",
"The",
"length",
"of",
"the",
"vector",
"will",
"be",
"1",
"."
] | train | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L995-L1004 |
UUDigitalHumanitieslab/tei_reader | tei_reader/models/division.py | Division.text | def text(self):
"""Get the entire text content as str"""
divisions = list(self.divisions)
if len(divisions) == 0:
return ''
elif len(divisions) == 1:
return divisions[0].text.strip()
else:
return super().text | python | def text(self):
"""Get the entire text content as str"""
divisions = list(self.divisions)
if len(divisions) == 0:
return ''
elif len(divisions) == 1:
return divisions[0].text.strip()
else:
return super().text | [
"def",
"text",
"(",
"self",
")",
":",
"divisions",
"=",
"list",
"(",
"self",
".",
"divisions",
")",
"if",
"len",
"(",
"divisions",
")",
"==",
"0",
":",
"return",
"''",
"elif",
"len",
"(",
"divisions",
")",
"==",
"1",
":",
"return",
"divisions",
"["... | Get the entire text content as str | [
"Get",
"the",
"entire",
"text",
"content",
"as",
"str"
] | train | https://github.com/UUDigitalHumanitieslab/tei_reader/blob/7b19c34a9d7cc941a36ecdcf6f361e26c6488697/tei_reader/models/division.py#L6-L14 |
T-002/pycast | pycast/errors/medianabsolutepercentageerror.py | MedianAbsolutePercentageError._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/medianabsolutepercentageerror.py#L31-L52 |
pdkit/pdkit | pdkit/finger_tapping_processor.py | FingerTappingProcessor.frequency | def frequency(self, data_frame):
"""
This method returns the number of #taps divided by the test duration
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return frequency: frequency
:rtype frequency: float
"""
fr... | python | def frequency(self, data_frame):
"""
This method returns the number of #taps divided by the test duration
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return frequency: frequency
:rtype frequency: float
"""
fr... | [
"def",
"frequency",
"(",
"self",
",",
"data_frame",
")",
":",
"freq",
"=",
"sum",
"(",
"data_frame",
".",
"action_type",
"==",
"1",
")",
"/",
"data_frame",
".",
"td",
"[",
"-",
"1",
"]",
"duration",
"=",
"math",
".",
"ceil",
"(",
"data_frame",
".",
... | This method returns the number of #taps divided by the test duration
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return frequency: frequency
:rtype frequency: float | [
"This",
"method",
"returns",
"the",
"number",
"of",
"#taps",
"divided",
"by",
"the",
"test",
"duration"
] | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/finger_tapping_processor.py#L50-L63 |
pdkit/pdkit | pdkit/finger_tapping_processor.py | FingerTappingProcessor.moving_frequency | def moving_frequency(self, data_frame):
"""
This method returns moving frequency
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return diff_mov_freq: frequency
:rtype diff_mov_freq: float
"""
f = []
for ... | python | def moving_frequency(self, data_frame):
"""
This method returns moving frequency
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return diff_mov_freq: frequency
:rtype diff_mov_freq: float
"""
f = []
for ... | [
"def",
"moving_frequency",
"(",
"self",
",",
"data_frame",
")",
":",
"f",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"(",
"data_frame",
".",
"td",
"[",
"-",
"1",
"]",
".",
"astype",
"(",
"'int'",
")",
"-",
"self",
".",
"window",
"... | This method returns moving frequency
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return diff_mov_freq: frequency
:rtype diff_mov_freq: float | [
"This",
"method",
"returns",
"moving",
"frequency"
] | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/finger_tapping_processor.py#L65-L84 |
pdkit/pdkit | pdkit/finger_tapping_processor.py | FingerTappingProcessor.continuous_frequency | def continuous_frequency(self, data_frame):
"""
This method returns continuous frequency
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return cont_freq: frequency
:rtype cont_freq: float
"""
tap_timestamps = da... | python | def continuous_frequency(self, data_frame):
"""
This method returns continuous frequency
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return cont_freq: frequency
:rtype cont_freq: float
"""
tap_timestamps = da... | [
"def",
"continuous_frequency",
"(",
"self",
",",
"data_frame",
")",
":",
"tap_timestamps",
"=",
"data_frame",
".",
"td",
"[",
"data_frame",
".",
"action_type",
"==",
"1",
"]",
"cont_freq",
"=",
"1.0",
"/",
"(",
"np",
".",
"array",
"(",
"tap_timestamps",
"[... | This method returns continuous frequency
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return cont_freq: frequency
:rtype cont_freq: float | [
"This",
"method",
"returns",
"continuous",
"frequency"
] | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/finger_tapping_processor.py#L86-L100 |
pdkit/pdkit | pdkit/finger_tapping_processor.py | FingerTappingProcessor.mean_moving_time | def mean_moving_time(self, data_frame):
"""
This method calculates the mean time (ms) that the hand was moving from one target to the next
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return mmt: the mean moving time in ms
:rt... | python | def mean_moving_time(self, data_frame):
"""
This method calculates the mean time (ms) that the hand was moving from one target to the next
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return mmt: the mean moving time in ms
:rt... | [
"def",
"mean_moving_time",
"(",
"self",
",",
"data_frame",
")",
":",
"diff",
"=",
"data_frame",
".",
"td",
"[",
"1",
":",
"-",
"1",
"]",
".",
"values",
"-",
"data_frame",
".",
"td",
"[",
"0",
":",
"-",
"2",
"]",
".",
"values",
"mmt",
"=",
"np",
... | This method calculates the mean time (ms) that the hand was moving from one target to the next
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return mmt: the mean moving time in ms
:rtype mmt: float | [
"This",
"method",
"calculates",
"the",
"mean",
"time",
"(",
"ms",
")",
"that",
"the",
"hand",
"was",
"moving",
"from",
"one",
"target",
"to",
"the",
"next"
] | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/finger_tapping_processor.py#L102-L116 |
pdkit/pdkit | pdkit/finger_tapping_processor.py | FingerTappingProcessor.incoordination_score | def incoordination_score(self, data_frame):
"""
This method calculates the variance of the time interval in msec between taps
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return is: incoordination score
:rtype is: float
... | python | def incoordination_score(self, data_frame):
"""
This method calculates the variance of the time interval in msec between taps
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return is: incoordination score
:rtype is: float
... | [
"def",
"incoordination_score",
"(",
"self",
",",
"data_frame",
")",
":",
"diff",
"=",
"data_frame",
".",
"td",
"[",
"1",
":",
"-",
"1",
"]",
".",
"values",
"-",
"data_frame",
".",
"td",
"[",
"0",
":",
"-",
"2",
"]",
".",
"values",
"inc_s",
"=",
"... | This method calculates the variance of the time interval in msec between taps
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return is: incoordination score
:rtype is: float | [
"This",
"method",
"calculates",
"the",
"variance",
"of",
"the",
"time",
"interval",
"in",
"msec",
"between",
"taps"
] | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/finger_tapping_processor.py#L118-L131 |
pdkit/pdkit | pdkit/finger_tapping_processor.py | FingerTappingProcessor.mean_alnt_target_distance | def mean_alnt_target_distance(self, data_frame):
"""
This method calculates the distance (number of pixels) between alternate tapping
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return matd: the mean alternate target distance in pixels
... | python | def mean_alnt_target_distance(self, data_frame):
"""
This method calculates the distance (number of pixels) between alternate tapping
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return matd: the mean alternate target distance in pixels
... | [
"def",
"mean_alnt_target_distance",
"(",
"self",
",",
"data_frame",
")",
":",
"dist",
"=",
"np",
".",
"sqrt",
"(",
"(",
"data_frame",
".",
"x",
"[",
"1",
":",
"-",
"1",
"]",
".",
"values",
"-",
"data_frame",
".",
"x",
"[",
"0",
":",
"-",
"2",
"]"... | This method calculates the distance (number of pixels) between alternate tapping
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return matd: the mean alternate target distance in pixels
:rtype matd: float | [
"This",
"method",
"calculates",
"the",
"distance",
"(",
"number",
"of",
"pixels",
")",
"between",
"alternate",
"tapping"
] | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/finger_tapping_processor.py#L133-L147 |
pdkit/pdkit | pdkit/finger_tapping_processor.py | FingerTappingProcessor.kinesia_scores | def kinesia_scores(self, data_frame):
"""
This method calculates the number of key taps
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return ks: key taps
:rtype ks: float
:return duration: test duration (seconds)
... | python | def kinesia_scores(self, data_frame):
"""
This method calculates the number of key taps
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return ks: key taps
:rtype ks: float
:return duration: test duration (seconds)
... | [
"def",
"kinesia_scores",
"(",
"self",
",",
"data_frame",
")",
":",
"# tap_timestamps = data_frame.td[data_frame.action_type == 1]",
"# grouped = tap_timestamps.groupby(pd.TimeGrouper('30u'))",
"# return np.mean(grouped.size().values)",
"ks",
"=",
"sum",
"(",
"data_frame",
".",
"act... | This method calculates the number of key taps
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return ks: key taps
:rtype ks: float
:return duration: test duration (seconds)
:rtype duration: float | [
"This",
"method",
"calculates",
"the",
"number",
"of",
"key",
"taps"
] | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/finger_tapping_processor.py#L149-L166 |
pdkit/pdkit | pdkit/finger_tapping_processor.py | FingerTappingProcessor.akinesia_times | def akinesia_times(self, data_frame):
"""
This method calculates akinesia times, mean dwell time on each key in milliseconds
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return at: akinesia times
:rtype at: float
:... | python | def akinesia_times(self, data_frame):
"""
This method calculates akinesia times, mean dwell time on each key in milliseconds
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return at: akinesia times
:rtype at: float
:... | [
"def",
"akinesia_times",
"(",
"self",
",",
"data_frame",
")",
":",
"raise_timestamps",
"=",
"data_frame",
".",
"td",
"[",
"data_frame",
".",
"action_type",
"==",
"1",
"]",
"down_timestamps",
"=",
"data_frame",
".",
"td",
"[",
"data_frame",
".",
"action_type",
... | This method calculates akinesia times, mean dwell time on each key in milliseconds
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return at: akinesia times
:rtype at: float
:return duration: test duration (seconds)
:rtype du... | [
"This",
"method",
"calculates",
"akinesia",
"times",
"mean",
"dwell",
"time",
"on",
"each",
"key",
"in",
"milliseconds"
] | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/finger_tapping_processor.py#L168-L192 |
pdkit/pdkit | pdkit/finger_tapping_processor.py | FingerTappingProcessor.dysmetria_score | def dysmetria_score(self, data_frame):
"""
This method calculates accuracy of target taps in pixels
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return ds: dysmetria score in pixels
:rtype ds: float
"""
tap_da... | python | def dysmetria_score(self, data_frame):
"""
This method calculates accuracy of target taps in pixels
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return ds: dysmetria score in pixels
:rtype ds: float
"""
tap_da... | [
"def",
"dysmetria_score",
"(",
"self",
",",
"data_frame",
")",
":",
"tap_data",
"=",
"data_frame",
"[",
"data_frame",
".",
"action_type",
"==",
"0",
"]",
"ds",
"=",
"np",
".",
"mean",
"(",
"np",
".",
"sqrt",
"(",
"(",
"tap_data",
".",
"x",
"-",
"tap_... | This method calculates accuracy of target taps in pixels
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return ds: dysmetria score in pixels
:rtype ds: float | [
"This",
"method",
"calculates",
"accuracy",
"of",
"target",
"taps",
"in",
"pixels"
] | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/finger_tapping_processor.py#L194-L207 |
pdkit/pdkit | pdkit/finger_tapping_processor.py | FingerTappingProcessor.extract_features | def extract_features(self, data_frame, pre=''):
"""
This method extracts all the features available to the Finger Tapping Processor class.
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return: 'frequency', 'moving_frequency','continuous_fr... | python | def extract_features(self, data_frame, pre=''):
"""
This method extracts all the features available to the Finger Tapping Processor class.
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return: 'frequency', 'moving_frequency','continuous_fr... | [
"def",
"extract_features",
"(",
"self",
",",
"data_frame",
",",
"pre",
"=",
"''",
")",
":",
"try",
":",
"return",
"{",
"pre",
"+",
"'frequency'",
":",
"self",
".",
"frequency",
"(",
"data_frame",
")",
"[",
"0",
"]",
",",
"pre",
"+",
"'mean_moving_time'... | This method extracts all the features available to the Finger Tapping Processor class.
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:return: 'frequency', 'moving_frequency','continuous_frequency','mean_moving_time','incoordination_score', \
... | [
"This",
"method",
"extracts",
"all",
"the",
"features",
"available",
"to",
"the",
"Finger",
"Tapping",
"Processor",
"class",
"."
] | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/finger_tapping_processor.py#L209-L229 |
pdkit/pdkit | pdkit/clinical_updrs.py | Clinical_UPDRS.__train | def __train(self, n_neighbors=3):
"""
Train the classifier implementing the `k-nearest neighbors vote <http://scikit-learn.org/stable/modules/\
generated/sklearn.neighbors.KNeighborsClassifier.html>`_
:param n_clusters: the number of clusters
:type n_clusters: in... | python | def __train(self, n_neighbors=3):
"""
Train the classifier implementing the `k-nearest neighbors vote <http://scikit-learn.org/stable/modules/\
generated/sklearn.neighbors.KNeighborsClassifier.html>`_
:param n_clusters: the number of clusters
:type n_clusters: in... | [
"def",
"__train",
"(",
"self",
",",
"n_neighbors",
"=",
"3",
")",
":",
"# m = self.labels.drop(['id','MDS_UPDRSIII'], axis=1).values",
"# print(itemfreq(m))",
"#",
"# for i, row in enumerate(self.labels.drop(['id','MDS_UPDRSIII'], axis=1).values):",
"# print(np.bincount(row))",
"tr... | Train the classifier implementing the `k-nearest neighbors vote <http://scikit-learn.org/stable/modules/\
generated/sklearn.neighbors.KNeighborsClassifier.html>`_
:param n_clusters: the number of clusters
:type n_clusters: int | [
"Train",
"the",
"classifier",
"implementing",
"the",
"k",
"-",
"nearest",
"neighbors",
"vote",
"<http",
":",
"//",
"scikit",
"-",
"learn",
".",
"org",
"/",
"stable",
"/",
"modules",
"/",
"\\",
"generated",
"/",
"sklearn",
".",
"neighbors",
".",
"KNeighbors... | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/clinical_updrs.py#L92-L138 |
pdkit/pdkit | pdkit/clinical_updrs.py | Clinical_UPDRS.__get_features_for_observation | def __get_features_for_observation(self, data_frame=None, observation='LA-LL',
skip_id=None, last_column_is_id=False):
"""
Extract the features for a given observation from a data frame
:param data_frame: data frame to get features from
... | python | def __get_features_for_observation(self, data_frame=None, observation='LA-LL',
skip_id=None, last_column_is_id=False):
"""
Extract the features for a given observation from a data frame
:param data_frame: data frame to get features from
... | [
"def",
"__get_features_for_observation",
"(",
"self",
",",
"data_frame",
"=",
"None",
",",
"observation",
"=",
"'LA-LL'",
",",
"skip_id",
"=",
"None",
",",
"last_column_is_id",
"=",
"False",
")",
":",
"try",
":",
"features",
"=",
"np",
".",
"array",
"(",
"... | Extract the features for a given observation from a data frame
:param data_frame: data frame to get features from
:type data_frame: pandas.DataFrame
:param observation: observation name
:type observation: string
:param skip_id: skip any test with a given id (... | [
"Extract",
"the",
"features",
"for",
"a",
"given",
"observation",
"from",
"a",
"data",
"frame"
] | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/clinical_updrs.py#L140-L179 |
pdkit/pdkit | pdkit/clinical_updrs.py | Clinical_UPDRS.predict | def predict(self, measurement, output_format='array'):
"""
Method to predict the class labels for the provided data
:param measurement: the point to classify
:type measurement: pandas.DataFrame
:param output_format: the format to return the scores ('array' or 'st... | python | def predict(self, measurement, output_format='array'):
"""
Method to predict the class labels for the provided data
:param measurement: the point to classify
:type measurement: pandas.DataFrame
:param output_format: the format to return the scores ('array' or 'st... | [
"def",
"predict",
"(",
"self",
",",
"measurement",
",",
"output_format",
"=",
"'array'",
")",
":",
"scores",
"=",
"np",
".",
"array",
"(",
"[",
"]",
")",
"for",
"obs",
"in",
"self",
".",
"observations",
":",
"knn",
"=",
"self",
".",
"__get_knn_by_obser... | Method to predict the class labels for the provided data
: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 prediction: the... | [
"Method",
"to",
"predict",
"the",
"class",
"labels",
"for",
"the",
"provided",
"data"
] | train | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/clinical_updrs.py#L186-L209 |
twisted/txaws | txaws/server/schema.py | _namify_arguments | def _namify_arguments(mapping):
"""
Ensure that a mapping of names to parameters has the parameters set to the
correct name.
"""
result = []
for name, parameter in mapping.iteritems():
parameter.name = name
result.append(parameter)
return result | python | def _namify_arguments(mapping):
"""
Ensure that a mapping of names to parameters has the parameters set to the
correct name.
"""
result = []
for name, parameter in mapping.iteritems():
parameter.name = name
result.append(parameter)
return result | [
"def",
"_namify_arguments",
"(",
"mapping",
")",
":",
"result",
"=",
"[",
"]",
"for",
"name",
",",
"parameter",
"in",
"mapping",
".",
"iteritems",
"(",
")",
":",
"parameter",
".",
"name",
"=",
"name",
"result",
".",
"append",
"(",
"parameter",
")",
"re... | Ensure that a mapping of names to parameters has the parameters set to the
correct name. | [
"Ensure",
"that",
"a",
"mapping",
"of",
"names",
"to",
"parameters",
"has",
"the",
"parameters",
"set",
"to",
"the",
"correct",
"name",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/schema.py#L517-L526 |
twisted/txaws | txaws/server/schema.py | _merge_associative_list | def _merge_associative_list(alist, path, value):
"""
Merge a value into an associative list at the given path, maintaining
insertion order. Examples will explain it::
>>> alist = []
>>> _merge_associative_list(alist, ["foo", "bar"], "barvalue")
>>> _merge_associative_list(alist, ["f... | python | def _merge_associative_list(alist, path, value):
"""
Merge a value into an associative list at the given path, maintaining
insertion order. Examples will explain it::
>>> alist = []
>>> _merge_associative_list(alist, ["foo", "bar"], "barvalue")
>>> _merge_associative_list(alist, ["f... | [
"def",
"_merge_associative_list",
"(",
"alist",
",",
"path",
",",
"value",
")",
":",
"for",
"key",
"in",
"path",
"[",
":",
"-",
"1",
"]",
":",
"for",
"item",
"in",
"alist",
":",
"if",
"item",
"[",
"0",
"]",
"==",
"key",
":",
"alist",
"=",
"item",... | Merge a value into an associative list at the given path, maintaining
insertion order. Examples will explain it::
>>> alist = []
>>> _merge_associative_list(alist, ["foo", "bar"], "barvalue")
>>> _merge_associative_list(alist, ["foo", "baz"], "bazvalue")
>>> alist == [("foo", [("bar... | [
"Merge",
"a",
"value",
"into",
"an",
"associative",
"list",
"at",
"the",
"given",
"path",
"maintaining",
"insertion",
"order",
".",
"Examples",
"will",
"explain",
"it",
"::"
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/schema.py#L809-L834 |
twisted/txaws | txaws/server/schema.py | Parameter.coerce | def coerce(self, value):
"""Coerce a single value according to this parameter's settings.
@param value: A L{str}, or L{None}. If L{None} is passed - meaning no
value is avalable at all, not even the empty string - and this
parameter is optional, L{self.default} will be returned.... | python | def coerce(self, value):
"""Coerce a single value according to this parameter's settings.
@param value: A L{str}, or L{None}. If L{None} is passed - meaning no
value is avalable at all, not even the empty string - and this
parameter is optional, L{self.default} will be returned.... | [
"def",
"coerce",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"if",
"self",
".",
"optional",
":",
"return",
"self",
".",
"default",
"else",
":",
"value",
"=",
"\"\"",
"if",
"value",
"==",
"\"\"",
":",
"if",
"not",
"self",
... | Coerce a single value according to this parameter's settings.
@param value: A L{str}, or L{None}. If L{None} is passed - meaning no
value is avalable at all, not even the empty string - and this
parameter is optional, L{self.default} will be returned. | [
"Coerce",
"a",
"single",
"value",
"according",
"to",
"this",
"parameter",
"s",
"settings",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/schema.py#L107-L135 |
twisted/txaws | txaws/server/schema.py | Parameter._check_range | def _check_range(self, value):
"""Check that the given C{value} is in the expected range."""
if self.min is None and self.max is None:
return
measure = self.measure(value)
prefix = "Value (%s) for parameter %s is invalid. %s"
if self.min is not None and measure < s... | python | def _check_range(self, value):
"""Check that the given C{value} is in the expected range."""
if self.min is None and self.max is None:
return
measure = self.measure(value)
prefix = "Value (%s) for parameter %s is invalid. %s"
if self.min is not None and measure < s... | [
"def",
"_check_range",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"min",
"is",
"None",
"and",
"self",
".",
"max",
"is",
"None",
":",
"return",
"measure",
"=",
"self",
".",
"measure",
"(",
"value",
")",
"prefix",
"=",
"\"Value (%s) for para... | Check that the given C{value} is in the expected range. | [
"Check",
"that",
"the",
"given",
"C",
"{",
"value",
"}",
"is",
"in",
"the",
"expected",
"range",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/schema.py#L137-L153 |
twisted/txaws | txaws/server/schema.py | List.parse | def parse(self, value):
"""
Convert a dictionary of {relative index: value} to a list of parsed
C{value}s.
"""
indices = []
if not isinstance(value, dict):
# We interpret non-list inputs as a list of one element, for
# compatibility with certain EC... | python | def parse(self, value):
"""
Convert a dictionary of {relative index: value} to a list of parsed
C{value}s.
"""
indices = []
if not isinstance(value, dict):
# We interpret non-list inputs as a list of one element, for
# compatibility with certain EC... | [
"def",
"parse",
"(",
"self",
",",
"value",
")",
":",
"indices",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"# We interpret non-list inputs as a list of one element, for",
"# compatibility with certain EC2 APIs.",
"return",
"[",
"s... | Convert a dictionary of {relative index: value} to a list of parsed
C{value}s. | [
"Convert",
"a",
"dictionary",
"of",
"{",
"relative",
"index",
":",
"value",
"}",
"to",
"a",
"list",
"of",
"parsed",
"C",
"{",
"value",
"}",
"s",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/schema.py#L366-L387 |
twisted/txaws | txaws/server/schema.py | List.format | def format(self, value):
"""
Convert a list like::
["a", "b", "c"]
to:
{"1": "a", "2": "b", "3": "c"}
C{value} may also be an L{Arguments} instance, mapping indices to
values. Who knows why.
"""
if isinstance(value, Arguments):
... | python | def format(self, value):
"""
Convert a list like::
["a", "b", "c"]
to:
{"1": "a", "2": "b", "3": "c"}
C{value} may also be an L{Arguments} instance, mapping indices to
values. Who knows why.
"""
if isinstance(value, Arguments):
... | [
"def",
"format",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Arguments",
")",
":",
"return",
"dict",
"(",
"(",
"str",
"(",
"i",
")",
",",
"self",
".",
"item",
".",
"format",
"(",
"v",
")",
")",
"for",
"i",
",",
... | Convert a list like::
["a", "b", "c"]
to:
{"1": "a", "2": "b", "3": "c"}
C{value} may also be an L{Arguments} instance, mapping indices to
values. Who knows why. | [
"Convert",
"a",
"list",
"like",
"::"
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/schema.py#L389-L405 |
twisted/txaws | txaws/server/schema.py | Structure.parse | def parse(self, value):
"""
Convert a dictionary of raw values to a dictionary of processed values.
"""
result = {}
rest = {}
for k, v in value.iteritems():
if k in self.fields:
if (isinstance(v, dict)
and not self.field... | python | def parse(self, value):
"""
Convert a dictionary of raw values to a dictionary of processed values.
"""
result = {}
rest = {}
for k, v in value.iteritems():
if k in self.fields:
if (isinstance(v, dict)
and not self.field... | [
"def",
"parse",
"(",
"self",
",",
"value",
")",
":",
"result",
"=",
"{",
"}",
"rest",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"value",
".",
"iteritems",
"(",
")",
":",
"if",
"k",
"in",
"self",
".",
"fields",
":",
"if",
"(",
"isinstance",
"... | Convert a dictionary of raw values to a dictionary of processed values. | [
"Convert",
"a",
"dictionary",
"of",
"raw",
"values",
"to",
"a",
"dictionary",
"of",
"processed",
"values",
"."
] | train | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/schema.py#L428-L452 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.