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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
senseobservationsystems/commonsense-python-lib
senseapi.py
SenseAPI.DataProcessorsGet
def DataProcessorsGet(self, parameters): """ List the users data processors. @param parameters (dictonary) - Dictionary containing the parameters of the request. @return (bool) - Boolean indicating whether this call was successful. ...
python
def DataProcessorsGet(self, parameters): """ List the users data processors. @param parameters (dictonary) - Dictionary containing the parameters of the request. @return (bool) - Boolean indicating whether this call was successful. ...
[ "def", "DataProcessorsGet", "(", "self", ",", "parameters", ")", ":", "if", "self", ".", "__SenseApiCall__", "(", "'/dataprocessors.json'", ",", "'GET'", ",", "parameters", "=", "parameters", ")", ":", "return", "True", "else", ":", "self", ".", "__error__", ...
List the users data processors. @param parameters (dictonary) - Dictionary containing the parameters of the request. @return (bool) - Boolean indicating whether this call was successful.
[ "List", "the", "users", "data", "processors", "." ]
aac59a1751ef79eb830b3ca1fab6ef2c83931f87
https://github.com/senseobservationsystems/commonsense-python-lib/blob/aac59a1751ef79eb830b3ca1fab6ef2c83931f87/senseapi.py#L1797-L1809
train
63,300
senseobservationsystems/commonsense-python-lib
senseapi.py
SenseAPI.DataProcessorsDelete
def DataProcessorsDelete(self, dataProcessorId): """ Delete a data processor in CommonSense. @param dataProcessorId - The id of the data processor that will be deleted. @return (bool) - Boolean indicating whether GroupsP...
python
def DataProcessorsDelete(self, dataProcessorId): """ Delete a data processor in CommonSense. @param dataProcessorId - The id of the data processor that will be deleted. @return (bool) - Boolean indicating whether GroupsP...
[ "def", "DataProcessorsDelete", "(", "self", ",", "dataProcessorId", ")", ":", "if", "self", ".", "__SenseApiCall__", "(", "'/dataprocessors/{id}.json'", ".", "format", "(", "id", "=", "dataProcessorId", ")", ",", "'DELETE'", ")", ":", "return", "True", "else", ...
Delete a data processor in CommonSense. @param dataProcessorId - The id of the data processor that will be deleted. @return (bool) - Boolean indicating whether GroupsPost was successful.
[ "Delete", "a", "data", "processor", "in", "CommonSense", "." ]
aac59a1751ef79eb830b3ca1fab6ef2c83931f87
https://github.com/senseobservationsystems/commonsense-python-lib/blob/aac59a1751ef79eb830b3ca1fab6ef2c83931f87/senseapi.py#L1830-L1842
train
63,301
pysal/spglm
spglm/varfuncs.py
NegativeBinomial.deriv
def deriv(self, mu): """ Derivative of the negative binomial variance function. """ p = self._clean(mu) return 1 + 2 * self.alpha * p
python
def deriv(self, mu): """ Derivative of the negative binomial variance function. """ p = self._clean(mu) return 1 + 2 * self.alpha * p
[ "def", "deriv", "(", "self", ",", "mu", ")", ":", "p", "=", "self", ".", "_clean", "(", "mu", ")", "return", "1", "+", "2", "*", "self", ".", "alpha", "*", "p" ]
Derivative of the negative binomial variance function.
[ "Derivative", "of", "the", "negative", "binomial", "variance", "function", "." ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/varfuncs.py#L271-L277
train
63,302
pysal/spglm
spglm/iwls.py
iwls
def iwls(y, x, family, offset, y_fix, ini_betas=None, tol=1.0e-8, max_iter=200, wi=None): """ Iteratively re-weighted least squares estimation routine Parameters ---------- y : array n*1, dependent variable x : array n*k, designs...
python
def iwls(y, x, family, offset, y_fix, ini_betas=None, tol=1.0e-8, max_iter=200, wi=None): """ Iteratively re-weighted least squares estimation routine Parameters ---------- y : array n*1, dependent variable x : array n*k, designs...
[ "def", "iwls", "(", "y", ",", "x", ",", "family", ",", "offset", ",", "y_fix", ",", "ini_betas", "=", "None", ",", "tol", "=", "1.0e-8", ",", "max_iter", "=", "200", ",", "wi", "=", "None", ")", ":", "n_iter", "=", "0", "diff", "=", "1.0e6", "i...
Iteratively re-weighted least squares estimation routine Parameters ---------- y : array n*1, dependent variable x : array n*k, designs matrix of k independent variables family : family object probability models: Gauss...
[ "Iteratively", "re", "-", "weighted", "least", "squares", "estimation", "routine" ]
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/iwls.py#L42-L152
train
63,303
pysal/spglm
spglm/utils.py
_next_regular
def _next_regular(target): """ Find the next regular number greater than or equal to target. Regular numbers are composites of the prime factors 2, 3, and 5. Also known as 5-smooth numbers or Hamming numbers, these are the optimal size for inputs to FFTPACK. Target must be a positive integer. ...
python
def _next_regular(target): """ Find the next regular number greater than or equal to target. Regular numbers are composites of the prime factors 2, 3, and 5. Also known as 5-smooth numbers or Hamming numbers, these are the optimal size for inputs to FFTPACK. Target must be a positive integer. ...
[ "def", "_next_regular", "(", "target", ")", ":", "if", "target", "<=", "6", ":", "return", "target", "# Quickly check if it's already a power of 2", "if", "not", "(", "target", "&", "(", "target", "-", "1", ")", ")", ":", "return", "target", "match", "=", ...
Find the next regular number greater than or equal to target. Regular numbers are composites of the prime factors 2, 3, and 5. Also known as 5-smooth numbers or Hamming numbers, these are the optimal size for inputs to FFTPACK. Target must be a positive integer.
[ "Find", "the", "next", "regular", "number", "greater", "than", "or", "equal", "to", "target", ".", "Regular", "numbers", "are", "composites", "of", "the", "prime", "factors", "2", "3", "and", "5", ".", "Also", "known", "as", "5", "-", "smooth", "numbers"...
1339898adcb7e1638f1da83d57aa37392525f018
https://github.com/pysal/spglm/blob/1339898adcb7e1638f1da83d57aa37392525f018/spglm/utils.py#L201-L246
train
63,304
nudomarinero/wquantiles
wquantiles.py
quantile_1D
def quantile_1D(data, weights, quantile): """ Compute the weighted quantile of a 1D numpy array. Parameters ---------- data : ndarray Input array (one dimension). weights : ndarray Array with the weights of the same size of `data`. quantile : float Quantile to comput...
python
def quantile_1D(data, weights, quantile): """ Compute the weighted quantile of a 1D numpy array. Parameters ---------- data : ndarray Input array (one dimension). weights : ndarray Array with the weights of the same size of `data`. quantile : float Quantile to comput...
[ "def", "quantile_1D", "(", "data", ",", "weights", ",", "quantile", ")", ":", "# Check the data", "if", "not", "isinstance", "(", "data", ",", "np", ".", "matrix", ")", ":", "data", "=", "np", ".", "asarray", "(", "data", ")", "if", "not", "isinstance"...
Compute the weighted quantile of a 1D numpy array. Parameters ---------- data : ndarray Input array (one dimension). weights : ndarray Array with the weights of the same size of `data`. quantile : float Quantile to compute. It must have a value between 0 and 1. Returns ...
[ "Compute", "the", "weighted", "quantile", "of", "a", "1D", "numpy", "array", "." ]
55120dfd9730688c9dc32020563e53ebb902e7f0
https://github.com/nudomarinero/wquantiles/blob/55120dfd9730688c9dc32020563e53ebb902e7f0/wquantiles.py#L11-L54
train
63,305
nudomarinero/wquantiles
wquantiles.py
quantile
def quantile(data, weights, quantile): """ Weighted quantile of an array with respect to the last axis. Parameters ---------- data : ndarray Input array. weights : ndarray Array with the weights. It must have the same size of the last axis of `data`. quantile : floa...
python
def quantile(data, weights, quantile): """ Weighted quantile of an array with respect to the last axis. Parameters ---------- data : ndarray Input array. weights : ndarray Array with the weights. It must have the same size of the last axis of `data`. quantile : floa...
[ "def", "quantile", "(", "data", ",", "weights", ",", "quantile", ")", ":", "# TODO: Allow to specify the axis", "nd", "=", "data", ".", "ndim", "if", "nd", "==", "0", ":", "TypeError", "(", "\"data must have at least one dimension\"", ")", "elif", "nd", "==", ...
Weighted quantile of an array with respect to the last axis. Parameters ---------- data : ndarray Input array. weights : ndarray Array with the weights. It must have the same size of the last axis of `data`. quantile : float Quantile to compute. It must have a value...
[ "Weighted", "quantile", "of", "an", "array", "with", "respect", "to", "the", "last", "axis", "." ]
55120dfd9730688c9dc32020563e53ebb902e7f0
https://github.com/nudomarinero/wquantiles/blob/55120dfd9730688c9dc32020563e53ebb902e7f0/wquantiles.py#L57-L86
train
63,306
biocommons/eutils
eutils/queryservice.py
QueryService.einfo
def einfo(self, args=None): """ execute a NON-cached, throttled einfo query einfo.fcgi?db=<database> Input: Entrez database (&db) or None (returns info on all Entrez databases) Output: XML containing database statistics Example: Find database statistics for Entrez Pro...
python
def einfo(self, args=None): """ execute a NON-cached, throttled einfo query einfo.fcgi?db=<database> Input: Entrez database (&db) or None (returns info on all Entrez databases) Output: XML containing database statistics Example: Find database statistics for Entrez Pro...
[ "def", "einfo", "(", "self", ",", "args", "=", "None", ")", ":", "if", "args", "is", "None", ":", "args", "=", "{", "}", "return", "self", ".", "_query", "(", "'/einfo.fcgi'", ",", "args", ",", "skip_cache", "=", "True", ")" ]
execute a NON-cached, throttled einfo query einfo.fcgi?db=<database> Input: Entrez database (&db) or None (returns info on all Entrez databases) Output: XML containing database statistics Example: Find database statistics for Entrez Protein. QueryService.einfo({'db': 'pr...
[ "execute", "a", "NON", "-", "cached", "throttled", "einfo", "query" ]
0ec7444fd520d2af56114122442ff8f60952db0b
https://github.com/biocommons/eutils/blob/0ec7444fd520d2af56114122442ff8f60952db0b/eutils/queryservice.py#L144-L170
train
63,307
ryan-roemer/django-cloud-browser
cloud_browser/cloud/base.py
CloudObject.native_obj
def native_obj(self): """Native storage object.""" if self.__native is None: self.__native = self._get_object() return self.__native
python
def native_obj(self): """Native storage object.""" if self.__native is None: self.__native = self._get_object() return self.__native
[ "def", "native_obj", "(", "self", ")", ":", "if", "self", ".", "__native", "is", "None", ":", "self", ".", "__native", "=", "self", ".", "_get_object", "(", ")", "return", "self", ".", "__native" ]
Native storage object.
[ "Native", "storage", "object", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/base.py#L41-L46
train
63,308
ryan-roemer/django-cloud-browser
cloud_browser/cloud/base.py
CloudObject.smart_content_type
def smart_content_type(self): """Smart content type.""" content_type = self.content_type if content_type in (None, '', 'application/octet-stream'): content_type, _ = mimetypes.guess_type(self.name) return content_type
python
def smart_content_type(self): """Smart content type.""" content_type = self.content_type if content_type in (None, '', 'application/octet-stream'): content_type, _ = mimetypes.guess_type(self.name) return content_type
[ "def", "smart_content_type", "(", "self", ")", ":", "content_type", "=", "self", ".", "content_type", "if", "content_type", "in", "(", "None", ",", "''", ",", "'application/octet-stream'", ")", ":", "content_type", ",", "_", "=", "mimetypes", ".", "guess_type"...
Smart content type.
[ "Smart", "content", "type", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/base.py#L73-L79
train
63,309
ryan-roemer/django-cloud-browser
cloud_browser/cloud/base.py
CloudObject.smart_content_encoding
def smart_content_encoding(self): """Smart content encoding.""" encoding = self.content_encoding if not encoding: base_list = self.basename.split('.') while (not encoding) and len(base_list) > 1: _, encoding = mimetypes.guess_type('.'.join(base_list)) ...
python
def smart_content_encoding(self): """Smart content encoding.""" encoding = self.content_encoding if not encoding: base_list = self.basename.split('.') while (not encoding) and len(base_list) > 1: _, encoding = mimetypes.guess_type('.'.join(base_list)) ...
[ "def", "smart_content_encoding", "(", "self", ")", ":", "encoding", "=", "self", ".", "content_encoding", "if", "not", "encoding", ":", "base_list", "=", "self", ".", "basename", ".", "split", "(", "'.'", ")", "while", "(", "not", "encoding", ")", "and", ...
Smart content encoding.
[ "Smart", "content", "encoding", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/base.py#L82-L91
train
63,310
ryan-roemer/django-cloud-browser
cloud_browser/cloud/base.py
CloudContainer.native_container
def native_container(self): """Native container object.""" if self.__native is None: self.__native = self._get_container() return self.__native
python
def native_container(self): """Native container object.""" if self.__native is None: self.__native = self._get_container() return self.__native
[ "def", "native_container", "(", "self", ")", ":", "if", "self", ".", "__native", "is", "None", ":", "self", ".", "__native", "=", "self", ".", "_get_container", "(", ")", "return", "self", ".", "__native" ]
Native container object.
[ "Native", "container", "object", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/base.py#L119-L124
train
63,311
ryan-roemer/django-cloud-browser
cloud_browser/cloud/base.py
CloudConnection.native_conn
def native_conn(self): """Native connection object.""" if self.__native is None: self.__native = self._get_connection() return self.__native
python
def native_conn(self): """Native connection object.""" if self.__native is None: self.__native = self._get_connection() return self.__native
[ "def", "native_conn", "(", "self", ")", ":", "if", "self", ".", "__native", "is", "None", ":", "self", ".", "__native", "=", "self", ".", "_get_connection", "(", ")", "return", "self", ".", "__native" ]
Native connection object.
[ "Native", "connection", "object", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/base.py#L155-L160
train
63,312
ryan-roemer/django-cloud-browser
cloud_browser/app_settings.py
Setting.validate
def validate(self, name, value): """Validate and return a value.""" if self.valid_set and value not in self.valid_set: raise ImproperlyConfigured( "%s: \"%s\" is not a valid setting (choose between %s)." % (name, value, ", ".join("\"%s\"" % x for x in self.va...
python
def validate(self, name, value): """Validate and return a value.""" if self.valid_set and value not in self.valid_set: raise ImproperlyConfigured( "%s: \"%s\" is not a valid setting (choose between %s)." % (name, value, ", ".join("\"%s\"" % x for x in self.va...
[ "def", "validate", "(", "self", ",", "name", ",", "value", ")", ":", "if", "self", ".", "valid_set", "and", "value", "not", "in", "self", ".", "valid_set", ":", "raise", "ImproperlyConfigured", "(", "\"%s: \\\"%s\\\" is not a valid setting (choose between %s).\"", ...
Validate and return a value.
[ "Validate", "and", "return", "a", "value", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/app_settings.py#L26-L34
train
63,313
ryan-roemer/django-cloud-browser
cloud_browser/app_settings.py
Setting.get
def get(self, name, default=None): """Get value.""" default = default if default is not None else self.default try: value = getattr(_settings, name) except AttributeError: value = os.environ.get(name, default) if self.from_env else default # Convert en...
python
def get(self, name, default=None): """Get value.""" default = default if default is not None else self.default try: value = getattr(_settings, name) except AttributeError: value = os.environ.get(name, default) if self.from_env else default # Convert en...
[ "def", "get", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "default", "=", "default", "if", "default", "is", "not", "None", "else", "self", ".", "default", "try", ":", "value", "=", "getattr", "(", "_settings", ",", "name", ")", ...
Get value.
[ "Get", "value", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/app_settings.py#L40-L51
train
63,314
ryan-roemer/django-cloud-browser
cloud_browser/app_settings.py
Settings._container_whitelist
def _container_whitelist(self): """Container whitelist.""" if self.__container_whitelist is None: self.__container_whitelist = \ set(self.CLOUD_BROWSER_CONTAINER_WHITELIST or []) return self.__container_whitelist
python
def _container_whitelist(self): """Container whitelist.""" if self.__container_whitelist is None: self.__container_whitelist = \ set(self.CLOUD_BROWSER_CONTAINER_WHITELIST or []) return self.__container_whitelist
[ "def", "_container_whitelist", "(", "self", ")", ":", "if", "self", ".", "__container_whitelist", "is", "None", ":", "self", ".", "__container_whitelist", "=", "set", "(", "self", ".", "CLOUD_BROWSER_CONTAINER_WHITELIST", "or", "[", "]", ")", "return", "self", ...
Container whitelist.
[ "Container", "whitelist", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/app_settings.py#L224-L229
train
63,315
ryan-roemer/django-cloud-browser
cloud_browser/app_settings.py
Settings._container_blacklist
def _container_blacklist(self): """Container blacklist.""" if self.__container_blacklist is None: self.__container_blacklist = \ set(self.CLOUD_BROWSER_CONTAINER_BLACKLIST or []) return self.__container_blacklist
python
def _container_blacklist(self): """Container blacklist.""" if self.__container_blacklist is None: self.__container_blacklist = \ set(self.CLOUD_BROWSER_CONTAINER_BLACKLIST or []) return self.__container_blacklist
[ "def", "_container_blacklist", "(", "self", ")", ":", "if", "self", ".", "__container_blacklist", "is", "None", ":", "self", ".", "__container_blacklist", "=", "set", "(", "self", ".", "CLOUD_BROWSER_CONTAINER_BLACKLIST", "or", "[", "]", ")", "return", "self", ...
Container blacklist.
[ "Container", "blacklist", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/app_settings.py#L232-L237
train
63,316
ryan-roemer/django-cloud-browser
cloud_browser/app_settings.py
Settings.container_permitted
def container_permitted(self, name): """Return whether or not a container is permitted. :param name: Container name. :return: ``True`` if container is permitted. :rtype: ``bool`` """ white = self._container_whitelist black = self._container_blacklist ret...
python
def container_permitted(self, name): """Return whether or not a container is permitted. :param name: Container name. :return: ``True`` if container is permitted. :rtype: ``bool`` """ white = self._container_whitelist black = self._container_blacklist ret...
[ "def", "container_permitted", "(", "self", ",", "name", ")", ":", "white", "=", "self", ".", "_container_whitelist", "black", "=", "self", ".", "_container_blacklist", "return", "name", "not", "in", "black", "and", "(", "not", "white", "or", "name", "in", ...
Return whether or not a container is permitted. :param name: Container name. :return: ``True`` if container is permitted. :rtype: ``bool``
[ "Return", "whether", "or", "not", "a", "container", "is", "permitted", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/app_settings.py#L239-L248
train
63,317
ryan-roemer/django-cloud-browser
cloud_browser/app_settings.py
Settings.app_media_url
def app_media_url(self): """Get application media root from real media root URL.""" url = None media_dir = self.CLOUD_BROWSER_STATIC_MEDIA_DIR if media_dir: url = os.path.join(self.MEDIA_URL, media_dir).rstrip('/') + '/' return url
python
def app_media_url(self): """Get application media root from real media root URL.""" url = None media_dir = self.CLOUD_BROWSER_STATIC_MEDIA_DIR if media_dir: url = os.path.join(self.MEDIA_URL, media_dir).rstrip('/') + '/' return url
[ "def", "app_media_url", "(", "self", ")", ":", "url", "=", "None", "media_dir", "=", "self", ".", "CLOUD_BROWSER_STATIC_MEDIA_DIR", "if", "media_dir", ":", "url", "=", "os", ".", "path", ".", "join", "(", "self", ".", "MEDIA_URL", ",", "media_dir", ")", ...
Get application media root from real media root URL.
[ "Get", "application", "media", "root", "from", "real", "media", "root", "URL", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/app_settings.py#L251-L258
train
63,318
Kitware/tangelo
tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py
module_getmtime
def module_getmtime(filename): """ Get the mtime associated with a module. If this is a .pyc or .pyo file and a corresponding .py file exists, the time of the .py file is returned. :param filename: filename of the module. :returns: mtime or None if the file doesn"t exist. """ if os.path.sp...
python
def module_getmtime(filename): """ Get the mtime associated with a module. If this is a .pyc or .pyo file and a corresponding .py file exists, the time of the .py file is returned. :param filename: filename of the module. :returns: mtime or None if the file doesn"t exist. """ if os.path.sp...
[ "def", "module_getmtime", "(", "filename", ")", ":", "if", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "1", "]", ".", "lower", "(", ")", "in", "(", "\".pyc\"", ",", "\".pyo\"", ")", "and", "os", ".", "path", ".", "exists", "(", ...
Get the mtime associated with a module. If this is a .pyc or .pyo file and a corresponding .py file exists, the time of the .py file is returned. :param filename: filename of the module. :returns: mtime or None if the file doesn"t exist.
[ "Get", "the", "mtime", "associated", "with", "a", "module", ".", "If", "this", "is", "a", ".", "pyc", "or", ".", "pyo", "file", "and", "a", "corresponding", ".", "py", "file", "exists", "the", "time", "of", "the", ".", "py", "file", "is", "returned",...
470034ee9b3d7a01becc1ce5fddc7adc1d5263ef
https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py#L55-L67
train
63,319
Kitware/tangelo
tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py
module_reload_changed
def module_reload_changed(key): """ Reload a module if it has changed since we last imported it. This is necessary if module a imports script b, script b is changed, and then module c asks to import script b. :param key: our key used in the WatchList. :returns: True if reloaded. """ im...
python
def module_reload_changed(key): """ Reload a module if it has changed since we last imported it. This is necessary if module a imports script b, script b is changed, and then module c asks to import script b. :param key: our key used in the WatchList. :returns: True if reloaded. """ im...
[ "def", "module_reload_changed", "(", "key", ")", ":", "imp", ".", "acquire_lock", "(", ")", "try", ":", "modkey", "=", "module_sys_modules_key", "(", "key", ")", "if", "not", "modkey", ":", "return", "False", "found", "=", "None", "if", "modkey", ":", "f...
Reload a module if it has changed since we last imported it. This is necessary if module a imports script b, script b is changed, and then module c asks to import script b. :param key: our key used in the WatchList. :returns: True if reloaded.
[ "Reload", "a", "module", "if", "it", "has", "changed", "since", "we", "last", "imported", "it", ".", "This", "is", "necessary", "if", "module", "a", "imports", "script", "b", "script", "b", "is", "changed", "and", "then", "module", "c", "asks", "to", "...
470034ee9b3d7a01becc1ce5fddc7adc1d5263ef
https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py#L70-L104
train
63,320
Kitware/tangelo
tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py
module_sys_modules_key
def module_sys_modules_key(key): """ Check if a module is in the sys.modules dictionary in some manner. If so, return the key used in that dictionary. :param key: our key to the module. :returns: the key in sys.modules or None. """ moduleparts = key.split(".") for partnum, part in enum...
python
def module_sys_modules_key(key): """ Check if a module is in the sys.modules dictionary in some manner. If so, return the key used in that dictionary. :param key: our key to the module. :returns: the key in sys.modules or None. """ moduleparts = key.split(".") for partnum, part in enum...
[ "def", "module_sys_modules_key", "(", "key", ")", ":", "moduleparts", "=", "key", ".", "split", "(", "\".\"", ")", "for", "partnum", ",", "part", "in", "enumerate", "(", "moduleparts", ")", ":", "modkey", "=", "\".\"", ".", "join", "(", "moduleparts", "[...
Check if a module is in the sys.modules dictionary in some manner. If so, return the key used in that dictionary. :param key: our key to the module. :returns: the key in sys.modules or None.
[ "Check", "if", "a", "module", "is", "in", "the", "sys", ".", "modules", "dictionary", "in", "some", "manner", ".", "If", "so", "return", "the", "key", "used", "in", "that", "dictionary", "." ]
470034ee9b3d7a01becc1ce5fddc7adc1d5263ef
https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py#L107-L120
train
63,321
Kitware/tangelo
tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py
reload_including_local
def reload_including_local(module): """ Reload a module. If it isn"t found, try to include the local service directory. This must be called from a thread that has acquired the import lock. :param module: the module to reload. """ try: reload(module) except ImportError: ...
python
def reload_including_local(module): """ Reload a module. If it isn"t found, try to include the local service directory. This must be called from a thread that has acquired the import lock. :param module: the module to reload. """ try: reload(module) except ImportError: ...
[ "def", "reload_including_local", "(", "module", ")", ":", "try", ":", "reload", "(", "module", ")", "except", "ImportError", ":", "# This can happen if the module was loaded in the immediate script", "# directory. Add the service path and try again.", "if", "not", "hasattr", ...
Reload a module. If it isn"t found, try to include the local service directory. This must be called from a thread that has acquired the import lock. :param module: the module to reload.
[ "Reload", "a", "module", ".", "If", "it", "isn", "t", "found", "try", "to", "include", "the", "local", "service", "directory", ".", "This", "must", "be", "called", "from", "a", "thread", "that", "has", "acquired", "the", "import", "lock", "." ]
470034ee9b3d7a01becc1ce5fddc7adc1d5263ef
https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py#L123-L148
train
63,322
Kitware/tangelo
tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py
reload_recent_submodules
def reload_recent_submodules(module, mtime=0, processed=[]): """ Recursively reload submodules which are more recent than a specified timestamp. To be called from a thread that has acquired the import lock to be thread safe. :param module: the module name. The WatchList is checked for modules tha...
python
def reload_recent_submodules(module, mtime=0, processed=[]): """ Recursively reload submodules which are more recent than a specified timestamp. To be called from a thread that has acquired the import lock to be thread safe. :param module: the module name. The WatchList is checked for modules tha...
[ "def", "reload_recent_submodules", "(", "module", ",", "mtime", "=", "0", ",", "processed", "=", "[", "]", ")", ":", "if", "module", ".", "endswith", "(", "\".py\"", ")", ":", "module", "=", "module", "[", ":", "-", "3", "]", "if", "module", "in", ...
Recursively reload submodules which are more recent than a specified timestamp. To be called from a thread that has acquired the import lock to be thread safe. :param module: the module name. The WatchList is checked for modules that list this as a parent. :param mtime: the latest ...
[ "Recursively", "reload", "submodules", "which", "are", "more", "recent", "than", "a", "specified", "timestamp", ".", "To", "be", "called", "from", "a", "thread", "that", "has", "acquired", "the", "import", "lock", "to", "be", "thread", "safe", "." ]
470034ee9b3d7a01becc1ce5fddc7adc1d5263ef
https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py#L151-L189
train
63,323
Kitware/tangelo
tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py
watch_import
def watch_import(name, globals=None, *args, **kwargs): """ When a module is asked to be imported, check if we have previously imported it. If so, check if the time stamp of it, a companion yaml file, or any modules it imports have changed. If so, reimport the module. :params: see __builtin__.__im...
python
def watch_import(name, globals=None, *args, **kwargs): """ When a module is asked to be imported, check if we have previously imported it. If so, check if the time stamp of it, a companion yaml file, or any modules it imports have changed. If so, reimport the module. :params: see __builtin__.__im...
[ "def", "watch_import", "(", "name", ",", "globals", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Don\"t monitor builtin modules. types seem special, so don\"t monitor it", "# either.", "monitor", "=", "not", "imp", ".", "is_builtin", "(", ...
When a module is asked to be imported, check if we have previously imported it. If so, check if the time stamp of it, a companion yaml file, or any modules it imports have changed. If so, reimport the module. :params: see __builtin__.__import__
[ "When", "a", "module", "is", "asked", "to", "be", "imported", "check", "if", "we", "have", "previously", "imported", "it", ".", "If", "so", "check", "if", "the", "time", "stamp", "of", "it", "a", "companion", "yaml", "file", "or", "any", "modules", "it...
470034ee9b3d7a01becc1ce5fddc7adc1d5263ef
https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py#L192-L234
train
63,324
Kitware/tangelo
tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py
watch_module_cache_get
def watch_module_cache_get(cache, module): """ When we ask to fetch a module with optional config file, check time stamps and dependencies to determine if it should be reloaded or not. :param cache: the cache object that stores whether to check for config files and which files have be...
python
def watch_module_cache_get(cache, module): """ When we ask to fetch a module with optional config file, check time stamps and dependencies to determine if it should be reloaded or not. :param cache: the cache object that stores whether to check for config files and which files have be...
[ "def", "watch_module_cache_get", "(", "cache", ",", "module", ")", ":", "imp", ".", "acquire_lock", "(", ")", "try", ":", "if", "not", "hasattr", "(", "cache", ",", "\"timestamps\"", ")", ":", "cache", ".", "timestamps", "=", "{", "}", "mtime", "=", "o...
When we ask to fetch a module with optional config file, check time stamps and dependencies to determine if it should be reloaded or not. :param cache: the cache object that stores whether to check for config files and which files have been loaded. :param module: the path of the module to...
[ "When", "we", "ask", "to", "fetch", "a", "module", "with", "optional", "config", "file", "check", "time", "stamps", "and", "dependencies", "to", "determine", "if", "it", "should", "be", "reloaded", "or", "not", "." ]
470034ee9b3d7a01becc1ce5fddc7adc1d5263ef
https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py#L237-L282
train
63,325
ryan-roemer/django-cloud-browser
cloud_browser/common.py
get_int
def get_int(value, default, test_fn=None): """Convert value to integer. :param value: Integer value. :param default: Default value on failed conversion. :param test_fn: Constraint function. Use default if returns ``False``. :return: Integer value. :rtype: ``int`` """ try: conve...
python
def get_int(value, default, test_fn=None): """Convert value to integer. :param value: Integer value. :param default: Default value on failed conversion. :param test_fn: Constraint function. Use default if returns ``False``. :return: Integer value. :rtype: ``int`` """ try: conve...
[ "def", "get_int", "(", "value", ",", "default", ",", "test_fn", "=", "None", ")", ":", "try", ":", "converted", "=", "int", "(", "value", ")", "except", "ValueError", ":", "return", "default", "test_fn", "=", "test_fn", "if", "test_fn", "else", "lambda",...
Convert value to integer. :param value: Integer value. :param default: Default value on failed conversion. :param test_fn: Constraint function. Use default if returns ``False``. :return: Integer value. :rtype: ``int``
[ "Convert", "value", "to", "integer", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/common.py#L23-L38
train
63,326
ryan-roemer/django-cloud-browser
cloud_browser/common.py
requires
def requires(module, name=""): """Enforces module presence. The general use here is to allow conditional imports that may fail (e.g., a required python package is not installed) but still allow the rest of the python package to compile and run fine. If the wrapped method with this decorated is invo...
python
def requires(module, name=""): """Enforces module presence. The general use here is to allow conditional imports that may fail (e.g., a required python package is not installed) but still allow the rest of the python package to compile and run fine. If the wrapped method with this decorated is invo...
[ "def", "requires", "(", "module", ",", "name", "=", "\"\"", ")", ":", "def", "wrapped", "(", "method", ")", ":", "\"\"\"Call and enforce method.\"\"\"", "if", "module", "is", "None", ":", "raise", "ImproperlyConfigured", "(", "\"Module '%s' is not installed.\"", "...
Enforces module presence. The general use here is to allow conditional imports that may fail (e.g., a required python package is not installed) but still allow the rest of the python package to compile and run fine. If the wrapped method with this decorated is invoked, then a runtime error is generated...
[ "Enforces", "module", "presence", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/common.py#L51-L70
train
63,327
ryan-roemer/django-cloud-browser
cloud_browser/common.py
dt_from_header
def dt_from_header(date_str): """Try various RFC conversions to ``datetime`` or return ``None``. :param date_str: Date string. :type date_str: ``string`` :return: Date time. :rtype: :class:`datetime.datetime` or ``None`` """ convert_fns = ( dt_from_rfc8601, dt_from_rfc1123...
python
def dt_from_header(date_str): """Try various RFC conversions to ``datetime`` or return ``None``. :param date_str: Date string. :type date_str: ``string`` :return: Date time. :rtype: :class:`datetime.datetime` or ``None`` """ convert_fns = ( dt_from_rfc8601, dt_from_rfc1123...
[ "def", "dt_from_header", "(", "date_str", ")", ":", "convert_fns", "=", "(", "dt_from_rfc8601", ",", "dt_from_rfc1123", ",", ")", "for", "convert_fn", "in", "convert_fns", ":", "try", ":", "return", "convert_fn", "(", "date_str", ")", "except", "ValueError", "...
Try various RFC conversions to ``datetime`` or return ``None``. :param date_str: Date string. :type date_str: ``string`` :return: Date time. :rtype: :class:`datetime.datetime` or ``None``
[ "Try", "various", "RFC", "conversions", "to", "datetime", "or", "return", "None", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/common.py#L111-L130
train
63,328
ryan-roemer/django-cloud-browser
cloud_browser/common.py
basename
def basename(path): """Rightmost part of path after separator.""" base_path = path.strip(SEP) sep_ind = base_path.rfind(SEP) if sep_ind < 0: return path return base_path[sep_ind + 1:]
python
def basename(path): """Rightmost part of path after separator.""" base_path = path.strip(SEP) sep_ind = base_path.rfind(SEP) if sep_ind < 0: return path return base_path[sep_ind + 1:]
[ "def", "basename", "(", "path", ")", ":", "base_path", "=", "path", ".", "strip", "(", "SEP", ")", "sep_ind", "=", "base_path", ".", "rfind", "(", "SEP", ")", "if", "sep_ind", "<", "0", ":", "return", "path", "return", "base_path", "[", "sep_ind", "+...
Rightmost part of path after separator.
[ "Rightmost", "part", "of", "path", "after", "separator", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/common.py#L136-L143
train
63,329
ryan-roemer/django-cloud-browser
cloud_browser/common.py
path_parts
def path_parts(path): """Split path into container, object. :param path: Path to resource (including container). :type path: `string` :return: Container, storage object tuple. :rtype: `tuple` of `string`, `string` """ path = path if path is not None else '' container_path = object_pat...
python
def path_parts(path): """Split path into container, object. :param path: Path to resource (including container). :type path: `string` :return: Container, storage object tuple. :rtype: `tuple` of `string`, `string` """ path = path if path is not None else '' container_path = object_pat...
[ "def", "path_parts", "(", "path", ")", ":", "path", "=", "path", "if", "path", "is", "not", "None", "else", "''", "container_path", "=", "object_path", "=", "''", "parts", "=", "path_list", "(", "path", ")", "if", "len", "(", "parts", ")", ">=", "1",...
Split path into container, object. :param path: Path to resource (including container). :type path: `string` :return: Container, storage object tuple. :rtype: `tuple` of `string`, `string`
[ "Split", "path", "into", "container", "object", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/common.py#L146-L163
train
63,330
ryan-roemer/django-cloud-browser
cloud_browser/common.py
path_yield
def path_yield(path): """Yield on all path parts.""" for part in (x for x in path.strip(SEP).split(SEP) if x not in (None, '')): yield part
python
def path_yield(path): """Yield on all path parts.""" for part in (x for x in path.strip(SEP).split(SEP) if x not in (None, '')): yield part
[ "def", "path_yield", "(", "path", ")", ":", "for", "part", "in", "(", "x", "for", "x", "in", "path", ".", "strip", "(", "SEP", ")", ".", "split", "(", "SEP", ")", "if", "x", "not", "in", "(", "None", ",", "''", ")", ")", ":", "yield", "part" ...
Yield on all path parts.
[ "Yield", "on", "all", "path", "parts", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/common.py#L166-L169
train
63,331
ryan-roemer/django-cloud-browser
cloud_browser/common.py
path_join
def path_join(*args): """Join path parts to single path.""" return SEP.join((x for x in args if x not in (None, ''))).strip(SEP)
python
def path_join(*args): """Join path parts to single path.""" return SEP.join((x for x in args if x not in (None, ''))).strip(SEP)
[ "def", "path_join", "(", "*", "args", ")", ":", "return", "SEP", ".", "join", "(", "(", "x", "for", "x", "in", "args", "if", "x", "not", "in", "(", "None", ",", "''", ")", ")", ")", ".", "strip", "(", "SEP", ")" ]
Join path parts to single path.
[ "Join", "path", "parts", "to", "single", "path", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/common.py#L177-L179
train
63,332
ryan-roemer/django-cloud-browser
cloud_browser/common.py
relpath
def relpath(path, start): """Get relative path to start. Note: Modeled after python2.6 :meth:`os.path.relpath`. """ path_items = path_list(path) start_items = path_list(start) # Find common parts of path. common = [] for pth, stt in zip(path_items, start_items): if pth != stt: ...
python
def relpath(path, start): """Get relative path to start. Note: Modeled after python2.6 :meth:`os.path.relpath`. """ path_items = path_list(path) start_items = path_list(start) # Find common parts of path. common = [] for pth, stt in zip(path_items, start_items): if pth != stt: ...
[ "def", "relpath", "(", "path", ",", "start", ")", ":", "path_items", "=", "path_list", "(", "path", ")", "start_items", "=", "path_list", "(", "start", ")", "# Find common parts of path.", "common", "=", "[", "]", "for", "pth", ",", "stt", "in", "zip", "...
Get relative path to start. Note: Modeled after python2.6 :meth:`os.path.relpath`.
[ "Get", "relative", "path", "to", "start", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/common.py#L182-L203
train
63,333
bjmorgan/lattice_mc
lattice_mc/species.py
Species.collective_dr_squared
def collective_dr_squared( self ): """ Squared sum of total displacements for these atoms. Args: None Returns: (Float): The square of the summed total displacements for these atoms. """ return sum( np.square( sum( [ atom.dr for atom in self.atoms...
python
def collective_dr_squared( self ): """ Squared sum of total displacements for these atoms. Args: None Returns: (Float): The square of the summed total displacements for these atoms. """ return sum( np.square( sum( [ atom.dr for atom in self.atoms...
[ "def", "collective_dr_squared", "(", "self", ")", ":", "return", "sum", "(", "np", ".", "square", "(", "sum", "(", "[", "atom", ".", "dr", "for", "atom", "in", "self", ".", "atoms", "]", ")", ")", ")" ]
Squared sum of total displacements for these atoms. Args: None Returns: (Float): The square of the summed total displacements for these atoms.
[ "Squared", "sum", "of", "total", "displacements", "for", "these", "atoms", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/species.py#L46-L56
train
63,334
bjmorgan/lattice_mc
lattice_mc/species.py
Species.occupations
def occupations( self, site_label ): """ Number of these atoms occupying a specific site type. Args: site_label (Str): Label for the site type being considered. Returns: (Int): Number of atoms occupying sites of type `site_label`. """ return sum(...
python
def occupations( self, site_label ): """ Number of these atoms occupying a specific site type. Args: site_label (Str): Label for the site type being considered. Returns: (Int): Number of atoms occupying sites of type `site_label`. """ return sum(...
[ "def", "occupations", "(", "self", ",", "site_label", ")", ":", "return", "sum", "(", "atom", ".", "site", ".", "label", "==", "site_label", "for", "atom", "in", "self", ".", "atoms", ")" ]
Number of these atoms occupying a specific site type. Args: site_label (Str): Label for the site type being considered. Returns: (Int): Number of atoms occupying sites of type `site_label`.
[ "Number", "of", "these", "atoms", "occupying", "a", "specific", "site", "type", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/species.py#L58-L68
train
63,335
futurecolors/django-geoip
django_geoip/utils.py
get_class
def get_class(class_string): """ Convert a string version of a function name to the callable object. """ try: mod_name, class_name = get_mod_func(class_string) if class_name != '': cls = getattr(__import__(mod_name, {}, {}, ['']), class_name) return cls except...
python
def get_class(class_string): """ Convert a string version of a function name to the callable object. """ try: mod_name, class_name = get_mod_func(class_string) if class_name != '': cls = getattr(__import__(mod_name, {}, {}, ['']), class_name) return cls except...
[ "def", "get_class", "(", "class_string", ")", ":", "try", ":", "mod_name", ",", "class_name", "=", "get_mod_func", "(", "class_string", ")", "if", "class_name", "!=", "''", ":", "cls", "=", "getattr", "(", "__import__", "(", "mod_name", ",", "{", "}", ",...
Convert a string version of a function name to the callable object.
[ "Convert", "a", "string", "version", "of", "a", "function", "name", "to", "the", "callable", "object", "." ]
f9eee4bcad40508089b184434b79826f842d7bd0
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/utils.py#L4-L15
train
63,336
ryan-roemer/django-cloud-browser
cloud_browser/cloud/google.py
GsObject._is_gs_folder
def _is_gs_folder(cls, result): """Return ``True`` if GS standalone folder object. GS will create a 0 byte ``<FOLDER NAME>_$folder$`` key as a pseudo-directory place holder if there are no files present. """ return (cls.is_key(result) and result.size == 0 and ...
python
def _is_gs_folder(cls, result): """Return ``True`` if GS standalone folder object. GS will create a 0 byte ``<FOLDER NAME>_$folder$`` key as a pseudo-directory place holder if there are no files present. """ return (cls.is_key(result) and result.size == 0 and ...
[ "def", "_is_gs_folder", "(", "cls", ",", "result", ")", ":", "return", "(", "cls", ".", "is_key", "(", "result", ")", "and", "result", ".", "size", "==", "0", "and", "result", ".", "name", ".", "endswith", "(", "cls", ".", "_gs_folder_suffix", ")", "...
Return ``True`` if GS standalone folder object. GS will create a 0 byte ``<FOLDER NAME>_$folder$`` key as a pseudo-directory place holder if there are no files present.
[ "Return", "True", "if", "GS", "standalone", "folder", "object", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/google.py#L36-L44
train
63,337
ryan-roemer/django-cloud-browser
cloud_browser/cloud/google.py
GsObject.is_prefix
def is_prefix(cls, result): """Return ``True`` if result is a prefix object. .. note:: Boto uses the S3 Prefix object for GS prefixes. """ from boto.s3.prefix import Prefix return isinstance(result, Prefix) or cls._is_gs_folder(result)
python
def is_prefix(cls, result): """Return ``True`` if result is a prefix object. .. note:: Boto uses the S3 Prefix object for GS prefixes. """ from boto.s3.prefix import Prefix return isinstance(result, Prefix) or cls._is_gs_folder(result)
[ "def", "is_prefix", "(", "cls", ",", "result", ")", ":", "from", "boto", ".", "s3", ".", "prefix", "import", "Prefix", "return", "isinstance", "(", "result", ",", "Prefix", ")", "or", "cls", ".", "_is_gs_folder", "(", "result", ")" ]
Return ``True`` if result is a prefix object. .. note:: Boto uses the S3 Prefix object for GS prefixes.
[ "Return", "True", "if", "result", "is", "a", "prefix", "object", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/google.py#L56-L64
train
63,338
ryan-roemer/django-cloud-browser
cloud_browser/cloud/boto_base.py
BotoExceptionWrapper.translate
def translate(self, exc): """Return whether or not to do translation.""" from boto.exception import StorageResponseError if isinstance(exc, StorageResponseError): if exc.status == 404: return self.error_cls(str(exc)) return None
python
def translate(self, exc): """Return whether or not to do translation.""" from boto.exception import StorageResponseError if isinstance(exc, StorageResponseError): if exc.status == 404: return self.error_cls(str(exc)) return None
[ "def", "translate", "(", "self", ",", "exc", ")", ":", "from", "boto", ".", "exception", "import", "StorageResponseError", "if", "isinstance", "(", "exc", ",", "StorageResponseError", ")", ":", "if", "exc", ".", "status", "==", "404", ":", "return", "self"...
Return whether or not to do translation.
[ "Return", "whether", "or", "not", "to", "do", "translation", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/boto_base.py#L33-L41
train
63,339
ryan-roemer/django-cloud-browser
cloud_browser/cloud/boto_base.py
BotoObject.from_result
def from_result(cls, container, result): """Create from ambiguous result.""" if result is None: raise errors.NoObjectException elif cls.is_prefix(result): return cls.from_prefix(container, result) elif cls.is_key(result): return cls.from_key(containe...
python
def from_result(cls, container, result): """Create from ambiguous result.""" if result is None: raise errors.NoObjectException elif cls.is_prefix(result): return cls.from_prefix(container, result) elif cls.is_key(result): return cls.from_key(containe...
[ "def", "from_result", "(", "cls", ",", "container", ",", "result", ")", ":", "if", "result", "is", "None", ":", "raise", "errors", ".", "NoObjectException", "elif", "cls", ".", "is_prefix", "(", "result", ")", ":", "return", "cls", ".", "from_prefix", "(...
Create from ambiguous result.
[ "Create", "from", "ambiguous", "result", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/boto_base.py#L80-L92
train
63,340
ryan-roemer/django-cloud-browser
cloud_browser/cloud/boto_base.py
BotoObject.from_key
def from_key(cls, container, key): """Create from key object.""" if key is None: raise errors.NoObjectException # Get Key (1123): Tue, 13 Apr 2010 14:02:48 GMT # List Keys (8601): 2010-04-13T14:02:48.000Z return cls(container, name=key.name, ...
python
def from_key(cls, container, key): """Create from key object.""" if key is None: raise errors.NoObjectException # Get Key (1123): Tue, 13 Apr 2010 14:02:48 GMT # List Keys (8601): 2010-04-13T14:02:48.000Z return cls(container, name=key.name, ...
[ "def", "from_key", "(", "cls", ",", "container", ",", "key", ")", ":", "if", "key", "is", "None", ":", "raise", "errors", ".", "NoObjectException", "# Get Key (1123): Tue, 13 Apr 2010 14:02:48 GMT", "# List Keys (8601): 2010-04-13T14:02:48.000Z", "return", "cls", "(",...
Create from key object.
[ "Create", "from", "key", "object", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/boto_base.py#L105-L118
train
63,341
ryan-roemer/django-cloud-browser
cloud_browser/cloud/boto_base.py
BotoContainer.from_bucket
def from_bucket(cls, connection, bucket): """Create from bucket object.""" if bucket is None: raise errors.NoContainerException # It appears that Amazon does not have a single-shot REST query to # determine the number of keys / overall byte size of a bucket. return c...
python
def from_bucket(cls, connection, bucket): """Create from bucket object.""" if bucket is None: raise errors.NoContainerException # It appears that Amazon does not have a single-shot REST query to # determine the number of keys / overall byte size of a bucket. return c...
[ "def", "from_bucket", "(", "cls", ",", "connection", ",", "bucket", ")", ":", "if", "bucket", "is", "None", ":", "raise", "errors", ".", "NoContainerException", "# It appears that Amazon does not have a single-shot REST query to", "# determine the number of keys / overall byt...
Create from bucket object.
[ "Create", "from", "bucket", "object", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/boto_base.py#L169-L176
train
63,342
ryan-roemer/django-cloud-browser
cloud_browser/cloud/config.py
Config.from_settings
def from_settings(cls): """Create configuration from Django settings or environment.""" from cloud_browser.app_settings import settings from django.core.exceptions import ImproperlyConfigured conn_cls = conn_fn = None datastore = settings.CLOUD_BROWSER_DATASTORE if datas...
python
def from_settings(cls): """Create configuration from Django settings or environment.""" from cloud_browser.app_settings import settings from django.core.exceptions import ImproperlyConfigured conn_cls = conn_fn = None datastore = settings.CLOUD_BROWSER_DATASTORE if datas...
[ "def", "from_settings", "(", "cls", ")", ":", "from", "cloud_browser", ".", "app_settings", "import", "settings", "from", "django", ".", "core", ".", "exceptions", "import", "ImproperlyConfigured", "conn_cls", "=", "conn_fn", "=", "None", "datastore", "=", "sett...
Create configuration from Django settings or environment.
[ "Create", "configuration", "from", "Django", "settings", "or", "environment", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/config.py#L11-L71
train
63,343
ryan-roemer/django-cloud-browser
cloud_browser/cloud/config.py
Config.get_connection_cls
def get_connection_cls(cls): """Return connection class. :rtype: :class:`type` """ if cls.__connection_cls is None: cls.__connection_cls, _ = cls.from_settings() return cls.__connection_cls
python
def get_connection_cls(cls): """Return connection class. :rtype: :class:`type` """ if cls.__connection_cls is None: cls.__connection_cls, _ = cls.from_settings() return cls.__connection_cls
[ "def", "get_connection_cls", "(", "cls", ")", ":", "if", "cls", ".", "__connection_cls", "is", "None", ":", "cls", ".", "__connection_cls", ",", "_", "=", "cls", ".", "from_settings", "(", ")", "return", "cls", ".", "__connection_cls" ]
Return connection class. :rtype: :class:`type`
[ "Return", "connection", "class", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/config.py#L74-L81
train
63,344
ryan-roemer/django-cloud-browser
cloud_browser/cloud/config.py
Config.get_connection
def get_connection(cls): """Return connection object. :rtype: :class:`cloud_browser.cloud.base.CloudConnection` """ if cls.__connection_obj is None: if cls.__connection_fn is None: _, cls.__connection_fn = cls.from_settings() cls.__connection_obj ...
python
def get_connection(cls): """Return connection object. :rtype: :class:`cloud_browser.cloud.base.CloudConnection` """ if cls.__connection_obj is None: if cls.__connection_fn is None: _, cls.__connection_fn = cls.from_settings() cls.__connection_obj ...
[ "def", "get_connection", "(", "cls", ")", ":", "if", "cls", ".", "__connection_obj", "is", "None", ":", "if", "cls", ".", "__connection_fn", "is", "None", ":", "_", ",", "cls", ".", "__connection_fn", "=", "cls", ".", "from_settings", "(", ")", "cls", ...
Return connection object. :rtype: :class:`cloud_browser.cloud.base.CloudConnection`
[ "Return", "connection", "object", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/config.py#L84-L93
train
63,345
ryan-roemer/django-cloud-browser
cloud_browser/cloud/fs.py
FilesystemObject.from_path
def from_path(cls, container, path): """Create object from path.""" from datetime import datetime path = path.strip(SEP) full_path = os.path.join(container.base_path, path) last_modified = datetime.fromtimestamp(os.path.getmtime(full_path)) obj_type = cls.type_cls.SUBDIR...
python
def from_path(cls, container, path): """Create object from path.""" from datetime import datetime path = path.strip(SEP) full_path = os.path.join(container.base_path, path) last_modified = datetime.fromtimestamp(os.path.getmtime(full_path)) obj_type = cls.type_cls.SUBDIR...
[ "def", "from_path", "(", "cls", ",", "container", ",", "path", ")", ":", "from", "datetime", "import", "datetime", "path", "=", "path", ".", "strip", "(", "SEP", ")", "full_path", "=", "os", ".", "path", ".", "join", "(", "container", ".", "base_path",...
Create object from path.
[ "Create", "object", "from", "path", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/fs.py#L65-L80
train
63,346
ryan-roemer/django-cloud-browser
cloud_browser/cloud/fs.py
FilesystemContainer.from_path
def from_path(cls, conn, path): """Create container from path.""" path = path.strip(SEP) full_path = os.path.join(conn.abs_root, path) return cls(conn, path, 0, os.path.getsize(full_path))
python
def from_path(cls, conn, path): """Create container from path.""" path = path.strip(SEP) full_path = os.path.join(conn.abs_root, path) return cls(conn, path, 0, os.path.getsize(full_path))
[ "def", "from_path", "(", "cls", ",", "conn", ",", "path", ")", ":", "path", "=", "path", ".", "strip", "(", "SEP", ")", "full_path", "=", "os", ".", "path", ".", "join", "(", "conn", ".", "abs_root", ",", "path", ")", "return", "cls", "(", "conn"...
Create container from path.
[ "Create", "container", "from", "path", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/fs.py#L119-L123
train
63,347
bjmorgan/lattice_mc
lattice_mc/init_lattice.py
cubic_lattice
def cubic_lattice( a, b, c, spacing ): """ Generate a cubic lattice. Args: a (Int): Number of lattice repeat units along x. b (Int): Number of lattice repeat units along y. c (Int): Number of lattice repeat units along z. spacing (Float): Distance bet...
python
def cubic_lattice( a, b, c, spacing ): """ Generate a cubic lattice. Args: a (Int): Number of lattice repeat units along x. b (Int): Number of lattice repeat units along y. c (Int): Number of lattice repeat units along z. spacing (Float): Distance bet...
[ "def", "cubic_lattice", "(", "a", ",", "b", ",", "c", ",", "spacing", ")", ":", "grid", "=", "np", ".", "array", "(", "list", "(", "range", "(", "1", ",", "a", "*", "b", "*", "c", "+", "1", ")", ")", ")", ".", "reshape", "(", "a", ",", "b...
Generate a cubic lattice. Args: a (Int): Number of lattice repeat units along x. b (Int): Number of lattice repeat units along y. c (Int): Number of lattice repeat units along z. spacing (Float): Distance between lattice sites. Returns: (Lattice)...
[ "Generate", "a", "cubic", "lattice", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/init_lattice.py#L91-L118
train
63,348
bjmorgan/lattice_mc
lattice_mc/init_lattice.py
lattice_from_sites_file
def lattice_from_sites_file( site_file, cell_lengths ): """ Generate a lattice from a sites file. Args: site_file (Str): Filename for the file containing the site information. cell_lengths (List(Float,Float,Float)): A list containing the [ x, y, z ] cell lengths. Returns: (Latt...
python
def lattice_from_sites_file( site_file, cell_lengths ): """ Generate a lattice from a sites file. Args: site_file (Str): Filename for the file containing the site information. cell_lengths (List(Float,Float,Float)): A list containing the [ x, y, z ] cell lengths. Returns: (Latt...
[ "def", "lattice_from_sites_file", "(", "site_file", ",", "cell_lengths", ")", ":", "sites", "=", "[", "]", "site_re", "=", "re", ".", "compile", "(", "'site:\\s+([-+]?\\d+)'", ")", "r_re", "=", "re", ".", "compile", "(", "'cent(?:er|re):\\s+([-\\d\\.e]+)\\s+([-\\d...
Generate a lattice from a sites file. Args: site_file (Str): Filename for the file containing the site information. cell_lengths (List(Float,Float,Float)): A list containing the [ x, y, z ] cell lengths. Returns: (Lattice): The new lattice Notes: | The site information fil...
[ "Generate", "a", "lattice", "from", "a", "sites", "file", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/init_lattice.py#L134-L180
train
63,349
futurecolors/django-geoip
django_geoip/views.py
set_location
def set_location(request): """ Redirect to a given url while setting the chosen location in the cookie. The url and the location_id need to be specified in the request parameters. Since this view changes how the user will see the rest of the site, it must only be accessed as a POST request. If ...
python
def set_location(request): """ Redirect to a given url while setting the chosen location in the cookie. The url and the location_id need to be specified in the request parameters. Since this view changes how the user will see the rest of the site, it must only be accessed as a POST request. If ...
[ "def", "set_location", "(", "request", ")", ":", "next", "=", "request", ".", "GET", ".", "get", "(", "'next'", ",", "None", ")", "or", "request", ".", "POST", ".", "get", "(", "'next'", ",", "None", ")", "if", "not", "next", ":", "next", "=", "r...
Redirect to a given url while setting the chosen location in the cookie. The url and the location_id need to be specified in the request parameters. Since this view changes how the user will see the rest of the site, it must only be accessed as a POST request. If called as a GET request, it will re...
[ "Redirect", "to", "a", "given", "url", "while", "setting", "the", "chosen", "location", "in", "the", "cookie", ".", "The", "url", "and", "the", "location_id", "need", "to", "be", "specified", "in", "the", "request", "parameters", "." ]
f9eee4bcad40508089b184434b79826f842d7bd0
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/views.py#L8-L33
train
63,350
bjmorgan/lattice_mc
lattice_mc/lattice_site.py
Site.site_specific_nn_occupation
def site_specific_nn_occupation( self ): """ Returns the number of occupied nearest neighbour sites, classified by site type. Args: None Returns: (Dict(Str:Int)): Dictionary of nearest-neighbour occupied site numbers, classified by site label, e.g. { 'A' : 2, 'B...
python
def site_specific_nn_occupation( self ): """ Returns the number of occupied nearest neighbour sites, classified by site type. Args: None Returns: (Dict(Str:Int)): Dictionary of nearest-neighbour occupied site numbers, classified by site label, e.g. { 'A' : 2, 'B...
[ "def", "site_specific_nn_occupation", "(", "self", ")", ":", "to_return", "=", "{", "l", ":", "0", "for", "l", "in", "set", "(", "(", "site", ".", "label", "for", "site", "in", "self", ".", "p_neighbours", ")", ")", "}", "for", "site", "in", "self", ...
Returns the number of occupied nearest neighbour sites, classified by site type. Args: None Returns: (Dict(Str:Int)): Dictionary of nearest-neighbour occupied site numbers, classified by site label, e.g. { 'A' : 2, 'B' : 1 }.
[ "Returns", "the", "number", "of", "occupied", "nearest", "neighbour", "sites", "classified", "by", "site", "type", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice_site.py#L54-L68
train
63,351
bjmorgan/lattice_mc
lattice_mc/lattice_site.py
Site.cn_occupation_energy
def cn_occupation_energy( self, delta_occupation=None ): """ The coordination-number dependent energy for this site. Args: delta_occupation (:obj:Dict(Str:Int), optional): A dictionary of a change in (site-type specific) coordination number, e.g. { 'A' : 1, 'B' : -1 }. ...
python
def cn_occupation_energy( self, delta_occupation=None ): """ The coordination-number dependent energy for this site. Args: delta_occupation (:obj:Dict(Str:Int), optional): A dictionary of a change in (site-type specific) coordination number, e.g. { 'A' : 1, 'B' : -1 }. ...
[ "def", "cn_occupation_energy", "(", "self", ",", "delta_occupation", "=", "None", ")", ":", "nn_occupations", "=", "self", ".", "site_specific_nn_occupation", "(", ")", "if", "delta_occupation", ":", "for", "site", "in", "delta_occupation", ":", "assert", "(", "...
The coordination-number dependent energy for this site. Args: delta_occupation (:obj:Dict(Str:Int), optional): A dictionary of a change in (site-type specific) coordination number, e.g. { 'A' : 1, 'B' : -1 }. If this is not None, the coordination-number dependent energy is calculate...
[ "The", "coordination", "-", "number", "dependent", "energy", "for", "this", "site", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice_site.py#L94-L110
train
63,352
futurecolors/django-geoip
django_geoip/management/ipgeobase.py
IpGeobase.clear_database
def clear_database(self): """ Removes all geodata stored in database. Useful for development, never use on production. """ self.logger.info('Removing obsolete geoip from database...') IpRange.objects.all().delete() City.objects.all().delete() Region.objects.al...
python
def clear_database(self): """ Removes all geodata stored in database. Useful for development, never use on production. """ self.logger.info('Removing obsolete geoip from database...') IpRange.objects.all().delete() City.objects.all().delete() Region.objects.al...
[ "def", "clear_database", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "'Removing obsolete geoip from database...'", ")", "IpRange", ".", "objects", ".", "all", "(", ")", ".", "delete", "(", ")", "City", ".", "objects", ".", "all", "(", ...
Removes all geodata stored in database. Useful for development, never use on production.
[ "Removes", "all", "geodata", "stored", "in", "database", ".", "Useful", "for", "development", "never", "use", "on", "production", "." ]
f9eee4bcad40508089b184434b79826f842d7bd0
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/management/ipgeobase.py#L31-L39
train
63,353
futurecolors/django-geoip
django_geoip/management/ipgeobase.py
IpGeobase._download_extract_archive
def _download_extract_archive(self, url): """ Returns dict with 2 extracted filenames """ self.logger.info('Downloading zipfile from ipgeobase.ru...') temp_dir = tempfile.mkdtemp() archive = zipfile.ZipFile(self._download_url_to_string(url)) self.logger.info('Extracting files...'...
python
def _download_extract_archive(self, url): """ Returns dict with 2 extracted filenames """ self.logger.info('Downloading zipfile from ipgeobase.ru...') temp_dir = tempfile.mkdtemp() archive = zipfile.ZipFile(self._download_url_to_string(url)) self.logger.info('Extracting files...'...
[ "def", "_download_extract_archive", "(", "self", ",", "url", ")", ":", "self", ".", "logger", ".", "info", "(", "'Downloading zipfile from ipgeobase.ru...'", ")", "temp_dir", "=", "tempfile", ".", "mkdtemp", "(", ")", "archive", "=", "zipfile", ".", "ZipFile", ...
Returns dict with 2 extracted filenames
[ "Returns", "dict", "with", "2", "extracted", "filenames" ]
f9eee4bcad40508089b184434b79826f842d7bd0
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/management/ipgeobase.py#L57-L65
train
63,354
futurecolors/django-geoip
django_geoip/management/ipgeobase.py
IpGeobase._line_to_dict
def _line_to_dict(self, file, field_names): """ Converts file line into dictonary """ for line in file: delimiter = settings.IPGEOBASE_FILE_FIELDS_DELIMITER yield self._extract_data_from_line(line, field_names, delimiter)
python
def _line_to_dict(self, file, field_names): """ Converts file line into dictonary """ for line in file: delimiter = settings.IPGEOBASE_FILE_FIELDS_DELIMITER yield self._extract_data_from_line(line, field_names, delimiter)
[ "def", "_line_to_dict", "(", "self", ",", "file", ",", "field_names", ")", ":", "for", "line", "in", "file", ":", "delimiter", "=", "settings", ".", "IPGEOBASE_FILE_FIELDS_DELIMITER", "yield", "self", ".", "_extract_data_from_line", "(", "line", ",", "field_name...
Converts file line into dictonary
[ "Converts", "file", "line", "into", "dictonary" ]
f9eee4bcad40508089b184434b79826f842d7bd0
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/management/ipgeobase.py#L71-L75
train
63,355
futurecolors/django-geoip
django_geoip/management/ipgeobase.py
IpGeobase._process_cidr_file
def _process_cidr_file(self, file): """ Iterate over ip info and extract useful data """ data = {'cidr': list(), 'countries': set(), 'city_country_mapping': dict()} allowed_countries = settings.IPGEOBASE_ALLOWED_COUNTRIES for cidr_info in self._line_to_dict(file, field_names=settings.IPG...
python
def _process_cidr_file(self, file): """ Iterate over ip info and extract useful data """ data = {'cidr': list(), 'countries': set(), 'city_country_mapping': dict()} allowed_countries = settings.IPGEOBASE_ALLOWED_COUNTRIES for cidr_info in self._line_to_dict(file, field_names=settings.IPG...
[ "def", "_process_cidr_file", "(", "self", ",", "file", ")", ":", "data", "=", "{", "'cidr'", ":", "list", "(", ")", ",", "'countries'", ":", "set", "(", ")", ",", "'city_country_mapping'", ":", "dict", "(", ")", "}", "allowed_countries", "=", "settings",...
Iterate over ip info and extract useful data
[ "Iterate", "over", "ip", "info", "and", "extract", "useful", "data" ]
f9eee4bcad40508089b184434b79826f842d7bd0
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/management/ipgeobase.py#L80-L96
train
63,356
futurecolors/django-geoip
django_geoip/management/ipgeobase.py
IpGeobase._process_cities_file
def _process_cities_file(self, file, city_country_mapping): """ Iterate over cities info and extract useful data """ data = {'all_regions': list(), 'regions': list(), 'cities': list(), 'city_region_mapping': dict()} allowed_countries = settings.IPGEOBASE_ALLOWED_COUNTRIES for geo_info in...
python
def _process_cities_file(self, file, city_country_mapping): """ Iterate over cities info and extract useful data """ data = {'all_regions': list(), 'regions': list(), 'cities': list(), 'city_region_mapping': dict()} allowed_countries = settings.IPGEOBASE_ALLOWED_COUNTRIES for geo_info in...
[ "def", "_process_cities_file", "(", "self", ",", "file", ",", "city_country_mapping", ")", ":", "data", "=", "{", "'all_regions'", ":", "list", "(", ")", ",", "'regions'", ":", "list", "(", ")", ",", "'cities'", ":", "list", "(", ")", ",", "'city_region_...
Iterate over cities info and extract useful data
[ "Iterate", "over", "cities", "info", "and", "extract", "useful", "data" ]
f9eee4bcad40508089b184434b79826f842d7bd0
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/management/ipgeobase.py#L105-L126
train
63,357
futurecolors/django-geoip
django_geoip/management/ipgeobase.py
IpGeobase._update_geography
def _update_geography(self, countries, regions, cities, city_country_mapping): """ Update database with new countries, regions and cities """ existing = { 'cities': list(City.objects.values_list('id', flat=True)), 'regions': list(Region.objects.values('name', 'country__code')), ...
python
def _update_geography(self, countries, regions, cities, city_country_mapping): """ Update database with new countries, regions and cities """ existing = { 'cities': list(City.objects.values_list('id', flat=True)), 'regions': list(Region.objects.values('name', 'country__code')), ...
[ "def", "_update_geography", "(", "self", ",", "countries", ",", "regions", ",", "cities", ",", "city_country_mapping", ")", ":", "existing", "=", "{", "'cities'", ":", "list", "(", "City", ".", "objects", ".", "values_list", "(", "'id'", ",", "flat", "=", ...
Update database with new countries, regions and cities
[ "Update", "database", "with", "new", "countries", "regions", "and", "cities" ]
f9eee4bcad40508089b184434b79826f842d7bd0
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/management/ipgeobase.py#L128-L147
train
63,358
bjmorgan/lattice_mc
lattice_mc/lookup_table.py
LookupTable.relative_probability
def relative_probability( self, l1, l2, c1, c2 ): """ The relative probability for a jump between two sites with specific site types and coordination numbers. Args: l1 (Str): Site label for the initial site. l2 (Str): Site label for the final site. c1 (Int): ...
python
def relative_probability( self, l1, l2, c1, c2 ): """ The relative probability for a jump between two sites with specific site types and coordination numbers. Args: l1 (Str): Site label for the initial site. l2 (Str): Site label for the final site. c1 (Int): ...
[ "def", "relative_probability", "(", "self", ",", "l1", ",", "l2", ",", "c1", ",", "c2", ")", ":", "if", "self", ".", "site_energies", ":", "site_delta_E", "=", "self", ".", "site_energies", "[", "l2", "]", "-", "self", ".", "site_energies", "[", "l1", ...
The relative probability for a jump between two sites with specific site types and coordination numbers. Args: l1 (Str): Site label for the initial site. l2 (Str): Site label for the final site. c1 (Int): Coordination number for the initial site. c2 (Int): Coordi...
[ "The", "relative", "probability", "for", "a", "jump", "between", "two", "sites", "with", "specific", "site", "types", "and", "coordination", "numbers", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lookup_table.py#L50-L70
train
63,359
bjmorgan/lattice_mc
lattice_mc/lookup_table.py
LookupTable.generate_nearest_neighbour_lookup_table
def generate_nearest_neighbour_lookup_table( self ): """ Construct a look-up table of relative jump probabilities for a nearest-neighbour interaction Hamiltonian. Args: None. Returns: None. """ self.jump_probability = {} for site_label_1 ...
python
def generate_nearest_neighbour_lookup_table( self ): """ Construct a look-up table of relative jump probabilities for a nearest-neighbour interaction Hamiltonian. Args: None. Returns: None. """ self.jump_probability = {} for site_label_1 ...
[ "def", "generate_nearest_neighbour_lookup_table", "(", "self", ")", ":", "self", ".", "jump_probability", "=", "{", "}", "for", "site_label_1", "in", "self", ".", "connected_site_pairs", ":", "self", ".", "jump_probability", "[", "site_label_1", "]", "=", "{", "...
Construct a look-up table of relative jump probabilities for a nearest-neighbour interaction Hamiltonian. Args: None. Returns: None.
[ "Construct", "a", "look", "-", "up", "table", "of", "relative", "jump", "probabilities", "for", "a", "nearest", "-", "neighbour", "interaction", "Hamiltonian", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lookup_table.py#L72-L90
train
63,360
bjmorgan/lattice_mc
lattice_mc/atom.py
Atom.reset
def reset( self ): """ Reinitialise the stored displacements, number of hops, and list of sites visited for this `Atom`. Args: None Returns: None """ self.number_of_hops = 0 self.dr = np.array( [ 0.0, 0.0, 0.0 ] ) self.summed_dr2 ...
python
def reset( self ): """ Reinitialise the stored displacements, number of hops, and list of sites visited for this `Atom`. Args: None Returns: None """ self.number_of_hops = 0 self.dr = np.array( [ 0.0, 0.0, 0.0 ] ) self.summed_dr2 ...
[ "def", "reset", "(", "self", ")", ":", "self", ".", "number_of_hops", "=", "0", "self", ".", "dr", "=", "np", ".", "array", "(", "[", "0.0", ",", "0.0", ",", "0.0", "]", ")", "self", ".", "summed_dr2", "=", "0.0", "self", ".", "sites_visited", "=...
Reinitialise the stored displacements, number of hops, and list of sites visited for this `Atom`. Args: None Returns: None
[ "Reinitialise", "the", "stored", "displacements", "number", "of", "hops", "and", "list", "of", "sites", "visited", "for", "this", "Atom", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/atom.py#L31-L44
train
63,361
futurecolors/django-geoip
django_geoip/models.py
IpRangeQuerySet.by_ip
def by_ip(self, ip): """ Find the smallest range containing the given IP. """ try: number = inet_aton(ip) except Exception: raise IpRange.DoesNotExist try: return self.filter(start_ip__lte=number, end_ip__gte=number)\ .o...
python
def by_ip(self, ip): """ Find the smallest range containing the given IP. """ try: number = inet_aton(ip) except Exception: raise IpRange.DoesNotExist try: return self.filter(start_ip__lte=number, end_ip__gte=number)\ .o...
[ "def", "by_ip", "(", "self", ",", "ip", ")", ":", "try", ":", "number", "=", "inet_aton", "(", "ip", ")", "except", "Exception", ":", "raise", "IpRange", ".", "DoesNotExist", "try", ":", "return", "self", ".", "filter", "(", "start_ip__lte", "=", "numb...
Find the smallest range containing the given IP.
[ "Find", "the", "smallest", "range", "containing", "the", "given", "IP", "." ]
f9eee4bcad40508089b184434b79826f842d7bd0
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/models.py#L78-L90
train
63,362
ryan-roemer/django-cloud-browser
fabfile.py
_manage
def _manage(target, extra='', proj_settings=PROJ_SETTINGS): """Generic wrapper for ``django-admin.py``.""" local("export PYTHONPATH='' && " "export DJANGO_SETTINGS_MODULE='%s' && " "django-admin.py %s %s" % (proj_settings, target, extra), capture=False)
python
def _manage(target, extra='', proj_settings=PROJ_SETTINGS): """Generic wrapper for ``django-admin.py``.""" local("export PYTHONPATH='' && " "export DJANGO_SETTINGS_MODULE='%s' && " "django-admin.py %s %s" % (proj_settings, target, extra), capture=False)
[ "def", "_manage", "(", "target", ",", "extra", "=", "''", ",", "proj_settings", "=", "PROJ_SETTINGS", ")", ":", "local", "(", "\"export PYTHONPATH='' && \"", "\"export DJANGO_SETTINGS_MODULE='%s' && \"", "\"django-admin.py %s %s\"", "%", "(", "proj_settings", ",", "targ...
Generic wrapper for ``django-admin.py``.
[ "Generic", "wrapper", "for", "django", "-", "admin", ".", "py", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/fabfile.py#L152-L158
train
63,363
Kitware/tangelo
tangelo/tangelo/__init__.py
types
def types(**typefuncs): """ Decorate a function that takes strings to one that takes typed values. The decorator's arguments are functions to perform type conversion. The positional and keyword arguments will be mapped to the positional and keyword arguments of the decoratored function. This allow...
python
def types(**typefuncs): """ Decorate a function that takes strings to one that takes typed values. The decorator's arguments are functions to perform type conversion. The positional and keyword arguments will be mapped to the positional and keyword arguments of the decoratored function. This allow...
[ "def", "types", "(", "*", "*", "typefuncs", ")", ":", "def", "wrap", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "typed_func", "(", "*", "pargs", ",", "*", "*", "kwargs", ")", ":", "# Analyze the incoming arguments so we k...
Decorate a function that takes strings to one that takes typed values. The decorator's arguments are functions to perform type conversion. The positional and keyword arguments will be mapped to the positional and keyword arguments of the decoratored function. This allows web-based service functions, w...
[ "Decorate", "a", "function", "that", "takes", "strings", "to", "one", "that", "takes", "typed", "values", "." ]
470034ee9b3d7a01becc1ce5fddc7adc1d5263ef
https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/__init__.py#L221-L286
train
63,364
Kitware/tangelo
tangelo/tangelo/__init__.py
return_type
def return_type(rettype): """ Decorate a function to automatically convert its return type to a string using a custom function. Web-based service functions must return text to the client. Tangelo contains default logic to convert many kinds of values into string, but this decorator allows the ...
python
def return_type(rettype): """ Decorate a function to automatically convert its return type to a string using a custom function. Web-based service functions must return text to the client. Tangelo contains default logic to convert many kinds of values into string, but this decorator allows the ...
[ "def", "return_type", "(", "rettype", ")", ":", "def", "wrap", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "converter", "(", "*", "pargs", ",", "*", "*", "kwargs", ")", ":", "# Run the function to capture the output.", "resu...
Decorate a function to automatically convert its return type to a string using a custom function. Web-based service functions must return text to the client. Tangelo contains default logic to convert many kinds of values into string, but this decorator allows the service writer to specify custom behav...
[ "Decorate", "a", "function", "to", "automatically", "convert", "its", "return", "type", "to", "a", "string", "using", "a", "custom", "function", "." ]
470034ee9b3d7a01becc1ce5fddc7adc1d5263ef
https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/__init__.py#L289-L316
train
63,365
ryan-roemer/django-cloud-browser
cloud_browser/cloud/errors.py
CloudExceptionWrapper.excepts
def excepts(cls): """Return tuple of underlying exception classes to trap and wrap. :rtype: ``tuple`` of ``type`` """ if cls._excepts is None: cls._excepts = tuple(cls.translations.keys()) return cls._excepts
python
def excepts(cls): """Return tuple of underlying exception classes to trap and wrap. :rtype: ``tuple`` of ``type`` """ if cls._excepts is None: cls._excepts = tuple(cls.translations.keys()) return cls._excepts
[ "def", "excepts", "(", "cls", ")", ":", "if", "cls", ".", "_excepts", "is", "None", ":", "cls", ".", "_excepts", "=", "tuple", "(", "cls", ".", "translations", ".", "keys", "(", ")", ")", "return", "cls", ".", "_excepts" ]
Return tuple of underlying exception classes to trap and wrap. :rtype: ``tuple`` of ``type``
[ "Return", "tuple", "of", "underlying", "exception", "classes", "to", "trap", "and", "wrap", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/errors.py#L102-L109
train
63,366
ryan-roemer/django-cloud-browser
cloud_browser/cloud/errors.py
CloudExceptionWrapper.translate
def translate(self, exc): """Return translation of exception to new class. Calling code should only raise exception if exception class is passed in, else ``None`` (which signifies no wrapping should be done). """ # Find actual class. for key in self.translations.keys(): ...
python
def translate(self, exc): """Return translation of exception to new class. Calling code should only raise exception if exception class is passed in, else ``None`` (which signifies no wrapping should be done). """ # Find actual class. for key in self.translations.keys(): ...
[ "def", "translate", "(", "self", ",", "exc", ")", ":", "# Find actual class.", "for", "key", "in", "self", ".", "translations", ".", "keys", "(", ")", ":", "if", "isinstance", "(", "exc", ",", "key", ")", ":", "# pylint: disable=unsubscriptable-object", "ret...
Return translation of exception to new class. Calling code should only raise exception if exception class is passed in, else ``None`` (which signifies no wrapping should be done).
[ "Return", "translation", "of", "exception", "to", "new", "class", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/errors.py#L111-L123
train
63,367
ryan-roemer/django-cloud-browser
cloud_browser/views.py
settings_view_decorator
def settings_view_decorator(function): """Insert decorator from settings, if any. .. note:: Decorator in ``CLOUD_BROWSER_VIEW_DECORATOR`` can be either a callable or a fully-qualified string path (the latter, which we'll lazy import). """ dec = settings.CLOUD_BROWSER_VIEW_DECORATOR ...
python
def settings_view_decorator(function): """Insert decorator from settings, if any. .. note:: Decorator in ``CLOUD_BROWSER_VIEW_DECORATOR`` can be either a callable or a fully-qualified string path (the latter, which we'll lazy import). """ dec = settings.CLOUD_BROWSER_VIEW_DECORATOR ...
[ "def", "settings_view_decorator", "(", "function", ")", ":", "dec", "=", "settings", ".", "CLOUD_BROWSER_VIEW_DECORATOR", "# Trade-up string to real decorator.", "if", "isinstance", "(", "dec", ",", "str", ")", ":", "# Split into module and decorator strings.", "mod_str", ...
Insert decorator from settings, if any. .. note:: Decorator in ``CLOUD_BROWSER_VIEW_DECORATOR`` can be either a callable or a fully-qualified string path (the latter, which we'll lazy import).
[ "Insert", "decorator", "from", "settings", "if", "any", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/views.py#L20-L47
train
63,368
ryan-roemer/django-cloud-browser
cloud_browser/views.py
_breadcrumbs
def _breadcrumbs(path): """Return breadcrumb dict from path.""" full = None crumbs = [] for part in path_yield(path): full = path_join(full, part) if full else part crumbs.append((full, part)) return crumbs
python
def _breadcrumbs(path): """Return breadcrumb dict from path.""" full = None crumbs = [] for part in path_yield(path): full = path_join(full, part) if full else part crumbs.append((full, part)) return crumbs
[ "def", "_breadcrumbs", "(", "path", ")", ":", "full", "=", "None", "crumbs", "=", "[", "]", "for", "part", "in", "path_yield", "(", "path", ")", ":", "full", "=", "path_join", "(", "full", ",", "part", ")", "if", "full", "else", "part", "crumbs", "...
Return breadcrumb dict from path.
[ "Return", "breadcrumb", "dict", "from", "path", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/views.py#L50-L59
train
63,369
ryan-roemer/django-cloud-browser
cloud_browser/views.py
browser
def browser(request, path='', template="cloud_browser/browser.html"): """View files in a file path. :param request: The request. :param path: Path to resource, including container as first part of path. :param template: Template to render. """ from itertools import islice try: # p...
python
def browser(request, path='', template="cloud_browser/browser.html"): """View files in a file path. :param request: The request. :param path: Path to resource, including container as first part of path. :param template: Template to render. """ from itertools import islice try: # p...
[ "def", "browser", "(", "request", ",", "path", "=", "''", ",", "template", "=", "\"cloud_browser/browser.html\"", ")", ":", "from", "itertools", "import", "islice", "try", ":", "# pylint: disable=redefined-builtin", "from", "future_builtins", "import", "filter", "ex...
View files in a file path. :param request: The request. :param path: Path to resource, including container as first part of path. :param template: Template to render.
[ "View", "files", "in", "a", "file", "path", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/views.py#L63-L139
train
63,370
ryan-roemer/django-cloud-browser
cloud_browser/views.py
document
def document(_, path=''): """View single document from path. :param path: Path to resource, including container as first part of path. """ container_path, object_path = path_parts(path) conn = get_connection() try: container = conn.get_container(container_path) except errors.NoConta...
python
def document(_, path=''): """View single document from path. :param path: Path to resource, including container as first part of path. """ container_path, object_path = path_parts(path) conn = get_connection() try: container = conn.get_container(container_path) except errors.NoConta...
[ "def", "document", "(", "_", ",", "path", "=", "''", ")", ":", "container_path", ",", "object_path", "=", "path_parts", "(", "path", ")", "conn", "=", "get_connection", "(", ")", "try", ":", "container", "=", "conn", ".", "get_container", "(", "container...
View single document from path. :param path: Path to resource, including container as first part of path.
[ "View", "single", "document", "from", "path", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/views.py#L143-L170
train
63,371
ryan-roemer/django-cloud-browser
cloud_browser/templatetags/cloud_browser_extras.py
truncatechars
def truncatechars(value, num, end_text="..."): """Truncate string on character boundary. .. note:: Django ticket `5025 <http://code.djangoproject.com/ticket/5025>`_ has a patch for a more extensible and robust truncate characters tag filter. Example:: {{ my_variable|truncatechars:...
python
def truncatechars(value, num, end_text="..."): """Truncate string on character boundary. .. note:: Django ticket `5025 <http://code.djangoproject.com/ticket/5025>`_ has a patch for a more extensible and robust truncate characters tag filter. Example:: {{ my_variable|truncatechars:...
[ "def", "truncatechars", "(", "value", ",", "num", ",", "end_text", "=", "\"...\"", ")", ":", "length", "=", "None", "try", ":", "length", "=", "int", "(", "num", ")", "except", "ValueError", ":", "pass", "if", "length", "is", "not", "None", "and", "l...
Truncate string on character boundary. .. note:: Django ticket `5025 <http://code.djangoproject.com/ticket/5025>`_ has a patch for a more extensible and robust truncate characters tag filter. Example:: {{ my_variable|truncatechars:22 }} :param value: Value to truncate. :type ...
[ "Truncate", "string", "on", "character", "boundary", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/templatetags/cloud_browser_extras.py#L15-L40
train
63,372
ryan-roemer/django-cloud-browser
cloud_browser/templatetags/cloud_browser_extras.py
cloud_browser_media_url
def cloud_browser_media_url(_, token): """Get base media URL for application static media. Correctly handles whether or not the settings variable ``CLOUD_BROWSER_STATIC_MEDIA_DIR`` is set and served. For example:: <link rel="stylesheet" type="text/css" href="{% cloud_browser_media...
python
def cloud_browser_media_url(_, token): """Get base media URL for application static media. Correctly handles whether or not the settings variable ``CLOUD_BROWSER_STATIC_MEDIA_DIR`` is set and served. For example:: <link rel="stylesheet" type="text/css" href="{% cloud_browser_media...
[ "def", "cloud_browser_media_url", "(", "_", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "!=", "2", ":", "raise", "TemplateSyntaxError", "(", "\"'%s' takes one argument\"", "%", "bits", "[", ...
Get base media URL for application static media. Correctly handles whether or not the settings variable ``CLOUD_BROWSER_STATIC_MEDIA_DIR`` is set and served. For example:: <link rel="stylesheet" type="text/css" href="{% cloud_browser_media_url "css/cloud-browser.css" %}" />
[ "Get", "base", "media", "URL", "for", "application", "static", "media", "." ]
b06cdd24885a6309e843ed924dbf1705b67e7f48
https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/templatetags/cloud_browser_extras.py#L45-L61
train
63,373
bjmorgan/lattice_mc
lattice_mc/simulation.py
Simulation.reset
def reset( self ): """ Reset all counters for this simulation. Args: None Returns: None """ self.lattice.reset() for atom in self.atoms.atoms: atom.reset()
python
def reset( self ): """ Reset all counters for this simulation. Args: None Returns: None """ self.lattice.reset() for atom in self.atoms.atoms: atom.reset()
[ "def", "reset", "(", "self", ")", ":", "self", ".", "lattice", ".", "reset", "(", ")", "for", "atom", "in", "self", ".", "atoms", ".", "atoms", ":", "atom", ".", "reset", "(", ")" ]
Reset all counters for this simulation. Args: None Returns: None
[ "Reset", "all", "counters", "for", "this", "simulation", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/simulation.py#L29-L41
train
63,374
bjmorgan/lattice_mc
lattice_mc/simulation.py
Simulation.set_number_of_atoms
def set_number_of_atoms( self, n, selected_sites=None ): """ Set the number of atoms for the simulation, and populate the simulation lattice. Args: n (Int): Number of atoms for this simulation. selected_sites (:obj:(List|Set|String), optional): Selects a subset of site t...
python
def set_number_of_atoms( self, n, selected_sites=None ): """ Set the number of atoms for the simulation, and populate the simulation lattice. Args: n (Int): Number of atoms for this simulation. selected_sites (:obj:(List|Set|String), optional): Selects a subset of site t...
[ "def", "set_number_of_atoms", "(", "self", ",", "n", ",", "selected_sites", "=", "None", ")", ":", "self", ".", "number_of_atoms", "=", "n", "self", ".", "atoms", "=", "species", ".", "Species", "(", "self", ".", "lattice", ".", "populate_sites", "(", "s...
Set the number of atoms for the simulation, and populate the simulation lattice. Args: n (Int): Number of atoms for this simulation. selected_sites (:obj:(List|Set|String), optional): Selects a subset of site types to be populated with atoms. Defaults to None. Returns: ...
[ "Set", "the", "number", "of", "atoms", "for", "the", "simulation", "and", "populate", "the", "simulation", "lattice", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/simulation.py#L43-L55
train
63,375
bjmorgan/lattice_mc
lattice_mc/simulation.py
Simulation.is_initialised
def is_initialised( self ): """ Check whether the simulation has been initialised. Args: None Returns: None """ if not self.lattice: raise AttributeError('Running a simulation needs the lattice to be initialised') if not self....
python
def is_initialised( self ): """ Check whether the simulation has been initialised. Args: None Returns: None """ if not self.lattice: raise AttributeError('Running a simulation needs the lattice to be initialised') if not self....
[ "def", "is_initialised", "(", "self", ")", ":", "if", "not", "self", ".", "lattice", ":", "raise", "AttributeError", "(", "'Running a simulation needs the lattice to be initialised'", ")", "if", "not", "self", ".", "atoms", ":", "raise", "AttributeError", "(", "'R...
Check whether the simulation has been initialised. Args: None Returns: None
[ "Check", "whether", "the", "simulation", "has", "been", "initialised", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/simulation.py#L135-L150
train
63,376
bjmorgan/lattice_mc
lattice_mc/simulation.py
Simulation.old_collective_correlation
def old_collective_correlation( self ): """ Returns the collective correlation factor, f_I Args: None Returns: (Float): The collective correlation factor, f_I. Notes: This function assumes that the jump distance between sites has ...
python
def old_collective_correlation( self ): """ Returns the collective correlation factor, f_I Args: None Returns: (Float): The collective correlation factor, f_I. Notes: This function assumes that the jump distance between sites has ...
[ "def", "old_collective_correlation", "(", "self", ")", ":", "if", "self", ".", "has_run", ":", "return", "self", ".", "atoms", ".", "collective_dr_squared", "(", ")", "/", "float", "(", "self", ".", "number_of_jumps", ")", "else", ":", "return", "None" ]
Returns the collective correlation factor, f_I Args: None Returns: (Float): The collective correlation factor, f_I. Notes: This function assumes that the jump distance between sites has been normalised to a=1. If the jumps distance is not equal ...
[ "Returns", "the", "collective", "correlation", "factor", "f_I" ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/simulation.py#L236-L255
train
63,377
bjmorgan/lattice_mc
lattice_mc/simulation.py
Simulation.collective_diffusion_coefficient
def collective_diffusion_coefficient( self ): """ Returns the collective or "jump" diffusion coefficient, D_J. Args: None Returns: (Float): The collective diffusion coefficient, D_J. """ if self.has_run: return self.atoms.collective_d...
python
def collective_diffusion_coefficient( self ): """ Returns the collective or "jump" diffusion coefficient, D_J. Args: None Returns: (Float): The collective diffusion coefficient, D_J. """ if self.has_run: return self.atoms.collective_d...
[ "def", "collective_diffusion_coefficient", "(", "self", ")", ":", "if", "self", ".", "has_run", ":", "return", "self", ".", "atoms", ".", "collective_dr_squared", "(", ")", "/", "(", "6.0", "*", "self", ".", "lattice", ".", "time", ")", "else", ":", "ret...
Returns the collective or "jump" diffusion coefficient, D_J. Args: None Returns: (Float): The collective diffusion coefficient, D_J.
[ "Returns", "the", "collective", "or", "jump", "diffusion", "coefficient", "D_J", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/simulation.py#L274-L287
train
63,378
bjmorgan/lattice_mc
lattice_mc/simulation.py
Simulation.setup_lookup_table
def setup_lookup_table( self, hamiltonian='nearest-neighbour' ): """ Create a jump-probability look-up table corresponding to the appropriate Hamiltonian. Args: hamiltonian (Str, optional): String specifying the simulation Hamiltonian. valid values are 'nearest-neigh...
python
def setup_lookup_table( self, hamiltonian='nearest-neighbour' ): """ Create a jump-probability look-up table corresponding to the appropriate Hamiltonian. Args: hamiltonian (Str, optional): String specifying the simulation Hamiltonian. valid values are 'nearest-neigh...
[ "def", "setup_lookup_table", "(", "self", ",", "hamiltonian", "=", "'nearest-neighbour'", ")", ":", "expected_hamiltonian_values", "=", "[", "'nearest-neighbour'", ",", "'coordination_number'", "]", "if", "hamiltonian", "not", "in", "expected_hamiltonian_values", ":", "...
Create a jump-probability look-up table corresponding to the appropriate Hamiltonian. Args: hamiltonian (Str, optional): String specifying the simulation Hamiltonian. valid values are 'nearest-neighbour' (default) and 'coordination_number'. Returns: None
[ "Create", "a", "jump", "-", "probability", "look", "-", "up", "table", "corresponding", "to", "the", "appropriate", "Hamiltonian", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/simulation.py#L319-L333
train
63,379
bjmorgan/lattice_mc
lattice_mc/lattice.py
Lattice.update
def update( self, jump ): """ Update the lattice state by accepting a specific jump Args: jump (Jump): The jump that has been accepted. Returns: None. """ atom = jump.initial_site.atom dr = jump.dr( self.cell_lengths ) #print( "at...
python
def update( self, jump ): """ Update the lattice state by accepting a specific jump Args: jump (Jump): The jump that has been accepted. Returns: None. """ atom = jump.initial_site.atom dr = jump.dr( self.cell_lengths ) #print( "at...
[ "def", "update", "(", "self", ",", "jump", ")", ":", "atom", "=", "jump", ".", "initial_site", ".", "atom", "dr", "=", "jump", ".", "dr", "(", "self", ".", "cell_lengths", ")", "#print( \"atom {} jumped from site {} to site {}\".format( atom.number, jump.initial_sit...
Update the lattice state by accepting a specific jump Args: jump (Jump): The jump that has been accepted. Returns: None.
[ "Update", "the", "lattice", "state", "by", "accepting", "a", "specific", "jump" ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice.py#L171-L194
train
63,380
bjmorgan/lattice_mc
lattice_mc/lattice.py
Lattice.populate_sites
def populate_sites( self, number_of_atoms, selected_sites=None ): """ Populate the lattice sites with a specific number of atoms. Args: number_of_atoms (Int): The number of atoms to populate the lattice sites with. selected_sites (:obj:List, optional): List of site label...
python
def populate_sites( self, number_of_atoms, selected_sites=None ): """ Populate the lattice sites with a specific number of atoms. Args: number_of_atoms (Int): The number of atoms to populate the lattice sites with. selected_sites (:obj:List, optional): List of site label...
[ "def", "populate_sites", "(", "self", ",", "number_of_atoms", ",", "selected_sites", "=", "None", ")", ":", "if", "number_of_atoms", ">", "self", ".", "number_of_sites", ":", "raise", "ValueError", "if", "selected_sites", ":", "atoms", "=", "[", "atom", ".", ...
Populate the lattice sites with a specific number of atoms. Args: number_of_atoms (Int): The number of atoms to populate the lattice sites with. selected_sites (:obj:List, optional): List of site labels if only some sites are to be occupied. Defaults to None. Returns: ...
[ "Populate", "the", "lattice", "sites", "with", "a", "specific", "number", "of", "atoms", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice.py#L196-L214
train
63,381
bjmorgan/lattice_mc
lattice_mc/lattice.py
Lattice.jump
def jump( self ): """ Select a jump at random from all potential jumps, then update the lattice state. Args: None Returns: None """ potential_jumps = self.potential_jumps() if not potential_jumps: raise BlockedLatticeError('No...
python
def jump( self ): """ Select a jump at random from all potential jumps, then update the lattice state. Args: None Returns: None """ potential_jumps = self.potential_jumps() if not potential_jumps: raise BlockedLatticeError('No...
[ "def", "jump", "(", "self", ")", ":", "potential_jumps", "=", "self", ".", "potential_jumps", "(", ")", "if", "not", "potential_jumps", ":", "raise", "BlockedLatticeError", "(", "'No moves are possible in this lattice'", ")", "all_transitions", "=", "transitions", "...
Select a jump at random from all potential jumps, then update the lattice state. Args: None Returns: None
[ "Select", "a", "jump", "at", "random", "from", "all", "potential", "jumps", "then", "update", "the", "lattice", "state", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice.py#L216-L235
train
63,382
bjmorgan/lattice_mc
lattice_mc/lattice.py
Lattice.site_occupation_statistics
def site_occupation_statistics( self ): """ Average site occupation for each site type Args: None Returns: (Dict(Str:Float)): Dictionary of occupation statistics, e.g.:: { 'A' : 2.5, 'B' : 25.3 } """ if self.time == 0.0: ...
python
def site_occupation_statistics( self ): """ Average site occupation for each site type Args: None Returns: (Dict(Str:Float)): Dictionary of occupation statistics, e.g.:: { 'A' : 2.5, 'B' : 25.3 } """ if self.time == 0.0: ...
[ "def", "site_occupation_statistics", "(", "self", ")", ":", "if", "self", ".", "time", "==", "0.0", ":", "return", "None", "occupation_stats", "=", "{", "label", ":", "0.0", "for", "label", "in", "self", ".", "site_labels", "}", "for", "site", "in", "sel...
Average site occupation for each site type Args: None Returns: (Dict(Str:Float)): Dictionary of occupation statistics, e.g.:: { 'A' : 2.5, 'B' : 25.3 }
[ "Average", "site", "occupation", "for", "each", "site", "type" ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice.py#L250-L269
train
63,383
bjmorgan/lattice_mc
lattice_mc/lattice.py
Lattice.set_site_energies
def set_site_energies( self, energies ): """ Set the energies for every site in the lattice according to the site labels. Args: energies (Dict(Str:Float): Dictionary of energies for each site label, e.g.:: { 'A' : 1.0, 'B', 0.0 } Returns: None ...
python
def set_site_energies( self, energies ): """ Set the energies for every site in the lattice according to the site labels. Args: energies (Dict(Str:Float): Dictionary of energies for each site label, e.g.:: { 'A' : 1.0, 'B', 0.0 } Returns: None ...
[ "def", "set_site_energies", "(", "self", ",", "energies", ")", ":", "self", ".", "site_energies", "=", "energies", "for", "site_label", "in", "energies", ":", "for", "site", "in", "self", ".", "sites", ":", "if", "site", ".", "label", "==", "site_label", ...
Set the energies for every site in the lattice according to the site labels. Args: energies (Dict(Str:Float): Dictionary of energies for each site label, e.g.:: { 'A' : 1.0, 'B', 0.0 } Returns: None
[ "Set", "the", "energies", "for", "every", "site", "in", "the", "lattice", "according", "to", "the", "site", "labels", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice.py#L271-L287
train
63,384
bjmorgan/lattice_mc
lattice_mc/lattice.py
Lattice.set_cn_energies
def set_cn_energies( self, cn_energies ): """ Set the coordination number dependent energies for this lattice. Args: cn_energies (Dict(Str:Dict(Int:Float))): Dictionary of dictionaries specifying the coordination number dependent energies for each site type. e.g.:: ...
python
def set_cn_energies( self, cn_energies ): """ Set the coordination number dependent energies for this lattice. Args: cn_energies (Dict(Str:Dict(Int:Float))): Dictionary of dictionaries specifying the coordination number dependent energies for each site type. e.g.:: ...
[ "def", "set_cn_energies", "(", "self", ",", "cn_energies", ")", ":", "for", "site", "in", "self", ".", "sites", ":", "site", ".", "set_cn_occupation_energies", "(", "cn_energies", "[", "site", ".", "label", "]", ")", "self", ".", "cn_energies", "=", "cn_en...
Set the coordination number dependent energies for this lattice. Args: cn_energies (Dict(Str:Dict(Int:Float))): Dictionary of dictionaries specifying the coordination number dependent energies for each site type. e.g.:: { 'A' : { 0 : 0.0, 1 : 1.0, 2 : 2.0 }, 'B' : { 0 : 0.0, 1 : 2....
[ "Set", "the", "coordination", "number", "dependent", "energies", "for", "this", "lattice", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice.py#L301-L315
train
63,385
bjmorgan/lattice_mc
lattice_mc/lattice.py
Lattice.site_specific_coordination_numbers
def site_specific_coordination_numbers( self ): """ Returns a dictionary of coordination numbers for each site type. Args: None Returns: (Dict(Str:List(Int))) : Dictionary of coordination numbers for each site type, e.g.:: { 'A' : [ 2, 4 ], 'B' ...
python
def site_specific_coordination_numbers( self ): """ Returns a dictionary of coordination numbers for each site type. Args: None Returns: (Dict(Str:List(Int))) : Dictionary of coordination numbers for each site type, e.g.:: { 'A' : [ 2, 4 ], 'B' ...
[ "def", "site_specific_coordination_numbers", "(", "self", ")", ":", "specific_coordination_numbers", "=", "{", "}", "for", "site", "in", "self", ".", "sites", ":", "specific_coordination_numbers", "[", "site", ".", "label", "]", "=", "site", ".", "site_specific_ne...
Returns a dictionary of coordination numbers for each site type. Args: None Returns: (Dict(Str:List(Int))) : Dictionary of coordination numbers for each site type, e.g.:: { 'A' : [ 2, 4 ], 'B' : [ 2 ] }
[ "Returns", "a", "dictionary", "of", "coordination", "numbers", "for", "each", "site", "type", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice.py#L351-L366
train
63,386
bjmorgan/lattice_mc
lattice_mc/lattice.py
Lattice.transmute_sites
def transmute_sites( self, old_site_label, new_site_label, n_sites_to_change ): """ Selects a random subset of sites with a specific label and gives them a different label. Args: old_site_label (String or List(String)): Site label(s) of the sites to be modified.. new_sit...
python
def transmute_sites( self, old_site_label, new_site_label, n_sites_to_change ): """ Selects a random subset of sites with a specific label and gives them a different label. Args: old_site_label (String or List(String)): Site label(s) of the sites to be modified.. new_sit...
[ "def", "transmute_sites", "(", "self", ",", "old_site_label", ",", "new_site_label", ",", "n_sites_to_change", ")", ":", "selected_sites", "=", "self", ".", "select_sites", "(", "old_site_label", ")", "for", "site", "in", "random", ".", "sample", "(", "selected_...
Selects a random subset of sites with a specific label and gives them a different label. Args: old_site_label (String or List(String)): Site label(s) of the sites to be modified.. new_site_label (String): Site label to be applied to the modified sites. n_site...
[ "Selects", "a", "random", "subset", "of", "sites", "with", "a", "specific", "label", "and", "gives", "them", "a", "different", "label", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice.py#L390-L405
train
63,387
bjmorgan/lattice_mc
lattice_mc/lattice.py
Lattice.connected_sites
def connected_sites( self, site_labels=None ): """ Searches the lattice to find sets of sites that are contiguously neighbouring. Mutually exclusive sets of contiguous sites are returned as Cluster objects. Args: site_labels (:obj:(List(Str)|Set(Str)|Str), optional): Labels ...
python
def connected_sites( self, site_labels=None ): """ Searches the lattice to find sets of sites that are contiguously neighbouring. Mutually exclusive sets of contiguous sites are returned as Cluster objects. Args: site_labels (:obj:(List(Str)|Set(Str)|Str), optional): Labels ...
[ "def", "connected_sites", "(", "self", ",", "site_labels", "=", "None", ")", ":", "if", "site_labels", ":", "selected_sites", "=", "self", ".", "select_sites", "(", "site_labels", ")", "else", ":", "selected_sites", "=", "self", ".", "sites", "initial_clusters...
Searches the lattice to find sets of sites that are contiguously neighbouring. Mutually exclusive sets of contiguous sites are returned as Cluster objects. Args: site_labels (:obj:(List(Str)|Set(Str)|Str), optional): Labels for sites to be considered in the search. This can ...
[ "Searches", "the", "lattice", "to", "find", "sets", "of", "sites", "that", "are", "contiguously", "neighbouring", ".", "Mutually", "exclusive", "sets", "of", "contiguous", "sites", "are", "returned", "as", "Cluster", "objects", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice.py#L407-L447
train
63,388
bjmorgan/lattice_mc
lattice_mc/lattice.py
Lattice.select_sites
def select_sites( self, site_labels ): """ Selects sites in the lattice with specified labels. Args: site_labels (List(Str)|Set(Str)|Str): Labels of sites to select. This can be a List [ 'A', 'B' ], a Set ( 'A', 'B' ), or a String 'A'. Returns: (...
python
def select_sites( self, site_labels ): """ Selects sites in the lattice with specified labels. Args: site_labels (List(Str)|Set(Str)|Str): Labels of sites to select. This can be a List [ 'A', 'B' ], a Set ( 'A', 'B' ), or a String 'A'. Returns: (...
[ "def", "select_sites", "(", "self", ",", "site_labels", ")", ":", "if", "type", "(", "site_labels", ")", "in", "(", "list", ",", "set", ")", ":", "selected_sites", "=", "[", "s", "for", "s", "in", "self", ".", "sites", "if", "s", ".", "label", "in"...
Selects sites in the lattice with specified labels. Args: site_labels (List(Str)|Set(Str)|Str): Labels of sites to select. This can be a List [ 'A', 'B' ], a Set ( 'A', 'B' ), or a String 'A'. Returns: (List(Site)): List of sites with labels given by `site_label...
[ "Selects", "sites", "in", "the", "lattice", "with", "specified", "labels", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/lattice.py#L449-L466
train
63,389
bjmorgan/lattice_mc
lattice_mc/cluster.py
Cluster.merge
def merge( self, other_cluster ): """ Combine two clusters into a single cluster. Args: other_cluster (Cluster): The second cluster to combine. Returns: (Cluster): The combination of both clusters. """ new_cluster = Cluster( self.sites | other_...
python
def merge( self, other_cluster ): """ Combine two clusters into a single cluster. Args: other_cluster (Cluster): The second cluster to combine. Returns: (Cluster): The combination of both clusters. """ new_cluster = Cluster( self.sites | other_...
[ "def", "merge", "(", "self", ",", "other_cluster", ")", ":", "new_cluster", "=", "Cluster", "(", "self", ".", "sites", "|", "other_cluster", ".", "sites", ")", "new_cluster", ".", "neighbours", "=", "(", "self", ".", "neighbours", "|", "other_cluster", "."...
Combine two clusters into a single cluster. Args: other_cluster (Cluster): The second cluster to combine. Returns: (Cluster): The combination of both clusters.
[ "Combine", "two", "clusters", "into", "a", "single", "cluster", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/cluster.py#L21-L33
train
63,390
bjmorgan/lattice_mc
lattice_mc/cluster.py
Cluster.sites_at_edges
def sites_at_edges( self ): """ Finds the six sites with the maximum and minimum coordinates along x, y, and z. Args: None Returns: (List(List)): In the order [ +x, -x, +y, -y, +z, -z ] """ min_x = min( [ s.r[0] for s in self.sites ] ) m...
python
def sites_at_edges( self ): """ Finds the six sites with the maximum and minimum coordinates along x, y, and z. Args: None Returns: (List(List)): In the order [ +x, -x, +y, -y, +z, -z ] """ min_x = min( [ s.r[0] for s in self.sites ] ) m...
[ "def", "sites_at_edges", "(", "self", ")", ":", "min_x", "=", "min", "(", "[", "s", ".", "r", "[", "0", "]", "for", "s", "in", "self", ".", "sites", "]", ")", "max_x", "=", "max", "(", "[", "s", ".", "r", "[", "0", "]", "for", "s", "in", ...
Finds the six sites with the maximum and minimum coordinates along x, y, and z. Args: None Returns: (List(List)): In the order [ +x, -x, +y, -y, +z, -z ]
[ "Finds", "the", "six", "sites", "with", "the", "maximum", "and", "minimum", "coordinates", "along", "x", "y", "and", "z", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/cluster.py#L59-L81
train
63,391
bjmorgan/lattice_mc
lattice_mc/cluster.py
Cluster.is_periodically_contiguous
def is_periodically_contiguous( self ): """ logical check whether a cluster connects with itself across the simulation periodic boundary conditions. Args: none Returns ( Bool, Bool, Bool ): Contiguity along the x, y, and z coordinate axes """ ...
python
def is_periodically_contiguous( self ): """ logical check whether a cluster connects with itself across the simulation periodic boundary conditions. Args: none Returns ( Bool, Bool, Bool ): Contiguity along the x, y, and z coordinate axes """ ...
[ "def", "is_periodically_contiguous", "(", "self", ")", ":", "edges", "=", "self", ".", "sites_at_edges", "(", ")", "is_contiguous", "=", "[", "False", ",", "False", ",", "False", "]", "along_x", "=", "any", "(", "[", "s2", "in", "s1", ".", "p_neighbours"...
logical check whether a cluster connects with itself across the simulation periodic boundary conditions. Args: none Returns ( Bool, Bool, Bool ): Contiguity along the x, y, and z coordinate axes
[ "logical", "check", "whether", "a", "cluster", "connects", "with", "itself", "across", "the", "simulation", "periodic", "boundary", "conditions", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/cluster.py#L83-L99
train
63,392
bjmorgan/lattice_mc
lattice_mc/cluster.py
Cluster.remove_sites_from_neighbours
def remove_sites_from_neighbours( self, remove_labels ): """ Removes sites from the set of neighbouring sites if these have labels in remove_labels. Args: Remove_labels (List) or (Str): List of Site labels to be removed from the cluster neighbour set. Returns: N...
python
def remove_sites_from_neighbours( self, remove_labels ): """ Removes sites from the set of neighbouring sites if these have labels in remove_labels. Args: Remove_labels (List) or (Str): List of Site labels to be removed from the cluster neighbour set. Returns: N...
[ "def", "remove_sites_from_neighbours", "(", "self", ",", "remove_labels", ")", ":", "if", "type", "(", "remove_labels", ")", "is", "str", ":", "remove_labels", "=", "[", "remove_labels", "]", "self", ".", "neighbours", "=", "set", "(", "n", "for", "n", "in...
Removes sites from the set of neighbouring sites if these have labels in remove_labels. Args: Remove_labels (List) or (Str): List of Site labels to be removed from the cluster neighbour set. Returns: None
[ "Removes", "sites", "from", "the", "set", "of", "neighbouring", "sites", "if", "these", "have", "labels", "in", "remove_labels", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/cluster.py#L101-L113
train
63,393
bjmorgan/lattice_mc
lattice_mc/transitions.py
Transitions.cumulative_probabilities
def cumulative_probabilities( self ): """ Cumulative sum of the relative probabilities for all possible jumps. Args: None Returns: (np.array): Cumulative sum of relative jump probabilities. """ partition_function = np.sum( self.p ) return...
python
def cumulative_probabilities( self ): """ Cumulative sum of the relative probabilities for all possible jumps. Args: None Returns: (np.array): Cumulative sum of relative jump probabilities. """ partition_function = np.sum( self.p ) return...
[ "def", "cumulative_probabilities", "(", "self", ")", ":", "partition_function", "=", "np", ".", "sum", "(", "self", ".", "p", ")", "return", "np", ".", "cumsum", "(", "self", ".", "p", ")", "/", "partition_function" ]
Cumulative sum of the relative probabilities for all possible jumps. Args: None Returns: (np.array): Cumulative sum of relative jump probabilities.
[ "Cumulative", "sum", "of", "the", "relative", "probabilities", "for", "all", "possible", "jumps", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/transitions.py#L26-L37
train
63,394
bjmorgan/lattice_mc
lattice_mc/transitions.py
Transitions.random
def random( self ): """ Select a jump at random with appropriate relative probabilities. Args: None Returns: (Jump): The randomly selected Jump. """ j = np.searchsorted( self.cumulative_probabilities(), random.random() ) return self.jumps...
python
def random( self ): """ Select a jump at random with appropriate relative probabilities. Args: None Returns: (Jump): The randomly selected Jump. """ j = np.searchsorted( self.cumulative_probabilities(), random.random() ) return self.jumps...
[ "def", "random", "(", "self", ")", ":", "j", "=", "np", ".", "searchsorted", "(", "self", ".", "cumulative_probabilities", "(", ")", ",", "random", ".", "random", "(", ")", ")", "return", "self", ".", "jumps", "[", "j", "]" ]
Select a jump at random with appropriate relative probabilities. Args: None Returns: (Jump): The randomly selected Jump.
[ "Select", "a", "jump", "at", "random", "with", "appropriate", "relative", "probabilities", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/transitions.py#L39-L50
train
63,395
bjmorgan/lattice_mc
lattice_mc/transitions.py
Transitions.time_to_jump
def time_to_jump( self ): """ The timestep until the next jump. Args: None Returns: (Float): The timestep until the next jump. """ k_tot = rate_prefactor * np.sum( self.p ) return -( 1.0 / k_tot ) * math.log( random.random() )
python
def time_to_jump( self ): """ The timestep until the next jump. Args: None Returns: (Float): The timestep until the next jump. """ k_tot = rate_prefactor * np.sum( self.p ) return -( 1.0 / k_tot ) * math.log( random.random() )
[ "def", "time_to_jump", "(", "self", ")", ":", "k_tot", "=", "rate_prefactor", "*", "np", ".", "sum", "(", "self", ".", "p", ")", "return", "-", "(", "1.0", "/", "k_tot", ")", "*", "math", ".", "log", "(", "random", ".", "random", "(", ")", ")" ]
The timestep until the next jump. Args: None Returns: (Float): The timestep until the next jump.
[ "The", "timestep", "until", "the", "next", "jump", "." ]
7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5
https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/transitions.py#L52-L63
train
63,396
futurecolors/django-geoip
django_geoip/base.py
Locator._get_real_ip
def _get_real_ip(self): """ Get IP from request. :param request: A usual request object :type request: HttpRequest :return: ipv4 string or None """ try: # Trying to work with most common proxy headers real_ip = self.request.META['HTTP_X_FO...
python
def _get_real_ip(self): """ Get IP from request. :param request: A usual request object :type request: HttpRequest :return: ipv4 string or None """ try: # Trying to work with most common proxy headers real_ip = self.request.META['HTTP_X_FO...
[ "def", "_get_real_ip", "(", "self", ")", ":", "try", ":", "# Trying to work with most common proxy headers", "real_ip", "=", "self", ".", "request", ".", "META", "[", "'HTTP_X_FORWARDED_FOR'", "]", "return", "real_ip", ".", "split", "(", "','", ")", "[", "0", ...
Get IP from request. :param request: A usual request object :type request: HttpRequest :return: ipv4 string or None
[ "Get", "IP", "from", "request", "." ]
f9eee4bcad40508089b184434b79826f842d7bd0
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/base.py#L55-L71
train
63,397
futurecolors/django-geoip
django_geoip/base.py
Locator._get_ip_range
def _get_ip_range(self): """ Fetches IpRange instance if request IP is found in database. :param request: A ususal request object :type request: HttpRequest :return: IpRange object or None """ ip = self._get_real_ip() try: geobase_entry = IpRa...
python
def _get_ip_range(self): """ Fetches IpRange instance if request IP is found in database. :param request: A ususal request object :type request: HttpRequest :return: IpRange object or None """ ip = self._get_real_ip() try: geobase_entry = IpRa...
[ "def", "_get_ip_range", "(", "self", ")", ":", "ip", "=", "self", ".", "_get_real_ip", "(", ")", "try", ":", "geobase_entry", "=", "IpRange", ".", "objects", ".", "by_ip", "(", "ip", ")", "except", "IpRange", ".", "DoesNotExist", ":", "geobase_entry", "=...
Fetches IpRange instance if request IP is found in database. :param request: A ususal request object :type request: HttpRequest :return: IpRange object or None
[ "Fetches", "IpRange", "instance", "if", "request", "IP", "is", "found", "in", "database", "." ]
f9eee4bcad40508089b184434b79826f842d7bd0
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/base.py#L73-L86
train
63,398
futurecolors/django-geoip
django_geoip/base.py
Locator._get_stored_location
def _get_stored_location(self): """ Get location from cookie. :param request: A ususal request object :type request: HttpRequest :return: Custom location model """ location_storage = storage_class(request=self.request, response=None) return location_storage.get()
python
def _get_stored_location(self): """ Get location from cookie. :param request: A ususal request object :type request: HttpRequest :return: Custom location model """ location_storage = storage_class(request=self.request, response=None) return location_storage.get()
[ "def", "_get_stored_location", "(", "self", ")", ":", "location_storage", "=", "storage_class", "(", "request", "=", "self", ".", "request", ",", "response", "=", "None", ")", "return", "location_storage", ".", "get", "(", ")" ]
Get location from cookie. :param request: A ususal request object :type request: HttpRequest :return: Custom location model
[ "Get", "location", "from", "cookie", "." ]
f9eee4bcad40508089b184434b79826f842d7bd0
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/base.py#L88-L96
train
63,399