id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
46,400 | 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 |
46,401 | 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 |
46,402 | 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 |
46,403 | 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 |
46,404 | 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 |
46,405 | 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 |
46,406 | 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 |
46,407 | 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 |
46,408 | 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 |
46,409 | 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 |
46,410 | 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 |
46,411 | 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 |
46,412 | 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 |
46,413 | 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 |
46,414 | 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 |
46,415 | 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 |
46,416 | 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 |
46,417 | 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 |
46,418 | 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 |
46,419 | 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 |
46,420 | 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 |
46,421 | 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 |
46,422 | 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 |
46,423 | 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 |
46,424 | 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 |
46,425 | 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 |
46,426 | 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 |
46,427 | 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 |
46,428 | 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 |
46,429 | 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 |
46,430 | 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 |
46,431 | 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 |
46,432 | 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 |
46,433 | 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 |
46,434 | 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 |
46,435 | 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 |
46,436 | 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 |
46,437 | 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 |
46,438 | 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 |
46,439 | 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 |
46,440 | 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 |
46,441 | 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 |
46,442 | 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 |
46,443 | 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 |
46,444 | 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 |
46,445 | 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 |
46,446 | 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 |
46,447 | 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 |
46,448 | 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 |
46,449 | 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 |
46,450 | 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 |
46,451 | 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 |
46,452 | 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 |
46,453 | 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 |
46,454 | 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 |
46,455 | 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 |
46,456 | 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 |
46,457 | 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 |
46,458 | 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 |
46,459 | 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 |
46,460 | 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 |
46,461 | 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 |
46,462 | 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 |
46,463 | ryan-roemer/django-cloud-browser | cloud_browser/cloud/rackspace.py | RackspaceExceptionWrapper.lazy_translations | def lazy_translations(cls):
"""Lazy translations."""
return {
cloudfiles.errors.NoSuchContainer: errors.NoContainerException,
cloudfiles.errors.NoSuchObject: errors.NoObjectException,
} | python | def lazy_translations(cls):
"""Lazy translations."""
return {
cloudfiles.errors.NoSuchContainer: errors.NoContainerException,
cloudfiles.errors.NoSuchObject: errors.NoObjectException,
} | [
"def",
"lazy_translations",
"(",
"cls",
")",
":",
"return",
"{",
"cloudfiles",
".",
"errors",
".",
"NoSuchContainer",
":",
"errors",
".",
"NoContainerException",
",",
"cloudfiles",
".",
"errors",
".",
"NoSuchObject",
":",
"errors",
".",
"NoObjectException",
",",... | Lazy translations. | [
"Lazy",
"translations",
"."
] | b06cdd24885a6309e843ed924dbf1705b67e7f48 | https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/rackspace.py#L43-L48 |
46,464 | ryan-roemer/django-cloud-browser | cloud_browser/cloud/rackspace.py | RackspaceObject.from_info | def from_info(cls, container, info_obj):
"""Create from subdirectory or file info object."""
create_fn = cls.from_subdir if 'subdir' in info_obj \
else cls.from_file_info
return create_fn(container, info_obj) | python | def from_info(cls, container, info_obj):
"""Create from subdirectory or file info object."""
create_fn = cls.from_subdir if 'subdir' in info_obj \
else cls.from_file_info
return create_fn(container, info_obj) | [
"def",
"from_info",
"(",
"cls",
",",
"container",
",",
"info_obj",
")",
":",
"create_fn",
"=",
"cls",
".",
"from_subdir",
"if",
"'subdir'",
"in",
"info_obj",
"else",
"cls",
".",
"from_file_info",
"return",
"create_fn",
"(",
"container",
",",
"info_obj",
")"
... | Create from subdirectory or file info object. | [
"Create",
"from",
"subdirectory",
"or",
"file",
"info",
"object",
"."
] | b06cdd24885a6309e843ed924dbf1705b67e7f48 | https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/rackspace.py#L75-L79 |
46,465 | ryan-roemer/django-cloud-browser | cloud_browser/cloud/rackspace.py | RackspaceObject.from_subdir | def from_subdir(cls, container, info_obj):
"""Create from subdirectory info object."""
return cls(container,
info_obj['subdir'],
obj_type=cls.type_cls.SUBDIR) | python | def from_subdir(cls, container, info_obj):
"""Create from subdirectory info object."""
return cls(container,
info_obj['subdir'],
obj_type=cls.type_cls.SUBDIR) | [
"def",
"from_subdir",
"(",
"cls",
",",
"container",
",",
"info_obj",
")",
":",
"return",
"cls",
"(",
"container",
",",
"info_obj",
"[",
"'subdir'",
"]",
",",
"obj_type",
"=",
"cls",
".",
"type_cls",
".",
"SUBDIR",
")"
] | Create from subdirectory info object. | [
"Create",
"from",
"subdirectory",
"info",
"object",
"."
] | b06cdd24885a6309e843ed924dbf1705b67e7f48 | https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/rackspace.py#L82-L86 |
46,466 | ryan-roemer/django-cloud-browser | cloud_browser/cloud/rackspace.py | RackspaceObject.choose_type | def choose_type(cls, content_type):
"""Choose object type from content type."""
return cls.type_cls.SUBDIR if content_type in cls.subdir_types \
else cls.type_cls.FILE | python | def choose_type(cls, content_type):
"""Choose object type from content type."""
return cls.type_cls.SUBDIR if content_type in cls.subdir_types \
else cls.type_cls.FILE | [
"def",
"choose_type",
"(",
"cls",
",",
"content_type",
")",
":",
"return",
"cls",
".",
"type_cls",
".",
"SUBDIR",
"if",
"content_type",
"in",
"cls",
".",
"subdir_types",
"else",
"cls",
".",
"type_cls",
".",
"FILE"
] | Choose object type from content type. | [
"Choose",
"object",
"type",
"from",
"content",
"type",
"."
] | b06cdd24885a6309e843ed924dbf1705b67e7f48 | https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/rackspace.py#L89-L92 |
46,467 | ryan-roemer/django-cloud-browser | cloud_browser/cloud/rackspace.py | RackspaceConnection._get_connection | def _get_connection(self):
"""Return native connection object."""
kwargs = {
'username': self.account,
'api_key': self.secret_key,
}
# Only add kwarg for servicenet if True because user could set
# environment variable 'RACKSPACE_SERVICENET' separately.
... | python | def _get_connection(self):
"""Return native connection object."""
kwargs = {
'username': self.account,
'api_key': self.secret_key,
}
# Only add kwarg for servicenet if True because user could set
# environment variable 'RACKSPACE_SERVICENET' separately.
... | [
"def",
"_get_connection",
"(",
"self",
")",
":",
"kwargs",
"=",
"{",
"'username'",
":",
"self",
".",
"account",
",",
"'api_key'",
":",
"self",
".",
"secret_key",
",",
"}",
"# Only add kwarg for servicenet if True because user could set",
"# environment variable 'RACKSPA... | Return native connection object. | [
"Return",
"native",
"connection",
"object",
"."
] | b06cdd24885a6309e843ed924dbf1705b67e7f48 | https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/rackspace.py#L254-L269 |
46,468 | bjmorgan/lattice_mc | lattice_mc/jump.py | Jump.delta_E | def delta_E( self ):
"""
The change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E
"""
site_delta_E = self.final_site.energy - self.initial_site.energy
if self.nearest_neighbour_energy:
site_... | python | def delta_E( self ):
"""
The change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E
"""
site_delta_E = self.final_site.energy - self.initial_site.energy
if self.nearest_neighbour_energy:
site_... | [
"def",
"delta_E",
"(",
"self",
")",
":",
"site_delta_E",
"=",
"self",
".",
"final_site",
".",
"energy",
"-",
"self",
".",
"initial_site",
".",
"energy",
"if",
"self",
".",
"nearest_neighbour_energy",
":",
"site_delta_E",
"+=",
"self",
".",
"nearest_neighbour_d... | The change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E | [
"The",
"change",
"in",
"system",
"energy",
"if",
"this",
"jump",
"were",
"accepted",
"."
] | 7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5 | https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/jump.py#L62-L77 |
46,469 | bjmorgan/lattice_mc | lattice_mc/jump.py | Jump.nearest_neighbour_delta_E | def nearest_neighbour_delta_E( self ):
"""
Nearest-neighbour interaction contribution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (nearest-neighbour)
"""
delta_nn = self.final_site.nn_occupation... | python | def nearest_neighbour_delta_E( self ):
"""
Nearest-neighbour interaction contribution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (nearest-neighbour)
"""
delta_nn = self.final_site.nn_occupation... | [
"def",
"nearest_neighbour_delta_E",
"(",
"self",
")",
":",
"delta_nn",
"=",
"self",
".",
"final_site",
".",
"nn_occupation",
"(",
")",
"-",
"self",
".",
"initial_site",
".",
"nn_occupation",
"(",
")",
"-",
"1",
"# -1 because the hopping ion is not counted in the fin... | Nearest-neighbour interaction contribution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (nearest-neighbour) | [
"Nearest",
"-",
"neighbour",
"interaction",
"contribution",
"to",
"the",
"change",
"in",
"system",
"energy",
"if",
"this",
"jump",
"were",
"accepted",
"."
] | 7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5 | https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/jump.py#L79-L90 |
46,470 | bjmorgan/lattice_mc | lattice_mc/jump.py | Jump.coordination_number_delta_E | def coordination_number_delta_E( self ):
"""
Coordination-number dependent energy conrtibution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (coordination-number)
"""
initial_site_neighbours = [ s... | python | def coordination_number_delta_E( self ):
"""
Coordination-number dependent energy conrtibution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (coordination-number)
"""
initial_site_neighbours = [ s... | [
"def",
"coordination_number_delta_E",
"(",
"self",
")",
":",
"initial_site_neighbours",
"=",
"[",
"s",
"for",
"s",
"in",
"self",
".",
"initial_site",
".",
"p_neighbours",
"if",
"s",
".",
"is_occupied",
"]",
"# excludes final site, since this is always unoccupied",
"fi... | Coordination-number dependent energy conrtibution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (coordination-number) | [
"Coordination",
"-",
"number",
"dependent",
"energy",
"conrtibution",
"to",
"the",
"change",
"in",
"system",
"energy",
"if",
"this",
"jump",
"were",
"accepted",
"."
] | 7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5 | https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/jump.py#L92-L110 |
46,471 | bjmorgan/lattice_mc | lattice_mc/jump.py | Jump.dr | def dr( self, cell_lengths ):
"""
Particle displacement vector for this jump
Args:
cell_lengths (np.array(x,y,z)): Cell lengths for the orthogonal simulation cell.
Returns
(np.array(x,y,z)): dr
"""
half_cell_lengths = cell_lengths / 2.0
t... | python | def dr( self, cell_lengths ):
"""
Particle displacement vector for this jump
Args:
cell_lengths (np.array(x,y,z)): Cell lengths for the orthogonal simulation cell.
Returns
(np.array(x,y,z)): dr
"""
half_cell_lengths = cell_lengths / 2.0
t... | [
"def",
"dr",
"(",
"self",
",",
"cell_lengths",
")",
":",
"half_cell_lengths",
"=",
"cell_lengths",
"/",
"2.0",
"this_dr",
"=",
"self",
".",
"final_site",
".",
"r",
"-",
"self",
".",
"initial_site",
".",
"r",
"for",
"i",
"in",
"range",
"(",
"3",
")",
... | Particle displacement vector for this jump
Args:
cell_lengths (np.array(x,y,z)): Cell lengths for the orthogonal simulation cell.
Returns
(np.array(x,y,z)): dr | [
"Particle",
"displacement",
"vector",
"for",
"this",
"jump"
] | 7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5 | https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/jump.py#L112-L129 |
46,472 | bjmorgan/lattice_mc | lattice_mc/jump.py | Jump.relative_probability_from_lookup_table | def relative_probability_from_lookup_table( self, jump_lookup_table ):
"""
Relative probability of accepting this jump from a lookup-table.
Args:
jump_lookup_table (LookupTable): the lookup table to be used for this jump.
Returns:
(Float): relative probability o... | python | def relative_probability_from_lookup_table( self, jump_lookup_table ):
"""
Relative probability of accepting this jump from a lookup-table.
Args:
jump_lookup_table (LookupTable): the lookup table to be used for this jump.
Returns:
(Float): relative probability o... | [
"def",
"relative_probability_from_lookup_table",
"(",
"self",
",",
"jump_lookup_table",
")",
":",
"l1",
"=",
"self",
".",
"initial_site",
".",
"label",
"l2",
"=",
"self",
".",
"final_site",
".",
"label",
"c1",
"=",
"self",
".",
"initial_site",
".",
"nn_occupat... | Relative probability of accepting this jump from a lookup-table.
Args:
jump_lookup_table (LookupTable): the lookup table to be used for this jump.
Returns:
(Float): relative probability of accepting this jump. | [
"Relative",
"probability",
"of",
"accepting",
"this",
"jump",
"from",
"a",
"lookup",
"-",
"table",
"."
] | 7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5 | https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/jump.py#L131-L145 |
46,473 | Kitware/tangelo | tangelo/tangelo/util.py | module_cache_get | def module_cache_get(cache, module):
"""
Import a module with an optional yaml config file, but only if we haven't
imported it already.
:param cache: object which holds information on which modules and config
files have been loaded and whether config files should be
... | python | def module_cache_get(cache, module):
"""
Import a module with an optional yaml config file, but only if we haven't
imported it already.
:param cache: object which holds information on which modules and config
files have been loaded and whether config files should be
... | [
"def",
"module_cache_get",
"(",
"cache",
",",
"module",
")",
":",
"if",
"getattr",
"(",
"cache",
",",
"\"config\"",
",",
"False",
")",
":",
"config_file",
"=",
"module",
"[",
":",
"-",
"2",
"]",
"+",
"\"yaml\"",
"if",
"config_file",
"not",
"in",
"cache... | Import a module with an optional yaml config file, but only if we haven't
imported it already.
:param cache: object which holds information on which modules and config
files have been loaded and whether config files should be
loaded.
:param module: the path of the module... | [
"Import",
"a",
"module",
"with",
"an",
"optional",
"yaml",
"config",
"file",
"but",
"only",
"if",
"we",
"haven",
"t",
"imported",
"it",
"already",
"."
] | 470034ee9b3d7a01becc1ce5fddc7adc1d5263ef | https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/util.py#L170-L214 |
46,474 | bihealth/vcfpy | vcfpy/bgzf.py | BgzfWriter.close | def close(self):
"""Flush data, write 28 bytes BGZF EOF marker, and close BGZF file.
samtools will look for a magic EOF marker, just a 28 byte empty BGZF
block, and if it is missing warns the BAM file may be truncated. In
addition to samtools writing this block, so too does bgzip - so th... | python | def close(self):
"""Flush data, write 28 bytes BGZF EOF marker, and close BGZF file.
samtools will look for a magic EOF marker, just a 28 byte empty BGZF
block, and if it is missing warns the BAM file may be truncated. In
addition to samtools writing this block, so too does bgzip - so th... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_buffer",
":",
"self",
".",
"flush",
"(",
")",
"self",
".",
"_handle",
".",
"write",
"(",
"_bgzf_eof",
")",
"self",
".",
"_handle",
".",
"flush",
"(",
")",
"self",
".",
"_handle",
".",
"c... | Flush data, write 28 bytes BGZF EOF marker, and close BGZF file.
samtools will look for a magic EOF marker, just a 28 byte empty BGZF
block, and if it is missing warns the BAM file may be truncated. In
addition to samtools writing this block, so too does bgzip - so this
implementation do... | [
"Flush",
"data",
"write",
"28",
"bytes",
"BGZF",
"EOF",
"marker",
"and",
"close",
"BGZF",
"file",
".",
"samtools",
"will",
"look",
"for",
"a",
"magic",
"EOF",
"marker",
"just",
"a",
"28",
"byte",
"empty",
"BGZF",
"block",
"and",
"if",
"it",
"is",
"miss... | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/bgzf.py#L157-L168 |
46,475 | eraclitux/ipcampy | ipcamweb/utils.py | ensure_secret | def ensure_secret():
"""Check if secret key to encryot sessions exists,
generate it otherwise."""
home_dir = os.environ['HOME']
file_name = home_dir + "/.ipcamweb"
if os.path.exists(file_name):
with open(file_name, "r") as s_file:
secret = s_file.readline()
else:
secr... | python | def ensure_secret():
"""Check if secret key to encryot sessions exists,
generate it otherwise."""
home_dir = os.environ['HOME']
file_name = home_dir + "/.ipcamweb"
if os.path.exists(file_name):
with open(file_name, "r") as s_file:
secret = s_file.readline()
else:
secr... | [
"def",
"ensure_secret",
"(",
")",
":",
"home_dir",
"=",
"os",
".",
"environ",
"[",
"'HOME'",
"]",
"file_name",
"=",
"home_dir",
"+",
"\"/.ipcamweb\"",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"file_name",
")",
":",
"with",
"open",
"(",
"file_name",
... | Check if secret key to encryot sessions exists,
generate it otherwise. | [
"Check",
"if",
"secret",
"key",
"to",
"encryot",
"sessions",
"exists",
"generate",
"it",
"otherwise",
"."
] | bffd1c4df9006705cffa5b83a090b0db90cbcbcf | https://github.com/eraclitux/ipcampy/blob/bffd1c4df9006705cffa5b83a090b0db90cbcbcf/ipcamweb/utils.py#L6-L18 |
46,476 | eraclitux/ipcampy | ipcamweb/utils.py | list_snapshots_for_a_minute | def list_snapshots_for_a_minute(path, cam_id, day, hourm):
"""Returns a list of screenshots"""
screenshoots_path = path+"/"+str(cam_id)+"/"+day+"/"+hourm
if os.path.exists(screenshoots_path):
screenshots = [scr for scr in sorted(os.listdir(screenshoots_path))]
return screenshots
else:
... | python | def list_snapshots_for_a_minute(path, cam_id, day, hourm):
"""Returns a list of screenshots"""
screenshoots_path = path+"/"+str(cam_id)+"/"+day+"/"+hourm
if os.path.exists(screenshoots_path):
screenshots = [scr for scr in sorted(os.listdir(screenshoots_path))]
return screenshots
else:
... | [
"def",
"list_snapshots_for_a_minute",
"(",
"path",
",",
"cam_id",
",",
"day",
",",
"hourm",
")",
":",
"screenshoots_path",
"=",
"path",
"+",
"\"/\"",
"+",
"str",
"(",
"cam_id",
")",
"+",
"\"/\"",
"+",
"day",
"+",
"\"/\"",
"+",
"hourm",
"if",
"os",
".",... | Returns a list of screenshots | [
"Returns",
"a",
"list",
"of",
"screenshots"
] | bffd1c4df9006705cffa5b83a090b0db90cbcbcf | https://github.com/eraclitux/ipcampy/blob/bffd1c4df9006705cffa5b83a090b0db90cbcbcf/ipcamweb/utils.py#L44-L51 |
46,477 | bihealth/vcfpy | vcfpy/record.py | Record.is_snv | def is_snv(self):
"""Return ``True`` if it is a SNV"""
return len(self.REF) == 1 and all(a.type == "SNV" for a in self.ALT) | python | def is_snv(self):
"""Return ``True`` if it is a SNV"""
return len(self.REF) == 1 and all(a.type == "SNV" for a in self.ALT) | [
"def",
"is_snv",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"REF",
")",
"==",
"1",
"and",
"all",
"(",
"a",
".",
"type",
"==",
"\"SNV\"",
"for",
"a",
"in",
"self",
".",
"ALT",
")"
] | Return ``True`` if it is a SNV | [
"Return",
"True",
"if",
"it",
"is",
"a",
"SNV"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L95-L97 |
46,478 | bihealth/vcfpy | vcfpy/record.py | Record.affected_start | def affected_start(self):
"""Return affected start position in 0-based coordinates
For SNVs, MNVs, and deletions, the behaviour is the start position.
In the case of insertions, the position behind the insert position is
returned, yielding a 0-length interval together with
:py:m... | python | def affected_start(self):
"""Return affected start position in 0-based coordinates
For SNVs, MNVs, and deletions, the behaviour is the start position.
In the case of insertions, the position behind the insert position is
returned, yielding a 0-length interval together with
:py:m... | [
"def",
"affected_start",
"(",
"self",
")",
":",
"types",
"=",
"{",
"alt",
".",
"type",
"for",
"alt",
"in",
"self",
".",
"ALT",
"}",
"# set!",
"BAD_MIX",
"=",
"{",
"INS",
",",
"SV",
",",
"BND",
",",
"SYMBOLIC",
"}",
"# don't mix well with others",
"if",... | Return affected start position in 0-based coordinates
For SNVs, MNVs, and deletions, the behaviour is the start position.
In the case of insertions, the position behind the insert position is
returned, yielding a 0-length interval together with
:py:meth:`~Record.affected_end` | [
"Return",
"affected",
"start",
"position",
"in",
"0",
"-",
"based",
"coordinates"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L100-L114 |
46,479 | bihealth/vcfpy | vcfpy/record.py | Record.add_filter | def add_filter(self, label):
"""Add label to FILTER if not set yet, removing ``PASS`` entry if
present
"""
if label not in self.FILTER:
if "PASS" in self.FILTER:
self.FILTER = [f for f in self.FILTER if f != "PASS"]
self.FILTER.append(label) | python | def add_filter(self, label):
"""Add label to FILTER if not set yet, removing ``PASS`` entry if
present
"""
if label not in self.FILTER:
if "PASS" in self.FILTER:
self.FILTER = [f for f in self.FILTER if f != "PASS"]
self.FILTER.append(label) | [
"def",
"add_filter",
"(",
"self",
",",
"label",
")",
":",
"if",
"label",
"not",
"in",
"self",
".",
"FILTER",
":",
"if",
"\"PASS\"",
"in",
"self",
".",
"FILTER",
":",
"self",
".",
"FILTER",
"=",
"[",
"f",
"for",
"f",
"in",
"self",
".",
"FILTER",
"... | Add label to FILTER if not set yet, removing ``PASS`` entry if
present | [
"Add",
"label",
"to",
"FILTER",
"if",
"not",
"set",
"yet",
"removing",
"PASS",
"entry",
"if",
"present"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L133-L140 |
46,480 | bihealth/vcfpy | vcfpy/record.py | Record.add_format | def add_format(self, key, value=None):
"""Add an entry to format
The record's calls ``data[key]`` will be set to ``value`` if not yet
set and value is not ``None``. If key is already in FORMAT then
nothing is done.
"""
if key in self.FORMAT:
return
s... | python | def add_format(self, key, value=None):
"""Add an entry to format
The record's calls ``data[key]`` will be set to ``value`` if not yet
set and value is not ``None``. If key is already in FORMAT then
nothing is done.
"""
if key in self.FORMAT:
return
s... | [
"def",
"add_format",
"(",
"self",
",",
"key",
",",
"value",
"=",
"None",
")",
":",
"if",
"key",
"in",
"self",
".",
"FORMAT",
":",
"return",
"self",
".",
"FORMAT",
".",
"append",
"(",
"key",
")",
"if",
"value",
"is",
"not",
"None",
":",
"for",
"ca... | Add an entry to format
The record's calls ``data[key]`` will be set to ``value`` if not yet
set and value is not ``None``. If key is already in FORMAT then
nothing is done. | [
"Add",
"an",
"entry",
"to",
"format"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L142-L154 |
46,481 | bihealth/vcfpy | vcfpy/record.py | Call.gt_type | def gt_type(self):
"""The type of genotype, returns one of ``HOM_REF``, ``HOM_ALT``, and
``HET``.
"""
if not self.called:
return None # not called
elif all(a == 0 for a in self.gt_alleles):
return HOM_REF
elif len(set(self.gt_alleles)) == 1:
... | python | def gt_type(self):
"""The type of genotype, returns one of ``HOM_REF``, ``HOM_ALT``, and
``HET``.
"""
if not self.called:
return None # not called
elif all(a == 0 for a in self.gt_alleles):
return HOM_REF
elif len(set(self.gt_alleles)) == 1:
... | [
"def",
"gt_type",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"called",
":",
"return",
"None",
"# not called",
"elif",
"all",
"(",
"a",
"==",
"0",
"for",
"a",
"in",
"self",
".",
"gt_alleles",
")",
":",
"return",
"HOM_REF",
"elif",
"len",
"(",
... | The type of genotype, returns one of ``HOM_REF``, ``HOM_ALT``, and
``HET``. | [
"The",
"type",
"of",
"genotype",
"returns",
"one",
"of",
"HOM_REF",
"HOM_ALT",
"and",
"HET",
"."
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L268-L279 |
46,482 | bihealth/vcfpy | vcfpy/record.py | Call.is_filtered | def is_filtered(self, require=None, ignore=None):
"""Return ``True`` for filtered calls
:param iterable ignore: if set, the filters to ignore, make sure to
include 'PASS', when setting, default is ``['PASS']``
:param iterable require: if set, the filters to require for returning
... | python | def is_filtered(self, require=None, ignore=None):
"""Return ``True`` for filtered calls
:param iterable ignore: if set, the filters to ignore, make sure to
include 'PASS', when setting, default is ``['PASS']``
:param iterable require: if set, the filters to require for returning
... | [
"def",
"is_filtered",
"(",
"self",
",",
"require",
"=",
"None",
",",
"ignore",
"=",
"None",
")",
":",
"ignore",
"=",
"ignore",
"or",
"[",
"\"PASS\"",
"]",
"if",
"\"FT\"",
"not",
"in",
"self",
".",
"data",
"or",
"not",
"self",
".",
"data",
"[",
"\"F... | Return ``True`` for filtered calls
:param iterable ignore: if set, the filters to ignore, make sure to
include 'PASS', when setting, default is ``['PASS']``
:param iterable require: if set, the filters to require for returning
``True`` | [
"Return",
"True",
"for",
"filtered",
"calls"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L281-L299 |
46,483 | bihealth/vcfpy | vcfpy/record.py | BreakEnd.serialize | def serialize(self):
"""Return string representation for VCF"""
if self.mate_chrom is None:
remote_tag = "."
else:
if self.within_main_assembly:
mate_chrom = self.mate_chrom
else:
mate_chrom = "<{}>".format(self.mate_chrom)
... | python | def serialize(self):
"""Return string representation for VCF"""
if self.mate_chrom is None:
remote_tag = "."
else:
if self.within_main_assembly:
mate_chrom = self.mate_chrom
else:
mate_chrom = "<{}>".format(self.mate_chrom)
... | [
"def",
"serialize",
"(",
"self",
")",
":",
"if",
"self",
".",
"mate_chrom",
"is",
"None",
":",
"remote_tag",
"=",
"\".\"",
"else",
":",
"if",
"self",
".",
"within_main_assembly",
":",
"mate_chrom",
"=",
"self",
".",
"mate_chrom",
"else",
":",
"mate_chrom",... | Return string representation for VCF | [
"Return",
"string",
"representation",
"for",
"VCF"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L431-L445 |
46,484 | chriso/timeseries | timeseries/time_series.py | TimeSeries.trend_coefficients | def trend_coefficients(self, order=LINEAR):
'''Calculate trend coefficients for the specified order.'''
if not len(self.points):
raise ArithmeticError('Cannot calculate the trend of an empty series')
return LazyImport.numpy().polyfit(self.timestamps, self.values, order) | python | def trend_coefficients(self, order=LINEAR):
'''Calculate trend coefficients for the specified order.'''
if not len(self.points):
raise ArithmeticError('Cannot calculate the trend of an empty series')
return LazyImport.numpy().polyfit(self.timestamps, self.values, order) | [
"def",
"trend_coefficients",
"(",
"self",
",",
"order",
"=",
"LINEAR",
")",
":",
"if",
"not",
"len",
"(",
"self",
".",
"points",
")",
":",
"raise",
"ArithmeticError",
"(",
"'Cannot calculate the trend of an empty series'",
")",
"return",
"LazyImport",
".",
"nump... | Calculate trend coefficients for the specified order. | [
"Calculate",
"trend",
"coefficients",
"for",
"the",
"specified",
"order",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/time_series.py#L62-L66 |
46,485 | chriso/timeseries | timeseries/time_series.py | TimeSeries.moving_average | def moving_average(self, window, method=SIMPLE):
'''Calculate a moving average using the specified method and window'''
if len(self.points) < window:
raise ArithmeticError('Not enough points for moving average')
numpy = LazyImport.numpy()
if method == TimeSeries.SIMPLE:
... | python | def moving_average(self, window, method=SIMPLE):
'''Calculate a moving average using the specified method and window'''
if len(self.points) < window:
raise ArithmeticError('Not enough points for moving average')
numpy = LazyImport.numpy()
if method == TimeSeries.SIMPLE:
... | [
"def",
"moving_average",
"(",
"self",
",",
"window",
",",
"method",
"=",
"SIMPLE",
")",
":",
"if",
"len",
"(",
"self",
".",
"points",
")",
"<",
"window",
":",
"raise",
"ArithmeticError",
"(",
"'Not enough points for moving average'",
")",
"numpy",
"=",
"Lazy... | Calculate a moving average using the specified method and window | [
"Calculate",
"a",
"moving",
"average",
"using",
"the",
"specified",
"method",
"and",
"window"
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/time_series.py#L68-L77 |
46,486 | chriso/timeseries | timeseries/time_series.py | TimeSeries.forecast | def forecast(self, horizon, method=ARIMA, frequency=None):
'''Forecast points beyond the time series range using the specified
forecasting method. `horizon` is the number of points to forecast.'''
if len(self.points) <= 1:
raise ArithmeticError('Cannot run forecast when len(series) <... | python | def forecast(self, horizon, method=ARIMA, frequency=None):
'''Forecast points beyond the time series range using the specified
forecasting method. `horizon` is the number of points to forecast.'''
if len(self.points) <= 1:
raise ArithmeticError('Cannot run forecast when len(series) <... | [
"def",
"forecast",
"(",
"self",
",",
"horizon",
",",
"method",
"=",
"ARIMA",
",",
"frequency",
"=",
"None",
")",
":",
"if",
"len",
"(",
"self",
".",
"points",
")",
"<=",
"1",
":",
"raise",
"ArithmeticError",
"(",
"'Cannot run forecast when len(series) <= 1'"... | Forecast points beyond the time series range using the specified
forecasting method. `horizon` is the number of points to forecast. | [
"Forecast",
"points",
"beyond",
"the",
"time",
"series",
"range",
"using",
"the",
"specified",
"forecasting",
"method",
".",
"horizon",
"is",
"the",
"number",
"of",
"points",
"to",
"forecast",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/time_series.py#L79-L99 |
46,487 | chriso/timeseries | timeseries/time_series.py | TimeSeries.decompose | def decompose(self, frequency, window=None, periodic=False):
'''Use STL to decompose the time series into seasonal, trend, and
residual components.'''
R = LazyImport.rpy2()
if periodic:
window = 'periodic'
elif window is None:
window = frequency
ti... | python | def decompose(self, frequency, window=None, periodic=False):
'''Use STL to decompose the time series into seasonal, trend, and
residual components.'''
R = LazyImport.rpy2()
if periodic:
window = 'periodic'
elif window is None:
window = frequency
ti... | [
"def",
"decompose",
"(",
"self",
",",
"frequency",
",",
"window",
"=",
"None",
",",
"periodic",
"=",
"False",
")",
":",
"R",
"=",
"LazyImport",
".",
"rpy2",
"(",
")",
"if",
"periodic",
":",
"window",
"=",
"'periodic'",
"elif",
"window",
"is",
"None",
... | Use STL to decompose the time series into seasonal, trend, and
residual components. | [
"Use",
"STL",
"to",
"decompose",
"the",
"time",
"series",
"into",
"seasonal",
"trend",
"and",
"residual",
"components",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/time_series.py#L101-L122 |
46,488 | chriso/timeseries | timeseries/time_series.py | TimeSeries.plot | def plot(self, label=None, colour='g', style='-'): # pragma: no cover
'''Plot the time series.'''
pylab = LazyImport.pylab()
pylab.plot(self.dates, self.values, '%s%s' % (colour, style), label=label)
if label is not None:
pylab.legend()
pylab.show() | python | def plot(self, label=None, colour='g', style='-'): # pragma: no cover
'''Plot the time series.'''
pylab = LazyImport.pylab()
pylab.plot(self.dates, self.values, '%s%s' % (colour, style), label=label)
if label is not None:
pylab.legend()
pylab.show() | [
"def",
"plot",
"(",
"self",
",",
"label",
"=",
"None",
",",
"colour",
"=",
"'g'",
",",
"style",
"=",
"'-'",
")",
":",
"# pragma: no cover",
"pylab",
"=",
"LazyImport",
".",
"pylab",
"(",
")",
"pylab",
".",
"plot",
"(",
"self",
".",
"dates",
",",
"s... | Plot the time series. | [
"Plot",
"the",
"time",
"series",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/time_series.py#L124-L130 |
46,489 | chriso/timeseries | timeseries/utilities.py | table_output | def table_output(data):
'''Get a table representation of a dictionary.'''
if type(data) == DictType:
data = data.items()
headings = [ item[0] for item in data ]
rows = [ item[1] for item in data ]
columns = zip(*rows)
if len(columns):
widths = [ max([ len(str(y)) for y in row ]) ... | python | def table_output(data):
'''Get a table representation of a dictionary.'''
if type(data) == DictType:
data = data.items()
headings = [ item[0] for item in data ]
rows = [ item[1] for item in data ]
columns = zip(*rows)
if len(columns):
widths = [ max([ len(str(y)) for y in row ]) ... | [
"def",
"table_output",
"(",
"data",
")",
":",
"if",
"type",
"(",
"data",
")",
"==",
"DictType",
":",
"data",
"=",
"data",
".",
"items",
"(",
")",
"headings",
"=",
"[",
"item",
"[",
"0",
"]",
"for",
"item",
"in",
"data",
"]",
"rows",
"=",
"[",
"... | Get a table representation of a dictionary. | [
"Get",
"a",
"table",
"representation",
"of",
"a",
"dictionary",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/utilities.py#L4-L22 |
46,490 | chriso/timeseries | timeseries/utilities.py | to_datetime | def to_datetime(time):
'''Convert `time` to a datetime.'''
if type(time) == IntType or type(time) == LongType:
time = datetime.fromtimestamp(time // 1000)
return time | python | def to_datetime(time):
'''Convert `time` to a datetime.'''
if type(time) == IntType or type(time) == LongType:
time = datetime.fromtimestamp(time // 1000)
return time | [
"def",
"to_datetime",
"(",
"time",
")",
":",
"if",
"type",
"(",
"time",
")",
"==",
"IntType",
"or",
"type",
"(",
"time",
")",
"==",
"LongType",
":",
"time",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"time",
"//",
"1000",
")",
"return",
"time"
] | Convert `time` to a datetime. | [
"Convert",
"time",
"to",
"a",
"datetime",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/utilities.py#L24-L28 |
46,491 | timmahrt/pysle | pysle/praattools.py | spellCheckTextgrid | def spellCheckTextgrid(tg, targetTierName, newTierName, isleDict,
printEntries=False):
'''
Spell check words by using the praatio spellcheck function
Incorrect items are noted in a new tier and optionally
printed to the screen
'''
def checkFunc(word):
... | python | def spellCheckTextgrid(tg, targetTierName, newTierName, isleDict,
printEntries=False):
'''
Spell check words by using the praatio spellcheck function
Incorrect items are noted in a new tier and optionally
printed to the screen
'''
def checkFunc(word):
... | [
"def",
"spellCheckTextgrid",
"(",
"tg",
",",
"targetTierName",
",",
"newTierName",
",",
"isleDict",
",",
"printEntries",
"=",
"False",
")",
":",
"def",
"checkFunc",
"(",
"word",
")",
":",
"try",
":",
"isleDict",
".",
"lookup",
"(",
"word",
")",
"except",
... | Spell check words by using the praatio spellcheck function
Incorrect items are noted in a new tier and optionally
printed to the screen | [
"Spell",
"check",
"words",
"by",
"using",
"the",
"praatio",
"spellcheck",
"function",
"Incorrect",
"items",
"are",
"noted",
"in",
"a",
"new",
"tier",
"and",
"optionally",
"printed",
"to",
"the",
"screen"
] | da7c3d9ebdc01647be845f442b6f072a854eba3b | https://github.com/timmahrt/pysle/blob/da7c3d9ebdc01647be845f442b6f072a854eba3b/pysle/praattools.py#L24-L46 |
46,492 | bihealth/vcfpy | vcfpy/parser.py | split_mapping | def split_mapping(pair_str):
"""Split the ``str`` in ``pair_str`` at ``'='``
Warn if key needs to be stripped
"""
orig_key, value = pair_str.split("=", 1)
key = orig_key.strip()
if key != orig_key:
warnings.warn(
"Mapping key {} has leading or trailing space".format(repr(ori... | python | def split_mapping(pair_str):
"""Split the ``str`` in ``pair_str`` at ``'='``
Warn if key needs to be stripped
"""
orig_key, value = pair_str.split("=", 1)
key = orig_key.strip()
if key != orig_key:
warnings.warn(
"Mapping key {} has leading or trailing space".format(repr(ori... | [
"def",
"split_mapping",
"(",
"pair_str",
")",
":",
"orig_key",
",",
"value",
"=",
"pair_str",
".",
"split",
"(",
"\"=\"",
",",
"1",
")",
"key",
"=",
"orig_key",
".",
"strip",
"(",
")",
"if",
"key",
"!=",
"orig_key",
":",
"warnings",
".",
"warn",
"(",... | Split the ``str`` in ``pair_str`` at ``'='``
Warn if key needs to be stripped | [
"Split",
"the",
"str",
"in",
"pair_str",
"at",
"="
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L128-L140 |
46,493 | bihealth/vcfpy | vcfpy/parser.py | parse_mapping | def parse_mapping(value):
"""Parse the given VCF header line mapping
Such a mapping consists of "key=value" pairs, separated by commas and
wrapped into angular brackets ("<...>"). Strings are usually quoted,
for certain known keys, exceptions are made, depending on the tag key.
this, however, only... | python | def parse_mapping(value):
"""Parse the given VCF header line mapping
Such a mapping consists of "key=value" pairs, separated by commas and
wrapped into angular brackets ("<...>"). Strings are usually quoted,
for certain known keys, exceptions are made, depending on the tag key.
this, however, only... | [
"def",
"parse_mapping",
"(",
"value",
")",
":",
"if",
"not",
"value",
".",
"startswith",
"(",
"\"<\"",
")",
"or",
"not",
"value",
".",
"endswith",
"(",
"\">\"",
")",
":",
"raise",
"exceptions",
".",
"InvalidHeaderException",
"(",
"\"Header mapping value was no... | Parse the given VCF header line mapping
Such a mapping consists of "key=value" pairs, separated by commas and
wrapped into angular brackets ("<...>"). Strings are usually quoted,
for certain known keys, exceptions are made, depending on the tag key.
this, however, only gets important when serializing.... | [
"Parse",
"the",
"given",
"VCF",
"header",
"line",
"mapping"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L143-L174 |
46,494 | bihealth/vcfpy | vcfpy/parser.py | build_header_parsers | def build_header_parsers():
"""Return mapping for parsers to use for each VCF header type
Inject the WarningHelper into the parsers.
"""
result = {
"ALT": MappingHeaderLineParser(header.AltAlleleHeaderLine),
"contig": MappingHeaderLineParser(header.ContigHeaderLine),
"FILTER": M... | python | def build_header_parsers():
"""Return mapping for parsers to use for each VCF header type
Inject the WarningHelper into the parsers.
"""
result = {
"ALT": MappingHeaderLineParser(header.AltAlleleHeaderLine),
"contig": MappingHeaderLineParser(header.ContigHeaderLine),
"FILTER": M... | [
"def",
"build_header_parsers",
"(",
")",
":",
"result",
"=",
"{",
"\"ALT\"",
":",
"MappingHeaderLineParser",
"(",
"header",
".",
"AltAlleleHeaderLine",
")",
",",
"\"contig\"",
":",
"MappingHeaderLineParser",
"(",
"header",
".",
"ContigHeaderLine",
")",
",",
"\"FIL... | Return mapping for parsers to use for each VCF header type
Inject the WarningHelper into the parsers. | [
"Return",
"mapping",
"for",
"parsers",
"to",
"use",
"for",
"each",
"VCF",
"header",
"type"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L209-L225 |
46,495 | bihealth/vcfpy | vcfpy/parser.py | convert_field_value | def convert_field_value(type_, value):
"""Convert atomic field value according to the type"""
if value == ".":
return None
elif type_ in ("Character", "String"):
if "%" in value:
for k, v in record.UNESCAPE_MAPPING:
value = value.replace(k, v)
return value... | python | def convert_field_value(type_, value):
"""Convert atomic field value according to the type"""
if value == ".":
return None
elif type_ in ("Character", "String"):
if "%" in value:
for k, v in record.UNESCAPE_MAPPING:
value = value.replace(k, v)
return value... | [
"def",
"convert_field_value",
"(",
"type_",
",",
"value",
")",
":",
"if",
"value",
"==",
"\".\"",
":",
"return",
"None",
"elif",
"type_",
"in",
"(",
"\"Character\"",
",",
"\"String\"",
")",
":",
"if",
"\"%\"",
"in",
"value",
":",
"for",
"k",
",",
"v",
... | Convert atomic field value according to the type | [
"Convert",
"atomic",
"field",
"value",
"according",
"to",
"the",
"type"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L238-L255 |
46,496 | bihealth/vcfpy | vcfpy/parser.py | parse_field_value | def parse_field_value(field_info, value):
"""Parse ``value`` according to ``field_info``
"""
if field_info.id == "FT":
return [x for x in value.split(";") if x != "."]
elif field_info.type == "Flag":
return True
elif field_info.number == 1:
return convert_field_value(field_in... | python | def parse_field_value(field_info, value):
"""Parse ``value`` according to ``field_info``
"""
if field_info.id == "FT":
return [x for x in value.split(";") if x != "."]
elif field_info.type == "Flag":
return True
elif field_info.number == 1:
return convert_field_value(field_in... | [
"def",
"parse_field_value",
"(",
"field_info",
",",
"value",
")",
":",
"if",
"field_info",
".",
"id",
"==",
"\"FT\"",
":",
"return",
"[",
"x",
"for",
"x",
"in",
"value",
".",
"split",
"(",
"\";\"",
")",
"if",
"x",
"!=",
"\".\"",
"]",
"elif",
"field_i... | Parse ``value`` according to ``field_info`` | [
"Parse",
"value",
"according",
"to",
"field_info"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L258-L271 |
46,497 | bihealth/vcfpy | vcfpy/parser.py | parse_breakend | def parse_breakend(alt_str):
"""Parse breakend and return tuple with results, parameters for BreakEnd
constructor
"""
arr = BREAKEND_PATTERN.split(alt_str)
mate_chrom, mate_pos = arr[1].split(":", 1)
mate_pos = int(mate_pos)
if mate_chrom[0] == "<":
mate_chrom = mate_chrom[1:-1]
... | python | def parse_breakend(alt_str):
"""Parse breakend and return tuple with results, parameters for BreakEnd
constructor
"""
arr = BREAKEND_PATTERN.split(alt_str)
mate_chrom, mate_pos = arr[1].split(":", 1)
mate_pos = int(mate_pos)
if mate_chrom[0] == "<":
mate_chrom = mate_chrom[1:-1]
... | [
"def",
"parse_breakend",
"(",
"alt_str",
")",
":",
"arr",
"=",
"BREAKEND_PATTERN",
".",
"split",
"(",
"alt_str",
")",
"mate_chrom",
",",
"mate_pos",
"=",
"arr",
"[",
"1",
"]",
".",
"split",
"(",
"\":\"",
",",
"1",
")",
"mate_pos",
"=",
"int",
"(",
"m... | Parse breakend and return tuple with results, parameters for BreakEnd
constructor | [
"Parse",
"breakend",
"and",
"return",
"tuple",
"with",
"results",
"parameters",
"for",
"BreakEnd",
"constructor"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L278-L297 |
46,498 | bihealth/vcfpy | vcfpy/parser.py | process_sub_grow | def process_sub_grow(ref, alt_str):
"""Process substution where the string grows"""
if len(alt_str) == 0:
raise exceptions.InvalidRecordException("Invalid VCF, empty ALT")
elif len(alt_str) == 1:
if ref[0] == alt_str[0]:
return record.Substitution(record.DEL, alt_str)
els... | python | def process_sub_grow(ref, alt_str):
"""Process substution where the string grows"""
if len(alt_str) == 0:
raise exceptions.InvalidRecordException("Invalid VCF, empty ALT")
elif len(alt_str) == 1:
if ref[0] == alt_str[0]:
return record.Substitution(record.DEL, alt_str)
els... | [
"def",
"process_sub_grow",
"(",
"ref",
",",
"alt_str",
")",
":",
"if",
"len",
"(",
"alt_str",
")",
"==",
"0",
":",
"raise",
"exceptions",
".",
"InvalidRecordException",
"(",
"\"Invalid VCF, empty ALT\"",
")",
"elif",
"len",
"(",
"alt_str",
")",
"==",
"1",
... | Process substution where the string grows | [
"Process",
"substution",
"where",
"the",
"string",
"grows"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L300-L310 |
46,499 | bihealth/vcfpy | vcfpy/parser.py | process_sub_shrink | def process_sub_shrink(ref, alt_str):
"""Process substution where the string shrink"""
if len(ref) == 0:
raise exceptions.InvalidRecordException("Invalid VCF, empty REF")
elif len(ref) == 1:
if ref[0] == alt_str[0]:
return record.Substitution(record.INS, alt_str)
else:
... | python | def process_sub_shrink(ref, alt_str):
"""Process substution where the string shrink"""
if len(ref) == 0:
raise exceptions.InvalidRecordException("Invalid VCF, empty REF")
elif len(ref) == 1:
if ref[0] == alt_str[0]:
return record.Substitution(record.INS, alt_str)
else:
... | [
"def",
"process_sub_shrink",
"(",
"ref",
",",
"alt_str",
")",
":",
"if",
"len",
"(",
"ref",
")",
"==",
"0",
":",
"raise",
"exceptions",
".",
"InvalidRecordException",
"(",
"\"Invalid VCF, empty REF\"",
")",
"elif",
"len",
"(",
"ref",
")",
"==",
"1",
":",
... | Process substution where the string shrink | [
"Process",
"substution",
"where",
"the",
"string",
"shrink"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L313-L323 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.