repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
linode/linode_api4-python
linode_api4/objects/nodebalancer.py
NodeBalancerConfig.nodes
def nodes(self): """ This is a special derived_class relationship because NodeBalancerNode is the only api object that requires two parent_ids """ if not hasattr(self, '_nodes'): base_url = "{}/{}".format(NodeBalancerConfig.api_endpoint, NodeBalancerNode.derived_url_p...
python
def nodes(self): """ This is a special derived_class relationship because NodeBalancerNode is the only api object that requires two parent_ids """ if not hasattr(self, '_nodes'): base_url = "{}/{}".format(NodeBalancerConfig.api_endpoint, NodeBalancerNode.derived_url_p...
[ "def", "nodes", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_nodes'", ")", ":", "base_url", "=", "\"{}/{}\"", ".", "format", "(", "NodeBalancerConfig", ".", "api_endpoint", ",", "NodeBalancerNode", ".", "derived_url_path", ")", "result...
This is a special derived_class relationship because NodeBalancerNode is the only api object that requires two parent_ids
[ "This", "is", "a", "special", "derived_class", "relationship", "because", "NodeBalancerNode", "is", "the", "only", "api", "object", "that", "requires", "two", "parent_ids" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/nodebalancer.py#L73-L84
train
linode/linode_api4-python
linode_api4/objects/volume.py
Volume.attach
def attach(self, to_linode, config=None): """ Attaches this Volume to the given Linode """ result = self._client.post('{}/attach'.format(Volume.api_endpoint), model=self, data={ "linode_id": to_linode.id if issubclass(type(to_linode), Base) else to_lin...
python
def attach(self, to_linode, config=None): """ Attaches this Volume to the given Linode """ result = self._client.post('{}/attach'.format(Volume.api_endpoint), model=self, data={ "linode_id": to_linode.id if issubclass(type(to_linode), Base) else to_lin...
[ "def", "attach", "(", "self", ",", "to_linode", ",", "config", "=", "None", ")", ":", "result", "=", "self", ".", "_client", ".", "post", "(", "'{}/attach'", ".", "format", "(", "Volume", ".", "api_endpoint", ")", ",", "model", "=", "self", ",", "dat...
Attaches this Volume to the given Linode
[ "Attaches", "this", "Volume", "to", "the", "given", "Linode" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/volume.py#L22-L36
train
linode/linode_api4-python
linode_api4/objects/volume.py
Volume.detach
def detach(self): """ Detaches this Volume if it is attached """ self._client.post('{}/detach'.format(Volume.api_endpoint), model=self) return True
python
def detach(self): """ Detaches this Volume if it is attached """ self._client.post('{}/detach'.format(Volume.api_endpoint), model=self) return True
[ "def", "detach", "(", "self", ")", ":", "self", ".", "_client", ".", "post", "(", "'{}/detach'", ".", "format", "(", "Volume", ".", "api_endpoint", ")", ",", "model", "=", "self", ")", "return", "True" ]
Detaches this Volume if it is attached
[ "Detaches", "this", "Volume", "if", "it", "is", "attached" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/volume.py#L38-L44
train
linode/linode_api4-python
linode_api4/objects/volume.py
Volume.resize
def resize(self, size): """ Resizes this Volume """ result = self._client.post('{}/resize'.format(Volume.api_endpoint, model=self, data={ "size": size })) self._populate(result.json) return True
python
def resize(self, size): """ Resizes this Volume """ result = self._client.post('{}/resize'.format(Volume.api_endpoint, model=self, data={ "size": size })) self._populate(result.json) return True
[ "def", "resize", "(", "self", ",", "size", ")", ":", "result", "=", "self", ".", "_client", ".", "post", "(", "'{}/resize'", ".", "format", "(", "Volume", ".", "api_endpoint", ",", "model", "=", "self", ",", "data", "=", "{", "\"size\"", ":", "size",...
Resizes this Volume
[ "Resizes", "this", "Volume" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/volume.py#L46-L55
train
linode/linode_api4-python
linode_api4/objects/volume.py
Volume.clone
def clone(self, label): """ Clones this volume to a new volume in the same region with the given label :param label: The label for the new volume. :returns: The new volume object. """ result = self._client.post('{}/clone'.format(Volume.api_endpoint), mod...
python
def clone(self, label): """ Clones this volume to a new volume in the same region with the given label :param label: The label for the new volume. :returns: The new volume object. """ result = self._client.post('{}/clone'.format(Volume.api_endpoint), mod...
[ "def", "clone", "(", "self", ",", "label", ")", ":", "result", "=", "self", ".", "_client", ".", "post", "(", "'{}/clone'", ".", "format", "(", "Volume", ".", "api_endpoint", ")", ",", "model", "=", "self", ",", "data", "=", "{", "'label'", ":", "l...
Clones this volume to a new volume in the same region with the given label :param label: The label for the new volume. :returns: The new volume object.
[ "Clones", "this", "volume", "to", "a", "new", "volume", "in", "the", "same", "region", "with", "the", "given", "label" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/volume.py#L57-L71
train
linode/linode_api4-python
linode_api4/objects/tag.py
Tag._get_raw_objects
def _get_raw_objects(self): """ Helper function to populate the first page of raw objects for this tag. This has the side effect of creating the ``_raw_objects`` attribute of this object. """ if not hasattr(self, '_raw_objects'): result = self._client.get(type...
python
def _get_raw_objects(self): """ Helper function to populate the first page of raw objects for this tag. This has the side effect of creating the ``_raw_objects`` attribute of this object. """ if not hasattr(self, '_raw_objects'): result = self._client.get(type...
[ "def", "_get_raw_objects", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_raw_objects'", ")", ":", "result", "=", "self", ".", "_client", ".", "get", "(", "type", "(", "self", ")", ".", "api_endpoint", ",", "model", "=", "self", ...
Helper function to populate the first page of raw objects for this tag. This has the side effect of creating the ``_raw_objects`` attribute of this object.
[ "Helper", "function", "to", "populate", "the", "first", "page", "of", "raw", "objects", "for", "this", "tag", ".", "This", "has", "the", "side", "effect", "of", "creating", "the", "_raw_objects", "attribute", "of", "this", "object", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/tag.py#L32-L45
train
linode/linode_api4-python
linode_api4/objects/tag.py
Tag.objects
def objects(self): """ Returns a list of objects with this Tag. This list may contain any taggable object type. """ data = self._get_raw_objects() return PaginatedList.make_paginated_list(data, self._client, TaggedObjectProxy, ...
python
def objects(self): """ Returns a list of objects with this Tag. This list may contain any taggable object type. """ data = self._get_raw_objects() return PaginatedList.make_paginated_list(data, self._client, TaggedObjectProxy, ...
[ "def", "objects", "(", "self", ")", ":", "data", "=", "self", ".", "_get_raw_objects", "(", ")", "return", "PaginatedList", ".", "make_paginated_list", "(", "data", ",", "self", ".", "_client", ",", "TaggedObjectProxy", ",", "page_url", "=", "type", "(", "...
Returns a list of objects with this Tag. This list may contain any taggable object type.
[ "Returns", "a", "list", "of", "objects", "with", "this", "Tag", ".", "This", "list", "may", "contain", "any", "taggable", "object", "type", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/tag.py#L60-L68
train
linode/linode_api4-python
linode_api4/objects/tag.py
TaggedObjectProxy.make_instance
def make_instance(cls, id, client, parent_id=None, json=None): """ Overrides Base's ``make_instance`` to allow dynamic creation of objects based on the defined type in the response json. :param cls: The class this was called on :param id: The id of the instance to create ...
python
def make_instance(cls, id, client, parent_id=None, json=None): """ Overrides Base's ``make_instance`` to allow dynamic creation of objects based on the defined type in the response json. :param cls: The class this was called on :param id: The id of the instance to create ...
[ "def", "make_instance", "(", "cls", ",", "id", ",", "client", ",", "parent_id", "=", "None", ",", "json", "=", "None", ")", ":", "make_cls", "=", "CLASS_MAP", ".", "get", "(", "id", ")", "if", "make_cls", "is", "None", ":", "return", "None", "real_js...
Overrides Base's ``make_instance`` to allow dynamic creation of objects based on the defined type in the response json. :param cls: The class this was called on :param id: The id of the instance to create :param client: The client to use for this instance :param parent_id: The p...
[ "Overrides", "Base", "s", "make_instance", "to", "allow", "dynamic", "creation", "of", "objects", "based", "on", "the", "defined", "type", "in", "the", "response", "json", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/tag.py#L89-L113
train
linode/linode_api4-python
linode_api4/objects/linode.py
Disk.resize
def resize(self, new_size): """ Resizes this disk. The Linode Instance this disk belongs to must have sufficient space available to accommodate the new size, and must be offline. **NOTE** If resizing a disk down, the filesystem on the disk must still fit on the new disk...
python
def resize(self, new_size): """ Resizes this disk. The Linode Instance this disk belongs to must have sufficient space available to accommodate the new size, and must be offline. **NOTE** If resizing a disk down, the filesystem on the disk must still fit on the new disk...
[ "def", "resize", "(", "self", ",", "new_size", ")", ":", "self", ".", "_client", ".", "post", "(", "'{}/resize'", ".", "format", "(", "Disk", ".", "api_endpoint", ")", ",", "model", "=", "self", ",", "data", "=", "{", "\"size\"", ":", "new_size", "}"...
Resizes this disk. The Linode Instance this disk belongs to must have sufficient space available to accommodate the new size, and must be offline. **NOTE** If resizing a disk down, the filesystem on the disk must still fit on the new disk size. You may need to resize the filesystem on...
[ "Resizes", "this", "disk", ".", "The", "Linode", "Instance", "this", "disk", "belongs", "to", "must", "have", "sufficient", "space", "available", "to", "accommodate", "the", "new", "size", "and", "must", "be", "offline", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L98-L116
train
linode/linode_api4-python
linode_api4/objects/linode.py
Config._populate
def _populate(self, json): """ Map devices more nicely while populating. """ from .volume import Volume DerivedBase._populate(self, json) devices = {} for device_index, device in json['devices'].items(): if not device: devices[device_...
python
def _populate(self, json): """ Map devices more nicely while populating. """ from .volume import Volume DerivedBase._populate(self, json) devices = {} for device_index, device in json['devices'].items(): if not device: devices[device_...
[ "def", "_populate", "(", "self", ",", "json", ")", ":", "from", ".", "volume", "import", "Volume", "DerivedBase", ".", "_populate", "(", "self", ",", "json", ")", "devices", "=", "{", "}", "for", "device_index", ",", "device", "in", "json", "[", "'devi...
Map devices more nicely while populating.
[ "Map", "devices", "more", "nicely", "while", "populating", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L172-L195
train
linode/linode_api4-python
linode_api4/objects/linode.py
Instance.ips
def ips(self): """ The ips related collection is not normalized like the others, so we have to make an ad-hoc object to return for its response """ if not hasattr(self, '_ips'): result = self._client.get("{}/ips".format(Instance.api_endpoint), model=self) ...
python
def ips(self): """ The ips related collection is not normalized like the others, so we have to make an ad-hoc object to return for its response """ if not hasattr(self, '_ips'): result = self._client.get("{}/ips".format(Instance.api_endpoint), model=self) ...
[ "def", "ips", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_ips'", ")", ":", "result", "=", "self", ".", "_client", ".", "get", "(", "\"{}/ips\"", ".", "format", "(", "Instance", ".", "api_endpoint", ")", ",", "model", "=", "s...
The ips related collection is not normalized like the others, so we have to make an ad-hoc object to return for its response
[ "The", "ips", "related", "collection", "is", "not", "normalized", "like", "the", "others", "so", "we", "have", "to", "make", "an", "ad", "-", "hoc", "object", "to", "return", "for", "its", "response" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L222-L272
train
linode/linode_api4-python
linode_api4/objects/linode.py
Instance.available_backups
def available_backups(self): """ The backups response contains what backups are available to be restored. """ if not hasattr(self, '_avail_backups'): result = self._client.get("{}/backups".format(Instance.api_endpoint), model=self) if not 'automatic' in result: ...
python
def available_backups(self): """ The backups response contains what backups are available to be restored. """ if not hasattr(self, '_avail_backups'): result = self._client.get("{}/backups".format(Instance.api_endpoint), model=self) if not 'automatic' in result: ...
[ "def", "available_backups", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_avail_backups'", ")", ":", "result", "=", "self", ".", "_client", ".", "get", "(", "\"{}/backups\"", ".", "format", "(", "Instance", ".", "api_endpoint", ")", ...
The backups response contains what backups are available to be restored.
[ "The", "backups", "response", "contains", "what", "backups", "are", "available", "to", "be", "restored", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L275-L308
train
linode/linode_api4-python
linode_api4/objects/linode.py
Instance.invalidate
def invalidate(self): """ Clear out cached properties """ if hasattr(self, '_avail_backups'): del self._avail_backups if hasattr(self, '_ips'): del self._ips Base.invalidate(self)
python
def invalidate(self): """ Clear out cached properties """ if hasattr(self, '_avail_backups'): del self._avail_backups if hasattr(self, '_ips'): del self._ips Base.invalidate(self)
[ "def", "invalidate", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_avail_backups'", ")", ":", "del", "self", ".", "_avail_backups", "if", "hasattr", "(", "self", ",", "'_ips'", ")", ":", "del", "self", ".", "_ips", "Base", ".", "invalida...
Clear out cached properties
[ "Clear", "out", "cached", "properties" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L321-L328
train
linode/linode_api4-python
linode_api4/objects/linode.py
Instance.config_create
def config_create(self, kernel=None, label=None, devices=[], disks=[], volumes=[], **kwargs): """ Creates a Linode Config with the given attributes. :param kernel: The kernel to boot with. :param label: The config label :param disks: The list of disks, starting at sd...
python
def config_create(self, kernel=None, label=None, devices=[], disks=[], volumes=[], **kwargs): """ Creates a Linode Config with the given attributes. :param kernel: The kernel to boot with. :param label: The config label :param disks: The list of disks, starting at sd...
[ "def", "config_create", "(", "self", ",", "kernel", "=", "None", ",", "label", "=", "None", ",", "devices", "=", "[", "]", ",", "disks", "=", "[", "]", ",", "volumes", "=", "[", "]", ",", "**", "kwargs", ")", ":", "from", ".", "volume", "import",...
Creates a Linode Config with the given attributes. :param kernel: The kernel to boot with. :param label: The config label :param disks: The list of disks, starting at sda, to map to this config. :param volumes: The volumes, starting after the last disk, to map to this config...
[ "Creates", "a", "Linode", "Config", "with", "the", "given", "attributes", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L378-L456
train
linode/linode_api4-python
linode_api4/objects/linode.py
Instance.enable_backups
def enable_backups(self): """ Enable Backups for this Instance. When enabled, we will automatically backup your Instance's data so that it can be restored at a later date. For more information on Instance's Backups service and pricing, see our `Backups Page`_ .. _Backup...
python
def enable_backups(self): """ Enable Backups for this Instance. When enabled, we will automatically backup your Instance's data so that it can be restored at a later date. For more information on Instance's Backups service and pricing, see our `Backups Page`_ .. _Backup...
[ "def", "enable_backups", "(", "self", ")", ":", "self", ".", "_client", ".", "post", "(", "\"{}/backups/enable\"", ".", "format", "(", "Instance", ".", "api_endpoint", ")", ",", "model", "=", "self", ")", "self", ".", "invalidate", "(", ")", "return", "T...
Enable Backups for this Instance. When enabled, we will automatically backup your Instance's data so that it can be restored at a later date. For more information on Instance's Backups service and pricing, see our `Backups Page`_ .. _Backups Page: https://www.linode.com/backups
[ "Enable", "Backups", "for", "this", "Instance", ".", "When", "enabled", "we", "will", "automatically", "backup", "your", "Instance", "s", "data", "so", "that", "it", "can", "be", "restored", "at", "a", "later", "date", ".", "For", "more", "information", "o...
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L502-L513
train
linode/linode_api4-python
linode_api4/objects/linode.py
Instance.mutate
def mutate(self): """ Upgrades this Instance to the latest generation type """ self._client.post('{}/mutate'.format(Instance.api_endpoint), model=self) return True
python
def mutate(self): """ Upgrades this Instance to the latest generation type """ self._client.post('{}/mutate'.format(Instance.api_endpoint), model=self) return True
[ "def", "mutate", "(", "self", ")", ":", "self", ".", "_client", ".", "post", "(", "'{}/mutate'", ".", "format", "(", "Instance", ".", "api_endpoint", ")", ",", "model", "=", "self", ")", "return", "True" ]
Upgrades this Instance to the latest generation type
[ "Upgrades", "this", "Instance", "to", "the", "latest", "generation", "type" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L635-L641
train
linode/linode_api4-python
linode_api4/objects/linode.py
Instance.initiate_migration
def initiate_migration(self): """ Initiates a pending migration that is already scheduled for this Linode Instance """ self._client.post('{}/migrate'.format(Instance.api_endpoint), model=self)
python
def initiate_migration(self): """ Initiates a pending migration that is already scheduled for this Linode Instance """ self._client.post('{}/migrate'.format(Instance.api_endpoint), model=self)
[ "def", "initiate_migration", "(", "self", ")", ":", "self", ".", "_client", ".", "post", "(", "'{}/migrate'", ".", "format", "(", "Instance", ".", "api_endpoint", ")", ",", "model", "=", "self", ")" ]
Initiates a pending migration that is already scheduled for this Linode Instance
[ "Initiates", "a", "pending", "migration", "that", "is", "already", "scheduled", "for", "this", "Linode", "Instance" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L643-L648
train
linode/linode_api4-python
linode_api4/objects/linode.py
Instance.clone
def clone(self, to_linode=None, region=None, service=None, configs=[], disks=[], label=None, group=None, with_backups=None): """ Clones this linode into a new linode or into a new linode in the given region """ if to_linode and region: raise ValueError('You may only specify one o...
python
def clone(self, to_linode=None, region=None, service=None, configs=[], disks=[], label=None, group=None, with_backups=None): """ Clones this linode into a new linode or into a new linode in the given region """ if to_linode and region: raise ValueError('You may only specify one o...
[ "def", "clone", "(", "self", ",", "to_linode", "=", "None", ",", "region", "=", "None", ",", "service", "=", "None", ",", "configs", "=", "[", "]", ",", "disks", "=", "[", "]", ",", "label", "=", "None", ",", "group", "=", "None", ",", "with_back...
Clones this linode into a new linode or into a new linode in the given region
[ "Clones", "this", "linode", "into", "a", "new", "linode", "or", "into", "a", "new", "linode", "in", "the", "given", "region" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L650-L684
train
linode/linode_api4-python
linode_api4/objects/linode.py
Instance.stats
def stats(self): """ Returns the JSON stats for this Instance """ # TODO - this would be nicer if we formatted the stats return self._client.get('{}/stats'.format(Instance.api_endpoint), model=self)
python
def stats(self): """ Returns the JSON stats for this Instance """ # TODO - this would be nicer if we formatted the stats return self._client.get('{}/stats'.format(Instance.api_endpoint), model=self)
[ "def", "stats", "(", "self", ")", ":", "return", "self", ".", "_client", ".", "get", "(", "'{}/stats'", ".", "format", "(", "Instance", ".", "api_endpoint", ")", ",", "model", "=", "self", ")" ]
Returns the JSON stats for this Instance
[ "Returns", "the", "JSON", "stats", "for", "this", "Instance" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L687-L692
train
linode/linode_api4-python
linode_api4/objects/linode.py
Instance.stats_for
def stats_for(self, dt): """ Returns stats for the month containing the given datetime """ # TODO - this would be nicer if we formatted the stats if not isinstance(dt, datetime): raise TypeError('stats_for requires a datetime object!') return self._client.get(...
python
def stats_for(self, dt): """ Returns stats for the month containing the given datetime """ # TODO - this would be nicer if we formatted the stats if not isinstance(dt, datetime): raise TypeError('stats_for requires a datetime object!') return self._client.get(...
[ "def", "stats_for", "(", "self", ",", "dt", ")", ":", "if", "not", "isinstance", "(", "dt", ",", "datetime", ")", ":", "raise", "TypeError", "(", "'stats_for requires a datetime object!'", ")", "return", "self", ".", "_client", ".", "get", "(", "'{}/stats/'"...
Returns stats for the month containing the given datetime
[ "Returns", "stats", "for", "the", "month", "containing", "the", "given", "datetime" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L694-L701
train
linode/linode_api4-python
linode_api4/objects/linode.py
StackScript._populate
def _populate(self, json): """ Override the populate method to map user_defined_fields to fancy values """ Base._populate(self, json) mapped_udfs = [] for udf in self.user_defined_fields: t = UserDefinedFieldType.text choices = None ...
python
def _populate(self, json): """ Override the populate method to map user_defined_fields to fancy values """ Base._populate(self, json) mapped_udfs = [] for udf in self.user_defined_fields: t = UserDefinedFieldType.text choices = None ...
[ "def", "_populate", "(", "self", ",", "json", ")", ":", "Base", ".", "_populate", "(", "self", ",", "json", ")", "mapped_udfs", "=", "[", "]", "for", "udf", "in", "self", ".", "user_defined_fields", ":", "t", "=", "UserDefinedFieldType", ".", "text", "...
Override the populate method to map user_defined_fields to fancy values
[ "Override", "the", "populate", "method", "to", "map", "user_defined_fields", "to", "fancy", "values" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L738-L763
train
linode/linode_api4-python
linode_api4/objects/account.py
InvoiceItem._populate
def _populate(self, json): """ Allows population of "from_date" from the returned "from" attribute which is a reserved word in python. Also populates "to_date" to be complete. """ super(InvoiceItem, self)._populate(json) self.from_date = datetime.strptime(json['from'], ...
python
def _populate(self, json): """ Allows population of "from_date" from the returned "from" attribute which is a reserved word in python. Also populates "to_date" to be complete. """ super(InvoiceItem, self)._populate(json) self.from_date = datetime.strptime(json['from'], ...
[ "def", "_populate", "(", "self", ",", "json", ")", ":", "super", "(", "InvoiceItem", ",", "self", ")", ".", "_populate", "(", "json", ")", "self", ".", "from_date", "=", "datetime", ".", "strptime", "(", "json", "[", "'from'", "]", ",", "DATE_FORMAT", ...
Allows population of "from_date" from the returned "from" attribute which is a reserved word in python. Also populates "to_date" to be complete.
[ "Allows", "population", "of", "from_date", "from", "the", "returned", "from", "attribute", "which", "is", "a", "reserved", "word", "in", "python", ".", "Also", "populates", "to_date", "to", "be", "complete", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/account.py#L128-L136
train
linode/linode_api4-python
linode_api4/objects/account.py
OAuthClient.reset_secret
def reset_secret(self): """ Resets the client secret for this client. """ result = self._client.post("{}/reset_secret".format(OAuthClient.api_endpoint), model=self) if not 'id' in result: raise UnexpectedResponseError('Unexpected response when resetting secret!', jso...
python
def reset_secret(self): """ Resets the client secret for this client. """ result = self._client.post("{}/reset_secret".format(OAuthClient.api_endpoint), model=self) if not 'id' in result: raise UnexpectedResponseError('Unexpected response when resetting secret!', jso...
[ "def", "reset_secret", "(", "self", ")", ":", "result", "=", "self", ".", "_client", ".", "post", "(", "\"{}/reset_secret\"", ".", "format", "(", "OAuthClient", ".", "api_endpoint", ")", ",", "model", "=", "self", ")", "if", "not", "'id'", "in", "result"...
Resets the client secret for this client.
[ "Resets", "the", "client", "secret", "for", "this", "client", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/account.py#L163-L173
train
linode/linode_api4-python
linode_api4/objects/account.py
OAuthClient.thumbnail
def thumbnail(self, dump_to=None): """ This returns binary data that represents a 128x128 image. If dump_to is given, attempts to write the image to a file at the given location. """ headers = { "Authorization": "token {}".format(self._client.token) } ...
python
def thumbnail(self, dump_to=None): """ This returns binary data that represents a 128x128 image. If dump_to is given, attempts to write the image to a file at the given location. """ headers = { "Authorization": "token {}".format(self._client.token) } ...
[ "def", "thumbnail", "(", "self", ",", "dump_to", "=", "None", ")", ":", "headers", "=", "{", "\"Authorization\"", ":", "\"token {}\"", ".", "format", "(", "self", ".", "_client", ".", "token", ")", "}", "result", "=", "requests", ".", "get", "(", "'{}/...
This returns binary data that represents a 128x128 image. If dump_to is given, attempts to write the image to a file at the given location.
[ "This", "returns", "binary", "data", "that", "represents", "a", "128x128", "image", ".", "If", "dump_to", "is", "given", "attempts", "to", "write", "the", "image", "to", "a", "file", "at", "the", "given", "location", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/account.py#L175-L195
train
linode/linode_api4-python
linode_api4/objects/account.py
OAuthClient.set_thumbnail
def set_thumbnail(self, thumbnail): """ Sets the thumbnail for this OAuth Client. If thumbnail is bytes, uploads it as a png. Otherwise, assumes thumbnail is a path to the thumbnail and reads it in as bytes before uploading. """ headers = { "Authorization": ...
python
def set_thumbnail(self, thumbnail): """ Sets the thumbnail for this OAuth Client. If thumbnail is bytes, uploads it as a png. Otherwise, assumes thumbnail is a path to the thumbnail and reads it in as bytes before uploading. """ headers = { "Authorization": ...
[ "def", "set_thumbnail", "(", "self", ",", "thumbnail", ")", ":", "headers", "=", "{", "\"Authorization\"", ":", "\"token {}\"", ".", "format", "(", "self", ".", "_client", ".", "token", ")", ",", "\"Content-type\"", ":", "\"image/png\"", ",", "}", "if", "n...
Sets the thumbnail for this OAuth Client. If thumbnail is bytes, uploads it as a png. Otherwise, assumes thumbnail is a path to the thumbnail and reads it in as bytes before uploading.
[ "Sets", "the", "thumbnail", "for", "this", "OAuth", "Client", ".", "If", "thumbnail", "is", "bytes", "uploads", "it", "as", "a", "png", ".", "Otherwise", "assumes", "thumbnail", "is", "a", "path", "to", "the", "thumbnail", "and", "reads", "it", "in", "as...
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/account.py#L197-L224
train
linode/linode_api4-python
linode_api4/objects/account.py
User.grants
def grants(self): """ Retrieves the grants for this user. If the user is unrestricted, this will result in an ApiError. This is smart, and will only fetch from the api once unless the object is invalidated. :returns: The grants for this user. :rtype: linode.objects.acc...
python
def grants(self): """ Retrieves the grants for this user. If the user is unrestricted, this will result in an ApiError. This is smart, and will only fetch from the api once unless the object is invalidated. :returns: The grants for this user. :rtype: linode.objects.acc...
[ "def", "grants", "(", "self", ")", ":", "from", "linode_api4", ".", "objects", ".", "account", "import", "UserGrants", "if", "not", "hasattr", "(", "self", ",", "'_grants'", ")", ":", "resp", "=", "self", ".", "_client", ".", "get", "(", "UserGrants", ...
Retrieves the grants for this user. If the user is unrestricted, this will result in an ApiError. This is smart, and will only fetch from the api once unless the object is invalidated. :returns: The grants for this user. :rtype: linode.objects.account.UserGrants
[ "Retrieves", "the", "grants", "for", "this", "user", ".", "If", "the", "user", "is", "unrestricted", "this", "will", "result", "in", "an", "ApiError", ".", "This", "is", "smart", "and", "will", "only", "fetch", "from", "the", "api", "once", "unless", "th...
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/account.py#L248-L264
train
linode/linode_api4-python
linode_api4/objects/base.py
Base.save
def save(self): """ Send this object's mutable values to the server in a PUT request """ resp = self._client.put(type(self).api_endpoint, model=self, data=self._serialize()) if 'error' in resp: return False return True
python
def save(self): """ Send this object's mutable values to the server in a PUT request """ resp = self._client.put(type(self).api_endpoint, model=self, data=self._serialize()) if 'error' in resp: return False return True
[ "def", "save", "(", "self", ")", ":", "resp", "=", "self", ".", "_client", ".", "put", "(", "type", "(", "self", ")", ".", "api_endpoint", ",", "model", "=", "self", ",", "data", "=", "self", ".", "_serialize", "(", ")", ")", "if", "'error'", "in...
Send this object's mutable values to the server in a PUT request
[ "Send", "this", "object", "s", "mutable", "values", "to", "the", "server", "in", "a", "PUT", "request" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L150-L159
train
linode/linode_api4-python
linode_api4/objects/base.py
Base.delete
def delete(self): """ Sends a DELETE request for this object """ resp = self._client.delete(type(self).api_endpoint, model=self) if 'error' in resp: return False self.invalidate() return True
python
def delete(self): """ Sends a DELETE request for this object """ resp = self._client.delete(type(self).api_endpoint, model=self) if 'error' in resp: return False self.invalidate() return True
[ "def", "delete", "(", "self", ")", ":", "resp", "=", "self", ".", "_client", ".", "delete", "(", "type", "(", "self", ")", ".", "api_endpoint", ",", "model", "=", "self", ")", "if", "'error'", "in", "resp", ":", "return", "False", "self", ".", "inv...
Sends a DELETE request for this object
[ "Sends", "a", "DELETE", "request", "for", "this", "object" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L161-L170
train
linode/linode_api4-python
linode_api4/objects/base.py
Base.invalidate
def invalidate(self): """ Invalidates all non-identifier Properties this object has locally, causing the next access to re-fetch them from the server """ for key in [k for k in type(self).properties.keys() if not type(self).properties[k].identifier]: s...
python
def invalidate(self): """ Invalidates all non-identifier Properties this object has locally, causing the next access to re-fetch them from the server """ for key in [k for k in type(self).properties.keys() if not type(self).properties[k].identifier]: s...
[ "def", "invalidate", "(", "self", ")", ":", "for", "key", "in", "[", "k", "for", "k", "in", "type", "(", "self", ")", ".", "properties", ".", "keys", "(", ")", "if", "not", "type", "(", "self", ")", ".", "properties", "[", "k", "]", ".", "ident...
Invalidates all non-identifier Properties this object has locally, causing the next access to re-fetch them from the server
[ "Invalidates", "all", "non", "-", "identifier", "Properties", "this", "object", "has", "locally", "causing", "the", "next", "access", "to", "re", "-", "fetch", "them", "from", "the", "server" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L172-L181
train
linode/linode_api4-python
linode_api4/objects/base.py
Base._serialize
def _serialize(self): """ A helper method to build a dict of all mutable Properties of this object """ result = { a: getattr(self, a) for a in type(self).properties if type(self).properties[a].mutable } for k, v in result.items(): if isinstance(v,...
python
def _serialize(self): """ A helper method to build a dict of all mutable Properties of this object """ result = { a: getattr(self, a) for a in type(self).properties if type(self).properties[a].mutable } for k, v in result.items(): if isinstance(v,...
[ "def", "_serialize", "(", "self", ")", ":", "result", "=", "{", "a", ":", "getattr", "(", "self", ",", "a", ")", "for", "a", "in", "type", "(", "self", ")", ".", "properties", "if", "type", "(", "self", ")", ".", "properties", "[", "a", "]", "....
A helper method to build a dict of all mutable Properties of this object
[ "A", "helper", "method", "to", "build", "a", "dict", "of", "all", "mutable", "Properties", "of", "this", "object" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L183-L195
train
linode/linode_api4-python
linode_api4/objects/base.py
Base._api_get
def _api_get(self): """ A helper method to GET this object from the server """ json = self._client.get(type(self).api_endpoint, model=self) self._populate(json)
python
def _api_get(self): """ A helper method to GET this object from the server """ json = self._client.get(type(self).api_endpoint, model=self) self._populate(json)
[ "def", "_api_get", "(", "self", ")", ":", "json", "=", "self", ".", "_client", ".", "get", "(", "type", "(", "self", ")", ".", "api_endpoint", ",", "model", "=", "self", ")", "self", ".", "_populate", "(", "json", ")" ]
A helper method to GET this object from the server
[ "A", "helper", "method", "to", "GET", "this", "object", "from", "the", "server" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L197-L202
train
linode/linode_api4-python
linode_api4/objects/base.py
Base._populate
def _populate(self, json): """ A helper method that, given a JSON object representing this object, assigns values based on the properties dict and the attributes of its Properties. """ if not json: return # hide the raw JSON away in case someone needs...
python
def _populate(self, json): """ A helper method that, given a JSON object representing this object, assigns values based on the properties dict and the attributes of its Properties. """ if not json: return # hide the raw JSON away in case someone needs...
[ "def", "_populate", "(", "self", ",", "json", ")", ":", "if", "not", "json", ":", "return", "self", ".", "_set", "(", "'_raw_json'", ",", "json", ")", "for", "key", "in", "json", ":", "if", "key", "in", "(", "k", "for", "k", "in", "type", "(", ...
A helper method that, given a JSON object representing this object, assigns values based on the properties dict and the attributes of its Properties.
[ "A", "helper", "method", "that", "given", "a", "JSON", "object", "representing", "this", "object", "assigns", "values", "based", "on", "the", "properties", "dict", "and", "the", "attributes", "of", "its", "Properties", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L204-L265
train
linode/linode_api4-python
linode_api4/objects/base.py
Base.make
def make(id, client, cls, parent_id=None, json=None): """ Makes an api object based on an id and class. :param id: The id of the object to create :param client: The LinodeClient to give the new object :param cls: The class type to instantiate :param parent_id: The parent...
python
def make(id, client, cls, parent_id=None, json=None): """ Makes an api object based on an id and class. :param id: The id of the object to create :param client: The LinodeClient to give the new object :param cls: The class type to instantiate :param parent_id: The parent...
[ "def", "make", "(", "id", ",", "client", ",", "cls", ",", "parent_id", "=", "None", ",", "json", "=", "None", ")", ":", "from", ".", "dbase", "import", "DerivedBase", "if", "issubclass", "(", "cls", ",", "DerivedBase", ")", ":", "return", "cls", "(",...
Makes an api object based on an id and class. :param id: The id of the object to create :param client: The LinodeClient to give the new object :param cls: The class type to instantiate :param parent_id: The parent id for derived classes :param json: The JSON to use to populate t...
[ "Makes", "an", "api", "object", "based", "on", "an", "id", "and", "class", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L283-L300
train
linode/linode_api4-python
linode_api4/objects/base.py
Base.make_instance
def make_instance(cls, id, client, parent_id=None, json=None): """ Makes an instance of the class this is called on and returns it. The intended usage is: instance = Linode.make_instance(123, client, json=response) :param cls: The class this was called on. :param id: ...
python
def make_instance(cls, id, client, parent_id=None, json=None): """ Makes an instance of the class this is called on and returns it. The intended usage is: instance = Linode.make_instance(123, client, json=response) :param cls: The class this was called on. :param id: ...
[ "def", "make_instance", "(", "cls", ",", "id", ",", "client", ",", "parent_id", "=", "None", ",", "json", "=", "None", ")", ":", "return", "Base", ".", "make", "(", "id", ",", "client", ",", "cls", ",", "parent_id", "=", "parent_id", ",", "json", "...
Makes an instance of the class this is called on and returns it. The intended usage is: instance = Linode.make_instance(123, client, json=response) :param cls: The class this was called on. :param id: The id of the instance to create :param client: The client to use for this ...
[ "Makes", "an", "instance", "of", "the", "class", "this", "is", "called", "on", "and", "returns", "it", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L303-L318
train
linode/linode_api4-python
linode_api4/objects/networking.py
IPAddress.to
def to(self, linode): """ This is a helper method for ip-assign, and should not be used outside of that context. It's used to cleanly build an IP Assign request with pretty python syntax. """ from .linode import Instance if not isinstance(linode, Instance): ...
python
def to(self, linode): """ This is a helper method for ip-assign, and should not be used outside of that context. It's used to cleanly build an IP Assign request with pretty python syntax. """ from .linode import Instance if not isinstance(linode, Instance): ...
[ "def", "to", "(", "self", ",", "linode", ")", ":", "from", ".", "linode", "import", "Instance", "if", "not", "isinstance", "(", "linode", ",", "Instance", ")", ":", "raise", "ValueError", "(", "\"IP Address can only be assigned to a Linode!\"", ")", "return", ...
This is a helper method for ip-assign, and should not be used outside of that context. It's used to cleanly build an IP Assign request with pretty python syntax.
[ "This", "is", "a", "helper", "method", "for", "ip", "-", "assign", "and", "should", "not", "be", "used", "outside", "of", "that", "context", ".", "It", "s", "used", "to", "cleanly", "build", "an", "IP", "Assign", "request", "with", "pretty", "python", ...
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/networking.py#L49-L58
train
linode/linode_api4-python
linode_api4/linode_client.py
ProfileGroup.token_create
def token_create(self, label=None, expiry=None, scopes=None, **kwargs): """ Creates and returns a new Personal Access Token """ if label: kwargs['label'] = label if expiry: if isinstance(expiry, datetime): expiry = datetime.strftime(expiry,...
python
def token_create(self, label=None, expiry=None, scopes=None, **kwargs): """ Creates and returns a new Personal Access Token """ if label: kwargs['label'] = label if expiry: if isinstance(expiry, datetime): expiry = datetime.strftime(expiry,...
[ "def", "token_create", "(", "self", ",", "label", "=", "None", ",", "expiry", "=", "None", ",", "scopes", "=", "None", ",", "**", "kwargs", ")", ":", "if", "label", ":", "kwargs", "[", "'label'", "]", "=", "label", "if", "expiry", ":", "if", "isins...
Creates and returns a new Personal Access Token
[ "Creates", "and", "returns", "a", "new", "Personal", "Access", "Token" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L358-L378
train
linode/linode_api4-python
linode_api4/linode_client.py
ProfileGroup.ssh_key_upload
def ssh_key_upload(self, key, label): """ Uploads a new SSH Public Key to your profile This key can be used in later Linode deployments. :param key: The ssh key, or a path to the ssh key. If a path is provided, the file at the path must exist and be readable or an ...
python
def ssh_key_upload(self, key, label): """ Uploads a new SSH Public Key to your profile This key can be used in later Linode deployments. :param key: The ssh key, or a path to the ssh key. If a path is provided, the file at the path must exist and be readable or an ...
[ "def", "ssh_key_upload", "(", "self", ",", "key", ",", "label", ")", ":", "if", "not", "key", ".", "startswith", "(", "SSH_KEY_TYPES", ")", ":", "path", "=", "os", ".", "path", ".", "expanduser", "(", "key", ")", "if", "os", ".", "path", ".", "isfi...
Uploads a new SSH Public Key to your profile This key can be used in later Linode deployments. :param key: The ssh key, or a path to the ssh key. If a path is provided, the file at the path must exist and be readable or an exception will be thrown. :typ...
[ "Uploads", "a", "new", "SSH", "Public", "Key", "to", "your", "profile", "This", "key", "can", "be", "used", "in", "later", "Linode", "deployments", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L392-L430
train
linode/linode_api4-python
linode_api4/linode_client.py
LongviewGroup.client_create
def client_create(self, label=None): """ Creates a new LongviewClient, optionally with a given label. :param label: The label for the new client. If None, a default label based on the new client's ID will be used. :returns: A new LongviewClient :raises ApiError: I...
python
def client_create(self, label=None): """ Creates a new LongviewClient, optionally with a given label. :param label: The label for the new client. If None, a default label based on the new client's ID will be used. :returns: A new LongviewClient :raises ApiError: I...
[ "def", "client_create", "(", "self", ",", "label", "=", "None", ")", ":", "result", "=", "self", ".", "client", ".", "post", "(", "'/longview/clients'", ",", "data", "=", "{", "\"label\"", ":", "label", "}", ")", "if", "not", "'id'", "in", "result", ...
Creates a new LongviewClient, optionally with a given label. :param label: The label for the new client. If None, a default label based on the new client's ID will be used. :returns: A new LongviewClient :raises ApiError: If a non-200 status code is returned :raises Unexp...
[ "Creates", "a", "new", "LongviewClient", "optionally", "with", "a", "given", "label", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L441-L463
train
linode/linode_api4-python
linode_api4/linode_client.py
AccountGroup.events_mark_seen
def events_mark_seen(self, event): """ Marks event as the last event we have seen. If event is an int, it is treated as an event_id, otherwise it should be an event object whose id will be used. """ last_seen = event if isinstance(event, int) else event.id self.client.po...
python
def events_mark_seen(self, event): """ Marks event as the last event we have seen. If event is an int, it is treated as an event_id, otherwise it should be an event object whose id will be used. """ last_seen = event if isinstance(event, int) else event.id self.client.po...
[ "def", "events_mark_seen", "(", "self", ",", "event", ")", ":", "last_seen", "=", "event", "if", "isinstance", "(", "event", ",", "int", ")", "else", "event", ".", "id", "self", ".", "client", ".", "post", "(", "'{}/seen'", ".", "format", "(", "Event",...
Marks event as the last event we have seen. If event is an int, it is treated as an event_id, otherwise it should be an event object whose id will be used.
[ "Marks", "event", "as", "the", "last", "event", "we", "have", "seen", ".", "If", "event", "is", "an", "int", "it", "is", "treated", "as", "an", "event_id", "otherwise", "it", "should", "be", "an", "event", "object", "whose", "id", "will", "be", "used",...
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L495-L501
train
linode/linode_api4-python
linode_api4/linode_client.py
AccountGroup.settings
def settings(self): """ Resturns the account settings data for this acocunt. This is not a listing endpoint. """ result = self.client.get('/account/settings') if not 'managed' in result: raise UnexpectedResponseError('Unexpected response when getting accoun...
python
def settings(self): """ Resturns the account settings data for this acocunt. This is not a listing endpoint. """ result = self.client.get('/account/settings') if not 'managed' in result: raise UnexpectedResponseError('Unexpected response when getting accoun...
[ "def", "settings", "(", "self", ")", ":", "result", "=", "self", ".", "client", ".", "get", "(", "'/account/settings'", ")", "if", "not", "'managed'", "in", "result", ":", "raise", "UnexpectedResponseError", "(", "'Unexpected response when getting account settings!'...
Resturns the account settings data for this acocunt. This is not a listing endpoint.
[ "Resturns", "the", "account", "settings", "data", "for", "this", "acocunt", ".", "This", "is", "not", "a", "listing", "endpoint", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L503-L515
train
linode/linode_api4-python
linode_api4/linode_client.py
AccountGroup.oauth_client_create
def oauth_client_create(self, name, redirect_uri, **kwargs): """ Make a new OAuth Client and return it """ params = { "label": name, "redirect_uri": redirect_uri, } params.update(kwargs) result = self.client.post('/account/oauth-clients', ...
python
def oauth_client_create(self, name, redirect_uri, **kwargs): """ Make a new OAuth Client and return it """ params = { "label": name, "redirect_uri": redirect_uri, } params.update(kwargs) result = self.client.post('/account/oauth-clients', ...
[ "def", "oauth_client_create", "(", "self", ",", "name", ",", "redirect_uri", ",", "**", "kwargs", ")", ":", "params", "=", "{", "\"label\"", ":", "name", ",", "\"redirect_uri\"", ":", "redirect_uri", ",", "}", "params", ".", "update", "(", "kwargs", ")", ...
Make a new OAuth Client and return it
[ "Make", "a", "new", "OAuth", "Client", "and", "return", "it" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L535-L552
train
linode/linode_api4-python
linode_api4/linode_client.py
AccountGroup.transfer
def transfer(self): """ Returns a MappedObject containing the account's transfer pool data """ result = self.client.get('/account/transfer') if not 'used' in result: raise UnexpectedResponseError('Unexpected response when getting Transfer Pool!') return Mapp...
python
def transfer(self): """ Returns a MappedObject containing the account's transfer pool data """ result = self.client.get('/account/transfer') if not 'used' in result: raise UnexpectedResponseError('Unexpected response when getting Transfer Pool!') return Mapp...
[ "def", "transfer", "(", "self", ")", ":", "result", "=", "self", ".", "client", ".", "get", "(", "'/account/transfer'", ")", "if", "not", "'used'", "in", "result", ":", "raise", "UnexpectedResponseError", "(", "'Unexpected response when getting Transfer Pool!'", "...
Returns a MappedObject containing the account's transfer pool data
[ "Returns", "a", "MappedObject", "containing", "the", "account", "s", "transfer", "pool", "data" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L560-L569
train
linode/linode_api4-python
linode_api4/linode_client.py
NetworkingGroup.ip_allocate
def ip_allocate(self, linode, public=True): """ Allocates an IP to a Instance you own. Additional IPs must be requested by opening a support ticket first. :param linode: The Instance to allocate the new IP for. :type linode: Instance or int :param public: If True, alloc...
python
def ip_allocate(self, linode, public=True): """ Allocates an IP to a Instance you own. Additional IPs must be requested by opening a support ticket first. :param linode: The Instance to allocate the new IP for. :type linode: Instance or int :param public: If True, alloc...
[ "def", "ip_allocate", "(", "self", ",", "linode", ",", "public", "=", "True", ")", ":", "result", "=", "self", ".", "client", ".", "post", "(", "'/networking/ipv4/'", ",", "data", "=", "{", "\"linode_id\"", ":", "linode", ".", "id", "if", "isinstance", ...
Allocates an IP to a Instance you own. Additional IPs must be requested by opening a support ticket first. :param linode: The Instance to allocate the new IP for. :type linode: Instance or int :param public: If True, allocate a public IP address. Defaults to True. :type public...
[ "Allocates", "an", "IP", "to", "a", "Instance", "you", "own", ".", "Additional", "IPs", "must", "be", "requested", "by", "opening", "a", "support", "ticket", "first", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L658-L682
train
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient.load
def load(self, target_type, target_id, target_parent_id=None): """ Constructs and immediately loads the object, circumventing the lazy-loading scheme by immediately making an API request. Does not load related objects. For example, if you wanted to load an :any:`Instance` objec...
python
def load(self, target_type, target_id, target_parent_id=None): """ Constructs and immediately loads the object, circumventing the lazy-loading scheme by immediately making an API request. Does not load related objects. For example, if you wanted to load an :any:`Instance` objec...
[ "def", "load", "(", "self", ",", "target_type", ",", "target_id", ",", "target_parent_id", "=", "None", ")", ":", "result", "=", "target_type", ".", "make_instance", "(", "target_id", ",", "self", ",", "parent_id", "=", "target_parent_id", ")", "result", "."...
Constructs and immediately loads the object, circumventing the lazy-loading scheme by immediately making an API request. Does not load related objects. For example, if you wanted to load an :any:`Instance` object with ID 123, you could do this:: loaded_linode = client.load(...
[ "Constructs", "and", "immediately", "loads", "the", "object", "circumventing", "the", "lazy", "-", "loading", "scheme", "by", "immediately", "making", "an", "API", "request", ".", "Does", "not", "load", "related", "objects", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L808-L839
train
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient._api_call
def _api_call(self, endpoint, model=None, method=None, data=None, filters=None): """ Makes a call to the linode api. Data should only be given if the method is POST or PUT, and should be a dictionary """ if not self.token: raise RuntimeError("You do not have an API t...
python
def _api_call(self, endpoint, model=None, method=None, data=None, filters=None): """ Makes a call to the linode api. Data should only be given if the method is POST or PUT, and should be a dictionary """ if not self.token: raise RuntimeError("You do not have an API t...
[ "def", "_api_call", "(", "self", ",", "endpoint", ",", "model", "=", "None", ",", "method", "=", "None", ",", "data", "=", "None", ",", "filters", "=", "None", ")", ":", "if", "not", "self", ".", "token", ":", "raise", "RuntimeError", "(", "\"You do ...
Makes a call to the linode api. Data should only be given if the method is POST or PUT, and should be a dictionary
[ "Makes", "a", "call", "to", "the", "linode", "api", ".", "Data", "should", "only", "be", "given", "if", "the", "method", "is", "POST", "or", "PUT", "and", "should", "be", "a", "dictionary" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L841-L892
train
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient.image_create
def image_create(self, disk, label=None, description=None): """ Creates a new Image from a disk you own. :param disk: The Disk to imagize. :type disk: Disk or int :param label: The label for the resulting Image (defaults to the disk's label. :type l...
python
def image_create(self, disk, label=None, description=None): """ Creates a new Image from a disk you own. :param disk: The Disk to imagize. :type disk: Disk or int :param label: The label for the resulting Image (defaults to the disk's label. :type l...
[ "def", "image_create", "(", "self", ",", "disk", ",", "label", "=", "None", ",", "description", "=", "None", ")", ":", "params", "=", "{", "\"disk_id\"", ":", "disk", ".", "id", "if", "issubclass", "(", "type", "(", "disk", ")", ",", "Base", ")", "...
Creates a new Image from a disk you own. :param disk: The Disk to imagize. :type disk: Disk or int :param label: The label for the resulting Image (defaults to the disk's label. :type label: str :param description: The description for the new Image. ...
[ "Creates", "a", "new", "Image", "from", "a", "disk", "you", "own", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L950-L981
train
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient.nodebalancer_create
def nodebalancer_create(self, region, **kwargs): """ Creates a new NodeBalancer in the given Region. :param region: The Region in which to create the NodeBalancer. :type region: Region or str :returns: The new NodeBalancer :rtype: NodeBalancer """ params...
python
def nodebalancer_create(self, region, **kwargs): """ Creates a new NodeBalancer in the given Region. :param region: The Region in which to create the NodeBalancer. :type region: Region or str :returns: The new NodeBalancer :rtype: NodeBalancer """ params...
[ "def", "nodebalancer_create", "(", "self", ",", "region", ",", "**", "kwargs", ")", ":", "params", "=", "{", "\"region\"", ":", "region", ".", "id", "if", "isinstance", "(", "region", ",", "Base", ")", "else", "region", ",", "}", "params", ".", "update...
Creates a new NodeBalancer in the given Region. :param region: The Region in which to create the NodeBalancer. :type region: Region or str :returns: The new NodeBalancer :rtype: NodeBalancer
[ "Creates", "a", "new", "NodeBalancer", "in", "the", "given", "Region", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L1005-L1026
train
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient.domain_create
def domain_create(self, domain, master=True, **kwargs): """ Registers a new Domain on the acting user's account. Make sure to point your registrar to Linode's nameservers so that Linode's DNS manager will correctly serve your domain. :param domain: The domain to register to Lin...
python
def domain_create(self, domain, master=True, **kwargs): """ Registers a new Domain on the acting user's account. Make sure to point your registrar to Linode's nameservers so that Linode's DNS manager will correctly serve your domain. :param domain: The domain to register to Lin...
[ "def", "domain_create", "(", "self", ",", "domain", ",", "master", "=", "True", ",", "**", "kwargs", ")", ":", "params", "=", "{", "'domain'", ":", "domain", ",", "'type'", ":", "'master'", "if", "master", "else", "'slave'", ",", "}", "params", ".", ...
Registers a new Domain on the acting user's account. Make sure to point your registrar to Linode's nameservers so that Linode's DNS manager will correctly serve your domain. :param domain: The domain to register to Linode's DNS manager. :type domain: str :param master: Whether ...
[ "Registers", "a", "new", "Domain", "on", "the", "acting", "user", "s", "account", ".", "Make", "sure", "to", "point", "your", "registrar", "to", "Linode", "s", "nameservers", "so", "that", "Linode", "s", "DNS", "manager", "will", "correctly", "serve", "you...
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L1028-L1054
train
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient.tag_create
def tag_create(self, label, instances=None, domains=None, nodebalancers=None, volumes=None, entities=[]): """ Creates a new Tag and optionally applies it to the given entities. :param label: The label for the new Tag :type label: str :param entities: A list of...
python
def tag_create(self, label, instances=None, domains=None, nodebalancers=None, volumes=None, entities=[]): """ Creates a new Tag and optionally applies it to the given entities. :param label: The label for the new Tag :type label: str :param entities: A list of...
[ "def", "tag_create", "(", "self", ",", "label", ",", "instances", "=", "None", ",", "domains", "=", "None", ",", "nodebalancers", "=", "None", ",", "volumes", "=", "None", ",", "entities", "=", "[", "]", ")", ":", "linode_ids", ",", "nodebalancer_ids", ...
Creates a new Tag and optionally applies it to the given entities. :param label: The label for the new Tag :type label: str :param entities: A list of objects to apply this Tag to upon creation. May only be taggable types (Linode Instances, Domains, ...
[ "Creates", "a", "new", "Tag", "and", "optionally", "applies", "it", "to", "the", "given", "entities", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L1068-L1143
train
linode/linode_api4-python
linode_api4/linode_client.py
LinodeClient.volume_create
def volume_create(self, label, region=None, linode=None, size=20, **kwargs): """ Creates a new Block Storage Volume, either in the given Region or attached to the given Instance. :param label: The label for the new Volume. :type label: str :param region: The Region to cr...
python
def volume_create(self, label, region=None, linode=None, size=20, **kwargs): """ Creates a new Block Storage Volume, either in the given Region or attached to the given Instance. :param label: The label for the new Volume. :type label: str :param region: The Region to cr...
[ "def", "volume_create", "(", "self", ",", "label", ",", "region", "=", "None", ",", "linode", "=", "None", ",", "size", "=", "20", ",", "**", "kwargs", ")", ":", "if", "not", "(", "region", "or", "linode", ")", ":", "raise", "ValueError", "(", "'re...
Creates a new Block Storage Volume, either in the given Region or attached to the given Instance. :param label: The label for the new Volume. :type label: str :param region: The Region to create this Volume in. Not required if `linode` is provided. :type ...
[ "Creates", "a", "new", "Block", "Storage", "Volume", "either", "in", "the", "given", "Region", "or", "attached", "to", "the", "given", "Instance", "." ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L1156-L1192
train
linode/linode_api4-python
linode_api4/login_client.py
LinodeLoginClient.expire_token
def expire_token(self, token): """ Given a token, makes a request to the authentication server to expire it immediately. This is considered a responsible way to log out a user. If you simply remove the session your application has for the user without expiring their token, the ...
python
def expire_token(self, token): """ Given a token, makes a request to the authentication server to expire it immediately. This is considered a responsible way to log out a user. If you simply remove the session your application has for the user without expiring their token, the ...
[ "def", "expire_token", "(", "self", ",", "token", ")", ":", "r", "=", "requests", ".", "post", "(", "self", ".", "_login_uri", "(", "\"/oauth/token/expire\"", ")", ",", "data", "=", "{", "\"client_id\"", ":", "self", ".", "client_id", ",", "\"client_secret...
Given a token, makes a request to the authentication server to expire it immediately. This is considered a responsible way to log out a user. If you simply remove the session your application has for the user without expiring their token, the user is not _really_ logged out. :param to...
[ "Given", "a", "token", "makes", "a", "request", "to", "the", "authentication", "server", "to", "expire", "it", "immediately", ".", "This", "is", "considered", "a", "responsible", "way", "to", "log", "out", "a", "user", ".", "If", "you", "simply", "remove",...
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/login_client.py#L417-L441
train
linode/linode_api4-python
linode_api4/objects/profile.py
Profile.grants
def grants(self): """ Returns grants for the current user """ from linode_api4.objects.account import UserGrants resp = self._client.get('/profile/grants') # use special endpoint for restricted users grants = None if resp is not None: # if resp is Non...
python
def grants(self): """ Returns grants for the current user """ from linode_api4.objects.account import UserGrants resp = self._client.get('/profile/grants') # use special endpoint for restricted users grants = None if resp is not None: # if resp is Non...
[ "def", "grants", "(", "self", ")", ":", "from", "linode_api4", ".", "objects", ".", "account", "import", "UserGrants", "resp", "=", "self", ".", "_client", ".", "get", "(", "'/profile/grants'", ")", "grants", "=", "None", "if", "resp", "is", "not", "None...
Returns grants for the current user
[ "Returns", "grants", "for", "the", "current", "user" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/profile.py#L91-L103
train
linode/linode_api4-python
linode_api4/objects/profile.py
Profile.add_whitelist_entry
def add_whitelist_entry(self, address, netmask, note=None): """ Adds a new entry to this user's IP whitelist, if enabled """ result = self._client.post("{}/whitelist".format(Profile.api_endpoint), data={ "address": address, "netmask...
python
def add_whitelist_entry(self, address, netmask, note=None): """ Adds a new entry to this user's IP whitelist, if enabled """ result = self._client.post("{}/whitelist".format(Profile.api_endpoint), data={ "address": address, "netmask...
[ "def", "add_whitelist_entry", "(", "self", ",", "address", ",", "netmask", ",", "note", "=", "None", ")", ":", "result", "=", "self", ".", "_client", ".", "post", "(", "\"{}/whitelist\"", ".", "format", "(", "Profile", ".", "api_endpoint", ")", ",", "dat...
Adds a new entry to this user's IP whitelist, if enabled
[ "Adds", "a", "new", "entry", "to", "this", "user", "s", "IP", "whitelist", "if", "enabled" ]
1dd7318d2aed014c746d48c7957464c57af883ca
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/profile.py#L112-L126
train
tmm/django-username-email
cuser/forms.py
AuthenticationForm.confirm_login_allowed
def confirm_login_allowed(self, user): """ Controls whether the given User may log in. This is a policy setting, independent of end-user authentication. This default behavior is to allow login by active users, and reject login by inactive users. If the given user cannot log in, ...
python
def confirm_login_allowed(self, user): """ Controls whether the given User may log in. This is a policy setting, independent of end-user authentication. This default behavior is to allow login by active users, and reject login by inactive users. If the given user cannot log in, ...
[ "def", "confirm_login_allowed", "(", "self", ",", "user", ")", ":", "if", "not", "user", ".", "is_active", ":", "raise", "forms", ".", "ValidationError", "(", "self", ".", "error_messages", "[", "'inactive'", "]", ",", "code", "=", "'inactive'", ",", ")" ]
Controls whether the given User may log in. This is a policy setting, independent of end-user authentication. This default behavior is to allow login by active users, and reject login by inactive users. If the given user cannot log in, this method should raise a ``forms.ValidationError`...
[ "Controls", "whether", "the", "given", "User", "may", "log", "in", ".", "This", "is", "a", "policy", "setting", "independent", "of", "end", "-", "user", "authentication", ".", "This", "default", "behavior", "is", "to", "allow", "login", "by", "active", "us...
36e56bcbf79d46af101ba4c8f4bd848856306329
https://github.com/tmm/django-username-email/blob/36e56bcbf79d46af101ba4c8f4bd848856306329/cuser/forms.py#L68-L83
train
dwavesystems/dwave-system
dwave/embedding/chain_breaks.py
broken_chains
def broken_chains(samples, chains): """Find the broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): ...
python
def broken_chains(samples, chains): """Find the broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): ...
[ "def", "broken_chains", "(", "samples", ",", "chains", ")", ":", "samples", "=", "np", ".", "asarray", "(", "samples", ")", "if", "samples", ".", "ndim", "!=", "2", ":", "raise", "ValueError", "(", "\"expected samples to be a numpy 2D array\"", ")", "num_sampl...
Find the broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): List of chains of length nC where nC...
[ "Find", "the", "broken", "chains", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/chain_breaks.py#L33-L88
train
dwavesystems/dwave-system
dwave/embedding/chain_breaks.py
discard
def discard(samples, chains): """Discard broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): ...
python
def discard(samples, chains): """Discard broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): ...
[ "def", "discard", "(", "samples", ",", "chains", ")", ":", "samples", "=", "np", ".", "asarray", "(", "samples", ")", "if", "samples", ".", "ndim", "!=", "2", ":", "raise", "ValueError", "(", "\"expected samples to be a numpy 2D array\"", ")", "num_samples", ...
Discard broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): List of chains of length nC where nC ...
[ "Discard", "broken", "chains", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/chain_breaks.py#L91-L142
train
dwavesystems/dwave-system
dwave/embedding/chain_breaks.py
majority_vote
def majority_vote(samples, chains): """Use the most common element in broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (li...
python
def majority_vote(samples, chains): """Use the most common element in broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (li...
[ "def", "majority_vote", "(", "samples", ",", "chains", ")", ":", "samples", "=", "np", ".", "asarray", "(", "samples", ")", "if", "samples", ".", "ndim", "!=", "2", ":", "raise", "ValueError", "(", "\"expected samples to be a numpy 2D array\"", ")", "num_sampl...
Use the most common element in broken chains. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): List of chains...
[ "Use", "the", "most", "common", "element", "in", "broken", "chains", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/chain_breaks.py#L145-L206
train
dwavesystems/dwave-system
dwave/embedding/chain_breaks.py
weighted_random
def weighted_random(samples, chains): """Determine the sample values of chains by weighed random choice. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1....
python
def weighted_random(samples, chains): """Determine the sample values of chains by weighed random choice. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1....
[ "def", "weighted_random", "(", "samples", ",", "chains", ")", ":", "samples", "=", "np", ".", "asarray", "(", "samples", ")", "if", "samples", ".", "ndim", "!=", "2", ":", "raise", "ValueError", "(", "\"expected samples to be a numpy 2D array\"", ")", "idx", ...
Determine the sample values of chains by weighed random choice. Args: samples (array_like): Samples as a nS x nV array_like object where nS is the number of samples and nV is the number of variables. The values should all be 0/1 or -1/+1. chains (list[array_like]): ...
[ "Determine", "the", "sample", "values", "of", "chains", "by", "weighed", "random", "choice", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/chain_breaks.py#L209-L256
train
dwavesystems/dwave-system
dwave/system/samplers/dwave_sampler.py
DWaveSampler.validate_anneal_schedule
def validate_anneal_schedule(self, anneal_schedule): """Raise an exception if the specified schedule is invalid for the sampler. Args: anneal_schedule (list): An anneal schedule variation is defined by a series of pairs of floating-point numbers identifying p...
python
def validate_anneal_schedule(self, anneal_schedule): """Raise an exception if the specified schedule is invalid for the sampler. Args: anneal_schedule (list): An anneal schedule variation is defined by a series of pairs of floating-point numbers identifying p...
[ "def", "validate_anneal_schedule", "(", "self", ",", "anneal_schedule", ")", ":", "if", "'anneal_schedule'", "not", "in", "self", ".", "parameters", ":", "raise", "RuntimeError", "(", "\"anneal_schedule is not an accepted parameter for this sampler\"", ")", "properties", ...
Raise an exception if the specified schedule is invalid for the sampler. Args: anneal_schedule (list): An anneal schedule variation is defined by a series of pairs of floating-point numbers identifying points in the schedule at which to change slope. The first ...
[ "Raise", "an", "exception", "if", "the", "specified", "schedule", "is", "invalid", "for", "the", "sampler", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/samplers/dwave_sampler.py#L318-L412
train
dwavesystems/dwave-system
dwave/embedding/utils.py
target_to_source
def target_to_source(target_adjacency, embedding): """Derive the source adjacency from an embedding and target adjacency. Args: target_adjacency (dict/:class:`networkx.Graph`): A dict of the form {v: Nv, ...} where v is a node in the target graph and Nv is the neighbors of v as ...
python
def target_to_source(target_adjacency, embedding): """Derive the source adjacency from an embedding and target adjacency. Args: target_adjacency (dict/:class:`networkx.Graph`): A dict of the form {v: Nv, ...} where v is a node in the target graph and Nv is the neighbors of v as ...
[ "def", "target_to_source", "(", "target_adjacency", ",", "embedding", ")", ":", "source_adjacency", "=", "{", "v", ":", "set", "(", ")", "for", "v", "in", "embedding", "}", "reverse_embedding", "=", "{", "}", "for", "v", ",", "chain", "in", "iteritems", ...
Derive the source adjacency from an embedding and target adjacency. Args: target_adjacency (dict/:class:`networkx.Graph`): A dict of the form {v: Nv, ...} where v is a node in the target graph and Nv is the neighbors of v as an iterable. This can also be a networkx graph. e...
[ "Derive", "the", "source", "adjacency", "from", "an", "embedding", "and", "target", "adjacency", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/utils.py#L30-L95
train
dwavesystems/dwave-system
dwave/embedding/utils.py
chain_to_quadratic
def chain_to_quadratic(chain, target_adjacency, chain_strength): """Determine the quadratic biases that induce the given chain. Args: chain (iterable): The variables that make up a chain. target_adjacency (dict/:class:`networkx.Graph`): Should be a dict of the form {s: ...
python
def chain_to_quadratic(chain, target_adjacency, chain_strength): """Determine the quadratic biases that induce the given chain. Args: chain (iterable): The variables that make up a chain. target_adjacency (dict/:class:`networkx.Graph`): Should be a dict of the form {s: ...
[ "def", "chain_to_quadratic", "(", "chain", ",", "target_adjacency", ",", "chain_strength", ")", ":", "quadratic", "=", "{", "}", "seen", "=", "set", "(", ")", "try", ":", "next_level", "=", "{", "next", "(", "iter", "(", "chain", ")", ")", "}", "except...
Determine the quadratic biases that induce the given chain. Args: chain (iterable): The variables that make up a chain. target_adjacency (dict/:class:`networkx.Graph`): Should be a dict of the form {s: Ns, ...} where s is a variable in the target graph and Ns is...
[ "Determine", "the", "quadratic", "biases", "that", "induce", "the", "given", "chain", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/utils.py#L98-L150
train
dwavesystems/dwave-system
dwave/embedding/utils.py
chain_break_frequency
def chain_break_frequency(samples_like, embedding): """Determine the frequency of chain breaks in the given samples. Args: samples_like (samples_like/:obj:`dimod.SampleSet`): A collection of raw samples. 'samples_like' is an extension of NumPy's array_like. See :func:`dimod.as_s...
python
def chain_break_frequency(samples_like, embedding): """Determine the frequency of chain breaks in the given samples. Args: samples_like (samples_like/:obj:`dimod.SampleSet`): A collection of raw samples. 'samples_like' is an extension of NumPy's array_like. See :func:`dimod.as_s...
[ "def", "chain_break_frequency", "(", "samples_like", ",", "embedding", ")", ":", "if", "isinstance", "(", "samples_like", ",", "dimod", ".", "SampleSet", ")", ":", "labels", "=", "samples_like", ".", "variables", "samples", "=", "samples_like", ".", "record", ...
Determine the frequency of chain breaks in the given samples. Args: samples_like (samples_like/:obj:`dimod.SampleSet`): A collection of raw samples. 'samples_like' is an extension of NumPy's array_like. See :func:`dimod.as_samples`. embedding (dict): Mapping fro...
[ "Determine", "the", "frequency", "of", "chain", "breaks", "in", "the", "given", "samples", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/utils.py#L153-L216
train
dwavesystems/dwave-system
dwave/embedding/utils.py
edgelist_to_adjacency
def edgelist_to_adjacency(edgelist): """Converts an iterator of edges to an adjacency dict. Args: edgelist (iterable): An iterator over 2-tuples where each 2-tuple is an edge. Returns: dict: The adjacency dict. A dict of the form {v: Nv, ...} where v is a node in a graph and ...
python
def edgelist_to_adjacency(edgelist): """Converts an iterator of edges to an adjacency dict. Args: edgelist (iterable): An iterator over 2-tuples where each 2-tuple is an edge. Returns: dict: The adjacency dict. A dict of the form {v: Nv, ...} where v is a node in a graph and ...
[ "def", "edgelist_to_adjacency", "(", "edgelist", ")", ":", "adjacency", "=", "dict", "(", ")", "for", "u", ",", "v", "in", "edgelist", ":", "if", "u", "in", "adjacency", ":", "adjacency", "[", "u", "]", ".", "add", "(", "v", ")", "else", ":", "adja...
Converts an iterator of edges to an adjacency dict. Args: edgelist (iterable): An iterator over 2-tuples where each 2-tuple is an edge. Returns: dict: The adjacency dict. A dict of the form {v: Nv, ...} where v is a node in a graph and Nv is the neighbors of v as an set.
[ "Converts", "an", "iterator", "of", "edges", "to", "an", "adjacency", "dict", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/utils.py#L219-L241
train
dwavesystems/dwave-system
dwave/system/composites/tiling.py
TilingComposite.sample
def sample(self, bqm, **kwargs): """Sample from the specified binary quadratic model. Args: bqm (:obj:`dimod.BinaryQuadraticModel`): Binary quadratic model to be sampled from. **kwargs: Optional keyword arguments for the sampling method, specifie...
python
def sample(self, bqm, **kwargs): """Sample from the specified binary quadratic model. Args: bqm (:obj:`dimod.BinaryQuadraticModel`): Binary quadratic model to be sampled from. **kwargs: Optional keyword arguments for the sampling method, specifie...
[ "def", "sample", "(", "self", ",", "bqm", ",", "**", "kwargs", ")", ":", "embedded_bqm", "=", "dimod", ".", "BinaryQuadraticModel", ".", "empty", "(", "bqm", ".", "vartype", ")", "__", ",", "__", ",", "target_adjacency", "=", "self", ".", "child", ".",...
Sample from the specified binary quadratic model. Args: bqm (:obj:`dimod.BinaryQuadraticModel`): Binary quadratic model to be sampled from. **kwargs: Optional keyword arguments for the sampling method, specified per solver. Returns: ...
[ "Sample", "from", "the", "specified", "binary", "quadratic", "model", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/tiling.py#L199-L250
train
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
cache_connect
def cache_connect(database=None): """Returns a connection object to a sqlite database. Args: database (str, optional): The path to the database the user wishes to connect to. If not specified, a default is chosen using :func:`.cache_file`. If the special database name ':memory:'...
python
def cache_connect(database=None): """Returns a connection object to a sqlite database. Args: database (str, optional): The path to the database the user wishes to connect to. If not specified, a default is chosen using :func:`.cache_file`. If the special database name ':memory:'...
[ "def", "cache_connect", "(", "database", "=", "None", ")", ":", "if", "database", "is", "None", ":", "database", "=", "cache_file", "(", ")", "if", "os", ".", "path", ".", "isfile", "(", "database", ")", ":", "conn", "=", "sqlite3", ".", "connect", "...
Returns a connection object to a sqlite database. Args: database (str, optional): The path to the database the user wishes to connect to. If not specified, a default is chosen using :func:`.cache_file`. If the special database name ':memory:' is given, then a temporary d...
[ "Returns", "a", "connection", "object", "to", "a", "sqlite", "database", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L37-L67
train
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
insert_chain
def insert_chain(cur, chain, encoded_data=None): """Insert a chain into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chain (iterable): A collection of nodes. Chains in embedding act a...
python
def insert_chain(cur, chain, encoded_data=None): """Insert a chain into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chain (iterable): A collection of nodes. Chains in embedding act a...
[ "def", "insert_chain", "(", "cur", ",", "chain", ",", "encoded_data", "=", "None", ")", ":", "if", "encoded_data", "is", "None", ":", "encoded_data", "=", "{", "}", "if", "'nodes'", "not", "in", "encoded_data", ":", "encoded_data", "[", "'nodes'", "]", "...
Insert a chain into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chain (iterable): A collection of nodes. Chains in embedding act as one node. encoded_data (dict, optional): ...
[ "Insert", "a", "chain", "into", "the", "cache", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L70-L98
train
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
iter_chain
def iter_chain(cur): """Iterate over all of the chains in the database. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: list: The chain. """ select = "SELECT nodes FROM chain" for node...
python
def iter_chain(cur): """Iterate over all of the chains in the database. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: list: The chain. """ select = "SELECT nodes FROM chain" for node...
[ "def", "iter_chain", "(", "cur", ")", ":", "select", "=", "\"SELECT nodes FROM chain\"", "for", "nodes", ",", "in", "cur", ".", "execute", "(", "select", ")", ":", "yield", "json", ".", "loads", "(", "nodes", ")" ]
Iterate over all of the chains in the database. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: list: The chain.
[ "Iterate", "over", "all", "of", "the", "chains", "in", "the", "database", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L101-L114
train
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
insert_system
def insert_system(cur, system_name, encoded_data=None): """Insert a system name into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. system_name (str): The unique name of a system ...
python
def insert_system(cur, system_name, encoded_data=None): """Insert a system name into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. system_name (str): The unique name of a system ...
[ "def", "insert_system", "(", "cur", ",", "system_name", ",", "encoded_data", "=", "None", ")", ":", "if", "encoded_data", "is", "None", ":", "encoded_data", "=", "{", "}", "if", "'system_name'", "not", "in", "encoded_data", ":", "encoded_data", "[", "'system...
Insert a system name into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. system_name (str): The unique name of a system encoded_data (dict, optional): If a dictionary i...
[ "Insert", "a", "system", "name", "into", "the", "cache", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L117-L139
train
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
insert_flux_bias
def insert_flux_bias(cur, chain, system, flux_bias, chain_strength, encoded_data=None): """Insert a flux bias offset into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chain (iterable): ...
python
def insert_flux_bias(cur, chain, system, flux_bias, chain_strength, encoded_data=None): """Insert a flux bias offset into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chain (iterable): ...
[ "def", "insert_flux_bias", "(", "cur", ",", "chain", ",", "system", ",", "flux_bias", ",", "chain_strength", ",", "encoded_data", "=", "None", ")", ":", "if", "encoded_data", "is", "None", ":", "encoded_data", "=", "{", "}", "insert_chain", "(", "cur", ","...
Insert a flux bias offset into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chain (iterable): A collection of nodes. Chains in embedding act as one node. system (str): ...
[ "Insert", "a", "flux", "bias", "offset", "into", "the", "cache", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L158-L212
train
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
get_flux_biases_from_cache
def get_flux_biases_from_cache(cur, chains, system_name, chain_strength, max_age=3600): """Determine the flux biases for all of the the given chains, system and chain strength. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` stat...
python
def get_flux_biases_from_cache(cur, chains, system_name, chain_strength, max_age=3600): """Determine the flux biases for all of the the given chains, system and chain strength. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` stat...
[ "def", "get_flux_biases_from_cache", "(", "cur", ",", "chains", ",", "system_name", ",", "chain_strength", ",", "max_age", "=", "3600", ")", ":", "select", "=", "encoded_data", "=", "{", "'chain_strength'", ":", "_encode_real", "(", "chain_strength", ")", ",", ...
Determine the flux biases for all of the the given chains, system and chain strength. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. chains (iterable): An iterable of chains. Each chain is a collectio...
[ "Determine", "the", "flux", "biases", "for", "all", "of", "the", "the", "given", "chains", "system", "and", "chain", "strength", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L255-L312
train
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
insert_graph
def insert_graph(cur, nodelist, edgelist, encoded_data=None): """Insert a graph into the cache. A graph is stored by number of nodes, number of edges and a json-encoded list of edges. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a ...
python
def insert_graph(cur, nodelist, edgelist, encoded_data=None): """Insert a graph into the cache. A graph is stored by number of nodes, number of edges and a json-encoded list of edges. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a ...
[ "def", "insert_graph", "(", "cur", ",", "nodelist", ",", "edgelist", ",", "encoded_data", "=", "None", ")", ":", "if", "encoded_data", "is", "None", ":", "encoded_data", "=", "{", "}", "if", "'num_nodes'", "not", "in", "encoded_data", ":", "encoded_data", ...
Insert a graph into the cache. A graph is stored by number of nodes, number of edges and a json-encoded list of edges. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. nodelist (list): The nodes in the grap...
[ "Insert", "a", "graph", "into", "the", "cache", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L315-L372
train
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
select_embedding_from_tag
def select_embedding_from_tag(cur, embedding_tag, target_nodelist, target_edgelist): """Select an embedding from the given tag and target graph. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. source_nodelist ...
python
def select_embedding_from_tag(cur, embedding_tag, target_nodelist, target_edgelist): """Select an embedding from the given tag and target graph. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. source_nodelist ...
[ "def", "select_embedding_from_tag", "(", "cur", ",", "embedding_tag", ",", "target_nodelist", ",", "target_edgelist", ")", ":", "encoded_data", "=", "{", "'num_nodes'", ":", "len", "(", "target_nodelist", ")", ",", "'num_edges'", ":", "len", "(", "target_edgelist"...
Select an embedding from the given tag and target graph. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. source_nodelist (list): The nodes in the source graph. Should be integer valued. source...
[ "Select", "an", "embedding", "from", "the", "given", "tag", "and", "target", "graph", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L512-L557
train
dwavesystems/dwave-system
dwave/system/cache/database_manager.py
select_embedding_from_source
def select_embedding_from_source(cur, source_nodelist, source_edgelist, target_nodelist, target_edgelist): """Select an embedding from the source graph and target graph. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run...
python
def select_embedding_from_source(cur, source_nodelist, source_edgelist, target_nodelist, target_edgelist): """Select an embedding from the source graph and target graph. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run...
[ "def", "select_embedding_from_source", "(", "cur", ",", "source_nodelist", ",", "source_edgelist", ",", "target_nodelist", ",", "target_edgelist", ")", ":", "encoded_data", "=", "{", "'target_num_nodes'", ":", "len", "(", "target_nodelist", ")", ",", "'target_num_edge...
Select an embedding from the source graph and target graph. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. target_nodelist (list): The nodes in the target graph. Should be integer valued. tar...
[ "Select", "an", "embedding", "from", "the", "source", "graph", "and", "target", "graph", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/cache/database_manager.py#L560-L608
train
dwavesystems/dwave-system
dwave/embedding/drawing.py
draw_chimera_bqm
def draw_chimera_bqm(bqm, width=None, height=None): """Draws a Chimera Graph representation of a Binary Quadratic Model. If cell width and height not provided assumes square cell dimensions. Throws an error if drawing onto a Chimera graph of the given dimensions fails. Args: bqm (:obj:`dimod.B...
python
def draw_chimera_bqm(bqm, width=None, height=None): """Draws a Chimera Graph representation of a Binary Quadratic Model. If cell width and height not provided assumes square cell dimensions. Throws an error if drawing onto a Chimera graph of the given dimensions fails. Args: bqm (:obj:`dimod.B...
[ "def", "draw_chimera_bqm", "(", "bqm", ",", "width", "=", "None", ",", "height", "=", "None", ")", ":", "linear", "=", "bqm", ".", "linear", ".", "keys", "(", ")", "quadratic", "=", "bqm", ".", "quadratic", ".", "keys", "(", ")", "if", "width", "is...
Draws a Chimera Graph representation of a Binary Quadratic Model. If cell width and height not provided assumes square cell dimensions. Throws an error if drawing onto a Chimera graph of the given dimensions fails. Args: bqm (:obj:`dimod.BinaryQuadraticModel`): Should be equivalent to ...
[ "Draws", "a", "Chimera", "Graph", "representation", "of", "a", "Binary", "Quadratic", "Model", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/drawing.py#L23-L104
train
dwavesystems/dwave-system
dwave/embedding/transforms.py
embed_bqm
def embed_bqm(source_bqm, embedding, target_adjacency, chain_strength=1.0, smear_vartype=None): """Embed a binary quadratic model onto a target graph. Args: source_bqm (:obj:`.BinaryQuadraticModel`): Binary quadratic model to embed. embedding (dict): Mappi...
python
def embed_bqm(source_bqm, embedding, target_adjacency, chain_strength=1.0, smear_vartype=None): """Embed a binary quadratic model onto a target graph. Args: source_bqm (:obj:`.BinaryQuadraticModel`): Binary quadratic model to embed. embedding (dict): Mappi...
[ "def", "embed_bqm", "(", "source_bqm", ",", "embedding", ",", "target_adjacency", ",", "chain_strength", "=", "1.0", ",", "smear_vartype", "=", "None", ")", ":", "if", "smear_vartype", "is", "dimod", ".", "SPIN", "and", "source_bqm", ".", "vartype", "is", "d...
Embed a binary quadratic model onto a target graph. Args: source_bqm (:obj:`.BinaryQuadraticModel`): Binary quadratic model to embed. embedding (dict): Mapping from source graph to target graph as a dict of form {s: {t, ...}, ...}, where s is a source-model vari...
[ "Embed", "a", "binary", "quadratic", "model", "onto", "a", "target", "graph", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/transforms.py#L38-L168
train
dwavesystems/dwave-system
dwave/embedding/transforms.py
embed_ising
def embed_ising(source_h, source_J, embedding, target_adjacency, chain_strength=1.0): """Embed an Ising problem onto a target graph. Args: source_h (dict[variable, bias]/list[bias]): Linear biases of the Ising problem. If a list, the list's indices are used as variable labels. ...
python
def embed_ising(source_h, source_J, embedding, target_adjacency, chain_strength=1.0): """Embed an Ising problem onto a target graph. Args: source_h (dict[variable, bias]/list[bias]): Linear biases of the Ising problem. If a list, the list's indices are used as variable labels. ...
[ "def", "embed_ising", "(", "source_h", ",", "source_J", ",", "embedding", ",", "target_adjacency", ",", "chain_strength", "=", "1.0", ")", ":", "source_bqm", "=", "dimod", ".", "BinaryQuadraticModel", ".", "from_ising", "(", "source_h", ",", "source_J", ")", "...
Embed an Ising problem onto a target graph. Args: source_h (dict[variable, bias]/list[bias]): Linear biases of the Ising problem. If a list, the list's indices are used as variable labels. source_J (dict[(variable, variable), bias]): Quadratic biases of the Isin...
[ "Embed", "an", "Ising", "problem", "onto", "a", "target", "graph", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/transforms.py#L171-L250
train
dwavesystems/dwave-system
dwave/embedding/transforms.py
embed_qubo
def embed_qubo(source_Q, embedding, target_adjacency, chain_strength=1.0): """Embed a QUBO onto a target graph. Args: source_Q (dict[(variable, variable), bias]): Coefficients of a quadratic unconstrained binary optimization (QUBO) model. embedding (dict): Mapping from ...
python
def embed_qubo(source_Q, embedding, target_adjacency, chain_strength=1.0): """Embed a QUBO onto a target graph. Args: source_Q (dict[(variable, variable), bias]): Coefficients of a quadratic unconstrained binary optimization (QUBO) model. embedding (dict): Mapping from ...
[ "def", "embed_qubo", "(", "source_Q", ",", "embedding", ",", "target_adjacency", ",", "chain_strength", "=", "1.0", ")", ":", "source_bqm", "=", "dimod", ".", "BinaryQuadraticModel", ".", "from_qubo", "(", "source_Q", ")", "target_bqm", "=", "embed_bqm", "(", ...
Embed a QUBO onto a target graph. Args: source_Q (dict[(variable, variable), bias]): Coefficients of a quadratic unconstrained binary optimization (QUBO) model. embedding (dict): Mapping from source graph to target graph as a dict of form {s: {t, ...}, ...}, whe...
[ "Embed", "a", "QUBO", "onto", "a", "target", "graph", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/transforms.py#L253-L343
train
dwavesystems/dwave-system
dwave/embedding/transforms.py
unembed_sampleset
def unembed_sampleset(target_sampleset, embedding, source_bqm, chain_break_method=None, chain_break_fraction=False): """Unembed the samples set. Construct a sample set for the source binary quadratic model (BQM) by unembedding the given samples from the target BQM. Args: ...
python
def unembed_sampleset(target_sampleset, embedding, source_bqm, chain_break_method=None, chain_break_fraction=False): """Unembed the samples set. Construct a sample set for the source binary quadratic model (BQM) by unembedding the given samples from the target BQM. Args: ...
[ "def", "unembed_sampleset", "(", "target_sampleset", ",", "embedding", ",", "source_bqm", ",", "chain_break_method", "=", "None", ",", "chain_break_fraction", "=", "False", ")", ":", "if", "chain_break_method", "is", "None", ":", "chain_break_method", "=", "majority...
Unembed the samples set. Construct a sample set for the source binary quadratic model (BQM) by unembedding the given samples from the target BQM. Args: target_sampleset (:obj:`dimod.SampleSet`): SampleSet from the target BQM. embedding (dict): Mapping from source g...
[ "Unembed", "the", "samples", "set", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/transforms.py#L346-L441
train
dwavesystems/dwave-system
dwave/system/composites/embedding.py
LazyFixedEmbeddingComposite.sample
def sample(self, bqm, chain_strength=1.0, chain_break_fraction=True, **parameters): """Sample the binary quadratic model. Note: At the initial sample(..) call, it will find a suitable embedding and initialize the remaining attributes before sampling the bqm. All following sample(..) calls will ...
python
def sample(self, bqm, chain_strength=1.0, chain_break_fraction=True, **parameters): """Sample the binary quadratic model. Note: At the initial sample(..) call, it will find a suitable embedding and initialize the remaining attributes before sampling the bqm. All following sample(..) calls will ...
[ "def", "sample", "(", "self", ",", "bqm", ",", "chain_strength", "=", "1.0", ",", "chain_break_fraction", "=", "True", ",", "**", "parameters", ")", ":", "if", "self", ".", "embedding", "is", "None", ":", "child", "=", "self", ".", "child", "__", ",", ...
Sample the binary quadratic model. Note: At the initial sample(..) call, it will find a suitable embedding and initialize the remaining attributes before sampling the bqm. All following sample(..) calls will reuse that initial embedding. Args: bqm (:obj:`dimod.BinaryQuadraticModel`...
[ "Sample", "the", "binary", "quadratic", "model", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/embedding.py#L461-L495
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
_accumulate_random
def _accumulate_random(count, found, oldthing, newthing): """This performs on-line random selection. We have a stream of objects o_1,c_1; o_2,c_2; ... where there are c_i equivalent objects like o_1. We'd like to pick a random object o uniformly at random from the list [o_1]*c_1 + [...
python
def _accumulate_random(count, found, oldthing, newthing): """This performs on-line random selection. We have a stream of objects o_1,c_1; o_2,c_2; ... where there are c_i equivalent objects like o_1. We'd like to pick a random object o uniformly at random from the list [o_1]*c_1 + [...
[ "def", "_accumulate_random", "(", "count", ",", "found", ",", "oldthing", ",", "newthing", ")", ":", "if", "randint", "(", "1", ",", "count", "+", "found", ")", "<=", "found", ":", "return", "count", "+", "found", ",", "newthing", "else", ":", "return"...
This performs on-line random selection. We have a stream of objects o_1,c_1; o_2,c_2; ... where there are c_i equivalent objects like o_1. We'd like to pick a random object o uniformly at random from the list [o_1]*c_1 + [o_2]*c_2 + ... (actually, this algorithm allows arbitrary po...
[ "This", "performs", "on", "-", "line", "random", "selection", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L60-L108
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
_bulk_to_linear
def _bulk_to_linear(M, N, L, qubits): "Converts a list of chimera coordinates to linear indices." return [2 * L * N * x + 2 * L * y + L * u + k for x, y, u, k in qubits]
python
def _bulk_to_linear(M, N, L, qubits): "Converts a list of chimera coordinates to linear indices." return [2 * L * N * x + 2 * L * y + L * u + k for x, y, u, k in qubits]
[ "def", "_bulk_to_linear", "(", "M", ",", "N", ",", "L", ",", "qubits", ")", ":", "\"Converts a list of chimera coordinates to linear indices.\"", "return", "[", "2", "*", "L", "*", "N", "*", "x", "+", "2", "*", "L", "*", "y", "+", "L", "*", "u", "+", ...
Converts a list of chimera coordinates to linear indices.
[ "Converts", "a", "list", "of", "chimera", "coordinates", "to", "linear", "indices", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1161-L1163
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
_to_linear
def _to_linear(M, N, L, q): "Converts a qubit in chimera coordinates to its linear index." (x, y, u, k) = q return 2 * L * N * x + 2 * L * y + L * u + k
python
def _to_linear(M, N, L, q): "Converts a qubit in chimera coordinates to its linear index." (x, y, u, k) = q return 2 * L * N * x + 2 * L * y + L * u + k
[ "def", "_to_linear", "(", "M", ",", "N", ",", "L", ",", "q", ")", ":", "\"Converts a qubit in chimera coordinates to its linear index.\"", "(", "x", ",", "y", ",", "u", ",", "k", ")", "=", "q", "return", "2", "*", "L", "*", "N", "*", "x", "+", "2", ...
Converts a qubit in chimera coordinates to its linear index.
[ "Converts", "a", "qubit", "in", "chimera", "coordinates", "to", "its", "linear", "index", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1166-L1169
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
_bulk_to_chimera
def _bulk_to_chimera(M, N, L, qubits): "Converts a list of linear indices to chimera coordinates." return [(q // N // L // 2, (q // L // 2) % N, (q // L) % 2, q % L) for q in qubits]
python
def _bulk_to_chimera(M, N, L, qubits): "Converts a list of linear indices to chimera coordinates." return [(q // N // L // 2, (q // L // 2) % N, (q // L) % 2, q % L) for q in qubits]
[ "def", "_bulk_to_chimera", "(", "M", ",", "N", ",", "L", ",", "qubits", ")", ":", "\"Converts a list of linear indices to chimera coordinates.\"", "return", "[", "(", "q", "//", "N", "//", "L", "//", "2", ",", "(", "q", "//", "L", "//", "2", ")", "%", ...
Converts a list of linear indices to chimera coordinates.
[ "Converts", "a", "list", "of", "linear", "indices", "to", "chimera", "coordinates", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1172-L1174
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
_to_chimera
def _to_chimera(M, N, L, q): "Converts a qubit's linear index to chimera coordinates." return (q // N // L // 2, (q // L // 2) % N, (q // L) % 2, q % L)
python
def _to_chimera(M, N, L, q): "Converts a qubit's linear index to chimera coordinates." return (q // N // L // 2, (q // L // 2) % N, (q // L) % 2, q % L)
[ "def", "_to_chimera", "(", "M", ",", "N", ",", "L", ",", "q", ")", ":", "\"Converts a qubit's linear index to chimera coordinates.\"", "return", "(", "q", "//", "N", "//", "L", "//", "2", ",", "(", "q", "//", "L", "//", "2", ")", "%", "N", ",", "(", ...
Converts a qubit's linear index to chimera coordinates.
[ "Converts", "a", "qubit", "s", "linear", "index", "to", "chimera", "coordinates", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1177-L1179
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor._compute_vline_scores
def _compute_vline_scores(self): """Does the hard work to prepare ``vline_score``. """ M, N, L = self.M, self.N, self.L vline_score = {} for x in range(M): laststart = [0 if (x, 0, 1, k) in self else None for k in range(L)] for y in range(N): ...
python
def _compute_vline_scores(self): """Does the hard work to prepare ``vline_score``. """ M, N, L = self.M, self.N, self.L vline_score = {} for x in range(M): laststart = [0 if (x, 0, 1, k) in self else None for k in range(L)] for y in range(N): ...
[ "def", "_compute_vline_scores", "(", "self", ")", ":", "M", ",", "N", ",", "L", "=", "self", ".", "M", ",", "self", ".", "N", ",", "self", ".", "L", "vline_score", "=", "{", "}", "for", "x", "in", "range", "(", "M", ")", ":", "laststart", "=", ...
Does the hard work to prepare ``vline_score``.
[ "Does", "the", "hard", "work", "to", "prepare", "vline_score", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L188-L210
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor._compute_hline_scores
def _compute_hline_scores(self): """Does the hard work to prepare ``hline_score``. """ M, N, L = self.M, self.N, self.L hline_score = {} for y in range(N): laststart = [0 if (0, y, 0, k) in self else None for k in range(L)] for x in range(M): ...
python
def _compute_hline_scores(self): """Does the hard work to prepare ``hline_score``. """ M, N, L = self.M, self.N, self.L hline_score = {} for y in range(N): laststart = [0 if (0, y, 0, k) in self else None for k in range(L)] for x in range(M): ...
[ "def", "_compute_hline_scores", "(", "self", ")", ":", "M", ",", "N", ",", "L", "=", "self", ".", "M", ",", "self", ".", "N", ",", "self", ".", "L", "hline_score", "=", "{", "}", "for", "y", "in", "range", "(", "N", ")", ":", "laststart", "=", ...
Does the hard work to prepare ``hline_score``.
[ "Does", "the", "hard", "work", "to", "prepare", "hline_score", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L212-L234
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.biclique
def biclique(self, xmin, xmax, ymin, ymax): """Compute a maximum-sized complete bipartite graph contained in the rectangle defined by ``xmin, xmax, ymin, ymax`` where each chain of qubits is either a vertical line or a horizontal line. INPUTS: xmin,xmax,ymin,ymax: integers d...
python
def biclique(self, xmin, xmax, ymin, ymax): """Compute a maximum-sized complete bipartite graph contained in the rectangle defined by ``xmin, xmax, ymin, ymax`` where each chain of qubits is either a vertical line or a horizontal line. INPUTS: xmin,xmax,ymin,ymax: integers d...
[ "def", "biclique", "(", "self", ",", "xmin", ",", "xmax", ",", "ymin", ",", "ymax", ")", ":", "Aside", "=", "sum", "(", "(", "self", ".", "maximum_hline_bundle", "(", "y", ",", "xmin", ",", "xmax", ")", "for", "y", "in", "range", "(", "ymin", ","...
Compute a maximum-sized complete bipartite graph contained in the rectangle defined by ``xmin, xmax, ymin, ymax`` where each chain of qubits is either a vertical line or a horizontal line. INPUTS: xmin,xmax,ymin,ymax: integers defining the bounds of a rectangle where we ...
[ "Compute", "a", "maximum", "-", "sized", "complete", "bipartite", "graph", "contained", "in", "the", "rectangle", "defined", "by", "xmin", "xmax", "ymin", "ymax", "where", "each", "chain", "of", "qubits", "is", "either", "a", "vertical", "line", "or", "a", ...
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L291-L319
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor._contains_line
def _contains_line(self, line): """Test if a chain of qubits is completely contained in ``self``. In particular, test if all qubits are present and the couplers connecting those qubits are also connected. NOTE: this function assumes that ``line`` is a list or tuple of qubits wh...
python
def _contains_line(self, line): """Test if a chain of qubits is completely contained in ``self``. In particular, test if all qubits are present and the couplers connecting those qubits are also connected. NOTE: this function assumes that ``line`` is a list or tuple of qubits wh...
[ "def", "_contains_line", "(", "self", ",", "line", ")", ":", "return", "all", "(", "v", "in", "self", "for", "v", "in", "line", ")", "and", "all", "(", "u", "in", "self", "[", "v", "]", "for", "u", ",", "v", "in", "zip", "(", "line", ",", "li...
Test if a chain of qubits is completely contained in ``self``. In particular, test if all qubits are present and the couplers connecting those qubits are also connected. NOTE: this function assumes that ``line`` is a list or tuple of qubits which satisfies the precondition that ``(line...
[ "Test", "if", "a", "chain", "of", "qubits", "is", "completely", "contained", "in", "self", ".", "In", "particular", "test", "if", "all", "qubits", "are", "present", "and", "the", "couplers", "connecting", "those", "qubits", "are", "also", "connected", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L322-L337
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.maximum_ell_bundle
def maximum_ell_bundle(self, ell): """Return a maximum ell bundle in the rectangle bounded by :math:`\{x0,x1\} \\times \{y0,y1\}` with vertical component :math:`(x0,y0) ... (x0,y1) = {x0} \\times \{y0,...,y1\}` and horizontal component :math:`(x0,y0) ... ...
python
def maximum_ell_bundle(self, ell): """Return a maximum ell bundle in the rectangle bounded by :math:`\{x0,x1\} \\times \{y0,y1\}` with vertical component :math:`(x0,y0) ... (x0,y1) = {x0} \\times \{y0,...,y1\}` and horizontal component :math:`(x0,y0) ... ...
[ "def", "maximum_ell_bundle", "(", "self", ",", "ell", ")", ":", "(", "x0", ",", "x1", ",", "y0", ",", "y1", ")", "=", "ell", "hlines", "=", "self", ".", "maximum_hline_bundle", "(", "y0", ",", "x0", ",", "x1", ")", "vlines", "=", "self", ".", "ma...
Return a maximum ell bundle in the rectangle bounded by :math:`\{x0,x1\} \\times \{y0,y1\}` with vertical component :math:`(x0,y0) ... (x0,y1) = {x0} \\times \{y0,...,y1\}` and horizontal component :math:`(x0,y0) ... (x1,y0) = \{x0,...,x1\} \\times \{y0\}`. ...
[ "Return", "a", "maximum", "ell", "bundle", "in", "the", "rectangle", "bounded", "by" ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L368-L409
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
eden_processor.nativeCliqueEmbed
def nativeCliqueEmbed(self, width): """Compute a maximum-sized native clique embedding in an induced subgraph of chimera with all chainlengths ``width+1``. INPUTS: width: width of the squares to search, also `chainlength`-1 OUTPUT: score: the score for the retur...
python
def nativeCliqueEmbed(self, width): """Compute a maximum-sized native clique embedding in an induced subgraph of chimera with all chainlengths ``width+1``. INPUTS: width: width of the squares to search, also `chainlength`-1 OUTPUT: score: the score for the retur...
[ "def", "nativeCliqueEmbed", "(", "self", ",", "width", ")", ":", "maxCWR", "=", "{", "}", "M", ",", "N", "=", "self", ".", "M", ",", "self", ".", "N", "maxscore", "=", "None", "count", "=", "0", "key", "=", "None", "for", "w", "in", "range", "(...
Compute a maximum-sized native clique embedding in an induced subgraph of chimera with all chainlengths ``width+1``. INPUTS: width: width of the squares to search, also `chainlength`-1 OUTPUT: score: the score for the returned clique (just ``len(clique)`` in...
[ "Compute", "a", "maximum", "-", "sized", "native", "clique", "embedding", "in", "an", "induced", "subgraph", "of", "chimera", "with", "all", "chainlengths", "width", "+", "1", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L496-L544
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._compute_all_deletions
def _compute_all_deletions(self): """Returns all minimal edge covers of the set of evil edges. """ minimum_evil = [] for disabled_qubits in map(set, product(*self._evil)): newmin = [] for s in minimum_evil: if s < disabled_qubits: ...
python
def _compute_all_deletions(self): """Returns all minimal edge covers of the set of evil edges. """ minimum_evil = [] for disabled_qubits in map(set, product(*self._evil)): newmin = [] for s in minimum_evil: if s < disabled_qubits: ...
[ "def", "_compute_all_deletions", "(", "self", ")", ":", "minimum_evil", "=", "[", "]", "for", "disabled_qubits", "in", "map", "(", "set", ",", "product", "(", "*", "self", ".", "_evil", ")", ")", ":", "newmin", "=", "[", "]", "for", "s", "in", "minim...
Returns all minimal edge covers of the set of evil edges.
[ "Returns", "all", "minimal", "edge", "covers", "of", "the", "set", "of", "evil", "edges", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L810-L824
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._compute_deletions
def _compute_deletions(self): """If there are fewer than self._proc_limit possible deletion sets, compute all subprocessors obtained by deleting a minimal subset of qubits. """ M, N, L, edgelist = self.M, self.N, self.L, self._edgelist if 2**len(self._evil) <= self._proc_...
python
def _compute_deletions(self): """If there are fewer than self._proc_limit possible deletion sets, compute all subprocessors obtained by deleting a minimal subset of qubits. """ M, N, L, edgelist = self.M, self.N, self.L, self._edgelist if 2**len(self._evil) <= self._proc_...
[ "def", "_compute_deletions", "(", "self", ")", ":", "M", ",", "N", ",", "L", ",", "edgelist", "=", "self", ".", "M", ",", "self", ".", "N", ",", "self", ".", "L", ",", "self", ".", "_edgelist", "if", "2", "**", "len", "(", "self", ".", "_evil",...
If there are fewer than self._proc_limit possible deletion sets, compute all subprocessors obtained by deleting a minimal subset of qubits.
[ "If", "there", "are", "fewer", "than", "self", ".", "_proc_limit", "possible", "deletion", "sets", "compute", "all", "subprocessors", "obtained", "by", "deleting", "a", "minimal", "subset", "of", "qubits", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L836-L846
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._random_subprocessor
def _random_subprocessor(self): """Creates a random subprocessor where there is a coupler between every pair of working qubits on opposite sides of the same cell. This is guaranteed to be minimal in that adding a qubit back in will reintroduce a bad coupler, but not to have minimum size....
python
def _random_subprocessor(self): """Creates a random subprocessor where there is a coupler between every pair of working qubits on opposite sides of the same cell. This is guaranteed to be minimal in that adding a qubit back in will reintroduce a bad coupler, but not to have minimum size....
[ "def", "_random_subprocessor", "(", "self", ")", ":", "deletion", "=", "set", "(", ")", "for", "e", "in", "self", ".", "_evil", ":", "if", "e", "[", "0", "]", "in", "deletion", "or", "e", "[", "1", "]", "in", "deletion", ":", "continue", "deletion"...
Creates a random subprocessor where there is a coupler between every pair of working qubits on opposite sides of the same cell. This is guaranteed to be minimal in that adding a qubit back in will reintroduce a bad coupler, but not to have minimum size. OUTPUT: an :class:`ed...
[ "Creates", "a", "random", "subprocessor", "where", "there", "is", "a", "coupler", "between", "every", "pair", "of", "working", "qubits", "on", "opposite", "sides", "of", "the", "same", "cell", ".", "This", "is", "guaranteed", "to", "be", "minimal", "in", "...
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L848-L862
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._objective_bestscore
def _objective_bestscore(self, old, new): """An objective function that returns True if new has a better score than old, and ``False`` otherwise. INPUTS: old (tuple): a tuple (score, embedding) new (tuple): a tuple (score, embedding) """ (oldscore, oldt...
python
def _objective_bestscore(self, old, new): """An objective function that returns True if new has a better score than old, and ``False`` otherwise. INPUTS: old (tuple): a tuple (score, embedding) new (tuple): a tuple (score, embedding) """ (oldscore, oldt...
[ "def", "_objective_bestscore", "(", "self", ",", "old", ",", "new", ")", ":", "(", "oldscore", ",", "oldthing", ")", "=", "old", "(", "newscore", ",", "newthing", ")", "=", "new", "if", "oldscore", "is", "None", ":", "return", "True", "if", "newscore",...
An objective function that returns True if new has a better score than old, and ``False`` otherwise. INPUTS: old (tuple): a tuple (score, embedding) new (tuple): a tuple (score, embedding)
[ "An", "objective", "function", "that", "returns", "True", "if", "new", "has", "a", "better", "score", "than", "old", "and", "False", "otherwise", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L913-L929
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor.nativeCliqueEmbed
def nativeCliqueEmbed(self, width): """Compute a maximum-sized native clique embedding in an induced subgraph of chimera with chainsize ``width+1``. If possible, returns a uniform choice among all largest cliques. INPUTS: width: width of the squares to search, also `chainle...
python
def nativeCliqueEmbed(self, width): """Compute a maximum-sized native clique embedding in an induced subgraph of chimera with chainsize ``width+1``. If possible, returns a uniform choice among all largest cliques. INPUTS: width: width of the squares to search, also `chainle...
[ "def", "nativeCliqueEmbed", "(", "self", ",", "width", ")", ":", "def", "f", "(", "x", ")", ":", "return", "x", ".", "nativeCliqueEmbed", "(", "width", ")", "objective", "=", "self", ".", "_objective_bestscore", "return", "self", ".", "_translate", "(", ...
Compute a maximum-sized native clique embedding in an induced subgraph of chimera with chainsize ``width+1``. If possible, returns a uniform choice among all largest cliques. INPUTS: width: width of the squares to search, also `chainlength-1` OUTPUT: clique: a ...
[ "Compute", "a", "maximum", "-", "sized", "native", "clique", "embedding", "in", "an", "induced", "subgraph", "of", "chimera", "with", "chainsize", "width", "+", "1", ".", "If", "possible", "returns", "a", "uniform", "choice", "among", "all", "largest", "cliq...
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1038-L1062
train
dwavesystems/dwave-system
dwave/embedding/polynomialembedder.py
processor._translate
def _translate(self, embedding): "Translates an embedding back to linear coordinates if necessary." if embedding is None: return None if not self._linear: return embedding return [_bulk_to_linear(self.M, self.N, self.L, chain) for chain in embedding]
python
def _translate(self, embedding): "Translates an embedding back to linear coordinates if necessary." if embedding is None: return None if not self._linear: return embedding return [_bulk_to_linear(self.M, self.N, self.L, chain) for chain in embedding]
[ "def", "_translate", "(", "self", ",", "embedding", ")", ":", "\"Translates an embedding back to linear coordinates if necessary.\"", "if", "embedding", "is", "None", ":", "return", "None", "if", "not", "self", ".", "_linear", ":", "return", "embedding", "return", "...
Translates an embedding back to linear coordinates if necessary.
[ "Translates", "an", "embedding", "back", "to", "linear", "coordinates", "if", "necessary", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/polynomialembedder.py#L1152-L1158
train
dwavesystems/dwave-system
dwave/system/composites/virtual_graph.py
_validate_chain_strength
def _validate_chain_strength(sampler, chain_strength): """Validate the provided chain strength, checking J-ranges of the sampler's children. Args: chain_strength (float) The provided chain strength. Use None to use J-range. Returns (float): A valid chain strength, either provided or based...
python
def _validate_chain_strength(sampler, chain_strength): """Validate the provided chain strength, checking J-ranges of the sampler's children. Args: chain_strength (float) The provided chain strength. Use None to use J-range. Returns (float): A valid chain strength, either provided or based...
[ "def", "_validate_chain_strength", "(", "sampler", ",", "chain_strength", ")", ":", "properties", "=", "sampler", ".", "properties", "if", "'extended_j_range'", "in", "properties", ":", "max_chain_strength", "=", "-", "min", "(", "properties", "[", "'extended_j_rang...
Validate the provided chain strength, checking J-ranges of the sampler's children. Args: chain_strength (float) The provided chain strength. Use None to use J-range. Returns (float): A valid chain strength, either provided or based on available J-range. Positive finite float.
[ "Validate", "the", "provided", "chain", "strength", "checking", "J", "-", "ranges", "of", "the", "sampler", "s", "children", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/virtual_graph.py#L368-L392
train
dwavesystems/dwave-system
dwave/system/composites/virtual_graph.py
VirtualGraphComposite.sample
def sample(self, bqm, apply_flux_bias_offsets=True, **kwargs): """Sample from the given Ising model. Args: h (list/dict): Linear biases of the Ising model. If a list, the list's indices are used as variable labels. J (dict of (int, int):float): ...
python
def sample(self, bqm, apply_flux_bias_offsets=True, **kwargs): """Sample from the given Ising model. Args: h (list/dict): Linear biases of the Ising model. If a list, the list's indices are used as variable labels. J (dict of (int, int):float): ...
[ "def", "sample", "(", "self", ",", "bqm", ",", "apply_flux_bias_offsets", "=", "True", ",", "**", "kwargs", ")", ":", "child", "=", "self", ".", "child", "if", "apply_flux_bias_offsets", ":", "if", "self", ".", "flux_biases", "is", "not", "None", ":", "k...
Sample from the given Ising model. Args: h (list/dict): Linear biases of the Ising model. If a list, the list's indices are used as variable labels. J (dict of (int, int):float): Quadratic biases of the Ising model. apply_fl...
[ "Sample", "from", "the", "given", "Ising", "model", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/virtual_graph.py#L299-L365
train
dwavesystems/dwave-system
dwave/system/flux_bias_offsets.py
get_flux_biases
def get_flux_biases(sampler, embedding, chain_strength, num_reads=1000, max_age=3600): """Get the flux bias offsets for sampler and embedding. Args: sampler (:obj:`.DWaveSampler`): A D-Wave sampler. embedding (dict[hashable, iterable]): Mapping from a source graph to th...
python
def get_flux_biases(sampler, embedding, chain_strength, num_reads=1000, max_age=3600): """Get the flux bias offsets for sampler and embedding. Args: sampler (:obj:`.DWaveSampler`): A D-Wave sampler. embedding (dict[hashable, iterable]): Mapping from a source graph to th...
[ "def", "get_flux_biases", "(", "sampler", ",", "embedding", ",", "chain_strength", ",", "num_reads", "=", "1000", ",", "max_age", "=", "3600", ")", ":", "if", "not", "isinstance", "(", "sampler", ",", "dimod", ".", "Sampler", ")", ":", "raise", "TypeError"...
Get the flux bias offsets for sampler and embedding. Args: sampler (:obj:`.DWaveSampler`): A D-Wave sampler. embedding (dict[hashable, iterable]): Mapping from a source graph to the specified sampler’s graph (the target graph). The keys of embedding should be no...
[ "Get", "the", "flux", "bias", "offsets", "for", "sampler", "and", "embedding", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/flux_bias_offsets.py#L26-L88
train
dwavesystems/dwave-system
dwave/embedding/chimera.py
find_clique_embedding
def find_clique_embedding(k, m, n=None, t=None, target_edges=None): """Find an embedding for a clique in a Chimera graph. Given a target :term:`Chimera` graph size, and a clique (fully connect graph), attempts to find an embedding. Args: k (int/iterable): Clique to embed. If k is a...
python
def find_clique_embedding(k, m, n=None, t=None, target_edges=None): """Find an embedding for a clique in a Chimera graph. Given a target :term:`Chimera` graph size, and a clique (fully connect graph), attempts to find an embedding. Args: k (int/iterable): Clique to embed. If k is a...
[ "def", "find_clique_embedding", "(", "k", ",", "m", ",", "n", "=", "None", ",", "t", "=", "None", ",", "target_edges", "=", "None", ")", ":", "import", "random", "_", ",", "nodes", "=", "k", "m", ",", "n", ",", "t", ",", "target_edges", "=", "_ch...
Find an embedding for a clique in a Chimera graph. Given a target :term:`Chimera` graph size, and a clique (fully connect graph), attempts to find an embedding. Args: k (int/iterable): Clique to embed. If k is an integer, generates an embedding for a clique of size k labell...
[ "Find", "an", "embedding", "for", "a", "clique", "in", "a", "Chimera", "graph", "." ]
86a1698f15ccd8b0ece0ed868ee49292d3f67f5b
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/chimera.py#L27-L106
train