repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
linode/linode_api4-python
linode_api4/linode_client.py
ProfileGroup.ssh_key_upload
def ssh_key_upload(self, key, label): """ Uploads a new SSH Public Key to your profile This key can be used in later Linode deployments. :param key: The ssh key, or a path to the ssh key. If a path is provided, the file at the path must exist and be readable or an ...
python
def ssh_key_upload(self, key, label): """ Uploads a new SSH Public Key to your profile This key can be used in later Linode deployments. :param key: The ssh key, or a path to the ssh key. If a path is provided, the file at the path must exist and be readable or an ...
[ "def", "ssh_key_upload", "(", "self", ",", "key", ",", "label", ")", ":", "if", "not", "key", ".", "startswith", "(", "SSH_KEY_TYPES", ")", ":", "# this might be a file path - look for it", "path", "=", "os", ".", "path", ".", "expanduser", "(", "key", ")", ...
Uploads a new SSH Public Key to your profile This key can be used in later Linode deployments. :param key: The ssh key, or a path to the ssh key. If a path is provided, the file at the path must exist and be readable or an exception will be thrown. :typ...
[ "Uploads", "a", "new", "SSH", "Public", "Key", "to", "your", "profile", "This", "key", "can", "be", "used", "in", "later", "Linode", "deployments", "." ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L392-L430
linode/linode_api4-python
linode_api4/linode_client.py
LongviewGroup.client_create
def client_create(self, label=None): """ Creates a new LongviewClient, optionally with a given label. :param label: The label for the new client. If None, a default label based on the new client's ID will be used. :returns: A new LongviewClient :raises ApiError: I...
python
def client_create(self, label=None): """ Creates a new LongviewClient, optionally with a given label. :param label: The label for the new client. If None, a default label based on the new client's ID will be used. :returns: A new LongviewClient :raises ApiError: I...
[ "def", "client_create", "(", "self", ",", "label", "=", "None", ")", ":", "result", "=", "self", ".", "client", ".", "post", "(", "'/longview/clients'", ",", "data", "=", "{", "\"label\"", ":", "label", "}", ")", "if", "not", "'id'", "in", "result", ...
Creates a new LongviewClient, optionally with a given label. :param label: The label for the new client. If None, a default label based on the new client's ID will be used. :returns: A new LongviewClient :raises ApiError: If a non-200 status code is returned :raises Unexp...
[ "Creates", "a", "new", "LongviewClient", "optionally", "with", "a", "given", "label", "." ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L441-L463
linode/linode_api4-python
linode_api4/linode_client.py
AccountGroup.events_mark_seen
def events_mark_seen(self, event): """ Marks event as the last event we have seen. If event is an int, it is treated as an event_id, otherwise it should be an event object whose id will be used. """ last_seen = event if isinstance(event, int) else event.id self.client.po...
python
def events_mark_seen(self, event): """ Marks event as the last event we have seen. If event is an int, it is treated as an event_id, otherwise it should be an event object whose id will be used. """ last_seen = event if isinstance(event, int) else event.id self.client.po...
[ "def", "events_mark_seen", "(", "self", ",", "event", ")", ":", "last_seen", "=", "event", "if", "isinstance", "(", "event", ",", "int", ")", "else", "event", ".", "id", "self", ".", "client", ".", "post", "(", "'{}/seen'", ".", "format", "(", "Event",...
Marks event as the last event we have seen. If event is an int, it is treated as an event_id, otherwise it should be an event object whose id will be used.
[ "Marks", "event", "as", "the", "last", "event", "we", "have", "seen", ".", "If", "event", "is", "an", "int", "it", "is", "treated", "as", "an", "event_id", "otherwise", "it", "should", "be", "an", "event", "object", "whose", "id", "will", "be", "used",...
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L495-L501
linode/linode_api4-python
linode_api4/linode_client.py
AccountGroup.settings
def settings(self): """ Resturns the account settings data for this acocunt. This is not a listing endpoint. """ result = self.client.get('/account/settings') if not 'managed' in result: raise UnexpectedResponseError('Unexpected response when getting accoun...
python
def settings(self): """ Resturns the account settings data for this acocunt. This is not a listing endpoint. """ result = self.client.get('/account/settings') if not 'managed' in result: raise UnexpectedResponseError('Unexpected response when getting accoun...
[ "def", "settings", "(", "self", ")", ":", "result", "=", "self", ".", "client", ".", "get", "(", "'/account/settings'", ")", "if", "not", "'managed'", "in", "result", ":", "raise", "UnexpectedResponseError", "(", "'Unexpected response when getting account settings!'...
Resturns the account settings data for this acocunt. This is not a listing endpoint.
[ "Resturns", "the", "account", "settings", "data", "for", "this", "acocunt", ".", "This", "is", "not", "a", "listing", "endpoint", "." ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L503-L515
linode/linode_api4-python
linode_api4/linode_client.py
AccountGroup.oauth_client_create
def oauth_client_create(self, name, redirect_uri, **kwargs): """ Make a new OAuth Client and return it """ params = { "label": name, "redirect_uri": redirect_uri, } params.update(kwargs) result = self.client.post('/account/oauth-clients', ...
python
def oauth_client_create(self, name, redirect_uri, **kwargs): """ Make a new OAuth Client and return it """ params = { "label": name, "redirect_uri": redirect_uri, } params.update(kwargs) result = self.client.post('/account/oauth-clients', ...
[ "def", "oauth_client_create", "(", "self", ",", "name", ",", "redirect_uri", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "\"label\"", ":", "name", ",", "\"redirect_uri\"", ":", "redirect_uri", ",", "}", "params", ".", "update", "(", "kwargs", ...
Make a new OAuth Client and return it
[ "Make", "a", "new", "OAuth", "Client", "and", "return", "it" ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L535-L552
linode/linode_api4-python
linode_api4/linode_client.py
AccountGroup.transfer
def transfer(self): """ Returns a MappedObject containing the account's transfer pool data """ result = self.client.get('/account/transfer') if not 'used' in result: raise UnexpectedResponseError('Unexpected response when getting Transfer Pool!') return Mapp...
python
def transfer(self): """ Returns a MappedObject containing the account's transfer pool data """ result = self.client.get('/account/transfer') if not 'used' in result: raise UnexpectedResponseError('Unexpected response when getting Transfer Pool!') return Mapp...
[ "def", "transfer", "(", "self", ")", ":", "result", "=", "self", ".", "client", ".", "get", "(", "'/account/transfer'", ")", "if", "not", "'used'", "in", "result", ":", "raise", "UnexpectedResponseError", "(", "'Unexpected response when getting Transfer Pool!'", "...
Returns a MappedObject containing the account's transfer pool data
[ "Returns", "a", "MappedObject", "containing", "the", "account", "s", "transfer", "pool", "data" ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L560-L569
linode/linode_api4-python
linode_api4/linode_client.py
AccountGroup.user_create
def user_create(self, email, username, restricted=True): """ Creates a new user on your account. If you create an unrestricted user, they will immediately be able to access everything on your account. If you create a restricted user, you must grant them access to parts of your ...
python
def user_create(self, email, username, restricted=True): """ Creates a new user on your account. If you create an unrestricted user, they will immediately be able to access everything on your account. If you create a restricted user, you must grant them access to parts of your ...
[ "def", "user_create", "(", "self", ",", "email", ",", "username", ",", "restricted", "=", "True", ")", ":", "params", "=", "{", "\"email\"", ":", "email", ",", "\"username\"", ":", "username", ",", "\"restricted\"", ":", "restricted", ",", "}", "result", ...
Creates a new user on your account. If you create an unrestricted user, they will immediately be able to access everything on your account. If you create a restricted user, you must grant them access to parts of your account that you want to allow them to manage (see :any:`User.grants` for ...
[ "Creates", "a", "new", "user", "on", "your", "account", ".", "If", "you", "create", "an", "unrestricted", "user", "they", "will", "immediately", "be", "able", "to", "access", "everything", "on", "your", "account", ".", "If", "you", "create", "a", "restrict...
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L571-L608
linode/linode_api4-python
linode_api4/linode_client.py
NetworkingGroup.ips_assign
def ips_assign(self, region, *assignments): """ Redistributes :any:`IP Addressees<IPAddress>` within a single region. This function takes a :any:`Region` and a list of assignments to make, then requests that the assignments take place. If any :any:`Instance` ends up without a pu...
python
def ips_assign(self, region, *assignments): """ Redistributes :any:`IP Addressees<IPAddress>` within a single region. This function takes a :any:`Region` and a list of assignments to make, then requests that the assignments take place. If any :any:`Instance` ends up without a pu...
[ "def", "ips_assign", "(", "self", ",", "region", ",", "*", "assignments", ")", ":", "for", "a", "in", "assignments", ":", "if", "not", "'address'", "in", "a", "or", "not", "'linode_id'", "in", "a", ":", "raise", "ValueError", "(", "\"Invalid assignment: {}...
Redistributes :any:`IP Addressees<IPAddress>` within a single region. This function takes a :any:`Region` and a list of assignments to make, then requests that the assignments take place. If any :any:`Instance` ends up without a public IP, or with more than one private IP, all of the as...
[ "Redistributes", ":", "any", ":", "IP", "Addressees<IPAddress", ">", "within", "a", "single", "region", ".", "This", "function", "takes", "a", ":", "any", ":", "Region", "and", "a", "list", "of", "assignments", "to", "make", "then", "requests", "that", "th...
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L620-L656
linode/linode_api4-python
linode_api4/linode_client.py
NetworkingGroup.ip_allocate
def ip_allocate(self, linode, public=True): """ Allocates an IP to a Instance you own. Additional IPs must be requested by opening a support ticket first. :param linode: The Instance to allocate the new IP for. :type linode: Instance or int :param public: If True, alloc...
python
def ip_allocate(self, linode, public=True): """ Allocates an IP to a Instance you own. Additional IPs must be requested by opening a support ticket first. :param linode: The Instance to allocate the new IP for. :type linode: Instance or int :param public: If True, alloc...
[ "def", "ip_allocate", "(", "self", ",", "linode", ",", "public", "=", "True", ")", ":", "result", "=", "self", ".", "client", ".", "post", "(", "'/networking/ipv4/'", ",", "data", "=", "{", "\"linode_id\"", ":", "linode", ".", "id", "if", "isinstance", ...
Allocates an IP to a Instance you own. Additional IPs must be requested by opening a support ticket first. :param linode: The Instance to allocate the new IP for. :type linode: Instance or int :param public: If True, allocate a public IP address. Defaults to True. :type public...
[ "Allocates", "an", "IP", "to", "a", "Instance", "you", "own", ".", "Additional", "IPs", "must", "be", "requested", "by", "opening", "a", "support", "ticket", "first", "." ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L658-L682
linode/linode_api4-python
linode_api4/linode_client.py
NetworkingGroup.shared_ips
def shared_ips(self, linode, *ips): """ Shares the given list of :any:`IPAddresses<IPAddress>` with the provided :any:`Instance`. This will enable the provided Instance to bring up the shared IP Addresses even though it does not own them. :param linode: The Instance to share th...
python
def shared_ips(self, linode, *ips): """ Shares the given list of :any:`IPAddresses<IPAddress>` with the provided :any:`Instance`. This will enable the provided Instance to bring up the shared IP Addresses even though it does not own them. :param linode: The Instance to share th...
[ "def", "shared_ips", "(", "self", ",", "linode", ",", "*", "ips", ")", ":", "if", "not", "isinstance", "(", "linode", ",", "Instance", ")", ":", "# make this an object", "linode", "=", "Instance", "(", "self", ".", "client", ",", "linode", ")", "params",...
Shares the given list of :any:`IPAddresses<IPAddress>` with the provided :any:`Instance`. This will enable the provided Instance to bring up the shared IP Addresses even though it does not own them. :param linode: The Instance to share the IPAddresses with. This Instance ...
[ "Shares", "the", "given", "list", "of", ":", "any", ":", "IPAddresses<IPAddress", ">", "with", "the", "provided", ":", "any", ":", "Instance", ".", "This", "will", "enable", "the", "provided", "Instance", "to", "bring", "up", "the", "shared", "IP", "Addres...
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L684-L716
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient.load
def load(self, target_type, target_id, target_parent_id=None): """ Constructs and immediately loads the object, circumventing the lazy-loading scheme by immediately making an API request. Does not load related objects. For example, if you wanted to load an :any:`Instance` objec...
python
def load(self, target_type, target_id, target_parent_id=None): """ Constructs and immediately loads the object, circumventing the lazy-loading scheme by immediately making an API request. Does not load related objects. For example, if you wanted to load an :any:`Instance` objec...
[ "def", "load", "(", "self", ",", "target_type", ",", "target_id", ",", "target_parent_id", "=", "None", ")", ":", "result", "=", "target_type", ".", "make_instance", "(", "target_id", ",", "self", ",", "parent_id", "=", "target_parent_id", ")", "result", "."...
Constructs and immediately loads the object, circumventing the lazy-loading scheme by immediately making an API request. Does not load related objects. For example, if you wanted to load an :any:`Instance` object with ID 123, you could do this:: loaded_linode = client.load(...
[ "Constructs", "and", "immediately", "loads", "the", "object", "circumventing", "the", "lazy", "-", "loading", "scheme", "by", "immediately", "making", "an", "API", "request", ".", "Does", "not", "load", "related", "objects", "." ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L808-L839
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient._api_call
def _api_call(self, endpoint, model=None, method=None, data=None, filters=None): """ Makes a call to the linode api. Data should only be given if the method is POST or PUT, and should be a dictionary """ if not self.token: raise RuntimeError("You do not have an API t...
python
def _api_call(self, endpoint, model=None, method=None, data=None, filters=None): """ Makes a call to the linode api. Data should only be given if the method is POST or PUT, and should be a dictionary """ if not self.token: raise RuntimeError("You do not have an API t...
[ "def", "_api_call", "(", "self", ",", "endpoint", ",", "model", "=", "None", ",", "method", "=", "None", ",", "data", "=", "None", ",", "filters", "=", "None", ")", ":", "if", "not", "self", ".", "token", ":", "raise", "RuntimeError", "(", "\"You do ...
Makes a call to the linode api. Data should only be given if the method is POST or PUT, and should be a dictionary
[ "Makes", "a", "call", "to", "the", "linode", "api", ".", "Data", "should", "only", "be", "given", "if", "the", "method", "is", "POST", "or", "PUT", "and", "should", "be", "a", "dictionary" ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L841-L892
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient.image_create
def image_create(self, disk, label=None, description=None): """ Creates a new Image from a disk you own. :param disk: The Disk to imagize. :type disk: Disk or int :param label: The label for the resulting Image (defaults to the disk's label. :type l...
python
def image_create(self, disk, label=None, description=None): """ Creates a new Image from a disk you own. :param disk: The Disk to imagize. :type disk: Disk or int :param label: The label for the resulting Image (defaults to the disk's label. :type l...
[ "def", "image_create", "(", "self", ",", "disk", ",", "label", "=", "None", ",", "description", "=", "None", ")", ":", "params", "=", "{", "\"disk_id\"", ":", "disk", ".", "id", "if", "issubclass", "(", "type", "(", "disk", ")", ",", "Base", ")", "...
Creates a new Image from a disk you own. :param disk: The Disk to imagize. :type disk: Disk or int :param label: The label for the resulting Image (defaults to the disk's label. :type label: str :param description: The description for the new Image. ...
[ "Creates", "a", "new", "Image", "from", "a", "disk", "you", "own", "." ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L950-L981
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient.nodebalancer_create
def nodebalancer_create(self, region, **kwargs): """ Creates a new NodeBalancer in the given Region. :param region: The Region in which to create the NodeBalancer. :type region: Region or str :returns: The new NodeBalancer :rtype: NodeBalancer """ params...
python
def nodebalancer_create(self, region, **kwargs): """ Creates a new NodeBalancer in the given Region. :param region: The Region in which to create the NodeBalancer. :type region: Region or str :returns: The new NodeBalancer :rtype: NodeBalancer """ params...
[ "def", "nodebalancer_create", "(", "self", ",", "region", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "\"region\"", ":", "region", ".", "id", "if", "isinstance", "(", "region", ",", "Base", ")", "else", "region", ",", "}", "params", ".", "...
Creates a new NodeBalancer in the given Region. :param region: The Region in which to create the NodeBalancer. :type region: Region or str :returns: The new NodeBalancer :rtype: NodeBalancer
[ "Creates", "a", "new", "NodeBalancer", "in", "the", "given", "Region", "." ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L1005-L1026
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient.domain_create
def domain_create(self, domain, master=True, **kwargs): """ Registers a new Domain on the acting user's account. Make sure to point your registrar to Linode's nameservers so that Linode's DNS manager will correctly serve your domain. :param domain: The domain to register to Lin...
python
def domain_create(self, domain, master=True, **kwargs): """ Registers a new Domain on the acting user's account. Make sure to point your registrar to Linode's nameservers so that Linode's DNS manager will correctly serve your domain. :param domain: The domain to register to Lin...
[ "def", "domain_create", "(", "self", ",", "domain", ",", "master", "=", "True", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'domain'", ":", "domain", ",", "'type'", ":", "'master'", "if", "master", "else", "'slave'", ",", "}", "params", "...
Registers a new Domain on the acting user's account. Make sure to point your registrar to Linode's nameservers so that Linode's DNS manager will correctly serve your domain. :param domain: The domain to register to Linode's DNS manager. :type domain: str :param master: Whether ...
[ "Registers", "a", "new", "Domain", "on", "the", "acting", "user", "s", "account", ".", "Make", "sure", "to", "point", "your", "registrar", "to", "Linode", "s", "nameservers", "so", "that", "Linode", "s", "DNS", "manager", "will", "correctly", "serve", "you...
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L1028-L1054
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient.tag_create
def tag_create(self, label, instances=None, domains=None, nodebalancers=None, volumes=None, entities=[]): """ Creates a new Tag and optionally applies it to the given entities. :param label: The label for the new Tag :type label: str :param entities: A list of...
python
def tag_create(self, label, instances=None, domains=None, nodebalancers=None, volumes=None, entities=[]): """ Creates a new Tag and optionally applies it to the given entities. :param label: The label for the new Tag :type label: str :param entities: A list of...
[ "def", "tag_create", "(", "self", ",", "label", ",", "instances", "=", "None", ",", "domains", "=", "None", ",", "nodebalancers", "=", "None", ",", "volumes", "=", "None", ",", "entities", "=", "[", "]", ")", ":", "linode_ids", ",", "nodebalancer_ids", ...
Creates a new Tag and optionally applies it to the given entities. :param label: The label for the new Tag :type label: str :param entities: A list of objects to apply this Tag to upon creation. May only be taggable types (Linode Instances, Domains, ...
[ "Creates", "a", "new", "Tag", "and", "optionally", "applies", "it", "to", "the", "given", "entities", "." ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L1068-L1143
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient.volume_create
def volume_create(self, label, region=None, linode=None, size=20, **kwargs): """ Creates a new Block Storage Volume, either in the given Region or attached to the given Instance. :param label: The label for the new Volume. :type label: str :param region: The Region to cr...
python
def volume_create(self, label, region=None, linode=None, size=20, **kwargs): """ Creates a new Block Storage Volume, either in the given Region or attached to the given Instance. :param label: The label for the new Volume. :type label: str :param region: The Region to cr...
[ "def", "volume_create", "(", "self", ",", "label", ",", "region", "=", "None", ",", "linode", "=", "None", ",", "size", "=", "20", ",", "*", "*", "kwargs", ")", ":", "if", "not", "(", "region", "or", "linode", ")", ":", "raise", "ValueError", "(", ...
Creates a new Block Storage Volume, either in the given Region or attached to the given Instance. :param label: The label for the new Volume. :type label: str :param region: The Region to create this Volume in. Not required if `linode` is provided. :type ...
[ "Creates", "a", "new", "Block", "Storage", "Volume", "either", "in", "the", "given", "Region", "or", "attached", "to", "the", "given", "Instance", "." ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L1156-L1192
linode/linode_api4-python
linode_api4/login_client.py
LinodeLoginClient.generate_login_url
def generate_login_url(self, scopes=None, redirect_uri=None): """ Generates a url to send users so that they may authenticate to this application. This url is suitable for redirecting a user to. For example, in `Flask`_, a login route might be implemented like this:: @app.r...
python
def generate_login_url(self, scopes=None, redirect_uri=None): """ Generates a url to send users so that they may authenticate to this application. This url is suitable for redirecting a user to. For example, in `Flask`_, a login route might be implemented like this:: @app.r...
[ "def", "generate_login_url", "(", "self", ",", "scopes", "=", "None", ",", "redirect_uri", "=", "None", ")", ":", "url", "=", "self", ".", "base_url", "+", "\"/oauth/authorize\"", "split", "=", "list", "(", "urlparse", "(", "url", ")", ")", "params", "="...
Generates a url to send users so that they may authenticate to this application. This url is suitable for redirecting a user to. For example, in `Flask`_, a login route might be implemented like this:: @app.route("/login") def begin_oauth_login(): login_client = L...
[ "Generates", "a", "url", "to", "send", "users", "so", "that", "they", "may", "authenticate", "to", "this", "application", ".", "This", "url", "is", "suitable", "for", "redirecting", "a", "user", "to", ".", "For", "example", "in", "Flask", "_", "a", "logi...
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/login_client.py#L295-L329
linode/linode_api4-python
linode_api4/login_client.py
LinodeLoginClient.finish_oauth
def finish_oauth(self, code): """ Given an OAuth Exchange Code, completes the OAuth exchange with the authentication server. This should be called once the user has already been directed to the login_uri, and has been sent back after successfully authenticating. For example, in...
python
def finish_oauth(self, code): """ Given an OAuth Exchange Code, completes the OAuth exchange with the authentication server. This should be called once the user has already been directed to the login_uri, and has been sent back after successfully authenticating. For example, in...
[ "def", "finish_oauth", "(", "self", ",", "code", ")", ":", "r", "=", "requests", ".", "post", "(", "self", ".", "_login_uri", "(", "\"/oauth/token\"", ")", ",", "data", "=", "{", "\"code\"", ":", "code", ",", "\"client_id\"", ":", "self", ".", "client_...
Given an OAuth Exchange Code, completes the OAuth exchange with the authentication server. This should be called once the user has already been directed to the login_uri, and has been sent back after successfully authenticating. For example, in `Flask`_, this might be implemented as a ...
[ "Given", "an", "OAuth", "Exchange", "Code", "completes", "the", "OAuth", "exchange", "with", "the", "authentication", "server", ".", "This", "should", "be", "called", "once", "the", "user", "has", "already", "been", "directed", "to", "the", "login_uri", "and",...
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/login_client.py#L331-L378
linode/linode_api4-python
linode_api4/login_client.py
LinodeLoginClient.expire_token
def expire_token(self, token): """ Given a token, makes a request to the authentication server to expire it immediately. This is considered a responsible way to log out a user. If you simply remove the session your application has for the user without expiring their token, the ...
python
def expire_token(self, token): """ Given a token, makes a request to the authentication server to expire it immediately. This is considered a responsible way to log out a user. If you simply remove the session your application has for the user without expiring their token, the ...
[ "def", "expire_token", "(", "self", ",", "token", ")", ":", "r", "=", "requests", ".", "post", "(", "self", ".", "_login_uri", "(", "\"/oauth/token/expire\"", ")", ",", "data", "=", "{", "\"client_id\"", ":", "self", ".", "client_id", ",", "\"client_secret...
Given a token, makes a request to the authentication server to expire it immediately. This is considered a responsible way to log out a user. If you simply remove the session your application has for the user without expiring their token, the user is not _really_ logged out. :param to...
[ "Given", "a", "token", "makes", "a", "request", "to", "the", "authentication", "server", "to", "expire", "it", "immediately", ".", "This", "is", "considered", "a", "responsible", "way", "to", "log", "out", "a", "user", ".", "If", "you", "simply", "remove",...
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/login_client.py#L417-L441
linode/linode_api4-python
linode_api4/objects/profile.py
Profile.grants
def grants(self): """ Returns grants for the current user """ from linode_api4.objects.account import UserGrants resp = self._client.get('/profile/grants') # use special endpoint for restricted users grants = None if resp is not None: # if resp is Non...
python
def grants(self): """ Returns grants for the current user """ from linode_api4.objects.account import UserGrants resp = self._client.get('/profile/grants') # use special endpoint for restricted users grants = None if resp is not None: # if resp is Non...
[ "def", "grants", "(", "self", ")", ":", "from", "linode_api4", ".", "objects", ".", "account", "import", "UserGrants", "resp", "=", "self", ".", "_client", ".", "get", "(", "'/profile/grants'", ")", "# use special endpoint for restricted users", "grants", "=", "...
Returns grants for the current user
[ "Returns", "grants", "for", "the", "current", "user" ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/profile.py#L91-L103
linode/linode_api4-python
linode_api4/objects/profile.py
Profile.add_whitelist_entry
def add_whitelist_entry(self, address, netmask, note=None): """ Adds a new entry to this user's IP whitelist, if enabled """ result = self._client.post("{}/whitelist".format(Profile.api_endpoint), data={ "address": address, "netmask...
python
def add_whitelist_entry(self, address, netmask, note=None): """ Adds a new entry to this user's IP whitelist, if enabled """ result = self._client.post("{}/whitelist".format(Profile.api_endpoint), data={ "address": address, "netmask...
[ "def", "add_whitelist_entry", "(", "self", ",", "address", ",", "netmask", ",", "note", "=", "None", ")", ":", "result", "=", "self", ".", "_client", ".", "post", "(", "\"{}/whitelist\"", ".", "format", "(", "Profile", ".", "api_endpoint", ")", ",", "dat...
Adds a new entry to this user's IP whitelist, if enabled
[ "Adds", "a", "new", "entry", "to", "this", "user", "s", "IP", "whitelist", "if", "enabled" ]
train
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/profile.py#L112-L126
tmm/django-username-email
cuser/forms.py
AuthenticationForm.confirm_login_allowed
def confirm_login_allowed(self, user): """ Controls whether the given User may log in. This is a policy setting, independent of end-user authentication. This default behavior is to allow login by active users, and reject login by inactive users. If the given user cannot log in, ...
python
def confirm_login_allowed(self, user): """ Controls whether the given User may log in. This is a policy setting, independent of end-user authentication. This default behavior is to allow login by active users, and reject login by inactive users. If the given user cannot log in, ...
[ "def", "confirm_login_allowed", "(", "self", ",", "user", ")", ":", "if", "not", "user", ".", "is_active", ":", "raise", "forms", ".", "ValidationError", "(", "self", ".", "error_messages", "[", "'inactive'", "]", ",", "code", "=", "'inactive'", ",", ")" ]
Controls whether the given User may log in. This is a policy setting, independent of end-user authentication. This default behavior is to allow login by active users, and reject login by inactive users. If the given user cannot log in, this method should raise a ``forms.ValidationError`...
[ "Controls", "whether", "the", "given", "User", "may", "log", "in", ".", "This", "is", "a", "policy", "setting", "independent", "of", "end", "-", "user", "authentication", ".", "This", "default", "behavior", "is", "to", "allow", "login", "by", "active", "us...
train
https://github.com/tmm/django-username-email/blob/36e56bcbf79d46af101ba4c8f4bd848856306329/cuser/forms.py#L68-L83
dwavesystems/dwave-system
dwave/embedding/chain_breaks.py
broken_chains
def broken_chains(samples, chains): """Find the broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): ...
python
def broken_chains(samples, chains): """Find the broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): ...
[ "def", "broken_chains", "(", "samples", ",", "chains", ")", ":", "samples", "=", "np", ".", "asarray", "(", "samples", ")", "if", "samples", ".", "ndim", "!=", "2", ":", "raise", "ValueError", "(", "\"expected samples to be a numpy 2D array\"", ")", "num_sampl...
Find the broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): List of chains of length nC where nC...
[ "Find", "the", "broken", "chains", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/chain_breaks.py#L33-L88
dwavesystems/dwave-system
dwave/embedding/chain_breaks.py
discard
def discard(samples, chains): """Discard broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): ...
python
def discard(samples, chains): """Discard broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): ...
[ "def", "discard", "(", "samples", ",", "chains", ")", ":", "samples", "=", "np", ".", "asarray", "(", "samples", ")", "if", "samples", ".", "ndim", "!=", "2", ":", "raise", "ValueError", "(", "\"expected samples to be a numpy 2D array\"", ")", "num_samples", ...
Discard broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): List of chains of length nC where nC ...
[ "Discard", "broken", "chains", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/chain_breaks.py#L91-L142
dwavesystems/dwave-system
dwave/embedding/chain_breaks.py
majority_vote
def majority_vote(samples, chains): """Use the most common element in broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (li...
python
def majority_vote(samples, chains): """Use the most common element in broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (li...
[ "def", "majority_vote", "(", "samples", ",", "chains", ")", ":", "samples", "=", "np", ".", "asarray", "(", "samples", ")", "if", "samples", ".", "ndim", "!=", "2", ":", "raise", "ValueError", "(", "\"expected samples to be a numpy 2D array\"", ")", "num_sampl...
Use the most common element in broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): List of chains...
[ "Use", "the", "most", "common", "element", "in", "broken", "chains", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/chain_breaks.py#L145-L206
dwavesystems/dwave-system
dwave/embedding/chain_breaks.py
weighted_random
def weighted_random(samples, chains): """Determine the sample values of chains by weighed random choice. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1....
python
def weighted_random(samples, chains): """Determine the sample values of chains by weighed random choice. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1....
[ "def", "weighted_random", "(", "samples", ",", "chains", ")", ":", "samples", "=", "np", ".", "asarray", "(", "samples", ")", "if", "samples", ".", "ndim", "!=", "2", ":", "raise", "ValueError", "(", "\"expected samples to be a numpy 2D array\"", ")", "# it su...
Determine the sample values of chains by weighed random choice. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): ...
[ "Determine", "the", "sample", "values", "of", "chains", "by", "weighed", "random", "choice", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/chain_breaks.py#L209-L256
dwavesystems/dwave-system
dwave/system/samplers/dwave_sampler.py
DWaveSampler.sample_ising
def sample_ising(self, h, J, **kwargs): """Sample from the specified Ising model. Args: h (list/dict): Linear biases of the Ising model. If a list, the list's indices are used as variable labels. J (dict[(int, int): float]): Quadr...
python
def sample_ising(self, h, J, **kwargs): """Sample from the specified Ising model. Args: h (list/dict): Linear biases of the Ising model. If a list, the list's indices are used as variable labels. J (dict[(int, int): float]): Quadr...
[ "def", "sample_ising", "(", "self", ",", "h", ",", "J", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "h", ",", "list", ")", ":", "h", "=", "dict", "(", "enumerate", "(", "h", ")", ")", "variables", "=", "set", "(", "h", ")", "....
Sample from the specified Ising model. Args: h (list/dict): Linear biases of the Ising model. If a list, the list's indices are used as variable labels. J (dict[(int, int): float]): Quadratic biases of the Ising model. **kwar...
[ "Sample", "from", "the", "specified", "Ising", "model", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/samplers/dwave_sampler.py#L226-L273
dwavesystems/dwave-system
dwave/system/samplers/dwave_sampler.py
DWaveSampler.sample_qubo
def sample_qubo(self, Q, **kwargs): """Sample from the specified QUBO. Args: Q (dict): Coefficients of a quadratic unconstrained binary optimization (QUBO) model. **kwargs: Optional keyword arguments for the sampling method, specified per solver ...
python
def sample_qubo(self, Q, **kwargs): """Sample from the specified QUBO. Args: Q (dict): Coefficients of a quadratic unconstrained binary optimization (QUBO) model. **kwargs: Optional keyword arguments for the sampling method, specified per solver ...
[ "def", "sample_qubo", "(", "self", ",", "Q", ",", "*", "*", "kwargs", ")", ":", "variables", "=", "set", "(", ")", ".", "union", "(", "*", "Q", ")", "try", ":", "active_variables", "=", "sorted", "(", "variables", ")", "except", "TypeError", ":", "...
Sample from the specified QUBO. Args: Q (dict): Coefficients of a quadratic unconstrained binary optimization (QUBO) model. **kwargs: Optional keyword arguments for the sampling method, specified per solver in :attr:`.DWaveSampler.paramet...
[ "Sample", "from", "the", "specified", "QUBO", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/samplers/dwave_sampler.py#L275-L316
dwavesystems/dwave-system
dwave/system/samplers/dwave_sampler.py
DWaveSampler.validate_anneal_schedule
def validate_anneal_schedule(self, anneal_schedule): """Raise an exception if the specified schedule is invalid for the sampler. Args: anneal_schedule (list): An anneal schedule variation is defined by a series of pairs of floating-point numbers identifying p...
python
def validate_anneal_schedule(self, anneal_schedule): """Raise an exception if the specified schedule is invalid for the sampler. Args: anneal_schedule (list): An anneal schedule variation is defined by a series of pairs of floating-point numbers identifying p...
[ "def", "validate_anneal_schedule", "(", "self", ",", "anneal_schedule", ")", ":", "if", "'anneal_schedule'", "not", "in", "self", ".", "parameters", ":", "raise", "RuntimeError", "(", "\"anneal_schedule is not an accepted parameter for this sampler\"", ")", "properties", ...
Raise an exception if the specified schedule is invalid for the sampler. Args: anneal_schedule (list): An anneal schedule variation is defined by a series of pairs of floating-point numbers identifying points in the schedule at which to change slope. The first ...
[ "Raise", "an", "exception", "if", "the", "specified", "schedule", "is", "invalid", "for", "the", "sampler", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/samplers/dwave_sampler.py#L318-L412
dwavesystems/dwave-system
dwave/embedding/utils.py
target_to_source
def target_to_source(target_adjacency, embedding): """Derive the source adjacency from an embedding and target adjacency. Args: target_adjacency (dict/:class:`networkx.Graph`): A dict of the form {v: Nv, ...} where v is a node in the target graph and Nv is the neighbors of v as ...
python
def target_to_source(target_adjacency, embedding): """Derive the source adjacency from an embedding and target adjacency. Args: target_adjacency (dict/:class:`networkx.Graph`): A dict of the form {v: Nv, ...} where v is a node in the target graph and Nv is the neighbors of v as ...
[ "def", "target_to_source", "(", "target_adjacency", ",", "embedding", ")", ":", "# the nodes in the source adjacency are just the keys of the embedding", "source_adjacency", "=", "{", "v", ":", "set", "(", ")", "for", "v", "in", "embedding", "}", "# we need the mapping fr...
Derive the source adjacency from an embedding and target adjacency. Args: target_adjacency (dict/:class:`networkx.Graph`): A dict of the form {v: Nv, ...} where v is a node in the target graph and Nv is the neighbors of v as an iterable. This can also be a networkx graph. e...
[ "Derive", "the", "source", "adjacency", "from", "an", "embedding", "and", "target", "adjacency", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/utils.py#L30-L95
dwavesystems/dwave-system
dwave/embedding/utils.py
chain_to_quadratic
def chain_to_quadratic(chain, target_adjacency, chain_strength): """Determine the quadratic biases that induce the given chain. Args: chain (iterable): The variables that make up a chain. target_adjacency (dict/:class:`networkx.Graph`): Should be a dict of the form {s: ...
python
def chain_to_quadratic(chain, target_adjacency, chain_strength): """Determine the quadratic biases that induce the given chain. Args: chain (iterable): The variables that make up a chain. target_adjacency (dict/:class:`networkx.Graph`): Should be a dict of the form {s: ...
[ "def", "chain_to_quadratic", "(", "chain", ",", "target_adjacency", ",", "chain_strength", ")", ":", "quadratic", "=", "{", "}", "# we will be adding the edges that make the chain here", "# do a breadth first search", "seen", "=", "set", "(", ")", "try", ":", "next_leve...
Determine the quadratic biases that induce the given chain. Args: chain (iterable): The variables that make up a chain. target_adjacency (dict/:class:`networkx.Graph`): Should be a dict of the form {s: Ns, ...} where s is a variable in the target graph and Ns is...
[ "Determine", "the", "quadratic", "biases", "that", "induce", "the", "given", "chain", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/utils.py#L98-L150
dwavesystems/dwave-system
dwave/embedding/utils.py
chain_break_frequency
def chain_break_frequency(samples_like, embedding): """Determine the frequency of chain breaks in the given samples. Args: samples_like (samples_like/:obj:`dimod.SampleSet`): A collection of raw samples. 'samples_like' is an extension of NumPy's array_like. See :func:`dimod.as_s...
python
def chain_break_frequency(samples_like, embedding): """Determine the frequency of chain breaks in the given samples. Args: samples_like (samples_like/:obj:`dimod.SampleSet`): A collection of raw samples. 'samples_like' is an extension of NumPy's array_like. See :func:`dimod.as_s...
[ "def", "chain_break_frequency", "(", "samples_like", ",", "embedding", ")", ":", "if", "isinstance", "(", "samples_like", ",", "dimod", ".", "SampleSet", ")", ":", "labels", "=", "samples_like", ".", "variables", "samples", "=", "samples_like", ".", "record", ...
Determine the frequency of chain breaks in the given samples. Args: samples_like (samples_like/:obj:`dimod.SampleSet`): A collection of raw samples. 'samples_like' is an extension of NumPy's array_like. See :func:`dimod.as_samples`. embedding (dict): Mapping fro...
[ "Determine", "the", "frequency", "of", "chain", "breaks", "in", "the", "given", "samples", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/utils.py#L153-L216
dwavesystems/dwave-system
dwave/embedding/utils.py
edgelist_to_adjacency
def edgelist_to_adjacency(edgelist): """Converts an iterator of edges to an adjacency dict. Args: edgelist (iterable): An iterator over 2-tuples where each 2-tuple is an edge. Returns: dict: The adjacency dict. A dict of the form {v: Nv, ...} where v is a node in a graph and ...
python
def edgelist_to_adjacency(edgelist): """Converts an iterator of edges to an adjacency dict. Args: edgelist (iterable): An iterator over 2-tuples where each 2-tuple is an edge. Returns: dict: The adjacency dict. A dict of the form {v: Nv, ...} where v is a node in a graph and ...
[ "def", "edgelist_to_adjacency", "(", "edgelist", ")", ":", "adjacency", "=", "dict", "(", ")", "for", "u", ",", "v", "in", "edgelist", ":", "if", "u", "in", "adjacency", ":", "adjacency", "[", "u", "]", ".", "add", "(", "v", ")", "else", ":", "adja...
Converts an iterator of edges to an adjacency dict. Args: edgelist (iterable): An iterator over 2-tuples where each 2-tuple is an edge. Returns: dict: The adjacency dict. A dict of the form {v: Nv, ...} where v is a node in a graph and Nv is the neighbors of v as an set.
[ "Converts", "an", "iterator", "of", "edges", "to", "an", "adjacency", "dict", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/utils.py#L219-L241
dwavesystems/dwave-system
dwave/system/composites/tiling.py
TilingComposite.sample
def sample(self, bqm, **kwargs): """Sample from the specified binary quadratic model. Args: bqm (:obj:`dimod.BinaryQuadraticModel`): Binary quadratic model to be sampled from. **kwargs: Optional keyword arguments for the sampling method, specifie...
python
def sample(self, bqm, **kwargs): """Sample from the specified binary quadratic model. Args: bqm (:obj:`dimod.BinaryQuadraticModel`): Binary quadratic model to be sampled from. **kwargs: Optional keyword arguments for the sampling method, specifie...
[ "def", "sample", "(", "self", ",", "bqm", ",", "*", "*", "kwargs", ")", ":", "# apply the embeddings to the given problem to tile it across the child sampler", "embedded_bqm", "=", "dimod", ".", "BinaryQuadraticModel", ".", "empty", "(", "bqm", ".", "vartype", ")", ...
Sample from the specified binary quadratic model. Args: bqm (:obj:`dimod.BinaryQuadraticModel`): Binary quadratic model to be sampled from. **kwargs: Optional keyword arguments for the sampling method, specified per solver. Returns: ...
[ "Sample", "from", "the", "specified", "binary", "quadratic", "model", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/tiling.py#L199-L250
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
cache_connect
def cache_connect(database=None): """Returns a connection object to a sqlite database. Args: database (str, optional): The path to the database the user wishes to connect to. If not specified, a default is chosen using :func:`.cache_file`. If the special database name ':memory:'...
python
def cache_connect(database=None): """Returns a connection object to a sqlite database. Args: database (str, optional): The path to the database the user wishes to connect to. If not specified, a default is chosen using :func:`.cache_file`. If the special database name ':memory:'...
[ "def", "cache_connect", "(", "database", "=", "None", ")", ":", "if", "database", "is", "None", ":", "database", "=", "cache_file", "(", ")", "if", "os", ".", "path", ".", "isfile", "(", "database", ")", ":", "# just connect to the database as-is", "conn", ...
Returns a connection object to a sqlite database. Args: database (str, optional): The path to the database the user wishes to connect to. If not specified, a default is chosen using :func:`.cache_file`. If the special database name ':memory:' is given, then a temporary d...
[ "Returns", "a", "connection", "object", "to", "a", "sqlite", "database", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L37-L67
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
insert_chain
def insert_chain(cur, chain, encoded_data=None): """Insert a chain into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chain (iterable): A collection of nodes. Chains in embedding act a...
python
def insert_chain(cur, chain, encoded_data=None): """Insert a chain into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chain (iterable): A collection of nodes. Chains in embedding act a...
[ "def", "insert_chain", "(", "cur", ",", "chain", ",", "encoded_data", "=", "None", ")", ":", "if", "encoded_data", "is", "None", ":", "encoded_data", "=", "{", "}", "if", "'nodes'", "not", "in", "encoded_data", ":", "encoded_data", "[", "'nodes'", "]", "...
Insert a chain into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chain (iterable): A collection of nodes. Chains in embedding act as one node. encoded_data (dict, optional): ...
[ "Insert", "a", "chain", "into", "the", "cache", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L70-L98
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
iter_chain
def iter_chain(cur): """Iterate over all of the chains in the database. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: list: The chain. """ select = "SELECT nodes FROM chain" for node...
python
def iter_chain(cur): """Iterate over all of the chains in the database. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: list: The chain. """ select = "SELECT nodes FROM chain" for node...
[ "def", "iter_chain", "(", "cur", ")", ":", "select", "=", "\"SELECT nodes FROM chain\"", "for", "nodes", ",", "in", "cur", ".", "execute", "(", "select", ")", ":", "yield", "json", ".", "loads", "(", "nodes", ")" ]
Iterate over all of the chains in the database. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: list: The chain.
[ "Iterate", "over", "all", "of", "the", "chains", "in", "the", "database", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L101-L114
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
insert_system
def insert_system(cur, system_name, encoded_data=None): """Insert a system name into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. system_name (str): The unique name of a system ...
python
def insert_system(cur, system_name, encoded_data=None): """Insert a system name into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. system_name (str): The unique name of a system ...
[ "def", "insert_system", "(", "cur", ",", "system_name", ",", "encoded_data", "=", "None", ")", ":", "if", "encoded_data", "is", "None", ":", "encoded_data", "=", "{", "}", "if", "'system_name'", "not", "in", "encoded_data", ":", "encoded_data", "[", "'system...
Insert a system name into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. system_name (str): The unique name of a system encoded_data (dict, optional): If a dictionary i...
[ "Insert", "a", "system", "name", "into", "the", "cache", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L117-L139
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
insert_flux_bias
def insert_flux_bias(cur, chain, system, flux_bias, chain_strength, encoded_data=None): """Insert a flux bias offset into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chain (iterable): ...
python
def insert_flux_bias(cur, chain, system, flux_bias, chain_strength, encoded_data=None): """Insert a flux bias offset into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chain (iterable): ...
[ "def", "insert_flux_bias", "(", "cur", ",", "chain", ",", "system", ",", "flux_bias", ",", "chain_strength", ",", "encoded_data", "=", "None", ")", ":", "if", "encoded_data", "is", "None", ":", "encoded_data", "=", "{", "}", "insert_chain", "(", "cur", ","...
Insert a flux bias offset into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chain (iterable): A collection of nodes. Chains in embedding act as one node. system (str): ...
[ "Insert", "a", "flux", "bias", "offset", "into", "the", "cache", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L158-L212
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
iter_flux_bias
def iter_flux_bias(cur): """Iterate over all flux biases in the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: tuple: A 4-tuple: list: The chain. str: The system n...
python
def iter_flux_bias(cur): """Iterate over all flux biases in the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: tuple: A 4-tuple: list: The chain. str: The system n...
[ "def", "iter_flux_bias", "(", "cur", ")", ":", "select", "=", "\"\"\"\n SELECT nodes, system_name, flux_bias, chain_strength FROM flux_bias_view;\n \"\"\"", "for", "nodes", ",", "system", ",", "flux_bias", ",", "chain_strength", "in", "cur", ".", "execute", "(...
Iterate over all flux biases in the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: tuple: A 4-tuple: list: The chain. str: The system name. float: The flu...
[ "Iterate", "over", "all", "flux", "biases", "in", "the", "cache", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L215-L240
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
get_flux_biases_from_cache
def get_flux_biases_from_cache(cur, chains, system_name, chain_strength, max_age=3600): """Determine the flux biases for all of the the given chains, system and chain strength. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` stat...
python
def get_flux_biases_from_cache(cur, chains, system_name, chain_strength, max_age=3600): """Determine the flux biases for all of the the given chains, system and chain strength. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` stat...
[ "def", "get_flux_biases_from_cache", "(", "cur", ",", "chains", ",", "system_name", ",", "chain_strength", ",", "max_age", "=", "3600", ")", ":", "select", "=", "\"\"\"\n SELECT\n flux_bias\n FROM flux_bias_view WHERE\n chain_length = :chain_le...
Determine the flux biases for all of the the given chains, system and chain strength. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chains (iterable): An iterable of chains. Each chain is a collectio...
[ "Determine", "the", "flux", "biases", "for", "all", "of", "the", "the", "given", "chains", "system", "and", "chain", "strength", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L255-L312
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
insert_graph
def insert_graph(cur, nodelist, edgelist, encoded_data=None): """Insert a graph into the cache. A graph is stored by number of nodes, number of edges and a json-encoded list of edges. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a ...
python
def insert_graph(cur, nodelist, edgelist, encoded_data=None): """Insert a graph into the cache. A graph is stored by number of nodes, number of edges and a json-encoded list of edges. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a ...
[ "def", "insert_graph", "(", "cur", ",", "nodelist", ",", "edgelist", ",", "encoded_data", "=", "None", ")", ":", "if", "encoded_data", "is", "None", ":", "encoded_data", "=", "{", "}", "if", "'num_nodes'", "not", "in", "encoded_data", ":", "encoded_data", ...
Insert a graph into the cache. A graph is stored by number of nodes, number of edges and a json-encoded list of edges. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. nodelist (list): The nodes in the grap...
[ "Insert", "a", "graph", "into", "the", "cache", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L315-L372
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
iter_graph
def iter_graph(cur): """Iterate over all graphs in the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: tuple: A 2-tuple containing: list: The nodelist for a graph in the cache. ...
python
def iter_graph(cur): """Iterate over all graphs in the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: tuple: A 2-tuple containing: list: The nodelist for a graph in the cache. ...
[ "def", "iter_graph", "(", "cur", ")", ":", "select", "=", "\"\"\"SELECT num_nodes, num_edges, edges from graph;\"\"\"", "for", "num_nodes", ",", "num_edges", ",", "edges", "in", "cur", ".", "execute", "(", "select", ")", ":", "yield", "list", "(", "range", "(", ...
Iterate over all graphs in the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: tuple: A 2-tuple containing: list: The nodelist for a graph in the cache. list: the edgel...
[ "Iterate", "over", "all", "graphs", "in", "the", "cache", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L375-L400
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
insert_embedding
def insert_embedding(cur, source_nodelist, source_edgelist, target_nodelist, target_edgelist, embedding, embedding_tag): """Insert an embedding into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` ...
python
def insert_embedding(cur, source_nodelist, source_edgelist, target_nodelist, target_edgelist, embedding, embedding_tag): """Insert an embedding into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` ...
[ "def", "insert_embedding", "(", "cur", ",", "source_nodelist", ",", "source_edgelist", ",", "target_nodelist", ",", "target_edgelist", ",", "embedding", ",", "embedding_tag", ")", ":", "encoded_data", "=", "{", "}", "# first we need to encode the graphs and create the emb...
Insert an embedding into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. source_nodelist (list): The nodes in the source graph. Should be integer valued. source_edgelist (list): ...
[ "Insert", "an", "embedding", "into", "the", "cache", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L403-L509
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
select_embedding_from_tag
def select_embedding_from_tag(cur, embedding_tag, target_nodelist, target_edgelist): """Select an embedding from the given tag and target graph. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. source_nodelist ...
python
def select_embedding_from_tag(cur, embedding_tag, target_nodelist, target_edgelist): """Select an embedding from the given tag and target graph. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. source_nodelist ...
[ "def", "select_embedding_from_tag", "(", "cur", ",", "embedding_tag", ",", "target_nodelist", ",", "target_edgelist", ")", ":", "encoded_data", "=", "{", "'num_nodes'", ":", "len", "(", "target_nodelist", ")", ",", "'num_edges'", ":", "len", "(", "target_edgelist"...
Select an embedding from the given tag and target graph. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. source_nodelist (list): The nodes in the source graph. Should be integer valued. source...
[ "Select", "an", "embedding", "from", "the", "given", "tag", "and", "target", "graph", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L512-L557
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
select_embedding_from_source
def select_embedding_from_source(cur, source_nodelist, source_edgelist, target_nodelist, target_edgelist): """Select an embedding from the source graph and target graph. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run...
python
def select_embedding_from_source(cur, source_nodelist, source_edgelist, target_nodelist, target_edgelist): """Select an embedding from the source graph and target graph. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run...
[ "def", "select_embedding_from_source", "(", "cur", ",", "source_nodelist", ",", "source_edgelist", ",", "target_nodelist", ",", "target_edgelist", ")", ":", "encoded_data", "=", "{", "'target_num_nodes'", ":", "len", "(", "target_nodelist", ")", ",", "'target_num_edge...
Select an embedding from the source graph and target graph. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. target_nodelist (list): The nodes in the target graph. Should be integer valued. tar...
[ "Select", "an", "embedding", "from", "the", "source", "graph", "and", "target", "graph", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L560-L608
dwavesystems/dwave-system
dwave/embedding/pegasus.py
find_clique_embedding
def find_clique_embedding(k, m=None, target_graph=None): """Find an embedding of a k-sized clique on a Pegasus graph (target_graph). This clique is found by transforming the Pegasus graph into a K2,2 Chimera graph and then applying a Chimera clique finding algorithm. The results are then converted back in ...
python
def find_clique_embedding(k, m=None, target_graph=None): """Find an embedding of a k-sized clique on a Pegasus graph (target_graph). This clique is found by transforming the Pegasus graph into a K2,2 Chimera graph and then applying a Chimera clique finding algorithm. The results are then converted back in ...
[ "def", "find_clique_embedding", "(", "k", ",", "m", "=", "None", ",", "target_graph", "=", "None", ")", ":", "# Organize parameter values", "if", "target_graph", "is", "None", ":", "if", "m", "is", "None", ":", "raise", "TypeError", "(", "\"m and target_graph ...
Find an embedding of a k-sized clique on a Pegasus graph (target_graph). This clique is found by transforming the Pegasus graph into a K2,2 Chimera graph and then applying a Chimera clique finding algorithm. The results are then converted back in terms of Pegasus coordinates. Note: If target_graph is ...
[ "Find", "an", "embedding", "of", "a", "k", "-", "sized", "clique", "on", "a", "Pegasus", "graph", "(", "target_graph", ")", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/pegasus.py#L9-L86
dwavesystems/dwave-system
dwave/embedding/drawing.py
draw_chimera_bqm
def draw_chimera_bqm(bqm, width=None, height=None): """Draws a Chimera Graph representation of a Binary Quadratic Model. If cell width and height not provided assumes square cell dimensions. Throws an error if drawing onto a Chimera graph of the given dimensions fails. Args: bqm (:obj:`dimod.B...
python
def draw_chimera_bqm(bqm, width=None, height=None): """Draws a Chimera Graph representation of a Binary Quadratic Model. If cell width and height not provided assumes square cell dimensions. Throws an error if drawing onto a Chimera graph of the given dimensions fails. Args: bqm (:obj:`dimod.B...
[ "def", "draw_chimera_bqm", "(", "bqm", ",", "width", "=", "None", ",", "height", "=", "None", ")", ":", "linear", "=", "bqm", ".", "linear", ".", "keys", "(", ")", "quadratic", "=", "bqm", ".", "quadratic", ".", "keys", "(", ")", "if", "width", "is...
Draws a Chimera Graph representation of a Binary Quadratic Model. If cell width and height not provided assumes square cell dimensions. Throws an error if drawing onto a Chimera graph of the given dimensions fails. Args: bqm (:obj:`dimod.BinaryQuadraticModel`): Should be equivalent to ...
[ "Draws", "a", "Chimera", "Graph", "representation", "of", "a", "Binary", "Quadratic", "Model", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/drawing.py#L23-L104
dwavesystems/dwave-system
dwave/embedding/transforms.py
embed_bqm
def embed_bqm(source_bqm, embedding, target_adjacency, chain_strength=1.0, smear_vartype=None): """Embed a binary quadratic model onto a target graph. Args: source_bqm (:obj:`.BinaryQuadraticModel`): Binary quadratic model to embed. embedding (dict): Mappi...
python
def embed_bqm(source_bqm, embedding, target_adjacency, chain_strength=1.0, smear_vartype=None): """Embed a binary quadratic model onto a target graph. Args: source_bqm (:obj:`.BinaryQuadraticModel`): Binary quadratic model to embed. embedding (dict): Mappi...
[ "def", "embed_bqm", "(", "source_bqm", ",", "embedding", ",", "target_adjacency", ",", "chain_strength", "=", "1.0", ",", "smear_vartype", "=", "None", ")", ":", "if", "smear_vartype", "is", "dimod", ".", "SPIN", "and", "source_bqm", ".", "vartype", "is", "d...
Embed a binary quadratic model onto a target graph. Args: source_bqm (:obj:`.BinaryQuadraticModel`): Binary quadratic model to embed. embedding (dict): Mapping from source graph to target graph as a dict of form {s: {t, ...}, ...}, where s is a source-model vari...
[ "Embed", "a", "binary", "quadratic", "model", "onto", "a", "target", "graph", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/transforms.py#L38-L168
dwavesystems/dwave-system
dwave/embedding/transforms.py
embed_ising
def embed_ising(source_h, source_J, embedding, target_adjacency, chain_strength=1.0): """Embed an Ising problem onto a target graph. Args: source_h (dict[variable, bias]/list[bias]): Linear biases of the Ising problem. If a list, the list's indices are used as variable labels. ...
python
def embed_ising(source_h, source_J, embedding, target_adjacency, chain_strength=1.0): """Embed an Ising problem onto a target graph. Args: source_h (dict[variable, bias]/list[bias]): Linear biases of the Ising problem. If a list, the list's indices are used as variable labels. ...
[ "def", "embed_ising", "(", "source_h", ",", "source_J", ",", "embedding", ",", "target_adjacency", ",", "chain_strength", "=", "1.0", ")", ":", "source_bqm", "=", "dimod", ".", "BinaryQuadraticModel", ".", "from_ising", "(", "source_h", ",", "source_J", ")", "...
Embed an Ising problem onto a target graph. Args: source_h (dict[variable, bias]/list[bias]): Linear biases of the Ising problem. If a list, the list's indices are used as variable labels. source_J (dict[(variable, variable), bias]): Quadratic biases of the Isin...
[ "Embed", "an", "Ising", "problem", "onto", "a", "target", "graph", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/transforms.py#L171-L250
dwavesystems/dwave-system
dwave/embedding/transforms.py
embed_qubo
def embed_qubo(source_Q, embedding, target_adjacency, chain_strength=1.0): """Embed a QUBO onto a target graph. Args: source_Q (dict[(variable, variable), bias]): Coefficients of a quadratic unconstrained binary optimization (QUBO) model. embedding (dict): Mapping from ...
python
def embed_qubo(source_Q, embedding, target_adjacency, chain_strength=1.0): """Embed a QUBO onto a target graph. Args: source_Q (dict[(variable, variable), bias]): Coefficients of a quadratic unconstrained binary optimization (QUBO) model. embedding (dict): Mapping from ...
[ "def", "embed_qubo", "(", "source_Q", ",", "embedding", ",", "target_adjacency", ",", "chain_strength", "=", "1.0", ")", ":", "source_bqm", "=", "dimod", ".", "BinaryQuadraticModel", ".", "from_qubo", "(", "source_Q", ")", "target_bqm", "=", "embed_bqm", "(", ...
Embed a QUBO onto a target graph. Args: source_Q (dict[(variable, variable), bias]): Coefficients of a quadratic unconstrained binary optimization (QUBO) model. embedding (dict): Mapping from source graph to target graph as a dict of form {s: {t, ...}, ...}, whe...
[ "Embed", "a", "QUBO", "onto", "a", "target", "graph", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/transforms.py#L253-L343
dwavesystems/dwave-system
dwave/embedding/transforms.py
unembed_sampleset
def unembed_sampleset(target_sampleset, embedding, source_bqm, chain_break_method=None, chain_break_fraction=False): """Unembed the samples set. Construct a sample set for the source binary quadratic model (BQM) by unembedding the given samples from the target BQM. Args: ...
python
def unembed_sampleset(target_sampleset, embedding, source_bqm, chain_break_method=None, chain_break_fraction=False): """Unembed the samples set. Construct a sample set for the source binary quadratic model (BQM) by unembedding the given samples from the target BQM. Args: ...
[ "def", "unembed_sampleset", "(", "target_sampleset", ",", "embedding", ",", "source_bqm", ",", "chain_break_method", "=", "None", ",", "chain_break_fraction", "=", "False", ")", ":", "if", "chain_break_method", "is", "None", ":", "chain_break_method", "=", "majority...
Unembed the samples set. Construct a sample set for the source binary quadratic model (BQM) by unembedding the given samples from the target BQM. Args: target_sampleset (:obj:`dimod.SampleSet`): SampleSet from the target BQM. embedding (dict): Mapping from source g...
[ "Unembed", "the", "samples", "set", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/transforms.py#L346-L441
dwavesystems/dwave-system
dwave/system/composites/embedding.py
_adjacency_to_edges
def _adjacency_to_edges(adjacency): """determine from an adjacency the list of edges if (u, v) in edges, then (v, u) should not be""" edges = set() for u in adjacency: for v in adjacency[u]: try: edge = (u, v) if u <= v else (v, u) except TypeError: ...
python
def _adjacency_to_edges(adjacency): """determine from an adjacency the list of edges if (u, v) in edges, then (v, u) should not be""" edges = set() for u in adjacency: for v in adjacency[u]: try: edge = (u, v) if u <= v else (v, u) except TypeError: ...
[ "def", "_adjacency_to_edges", "(", "adjacency", ")", ":", "edges", "=", "set", "(", ")", "for", "u", "in", "adjacency", ":", "for", "v", "in", "adjacency", "[", "u", "]", ":", "try", ":", "edge", "=", "(", "u", ",", "v", ")", "if", "u", "<=", "...
determine from an adjacency the list of edges if (u, v) in edges, then (v, u) should not be
[ "determine", "from", "an", "adjacency", "the", "list", "of", "edges", "if", "(", "u", "v", ")", "in", "edges", "then", "(", "v", "u", ")", "should", "not", "be" ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/embedding.py#L414-L429
dwavesystems/dwave-system
dwave/system/composites/embedding.py
_embed_state
def _embed_state(embedding, state): """Embed a single state/sample by spreading it's values over the chains in the embedding""" return {u: state[v] for v, chain in embedding.items() for u in chain}
python
def _embed_state(embedding, state): """Embed a single state/sample by spreading it's values over the chains in the embedding""" return {u: state[v] for v, chain in embedding.items() for u in chain}
[ "def", "_embed_state", "(", "embedding", ",", "state", ")", ":", "return", "{", "u", ":", "state", "[", "v", "]", "for", "v", ",", "chain", "in", "embedding", ".", "items", "(", ")", "for", "u", "in", "chain", "}" ]
Embed a single state/sample by spreading it's values over the chains in the embedding
[ "Embed", "a", "single", "state", "/", "sample", "by", "spreading", "it", "s", "values", "over", "the", "chains", "in", "the", "embedding" ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/embedding.py#L432-L434
dwavesystems/dwave-system
dwave/system/composites/embedding.py
EmbeddingComposite.parameters
def parameters(self): """dict[str, list]: Parameters in the form of a dict. For an instantiated composed sampler, keys are the keyword parameters accepted by the child sampler and parameters added by the composite such as those related to chains. Examples: This example view...
python
def parameters(self): """dict[str, list]: Parameters in the form of a dict. For an instantiated composed sampler, keys are the keyword parameters accepted by the child sampler and parameters added by the composite such as those related to chains. Examples: This example view...
[ "def", "parameters", "(", "self", ")", ":", "param", "=", "self", ".", "child", ".", "parameters", ".", "copy", "(", ")", "param", "[", "'chain_strength'", "]", "=", "[", "]", "param", "[", "'chain_break_fraction'", "]", "=", "[", "]", "return", "param...
dict[str, list]: Parameters in the form of a dict. For an instantiated composed sampler, keys are the keyword parameters accepted by the child sampler and parameters added by the composite such as those related to chains. Examples: This example views parameters of a composed sample...
[ "dict", "[", "str", "list", "]", ":", "Parameters", "in", "the", "form", "of", "a", "dict", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/embedding.py#L74-L104
dwavesystems/dwave-system
dwave/system/composites/embedding.py
EmbeddingComposite.sample
def sample(self, bqm, chain_strength=1.0, chain_break_fraction=True, **parameters): """Sample from the provided binary quadratic model. Also set parameters for handling a chain, the set of vertices in a target graph that represents a source-graph vertex; when a D-Wave system is the sampler, it ...
python
def sample(self, bqm, chain_strength=1.0, chain_break_fraction=True, **parameters): """Sample from the provided binary quadratic model. Also set parameters for handling a chain, the set of vertices in a target graph that represents a source-graph vertex; when a D-Wave system is the sampler, it ...
[ "def", "sample", "(", "self", ",", "bqm", ",", "chain_strength", "=", "1.0", ",", "chain_break_fraction", "=", "True", ",", "*", "*", "parameters", ")", ":", "# solve the problem on the child system", "child", "=", "self", ".", "child", "# apply the embedding to t...
Sample from the provided binary quadratic model. Also set parameters for handling a chain, the set of vertices in a target graph that represents a source-graph vertex; when a D-Wave system is the sampler, it is a set of qubits that together represent a variable of the binary quadratic model bei...
[ "Sample", "from", "the", "provided", "binary", "quadratic", "model", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/embedding.py#L135-L207
dwavesystems/dwave-system
dwave/system/composites/embedding.py
FixedEmbeddingComposite.sample
def sample(self, bqm, chain_strength=1.0, chain_break_fraction=True, **parameters): """Sample from the provided binary quadratic model. Also set parameters for handling a chain, the set of vertices in a target graph that represents a source-graph vertex; when a D-Wave system is the sampler, it ...
python
def sample(self, bqm, chain_strength=1.0, chain_break_fraction=True, **parameters): """Sample from the provided binary quadratic model. Also set parameters for handling a chain, the set of vertices in a target graph that represents a source-graph vertex; when a D-Wave system is the sampler, it ...
[ "def", "sample", "(", "self", ",", "bqm", ",", "chain_strength", "=", "1.0", ",", "chain_break_fraction", "=", "True", ",", "*", "*", "parameters", ")", ":", "# solve the problem on the child system", "child", "=", "self", ".", "child", "# apply the embedding to t...
Sample from the provided binary quadratic model. Also set parameters for handling a chain, the set of vertices in a target graph that represents a source-graph vertex; when a D-Wave system is the sampler, it is a set of qubits that together represent a variable of the binary quadratic model bei...
[ "Sample", "from", "the", "provided", "binary", "quadratic", "model", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/embedding.py#L346-L411
dwavesystems/dwave-system
dwave/system/composites/embedding.py
LazyFixedEmbeddingComposite.sample
def sample(self, bqm, chain_strength=1.0, chain_break_fraction=True, **parameters): """Sample the binary quadratic model. Note: At the initial sample(..) call, it will find a suitable embedding and initialize the remaining attributes before sampling the bqm. All following sample(..) calls will ...
python
def sample(self, bqm, chain_strength=1.0, chain_break_fraction=True, **parameters): """Sample the binary quadratic model. Note: At the initial sample(..) call, it will find a suitable embedding and initialize the remaining attributes before sampling the bqm. All following sample(..) calls will ...
[ "def", "sample", "(", "self", ",", "bqm", ",", "chain_strength", "=", "1.0", ",", "chain_break_fraction", "=", "True", ",", "*", "*", "parameters", ")", ":", "if", "self", ".", "embedding", "is", "None", ":", "# Find embedding", "child", "=", "self", "."...
Sample the binary quadratic model. Note: At the initial sample(..) call, it will find a suitable embedding and initialize the remaining attributes before sampling the bqm. All following sample(..) calls will reuse that initial embedding. Args: bqm (:obj:`dimod.BinaryQuadraticModel`...
[ "Sample", "the", "binary", "quadratic", "model", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/embedding.py#L461-L495
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
_accumulate_random
def _accumulate_random(count, found, oldthing, newthing): """This performs on-line random selection. We have a stream of objects o_1,c_1; o_2,c_2; ... where there are c_i equivalent objects like o_1. We'd like to pick a random object o uniformly at random from the list [o_1]*c_1 + [...
python
def _accumulate_random(count, found, oldthing, newthing): """This performs on-line random selection. We have a stream of objects o_1,c_1; o_2,c_2; ... where there are c_i equivalent objects like o_1. We'd like to pick a random object o uniformly at random from the list [o_1]*c_1 + [...
[ "def", "_accumulate_random", "(", "count", ",", "found", ",", "oldthing", ",", "newthing", ")", ":", "if", "randint", "(", "1", ",", "count", "+", "found", ")", "<=", "found", ":", "return", "count", "+", "found", ",", "newthing", "else", ":", "return"...
This performs on-line random selection. We have a stream of objects o_1,c_1; o_2,c_2; ... where there are c_i equivalent objects like o_1. We'd like to pick a random object o uniformly at random from the list [o_1]*c_1 + [o_2]*c_2 + ... (actually, this algorithm allows arbitrary po...
[ "This", "performs", "on", "-", "line", "random", "selection", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L60-L108
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
_bulk_to_linear
def _bulk_to_linear(M, N, L, qubits): "Converts a list of chimera coordinates to linear indices." return [2 * L * N * x + 2 * L * y + L * u + k for x, y, u, k in qubits]
python
def _bulk_to_linear(M, N, L, qubits): "Converts a list of chimera coordinates to linear indices." return [2 * L * N * x + 2 * L * y + L * u + k for x, y, u, k in qubits]
[ "def", "_bulk_to_linear", "(", "M", ",", "N", ",", "L", ",", "qubits", ")", ":", "return", "[", "2", "*", "L", "*", "N", "*", "x", "+", "2", "*", "L", "*", "y", "+", "L", "*", "u", "+", "k", "for", "x", ",", "y", ",", "u", ",", "k", "...
Converts a list of chimera coordinates to linear indices.
[ "Converts", "a", "list", "of", "chimera", "coordinates", "to", "linear", "indices", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1161-L1163
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
_to_linear
def _to_linear(M, N, L, q): "Converts a qubit in chimera coordinates to its linear index." (x, y, u, k) = q return 2 * L * N * x + 2 * L * y + L * u + k
python
def _to_linear(M, N, L, q): "Converts a qubit in chimera coordinates to its linear index." (x, y, u, k) = q return 2 * L * N * x + 2 * L * y + L * u + k
[ "def", "_to_linear", "(", "M", ",", "N", ",", "L", ",", "q", ")", ":", "(", "x", ",", "y", ",", "u", ",", "k", ")", "=", "q", "return", "2", "*", "L", "*", "N", "*", "x", "+", "2", "*", "L", "*", "y", "+", "L", "*", "u", "+", "k" ]
Converts a qubit in chimera coordinates to its linear index.
[ "Converts", "a", "qubit", "in", "chimera", "coordinates", "to", "its", "linear", "index", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1166-L1169
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
_bulk_to_chimera
def _bulk_to_chimera(M, N, L, qubits): "Converts a list of linear indices to chimera coordinates." return [(q // N // L // 2, (q // L // 2) % N, (q // L) % 2, q % L) for q in qubits]
python
def _bulk_to_chimera(M, N, L, qubits): "Converts a list of linear indices to chimera coordinates." return [(q // N // L // 2, (q // L // 2) % N, (q // L) % 2, q % L) for q in qubits]
[ "def", "_bulk_to_chimera", "(", "M", ",", "N", ",", "L", ",", "qubits", ")", ":", "return", "[", "(", "q", "//", "N", "//", "L", "//", "2", ",", "(", "q", "//", "L", "//", "2", ")", "%", "N", ",", "(", "q", "//", "L", ")", "%", "2", ","...
Converts a list of linear indices to chimera coordinates.
[ "Converts", "a", "list", "of", "linear", "indices", "to", "chimera", "coordinates", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1172-L1174
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
_to_chimera
def _to_chimera(M, N, L, q): "Converts a qubit's linear index to chimera coordinates." return (q // N // L // 2, (q // L // 2) % N, (q // L) % 2, q % L)
python
def _to_chimera(M, N, L, q): "Converts a qubit's linear index to chimera coordinates." return (q // N // L // 2, (q // L // 2) % N, (q // L) % 2, q % L)
[ "def", "_to_chimera", "(", "M", ",", "N", ",", "L", ",", "q", ")", ":", "return", "(", "q", "//", "N", "//", "L", "//", "2", ",", "(", "q", "//", "L", "//", "2", ")", "%", "N", ",", "(", "q", "//", "L", ")", "%", "2", ",", "q", "%", ...
Converts a qubit's linear index to chimera coordinates.
[ "Converts", "a", "qubit", "s", "linear", "index", "to", "chimera", "coordinates", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1177-L1179
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
_chimera_neighbors
def _chimera_neighbors(M, N, L, q): "Returns a list of neighbors of (x,y,u,k) in a perfect :math:`C_{M,N,L}`" (x, y, u, k) = q n = [(x, y, 1 - u, l) for l in range(L)] if u == 0: if x: n.append((x - 1, y, u, k)) if x < M - 1: n.append((x + 1, y, u, k)) else: ...
python
def _chimera_neighbors(M, N, L, q): "Returns a list of neighbors of (x,y,u,k) in a perfect :math:`C_{M,N,L}`" (x, y, u, k) = q n = [(x, y, 1 - u, l) for l in range(L)] if u == 0: if x: n.append((x - 1, y, u, k)) if x < M - 1: n.append((x + 1, y, u, k)) else: ...
[ "def", "_chimera_neighbors", "(", "M", ",", "N", ",", "L", ",", "q", ")", ":", "(", "x", ",", "y", ",", "u", ",", "k", ")", "=", "q", "n", "=", "[", "(", "x", ",", "y", ",", "1", "-", "u", ",", "l", ")", "for", "l", "in", "range", "("...
Returns a list of neighbors of (x,y,u,k) in a perfect :math:`C_{M,N,L}`
[ "Returns", "a", "list", "of", "neighbors", "of", "(", "x", "y", "u", "k", ")", "in", "a", "perfect", ":", "math", ":", "C_", "{", "M", "N", "L", "}" ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1182-L1196
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
random_processor
def random_processor(M, N, L, qubit_yield, num_evil=0): """A utility function that generates a random :math:`C_{M,N,L}` missing some percentage of its qubits. INPUTS: M,N,L: the chimera parameters qubit_yield: ratio (0 <= qubit_yield <= 1) of #{qubits}/(2*M*N*L) num_evil: number of ...
python
def random_processor(M, N, L, qubit_yield, num_evil=0): """A utility function that generates a random :math:`C_{M,N,L}` missing some percentage of its qubits. INPUTS: M,N,L: the chimera parameters qubit_yield: ratio (0 <= qubit_yield <= 1) of #{qubits}/(2*M*N*L) num_evil: number of ...
[ "def", "random_processor", "(", "M", ",", "N", ",", "L", ",", "qubit_yield", ",", "num_evil", "=", "0", ")", ":", "# replacement for lambda in edge filter below that works with bot h", "def", "edge_filter", "(", "pq", ")", ":", "# we have to unpack the (p,q) edge", "p...
A utility function that generates a random :math:`C_{M,N,L}` missing some percentage of its qubits. INPUTS: M,N,L: the chimera parameters qubit_yield: ratio (0 <= qubit_yield <= 1) of #{qubits}/(2*M*N*L) num_evil: number of broken in-cell couplers between working qubits OUTPUT: ...
[ "A", "utility", "function", "that", "generates", "a", "random", ":", "math", ":", "C_", "{", "M", "N", "L", "}", "missing", "some", "percentage", "of", "its", "qubits", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1199-L1226
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.vline_score
def vline_score(self, x, ymin, ymax): """Returns the number of unbroken paths of qubits >>> [(x,y,1,k) for y in range(ymin,ymax+1)] for :math:`k = 0,1,\cdots,L-1`. This is precomputed for speed. """ return self._vline_score[x, ymin, ymax]
python
def vline_score(self, x, ymin, ymax): """Returns the number of unbroken paths of qubits >>> [(x,y,1,k) for y in range(ymin,ymax+1)] for :math:`k = 0,1,\cdots,L-1`. This is precomputed for speed. """ return self._vline_score[x, ymin, ymax]
[ "def", "vline_score", "(", "self", ",", "x", ",", "ymin", ",", "ymax", ")", ":", "return", "self", ".", "_vline_score", "[", "x", ",", "ymin", ",", "ymax", "]" ]
Returns the number of unbroken paths of qubits >>> [(x,y,1,k) for y in range(ymin,ymax+1)] for :math:`k = 0,1,\cdots,L-1`. This is precomputed for speed.
[ "Returns", "the", "number", "of", "unbroken", "paths", "of", "qubits" ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L170-L177
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.hline_score
def hline_score(self, y, xmin, xmax): """Returns the number of unbroken paths of qubits >>> [(x,y,0,k) for x in range(xmin,xmax+1)] for :math:`k = 0,1,\cdots,L-1`. This is precomputed for speed. """ return self._hline_score[y, xmin, xmax]
python
def hline_score(self, y, xmin, xmax): """Returns the number of unbroken paths of qubits >>> [(x,y,0,k) for x in range(xmin,xmax+1)] for :math:`k = 0,1,\cdots,L-1`. This is precomputed for speed. """ return self._hline_score[y, xmin, xmax]
[ "def", "hline_score", "(", "self", ",", "y", ",", "xmin", ",", "xmax", ")", ":", "return", "self", ".", "_hline_score", "[", "y", ",", "xmin", ",", "xmax", "]" ]
Returns the number of unbroken paths of qubits >>> [(x,y,0,k) for x in range(xmin,xmax+1)] for :math:`k = 0,1,\cdots,L-1`. This is precomputed for speed.
[ "Returns", "the", "number", "of", "unbroken", "paths", "of", "qubits" ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L179-L186
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor._compute_vline_scores
def _compute_vline_scores(self): """Does the hard work to prepare ``vline_score``. """ M, N, L = self.M, self.N, self.L vline_score = {} for x in range(M): laststart = [0 if (x, 0, 1, k) in self else None for k in range(L)] for y in range(N): ...
python
def _compute_vline_scores(self): """Does the hard work to prepare ``vline_score``. """ M, N, L = self.M, self.N, self.L vline_score = {} for x in range(M): laststart = [0 if (x, 0, 1, k) in self else None for k in range(L)] for y in range(N): ...
[ "def", "_compute_vline_scores", "(", "self", ")", ":", "M", ",", "N", ",", "L", "=", "self", ".", "M", ",", "self", ".", "N", ",", "self", ".", "L", "vline_score", "=", "{", "}", "for", "x", "in", "range", "(", "M", ")", ":", "laststart", "=", ...
Does the hard work to prepare ``vline_score``.
[ "Does", "the", "hard", "work", "to", "prepare", "vline_score", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L188-L210
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor._compute_hline_scores
def _compute_hline_scores(self): """Does the hard work to prepare ``hline_score``. """ M, N, L = self.M, self.N, self.L hline_score = {} for y in range(N): laststart = [0 if (0, y, 0, k) in self else None for k in range(L)] for x in range(M): ...
python
def _compute_hline_scores(self): """Does the hard work to prepare ``hline_score``. """ M, N, L = self.M, self.N, self.L hline_score = {} for y in range(N): laststart = [0 if (0, y, 0, k) in self else None for k in range(L)] for x in range(M): ...
[ "def", "_compute_hline_scores", "(", "self", ")", ":", "M", ",", "N", ",", "L", "=", "self", ".", "M", ",", "self", ".", "N", ",", "self", ".", "L", "hline_score", "=", "{", "}", "for", "y", "in", "range", "(", "N", ")", ":", "laststart", "=", ...
Does the hard work to prepare ``hline_score``.
[ "Does", "the", "hard", "work", "to", "prepare", "hline_score", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L212-L234
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor._compute_biclique_sizes
def _compute_biclique_sizes(self, recompute=False): """Calls ``self.biclique_size(...)`` for every rectangle contained in this processor, to fill the biclique size cache. INPUTS: recompute: if ``True``, then we dump the existing cache and compute all biclique sizes f...
python
def _compute_biclique_sizes(self, recompute=False): """Calls ``self.biclique_size(...)`` for every rectangle contained in this processor, to fill the biclique size cache. INPUTS: recompute: if ``True``, then we dump the existing cache and compute all biclique sizes f...
[ "def", "_compute_biclique_sizes", "(", "self", ",", "recompute", "=", "False", ")", ":", "if", "recompute", "or", "not", "self", ".", "_biclique_size_computed", ":", "self", ".", "_biclique_size", "=", "{", "}", "self", ".", "_biclique_size_to_length", "=", "d...
Calls ``self.biclique_size(...)`` for every rectangle contained in this processor, to fill the biclique size cache. INPUTS: recompute: if ``True``, then we dump the existing cache and compute all biclique sizes from scratch. (default: ``False``)
[ "Calls", "self", ".", "biclique_size", "(", "...", ")", "for", "every", "rectangle", "contained", "in", "this", "processor", "to", "fill", "the", "biclique", "size", "cache", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L236-L262
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.biclique_size
def biclique_size(self, xmin, xmax, ymin, ymax): """Returns the size parameters ``(m,n)`` of the complete bipartite graph :math:`K_{m,n}` comprised of ``m`` unbroken chains of horizontally-aligned qubits and ``n`` unbroken chains of vertically-aligned qubits (known as line bundles) ...
python
def biclique_size(self, xmin, xmax, ymin, ymax): """Returns the size parameters ``(m,n)`` of the complete bipartite graph :math:`K_{m,n}` comprised of ``m`` unbroken chains of horizontally-aligned qubits and ``n`` unbroken chains of vertically-aligned qubits (known as line bundles) ...
[ "def", "biclique_size", "(", "self", ",", "xmin", ",", "xmax", ",", "ymin", ",", "ymax", ")", ":", "try", ":", "return", "self", ".", "_biclique_size", "[", "xmin", ",", "xmax", ",", "ymin", ",", "ymax", "]", "except", "KeyError", ":", "hscore", "=",...
Returns the size parameters ``(m,n)`` of the complete bipartite graph :math:`K_{m,n}` comprised of ``m`` unbroken chains of horizontally-aligned qubits and ``n`` unbroken chains of vertically-aligned qubits (known as line bundles) INPUTS: xmin,xmax,ymin,ymax: integers defini...
[ "Returns", "the", "size", "parameters", "(", "m", "n", ")", "of", "the", "complete", "bipartite", "graph", ":", "math", ":", "K_", "{", "m", "n", "}", "comprised", "of", "m", "unbroken", "chains", "of", "horizontally", "-", "aligned", "qubits", "and", ...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L264-L289
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.biclique
def biclique(self, xmin, xmax, ymin, ymax): """Compute a maximum-sized complete bipartite graph contained in the rectangle defined by ``xmin, xmax, ymin, ymax`` where each chain of qubits is either a vertical line or a horizontal line. INPUTS: xmin,xmax,ymin,ymax: integers d...
python
def biclique(self, xmin, xmax, ymin, ymax): """Compute a maximum-sized complete bipartite graph contained in the rectangle defined by ``xmin, xmax, ymin, ymax`` where each chain of qubits is either a vertical line or a horizontal line. INPUTS: xmin,xmax,ymin,ymax: integers d...
[ "def", "biclique", "(", "self", ",", "xmin", ",", "xmax", ",", "ymin", ",", "ymax", ")", ":", "Aside", "=", "sum", "(", "(", "self", ".", "maximum_hline_bundle", "(", "y", ",", "xmin", ",", "xmax", ")", "for", "y", "in", "range", "(", "ymin", ","...
Compute a maximum-sized complete bipartite graph contained in the rectangle defined by ``xmin, xmax, ymin, ymax`` where each chain of qubits is either a vertical line or a horizontal line. INPUTS: xmin,xmax,ymin,ymax: integers defining the bounds of a rectangle where we ...
[ "Compute", "a", "maximum", "-", "sized", "complete", "bipartite", "graph", "contained", "in", "the", "rectangle", "defined", "by", "xmin", "xmax", "ymin", "ymax", "where", "each", "chain", "of", "qubits", "is", "either", "a", "vertical", "line", "or", "a", ...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L291-L319
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor._contains_line
def _contains_line(self, line): """Test if a chain of qubits is completely contained in ``self``. In particular, test if all qubits are present and the couplers connecting those qubits are also connected. NOTE: this function assumes that ``line`` is a list or tuple of qubits wh...
python
def _contains_line(self, line): """Test if a chain of qubits is completely contained in ``self``. In particular, test if all qubits are present and the couplers connecting those qubits are also connected. NOTE: this function assumes that ``line`` is a list or tuple of qubits wh...
[ "def", "_contains_line", "(", "self", ",", "line", ")", ":", "return", "all", "(", "v", "in", "self", "for", "v", "in", "line", ")", "and", "all", "(", "u", "in", "self", "[", "v", "]", "for", "u", ",", "v", "in", "zip", "(", "line", ",", "li...
Test if a chain of qubits is completely contained in ``self``. In particular, test if all qubits are present and the couplers connecting those qubits are also connected. NOTE: this function assumes that ``line`` is a list or tuple of qubits which satisfies the precondition that ``(line...
[ "Test", "if", "a", "chain", "of", "qubits", "is", "completely", "contained", "in", "self", ".", "In", "particular", "test", "if", "all", "qubits", "are", "present", "and", "the", "couplers", "connecting", "those", "qubits", "are", "also", "connected", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L322-L337
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.maximum_vline_bundle
def maximum_vline_bundle(self, x0, y0, y1): """Compute a maximum set of vertical lines in the unit cells ``(x0,y)`` for :math:`y0 \leq y \leq y1`. INPUTS: y0,x0,x1: int OUTPUT: list of lists of qubits """ y_range = range(y1, y0 - 1, -1) if y0 < ...
python
def maximum_vline_bundle(self, x0, y0, y1): """Compute a maximum set of vertical lines in the unit cells ``(x0,y)`` for :math:`y0 \leq y \leq y1`. INPUTS: y0,x0,x1: int OUTPUT: list of lists of qubits """ y_range = range(y1, y0 - 1, -1) if y0 < ...
[ "def", "maximum_vline_bundle", "(", "self", ",", "x0", ",", "y0", ",", "y1", ")", ":", "y_range", "=", "range", "(", "y1", ",", "y0", "-", "1", ",", "-", "1", ")", "if", "y0", "<", "y1", "else", "range", "(", "y1", ",", "y0", "+", "1", ")", ...
Compute a maximum set of vertical lines in the unit cells ``(x0,y)`` for :math:`y0 \leq y \leq y1`. INPUTS: y0,x0,x1: int OUTPUT: list of lists of qubits
[ "Compute", "a", "maximum", "set", "of", "vertical", "lines", "in", "the", "unit", "cells", "(", "x0", "y", ")", "for", ":", "math", ":", "y0", "\\", "leq", "y", "\\", "leq", "y1", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L339-L352
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.maximum_hline_bundle
def maximum_hline_bundle(self, y0, x0, x1): """Compute a maximum set of horizontal lines in the unit cells ``(x,y0)`` for :math:`x0 \leq x \leq x1`. INPUTS: y0,x0,x1: int OUTPUT: list of lists of qubits """ x_range = range(x0, x1 + 1) if x0 < x1 ...
python
def maximum_hline_bundle(self, y0, x0, x1): """Compute a maximum set of horizontal lines in the unit cells ``(x,y0)`` for :math:`x0 \leq x \leq x1`. INPUTS: y0,x0,x1: int OUTPUT: list of lists of qubits """ x_range = range(x0, x1 + 1) if x0 < x1 ...
[ "def", "maximum_hline_bundle", "(", "self", ",", "y0", ",", "x0", ",", "x1", ")", ":", "x_range", "=", "range", "(", "x0", ",", "x1", "+", "1", ")", "if", "x0", "<", "x1", "else", "range", "(", "x0", ",", "x1", "-", "1", ",", "-", "1", ")", ...
Compute a maximum set of horizontal lines in the unit cells ``(x,y0)`` for :math:`x0 \leq x \leq x1`. INPUTS: y0,x0,x1: int OUTPUT: list of lists of qubits
[ "Compute", "a", "maximum", "set", "of", "horizontal", "lines", "in", "the", "unit", "cells", "(", "x", "y0", ")", "for", ":", "math", ":", "x0", "\\", "leq", "x", "\\", "leq", "x1", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L354-L366
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.maximum_ell_bundle
def maximum_ell_bundle(self, ell): """Return a maximum ell bundle in the rectangle bounded by :math:`\{x0,x1\} \\times \{y0,y1\}` with vertical component :math:`(x0,y0) ... (x0,y1) = {x0} \\times \{y0,...,y1\}` and horizontal component :math:`(x0,y0) ... ...
python
def maximum_ell_bundle(self, ell): """Return a maximum ell bundle in the rectangle bounded by :math:`\{x0,x1\} \\times \{y0,y1\}` with vertical component :math:`(x0,y0) ... (x0,y1) = {x0} \\times \{y0,...,y1\}` and horizontal component :math:`(x0,y0) ... ...
[ "def", "maximum_ell_bundle", "(", "self", ",", "ell", ")", ":", "(", "x0", ",", "x1", ",", "y0", ",", "y1", ")", "=", "ell", "hlines", "=", "self", ".", "maximum_hline_bundle", "(", "y0", ",", "x0", ",", "x1", ")", "vlines", "=", "self", ".", "ma...
Return a maximum ell bundle in the rectangle bounded by :math:`\{x0,x1\} \\times \{y0,y1\}` with vertical component :math:`(x0,y0) ... (x0,y1) = {x0} \\times \{y0,...,y1\}` and horizontal component :math:`(x0,y0) ... (x1,y0) = \{x0,...,x1\} \\times \{y0\}`. ...
[ "Return", "a", "maximum", "ell", "bundle", "in", "the", "rectangle", "bounded", "by" ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L368-L409
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor._combine_clique_scores
def _combine_clique_scores(self, rscore, hbar, vbar): """Computes the score of a partial native clique embedding given the score attained by the already-placed ells, together with the ell block defined by ``hbar = (y0,xmin,xmax)``, and ``vbar = (x0,ymin,ymax)``. In the plain :class:`ed...
python
def _combine_clique_scores(self, rscore, hbar, vbar): """Computes the score of a partial native clique embedding given the score attained by the already-placed ells, together with the ell block defined by ``hbar = (y0,xmin,xmax)``, and ``vbar = (x0,ymin,ymax)``. In the plain :class:`ed...
[ "def", "_combine_clique_scores", "(", "self", ",", "rscore", ",", "hbar", ",", "vbar", ")", ":", "(", "y0", ",", "xmin", ",", "xmax", ")", "=", "hbar", "(", "x0", ",", "ymin", ",", "ymax", ")", "=", "vbar", "if", "rscore", "is", "None", ":", "rsc...
Computes the score of a partial native clique embedding given the score attained by the already-placed ells, together with the ell block defined by ``hbar = (y0,xmin,xmax)``, and ``vbar = (x0,ymin,ymax)``. In the plain :class:`eden_processor` class, this is simply the number of ells co...
[ "Computes", "the", "score", "of", "a", "partial", "native", "clique", "embedding", "given", "the", "score", "attained", "by", "the", "already", "-", "placed", "ells", "together", "with", "the", "ell", "block", "defined", "by", "hbar", "=", "(", "y0", "xmin...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L411-L429
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.maxCliqueWithRectangle
def maxCliqueWithRectangle(self, R, maxCWR): """This does the dirty work for :func:`nativeCliqueEmbed`. Not meant to be understood or called on its own. Guaranteed to maintain the inductive hypothesis that ``maxCWR`` is optimal. We put in the tiniest amount of effort to return a unifo...
python
def maxCliqueWithRectangle(self, R, maxCWR): """This does the dirty work for :func:`nativeCliqueEmbed`. Not meant to be understood or called on its own. Guaranteed to maintain the inductive hypothesis that ``maxCWR`` is optimal. We put in the tiniest amount of effort to return a unifo...
[ "def", "maxCliqueWithRectangle", "(", "self", ",", "R", ",", "maxCWR", ")", ":", "(", "xmin", ",", "xmax", ",", "ymin", ",", "ymax", ")", "=", "R", "best", "=", "nothing", "=", "0", ",", "None", ",", "None", ",", "1", "bestscore", "=", "None", "c...
This does the dirty work for :func:`nativeCliqueEmbed`. Not meant to be understood or called on its own. Guaranteed to maintain the inductive hypothesis that ``maxCWR`` is optimal. We put in the tiniest amount of effort to return a uniform random choice of a maximum-sized native cliqu...
[ "This", "does", "the", "dirty", "work", "for", ":", "func", ":", "nativeCliqueEmbed", ".", "Not", "meant", "to", "be", "understood", "or", "called", "on", "its", "own", ".", "Guaranteed", "to", "maintain", "the", "inductive", "hypothesis", "that", "maxCWR", ...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L431-L494
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.nativeCliqueEmbed
def nativeCliqueEmbed(self, width): """Compute a maximum-sized native clique embedding in an induced subgraph of chimera with all chainlengths ``width+1``. INPUTS: width: width of the squares to search, also `chainlength`-1 OUTPUT: score: the score for the retur...
python
def nativeCliqueEmbed(self, width): """Compute a maximum-sized native clique embedding in an induced subgraph of chimera with all chainlengths ``width+1``. INPUTS: width: width of the squares to search, also `chainlength`-1 OUTPUT: score: the score for the retur...
[ "def", "nativeCliqueEmbed", "(", "self", ",", "width", ")", ":", "maxCWR", "=", "{", "}", "M", ",", "N", "=", "self", ".", "M", ",", "self", ".", "N", "maxscore", "=", "None", "count", "=", "0", "key", "=", "None", "for", "w", "in", "range", "(...
Compute a maximum-sized native clique embedding in an induced subgraph of chimera with all chainlengths ``width+1``. INPUTS: width: width of the squares to search, also `chainlength`-1 OUTPUT: score: the score for the returned clique (just ``len(clique)`` in...
[ "Compute", "a", "maximum", "-", "sized", "native", "clique", "embedding", "in", "an", "induced", "subgraph", "of", "chimera", "with", "all", "chainlengths", "width", "+", "1", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L496-L544
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.largestNativeClique
def largestNativeClique(self, max_chain_length=None): """Returns the largest native clique embedding we can find on the processor, with the shortest chainlength possible (for that clique size). OUTPUT: score: the score for the returned clique (just ``len(clique)`` ...
python
def largestNativeClique(self, max_chain_length=None): """Returns the largest native clique embedding we can find on the processor, with the shortest chainlength possible (for that clique size). OUTPUT: score: the score for the returned clique (just ``len(clique)`` ...
[ "def", "largestNativeClique", "(", "self", ",", "max_chain_length", "=", "None", ")", ":", "bigclique", "=", "[", "]", "bestscore", "=", "None", "if", "max_chain_length", "is", "None", ":", "wmax", "=", "min", "(", "self", ".", "M", ",", "self", ".", "...
Returns the largest native clique embedding we can find on the processor, with the shortest chainlength possible (for that clique size). OUTPUT: score: the score for the returned clique (just ``len(clique)`` in the class :class:`eden_processor`; may differ in subclasses)...
[ "Returns", "the", "largest", "native", "clique", "embedding", "we", "can", "find", "on", "the", "processor", "with", "the", "shortest", "chainlength", "possible", "(", "for", "that", "clique", "size", ")", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L546-L580
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.largestNativeBiClique
def largestNativeBiClique(self, chain_imbalance=0, max_chain_length=None): """Returns a native embedding for the complete bipartite graph :math:`K_{n,m}` for :math:`n \leq m`; where :math:`n` is as large as possible and :math:`m` is as large as possible subject to :math:`n`. The native embeddin...
python
def largestNativeBiClique(self, chain_imbalance=0, max_chain_length=None): """Returns a native embedding for the complete bipartite graph :math:`K_{n,m}` for :math:`n \leq m`; where :math:`n` is as large as possible and :math:`m` is as large as possible subject to :math:`n`. The native embeddin...
[ "def", "largestNativeBiClique", "(", "self", ",", "chain_imbalance", "=", "0", ",", "max_chain_length", "=", "None", ")", ":", "self", ".", "_compute_biclique_sizes", "(", ")", "Len2Siz", "=", "self", ".", "_biclique_length_to_size", "Siz2Len", "=", "self", ".",...
Returns a native embedding for the complete bipartite graph :math:`K_{n,m}` for :math:`n \leq m`; where :math:`n` is as large as possible and :math:`m` is as large as possible subject to :math:`n`. The native embedding of a complete bipartite graph is a set of horizontally-aligned qubits connec...
[ "Returns", "a", "native", "embedding", "for", "the", "complete", "bipartite", "graph", ":", "math", ":", "K_", "{", "n", "m", "}", "for", ":", "math", ":", "n", "\\", "leq", "m", ";", "where", ":", "math", ":", "n", "is", "as", "large", "as", "po...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L608-L672
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._compute_all_deletions
def _compute_all_deletions(self): """Returns all minimal edge covers of the set of evil edges. """ minimum_evil = [] for disabled_qubits in map(set, product(*self._evil)): newmin = [] for s in minimum_evil: if s < disabled_qubits: ...
python
def _compute_all_deletions(self): """Returns all minimal edge covers of the set of evil edges. """ minimum_evil = [] for disabled_qubits in map(set, product(*self._evil)): newmin = [] for s in minimum_evil: if s < disabled_qubits: ...
[ "def", "_compute_all_deletions", "(", "self", ")", ":", "minimum_evil", "=", "[", "]", "for", "disabled_qubits", "in", "map", "(", "set", ",", "product", "(", "*", "self", ".", "_evil", ")", ")", ":", "newmin", "=", "[", "]", "for", "s", "in", "minim...
Returns all minimal edge covers of the set of evil edges.
[ "Returns", "all", "minimal", "edge", "covers", "of", "the", "set", "of", "evil", "edges", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L810-L824
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._subprocessor
def _subprocessor(self, disabled_qubits): """Create a subprocessor by deleting a set of qubits. We assume this removes all evil edges, and return an :class:`eden_processor` instance. """ edgelist = [(p, q) for p, q in self._edgelist if p not in disabled_qubit...
python
def _subprocessor(self, disabled_qubits): """Create a subprocessor by deleting a set of qubits. We assume this removes all evil edges, and return an :class:`eden_processor` instance. """ edgelist = [(p, q) for p, q in self._edgelist if p not in disabled_qubit...
[ "def", "_subprocessor", "(", "self", ",", "disabled_qubits", ")", ":", "edgelist", "=", "[", "(", "p", ",", "q", ")", "for", "p", ",", "q", "in", "self", ".", "_edgelist", "if", "p", "not", "in", "disabled_qubits", "and", "q", "not", "in", "disabled_...
Create a subprocessor by deleting a set of qubits. We assume this removes all evil edges, and return an :class:`eden_processor` instance.
[ "Create", "a", "subprocessor", "by", "deleting", "a", "set", "of", "qubits", ".", "We", "assume", "this", "removes", "all", "evil", "edges", "and", "return", "an", ":", "class", ":", "eden_processor", "instance", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L826-L834
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._compute_deletions
def _compute_deletions(self): """If there are fewer than self._proc_limit possible deletion sets, compute all subprocessors obtained by deleting a minimal subset of qubits. """ M, N, L, edgelist = self.M, self.N, self.L, self._edgelist if 2**len(self._evil) <= self._proc_...
python
def _compute_deletions(self): """If there are fewer than self._proc_limit possible deletion sets, compute all subprocessors obtained by deleting a minimal subset of qubits. """ M, N, L, edgelist = self.M, self.N, self.L, self._edgelist if 2**len(self._evil) <= self._proc_...
[ "def", "_compute_deletions", "(", "self", ")", ":", "M", ",", "N", ",", "L", ",", "edgelist", "=", "self", ".", "M", ",", "self", ".", "N", ",", "self", ".", "L", ",", "self", ".", "_edgelist", "if", "2", "**", "len", "(", "self", ".", "_evil",...
If there are fewer than self._proc_limit possible deletion sets, compute all subprocessors obtained by deleting a minimal subset of qubits.
[ "If", "there", "are", "fewer", "than", "self", ".", "_proc_limit", "possible", "deletion", "sets", "compute", "all", "subprocessors", "obtained", "by", "deleting", "a", "minimal", "subset", "of", "qubits", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L836-L846
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._random_subprocessor
def _random_subprocessor(self): """Creates a random subprocessor where there is a coupler between every pair of working qubits on opposite sides of the same cell. This is guaranteed to be minimal in that adding a qubit back in will reintroduce a bad coupler, but not to have minimum size....
python
def _random_subprocessor(self): """Creates a random subprocessor where there is a coupler between every pair of working qubits on opposite sides of the same cell. This is guaranteed to be minimal in that adding a qubit back in will reintroduce a bad coupler, but not to have minimum size....
[ "def", "_random_subprocessor", "(", "self", ")", ":", "deletion", "=", "set", "(", ")", "for", "e", "in", "self", ".", "_evil", ":", "if", "e", "[", "0", "]", "in", "deletion", "or", "e", "[", "1", "]", "in", "deletion", ":", "continue", "deletion"...
Creates a random subprocessor where there is a coupler between every pair of working qubits on opposite sides of the same cell. This is guaranteed to be minimal in that adding a qubit back in will reintroduce a bad coupler, but not to have minimum size. OUTPUT: an :class:`ed...
[ "Creates", "a", "random", "subprocessor", "where", "there", "is", "a", "coupler", "between", "every", "pair", "of", "working", "qubits", "on", "opposite", "sides", "of", "the", "same", "cell", ".", "This", "is", "guaranteed", "to", "be", "minimal", "in", "...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L848-L862
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._random_subprocessors
def _random_subprocessors(self): """Produces an iterator of subprocessors. If there are fewer than self._proc_limit subprocessors to consider (by knocking out a minimal subset of working qubits incident to broken couplers), we work exhaustively. Otherwise, we generate a random set of ...
python
def _random_subprocessors(self): """Produces an iterator of subprocessors. If there are fewer than self._proc_limit subprocessors to consider (by knocking out a minimal subset of working qubits incident to broken couplers), we work exhaustively. Otherwise, we generate a random set of ...
[ "def", "_random_subprocessors", "(", "self", ")", ":", "if", "self", ".", "_processors", "is", "not", "None", ":", "return", "(", "p", "for", "p", "in", "self", ".", "_processors", ")", "elif", "2", "**", "len", "(", "self", ".", "_evil", ")", "<=", ...
Produces an iterator of subprocessors. If there are fewer than self._proc_limit subprocessors to consider (by knocking out a minimal subset of working qubits incident to broken couplers), we work exhaustively. Otherwise, we generate a random set of ``self._proc_limit`` subprocessors. ...
[ "Produces", "an", "iterator", "of", "subprocessors", ".", "If", "there", "are", "fewer", "than", "self", ".", "_proc_limit", "subprocessors", "to", "consider", "(", "by", "knocking", "out", "a", "minimal", "subset", "of", "working", "qubits", "incident", "to",...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L864-L887
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._map_to_processors
def _map_to_processors(self, f, objective): """Map a function to a list of processors, and return the output that best satisfies a transitive objective function. The list of processors will differ according to the number of evil qubits and :func:`_proc_limit`, see details in :func:`self...
python
def _map_to_processors(self, f, objective): """Map a function to a list of processors, and return the output that best satisfies a transitive objective function. The list of processors will differ according to the number of evil qubits and :func:`_proc_limit`, see details in :func:`self...
[ "def", "_map_to_processors", "(", "self", ",", "f", ",", "objective", ")", ":", "P", "=", "self", ".", "_random_subprocessors", "(", ")", "best", "=", "f", "(", "next", "(", "P", ")", ")", "for", "p", "in", "P", ":", "x", "=", "f", "(", "p", ")...
Map a function to a list of processors, and return the output that best satisfies a transitive objective function. The list of processors will differ according to the number of evil qubits and :func:`_proc_limit`, see details in :func:`self._random_subprocessors`. INPUT: f ...
[ "Map", "a", "function", "to", "a", "list", "of", "processors", "and", "return", "the", "output", "that", "best", "satisfies", "a", "transitive", "objective", "function", ".", "The", "list", "of", "processors", "will", "differ", "according", "to", "the", "num...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L889-L911
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._objective_bestscore
def _objective_bestscore(self, old, new): """An objective function that returns True if new has a better score than old, and ``False`` otherwise. INPUTS: old (tuple): a tuple (score, embedding) new (tuple): a tuple (score, embedding) """ (oldscore, oldt...
python
def _objective_bestscore(self, old, new): """An objective function that returns True if new has a better score than old, and ``False`` otherwise. INPUTS: old (tuple): a tuple (score, embedding) new (tuple): a tuple (score, embedding) """ (oldscore, oldt...
[ "def", "_objective_bestscore", "(", "self", ",", "old", ",", "new", ")", ":", "(", "oldscore", ",", "oldthing", ")", "=", "old", "(", "newscore", ",", "newthing", ")", "=", "new", "if", "oldscore", "is", "None", ":", "return", "True", "if", "newscore",...
An objective function that returns True if new has a better score than old, and ``False`` otherwise. INPUTS: old (tuple): a tuple (score, embedding) new (tuple): a tuple (score, embedding)
[ "An", "objective", "function", "that", "returns", "True", "if", "new", "has", "a", "better", "score", "than", "old", "and", "False", "otherwise", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L913-L929
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._objective_qubitcount
def _objective_qubitcount(self, old, new): """An objective function that returns True if new uses fewer qubits than old, and False otherwise. This objective function should only be used to compare embeddings of the same graph (or at least embeddings of graphs with the same number of qub...
python
def _objective_qubitcount(self, old, new): """An objective function that returns True if new uses fewer qubits than old, and False otherwise. This objective function should only be used to compare embeddings of the same graph (or at least embeddings of graphs with the same number of qub...
[ "def", "_objective_qubitcount", "(", "self", ",", "old", ",", "new", ")", ":", "(", "oldscore", ",", "oldthing", ")", "=", "old", "(", "newscore", ",", "newthing", ")", "=", "new", "def", "measure", "(", "chains", ")", ":", "return", "sum", "(", "map...
An objective function that returns True if new uses fewer qubits than old, and False otherwise. This objective function should only be used to compare embeddings of the same graph (or at least embeddings of graphs with the same number of qubits). INPUTS: old (tuple): a tupl...
[ "An", "objective", "function", "that", "returns", "True", "if", "new", "uses", "fewer", "qubits", "than", "old", "and", "False", "otherwise", ".", "This", "objective", "function", "should", "only", "be", "used", "to", "compare", "embeddings", "of", "the", "s...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L931-L963
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._find_evil
def _find_evil(self): """A utility function that computes a list of missing couplers which should connect two working qubits in the same cell. The presence of (a nonconstant number of) these breaks the polynomial-time claim for our algorithm. Note: we're only actually hurt by missing ...
python
def _find_evil(self): """A utility function that computes a list of missing couplers which should connect two working qubits in the same cell. The presence of (a nonconstant number of) these breaks the polynomial-time claim for our algorithm. Note: we're only actually hurt by missing ...
[ "def", "_find_evil", "(", "self", ")", ":", "M", ",", "N", ",", "L", "=", "self", ".", "M", ",", "self", ".", "N", ",", "self", ".", "L", "proc", "=", "self", ".", "_proc0", "evil", "=", "[", "]", "cells", "=", "[", "(", "x", ",", "y", ")...
A utility function that computes a list of missing couplers which should connect two working qubits in the same cell. The presence of (a nonconstant number of) these breaks the polynomial-time claim for our algorithm. Note: we're only actually hurt by missing intercell couplers.
[ "A", "utility", "function", "that", "computes", "a", "list", "of", "missing", "couplers", "which", "should", "connect", "two", "working", "qubits", "in", "the", "same", "cell", ".", "The", "presence", "of", "(", "a", "nonconstant", "number", "of", ")", "th...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L965-L983
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor.largestNativeClique
def largestNativeClique(self, max_chain_length=None): """Returns the largest native clique embedding we can find on the processor, with the shortest chainlength possible (for that clique size). If possible, returns a uniform choice among all largest cliques. INPUTS: ...
python
def largestNativeClique(self, max_chain_length=None): """Returns the largest native clique embedding we can find on the processor, with the shortest chainlength possible (for that clique size). If possible, returns a uniform choice among all largest cliques. INPUTS: ...
[ "def", "largestNativeClique", "(", "self", ",", "max_chain_length", "=", "None", ")", ":", "def", "f", "(", "x", ")", ":", "return", "x", ".", "largestNativeClique", "(", "max_chain_length", "=", "max_chain_length", ")", "objective", "=", "self", ".", "_obje...
Returns the largest native clique embedding we can find on the processor, with the shortest chainlength possible (for that clique size). If possible, returns a uniform choice among all largest cliques. INPUTS: max_chain_length (int): longest chain length to consider or ``No...
[ "Returns", "the", "largest", "native", "clique", "embedding", "we", "can", "find", "on", "the", "processor", "with", "the", "shortest", "chainlength", "possible", "(", "for", "that", "clique", "size", ")", ".", "If", "possible", "returns", "a", "uniform", "c...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1011-L1036
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor.nativeCliqueEmbed
def nativeCliqueEmbed(self, width): """Compute a maximum-sized native clique embedding in an induced subgraph of chimera with chainsize ``width+1``. If possible, returns a uniform choice among all largest cliques. INPUTS: width: width of the squares to search, also `chainle...
python
def nativeCliqueEmbed(self, width): """Compute a maximum-sized native clique embedding in an induced subgraph of chimera with chainsize ``width+1``. If possible, returns a uniform choice among all largest cliques. INPUTS: width: width of the squares to search, also `chainle...
[ "def", "nativeCliqueEmbed", "(", "self", ",", "width", ")", ":", "def", "f", "(", "x", ")", ":", "return", "x", ".", "nativeCliqueEmbed", "(", "width", ")", "objective", "=", "self", ".", "_objective_bestscore", "return", "self", ".", "_translate", "(", ...
Compute a maximum-sized native clique embedding in an induced subgraph of chimera with chainsize ``width+1``. If possible, returns a uniform choice among all largest cliques. INPUTS: width: width of the squares to search, also `chainlength-1` OUTPUT: clique: a ...
[ "Compute", "a", "maximum", "-", "sized", "native", "clique", "embedding", "in", "an", "induced", "subgraph", "of", "chimera", "with", "chainsize", "width", "+", "1", ".", "If", "possible", "returns", "a", "uniform", "choice", "among", "all", "largest", "cliq...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1038-L1062
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor.largestNativeBiClique
def largestNativeBiClique(self, chain_imbalance=0, max_chain_length=None): """Returns a native embedding for the complete bipartite graph :math:`K_{n,m}` for `n <= m`; where `n` is as large as possible and `m` is as large as possible subject to `n`. The native embedding of a complete bipartite ...
python
def largestNativeBiClique(self, chain_imbalance=0, max_chain_length=None): """Returns a native embedding for the complete bipartite graph :math:`K_{n,m}` for `n <= m`; where `n` is as large as possible and `m` is as large as possible subject to `n`. The native embedding of a complete bipartite ...
[ "def", "largestNativeBiClique", "(", "self", ",", "chain_imbalance", "=", "0", ",", "max_chain_length", "=", "None", ")", ":", "def", "f", "(", "x", ")", ":", "return", "x", ".", "largestNativeBiClique", "(", "chain_imbalance", "=", "chain_imbalance", ",", "...
Returns a native embedding for the complete bipartite graph :math:`K_{n,m}` for `n <= m`; where `n` is as large as possible and `m` is as large as possible subject to `n`. The native embedding of a complete bipartite graph is a set of horizontally-aligned qubits connected in lines toget...
[ "Returns", "a", "native", "embedding", "for", "the", "complete", "bipartite", "graph", ":", "math", ":", "K_", "{", "n", "m", "}", "for", "n", "<", "=", "m", ";", "where", "n", "is", "as", "large", "as", "possible", "and", "m", "is", "as", "large",...
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1064-L1098
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._translate
def _translate(self, embedding): "Translates an embedding back to linear coordinates if necessary." if embedding is None: return None if not self._linear: return embedding return [_bulk_to_linear(self.M, self.N, self.L, chain) for chain in embedding]
python
def _translate(self, embedding): "Translates an embedding back to linear coordinates if necessary." if embedding is None: return None if not self._linear: return embedding return [_bulk_to_linear(self.M, self.N, self.L, chain) for chain in embedding]
[ "def", "_translate", "(", "self", ",", "embedding", ")", ":", "if", "embedding", "is", "None", ":", "return", "None", "if", "not", "self", ".", "_linear", ":", "return", "embedding", "return", "[", "_bulk_to_linear", "(", "self", ".", "M", ",", "self", ...
Translates an embedding back to linear coordinates if necessary.
[ "Translates", "an", "embedding", "back", "to", "linear", "coordinates", "if", "necessary", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1152-L1158
dwavesystems/dwave-system
dwave/system/composites/virtual_graph.py
_validate_chain_strength
def _validate_chain_strength(sampler, chain_strength): """Validate the provided chain strength, checking J-ranges of the sampler's children. Args: chain_strength (float) The provided chain strength. Use None to use J-range. Returns (float): A valid chain strength, either provided or based...
python
def _validate_chain_strength(sampler, chain_strength): """Validate the provided chain strength, checking J-ranges of the sampler's children. Args: chain_strength (float) The provided chain strength. Use None to use J-range. Returns (float): A valid chain strength, either provided or based...
[ "def", "_validate_chain_strength", "(", "sampler", ",", "chain_strength", ")", ":", "properties", "=", "sampler", ".", "properties", "if", "'extended_j_range'", "in", "properties", ":", "max_chain_strength", "=", "-", "min", "(", "properties", "[", "'extended_j_rang...
Validate the provided chain strength, checking J-ranges of the sampler's children. Args: chain_strength (float) The provided chain strength. Use None to use J-range. Returns (float): A valid chain strength, either provided or based on available J-range. Positive finite float.
[ "Validate", "the", "provided", "chain", "strength", "checking", "J", "-", "ranges", "of", "the", "sampler", "s", "children", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/virtual_graph.py#L368-L392
dwavesystems/dwave-system
dwave/system/composites/virtual_graph.py
VirtualGraphComposite.sample
def sample(self, bqm, apply_flux_bias_offsets=True, **kwargs): """Sample from the given Ising model. Args: h (list/dict): Linear biases of the Ising model. If a list, the list's indices are used as variable labels. J (dict of (int, int):float): ...
python
def sample(self, bqm, apply_flux_bias_offsets=True, **kwargs): """Sample from the given Ising model. Args: h (list/dict): Linear biases of the Ising model. If a list, the list's indices are used as variable labels. J (dict of (int, int):float): ...
[ "def", "sample", "(", "self", ",", "bqm", ",", "apply_flux_bias_offsets", "=", "True", ",", "*", "*", "kwargs", ")", ":", "child", "=", "self", ".", "child", "if", "apply_flux_bias_offsets", ":", "if", "self", ".", "flux_biases", "is", "not", "None", ":"...
Sample from the given Ising model. Args: h (list/dict): Linear biases of the Ising model. If a list, the list's indices are used as variable labels. J (dict of (int, int):float): Quadratic biases of the Ising model. apply_fl...
[ "Sample", "from", "the", "given", "Ising", "model", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/virtual_graph.py#L299-L365
dwavesystems/dwave-system
dwave/system/flux_bias_offsets.py
get_flux_biases
def get_flux_biases(sampler, embedding, chain_strength, num_reads=1000, max_age=3600): """Get the flux bias offsets for sampler and embedding. Args: sampler (:obj:`.DWaveSampler`): A D-Wave sampler. embedding (dict[hashable, iterable]): Mapping from a source graph to th...
python
def get_flux_biases(sampler, embedding, chain_strength, num_reads=1000, max_age=3600): """Get the flux bias offsets for sampler and embedding. Args: sampler (:obj:`.DWaveSampler`): A D-Wave sampler. embedding (dict[hashable, iterable]): Mapping from a source graph to th...
[ "def", "get_flux_biases", "(", "sampler", ",", "embedding", ",", "chain_strength", ",", "num_reads", "=", "1000", ",", "max_age", "=", "3600", ")", ":", "if", "not", "isinstance", "(", "sampler", ",", "dimod", ".", "Sampler", ")", ":", "raise", "TypeError"...
Get the flux bias offsets for sampler and embedding. Args: sampler (:obj:`.DWaveSampler`): A D-Wave sampler. embedding (dict[hashable, iterable]): Mapping from a source graph to the specified sampler’s graph (the target graph). The keys of embedding should be no...
[ "Get", "the", "flux", "bias", "offsets", "for", "sampler", "and", "embedding", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/flux_bias_offsets.py#L26-L88
dwavesystems/dwave-system
dwave/embedding/chimera.py
find_clique_embedding
def find_clique_embedding(k, m, n=None, t=None, target_edges=None): """Find an embedding for a clique in a Chimera graph. Given a target :term:`Chimera` graph size, and a clique (fully connect graph), attempts to find an embedding. Args: k (int/iterable): Clique to embed. If k is a...
python
def find_clique_embedding(k, m, n=None, t=None, target_edges=None): """Find an embedding for a clique in a Chimera graph. Given a target :term:`Chimera` graph size, and a clique (fully connect graph), attempts to find an embedding. Args: k (int/iterable): Clique to embed. If k is a...
[ "def", "find_clique_embedding", "(", "k", ",", "m", ",", "n", "=", "None", ",", "t", "=", "None", ",", "target_edges", "=", "None", ")", ":", "import", "random", "_", ",", "nodes", "=", "k", "m", ",", "n", ",", "t", ",", "target_edges", "=", "_ch...
Find an embedding for a clique in a Chimera graph. Given a target :term:`Chimera` graph size, and a clique (fully connect graph), attempts to find an embedding. Args: k (int/iterable): Clique to embed. If k is an integer, generates an embedding for a clique of size k labell...
[ "Find", "an", "embedding", "for", "a", "clique", "in", "a", "Chimera", "graph", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/chimera.py#L27-L106
dwavesystems/dwave-system
dwave/embedding/chimera.py
find_biclique_embedding
def find_biclique_embedding(a, b, m, n=None, t=None, target_edges=None): """Find an embedding for a biclique in a Chimera graph. Given a target :term:`Chimera` graph size, and a biclique (a bipartite graph where every vertex in a set in connected to all vertices in the other set), attempts to find an embed...
python
def find_biclique_embedding(a, b, m, n=None, t=None, target_edges=None): """Find an embedding for a biclique in a Chimera graph. Given a target :term:`Chimera` graph size, and a biclique (a bipartite graph where every vertex in a set in connected to all vertices in the other set), attempts to find an embed...
[ "def", "find_biclique_embedding", "(", "a", ",", "b", ",", "m", ",", "n", "=", "None", ",", "t", "=", "None", ",", "target_edges", "=", "None", ")", ":", "_", ",", "anodes", "=", "a", "_", ",", "bnodes", "=", "b", "m", ",", "n", ",", "t", ","...
Find an embedding for a biclique in a Chimera graph. Given a target :term:`Chimera` graph size, and a biclique (a bipartite graph where every vertex in a set in connected to all vertices in the other set), attempts to find an embedding. Args: a (int/iterable): Left shore of the bicliqu...
[ "Find", "an", "embedding", "for", "a", "biclique", "in", "a", "Chimera", "graph", "." ]
train
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/chimera.py#L111-L171