sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def create(self, root=None, namespace=None): """Create a sequence element with the given root. @param root: The C{etree.Element} to root the sequence at, if C{None} a new one will be created.. @result: A L{SequenceItem} with the given root. @raises L{ECResponseError}: If the...
Create a sequence element with the given root. @param root: The C{etree.Element} to root the sequence at, if C{None} a new one will be created.. @result: A L{SequenceItem} with the given root. @raises L{ECResponseError}: If the given C{root} has a bad tag.
entailment
def set(self, child, min_occurs=1, max_occurs=1): """Set the schema for the sequence children. @param child: The schema that children must match. @param min_occurs: The minimum number of children the sequence must have. @param max_occurs: The maximum number of children the s...
Set the schema for the sequence children. @param child: The schema that children must match. @param min_occurs: The minimum number of children the sequence must have. @param max_occurs: The maximum number of children the sequence can have.
entailment
def append(self): """Append a new item to the sequence, appending it to the end. @return: The newly created item. @raises L{WSDLParseError}: If the operation would result in having more child elements than the allowed max. """ tag = self._schema.tag children...
Append a new item to the sequence, appending it to the end. @return: The newly created item. @raises L{WSDLParseError}: If the operation would result in having more child elements than the allowed max.
entailment
def remove(self, item): """Remove the given C{item} from the sequence. @raises L{WSDLParseError}: If the operation would result in having less child elements than the required min_occurs, or if no such index is found. """ for index, child in enumerate(self._roo...
Remove the given C{item} from the sequence. @raises L{WSDLParseError}: If the operation would result in having less child elements than the required min_occurs, or if no such index is found.
entailment
def _get_child(self, children, index): """Return the child with the given index.""" try: return children[index] except IndexError: raise WSDLParseError("Non existing item in tag '%s'" % self._schema.tag)
Return the child with the given index.
entailment
def parse(self, wsdl): """Parse the given C{wsdl} data and build the associated schemas. @param wdsl: A string containing the raw xml of the WDSL definition to parse. @return: A C{dict} mapping response type names to their schemas. """ parser = etree.XMLParser(remove...
Parse the given C{wsdl} data and build the associated schemas. @param wdsl: A string containing the raw xml of the WDSL definition to parse. @return: A C{dict} mapping response type names to their schemas.
entailment
def _parse_type(self, element, types): """Parse a 'complexType' element. @param element: The top-level complexType element @param types: A map of the elements of all available complexType's. @return: The schema for the complexType. """ name = element.attrib["name"] ...
Parse a 'complexType' element. @param element: The top-level complexType element @param types: A map of the elements of all available complexType's. @return: The schema for the complexType.
entailment
def _parse_child(self, child): """Parse a single child element. @param child: The child C{etree.Element} to parse. @return: A tuple C{(name, type, min_occurs, max_occurs)} with the details about the given child. """ if set(child.attrib) - set(["name", "type", "minOcc...
Parse a single child element. @param child: The child C{etree.Element} to parse. @return: A tuple C{(name, type, min_occurs, max_occurs)} with the details about the given child.
entailment
def get_existing_item(self, item): """ Lookup item in remote service based on keys. :param item: D4S2Item data contains keys we will use for lookup. :return: requests.Response containing the successful result """ params = { 'project_id': item.project_id, ...
Lookup item in remote service based on keys. :param item: D4S2Item data contains keys we will use for lookup. :return: requests.Response containing the successful result
entailment
def create_item(self, item): """ Create a new item in D4S2 service for item at the specified destination. :param item: D4S2Item data to use for creating a D4S2 item :return: requests.Response containing the successful result """ item_dict = { 'project_id': ite...
Create a new item in D4S2 service for item at the specified destination. :param item: D4S2Item data to use for creating a D4S2 item :return: requests.Response containing the successful result
entailment
def send_item(self, destination, item_id, force_send): """ Run send method for item_id at destination. :param destination: str which type of operation are we doing (SHARE_DESTINATION or DELIVER_DESTINATION) :param item_id: str D4S2 service id representing the item we want to send ...
Run send method for item_id at destination. :param destination: str which type of operation are we doing (SHARE_DESTINATION or DELIVER_DESTINATION) :param item_id: str D4S2 service id representing the item we want to send :param force_send: bool it's ok to email the item again :return: r...
entailment
def check_response(self, response): """ Raises error if the response isn't successful. :param response: requests.Response response to be checked """ if response.status_code == 401: raise D4S2Error(UNAUTHORIZED_MESSAGE) if not 200 <= response.status_code < 300:...
Raises error if the response isn't successful. :param response: requests.Response response to be checked
entailment
def send(self, api, force_send): """ Send this item using api. :param api: D4S2Api sends messages to D4S2 :param force_send: bool should we send even if the item already exists """ item_id = self.get_existing_item_id(api) if not item_id: item_id = self...
Send this item using api. :param api: D4S2Api sends messages to D4S2 :param force_send: bool should we send even if the item already exists
entailment
def get_existing_item_id(self, api): """ Lookup the id for this item via the D4S2 service. :param api: D4S2Api object who communicates with D4S2 server. :return str id of this item or None if not found """ resp = api.get_existing_item(self) items = resp.json() ...
Lookup the id for this item via the D4S2 service. :param api: D4S2Api object who communicates with D4S2 server. :return str id of this item or None if not found
entailment
def create_item_returning_id(self, api): """ Create this item in the D4S2 service. :param api: D4S2Api object who communicates with D4S2 server. :return str newly created id for this item """ resp = api.create_item(self) item = resp.json() return item['id'...
Create this item in the D4S2 service. :param api: D4S2Api object who communicates with D4S2 server. :return str newly created id for this item
entailment
def share(self, project, to_user, force_send, auth_role, user_message): """ Send mail and give user specified access to the project. :param project: RemoteProject project to share :param to_user: RemoteUser user to receive email/access :param auth_role: str project role eg 'proje...
Send mail and give user specified access to the project. :param project: RemoteProject project to share :param to_user: RemoteUser user to receive email/access :param auth_role: str project role eg 'project_admin' to give to the user :param user_message: str message to be sent with the s...
entailment
def set_user_project_permission(self, project, user, auth_role): """ Give user access permissions for a project. :param project: RemoteProject project to update permissions on :param user: RemoteUser user to receive permissions :param auth_role: str project role eg 'project_admin...
Give user access permissions for a project. :param project: RemoteProject project to update permissions on :param user: RemoteUser user to receive permissions :param auth_role: str project role eg 'project_admin'
entailment
def deliver(self, project, new_project_name, to_user, share_users, force_send, path_filter, user_message): """ Remove access to project_name for to_user, copy to new_project_name if not None, send message to service to email user so they can have access. :param project: RemoteProject pre...
Remove access to project_name for to_user, copy to new_project_name if not None, send message to service to email user so they can have access. :param project: RemoteProject pre-existing project to be delivered :param new_project_name: str name of non-existing project to copy project_name to, if...
entailment
def _share_project(self, destination, project, to_user, force_send, auth_role='', user_message='', share_users=None): """ Send message to remote service to email/share project with to_user. :param destination: str which type of sharing we are doing (SHARE_DESTINATION or DE...
Send message to remote service to email/share project with to_user. :param destination: str which type of sharing we are doing (SHARE_DESTINATION or DELIVER_DESTINATION) :param project: RemoteProject project we are sharing :param to_user: RemoteUser user we are sharing with :param auth_r...
entailment
def _copy_project(self, project, new_project_name, path_filter): """ Copy pre-existing project with name project_name to non-existing project new_project_name. :param project: remotestore.RemoteProject project to copy from :param new_project_name: str project to copy to :param pa...
Copy pre-existing project with name project_name to non-existing project new_project_name. :param project: remotestore.RemoteProject project to copy from :param new_project_name: str project to copy to :param path_filter: PathFilter: filters what files are shared :return: RemoteProject n...
entailment
def _download_project(self, activity, project, temp_directory, path_filter): """ Download the project with project_name to temp_directory. :param activity: CopyActivity: info about the copy activity are downloading for :param project: remotestore.RemoteProject project to download ...
Download the project with project_name to temp_directory. :param activity: CopyActivity: info about the copy activity are downloading for :param project: remotestore.RemoteProject project to download :param temp_directory: str path to directory we can download into :param path_filter: Pa...
entailment
def _upload_project(self, activity, project_name, temp_directory): """ Upload the contents of temp_directory into project_name :param activity: CopyActivity: info about the copy activity are uploading for :param project_name: str project name we will upload files to :param temp_d...
Upload the contents of temp_directory into project_name :param activity: CopyActivity: info about the copy activity are uploading for :param project_name: str project name we will upload files to :param temp_directory: str path to directory who's files we will upload
entailment
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...
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
entailment
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())
Mark the activity as finished
entailment
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 ...
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
entailment
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 ...
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
entailment
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...
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
entailment
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. """ ...
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.
entailment
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...
Add properties to config based on filename replacing previous values. :param filename: str path to YAML file to pull top level properties from
entailment
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...
Determine root url of the data service from the url specified. :return: str root url of the data service (eg: https://dataservice.duke.edu)
entailment
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))
Contains the auth token for use with connecting to the dataservice. :return:
entailment
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)
Return the bytes per chunk to be sent to external store. :return: int bytes per upload chunk
entailment
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...
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
entailment
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...
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.
entailment
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...
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...
entailment
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...
Describe current instances.
entailment
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...
Run new instances. TODO: blockDeviceMapping, monitoring, subnetId
entailment
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) ...
Get the console output for a single instance.
entailment
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...
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.
entailment
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...
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...
entailment
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) ...
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...
entailment
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...
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}.
entailment
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...
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}.
entailment
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...
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}.
entailment
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...
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}.
entailment
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...
Describe available volumes.
entailment
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...
Create a new volume.
entailment
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...
Describe available snapshots. TODO: ownerSet, restorableBySet
entailment
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...
Remove a previously created snapshot.
entailment
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_...
Attach the given volume to the specified instance at C{device}.
entailment
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...
Returns information about key pairs available.
entailment
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...
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.
entailment
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 ...
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. ...
entailment
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, ...
Acquire an elastic IP address to be attached subsequently to EC2 instances. @return: the IP address allocated.
entailment
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, ...
Release a previously allocated address returned by C{allocate_address}. @return: C{True} if the operation succeeded.
entailment
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} ...
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}.
entailment
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. """ ...
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.
entailment
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...
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...
entailment
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...
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...
entailment
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...
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.
entailment
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...
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.
entailment
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...
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.
entailment
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 ...
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
entailment
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...
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.
entailment
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...
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.
entailment
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. """ ...
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.
entailment
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 """ ...
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
entailment
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) ...
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}.
entailment
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...
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.
entailment
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...
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).
entailment
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...
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
entailment
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 ...
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...
entailment
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} ...
Submit this query. @return: A deferred from get_page
entailment
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...
Compute and return the signature according to the given data.
entailment
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...
Return the text needed for signing using SignatureVersion 1.
entailment
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...
Return the text to be signed when signing the query.
entailment
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)
Return the canonical query params (used in signing).
entailment
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...
Encode a_string as per the canonicalisation encoding rules. See the AWS dev reference page 186 (2009-11-30 version). @return: a_string encoded.
entailment
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...
Create an instance of this from XML bytes. @param xml_bytes: C{str} bytes of XML to parse @return: an instance of L{MultipartInitiationResponse}
entailment
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 ...
Computer c = (a^2 + b^2)^0.5 without destructive underflow or overflow It solves the Pythagorean theorem a^2 + b^2 = c^2
entailment
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)...
Set the matrix values from a two dimensional list.
entailment
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 ...
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...
entailment
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...
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...
entailment
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 ...
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
entailment
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...
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...
entailment
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...
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...
entailment
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...
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...
entailment
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...
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...
entailment
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...
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. ...
entailment
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...
http://en.wikipedia.org/wiki/Block_matrix#Block_matrix_multiplication
entailment
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...
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]]
entailment
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...
turns an n*m Matrix into a (n/blocksize)*(m/blocksize matrix). Each element is another blocksize*blocksize matrix.
entailment
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()) ...
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
entailment
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): ...
Return a new transformed matrix. :return: Returns a new transformed Matrix :rtype: Matrix
entailment
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...
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 ...
entailment
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...
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...
entailment
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...
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...
entailment
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...
Return the pseudoinverse (Moore-Penrose-Inverse). The singular value decomposition is used to calculate the pseudoinverse.
entailment
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...
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...
entailment
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) ...
Unifies the vector. The length of the vector will be 1. :return: Return the instance itself :rtype: Vector
entailment