body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
@is_connected
def signature_verify(self, message, signature, uid=None, cryptographic_parameters=None):
'\n Verify a message signature using the specified signing key.\n\n Args:\n message (bytes): The bytes of the signed message. Required.\n signature (bytes): The bytes of the mes... | -4,692,309,284,648,152,000 | Verify a message signature using the specified signing key.
Args:
message (bytes): The bytes of the signed message. Required.
signature (bytes): The bytes of the message signature. Required.
uid (string): The unique ID of the signing key to use.
Optional, defaults to None.
cryptographic_paramet... | kmip/pie/client.py | signature_verify | eniltonj/PyKMIP | python | @is_connected
def signature_verify(self, message, signature, uid=None, cryptographic_parameters=None):
'\n Verify a message signature using the specified signing key.\n\n Args:\n message (bytes): The bytes of the signed message. Required.\n signature (bytes): The bytes of the mes... |
@is_connected
def sign(self, data, uid=None, cryptographic_parameters=None):
'\n Create a digital signature for data using the specified signing key.\n\n Args:\n data (bytes): The bytes of the data to be signed. Required.\n uid (string): The unique ID of the signing key to use.\n... | 2,028,020,218,903,071,500 | Create a digital signature for data using the specified signing key.
Args:
data (bytes): The bytes of the data to be signed. Required.
uid (string): The unique ID of the signing key to use.
Optional, defaults to None.
cryptographic_parameters (dict): A dictionary containing various
cryptogr... | kmip/pie/client.py | sign | eniltonj/PyKMIP | python | @is_connected
def sign(self, data, uid=None, cryptographic_parameters=None):
'\n Create a digital signature for data using the specified signing key.\n\n Args:\n data (bytes): The bytes of the data to be signed. Required.\n uid (string): The unique ID of the signing key to use.\n... |
@is_connected
def mac(self, data, uid=None, algorithm=None):
'\n Get the message authentication code for data.\n\n Args:\n data (string): The data to be MACed.\n uid (string): The unique ID of the managed object that is the key\n to use for the MAC operation.\n ... | -8,830,796,119,257,767,000 | Get the message authentication code for data.
Args:
data (string): The data to be MACed.
uid (string): The unique ID of the managed object that is the key
to use for the MAC operation.
algorithm (CryptographicAlgorithm): An enumeration defining the
algorithm to use to generate the MAC.
Ret... | kmip/pie/client.py | mac | eniltonj/PyKMIP | python | @is_connected
def mac(self, data, uid=None, algorithm=None):
'\n Get the message authentication code for data.\n\n Args:\n data (string): The data to be MACed.\n uid (string): The unique ID of the managed object that is the key\n to use for the MAC operation.\n ... |
def _build_cryptographic_parameters(self, value):
'\n Build a CryptographicParameters struct from a dictionary.\n\n Args:\n value (dict): A dictionary containing the key/value pairs for a\n CryptographicParameters struct.\n\n Returns:\n CryptographicParamete... | -5,474,984,838,081,721,000 | Build a CryptographicParameters struct from a dictionary.
Args:
value (dict): A dictionary containing the key/value pairs for a
CryptographicParameters struct.
Returns:
CryptographicParameters: a CryptographicParameters struct
Raises:
TypeError: if the input argument is invalid | kmip/pie/client.py | _build_cryptographic_parameters | eniltonj/PyKMIP | python | def _build_cryptographic_parameters(self, value):
'\n Build a CryptographicParameters struct from a dictionary.\n\n Args:\n value (dict): A dictionary containing the key/value pairs for a\n CryptographicParameters struct.\n\n Returns:\n CryptographicParamete... |
def _build_encryption_key_information(self, value):
'\n Build an EncryptionKeyInformation struct from a dictionary.\n\n Args:\n value (dict): A dictionary containing the key/value pairs for a\n EncryptionKeyInformation struct.\n\n Returns:\n EncryptionKeyInf... | -5,256,028,316,101,503,000 | Build an EncryptionKeyInformation struct from a dictionary.
Args:
value (dict): A dictionary containing the key/value pairs for a
EncryptionKeyInformation struct.
Returns:
EncryptionKeyInformation: an EncryptionKeyInformation struct
Raises:
TypeError: if the input argument is invalid | kmip/pie/client.py | _build_encryption_key_information | eniltonj/PyKMIP | python | def _build_encryption_key_information(self, value):
'\n Build an EncryptionKeyInformation struct from a dictionary.\n\n Args:\n value (dict): A dictionary containing the key/value pairs for a\n EncryptionKeyInformation struct.\n\n Returns:\n EncryptionKeyInf... |
def _build_mac_signature_key_information(self, value):
'\n Build an MACSignatureKeyInformation struct from a dictionary.\n\n Args:\n value (dict): A dictionary containing the key/value pairs for a\n MACSignatureKeyInformation struct.\n\n Returns:\n MACSignat... | 1,329,116,591,558,231,800 | Build an MACSignatureKeyInformation struct from a dictionary.
Args:
value (dict): A dictionary containing the key/value pairs for a
MACSignatureKeyInformation struct.
Returns:
MACSignatureInformation: a MACSignatureKeyInformation struct
Raises:
TypeError: if the input argument is invalid | kmip/pie/client.py | _build_mac_signature_key_information | eniltonj/PyKMIP | python | def _build_mac_signature_key_information(self, value):
'\n Build an MACSignatureKeyInformation struct from a dictionary.\n\n Args:\n value (dict): A dictionary containing the key/value pairs for a\n MACSignatureKeyInformation struct.\n\n Returns:\n MACSignat... |
def _build_key_wrapping_specification(self, value):
'\n Build a KeyWrappingSpecification struct from a dictionary.\n\n Args:\n value (dict): A dictionary containing the key/value pairs for a\n KeyWrappingSpecification struct.\n\n Returns:\n KeyWrappingSpecif... | 3,925,461,603,981,449,000 | Build a KeyWrappingSpecification struct from a dictionary.
Args:
value (dict): A dictionary containing the key/value pairs for a
KeyWrappingSpecification struct.
Returns:
KeyWrappingSpecification: a KeyWrappingSpecification struct
Raises:
TypeError: if the input argument is invalid | kmip/pie/client.py | _build_key_wrapping_specification | eniltonj/PyKMIP | python | def _build_key_wrapping_specification(self, value):
'\n Build a KeyWrappingSpecification struct from a dictionary.\n\n Args:\n value (dict): A dictionary containing the key/value pairs for a\n KeyWrappingSpecification struct.\n\n Returns:\n KeyWrappingSpecif... |
def _build_common_attributes(self, operation_policy_name=None):
'\n Build a list of common attributes that are shared across\n symmetric as well as asymmetric objects\n '
common_attributes = []
if operation_policy_name:
common_attributes.append(self.attribute_factory.create_at... | 324,684,847,106,925,200 | Build a list of common attributes that are shared across
symmetric as well as asymmetric objects | kmip/pie/client.py | _build_common_attributes | eniltonj/PyKMIP | python | def _build_common_attributes(self, operation_policy_name=None):
'\n Build a list of common attributes that are shared across\n symmetric as well as asymmetric objects\n '
common_attributes = []
if operation_policy_name:
common_attributes.append(self.attribute_factory.create_at... |
def _build_name_attribute(self, name=None):
'\n Build a name attribute, returned in a list for ease\n of use in the caller\n '
name_list = []
if name:
name_list.append(self.attribute_factory.create_attribute(enums.AttributeType.NAME, name))
return name_list | 2,217,580,416,632,324,600 | Build a name attribute, returned in a list for ease
of use in the caller | kmip/pie/client.py | _build_name_attribute | eniltonj/PyKMIP | python | def _build_name_attribute(self, name=None):
'\n Build a name attribute, returned in a list for ease\n of use in the caller\n '
name_list = []
if name:
name_list.append(self.attribute_factory.create_attribute(enums.AttributeType.NAME, name))
return name_list |
def _get_package_version(self):
'\n Attempt to get the most correct current version of Sentry.\n '
pkg_path = os.path.join(self.work_path, 'src')
sys.path.insert(0, pkg_path)
try:
import sentry
except Exception:
version = None
build = None
else:
log.... | -2,962,726,407,331,622,000 | Attempt to get the most correct current version of Sentry. | src/sentry/utils/distutils/commands/build_assets.py | _get_package_version | CSP197/sentry | python | def _get_package_version(self):
'\n \n '
pkg_path = os.path.join(self.work_path, 'src')
sys.path.insert(0, pkg_path)
try:
import sentry
except Exception:
version = None
build = None
else:
log.info(u"pulled version information from 'sentry' module".fo... |
def test_debugger(self):
"Test the debug_rdkit_mol(rdmol) function doesn't crash\n\n We can't really test it in the unit testing framework, because\n that already captures and redirects standard output, and that\n conflicts with the function, but this checks it doesn't crash.\n "
imp... | -6,677,699,815,019,591,000 | Test the debug_rdkit_mol(rdmol) function doesn't crash
We can't really test it in the unit testing framework, because
that already captures and redirects standard output, and that
conflicts with the function, but this checks it doesn't crash. | rmgpy/molecule/converterTest.py | test_debugger | MingyuWAN/RMG-Py | python | def test_debugger(self):
"Test the debug_rdkit_mol(rdmol) function doesn't crash\n\n We can't really test it in the unit testing framework, because\n that already captures and redirects standard output, and that\n conflicts with the function, but this checks it doesn't crash.\n "
imp... |
def test_lone_pair_retention(self):
"Test that we don't lose any lone pairs on round trip RDKit conversion."
mol = Molecule().from_adjacency_list('\n1 C u0 p0 c0 {2,D} {3,S} {4,S}\n2 O u0 p2 c0 {1,D}\n3 H u0 p0 c0 {1,S}\n4 H u0 p0 c0 {1,S}\n')
rdmol = to_rdkit_mol(mol)
mol2 = from_rdkit_mol(Molecule(), ... | 9,050,436,349,953,038,000 | Test that we don't lose any lone pairs on round trip RDKit conversion. | rmgpy/molecule/converterTest.py | test_lone_pair_retention | MingyuWAN/RMG-Py | python | def test_lone_pair_retention(self):
mol = Molecule().from_adjacency_list('\n1 C u0 p0 c0 {2,D} {3,S} {4,S}\n2 O u0 p2 c0 {1,D}\n3 H u0 p0 c0 {1,S}\n4 H u0 p0 c0 {1,S}\n')
rdmol = to_rdkit_mol(mol)
mol2 = from_rdkit_mol(Molecule(), rdmol)
self.assertTrue(mol.is_isomorphic(mol2)) |
def test_atom_mapping_1(self):
'Test that to_rdkit_mol returns correct indices and atom mappings.'
bond_order_dict = {'SINGLE': 1, 'DOUBLE': 2, 'TRIPLE': 3, 'AROMATIC': 1.5}
mol = Molecule().from_smiles('C1CCC=C1C=O')
(rdkitmol, rd_atom_indices) = to_rdkit_mol(mol, remove_h=False, return_mapping=True)
... | -5,476,122,460,933,926,000 | Test that to_rdkit_mol returns correct indices and atom mappings. | rmgpy/molecule/converterTest.py | test_atom_mapping_1 | MingyuWAN/RMG-Py | python | def test_atom_mapping_1(self):
bond_order_dict = {'SINGLE': 1, 'DOUBLE': 2, 'TRIPLE': 3, 'AROMATIC': 1.5}
mol = Molecule().from_smiles('C1CCC=C1C=O')
(rdkitmol, rd_atom_indices) = to_rdkit_mol(mol, remove_h=False, return_mapping=True)
for atom in mol.atoms:
self.assertTrue((atom in rd_atom_... |
def test_atom_mapping_2(self):
'Test that to_rdkit_mol returns correct indices and atom mappings when hydrogens are removed.'
adjlist = '\n1 H u0 p0 c0 {2,S}\n2 C u0 p0 c0 {1,S} {3,S} {4,S} {5,S}\n3 H u0 p0 c0 {2,S}\n4 H u0 p0 c0 {2,S}\n5 O u0 p2 c0 {2,S} {6,S}\n6 H u0 p0 c0 {5,S}\n '
mol = Molecule(... | 7,292,628,781,118,935,000 | Test that to_rdkit_mol returns correct indices and atom mappings when hydrogens are removed. | rmgpy/molecule/converterTest.py | test_atom_mapping_2 | MingyuWAN/RMG-Py | python | def test_atom_mapping_2(self):
adjlist = '\n1 H u0 p0 c0 {2,S}\n2 C u0 p0 c0 {1,S} {3,S} {4,S} {5,S}\n3 H u0 p0 c0 {2,S}\n4 H u0 p0 c0 {2,S}\n5 O u0 p2 c0 {2,S} {6,S}\n6 H u0 p0 c0 {5,S}\n '
mol = Molecule().from_adjacency_list(adjlist)
(rdkitmol, rd_atom_indices) = to_rdkit_mol(mol, remove_h=Tr... |
def setUp(self):
'Function run before each test in this class.'
self.test_mols = [Molecule().from_smiles('C'), Molecule().from_smiles('O'), Molecule().from_smiles('N'), Molecule().from_smiles('S'), Molecule().from_smiles('[CH2]C'), Molecule().from_smiles('[CH]C'), Molecule().from_smiles('C=CC=C'), Molecule().fr... | 7,450,568,532,803,879,000 | Function run before each test in this class. | rmgpy/molecule/converterTest.py | setUp | MingyuWAN/RMG-Py | python | def setUp(self):
self.test_mols = [Molecule().from_smiles('C'), Molecule().from_smiles('O'), Molecule().from_smiles('N'), Molecule().from_smiles('S'), Molecule().from_smiles('[CH2]C'), Molecule().from_smiles('[CH]C'), Molecule().from_smiles('C=CC=C'), Molecule().from_smiles('C#C[CH2]'), Molecule().from_smiles(... |
def test_rdkit_round_trip(self):
'Test conversion to and from RDKitMol'
for mol in self.test_mols:
rdkit_mol = to_rdkit_mol(mol)
new_mol = from_rdkit_mol(Molecule(), rdkit_mol)
self.assertTrue((mol.is_isomorphic(new_mol) or self.test_Hbond_free_mol.is_isomorphic(new_mol)))
self.a... | -3,285,463,596,830,834,700 | Test conversion to and from RDKitMol | rmgpy/molecule/converterTest.py | test_rdkit_round_trip | MingyuWAN/RMG-Py | python | def test_rdkit_round_trip(self):
for mol in self.test_mols:
rdkit_mol = to_rdkit_mol(mol)
new_mol = from_rdkit_mol(Molecule(), rdkit_mol)
self.assertTrue((mol.is_isomorphic(new_mol) or self.test_Hbond_free_mol.is_isomorphic(new_mol)))
self.assertEqual(mol.get_element_count(), ne... |
def test_ob_round_trip(self):
'Test conversion to and from OBMol'
for mol in self.test_mols:
ob_mol = to_ob_mol(mol)
new_mol = from_ob_mol(Molecule(), ob_mol)
self.assertTrue((mol.is_isomorphic(new_mol) or self.test_Hbond_free_mol.is_isomorphic(new_mol)))
self.assertEqual(mol.get... | 3,404,922,557,908,848,000 | Test conversion to and from OBMol | rmgpy/molecule/converterTest.py | test_ob_round_trip | MingyuWAN/RMG-Py | python | def test_ob_round_trip(self):
for mol in self.test_mols:
ob_mol = to_ob_mol(mol)
new_mol = from_ob_mol(Molecule(), ob_mol)
self.assertTrue((mol.is_isomorphic(new_mol) or self.test_Hbond_free_mol.is_isomorphic(new_mol)))
self.assertEqual(mol.get_element_count(), new_mol.get_eleme... |
@property
def range_keyname(self):
"\n Returns the name of this table's range key\n "
if (self._range_keyname is None):
for attr in self.data.get(KEY_SCHEMA):
if (attr.get(KEY_TYPE) == RANGE):
self._range_keyname = attr.get(ATTR_NAME)
return self._range_keyn... | -6,380,936,349,239,836,000 | Returns the name of this table's range key | pynamodb/connection/base.py | range_keyname | dwelch91/PynamoDB | python | @property
def range_keyname(self):
"\n \n "
if (self._range_keyname is None):
for attr in self.data.get(KEY_SCHEMA):
if (attr.get(KEY_TYPE) == RANGE):
self._range_keyname = attr.get(ATTR_NAME)
return self._range_keyname |
@property
def hash_keyname(self):
"\n Returns the name of this table's hash key\n "
if (self._hash_keyname is None):
for attr in self.data.get(KEY_SCHEMA):
if (attr.get(KEY_TYPE) == HASH):
self._hash_keyname = attr.get(ATTR_NAME)
break
return... | -6,271,449,913,786,349,000 | Returns the name of this table's hash key | pynamodb/connection/base.py | hash_keyname | dwelch91/PynamoDB | python | @property
def hash_keyname(self):
"\n \n "
if (self._hash_keyname is None):
for attr in self.data.get(KEY_SCHEMA):
if (attr.get(KEY_TYPE) == HASH):
self._hash_keyname = attr.get(ATTR_NAME)
break
return self._hash_keyname |
def get_key_names(self, index_name=None):
'\n Returns the names of the primary key attributes and index key attributes (if index_name is specified)\n '
key_names = [self.hash_keyname]
if self.range_keyname:
key_names.append(self.range_keyname)
if (index_name is not None):
i... | 5,456,218,973,157,170,000 | Returns the names of the primary key attributes and index key attributes (if index_name is specified) | pynamodb/connection/base.py | get_key_names | dwelch91/PynamoDB | python | def get_key_names(self, index_name=None):
'\n \n '
key_names = [self.hash_keyname]
if self.range_keyname:
key_names.append(self.range_keyname)
if (index_name is not None):
index_hash_keyname = self.get_index_hash_keyname(index_name)
if (index_hash_keyname not in key... |
def get_index_hash_keyname(self, index_name):
'\n Returns the name of the hash key for a given index\n '
global_indexes = self.data.get(GLOBAL_SECONDARY_INDEXES)
local_indexes = self.data.get(LOCAL_SECONDARY_INDEXES)
indexes = []
if local_indexes:
indexes += local_indexes
i... | 6,107,178,760,201,870,000 | Returns the name of the hash key for a given index | pynamodb/connection/base.py | get_index_hash_keyname | dwelch91/PynamoDB | python | def get_index_hash_keyname(self, index_name):
'\n \n '
global_indexes = self.data.get(GLOBAL_SECONDARY_INDEXES)
local_indexes = self.data.get(LOCAL_SECONDARY_INDEXES)
indexes = []
if local_indexes:
indexes += local_indexes
if global_indexes:
indexes += global_indexe... |
def get_index_range_keyname(self, index_name):
'\n Returns the name of the hash key for a given index\n '
global_indexes = self.data.get(GLOBAL_SECONDARY_INDEXES)
local_indexes = self.data.get(LOCAL_SECONDARY_INDEXES)
indexes = []
if local_indexes:
indexes += local_indexes
... | -8,206,062,927,985,802,000 | Returns the name of the hash key for a given index | pynamodb/connection/base.py | get_index_range_keyname | dwelch91/PynamoDB | python | def get_index_range_keyname(self, index_name):
'\n \n '
global_indexes = self.data.get(GLOBAL_SECONDARY_INDEXES)
local_indexes = self.data.get(LOCAL_SECONDARY_INDEXES)
indexes = []
if local_indexes:
indexes += local_indexes
if global_indexes:
indexes += global_index... |
def get_item_attribute_map(self, attributes, item_key=ITEM, pythonic_key=True):
'\n Builds up a dynamodb compatible AttributeValue map\n '
if pythonic_key:
item_key = item_key
attr_map = {item_key: {}}
for (key, value) in attributes.items():
if isinstance(value, dict):
... | 3,636,731,201,812,223,000 | Builds up a dynamodb compatible AttributeValue map | pynamodb/connection/base.py | get_item_attribute_map | dwelch91/PynamoDB | python | def get_item_attribute_map(self, attributes, item_key=ITEM, pythonic_key=True):
'\n \n '
if pythonic_key:
item_key = item_key
attr_map = {item_key: {}}
for (key, value) in attributes.items():
if isinstance(value, dict):
attr_map[item_key][key] = value
el... |
def get_attribute_type(self, attribute_name, value=None):
'\n Returns the proper attribute type for a given attribute name\n '
for attr in self.data.get(ATTR_DEFINITIONS):
if (attr.get(ATTR_NAME) == attribute_name):
return attr.get(ATTR_TYPE)
if ((value is not None) and isi... | 2,509,500,554,240,942,600 | Returns the proper attribute type for a given attribute name | pynamodb/connection/base.py | get_attribute_type | dwelch91/PynamoDB | python | def get_attribute_type(self, attribute_name, value=None):
'\n \n '
for attr in self.data.get(ATTR_DEFINITIONS):
if (attr.get(ATTR_NAME) == attribute_name):
return attr.get(ATTR_TYPE)
if ((value is not None) and isinstance(value, dict)):
for key in SHORT_ATTR_TYPES:
... |
def get_identifier_map(self, hash_key, range_key=None, key=KEY):
'\n Builds the identifier map that is common to several operations\n '
kwargs = {key: {self.hash_keyname: {self.get_attribute_type(self.hash_keyname): hash_key}}}
if (range_key is not None):
kwargs[key][self.range_keyname... | 6,966,726,338,914,713,000 | Builds the identifier map that is common to several operations | pynamodb/connection/base.py | get_identifier_map | dwelch91/PynamoDB | python | def get_identifier_map(self, hash_key, range_key=None, key=KEY):
'\n \n '
kwargs = {key: {self.hash_keyname: {self.get_attribute_type(self.hash_keyname): hash_key}}}
if (range_key is not None):
kwargs[key][self.range_keyname] = {self.get_attribute_type(self.range_keyname): range_key}
... |
def get_exclusive_start_key_map(self, exclusive_start_key):
'\n Builds the exclusive start key attribute map\n '
if (isinstance(exclusive_start_key, dict) and (self.hash_keyname in exclusive_start_key)):
return {EXCLUSIVE_START_KEY: exclusive_start_key}
else:
return {EXCLUSIVE_... | 8,152,123,984,138,970,000 | Builds the exclusive start key attribute map | pynamodb/connection/base.py | get_exclusive_start_key_map | dwelch91/PynamoDB | python | def get_exclusive_start_key_map(self, exclusive_start_key):
'\n \n '
if (isinstance(exclusive_start_key, dict) and (self.hash_keyname in exclusive_start_key)):
return {EXCLUSIVE_START_KEY: exclusive_start_key}
else:
return {EXCLUSIVE_START_KEY: {self.hash_keyname: {self.get_att... |
def _log_debug(self, operation, kwargs):
'\n Sends a debug message to the logger\n '
log.debug('Calling %s with arguments %s', operation, kwargs) | 169,557,376,176,583,780 | Sends a debug message to the logger | pynamodb/connection/base.py | _log_debug | dwelch91/PynamoDB | python | def _log_debug(self, operation, kwargs):
'\n \n '
log.debug('Calling %s with arguments %s', operation, kwargs) |
def _log_debug_response(self, operation, response):
'\n Sends a debug message to the logger about a response\n '
log.debug('%s response: %s', operation, response) | 3,272,533,888,218,723,000 | Sends a debug message to the logger about a response | pynamodb/connection/base.py | _log_debug_response | dwelch91/PynamoDB | python | def _log_debug_response(self, operation, response):
'\n \n '
log.debug('%s response: %s', operation, response) |
def _log_error(self, operation, response):
'\n Sends an error message to the logger\n '
log.error('%s failed with status: %s, message: %s', operation, response.status_code, response.content) | 3,364,985,844,450,834,400 | Sends an error message to the logger | pynamodb/connection/base.py | _log_error | dwelch91/PynamoDB | python | def _log_error(self, operation, response):
'\n \n '
log.error('%s failed with status: %s, message: %s', operation, response.status_code, response.content) |
def _create_prepared_request(self, request_dict, operation_model):
'\n Create a prepared request object from request_dict, and operation_model\n '
boto_prepared_request = self.client._endpoint.create_request(request_dict, operation_model)
raw_request_with_params = Request(boto_prepared_request... | 6,649,555,565,494,670,000 | Create a prepared request object from request_dict, and operation_model | pynamodb/connection/base.py | _create_prepared_request | dwelch91/PynamoDB | python | def _create_prepared_request(self, request_dict, operation_model):
'\n \n '
boto_prepared_request = self.client._endpoint.create_request(request_dict, operation_model)
raw_request_with_params = Request(boto_prepared_request.method, boto_prepared_request.url, data=boto_prepared_request.body, he... |
def dispatch(self, operation_name, operation_kwargs):
'\n Dispatches `operation_name` with arguments `operation_kwargs`\n\n Raises TableDoesNotExist if the specified table does not exist\n '
if (operation_name not in [DESCRIBE_TABLE, LIST_TABLES, UPDATE_TABLE, DELETE_TABLE, CREATE_TABLE]):
... | -3,937,433,697,370,865,700 | Dispatches `operation_name` with arguments `operation_kwargs`
Raises TableDoesNotExist if the specified table does not exist | pynamodb/connection/base.py | dispatch | dwelch91/PynamoDB | python | def dispatch(self, operation_name, operation_kwargs):
'\n Dispatches `operation_name` with arguments `operation_kwargs`\n\n Raises TableDoesNotExist if the specified table does not exist\n '
if (operation_name not in [DESCRIBE_TABLE, LIST_TABLES, UPDATE_TABLE, DELETE_TABLE, CREATE_TABLE]):
... |
def _make_api_call(self, operation_name, operation_kwargs):
"\n This private method is here for two reasons:\n 1. It's faster to avoid using botocore's response parsing\n 2. It provides a place to monkey patch requests for unit testing\n "
operation_model = self.client._service_model... | 7,612,137,007,857,733,000 | This private method is here for two reasons:
1. It's faster to avoid using botocore's response parsing
2. It provides a place to monkey patch requests for unit testing | pynamodb/connection/base.py | _make_api_call | dwelch91/PynamoDB | python | def _make_api_call(self, operation_name, operation_kwargs):
"\n This private method is here for two reasons:\n 1. It's faster to avoid using botocore's response parsing\n 2. It provides a place to monkey patch requests for unit testing\n "
operation_model = self.client._service_model... |
@staticmethod
def _handle_binary_attributes(data):
" Simulate botocore's binary attribute handling "
if (ITEM in data):
for attr in six.itervalues(data[ITEM]):
_convert_binary(attr)
if (ITEMS in data):
for item in data[ITEMS]:
for attr in six.itervalues(item):
... | 4,120,286,862,712,733,000 | Simulate botocore's binary attribute handling | pynamodb/connection/base.py | _handle_binary_attributes | dwelch91/PynamoDB | python | @staticmethod
def _handle_binary_attributes(data):
" "
if (ITEM in data):
for attr in six.itervalues(data[ITEM]):
_convert_binary(attr)
if (ITEMS in data):
for item in data[ITEMS]:
for attr in six.itervalues(item):
_convert_binary(attr)
if (RESPON... |
@property
def session(self):
'\n Returns a valid botocore session\n '
if (getattr(self._local, 'session', None) is None):
self._local.session = get_session()
return self._local.session | -514,464,121,125,460,740 | Returns a valid botocore session | pynamodb/connection/base.py | session | dwelch91/PynamoDB | python | @property
def session(self):
'\n \n '
if (getattr(self._local, 'session', None) is None):
self._local.session = get_session()
return self._local.session |
@property
def requests_session(self):
'\n Return a requests session to execute prepared requests using the same pool\n '
if (self._requests_session is None):
self._requests_session = self.session_cls()
return self._requests_session | 7,982,664,256,438,557,000 | Return a requests session to execute prepared requests using the same pool | pynamodb/connection/base.py | requests_session | dwelch91/PynamoDB | python | @property
def requests_session(self):
'\n \n '
if (self._requests_session is None):
self._requests_session = self.session_cls()
return self._requests_session |
@property
def client(self):
'\n Returns a botocore dynamodb client\n '
if ((not self._client) or (self._client._request_signer and (not self._client._request_signer._credentials))):
self._client = self.session.create_client(SERVICE_NAME, self.region, endpoint_url=self.host)
return self... | -1,559,269,023,375,754,500 | Returns a botocore dynamodb client | pynamodb/connection/base.py | client | dwelch91/PynamoDB | python | @property
def client(self):
'\n \n '
if ((not self._client) or (self._client._request_signer and (not self._client._request_signer._credentials))):
self._client = self.session.create_client(SERVICE_NAME, self.region, endpoint_url=self.host)
return self._client |
def get_meta_table(self, table_name, refresh=False):
'\n Returns a MetaTable\n '
if ((table_name not in self._tables) or refresh):
operation_kwargs = {TABLE_NAME: table_name}
try:
data = self.dispatch(DESCRIBE_TABLE, operation_kwargs)
self._tables[table_name... | 1,652,882,506,966,526,200 | Returns a MetaTable | pynamodb/connection/base.py | get_meta_table | dwelch91/PynamoDB | python | def get_meta_table(self, table_name, refresh=False):
'\n \n '
if ((table_name not in self._tables) or refresh):
operation_kwargs = {TABLE_NAME: table_name}
try:
data = self.dispatch(DESCRIBE_TABLE, operation_kwargs)
self._tables[table_name] = MetaTable(data.... |
def create_table(self, table_name, attribute_definitions=None, key_schema=None, read_capacity_units=None, write_capacity_units=None, global_secondary_indexes=None, local_secondary_indexes=None, stream_specification=None):
'\n Performs the CreateTable operation\n '
operation_kwargs = {TABLE_NAME: t... | -8,012,334,354,153,954,000 | Performs the CreateTable operation | pynamodb/connection/base.py | create_table | dwelch91/PynamoDB | python | def create_table(self, table_name, attribute_definitions=None, key_schema=None, read_capacity_units=None, write_capacity_units=None, global_secondary_indexes=None, local_secondary_indexes=None, stream_specification=None):
'\n \n '
operation_kwargs = {TABLE_NAME: table_name, PROVISIONED_THROUGHPUT:... |
def delete_table(self, table_name):
'\n Performs the DeleteTable operation\n '
operation_kwargs = {TABLE_NAME: table_name}
try:
data = self.dispatch(DELETE_TABLE, operation_kwargs)
except BOTOCORE_EXCEPTIONS as e:
raise TableError('Failed to delete table: {0}'.format(e), e)... | 4,455,668,059,063,957,500 | Performs the DeleteTable operation | pynamodb/connection/base.py | delete_table | dwelch91/PynamoDB | python | def delete_table(self, table_name):
'\n \n '
operation_kwargs = {TABLE_NAME: table_name}
try:
data = self.dispatch(DELETE_TABLE, operation_kwargs)
except BOTOCORE_EXCEPTIONS as e:
raise TableError('Failed to delete table: {0}'.format(e), e)
return data |
def update_table(self, table_name, read_capacity_units=None, write_capacity_units=None, global_secondary_index_updates=None):
'\n Performs the UpdateTable operation\n '
operation_kwargs = {TABLE_NAME: table_name}
if ((read_capacity_units and (not write_capacity_units)) or (write_capacity_units... | -4,731,766,806,556,885,000 | Performs the UpdateTable operation | pynamodb/connection/base.py | update_table | dwelch91/PynamoDB | python | def update_table(self, table_name, read_capacity_units=None, write_capacity_units=None, global_secondary_index_updates=None):
'\n \n '
operation_kwargs = {TABLE_NAME: table_name}
if ((read_capacity_units and (not write_capacity_units)) or (write_capacity_units and (not read_capacity_units))):
... |
def list_tables(self, exclusive_start_table_name=None, limit=None):
'\n Performs the ListTables operation\n '
operation_kwargs = {}
if exclusive_start_table_name:
operation_kwargs.update({EXCLUSIVE_START_TABLE_NAME: exclusive_start_table_name})
if (limit is not None):
opera... | 2,567,854,029,133,414,400 | Performs the ListTables operation | pynamodb/connection/base.py | list_tables | dwelch91/PynamoDB | python | def list_tables(self, exclusive_start_table_name=None, limit=None):
'\n \n '
operation_kwargs = {}
if exclusive_start_table_name:
operation_kwargs.update({EXCLUSIVE_START_TABLE_NAME: exclusive_start_table_name})
if (limit is not None):
operation_kwargs.update({LIMIT: limit}... |
def describe_table(self, table_name):
'\n Performs the DescribeTable operation\n '
try:
tbl = self.get_meta_table(table_name, refresh=True)
if tbl:
return tbl.data
except ValueError:
pass
raise TableDoesNotExist(table_name) | 4,120,375,463,528,351,000 | Performs the DescribeTable operation | pynamodb/connection/base.py | describe_table | dwelch91/PynamoDB | python | def describe_table(self, table_name):
'\n \n '
try:
tbl = self.get_meta_table(table_name, refresh=True)
if tbl:
return tbl.data
except ValueError:
pass
raise TableDoesNotExist(table_name) |
def get_conditional_operator(self, operator):
'\n Returns a dictionary containing the correct conditional operator,\n validating it first.\n '
operator = operator.upper()
if (operator not in CONDITIONAL_OPERATORS):
raise ValueError('The {0} must be one of {1}'.format(CONDITIONAL... | -6,437,857,568,692,306,000 | Returns a dictionary containing the correct conditional operator,
validating it first. | pynamodb/connection/base.py | get_conditional_operator | dwelch91/PynamoDB | python | def get_conditional_operator(self, operator):
'\n Returns a dictionary containing the correct conditional operator,\n validating it first.\n '
operator = operator.upper()
if (operator not in CONDITIONAL_OPERATORS):
raise ValueError('The {0} must be one of {1}'.format(CONDITIONAL... |
def get_item_attribute_map(self, table_name, attributes, item_key=ITEM, pythonic_key=True):
'\n Builds up a dynamodb compatible AttributeValue map\n '
tbl = self.get_meta_table(table_name)
if (tbl is None):
raise TableError('No such table {0}'.format(table_name))
return tbl.get_ite... | 6,238,838,979,059,248,000 | Builds up a dynamodb compatible AttributeValue map | pynamodb/connection/base.py | get_item_attribute_map | dwelch91/PynamoDB | python | def get_item_attribute_map(self, table_name, attributes, item_key=ITEM, pythonic_key=True):
'\n \n '
tbl = self.get_meta_table(table_name)
if (tbl is None):
raise TableError('No such table {0}'.format(table_name))
return tbl.get_item_attribute_map(attributes, item_key=item_key, pyt... |
def get_expected_map(self, table_name, expected):
'\n Builds the expected map that is common to several operations\n '
kwargs = {EXPECTED: {}}
for (key, condition) in expected.items():
if (EXISTS in condition):
kwargs[EXPECTED][key] = {EXISTS: condition.get(EXISTS)}
... | -7,198,897,823,071,446,000 | Builds the expected map that is common to several operations | pynamodb/connection/base.py | get_expected_map | dwelch91/PynamoDB | python | def get_expected_map(self, table_name, expected):
'\n \n '
kwargs = {EXPECTED: {}}
for (key, condition) in expected.items():
if (EXISTS in condition):
kwargs[EXPECTED][key] = {EXISTS: condition.get(EXISTS)}
elif (VALUE in condition):
kwargs[EXPECTED][key... |
def parse_attribute(self, attribute, return_type=False):
"\n Returns the attribute value, where the attribute can be\n a raw attribute value, or a dictionary containing the type:\n {'S': 'String value'}\n "
if isinstance(attribute, dict):
for key in SHORT_ATTR_TYPES:
... | -4,461,123,140,219,780,000 | Returns the attribute value, where the attribute can be
a raw attribute value, or a dictionary containing the type:
{'S': 'String value'} | pynamodb/connection/base.py | parse_attribute | dwelch91/PynamoDB | python | def parse_attribute(self, attribute, return_type=False):
"\n Returns the attribute value, where the attribute can be\n a raw attribute value, or a dictionary containing the type:\n {'S': 'String value'}\n "
if isinstance(attribute, dict):
for key in SHORT_ATTR_TYPES:
... |
def get_attribute_type(self, table_name, attribute_name, value=None):
'\n Returns the proper attribute type for a given attribute name\n :param value: The attribute value an be supplied just in case the type is already included\n '
tbl = self.get_meta_table(table_name)
if (tbl is None):... | -3,013,755,444,363,028,500 | Returns the proper attribute type for a given attribute name
:param value: The attribute value an be supplied just in case the type is already included | pynamodb/connection/base.py | get_attribute_type | dwelch91/PynamoDB | python | def get_attribute_type(self, table_name, attribute_name, value=None):
'\n Returns the proper attribute type for a given attribute name\n :param value: The attribute value an be supplied just in case the type is already included\n '
tbl = self.get_meta_table(table_name)
if (tbl is None):... |
def get_identifier_map(self, table_name, hash_key, range_key=None, key=KEY):
'\n Builds the identifier map that is common to several operations\n '
tbl = self.get_meta_table(table_name)
if (tbl is None):
raise TableError('No such table {0}'.format(table_name))
return tbl.get_identi... | -2,511,014,680,240,963,000 | Builds the identifier map that is common to several operations | pynamodb/connection/base.py | get_identifier_map | dwelch91/PynamoDB | python | def get_identifier_map(self, table_name, hash_key, range_key=None, key=KEY):
'\n \n '
tbl = self.get_meta_table(table_name)
if (tbl is None):
raise TableError('No such table {0}'.format(table_name))
return tbl.get_identifier_map(hash_key, range_key=range_key, key=key) |
def get_query_filter_map(self, table_name, query_filters):
'\n Builds the QueryFilter object needed for the Query operation\n '
kwargs = {QUERY_FILTER: {}}
for (key, condition) in query_filters.items():
operator = condition.get(COMPARISON_OPERATOR)
if (operator not in QUERY_FIL... | -845,778,907,933,675,500 | Builds the QueryFilter object needed for the Query operation | pynamodb/connection/base.py | get_query_filter_map | dwelch91/PynamoDB | python | def get_query_filter_map(self, table_name, query_filters):
'\n \n '
kwargs = {QUERY_FILTER: {}}
for (key, condition) in query_filters.items():
operator = condition.get(COMPARISON_OPERATOR)
if (operator not in QUERY_FILTER_VALUES):
raise ValueError('{0} must be one o... |
def get_consumed_capacity_map(self, return_consumed_capacity):
'\n Builds the consumed capacity map that is common to several operations\n '
if (return_consumed_capacity.upper() not in RETURN_CONSUMED_CAPACITY_VALUES):
raise ValueError('{0} must be one of {1}'.format(RETURN_ITEM_COLL_METRI... | -6,119,989,511,223,702,000 | Builds the consumed capacity map that is common to several operations | pynamodb/connection/base.py | get_consumed_capacity_map | dwelch91/PynamoDB | python | def get_consumed_capacity_map(self, return_consumed_capacity):
'\n \n '
if (return_consumed_capacity.upper() not in RETURN_CONSUMED_CAPACITY_VALUES):
raise ValueError('{0} must be one of {1}'.format(RETURN_ITEM_COLL_METRICS, RETURN_CONSUMED_CAPACITY_VALUES))
return {RETURN_CONSUMED_CAP... |
def get_return_values_map(self, return_values):
'\n Builds the return values map that is common to several operations\n '
if (return_values.upper() not in RETURN_VALUES_VALUES):
raise ValueError('{0} must be one of {1}'.format(RETURN_VALUES, RETURN_VALUES_VALUES))
return {RETURN_VALUES... | -1,790,315,102,523,764,700 | Builds the return values map that is common to several operations | pynamodb/connection/base.py | get_return_values_map | dwelch91/PynamoDB | python | def get_return_values_map(self, return_values):
'\n \n '
if (return_values.upper() not in RETURN_VALUES_VALUES):
raise ValueError('{0} must be one of {1}'.format(RETURN_VALUES, RETURN_VALUES_VALUES))
return {RETURN_VALUES: str(return_values).upper()} |
def get_item_collection_map(self, return_item_collection_metrics):
'\n Builds the item collection map\n '
if (return_item_collection_metrics.upper() not in RETURN_ITEM_COLL_METRICS_VALUES):
raise ValueError('{0} must be one of {1}'.format(RETURN_ITEM_COLL_METRICS, RETURN_ITEM_COLL_METRICS_... | -5,534,254,102,929,283,000 | Builds the item collection map | pynamodb/connection/base.py | get_item_collection_map | dwelch91/PynamoDB | python | def get_item_collection_map(self, return_item_collection_metrics):
'\n \n '
if (return_item_collection_metrics.upper() not in RETURN_ITEM_COLL_METRICS_VALUES):
raise ValueError('{0} must be one of {1}'.format(RETURN_ITEM_COLL_METRICS, RETURN_ITEM_COLL_METRICS_VALUES))
return {RETURN_IT... |
def get_exclusive_start_key_map(self, table_name, exclusive_start_key):
'\n Builds the exclusive start key attribute map\n '
tbl = self.get_meta_table(table_name)
if (tbl is None):
raise TableError('No such table {0}'.format(table_name))
return tbl.get_exclusive_start_key_map(exclu... | -9,065,540,817,265,543,000 | Builds the exclusive start key attribute map | pynamodb/connection/base.py | get_exclusive_start_key_map | dwelch91/PynamoDB | python | def get_exclusive_start_key_map(self, table_name, exclusive_start_key):
'\n \n '
tbl = self.get_meta_table(table_name)
if (tbl is None):
raise TableError('No such table {0}'.format(table_name))
return tbl.get_exclusive_start_key_map(exclusive_start_key) |
def delete_item(self, table_name, hash_key, range_key=None, condition=None, expected=None, conditional_operator=None, return_values=None, return_consumed_capacity=None, return_item_collection_metrics=None):
'\n Performs the DeleteItem operation and returns the result\n '
self._check_condition('con... | 983,130,726,870,653,800 | Performs the DeleteItem operation and returns the result | pynamodb/connection/base.py | delete_item | dwelch91/PynamoDB | python | def delete_item(self, table_name, hash_key, range_key=None, condition=None, expected=None, conditional_operator=None, return_values=None, return_consumed_capacity=None, return_item_collection_metrics=None):
'\n \n '
self._check_condition('condition', condition, expected, conditional_operator)
... |
def update_item(self, table_name, hash_key, range_key=None, actions=None, attribute_updates=None, condition=None, expected=None, return_consumed_capacity=None, conditional_operator=None, return_item_collection_metrics=None, return_values=None):
'\n Performs the UpdateItem operation\n '
self._check... | 590,127,341,153,676,000 | Performs the UpdateItem operation | pynamodb/connection/base.py | update_item | dwelch91/PynamoDB | python | def update_item(self, table_name, hash_key, range_key=None, actions=None, attribute_updates=None, condition=None, expected=None, return_consumed_capacity=None, conditional_operator=None, return_item_collection_metrics=None, return_values=None):
'\n \n '
self._check_actions(actions, attribute_updat... |
def put_item(self, table_name, hash_key, range_key=None, attributes=None, condition=None, expected=None, conditional_operator=None, return_values=None, return_consumed_capacity=None, return_item_collection_metrics=None):
'\n Performs the PutItem operation and returns the result\n '
self._check_con... | 6,717,633,873,929,923,000 | Performs the PutItem operation and returns the result | pynamodb/connection/base.py | put_item | dwelch91/PynamoDB | python | def put_item(self, table_name, hash_key, range_key=None, attributes=None, condition=None, expected=None, conditional_operator=None, return_values=None, return_consumed_capacity=None, return_item_collection_metrics=None):
'\n \n '
self._check_condition('condition', condition, expected, conditional_... |
def batch_write_item(self, table_name, put_items=None, delete_items=None, return_consumed_capacity=None, return_item_collection_metrics=None):
'\n Performs the batch_write_item operation\n '
if ((put_items is None) and (delete_items is None)):
raise ValueError('Either put_items or delete_i... | 5,590,380,452,570,849,000 | Performs the batch_write_item operation | pynamodb/connection/base.py | batch_write_item | dwelch91/PynamoDB | python | def batch_write_item(self, table_name, put_items=None, delete_items=None, return_consumed_capacity=None, return_item_collection_metrics=None):
'\n \n '
if ((put_items is None) and (delete_items is None)):
raise ValueError('Either put_items or delete_items must be specified')
operation_... |
def batch_get_item(self, table_name, keys, consistent_read=None, return_consumed_capacity=None, attributes_to_get=None):
'\n Performs the batch get item operation\n '
operation_kwargs = {REQUEST_ITEMS: {table_name: {}}}
args_map = {}
name_placeholders = {}
if consistent_read:
a... | 1,173,604,587,601,022,200 | Performs the batch get item operation | pynamodb/connection/base.py | batch_get_item | dwelch91/PynamoDB | python | def batch_get_item(self, table_name, keys, consistent_read=None, return_consumed_capacity=None, attributes_to_get=None):
'\n \n '
operation_kwargs = {REQUEST_ITEMS: {table_name: {}}}
args_map = {}
name_placeholders = {}
if consistent_read:
args_map[CONSISTENT_READ] = consistent... |
def get_item(self, table_name, hash_key, range_key=None, consistent_read=False, attributes_to_get=None):
'\n Performs the GetItem operation and returns the result\n '
operation_kwargs = {}
name_placeholders = {}
if (attributes_to_get is not None):
projection_expression = create_pro... | -1,897,549,044,289,928,200 | Performs the GetItem operation and returns the result | pynamodb/connection/base.py | get_item | dwelch91/PynamoDB | python | def get_item(self, table_name, hash_key, range_key=None, consistent_read=False, attributes_to_get=None):
'\n \n '
operation_kwargs = {}
name_placeholders = {}
if (attributes_to_get is not None):
projection_expression = create_projection_expression(attributes_to_get, name_placeholde... |
def rate_limited_scan(self, table_name, filter_condition=None, attributes_to_get=None, page_size=None, limit=None, conditional_operator=None, scan_filter=None, exclusive_start_key=None, segment=None, total_segments=None, timeout_seconds=None, read_capacity_to_consume_per_second=10, allow_rate_limited_scan_without_consu... | -145,864,167,132,673,200 | Performs a rate limited scan on the table. The API uses the scan API to fetch items from
DynamoDB. The rate_limited_scan uses the 'ConsumedCapacity' value returned from DynamoDB to
limit the rate of the scan. 'ProvisionedThroughputExceededException' is also handled and retried.
:param table_name: Name of the table to ... | pynamodb/connection/base.py | rate_limited_scan | dwelch91/PynamoDB | python | def rate_limited_scan(self, table_name, filter_condition=None, attributes_to_get=None, page_size=None, limit=None, conditional_operator=None, scan_filter=None, exclusive_start_key=None, segment=None, total_segments=None, timeout_seconds=None, read_capacity_to_consume_per_second=10, allow_rate_limited_scan_without_consu... |
def scan(self, table_name, filter_condition=None, attributes_to_get=None, limit=None, conditional_operator=None, scan_filter=None, return_consumed_capacity=None, exclusive_start_key=None, segment=None, total_segments=None, consistent_read=None, index_name=None):
'\n Performs the scan operation\n '
... | 4,201,838,212,909,153,000 | Performs the scan operation | pynamodb/connection/base.py | scan | dwelch91/PynamoDB | python | def scan(self, table_name, filter_condition=None, attributes_to_get=None, limit=None, conditional_operator=None, scan_filter=None, return_consumed_capacity=None, exclusive_start_key=None, segment=None, total_segments=None, consistent_read=None, index_name=None):
'\n \n '
self._check_condition('fil... |
def query(self, table_name, hash_key, range_key_condition=None, filter_condition=None, attributes_to_get=None, consistent_read=False, exclusive_start_key=None, index_name=None, key_conditions=None, query_filters=None, conditional_operator=None, limit=None, return_consumed_capacity=None, scan_index_forward=None, select=... | -172,714,989,958,527,460 | Performs the Query operation and returns the result | pynamodb/connection/base.py | query | dwelch91/PynamoDB | python | def query(self, table_name, hash_key, range_key_condition=None, filter_condition=None, attributes_to_get=None, consistent_read=False, exclusive_start_key=None, index_name=None, key_conditions=None, query_filters=None, conditional_operator=None, limit=None, return_consumed_capacity=None, scan_index_forward=None, select=... |
def _get_condition_expression(self, table_name, expected, conditional_operator, name_placeholders, expression_attribute_values):
'\n Builds the ConditionExpression needed for DeleteItem, PutItem, and UpdateItem operations\n '
condition_expression = None
conditional_operator = conditional_opera... | -7,477,454,266,131,427,000 | Builds the ConditionExpression needed for DeleteItem, PutItem, and UpdateItem operations | pynamodb/connection/base.py | _get_condition_expression | dwelch91/PynamoDB | python | def _get_condition_expression(self, table_name, expected, conditional_operator, name_placeholders, expression_attribute_values):
'\n \n '
condition_expression = None
conditional_operator = conditional_operator[CONDITIONAL_OPERATOR]
for key in sorted(expected.keys()):
condition = ex... |
def _get_filter_expression(self, table_name, filters, conditional_operator, name_placeholders, expression_attribute_values):
'\n Builds the FilterExpression needed for Query and Scan operations\n '
condition_expression = None
conditional_operator = conditional_operator[CONDITIONAL_OPERATOR]
... | -751,700,787,242,809,300 | Builds the FilterExpression needed for Query and Scan operations | pynamodb/connection/base.py | _get_filter_expression | dwelch91/PynamoDB | python | def _get_filter_expression(self, table_name, filters, conditional_operator, name_placeholders, expression_attribute_values):
'\n \n '
condition_expression = None
conditional_operator = conditional_operator[CONDITIONAL_OPERATOR]
for key in sorted(filters.keys()):
condition = filters... |
def __init__(self, config_service):
'Constructor for ChartService.\n\n Args:\n config_service (ConfigService): An instance of ConfigService.\n '
self.config_service = config_service
self.issuesnapshot_tbl = sql.SQLTableManager(ISSUESNAPSHOT_TABLE_NAME)
self.issuesnapshot2cc_tbl = sql.SQLTable... | 5,948,840,418,396,036,000 | Constructor for ChartService.
Args:
config_service (ConfigService): An instance of ConfigService. | appengine/monorail/services/chart_svc.py | __init__ | xinghun61/infra | python | def __init__(self, config_service):
'Constructor for ChartService.\n\n Args:\n config_service (ConfigService): An instance of ConfigService.\n '
self.config_service = config_service
self.issuesnapshot_tbl = sql.SQLTableManager(ISSUESNAPSHOT_TABLE_NAME)
self.issuesnapshot2cc_tbl = sql.SQLTable... |
def QueryIssueSnapshots(self, cnxn, services, unixtime, effective_ids, project, perms, group_by=None, label_prefix=None, query=None, canned_query=None):
'Queries historical issue counts grouped by label or component.\n\n Args:\n cnxn: A MonorailConnection instance.\n services: A Services instance.\n ... | -6,555,669,726,240,379,000 | Queries historical issue counts grouped by label or component.
Args:
cnxn: A MonorailConnection instance.
services: A Services instance.
unixtime: An integer representing the Unix time in seconds.
effective_ids: The effective User IDs associated with the current user.
project: A project object representing t... | appengine/monorail/services/chart_svc.py | QueryIssueSnapshots | xinghun61/infra | python | def QueryIssueSnapshots(self, cnxn, services, unixtime, effective_ids, project, perms, group_by=None, label_prefix=None, query=None, canned_query=None):
'Queries historical issue counts grouped by label or component.\n\n Args:\n cnxn: A MonorailConnection instance.\n services: A Services instance.\n ... |
def StoreIssueSnapshots(self, cnxn, issues, commit=True):
'Adds an IssueSnapshot and updates the previous one for each issue.'
for issue in issues:
right_now = self._currentTime()
self.issuesnapshot_tbl.Update(cnxn, delta={'period_end': right_now}, where=[('IssueSnapshot.issue_id = %s', [issue.i... | 8,419,155,530,821,845,000 | Adds an IssueSnapshot and updates the previous one for each issue. | appengine/monorail/services/chart_svc.py | StoreIssueSnapshots | xinghun61/infra | python | def StoreIssueSnapshots(self, cnxn, issues, commit=True):
for issue in issues:
right_now = self._currentTime()
self.issuesnapshot_tbl.Update(cnxn, delta={'period_end': right_now}, where=[('IssueSnapshot.issue_id = %s', [issue.issue_id]), ('IssueSnapshot.period_end = %s', [settings.maximum_snaps... |
def ExpungeHotlistsFromIssueSnapshots(self, cnxn, hotlist_ids):
'Expunge the existence of hotlists from issue snapshots.\n\n This method will not commit the operation. This method will not make\n changes to in-memory data.\n\n Args:\n cnxn: connection to SQL database.\n hotlist_ids: list of hotli... | -3,049,056,143,069,790,000 | Expunge the existence of hotlists from issue snapshots.
This method will not commit the operation. This method will not make
changes to in-memory data.
Args:
cnxn: connection to SQL database.
hotlist_ids: list of hotlist_ids for hotlists we want to delete. | appengine/monorail/services/chart_svc.py | ExpungeHotlistsFromIssueSnapshots | xinghun61/infra | python | def ExpungeHotlistsFromIssueSnapshots(self, cnxn, hotlist_ids):
'Expunge the existence of hotlists from issue snapshots.\n\n This method will not commit the operation. This method will not make\n changes to in-memory data.\n\n Args:\n cnxn: connection to SQL database.\n hotlist_ids: list of hotli... |
def _currentTime(self):
'This is a separate method so it can be mocked by tests.'
return time.time() | 2,013,309,874,087,380,700 | This is a separate method so it can be mocked by tests. | appengine/monorail/services/chart_svc.py | _currentTime | xinghun61/infra | python | def _currentTime(self):
return time.time() |
def _QueryToWhere(self, cnxn, services, project_config, query, canned_query, project):
'Parses a query string into LEFT JOIN and WHERE conditions.\n\n Args:\n cnxn: A MonorailConnection instance.\n services: A Services instance.\n project_config: The configuration for the given project.\n que... | 5,127,788,299,201,442,000 | Parses a query string into LEFT JOIN and WHERE conditions.
Args:
cnxn: A MonorailConnection instance.
services: A Services instance.
project_config: The configuration for the given project.
query (string): The query to parse.
canned_query (string): The supplied canned query.
project: The current project.
... | appengine/monorail/services/chart_svc.py | _QueryToWhere | xinghun61/infra | python | def _QueryToWhere(self, cnxn, services, project_config, query, canned_query, project):
'Parses a query string into LEFT JOIN and WHERE conditions.\n\n Args:\n cnxn: A MonorailConnection instance.\n services: A Services instance.\n project_config: The configuration for the given project.\n que... |
def _BuildSnapshotQuery(self, cols, where, joins, group_by, shard_id):
'Given SQL arguments, executes a snapshot COUNT query.'
stmt = sql.Statement.MakeSelect('IssueSnapshot', cols, distinct=True)
stmt.AddJoinClauses(joins, left=True)
stmt.AddWhereTerms((where + [('IssueSnapshot.shard = %s', [shard_id])... | 7,904,565,383,243,689,000 | Given SQL arguments, executes a snapshot COUNT query. | appengine/monorail/services/chart_svc.py | _BuildSnapshotQuery | xinghun61/infra | python | def _BuildSnapshotQuery(self, cols, where, joins, group_by, shard_id):
stmt = sql.Statement.MakeSelect('IssueSnapshot', cols, distinct=True)
stmt.AddJoinClauses(joins, left=True)
stmt.AddWhereTerms((where + [('IssueSnapshot.shard = %s', [shard_id])]))
if group_by:
stmt.AddGroupByTerms(group... |
def item_resolver(loan_pid):
'Resolve an Item given a Loan PID.'
Loan = current_circulation.loan_record_cls
loan = Loan.get_record_by_pid(loan_pid)
if (not loan.get('item_pid')):
return {}
try:
item = resolve_item_from_loan(loan['item_pid'])
except PIDDeletedError:
item =... | -3,242,135,409,896,678,400 | Resolve an Item given a Loan PID. | invenio_app_ils/circulation/jsonresolvers/loan.py | item_resolver | equadon/invenio-app-ils | python | def item_resolver(loan_pid):
Loan = current_circulation.loan_record_cls
loan = Loan.get_record_by_pid(loan_pid)
if (not loan.get('item_pid')):
return {}
try:
item = resolve_item_from_loan(loan['item_pid'])
except PIDDeletedError:
item = {}
else:
item = pick(i... |
@get_pid_or_default(default_value=dict())
def loan_patron_resolver(loan_pid):
'Resolve a Patron given a Loan PID.'
Loan = current_circulation.loan_record_cls
try:
patron_pid = get_field_value(Loan, loan_pid, 'patron_pid')
except KeyError:
return {}
return get_patron(patron_pid) | 4,676,525,259,656,586,000 | Resolve a Patron given a Loan PID. | invenio_app_ils/circulation/jsonresolvers/loan.py | loan_patron_resolver | equadon/invenio-app-ils | python | @get_pid_or_default(default_value=dict())
def loan_patron_resolver(loan_pid):
Loan = current_circulation.loan_record_cls
try:
patron_pid = get_field_value(Loan, loan_pid, 'patron_pid')
except KeyError:
return {}
return get_patron(patron_pid) |
@get_pid_or_default(default_value=dict())
def document_resolver(loan_pid):
'Resolve a Document given a Loan PID.'
Loan = current_circulation.loan_record_cls
try:
document_pid = get_field_value(Loan, loan_pid, 'document_pid')
except KeyError:
return {}
Document = current_app_ils.docum... | -3,565,126,571,594,388,500 | Resolve a Document given a Loan PID. | invenio_app_ils/circulation/jsonresolvers/loan.py | document_resolver | equadon/invenio-app-ils | python | @get_pid_or_default(default_value=dict())
def document_resolver(loan_pid):
Loan = current_circulation.loan_record_cls
try:
document_pid = get_field_value(Loan, loan_pid, 'document_pid')
except KeyError:
return {}
Document = current_app_ils.document_record_cls
try:
docume... |
def imports_in_module(module):
"\n Get a list of strings showing what is imported in a module.\n\n :param module: An actual module object the file of the module (as given by inspect.getfile(module)\n :return: A list of strings showing the imported objects (modules, functions, variables, classes...)\n\n ... | 2,330,081,719,587,653,000 | Get a list of strings showing what is imported in a module.
:param module: An actual module object the file of the module (as given by inspect.getfile(module)
:return: A list of strings showing the imported objects (modules, functions, variables, classes...)
Note: Requires having snakefood installed:
http://furius.ca... | tec/snake_food_import_counting.py | imports_in_module | thorwhalen/tec | python | def imports_in_module(module):
"\n Get a list of strings showing what is imported in a module.\n\n :param module: An actual module object the file of the module (as given by inspect.getfile(module)\n :return: A list of strings showing the imported objects (modules, functions, variables, classes...)\n\n ... |
def base_modules_used_in_module(module):
"\n Get a list of strings showing what base modules that are imported in a module.\n :param module: An actual module object the file of the module (as given by inspect.getfile(module)\n :return: A list of strings showing the imported base modules (i.e. the X of impo... | -2,815,861,855,548,621,000 | Get a list of strings showing what base modules that are imported in a module.
:param module: An actual module object the file of the module (as given by inspect.getfile(module)
:return: A list of strings showing the imported base modules (i.e. the X of import X.Y.Z or from X.Y import Z).
Note: Requires having snakefo... | tec/snake_food_import_counting.py | base_modules_used_in_module | thorwhalen/tec | python | def base_modules_used_in_module(module):
"\n Get a list of strings showing what base modules that are imported in a module.\n :param module: An actual module object the file of the module (as given by inspect.getfile(module)\n :return: A list of strings showing the imported base modules (i.e. the X of impo... |
def base_module_imports_in_module_recursive(module):
"\n Get a list of strings showing what base modules that are imported in a module, recursively.\n It's the recursive version of the base_modules_used_in_module function.\n Recursive in the sense that if module is a package module (i.e. containing a __ini... | 2,093,338,792,277,364,500 | Get a list of strings showing what base modules that are imported in a module, recursively.
It's the recursive version of the base_modules_used_in_module function.
Recursive in the sense that if module is a package module (i.e. containing a __init__.py and further submodules),
the base_modules_used_in_module function w... | tec/snake_food_import_counting.py | base_module_imports_in_module_recursive | thorwhalen/tec | python | def base_module_imports_in_module_recursive(module):
"\n Get a list of strings showing what base modules that are imported in a module, recursively.\n It's the recursive version of the base_modules_used_in_module function.\n Recursive in the sense that if module is a package module (i.e. containing a __ini... |
def pip_licenses_df(package_names=None, include_module_name=True, on_module_search_error=None):
'\n Get a dataframe of pip packages and licences\n :return:\n '
pip_licenses_output = subprocess.check_output(['pip-licenses'])
t = list(map(str.strip, list(filter(word_or_letter_p.search, pip_licenses_o... | 5,186,224,329,381,209,000 | Get a dataframe of pip packages and licences
:return: | tec/snake_food_import_counting.py | pip_licenses_df | thorwhalen/tec | python | def pip_licenses_df(package_names=None, include_module_name=True, on_module_search_error=None):
'\n Get a dataframe of pip packages and licences\n :return:\n '
pip_licenses_output = subprocess.check_output(['pip-licenses'])
t = list(map(str.strip, list(filter(word_or_letter_p.search, pip_licenses_o... |
def get_cfg_defaults():
'Get a yacs CfgNode object with default values for my_project.'
return _C.clone() | 3,392,797,044,932,206,600 | Get a yacs CfgNode object with default values for my_project. | connectomics/config/config.py | get_cfg_defaults | divyam-goel/pytorch_connectomics | python | def get_cfg_defaults():
return _C.clone() |
def save_all_cfg(cfg, output_dir):
'Save configs in the output directory.'
path = os.path.join(output_dir, 'config.yaml')
with open(path, 'w') as f:
f.write(cfg.dump())
print('Full config saved to {}'.format(path)) | -8,759,634,719,066,668,000 | Save configs in the output directory. | connectomics/config/config.py | save_all_cfg | divyam-goel/pytorch_connectomics | python | def save_all_cfg(cfg, output_dir):
path = os.path.join(output_dir, 'config.yaml')
with open(path, 'w') as f:
f.write(cfg.dump())
print('Full config saved to {}'.format(path)) |
def _choose_factor(factors, x, v, dom=QQ, prec=200, bound=5):
'\n Return a factor having root ``v``\n It is assumed that one of the factors has root ``v``.\n\n '
if isinstance(factors[0], tuple):
factors = [f[0] for f in factors]
if (len(factors) == 1):
return factors[0]
points ... | -4,111,242,513,032,327,000 | Return a factor having root ``v``
It is assumed that one of the factors has root ``v``. | diofant/polys/numberfields.py | _choose_factor | diofant/diofant | python | def _choose_factor(factors, x, v, dom=QQ, prec=200, bound=5):
'\n Return a factor having root ``v``\n It is assumed that one of the factors has root ``v``.\n\n '
if isinstance(factors[0], tuple):
factors = [f[0] for f in factors]
if (len(factors) == 1):
return factors[0]
points ... |
def _separate_sq(p):
'\n Helper function for ``_minimal_polynomial_sq``.\n\n It selects a rational ``g`` such that the polynomial ``p``\n consists of a sum of terms whose surds squared have gcd equal to ``g``\n and a sum of terms with surds squared prime with ``g``;\n then it takes the field norm to ... | -5,024,148,606,912,892,000 | Helper function for ``_minimal_polynomial_sq``.
It selects a rational ``g`` such that the polynomial ``p``
consists of a sum of terms whose surds squared have gcd equal to ``g``
and a sum of terms with surds squared prime with ``g``;
then it takes the field norm to eliminate ``sqrt(g)``
See simplify.simplify.split_su... | diofant/polys/numberfields.py | _separate_sq | diofant/diofant | python | def _separate_sq(p):
'\n Helper function for ``_minimal_polynomial_sq``.\n\n It selects a rational ``g`` such that the polynomial ``p``\n consists of a sum of terms whose surds squared have gcd equal to ``g``\n and a sum of terms with surds squared prime with ``g``;\n then it takes the field norm to ... |
def _minimal_polynomial_sq(p, n, x):
'\n Returns the minimal polynomial for the ``nth-root`` of a sum of surds\n or ``None`` if it fails.\n\n Parameters\n ==========\n\n p : sum of surds\n n : positive integer\n x : variable of the returned polynomial\n\n Examples\n ========\n\n >>> q ... | 4,186,569,879,789,552,600 | Returns the minimal polynomial for the ``nth-root`` of a sum of surds
or ``None`` if it fails.
Parameters
==========
p : sum of surds
n : positive integer
x : variable of the returned polynomial
Examples
========
>>> q = 1 + sqrt(2) + sqrt(3)
>>> _minimal_polynomial_sq(q, 3, x)
x**12 - 4*x**9 - 4*x**6 + 16*x**3 - 8 | diofant/polys/numberfields.py | _minimal_polynomial_sq | diofant/diofant | python | def _minimal_polynomial_sq(p, n, x):
'\n Returns the minimal polynomial for the ``nth-root`` of a sum of surds\n or ``None`` if it fails.\n\n Parameters\n ==========\n\n p : sum of surds\n n : positive integer\n x : variable of the returned polynomial\n\n Examples\n ========\n\n >>> q ... |
def _minpoly_op_algebraic_element(op, ex1, ex2, x, dom, mp1=None, mp2=None):
'\n Return the minimal polynomial for ``op(ex1, ex2)``.\n\n Parameters\n ==========\n\n op : operation ``Add`` or ``Mul``\n ex1, ex2 : expressions for the algebraic elements\n x : indeterminate of the polynomials\n dom... | 7,391,582,443,222,066,000 | Return the minimal polynomial for ``op(ex1, ex2)``.
Parameters
==========
op : operation ``Add`` or ``Mul``
ex1, ex2 : expressions for the algebraic elements
x : indeterminate of the polynomials
dom: ground domain
mp1, mp2 : minimal polynomials for ``ex1`` and ``ex2`` or None
Examples
========
>>> p1 = sqrt(sqrt(2)... | diofant/polys/numberfields.py | _minpoly_op_algebraic_element | diofant/diofant | python | def _minpoly_op_algebraic_element(op, ex1, ex2, x, dom, mp1=None, mp2=None):
'\n Return the minimal polynomial for ``op(ex1, ex2)``.\n\n Parameters\n ==========\n\n op : operation ``Add`` or ``Mul``\n ex1, ex2 : expressions for the algebraic elements\n x : indeterminate of the polynomials\n dom... |
def _invertx(p, x):
'Returns ``expand_mul(x**degree(p, x)*p.subs({x: 1/x}))``.'
(p1,) = parallel_poly_from_expr((p,), x)[0]
n = degree(p1)
a = [(c * (x ** (n - i))) for ((i,), c) in p1.terms()]
return Add(*a) | 6,602,618,625,459,212,000 | Returns ``expand_mul(x**degree(p, x)*p.subs({x: 1/x}))``. | diofant/polys/numberfields.py | _invertx | diofant/diofant | python | def _invertx(p, x):
(p1,) = parallel_poly_from_expr((p,), x)[0]
n = degree(p1)
a = [(c * (x ** (n - i))) for ((i,), c) in p1.terms()]
return Add(*a) |
def _muly(p, x, y):
'Returns ``_mexpand(y**deg*p.subs({x:x / y}))``.'
(p1,) = parallel_poly_from_expr((p,), x)[0]
n = degree(p1)
a = [((c * (x ** i)) * (y ** (n - i))) for ((i,), c) in p1.terms()]
return Add(*a) | -1,235,841,338,616,942,800 | Returns ``_mexpand(y**deg*p.subs({x:x / y}))``. | diofant/polys/numberfields.py | _muly | diofant/diofant | python | def _muly(p, x, y):
(p1,) = parallel_poly_from_expr((p,), x)[0]
n = degree(p1)
a = [((c * (x ** i)) * (y ** (n - i))) for ((i,), c) in p1.terms()]
return Add(*a) |
def _minpoly_pow(ex, pw, x, dom):
'\n Returns ``minimal_polynomial(ex**pw)``\n\n Parameters\n ==========\n\n ex : algebraic element\n pw : rational number\n x : indeterminate of the polynomial\n dom: ground domain\n\n Examples\n ========\n\n >>> p = sqrt(1 + sqrt(2))\n >>> _minpoly_... | -7,254,962,932,684,855,000 | Returns ``minimal_polynomial(ex**pw)``
Parameters
==========
ex : algebraic element
pw : rational number
x : indeterminate of the polynomial
dom: ground domain
Examples
========
>>> p = sqrt(1 + sqrt(2))
>>> _minpoly_pow(p, 2, x, QQ)
x**2 - 2*x - 1
>>> minimal_polynomial(p**2)(x)
x**2 - 2*x - 1
>>> _minpoly_pow(y, ... | diofant/polys/numberfields.py | _minpoly_pow | diofant/diofant | python | def _minpoly_pow(ex, pw, x, dom):
'\n Returns ``minimal_polynomial(ex**pw)``\n\n Parameters\n ==========\n\n ex : algebraic element\n pw : rational number\n x : indeterminate of the polynomial\n dom: ground domain\n\n Examples\n ========\n\n >>> p = sqrt(1 + sqrt(2))\n >>> _minpoly_... |
def _minpoly_add(x, dom, *a):
'Returns ``minimal_polynomial(Add(*a), dom)``.'
mp = _minpoly_op_algebraic_element(Add, a[0], a[1], x, dom)
p = (a[0] + a[1])
for px in a[2:]:
mp = _minpoly_op_algebraic_element(Add, p, px, x, dom, mp1=mp)
p = (p + px)
return mp | -1,227,765,417,159,476,500 | Returns ``minimal_polynomial(Add(*a), dom)``. | diofant/polys/numberfields.py | _minpoly_add | diofant/diofant | python | def _minpoly_add(x, dom, *a):
mp = _minpoly_op_algebraic_element(Add, a[0], a[1], x, dom)
p = (a[0] + a[1])
for px in a[2:]:
mp = _minpoly_op_algebraic_element(Add, p, px, x, dom, mp1=mp)
p = (p + px)
return mp |
def _minpoly_mul(x, dom, *a):
'Returns ``minimal_polynomial(Mul(*a), dom)``.'
mp = _minpoly_op_algebraic_element(Mul, a[0], a[1], x, dom)
p = (a[0] * a[1])
for px in a[2:]:
mp = _minpoly_op_algebraic_element(Mul, p, px, x, dom, mp1=mp)
p = (p * px)
return mp | -8,857,705,141,823,034,000 | Returns ``minimal_polynomial(Mul(*a), dom)``. | diofant/polys/numberfields.py | _minpoly_mul | diofant/diofant | python | def _minpoly_mul(x, dom, *a):
mp = _minpoly_op_algebraic_element(Mul, a[0], a[1], x, dom)
p = (a[0] * a[1])
for px in a[2:]:
mp = _minpoly_op_algebraic_element(Mul, p, px, x, dom, mp1=mp)
p = (p * px)
return mp |
def _minpoly_sin(ex, x):
'\n Returns the minimal polynomial of ``sin(ex)``\n see https://mathworld.wolfram.com/TrigonometryAngles.html\n\n '
(c, a) = ex.args[0].as_coeff_Mul()
if (a is pi):
n = c.denominator
q = sympify(n)
if q.is_prime:
a = chebyshevt_poly(n, po... | -1,322,492,182,160,284,400 | Returns the minimal polynomial of ``sin(ex)``
see https://mathworld.wolfram.com/TrigonometryAngles.html | diofant/polys/numberfields.py | _minpoly_sin | diofant/diofant | python | def _minpoly_sin(ex, x):
'\n Returns the minimal polynomial of ``sin(ex)``\n see https://mathworld.wolfram.com/TrigonometryAngles.html\n\n '
(c, a) = ex.args[0].as_coeff_Mul()
if (a is pi):
n = c.denominator
q = sympify(n)
if q.is_prime:
a = chebyshevt_poly(n, po... |
def _minpoly_cos(ex, x):
'\n Returns the minimal polynomial of ``cos(ex)``\n see https://mathworld.wolfram.com/TrigonometryAngles.html\n\n '
(c, a) = ex.args[0].as_coeff_Mul()
if (a is pi):
if (c.numerator == 1):
if (c.denominator == 7):
return ((((8 * (x ** 3)) ... | -6,751,102,412,441,725,000 | Returns the minimal polynomial of ``cos(ex)``
see https://mathworld.wolfram.com/TrigonometryAngles.html | diofant/polys/numberfields.py | _minpoly_cos | diofant/diofant | python | def _minpoly_cos(ex, x):
'\n Returns the minimal polynomial of ``cos(ex)``\n see https://mathworld.wolfram.com/TrigonometryAngles.html\n\n '
(c, a) = ex.args[0].as_coeff_Mul()
if (a is pi):
if (c.numerator == 1):
if (c.denominator == 7):
return ((((8 * (x ** 3)) ... |
def _minpoly_tan(ex, x):
'Returns the minimal polynomial of ``tan(ex)``.'
(c, a) = ex.args[0].as_coeff_Mul()
if ((a is pi) and c.is_Rational):
c *= 2
n = c.denominator
a = (n if ((c.numerator % 2) == 0) else 1)
terms = []
for k in range(((c.numerator + 1) % 2), (n + 1... | 2,288,737,244,398,866,400 | Returns the minimal polynomial of ``tan(ex)``. | diofant/polys/numberfields.py | _minpoly_tan | diofant/diofant | python | def _minpoly_tan(ex, x):
(c, a) = ex.args[0].as_coeff_Mul()
if ((a is pi) and c.is_Rational):
c *= 2
n = c.denominator
a = (n if ((c.numerator % 2) == 0) else 1)
terms = []
for k in range(((c.numerator + 1) % 2), (n + 1), 2):
terms.append((a * (x ** k)))
... |
def _minpoly_exp(ex, x):
'Returns the minimal polynomial of ``exp(ex)``.'
(c, a) = ex.exp.as_coeff_Mul()
q = sympify(c.denominator)
if (a == (I * pi)):
if (c.numerator in (1, (- 1))):
if (q == 3):
return (((x ** 2) - x) + 1)
if (q == 4):
re... | -8,084,815,998,895,631,000 | Returns the minimal polynomial of ``exp(ex)``. | diofant/polys/numberfields.py | _minpoly_exp | diofant/diofant | python | def _minpoly_exp(ex, x):
(c, a) = ex.exp.as_coeff_Mul()
q = sympify(c.denominator)
if (a == (I * pi)):
if (c.numerator in (1, (- 1))):
if (q == 3):
return (((x ** 2) - x) + 1)
if (q == 4):
return ((x ** 4) + 1)
if (q == 6):
... |
def _minpoly_rootof(ex, x):
'Returns the minimal polynomial of a ``RootOf`` object.'
domain = ex.poly.domain
if domain.is_IntegerRing:
return ex.poly(x)
else:
return ex.poly.sqf_norm()[(- 1)](x) | -4,655,506,516,199,611,000 | Returns the minimal polynomial of a ``RootOf`` object. | diofant/polys/numberfields.py | _minpoly_rootof | diofant/diofant | python | def _minpoly_rootof(ex, x):
domain = ex.poly.domain
if domain.is_IntegerRing:
return ex.poly(x)
else:
return ex.poly.sqf_norm()[(- 1)](x) |
def _minpoly_compose(ex, x, dom):
"\n Computes the minimal polynomial of an algebraic element\n using operations on minimal polynomials\n\n Examples\n ========\n\n >>> minimal_polynomial(sqrt(2) + 3*Rational(1, 3), method='compose')(x)\n x**2 - 2*x - 1\n >>> minimal_polynomial(sqrt(y) + 1/y, me... | 8,488,437,649,754,395,000 | Computes the minimal polynomial of an algebraic element
using operations on minimal polynomials
Examples
========
>>> minimal_polynomial(sqrt(2) + 3*Rational(1, 3), method='compose')(x)
x**2 - 2*x - 1
>>> minimal_polynomial(sqrt(y) + 1/y, method='compose')(x)
x**2*y**2 - 2*x*y - y**3 + 1 | diofant/polys/numberfields.py | _minpoly_compose | diofant/diofant | python | def _minpoly_compose(ex, x, dom):
"\n Computes the minimal polynomial of an algebraic element\n using operations on minimal polynomials\n\n Examples\n ========\n\n >>> minimal_polynomial(sqrt(2) + 3*Rational(1, 3), method='compose')(x)\n x**2 - 2*x - 1\n >>> minimal_polynomial(sqrt(y) + 1/y, me... |
@cacheit
def minimal_polynomial(ex, method=None, **args):
'\n Computes the minimal polynomial of an algebraic element.\n\n Parameters\n ==========\n\n ex : algebraic element expression\n method : str, optional\n If ``compose``, the minimal polynomial of the subexpressions\n of ``ex`` ar... | -2,723,472,507,521,778,000 | Computes the minimal polynomial of an algebraic element.
Parameters
==========
ex : algebraic element expression
method : str, optional
If ``compose``, the minimal polynomial of the subexpressions
of ``ex`` are computed, then the arithmetic operations on them are
performed using the resultant and factoriz... | diofant/polys/numberfields.py | minimal_polynomial | diofant/diofant | python | @cacheit
def minimal_polynomial(ex, method=None, **args):
'\n Computes the minimal polynomial of an algebraic element.\n\n Parameters\n ==========\n\n ex : algebraic element expression\n method : str, optional\n If ``compose``, the minimal polynomial of the subexpressions\n of ``ex`` ar... |
def minpoly_groebner(ex, x, domain):
"\n Computes the minimal polynomial of an algebraic number\n using Gröbner bases\n\n Examples\n ========\n\n >>> minimal_polynomial(sqrt(2) + 1, method='groebner')(x)\n x**2 - 2*x - 1\n\n References\n ==========\n\n * :cite:`Adams1994intro`\n\n "
... | -2,596,188,770,929,469,400 | Computes the minimal polynomial of an algebraic number
using Gröbner bases
Examples
========
>>> minimal_polynomial(sqrt(2) + 1, method='groebner')(x)
x**2 - 2*x - 1
References
==========
* :cite:`Adams1994intro` | diofant/polys/numberfields.py | minpoly_groebner | diofant/diofant | python | def minpoly_groebner(ex, x, domain):
"\n Computes the minimal polynomial of an algebraic number\n using Gröbner bases\n\n Examples\n ========\n\n >>> minimal_polynomial(sqrt(2) + 1, method='groebner')(x)\n x**2 - 2*x - 1\n\n References\n ==========\n\n * :cite:`Adams1994intro`\n\n "
... |
def primitive_element(extension, **args):
'Construct a common number field for all extensions.\n\n References\n ==========\n\n * :cite:`Yokoyama1989primitive`\n * :cite:`Arno1996alg`\n\n '
if (not extension):
raise ValueError("can't compute primitive element for empty extension")
exte... | 4,042,525,359,445,781,000 | Construct a common number field for all extensions.
References
==========
* :cite:`Yokoyama1989primitive`
* :cite:`Arno1996alg` | diofant/polys/numberfields.py | primitive_element | diofant/diofant | python | def primitive_element(extension, **args):
'Construct a common number field for all extensions.\n\n References\n ==========\n\n * :cite:`Yokoyama1989primitive`\n * :cite:`Arno1996alg`\n\n '
if (not extension):
raise ValueError("can't compute primitive element for empty extension")
exte... |
def field_isomorphism_pslq(a, b):
'Construct field isomorphism using PSLQ algorithm.'
if (not all(((_.domain.is_RationalField and _.ext.is_real) for _ in (a, b)))):
raise NotImplementedError("PSLQ doesn't support complex coefficients")
f = a.minpoly
x = f.gen
g = b.minpoly.replace(x)
m =... | 1,884,085,335,010,954,500 | Construct field isomorphism using PSLQ algorithm. | diofant/polys/numberfields.py | field_isomorphism_pslq | diofant/diofant | python | def field_isomorphism_pslq(a, b):
if (not all(((_.domain.is_RationalField and _.ext.is_real) for _ in (a, b)))):
raise NotImplementedError("PSLQ doesn't support complex coefficients")
f = a.minpoly
x = f.gen
g = b.minpoly.replace(x)
m = g.degree()
(a, b) = (a.ext, b.ext)
for n i... |
def field_isomorphism_factor(a, b):
'Construct field isomorphism via factorization.'
p = a.minpoly.set_domain(b)
(_, factors) = p.factor_list()
for (f, _) in factors:
if (f.degree() == 1):
root = ((- f.rep[(0,)]) / f.rep[(1,)])
if ((a.ext - b.to_expr(root)).evalf(chop=Tru... | -2,024,312,904,389,071,600 | Construct field isomorphism via factorization. | diofant/polys/numberfields.py | field_isomorphism_factor | diofant/diofant | python | def field_isomorphism_factor(a, b):
p = a.minpoly.set_domain(b)
(_, factors) = p.factor_list()
for (f, _) in factors:
if (f.degree() == 1):
root = ((- f.rep[(0,)]) / f.rep[(1,)])
if ((a.ext - b.to_expr(root)).evalf(chop=True) == 0):
return root.rep.all_co... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.