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_documentation_string
stringlengths
1
47.2k
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 ...
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...
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...
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...
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...
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.
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...
Resturns the account settings data for this acocunt. This is not a listing endpoint.
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', ...
Make a new OAuth Client and return it
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...
Returns a MappedObject containing the account's transfer pool data
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 ...
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 ...
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...
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...
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...
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...
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...
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 ...
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...
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(...
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...
Makes a call to the linode api. Data should only be given if the method is POST or PUT, and should be a dictionary
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...
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. ...
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...
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
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...
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 ...
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...
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, ...
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...
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 ...
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...
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...
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...
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 ...
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 ...
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...
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...
Returns grants for the current user
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...
Adds a new entry to this user's IP whitelist, if enabled
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, ...
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`...
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]): ...
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...
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]): ...
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 ...
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...
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...
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....
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]): ...
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...
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...
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 ...
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...
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...
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 ...
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 ...
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...
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: ...
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...
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...
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...
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 ...
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.
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...
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: ...
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:'...
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...
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...
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): ...
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...
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.
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 ...
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...
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): ...
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): ...
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...
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...
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...
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...
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 ...
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...
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. ...
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...
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` ...
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): ...
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 ...
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...
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...
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...
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 ...
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 ...
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...
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 ...
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...
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...
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. ...
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...
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 ...
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...
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: ...
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...
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: ...
determine from an adjacency the list of edges if (u, v) in edges, then (v, u) should not be
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}
Embed a single state/sample by spreading it's values over the chains in the embedding
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...
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...
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 ...
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...
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 ...
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...
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 ...
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`...
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 + [...
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...
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]
Converts a list of chimera coordinates to linear indices.
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
Converts a qubit in chimera coordinates to its linear index.
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]
Converts a list of linear indices to chimera coordinates.
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)
Converts a qubit's linear index to chimera coordinates.
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: ...
Returns a list of neighbors of (x,y,u,k) in a perfect :math:`C_{M,N,L}`
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 ...
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: ...
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]
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.
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]
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.
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): ...
Does the hard work to prepare ``vline_score``.
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): ...
Does the hard work to prepare ``hline_score``.
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...
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``)
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) ...
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...
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...
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 ...
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...
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...
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 < ...
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
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 ...
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
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) ... ...
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\}`. ...
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...
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...
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...
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...
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...
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...
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)`` ...
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)...
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...
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...
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: ...
Returns all minimal edge covers of the set of evil edges.
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...
Create a subprocessor by deleting a set of qubits. We assume this removes all evil edges, and return an :class:`eden_processor` instance.
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_...
If there are fewer than self._proc_limit possible deletion sets, compute all subprocessors obtained by deleting a minimal subset of qubits.
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....
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...
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 ...
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. ...
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...
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 ...
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...
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)
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...
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...
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 ...
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.
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: ...
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...
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...
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 ...
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 ...
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...
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]
Translates an embedding back to linear coordinates if necessary.
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...
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.
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): ...
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...
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...
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...
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...
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...
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...
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...
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/chimera.py#L111-L171