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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
44,100 | romansalin/django-seo2 | djangoseo/admin.py | MetadataFormset._construct_form | def _construct_form(self, i, **kwargs):
"""Override the method to change the form attribute empty_permitted."""
form = super(MetadataFormset, self)._construct_form(i, **kwargs)
# Monkey patch the form to always force a save.
# It's unfortunate, but necessary because we always want an ins... | python | def _construct_form(self, i, **kwargs):
"""Override the method to change the form attribute empty_permitted."""
form = super(MetadataFormset, self)._construct_form(i, **kwargs)
# Monkey patch the form to always force a save.
# It's unfortunate, but necessary because we always want an ins... | [
"def",
"_construct_form",
"(",
"self",
",",
"i",
",",
"*",
"*",
"kwargs",
")",
":",
"form",
"=",
"super",
"(",
"MetadataFormset",
",",
"self",
")",
".",
"_construct_form",
"(",
"i",
",",
"*",
"*",
"kwargs",
")",
"# Monkey patch the form to always force a sav... | Override the method to change the form attribute empty_permitted. | [
"Override",
"the",
"method",
"to",
"change",
"the",
"form",
"attribute",
"empty_permitted",
"."
] | f788699a88e286ab9a698759d9b42f57852865d8 | https://github.com/romansalin/django-seo2/blob/f788699a88e286ab9a698759d9b42f57852865d8/djangoseo/admin.py#L136-L152 |
44,101 | romansalin/django-seo2 | djangoseo/base.py | _get_metadata_model | def _get_metadata_model(name=None):
"""Find registered Metadata object."""
if name is not None:
try:
return registry[name]
except KeyError:
if len(registry) == 1:
valid_names = 'Try using the name "%s" or simply leaving it '\
... | python | def _get_metadata_model(name=None):
"""Find registered Metadata object."""
if name is not None:
try:
return registry[name]
except KeyError:
if len(registry) == 1:
valid_names = 'Try using the name "%s" or simply leaving it '\
... | [
"def",
"_get_metadata_model",
"(",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"not",
"None",
":",
"try",
":",
"return",
"registry",
"[",
"name",
"]",
"except",
"KeyError",
":",
"if",
"len",
"(",
"registry",
")",
"==",
"1",
":",
"valid_names",
... | Find registered Metadata object. | [
"Find",
"registered",
"Metadata",
"object",
"."
] | f788699a88e286ab9a698759d9b42f57852865d8 | https://github.com/romansalin/django-seo2/blob/f788699a88e286ab9a698759d9b42f57852865d8/djangoseo/base.py#L267-L286 |
44,102 | romansalin/django-seo2 | djangoseo/backends.py | MetadataBaseModel._resolve_value | def _resolve_value(self, name):
""" Returns an appropriate value for the given name. """
name = str(name)
if name in self._metadata._meta.elements:
element = self._metadata._meta.elements[name]
# Look in instances for an explicit value
if element.editable:
... | python | def _resolve_value(self, name):
""" Returns an appropriate value for the given name. """
name = str(name)
if name in self._metadata._meta.elements:
element = self._metadata._meta.elements[name]
# Look in instances for an explicit value
if element.editable:
... | [
"def",
"_resolve_value",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"str",
"(",
"name",
")",
"if",
"name",
"in",
"self",
".",
"_metadata",
".",
"_meta",
".",
"elements",
":",
"element",
"=",
"self",
".",
"_metadata",
".",
"_meta",
".",
"element... | Returns an appropriate value for the given name. | [
"Returns",
"an",
"appropriate",
"value",
"for",
"the",
"given",
"name",
"."
] | f788699a88e286ab9a698759d9b42f57852865d8 | https://github.com/romansalin/django-seo2/blob/f788699a88e286ab9a698759d9b42f57852865d8/djangoseo/backends.py#L37-L69 |
44,103 | umap-project/django-leaflet-storage | leaflet_storage/views.py | _urls_for_js | def _urls_for_js(urls=None):
"""
Return templated URLs prepared for javascript.
"""
if urls is None:
# prevent circular import
from .urls import urlpatterns
urls = [url.name for url in urlpatterns if getattr(url, 'name', None)]
urls = dict(zip(urls, [get_uri_template(url) for... | python | def _urls_for_js(urls=None):
"""
Return templated URLs prepared for javascript.
"""
if urls is None:
# prevent circular import
from .urls import urlpatterns
urls = [url.name for url in urlpatterns if getattr(url, 'name', None)]
urls = dict(zip(urls, [get_uri_template(url) for... | [
"def",
"_urls_for_js",
"(",
"urls",
"=",
"None",
")",
":",
"if",
"urls",
"is",
"None",
":",
"# prevent circular import",
"from",
".",
"urls",
"import",
"urlpatterns",
"urls",
"=",
"[",
"url",
".",
"name",
"for",
"url",
"in",
"urlpatterns",
"if",
"getattr",... | Return templated URLs prepared for javascript. | [
"Return",
"templated",
"URLs",
"prepared",
"for",
"javascript",
"."
] | c81972e524b1e09ffca355bfb7edfdede42dcc59 | https://github.com/umap-project/django-leaflet-storage/blob/c81972e524b1e09ffca355bfb7edfdede42dcc59/leaflet_storage/views.py#L43-L53 |
44,104 | umap-project/django-leaflet-storage | leaflet_storage/utils.py | decorated_patterns | def decorated_patterns(func, *urls):
"""
Utility function to decorate a group of url in urls.py
Taken from http://djangosnippets.org/snippets/532/ + comments
See also http://friendpaste.com/6afByRiBB9CMwPft3a6lym
Example:
urlpatterns = [
url(r'^language/(?P<lang_code>[a-z]+)$', views.M... | python | def decorated_patterns(func, *urls):
"""
Utility function to decorate a group of url in urls.py
Taken from http://djangosnippets.org/snippets/532/ + comments
See also http://friendpaste.com/6afByRiBB9CMwPft3a6lym
Example:
urlpatterns = [
url(r'^language/(?P<lang_code>[a-z]+)$', views.M... | [
"def",
"decorated_patterns",
"(",
"func",
",",
"*",
"urls",
")",
":",
"def",
"decorate",
"(",
"urls",
",",
"func",
")",
":",
"for",
"url",
"in",
"urls",
":",
"if",
"isinstance",
"(",
"url",
",",
"RegexURLPattern",
")",
":",
"url",
".",
"__class__",
"... | Utility function to decorate a group of url in urls.py
Taken from http://djangosnippets.org/snippets/532/ + comments
See also http://friendpaste.com/6afByRiBB9CMwPft3a6lym
Example:
urlpatterns = [
url(r'^language/(?P<lang_code>[a-z]+)$', views.MyView, name='name'),
] + decorated_patterns(l... | [
"Utility",
"function",
"to",
"decorate",
"a",
"group",
"of",
"url",
"in",
"urls",
".",
"py"
] | c81972e524b1e09ffca355bfb7edfdede42dcc59 | https://github.com/umap-project/django-leaflet-storage/blob/c81972e524b1e09ffca355bfb7edfdede42dcc59/leaflet_storage/utils.py#L72-L105 |
44,105 | willseward/django-custom-field | custom_field/custom_field.py | CustomFieldModel.get_custom_fields | def get_custom_fields(self):
""" Return a list of custom fields for this model """
return CustomField.objects.filter(
content_type=ContentType.objects.get_for_model(self)) | python | def get_custom_fields(self):
""" Return a list of custom fields for this model """
return CustomField.objects.filter(
content_type=ContentType.objects.get_for_model(self)) | [
"def",
"get_custom_fields",
"(",
"self",
")",
":",
"return",
"CustomField",
".",
"objects",
".",
"filter",
"(",
"content_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"self",
")",
")"
] | Return a list of custom fields for this model | [
"Return",
"a",
"list",
"of",
"custom",
"fields",
"for",
"this",
"model"
] | d42a620a53a69e53902ece77bfbdad27485f3ef1 | https://github.com/willseward/django-custom-field/blob/d42a620a53a69e53902ece77bfbdad27485f3ef1/custom_field/custom_field.py#L21-L24 |
44,106 | willseward/django-custom-field | custom_field/custom_field.py | CustomFieldModel.get_custom_field | def get_custom_field(self, field_name):
""" Get a custom field object for this model
field_name - Name of the custom field you want.
"""
content_type = ContentType.objects.get_for_model(self)
return CustomField.objects.get(
content_type=content_type, name=field_name) | python | def get_custom_field(self, field_name):
""" Get a custom field object for this model
field_name - Name of the custom field you want.
"""
content_type = ContentType.objects.get_for_model(self)
return CustomField.objects.get(
content_type=content_type, name=field_name) | [
"def",
"get_custom_field",
"(",
"self",
",",
"field_name",
")",
":",
"content_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"self",
")",
"return",
"CustomField",
".",
"objects",
".",
"get",
"(",
"content_type",
"=",
"content_type",
",",... | Get a custom field object for this model
field_name - Name of the custom field you want. | [
"Get",
"a",
"custom",
"field",
"object",
"for",
"this",
"model",
"field_name",
"-",
"Name",
"of",
"the",
"custom",
"field",
"you",
"want",
"."
] | d42a620a53a69e53902ece77bfbdad27485f3ef1 | https://github.com/willseward/django-custom-field/blob/d42a620a53a69e53902ece77bfbdad27485f3ef1/custom_field/custom_field.py#L34-L40 |
44,107 | willseward/django-custom-field | custom_field/custom_field.py | CustomFieldModel.get_custom_value | def get_custom_value(self, field_name):
""" Get a value for a specified custom field
field_name - Name of the custom field you want.
"""
custom_field = self.get_custom_field(field_name)
return CustomFieldValue.objects.get_or_create(
field=custom_field, object_id=self.... | python | def get_custom_value(self, field_name):
""" Get a value for a specified custom field
field_name - Name of the custom field you want.
"""
custom_field = self.get_custom_field(field_name)
return CustomFieldValue.objects.get_or_create(
field=custom_field, object_id=self.... | [
"def",
"get_custom_value",
"(",
"self",
",",
"field_name",
")",
":",
"custom_field",
"=",
"self",
".",
"get_custom_field",
"(",
"field_name",
")",
"return",
"CustomFieldValue",
".",
"objects",
".",
"get_or_create",
"(",
"field",
"=",
"custom_field",
",",
"object... | Get a value for a specified custom field
field_name - Name of the custom field you want. | [
"Get",
"a",
"value",
"for",
"a",
"specified",
"custom",
"field",
"field_name",
"-",
"Name",
"of",
"the",
"custom",
"field",
"you",
"want",
"."
] | d42a620a53a69e53902ece77bfbdad27485f3ef1 | https://github.com/willseward/django-custom-field/blob/d42a620a53a69e53902ece77bfbdad27485f3ef1/custom_field/custom_field.py#L42-L48 |
44,108 | willseward/django-custom-field | custom_field/custom_field.py | CustomFieldModel.set_custom_value | def set_custom_value(self, field_name, value):
""" Set a value for a specified custom field
field_name - Name of the custom field you want.
value - Value to set it to
"""
custom_field = self.get_custom_field(field_name)
custom_value = CustomFieldValue.objects.get_or_creat... | python | def set_custom_value(self, field_name, value):
""" Set a value for a specified custom field
field_name - Name of the custom field you want.
value - Value to set it to
"""
custom_field = self.get_custom_field(field_name)
custom_value = CustomFieldValue.objects.get_or_creat... | [
"def",
"set_custom_value",
"(",
"self",
",",
"field_name",
",",
"value",
")",
":",
"custom_field",
"=",
"self",
".",
"get_custom_field",
"(",
"field_name",
")",
"custom_value",
"=",
"CustomFieldValue",
".",
"objects",
".",
"get_or_create",
"(",
"field",
"=",
"... | Set a value for a specified custom field
field_name - Name of the custom field you want.
value - Value to set it to | [
"Set",
"a",
"value",
"for",
"a",
"specified",
"custom",
"field",
"field_name",
"-",
"Name",
"of",
"the",
"custom",
"field",
"you",
"want",
".",
"value",
"-",
"Value",
"to",
"set",
"it",
"to"
] | d42a620a53a69e53902ece77bfbdad27485f3ef1 | https://github.com/willseward/django-custom-field/blob/d42a620a53a69e53902ece77bfbdad27485f3ef1/custom_field/custom_field.py#L50-L59 |
44,109 | exhuma/python-cluster | cluster/method/kmeans.py | KMeansClustering.assign_item | def assign_item(self, item, origin):
"""
Assigns an item from a given cluster to the closest located cluster.
:param item: the item to be moved.
:param origin: the originating cluster.
"""
closest_cluster = origin
for cluster in self.__clusters:
if se... | python | def assign_item(self, item, origin):
"""
Assigns an item from a given cluster to the closest located cluster.
:param item: the item to be moved.
:param origin: the originating cluster.
"""
closest_cluster = origin
for cluster in self.__clusters:
if se... | [
"def",
"assign_item",
"(",
"self",
",",
"item",
",",
"origin",
")",
":",
"closest_cluster",
"=",
"origin",
"for",
"cluster",
"in",
"self",
".",
"__clusters",
":",
"if",
"self",
".",
"distance",
"(",
"item",
",",
"centroid",
"(",
"cluster",
")",
")",
"<... | Assigns an item from a given cluster to the closest located cluster.
:param item: the item to be moved.
:param origin: the originating cluster. | [
"Assigns",
"an",
"item",
"from",
"a",
"given",
"cluster",
"to",
"the",
"closest",
"located",
"cluster",
"."
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/method/kmeans.py#L113-L130 |
44,110 | exhuma/python-cluster | cluster/method/kmeans.py | KMeansClustering.move_item | def move_item(self, item, origin, destination):
"""
Moves an item from one cluster to anoter cluster.
:param item: the item to be moved.
:param origin: the originating cluster.
:param destination: the target cluster.
"""
if self.equality:
item_index =... | python | def move_item(self, item, origin, destination):
"""
Moves an item from one cluster to anoter cluster.
:param item: the item to be moved.
:param origin: the originating cluster.
:param destination: the target cluster.
"""
if self.equality:
item_index =... | [
"def",
"move_item",
"(",
"self",
",",
"item",
",",
"origin",
",",
"destination",
")",
":",
"if",
"self",
".",
"equality",
":",
"item_index",
"=",
"0",
"for",
"i",
",",
"element",
"in",
"enumerate",
"(",
"origin",
")",
":",
"if",
"self",
".",
"equalit... | Moves an item from one cluster to anoter cluster.
:param item: the item to be moved.
:param origin: the originating cluster.
:param destination: the target cluster. | [
"Moves",
"an",
"item",
"from",
"one",
"cluster",
"to",
"anoter",
"cluster",
"."
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/method/kmeans.py#L132-L149 |
44,111 | exhuma/python-cluster | cluster/method/kmeans.py | KMeansClustering.initialise_clusters | def initialise_clusters(self, input_, clustercount):
"""
Initialises the clusters by distributing the items from the data.
evenly across n clusters
:param input_: the data set (a list of tuples).
:param clustercount: the amount of clusters (n).
"""
# initialise t... | python | def initialise_clusters(self, input_, clustercount):
"""
Initialises the clusters by distributing the items from the data.
evenly across n clusters
:param input_: the data set (a list of tuples).
:param clustercount: the amount of clusters (n).
"""
# initialise t... | [
"def",
"initialise_clusters",
"(",
"self",
",",
"input_",
",",
"clustercount",
")",
":",
"# initialise the clusters with empty lists",
"self",
".",
"__clusters",
"=",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"clustercount",
")",
":",
"self",
".",
"__clusters",
... | Initialises the clusters by distributing the items from the data.
evenly across n clusters
:param input_: the data set (a list of tuples).
:param clustercount: the amount of clusters (n). | [
"Initialises",
"the",
"clusters",
"by",
"distributing",
"the",
"items",
"from",
"the",
"data",
".",
"evenly",
"across",
"n",
"clusters"
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/method/kmeans.py#L151-L168 |
44,112 | exhuma/python-cluster | cluster/method/hierarchical.py | HierarchicalClustering.publish_progress | def publish_progress(self, total, current):
"""
If a progress function was supplied, this will call that function with
the total number of elements, and the remaining number of elements.
:param total: The total number of elements.
:param remaining: The remaining number of elemen... | python | def publish_progress(self, total, current):
"""
If a progress function was supplied, this will call that function with
the total number of elements, and the remaining number of elements.
:param total: The total number of elements.
:param remaining: The remaining number of elemen... | [
"def",
"publish_progress",
"(",
"self",
",",
"total",
",",
"current",
")",
":",
"if",
"self",
".",
"progress_callback",
":",
"self",
".",
"progress_callback",
"(",
"total",
",",
"current",
")"
] | If a progress function was supplied, this will call that function with
the total number of elements, and the remaining number of elements.
:param total: The total number of elements.
:param remaining: The remaining number of elements. | [
"If",
"a",
"progress",
"function",
"was",
"supplied",
"this",
"will",
"call",
"that",
"function",
"with",
"the",
"total",
"number",
"of",
"elements",
"and",
"the",
"remaining",
"number",
"of",
"elements",
"."
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/method/hierarchical.py#L86-L95 |
44,113 | exhuma/python-cluster | cluster/method/hierarchical.py | HierarchicalClustering.set_linkage_method | def set_linkage_method(self, method):
"""
Sets the method to determine the distance between two clusters.
:param method: The method to use. It can be one of ``'single'``,
``'complete'``, ``'average'`` or ``'uclus'``, or a callable. The
callable should take two collection... | python | def set_linkage_method(self, method):
"""
Sets the method to determine the distance between two clusters.
:param method: The method to use. It can be one of ``'single'``,
``'complete'``, ``'average'`` or ``'uclus'``, or a callable. The
callable should take two collection... | [
"def",
"set_linkage_method",
"(",
"self",
",",
"method",
")",
":",
"if",
"method",
"==",
"'single'",
":",
"self",
".",
"linkage",
"=",
"single",
"elif",
"method",
"==",
"'complete'",
":",
"self",
".",
"linkage",
"=",
"complete",
"elif",
"method",
"==",
"... | Sets the method to determine the distance between two clusters.
:param method: The method to use. It can be one of ``'single'``,
``'complete'``, ``'average'`` or ``'uclus'``, or a callable. The
callable should take two collections as parameters and return a
distance value be... | [
"Sets",
"the",
"method",
"to",
"determine",
"the",
"distance",
"between",
"two",
"clusters",
"."
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/method/hierarchical.py#L97-L118 |
44,114 | exhuma/python-cluster | cluster/method/hierarchical.py | HierarchicalClustering.cluster | def cluster(self, matrix=None, level=None, sequence=None):
"""
Perform hierarchical clustering.
:param matrix: The 2D list that is currently under processing. The
matrix contains the distances of each item with each other
:param level: The current level of clustering
... | python | def cluster(self, matrix=None, level=None, sequence=None):
"""
Perform hierarchical clustering.
:param matrix: The 2D list that is currently under processing. The
matrix contains the distances of each item with each other
:param level: The current level of clustering
... | [
"def",
"cluster",
"(",
"self",
",",
"matrix",
"=",
"None",
",",
"level",
"=",
"None",
",",
"sequence",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"\"Performing cluster()\"",
")",
"if",
"matrix",
"is",
"None",
":",
"# create level 0, first iteration (... | Perform hierarchical clustering.
:param matrix: The 2D list that is currently under processing. The
matrix contains the distances of each item with each other
:param level: The current level of clustering
:param sequence: The sequence number of the clustering | [
"Perform",
"hierarchical",
"clustering",
"."
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/method/hierarchical.py#L120-L189 |
44,115 | exhuma/python-cluster | cluster/util.py | flatten | def flatten(L):
"""
Flattens a list.
Example:
>>> flatten([a,b,[c,d,[e,f]]])
[a,b,c,d,e,f]
"""
if not isinstance(L, list):
return [L]
if L == []:
return L
return flatten(L[0]) + flatten(L[1:]) | python | def flatten(L):
"""
Flattens a list.
Example:
>>> flatten([a,b,[c,d,[e,f]]])
[a,b,c,d,e,f]
"""
if not isinstance(L, list):
return [L]
if L == []:
return L
return flatten(L[0]) + flatten(L[1:]) | [
"def",
"flatten",
"(",
"L",
")",
":",
"if",
"not",
"isinstance",
"(",
"L",
",",
"list",
")",
":",
"return",
"[",
"L",
"]",
"if",
"L",
"==",
"[",
"]",
":",
"return",
"L",
"return",
"flatten",
"(",
"L",
"[",
"0",
"]",
")",
"+",
"flatten",
"(",
... | Flattens a list.
Example:
>>> flatten([a,b,[c,d,[e,f]]])
[a,b,c,d,e,f] | [
"Flattens",
"a",
"list",
"."
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/util.py#L29-L44 |
44,116 | exhuma/python-cluster | cluster/util.py | fullyflatten | def fullyflatten(container):
"""
Completely flattens out a cluster and returns a one-dimensional set
containing the cluster's items. This is useful in cases where some items of
the cluster are clusters in their own right and you only want the items.
:param container: the container to flatten.
"... | python | def fullyflatten(container):
"""
Completely flattens out a cluster and returns a one-dimensional set
containing the cluster's items. This is useful in cases where some items of
the cluster are clusters in their own right and you only want the items.
:param container: the container to flatten.
"... | [
"def",
"fullyflatten",
"(",
"container",
")",
":",
"flattened_items",
"=",
"[",
"]",
"for",
"item",
"in",
"container",
":",
"if",
"hasattr",
"(",
"item",
",",
"'items'",
")",
":",
"flattened_items",
"=",
"flattened_items",
"+",
"fullyflatten",
"(",
"item",
... | Completely flattens out a cluster and returns a one-dimensional set
containing the cluster's items. This is useful in cases where some items of
the cluster are clusters in their own right and you only want the items.
:param container: the container to flatten. | [
"Completely",
"flattens",
"out",
"a",
"cluster",
"and",
"returns",
"a",
"one",
"-",
"dimensional",
"set",
"containing",
"the",
"cluster",
"s",
"items",
".",
"This",
"is",
"useful",
"in",
"cases",
"where",
"some",
"items",
"of",
"the",
"cluster",
"are",
"cl... | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/util.py#L47-L63 |
44,117 | exhuma/python-cluster | cluster/util.py | minkowski_distance | def minkowski_distance(x, y, p=2):
"""
Calculates the minkowski distance between two points.
:param x: the first point
:param y: the second point
:param p: the order of the minkowski algorithm. If *p=1* it is equal
to the manhatten distance, if *p=2* it is equal to the euclidian
dis... | python | def minkowski_distance(x, y, p=2):
"""
Calculates the minkowski distance between two points.
:param x: the first point
:param y: the second point
:param p: the order of the minkowski algorithm. If *p=1* it is equal
to the manhatten distance, if *p=2* it is equal to the euclidian
dis... | [
"def",
"minkowski_distance",
"(",
"x",
",",
"y",
",",
"p",
"=",
"2",
")",
":",
"from",
"math",
"import",
"pow",
"assert",
"len",
"(",
"y",
")",
"==",
"len",
"(",
"x",
")",
"assert",
"len",
"(",
"x",
")",
">=",
"1",
"sum",
"=",
"0",
"for",
"i"... | Calculates the minkowski distance between two points.
:param x: the first point
:param y: the second point
:param p: the order of the minkowski algorithm. If *p=1* it is equal
to the manhatten distance, if *p=2* it is equal to the euclidian
distance. The higher the order, the closer it conv... | [
"Calculates",
"the",
"minkowski",
"distance",
"between",
"two",
"points",
"."
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/util.py#L89-L106 |
44,118 | exhuma/python-cluster | cluster/util.py | magnitude | def magnitude(a):
"calculates the magnitude of a vecor"
from math import sqrt
sum = 0
for coord in a:
sum += coord ** 2
return sqrt(sum) | python | def magnitude(a):
"calculates the magnitude of a vecor"
from math import sqrt
sum = 0
for coord in a:
sum += coord ** 2
return sqrt(sum) | [
"def",
"magnitude",
"(",
"a",
")",
":",
"from",
"math",
"import",
"sqrt",
"sum",
"=",
"0",
"for",
"coord",
"in",
"a",
":",
"sum",
"+=",
"coord",
"**",
"2",
"return",
"sqrt",
"(",
"sum",
")"
] | calculates the magnitude of a vecor | [
"calculates",
"the",
"magnitude",
"of",
"a",
"vecor"
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/util.py#L109-L115 |
44,119 | exhuma/python-cluster | cluster/util.py | dotproduct | def dotproduct(a, b):
"Calculates the dotproduct between two vecors"
assert(len(a) == len(b))
out = 0
for i in range(len(a)):
out += a[i] * b[i]
return out | python | def dotproduct(a, b):
"Calculates the dotproduct between two vecors"
assert(len(a) == len(b))
out = 0
for i in range(len(a)):
out += a[i] * b[i]
return out | [
"def",
"dotproduct",
"(",
"a",
",",
"b",
")",
":",
"assert",
"(",
"len",
"(",
"a",
")",
"==",
"len",
"(",
"b",
")",
")",
"out",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"a",
")",
")",
":",
"out",
"+=",
"a",
"[",
"i",
"]",
"... | Calculates the dotproduct between two vecors | [
"Calculates",
"the",
"dotproduct",
"between",
"two",
"vecors"
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/util.py#L118-L124 |
44,120 | exhuma/python-cluster | cluster/util.py | centroid | def centroid(data, method=median):
"returns the central vector of a list of vectors"
out = []
for i in range(len(data[0])):
out.append(method([x[i] for x in data]))
return tuple(out) | python | def centroid(data, method=median):
"returns the central vector of a list of vectors"
out = []
for i in range(len(data[0])):
out.append(method([x[i] for x in data]))
return tuple(out) | [
"def",
"centroid",
"(",
"data",
",",
"method",
"=",
"median",
")",
":",
"out",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"data",
"[",
"0",
"]",
")",
")",
":",
"out",
".",
"append",
"(",
"method",
"(",
"[",
"x",
"[",
"i",
"]... | returns the central vector of a list of vectors | [
"returns",
"the",
"central",
"vector",
"of",
"a",
"list",
"of",
"vectors"
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/util.py#L127-L132 |
44,121 | exhuma/python-cluster | cluster/cluster.py | Cluster.display | def display(self, depth=0):
"""
Pretty-prints this cluster. Useful for debuging.
"""
print(depth * " " + "[level %s]" % self.level)
for item in self.items:
if isinstance(item, Cluster):
item.display(depth + 1)
else:
print... | python | def display(self, depth=0):
"""
Pretty-prints this cluster. Useful for debuging.
"""
print(depth * " " + "[level %s]" % self.level)
for item in self.items:
if isinstance(item, Cluster):
item.display(depth + 1)
else:
print... | [
"def",
"display",
"(",
"self",
",",
"depth",
"=",
"0",
")",
":",
"print",
"(",
"depth",
"*",
"\" \"",
"+",
"\"[level %s]\"",
"%",
"self",
".",
"level",
")",
"for",
"item",
"in",
"self",
".",
"items",
":",
"if",
"isinstance",
"(",
"item",
",",
"C... | Pretty-prints this cluster. Useful for debuging. | [
"Pretty",
"-",
"prints",
"this",
"cluster",
".",
"Useful",
"for",
"debuging",
"."
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/cluster.py#L63-L72 |
44,122 | exhuma/python-cluster | cluster/cluster.py | Cluster.getlevel | def getlevel(self, threshold):
"""
Retrieve all clusters up to a specific level threshold. This
level-threshold represents the maximum distance between two clusters.
So the lower you set this threshold, the more clusters you will
receive and the higher you set it, you will receiv... | python | def getlevel(self, threshold):
"""
Retrieve all clusters up to a specific level threshold. This
level-threshold represents the maximum distance between two clusters.
So the lower you set this threshold, the more clusters you will
receive and the higher you set it, you will receiv... | [
"def",
"getlevel",
"(",
"self",
",",
"threshold",
")",
":",
"left",
"=",
"self",
".",
"items",
"[",
"0",
"]",
"right",
"=",
"self",
".",
"items",
"[",
"1",
"]",
"# if this object itself is below the threshold value we only need to",
"# return it's contents as a list... | Retrieve all clusters up to a specific level threshold. This
level-threshold represents the maximum distance between two clusters.
So the lower you set this threshold, the more clusters you will
receive and the higher you set it, you will receive less but bigger
clusters.
:param... | [
"Retrieve",
"all",
"clusters",
"up",
"to",
"a",
"specific",
"level",
"threshold",
".",
"This",
"level",
"-",
"threshold",
"represents",
"the",
"maximum",
"distance",
"between",
"two",
"clusters",
".",
"So",
"the",
"lower",
"you",
"set",
"this",
"threshold",
... | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/cluster.py#L111-L162 |
44,123 | tikitu/jsmin | jsmin/__init__.py | jsmin | def jsmin(js, **kwargs):
"""
returns a minified version of the javascript string
"""
if not is_3:
if cStringIO and not isinstance(js, unicode):
# strings can use cStringIO for a 3x performance
# improvement, but unicode (in python2) cannot
klass = cStr... | python | def jsmin(js, **kwargs):
"""
returns a minified version of the javascript string
"""
if not is_3:
if cStringIO and not isinstance(js, unicode):
# strings can use cStringIO for a 3x performance
# improvement, but unicode (in python2) cannot
klass = cStr... | [
"def",
"jsmin",
"(",
"js",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"is_3",
":",
"if",
"cStringIO",
"and",
"not",
"isinstance",
"(",
"js",
",",
"unicode",
")",
":",
"# strings can use cStringIO for a 3x performance",
"# improvement, but unicode (in python2)... | returns a minified version of the javascript string | [
"returns",
"a",
"minified",
"version",
"of",
"the",
"javascript",
"string"
] | e87a6f3b1490e2643cbcdef77e41840c94f9e788 | https://github.com/tikitu/jsmin/blob/e87a6f3b1490e2643cbcdef77e41840c94f9e788/jsmin/__init__.py#L45-L61 |
44,124 | exhuma/python-cluster | cluster/linkage.py | cached | def cached(fun):
"""
memoizing decorator for linkage functions.
Parameters have been hardcoded (no ``*args``, ``**kwargs`` magic), because,
the way this is coded (interchangingly using sets and frozensets) is true
for this specific case. For other cases that is not necessarily guaranteed.
"""
... | python | def cached(fun):
"""
memoizing decorator for linkage functions.
Parameters have been hardcoded (no ``*args``, ``**kwargs`` magic), because,
the way this is coded (interchangingly using sets and frozensets) is true
for this specific case. For other cases that is not necessarily guaranteed.
"""
... | [
"def",
"cached",
"(",
"fun",
")",
":",
"_cache",
"=",
"{",
"}",
"@",
"wraps",
"(",
"fun",
")",
"def",
"newfun",
"(",
"a",
",",
"b",
",",
"distance_function",
")",
":",
"frozen_a",
"=",
"frozenset",
"(",
"a",
")",
"frozen_b",
"=",
"frozenset",
"(",
... | memoizing decorator for linkage functions.
Parameters have been hardcoded (no ``*args``, ``**kwargs`` magic), because,
the way this is coded (interchangingly using sets and frozensets) is true
for this specific case. For other cases that is not necessarily guaranteed. | [
"memoizing",
"decorator",
"for",
"linkage",
"functions",
"."
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/linkage.py#L5-L24 |
44,125 | exhuma/python-cluster | cluster/linkage.py | single | def single(a, b, distance_function):
"""
Given two collections ``a`` and ``b``, this will return the distance of the
points which are closest together. ``distance_function`` is used to
determine the distance between two elements.
Example::
>>> single([1, 2], [3, 4], lambda x, y: abs(x-y))... | python | def single(a, b, distance_function):
"""
Given two collections ``a`` and ``b``, this will return the distance of the
points which are closest together. ``distance_function`` is used to
determine the distance between two elements.
Example::
>>> single([1, 2], [3, 4], lambda x, y: abs(x-y))... | [
"def",
"single",
"(",
"a",
",",
"b",
",",
"distance_function",
")",
":",
"left_a",
",",
"right_a",
"=",
"min",
"(",
"a",
")",
",",
"max",
"(",
"a",
")",
"left_b",
",",
"right_b",
"=",
"min",
"(",
"b",
")",
",",
"max",
"(",
"b",
")",
"result",
... | Given two collections ``a`` and ``b``, this will return the distance of the
points which are closest together. ``distance_function`` is used to
determine the distance between two elements.
Example::
>>> single([1, 2], [3, 4], lambda x, y: abs(x-y))
1 # (distance between 2 and 3) | [
"Given",
"two",
"collections",
"a",
"and",
"b",
"this",
"will",
"return",
"the",
"distance",
"of",
"the",
"points",
"which",
"are",
"closest",
"together",
".",
"distance_function",
"is",
"used",
"to",
"determine",
"the",
"distance",
"between",
"two",
"elements... | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/linkage.py#L28-L43 |
44,126 | exhuma/python-cluster | cluster/linkage.py | average | def average(a, b, distance_function):
"""
Given two collections ``a`` and ``b``, this will return the mean of all
distances. ``distance_function`` is used to determine the distance between
two elements.
Example::
>>> single([1, 2], [3, 100], lambda x, y: abs(x-y))
26
"""
di... | python | def average(a, b, distance_function):
"""
Given two collections ``a`` and ``b``, this will return the mean of all
distances. ``distance_function`` is used to determine the distance between
two elements.
Example::
>>> single([1, 2], [3, 100], lambda x, y: abs(x-y))
26
"""
di... | [
"def",
"average",
"(",
"a",
",",
"b",
",",
"distance_function",
")",
":",
"distances",
"=",
"[",
"distance_function",
"(",
"x",
",",
"y",
")",
"for",
"x",
"in",
"a",
"for",
"y",
"in",
"b",
"]",
"return",
"sum",
"(",
"distances",
")",
"/",
"len",
... | Given two collections ``a`` and ``b``, this will return the mean of all
distances. ``distance_function`` is used to determine the distance between
two elements.
Example::
>>> single([1, 2], [3, 100], lambda x, y: abs(x-y))
26 | [
"Given",
"two",
"collections",
"a",
"and",
"b",
"this",
"will",
"return",
"the",
"mean",
"of",
"all",
"distances",
".",
"distance_function",
"is",
"used",
"to",
"determine",
"the",
"distance",
"between",
"two",
"elements",
"."
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/linkage.py#L66-L79 |
44,127 | exhuma/python-cluster | cluster/matrix.py | Matrix.worker | def worker(self):
"""
Multiprocessing task function run by worker processes
"""
tasks_completed = 0
for task in iter(self.task_queue.get, 'STOP'):
col_index, item, item2 = task
if not hasattr(item, '__iter__') or isinstance(item, tuple):
it... | python | def worker(self):
"""
Multiprocessing task function run by worker processes
"""
tasks_completed = 0
for task in iter(self.task_queue.get, 'STOP'):
col_index, item, item2 = task
if not hasattr(item, '__iter__') or isinstance(item, tuple):
it... | [
"def",
"worker",
"(",
"self",
")",
":",
"tasks_completed",
"=",
"0",
"for",
"task",
"in",
"iter",
"(",
"self",
".",
"task_queue",
".",
"get",
",",
"'STOP'",
")",
":",
"col_index",
",",
"item",
",",
"item2",
"=",
"task",
"if",
"not",
"hasattr",
"(",
... | Multiprocessing task function run by worker processes | [
"Multiprocessing",
"task",
"function",
"run",
"by",
"worker",
"processes"
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/matrix.py#L89-L105 |
44,128 | exhuma/python-cluster | cluster/matrix.py | Matrix.genmatrix | def genmatrix(self, num_processes=1):
"""
Actually generate the matrix
:param num_processes: If you want to use multiprocessing to split up the
work and run ``combinfunc()`` in parallel, specify
``num_processes > 1`` and this number of workers will be spun up,
... | python | def genmatrix(self, num_processes=1):
"""
Actually generate the matrix
:param num_processes: If you want to use multiprocessing to split up the
work and run ``combinfunc()`` in parallel, specify
``num_processes > 1`` and this number of workers will be spun up,
... | [
"def",
"genmatrix",
"(",
"self",
",",
"num_processes",
"=",
"1",
")",
":",
"use_multiprocessing",
"=",
"num_processes",
">",
"1",
"if",
"use_multiprocessing",
":",
"self",
".",
"task_queue",
"=",
"Queue",
"(",
")",
"self",
".",
"done_queue",
"=",
"Queue",
... | Actually generate the matrix
:param num_processes: If you want to use multiprocessing to split up the
work and run ``combinfunc()`` in parallel, specify
``num_processes > 1`` and this number of workers will be spun up,
the work is split up amongst them evenly. | [
"Actually",
"generate",
"the",
"matrix"
] | 4c0ac14d9beafcd51f0d849151514083c296402f | https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/matrix.py#L107-L198 |
44,129 | neurosnap/mudicom | mudicom/validation.py | validate | def validate(fname):
""" This function uses dciodvfy to generate
a list of warnings and errors discovered within
the DICOM file.
:param fname: Location and filename of DICOM file.
"""
validation = {
"errors": [],
"warnings": []
}
for line in _process(fname):
kind... | python | def validate(fname):
""" This function uses dciodvfy to generate
a list of warnings and errors discovered within
the DICOM file.
:param fname: Location and filename of DICOM file.
"""
validation = {
"errors": [],
"warnings": []
}
for line in _process(fname):
kind... | [
"def",
"validate",
"(",
"fname",
")",
":",
"validation",
"=",
"{",
"\"errors\"",
":",
"[",
"]",
",",
"\"warnings\"",
":",
"[",
"]",
"}",
"for",
"line",
"in",
"_process",
"(",
"fname",
")",
":",
"kind",
",",
"message",
"=",
"_determine",
"(",
"line",
... | This function uses dciodvfy to generate
a list of warnings and errors discovered within
the DICOM file.
:param fname: Location and filename of DICOM file. | [
"This",
"function",
"uses",
"dciodvfy",
"to",
"generate",
"a",
"list",
"of",
"warnings",
"and",
"errors",
"discovered",
"within",
"the",
"DICOM",
"file",
"."
] | 04011967007409f0c5253b4f308f53a7b0fc99c6 | https://github.com/neurosnap/mudicom/blob/04011967007409f0c5253b4f308f53a7b0fc99c6/mudicom/validation.py#L27-L42 |
44,130 | neurosnap/mudicom | mudicom/image.py | Image.numpy | def numpy(self):
""" Grabs image data and converts it to a numpy array """
# load GDCM's image reading functionality
image_reader = gdcm.ImageReader()
image_reader.SetFileName(self.fname)
if not image_reader.Read():
raise IOError("Could not read DICOM image")
... | python | def numpy(self):
""" Grabs image data and converts it to a numpy array """
# load GDCM's image reading functionality
image_reader = gdcm.ImageReader()
image_reader.SetFileName(self.fname)
if not image_reader.Read():
raise IOError("Could not read DICOM image")
... | [
"def",
"numpy",
"(",
"self",
")",
":",
"# load GDCM's image reading functionality",
"image_reader",
"=",
"gdcm",
".",
"ImageReader",
"(",
")",
"image_reader",
".",
"SetFileName",
"(",
"self",
".",
"fname",
")",
"if",
"not",
"image_reader",
".",
"Read",
"(",
")... | Grabs image data and converts it to a numpy array | [
"Grabs",
"image",
"data",
"and",
"converts",
"it",
"to",
"a",
"numpy",
"array"
] | 04011967007409f0c5253b4f308f53a7b0fc99c6 | https://github.com/neurosnap/mudicom/blob/04011967007409f0c5253b4f308f53a7b0fc99c6/mudicom/image.py#L29-L37 |
44,131 | neurosnap/mudicom | mudicom/image.py | Image._gdcm_to_numpy | def _gdcm_to_numpy(self, image):
""" Converts a GDCM image to a numpy array.
:param image: GDCM.ImageReader.GetImage()
"""
gdcm_typemap = {
gdcm.PixelFormat.INT8: numpy.int8,
gdcm.PixelFormat.UINT8: numpy.uint8,
gdcm.PixelFormat.UINT16: numpy... | python | def _gdcm_to_numpy(self, image):
""" Converts a GDCM image to a numpy array.
:param image: GDCM.ImageReader.GetImage()
"""
gdcm_typemap = {
gdcm.PixelFormat.INT8: numpy.int8,
gdcm.PixelFormat.UINT8: numpy.uint8,
gdcm.PixelFormat.UINT16: numpy... | [
"def",
"_gdcm_to_numpy",
"(",
"self",
",",
"image",
")",
":",
"gdcm_typemap",
"=",
"{",
"gdcm",
".",
"PixelFormat",
".",
"INT8",
":",
"numpy",
".",
"int8",
",",
"gdcm",
".",
"PixelFormat",
".",
"UINT8",
":",
"numpy",
".",
"uint8",
",",
"gdcm",
".",
"... | Converts a GDCM image to a numpy array.
:param image: GDCM.ImageReader.GetImage() | [
"Converts",
"a",
"GDCM",
"image",
"to",
"a",
"numpy",
"array",
"."
] | 04011967007409f0c5253b4f308f53a7b0fc99c6 | https://github.com/neurosnap/mudicom/blob/04011967007409f0c5253b4f308f53a7b0fc99c6/mudicom/image.py#L39-L77 |
44,132 | neurosnap/mudicom | mudicom/image.py | Image.save_as_plt | def save_as_plt(self, fname, pixel_array=None, vmin=None, vmax=None,
cmap=None, format=None, origin=None):
""" This method saves the image from a numpy array using matplotlib
:param fname: Location and name of the image file to be saved.
:param pixel_array: Numpy pixel array, i.e. ``num... | python | def save_as_plt(self, fname, pixel_array=None, vmin=None, vmax=None,
cmap=None, format=None, origin=None):
""" This method saves the image from a numpy array using matplotlib
:param fname: Location and name of the image file to be saved.
:param pixel_array: Numpy pixel array, i.e. ``num... | [
"def",
"save_as_plt",
"(",
"self",
",",
"fname",
",",
"pixel_array",
"=",
"None",
",",
"vmin",
"=",
"None",
",",
"vmax",
"=",
"None",
",",
"cmap",
"=",
"None",
",",
"format",
"=",
"None",
",",
"origin",
"=",
"None",
")",
":",
"from",
"matplotlib",
... | This method saves the image from a numpy array using matplotlib
:param fname: Location and name of the image file to be saved.
:param pixel_array: Numpy pixel array, i.e. ``numpy()`` return value
:param vmin: matplotlib vmin
:param vmax: matplotlib vmax
:param cmap: matplotlib c... | [
"This",
"method",
"saves",
"the",
"image",
"from",
"a",
"numpy",
"array",
"using",
"matplotlib"
] | 04011967007409f0c5253b4f308f53a7b0fc99c6 | https://github.com/neurosnap/mudicom/blob/04011967007409f0c5253b4f308f53a7b0fc99c6/mudicom/image.py#L79-L108 |
44,133 | neurosnap/mudicom | mudicom/base.py | Dicom.read | def read(self):
""" Returns array of dictionaries containing all the data elements in
the DICOM file.
"""
def ds(data_element):
value = self._str_filter.ToStringPair(data_element.GetTag())
if value[1]:
return DataElement(data_element, value[0].stri... | python | def read(self):
""" Returns array of dictionaries containing all the data elements in
the DICOM file.
"""
def ds(data_element):
value = self._str_filter.ToStringPair(data_element.GetTag())
if value[1]:
return DataElement(data_element, value[0].stri... | [
"def",
"read",
"(",
"self",
")",
":",
"def",
"ds",
"(",
"data_element",
")",
":",
"value",
"=",
"self",
".",
"_str_filter",
".",
"ToStringPair",
"(",
"data_element",
".",
"GetTag",
"(",
")",
")",
"if",
"value",
"[",
"1",
"]",
":",
"return",
"DataElem... | Returns array of dictionaries containing all the data elements in
the DICOM file. | [
"Returns",
"array",
"of",
"dictionaries",
"containing",
"all",
"the",
"data",
"elements",
"in",
"the",
"DICOM",
"file",
"."
] | 04011967007409f0c5253b4f308f53a7b0fc99c6 | https://github.com/neurosnap/mudicom/blob/04011967007409f0c5253b4f308f53a7b0fc99c6/mudicom/base.py#L101-L111 |
44,134 | neurosnap/mudicom | mudicom/base.py | Dicom.walk | def walk(self, fn):
""" Loops through all data elements and allows a function to interact
with each data element. Uses a generator to improve iteration.
:param fn: Function that interacts with each DICOM element """
if not hasattr(fn, "__call__"):
raise TypeError("""walk_da... | python | def walk(self, fn):
""" Loops through all data elements and allows a function to interact
with each data element. Uses a generator to improve iteration.
:param fn: Function that interacts with each DICOM element """
if not hasattr(fn, "__call__"):
raise TypeError("""walk_da... | [
"def",
"walk",
"(",
"self",
",",
"fn",
")",
":",
"if",
"not",
"hasattr",
"(",
"fn",
",",
"\"__call__\"",
")",
":",
"raise",
"TypeError",
"(",
"\"\"\"walk_dataset requires a\n function as its parameter\"\"\"",
")",
"dataset",
"=",
"self",
".",
"_data... | Loops through all data elements and allows a function to interact
with each data element. Uses a generator to improve iteration.
:param fn: Function that interacts with each DICOM element | [
"Loops",
"through",
"all",
"data",
"elements",
"and",
"allows",
"a",
"function",
"to",
"interact",
"with",
"each",
"data",
"element",
".",
"Uses",
"a",
"generator",
"to",
"improve",
"iteration",
"."
] | 04011967007409f0c5253b4f308f53a7b0fc99c6 | https://github.com/neurosnap/mudicom/blob/04011967007409f0c5253b4f308f53a7b0fc99c6/mudicom/base.py#L113-L132 |
44,135 | neurosnap/mudicom | mudicom/base.py | Dicom.find | def find(self, group=None, element=None, name=None, VR=None):
""" Searches for data elements in the DICOM file given the filters
supplied to this method.
:param group: Hex decimal for the group of a DICOM element e.g. 0x002
:param element: Hex decimal for the element value of a DICOM el... | python | def find(self, group=None, element=None, name=None, VR=None):
""" Searches for data elements in the DICOM file given the filters
supplied to this method.
:param group: Hex decimal for the group of a DICOM element e.g. 0x002
:param element: Hex decimal for the element value of a DICOM el... | [
"def",
"find",
"(",
"self",
",",
"group",
"=",
"None",
",",
"element",
"=",
"None",
",",
"name",
"=",
"None",
",",
"VR",
"=",
"None",
")",
":",
"results",
"=",
"self",
".",
"read",
"(",
")",
"if",
"name",
"is",
"not",
"None",
":",
"def",
"find_... | Searches for data elements in the DICOM file given the filters
supplied to this method.
:param group: Hex decimal for the group of a DICOM element e.g. 0x002
:param element: Hex decimal for the element value of a DICOM element e.g. 0x0010
:param name: Name of the DICOM element, e.g. "Mo... | [
"Searches",
"for",
"data",
"elements",
"in",
"the",
"DICOM",
"file",
"given",
"the",
"filters",
"supplied",
"to",
"this",
"method",
"."
] | 04011967007409f0c5253b4f308f53a7b0fc99c6 | https://github.com/neurosnap/mudicom/blob/04011967007409f0c5253b4f308f53a7b0fc99c6/mudicom/base.py#L134-L167 |
44,136 | neurosnap/mudicom | mudicom/base.py | Dicom.anonymize | def anonymize(self):
""" According to PS 3.15-2008, basic application level
De-Indentification of a DICOM file requires replacing the values of a
set of data elements"""
self._anon_obj = gdcm.Anonymizer()
self._anon_obj.SetFile(self._file)
self._anon_obj.RemoveGroupLength... | python | def anonymize(self):
""" According to PS 3.15-2008, basic application level
De-Indentification of a DICOM file requires replacing the values of a
set of data elements"""
self._anon_obj = gdcm.Anonymizer()
self._anon_obj.SetFile(self._file)
self._anon_obj.RemoveGroupLength... | [
"def",
"anonymize",
"(",
"self",
")",
":",
"self",
".",
"_anon_obj",
"=",
"gdcm",
".",
"Anonymizer",
"(",
")",
"self",
".",
"_anon_obj",
".",
"SetFile",
"(",
"self",
".",
"_file",
")",
"self",
".",
"_anon_obj",
".",
"RemoveGroupLength",
"(",
")",
"if",... | According to PS 3.15-2008, basic application level
De-Indentification of a DICOM file requires replacing the values of a
set of data elements | [
"According",
"to",
"PS",
"3",
".",
"15",
"-",
"2008",
"basic",
"application",
"level",
"De",
"-",
"Indentification",
"of",
"a",
"DICOM",
"file",
"requires",
"replacing",
"the",
"values",
"of",
"a",
"set",
"of",
"data",
"elements"
] | 04011967007409f0c5253b4f308f53a7b0fc99c6 | https://github.com/neurosnap/mudicom/blob/04011967007409f0c5253b4f308f53a7b0fc99c6/mudicom/base.py#L169-L196 |
44,137 | neurosnap/mudicom | mudicom/base.py | Dicom.image | def image(self):
""" Read the loaded DICOM image data """
if self._image is None:
self._image = Image(self.fname)
return self._image | python | def image(self):
""" Read the loaded DICOM image data """
if self._image is None:
self._image = Image(self.fname)
return self._image | [
"def",
"image",
"(",
"self",
")",
":",
"if",
"self",
".",
"_image",
"is",
"None",
":",
"self",
".",
"_image",
"=",
"Image",
"(",
"self",
".",
"fname",
")",
"return",
"self",
".",
"_image"
] | Read the loaded DICOM image data | [
"Read",
"the",
"loaded",
"DICOM",
"image",
"data"
] | 04011967007409f0c5253b4f308f53a7b0fc99c6 | https://github.com/neurosnap/mudicom/blob/04011967007409f0c5253b4f308f53a7b0fc99c6/mudicom/base.py#L220-L224 |
44,138 | wdm0006/git-pandas | gitpandas/project.py | ProjectDirectory.repo_name | def repo_name(self):
"""
Returns a DataFrame of the repo names present in this project directory
:return: DataFrame
"""
ds = [[x.repo_name] for x in self.repos]
df = pd.DataFrame(ds, columns=['repository'])
return df | python | def repo_name(self):
"""
Returns a DataFrame of the repo names present in this project directory
:return: DataFrame
"""
ds = [[x.repo_name] for x in self.repos]
df = pd.DataFrame(ds, columns=['repository'])
return df | [
"def",
"repo_name",
"(",
"self",
")",
":",
"ds",
"=",
"[",
"[",
"x",
".",
"repo_name",
"]",
"for",
"x",
"in",
"self",
".",
"repos",
"]",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"ds",
",",
"columns",
"=",
"[",
"'repository'",
"]",
")",
"return",
... | Returns a DataFrame of the repo names present in this project directory
:return: DataFrame | [
"Returns",
"a",
"DataFrame",
"of",
"the",
"repo",
"names",
"present",
"in",
"this",
"project",
"directory"
] | e56b817b1d66b8296d1d5e703d5db0e181d25899 | https://github.com/wdm0006/git-pandas/blob/e56b817b1d66b8296d1d5e703d5db0e181d25899/gitpandas/project.py#L74-L84 |
44,139 | rienafairefr/pynYNAB | pynYNAB/scripts/__main__.py | CsvImport.command | def command(self):
"""Manually import a CSV into a nYNAB budget"""
print('pynYNAB CSV import')
args = self.parser.parse_args()
verify_common_args(args)
verify_csvimport(args.schema, args.accountname)
client = clientfromkwargs(**args)
delta = do_csvimport(args, c... | python | def command(self):
"""Manually import a CSV into a nYNAB budget"""
print('pynYNAB CSV import')
args = self.parser.parse_args()
verify_common_args(args)
verify_csvimport(args.schema, args.accountname)
client = clientfromkwargs(**args)
delta = do_csvimport(args, c... | [
"def",
"command",
"(",
"self",
")",
":",
"print",
"(",
"'pynYNAB CSV import'",
")",
"args",
"=",
"self",
".",
"parser",
".",
"parse_args",
"(",
")",
"verify_common_args",
"(",
"args",
")",
"verify_csvimport",
"(",
"args",
".",
"schema",
",",
"args",
".",
... | Manually import a CSV into a nYNAB budget | [
"Manually",
"import",
"a",
"CSV",
"into",
"a",
"nYNAB",
"budget"
] | d5fc0749618409c6bb01cc2b93832cc59d780eaa | https://github.com/rienafairefr/pynYNAB/blob/d5fc0749618409c6bb01cc2b93832cc59d780eaa/pynYNAB/scripts/__main__.py#L82-L92 |
44,140 | rienafairefr/pynYNAB | pynYNAB/scripts/__main__.py | OfxImport.command | def command(self):
"""Manually import an OFX into a nYNAB budget"""
print('pynYNAB OFX import')
args = self.parser.parse_args()
verify_common_args(args)
client = clientfromkwargs(**args)
delta = do_ofximport(args.file, client)
client.push(expected_delta=delta) | python | def command(self):
"""Manually import an OFX into a nYNAB budget"""
print('pynYNAB OFX import')
args = self.parser.parse_args()
verify_common_args(args)
client = clientfromkwargs(**args)
delta = do_ofximport(args.file, client)
client.push(expected_delta=delta) | [
"def",
"command",
"(",
"self",
")",
":",
"print",
"(",
"'pynYNAB OFX import'",
")",
"args",
"=",
"self",
".",
"parser",
".",
"parse_args",
"(",
")",
"verify_common_args",
"(",
"args",
")",
"client",
"=",
"clientfromkwargs",
"(",
"*",
"*",
"args",
")",
"d... | Manually import an OFX into a nYNAB budget | [
"Manually",
"import",
"an",
"OFX",
"into",
"a",
"nYNAB",
"budget"
] | d5fc0749618409c6bb01cc2b93832cc59d780eaa | https://github.com/rienafairefr/pynYNAB/blob/d5fc0749618409c6bb01cc2b93832cc59d780eaa/pynYNAB/scripts/__main__.py#L104-L113 |
44,141 | rienafairefr/pynYNAB | pynYNAB/schema/Entity.py | default_listener | def default_listener(col_attr, default):
"""Establish a default-setting listener."""
@event.listens_for(col_attr, "init_scalar", retval=True, propagate=True)
def init_scalar(target, value, dict_):
if default.is_callable:
# the callable of ColumnDefault always accepts a context argument... | python | def default_listener(col_attr, default):
"""Establish a default-setting listener."""
@event.listens_for(col_attr, "init_scalar", retval=True, propagate=True)
def init_scalar(target, value, dict_):
if default.is_callable:
# the callable of ColumnDefault always accepts a context argument... | [
"def",
"default_listener",
"(",
"col_attr",
",",
"default",
")",
":",
"@",
"event",
".",
"listens_for",
"(",
"col_attr",
",",
"\"init_scalar\"",
",",
"retval",
"=",
"True",
",",
"propagate",
"=",
"True",
")",
"def",
"init_scalar",
"(",
"target",
",",
"valu... | Establish a default-setting listener. | [
"Establish",
"a",
"default",
"-",
"setting",
"listener",
"."
] | d5fc0749618409c6bb01cc2b93832cc59d780eaa | https://github.com/rienafairefr/pynYNAB/blob/d5fc0749618409c6bb01cc2b93832cc59d780eaa/pynYNAB/schema/Entity.py#L165-L182 |
44,142 | wdm0006/git-pandas | gitpandas/repository.py | Repository.has_coverage | def has_coverage(self):
"""
Returns a boolean for is a parseable .coverage file can be found in the repository
:return: bool
"""
if os.path.exists(self.git_dir + os.sep + '.coverage'):
try:
with open(self.git_dir + os.sep + '.coverage', 'r') as f:
... | python | def has_coverage(self):
"""
Returns a boolean for is a parseable .coverage file can be found in the repository
:return: bool
"""
if os.path.exists(self.git_dir + os.sep + '.coverage'):
try:
with open(self.git_dir + os.sep + '.coverage', 'r') as f:
... | [
"def",
"has_coverage",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"git_dir",
"+",
"os",
".",
"sep",
"+",
"'.coverage'",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"git_dir",
"+",
"os",
".",
"sep"... | Returns a boolean for is a parseable .coverage file can be found in the repository
:return: bool | [
"Returns",
"a",
"boolean",
"for",
"is",
"a",
"parseable",
".",
"coverage",
"file",
"can",
"be",
"found",
"in",
"the",
"repository"
] | e56b817b1d66b8296d1d5e703d5db0e181d25899 | https://github.com/wdm0006/git-pandas/blob/e56b817b1d66b8296d1d5e703d5db0e181d25899/gitpandas/repository.py#L109-L127 |
44,143 | wdm0006/git-pandas | gitpandas/repository.py | Repository.__check_extension | def __check_extension(files, ignore_globs=None, include_globs=None):
"""
Internal method to filter a list of file changes by extension and ignore_dirs.
:param files:
:param ignore_globs: a list of globs to ignore (if none falls back to extensions and ignore_dir)
:param include_g... | python | def __check_extension(files, ignore_globs=None, include_globs=None):
"""
Internal method to filter a list of file changes by extension and ignore_dirs.
:param files:
:param ignore_globs: a list of globs to ignore (if none falls back to extensions and ignore_dir)
:param include_g... | [
"def",
"__check_extension",
"(",
"files",
",",
"ignore_globs",
"=",
"None",
",",
"include_globs",
"=",
"None",
")",
":",
"if",
"include_globs",
"is",
"None",
"or",
"include_globs",
"==",
"[",
"]",
":",
"include_globs",
"=",
"[",
"'*'",
"]",
"out",
"=",
"... | Internal method to filter a list of file changes by extension and ignore_dirs.
:param files:
:param ignore_globs: a list of globs to ignore (if none falls back to extensions and ignore_dir)
:param include_globs: a list of globs to include (if none, includes all).
:return: dict | [
"Internal",
"method",
"to",
"filter",
"a",
"list",
"of",
"file",
"changes",
"by",
"extension",
"and",
"ignore_dirs",
"."
] | e56b817b1d66b8296d1d5e703d5db0e181d25899 | https://github.com/wdm0006/git-pandas/blob/e56b817b1d66b8296d1d5e703d5db0e181d25899/gitpandas/repository.py#L489-L517 |
44,144 | wdm0006/git-pandas | gitpandas/repository.py | Repository._repo_name | def _repo_name(self):
"""
Returns the name of the repository, using the local directory name.
:returns: str
"""
if self._git_repo_name is not None:
return self._git_repo_name
else:
reponame = self.repo.git_dir.split(os.sep)[-2]
if rep... | python | def _repo_name(self):
"""
Returns the name of the repository, using the local directory name.
:returns: str
"""
if self._git_repo_name is not None:
return self._git_repo_name
else:
reponame = self.repo.git_dir.split(os.sep)[-2]
if rep... | [
"def",
"_repo_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"_git_repo_name",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_git_repo_name",
"else",
":",
"reponame",
"=",
"self",
".",
"repo",
".",
"git_dir",
".",
"split",
"(",
"os",
".",
"sep",
... | Returns the name of the repository, using the local directory name.
:returns: str | [
"Returns",
"the",
"name",
"of",
"the",
"repository",
"using",
"the",
"local",
"directory",
"name",
"."
] | e56b817b1d66b8296d1d5e703d5db0e181d25899 | https://github.com/wdm0006/git-pandas/blob/e56b817b1d66b8296d1d5e703d5db0e181d25899/gitpandas/repository.py#L798-L811 |
44,145 | beardypig/pymp4 | src/pymp4/parser.py | ISO6392TLanguageCode._decode | def _decode(self, obj, context):
"""
Get the python representation of the obj
"""
return b''.join(map(int2byte, [c + 0x60 for c in bytearray(obj)])).decode("utf8") | python | def _decode(self, obj, context):
"""
Get the python representation of the obj
"""
return b''.join(map(int2byte, [c + 0x60 for c in bytearray(obj)])).decode("utf8") | [
"def",
"_decode",
"(",
"self",
",",
"obj",
",",
"context",
")",
":",
"return",
"b''",
".",
"join",
"(",
"map",
"(",
"int2byte",
",",
"[",
"c",
"+",
"0x60",
"for",
"c",
"in",
"bytearray",
"(",
"obj",
")",
"]",
")",
")",
".",
"decode",
"(",
"\"ut... | Get the python representation of the obj | [
"Get",
"the",
"python",
"representation",
"of",
"the",
"obj"
] | 5f73f01def4ffea67847ee3062095ef3bae3f2d6 | https://github.com/beardypig/pymp4/blob/5f73f01def4ffea67847ee3062095ef3bae3f2d6/src/pymp4/parser.py#L234-L238 |
44,146 | djangonauts/django-rest-framework-hstore | rest_framework_hstore/serializers.py | HStoreSerializer.update | def update(self, instance, validated_data):
"""
temporarily remove hstore virtual fields otherwise DRF considers them many2many
"""
model = self.Meta.model
meta = self.Meta.model._meta
original_virtual_fields = list(meta.virtual_fields) # copy
if hasattr(model, ... | python | def update(self, instance, validated_data):
"""
temporarily remove hstore virtual fields otherwise DRF considers them many2many
"""
model = self.Meta.model
meta = self.Meta.model._meta
original_virtual_fields = list(meta.virtual_fields) # copy
if hasattr(model, ... | [
"def",
"update",
"(",
"self",
",",
"instance",
",",
"validated_data",
")",
":",
"model",
"=",
"self",
".",
"Meta",
".",
"model",
"meta",
"=",
"self",
".",
"Meta",
".",
"model",
".",
"_meta",
"original_virtual_fields",
"=",
"list",
"(",
"meta",
".",
"vi... | temporarily remove hstore virtual fields otherwise DRF considers them many2many | [
"temporarily",
"remove",
"hstore",
"virtual",
"fields",
"otherwise",
"DRF",
"considers",
"them",
"many2many"
] | aef8b5446417640764f2fdf0684dc4a0d87a8507 | https://github.com/djangonauts/django-rest-framework-hstore/blob/aef8b5446417640764f2fdf0684dc4a0d87a8507/rest_framework_hstore/serializers.py#L107-L126 |
44,147 | newville/wxmplot | wxmplot/imagepanel.py | ImagePanel.update_image | def update_image(self, data):
"""
update image on panel, as quickly as possible
"""
if 1 in data.shape:
data = data.squeeze()
if self.conf.contrast_level is not None:
clevels = [self.conf.contrast_level, 100.0-self.conf.contrast_level]
imin, im... | python | def update_image(self, data):
"""
update image on panel, as quickly as possible
"""
if 1 in data.shape:
data = data.squeeze()
if self.conf.contrast_level is not None:
clevels = [self.conf.contrast_level, 100.0-self.conf.contrast_level]
imin, im... | [
"def",
"update_image",
"(",
"self",
",",
"data",
")",
":",
"if",
"1",
"in",
"data",
".",
"shape",
":",
"data",
"=",
"data",
".",
"squeeze",
"(",
")",
"if",
"self",
".",
"conf",
".",
"contrast_level",
"is",
"not",
"None",
":",
"clevels",
"=",
"[",
... | update image on panel, as quickly as possible | [
"update",
"image",
"on",
"panel",
"as",
"quickly",
"as",
"possible"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/imagepanel.py#L156-L167 |
44,148 | newville/wxmplot | wxmplot/imagepanel.py | ImagePanel.set_viewlimits | def set_viewlimits(self, axes=None):
""" update xy limits of a plot"""
if axes is None:
axes = self.axes
xmin, xmax, ymin, ymax = self.data_range
if len(self.conf.zoom_lims) >1:
zlims = self.conf.zoom_lims[-1]
if axes in zlims:
xmin, x... | python | def set_viewlimits(self, axes=None):
""" update xy limits of a plot"""
if axes is None:
axes = self.axes
xmin, xmax, ymin, ymax = self.data_range
if len(self.conf.zoom_lims) >1:
zlims = self.conf.zoom_lims[-1]
if axes in zlims:
xmin, x... | [
"def",
"set_viewlimits",
"(",
"self",
",",
"axes",
"=",
"None",
")",
":",
"if",
"axes",
"is",
"None",
":",
"axes",
"=",
"self",
".",
"axes",
"xmin",
",",
"xmax",
",",
"ymin",
",",
"ymax",
"=",
"self",
".",
"data_range",
"if",
"len",
"(",
"self",
... | update xy limits of a plot | [
"update",
"xy",
"limits",
"of",
"a",
"plot"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/imagepanel.py#L196-L231 |
44,149 | newville/wxmplot | wxmplot/imagepanel.py | ImagePanel.zoom_leftup | def zoom_leftup(self, event=None):
"""leftup event handler for zoom mode in images"""
if self.zoom_ini is None:
return
ini_x, ini_y, ini_xd, ini_yd = self.zoom_ini
try:
dx = abs(ini_x - event.x)
dy = abs(ini_y - event.y)
except:
d... | python | def zoom_leftup(self, event=None):
"""leftup event handler for zoom mode in images"""
if self.zoom_ini is None:
return
ini_x, ini_y, ini_xd, ini_yd = self.zoom_ini
try:
dx = abs(ini_x - event.x)
dy = abs(ini_y - event.y)
except:
d... | [
"def",
"zoom_leftup",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"if",
"self",
".",
"zoom_ini",
"is",
"None",
":",
"return",
"ini_x",
",",
"ini_y",
",",
"ini_xd",
",",
"ini_yd",
"=",
"self",
".",
"zoom_ini",
"try",
":",
"dx",
"=",
"abs",
"("... | leftup event handler for zoom mode in images | [
"leftup",
"event",
"handler",
"for",
"zoom",
"mode",
"in",
"images"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/imagepanel.py#L327-L370 |
44,150 | benhoff/pluginmanager | pluginmanager/directory_manager.py | DirectoryManager.collect_directories | def collect_directories(self, directories):
"""
Collects all the directories into a `set` object.
If `self.recursive` is set to `True` this method will iterate through
and return all of the directories and the subdirectories found from
`directories` that are not blacklisted.
... | python | def collect_directories(self, directories):
"""
Collects all the directories into a `set` object.
If `self.recursive` is set to `True` this method will iterate through
and return all of the directories and the subdirectories found from
`directories` that are not blacklisted.
... | [
"def",
"collect_directories",
"(",
"self",
",",
"directories",
")",
":",
"directories",
"=",
"util",
".",
"to_absolute_paths",
"(",
"directories",
")",
"if",
"not",
"self",
".",
"recursive",
":",
"return",
"self",
".",
"_remove_blacklisted",
"(",
"directories",
... | Collects all the directories into a `set` object.
If `self.recursive` is set to `True` this method will iterate through
and return all of the directories and the subdirectories found from
`directories` that are not blacklisted.
if `self.recursive` is set to `False` this will return all... | [
"Collects",
"all",
"the",
"directories",
"into",
"a",
"set",
"object",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/directory_manager.py#L47-L75 |
44,151 | benhoff/pluginmanager | pluginmanager/directory_manager.py | DirectoryManager.remove_directories | def remove_directories(self, directories):
"""
Removes any `directories` from the set of plugin directories.
`directories` may be a single object or an iterable.
Recommend passing in all paths as absolute, but the method will
attemmpt to convert all paths to absolute if they ar... | python | def remove_directories(self, directories):
"""
Removes any `directories` from the set of plugin directories.
`directories` may be a single object or an iterable.
Recommend passing in all paths as absolute, but the method will
attemmpt to convert all paths to absolute if they ar... | [
"def",
"remove_directories",
"(",
"self",
",",
"directories",
")",
":",
"directories",
"=",
"util",
".",
"to_absolute_paths",
"(",
"directories",
")",
"self",
".",
"plugin_directories",
"=",
"util",
".",
"remove_from_set",
"(",
"self",
".",
"plugin_directories",
... | Removes any `directories` from the set of plugin directories.
`directories` may be a single object or an iterable.
Recommend passing in all paths as absolute, but the method will
attemmpt to convert all paths to absolute if they are not already
based on the current working directory. | [
"Removes",
"any",
"directories",
"from",
"the",
"set",
"of",
"plugin",
"directories",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/directory_manager.py#L116-L128 |
44,152 | benhoff/pluginmanager | pluginmanager/directory_manager.py | DirectoryManager.remove_blacklisted_directories | def remove_blacklisted_directories(self, directories):
"""
Attempts to remove the `directories` from the set of blacklisted
directories. If a particular directory is not found in the set of
blacklisted, method will continue on silently.
`directories` may be a single instance or ... | python | def remove_blacklisted_directories(self, directories):
"""
Attempts to remove the `directories` from the set of blacklisted
directories. If a particular directory is not found in the set of
blacklisted, method will continue on silently.
`directories` may be a single instance or ... | [
"def",
"remove_blacklisted_directories",
"(",
"self",
",",
"directories",
")",
":",
"directories",
"=",
"util",
".",
"to_absolute_paths",
"(",
"directories",
")",
"black_dirs",
"=",
"self",
".",
"blacklisted_directories",
"black_dirs",
"=",
"util",
".",
"remove_from... | Attempts to remove the `directories` from the set of blacklisted
directories. If a particular directory is not found in the set of
blacklisted, method will continue on silently.
`directories` may be a single instance or an iterable. Recommend
passing in absolute paths. Method will try t... | [
"Attempts",
"to",
"remove",
"the",
"directories",
"from",
"the",
"set",
"of",
"blacklisted",
"directories",
".",
"If",
"a",
"particular",
"directory",
"is",
"not",
"found",
"in",
"the",
"set",
"of",
"blacklisted",
"method",
"will",
"continue",
"on",
"silently"... | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/directory_manager.py#L194-L206 |
44,153 | benhoff/pluginmanager | pluginmanager/directory_manager.py | DirectoryManager._remove_blacklisted | def _remove_blacklisted(self, directories):
"""
Attempts to remove the blacklisted directories from `directories`
and then returns whatever is left in the set.
Called from the `collect_directories` method.
"""
directories = util.to_absolute_paths(directories)
dir... | python | def _remove_blacklisted(self, directories):
"""
Attempts to remove the blacklisted directories from `directories`
and then returns whatever is left in the set.
Called from the `collect_directories` method.
"""
directories = util.to_absolute_paths(directories)
dir... | [
"def",
"_remove_blacklisted",
"(",
"self",
",",
"directories",
")",
":",
"directories",
"=",
"util",
".",
"to_absolute_paths",
"(",
"directories",
")",
"directories",
"=",
"util",
".",
"remove_from_set",
"(",
"directories",
",",
"self",
".",
"blacklisted_directori... | Attempts to remove the blacklisted directories from `directories`
and then returns whatever is left in the set.
Called from the `collect_directories` method. | [
"Attempts",
"to",
"remove",
"the",
"blacklisted",
"directories",
"from",
"directories",
"and",
"then",
"returns",
"whatever",
"is",
"left",
"in",
"the",
"set",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/directory_manager.py#L208-L219 |
44,154 | newville/wxmplot | examples/tifffile.py | imread | def imread(filename, *args, **kwargs):
"""Return image data from TIFF file as numpy array.
The first image series is returned if no arguments are provided.
Parameters
----------
key : int, slice, or sequence of page indices
Defines which pages to return as array.
series : int
D... | python | def imread(filename, *args, **kwargs):
"""Return image data from TIFF file as numpy array.
The first image series is returned if no arguments are provided.
Parameters
----------
key : int, slice, or sequence of page indices
Defines which pages to return as array.
series : int
D... | [
"def",
"imread",
"(",
"filename",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"TIFFfile",
"(",
"filename",
")",
"as",
"tif",
":",
"return",
"tif",
".",
"asarray",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Return image data from TIFF file as numpy array.
The first image series is returned if no arguments are provided.
Parameters
----------
key : int, slice, or sequence of page indices
Defines which pages to return as array.
series : int
Defines which series of pages to return as arra... | [
"Return",
"image",
"data",
"from",
"TIFF",
"file",
"as",
"numpy",
"array",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L384-L402 |
44,155 | newville/wxmplot | examples/tifffile.py | read_nih_image_header | def read_nih_image_header(fd, byte_order, dtype, count):
"""Read NIH_IMAGE_HEADER tag from file and return as dictionary."""
fd.seek(12, 1)
return {'version': struct.unpack(byte_order+'H', fd.read(2))[0]} | python | def read_nih_image_header(fd, byte_order, dtype, count):
"""Read NIH_IMAGE_HEADER tag from file and return as dictionary."""
fd.seek(12, 1)
return {'version': struct.unpack(byte_order+'H', fd.read(2))[0]} | [
"def",
"read_nih_image_header",
"(",
"fd",
",",
"byte_order",
",",
"dtype",
",",
"count",
")",
":",
"fd",
".",
"seek",
"(",
"12",
",",
"1",
")",
"return",
"{",
"'version'",
":",
"struct",
".",
"unpack",
"(",
"byte_order",
"+",
"'H'",
",",
"fd",
".",
... | Read NIH_IMAGE_HEADER tag from file and return as dictionary. | [
"Read",
"NIH_IMAGE_HEADER",
"tag",
"from",
"file",
"and",
"return",
"as",
"dictionary",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1398-L1401 |
44,156 | newville/wxmplot | examples/tifffile.py | read_mm_header | def read_mm_header(fd, byte_order, dtype, count):
"""Read MM_HEADER tag from file and return as numpy.rec.array."""
return numpy.rec.fromfile(fd, MM_HEADER, 1, byteorder=byte_order)[0] | python | def read_mm_header(fd, byte_order, dtype, count):
"""Read MM_HEADER tag from file and return as numpy.rec.array."""
return numpy.rec.fromfile(fd, MM_HEADER, 1, byteorder=byte_order)[0] | [
"def",
"read_mm_header",
"(",
"fd",
",",
"byte_order",
",",
"dtype",
",",
"count",
")",
":",
"return",
"numpy",
".",
"rec",
".",
"fromfile",
"(",
"fd",
",",
"MM_HEADER",
",",
"1",
",",
"byteorder",
"=",
"byte_order",
")",
"[",
"0",
"]"
] | Read MM_HEADER tag from file and return as numpy.rec.array. | [
"Read",
"MM_HEADER",
"tag",
"from",
"file",
"and",
"return",
"as",
"numpy",
".",
"rec",
".",
"array",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1404-L1406 |
44,157 | newville/wxmplot | examples/tifffile.py | read_mm_uic1 | def read_mm_uic1(fd, byte_order, dtype, count):
"""Read MM_UIC1 tag from file and return as dictionary."""
t = fd.read(8*count)
t = struct.unpack('%s%iI' % (byte_order, 2*count), t)
return dict((MM_TAG_IDS[k], v) for k, v in zip(t[::2], t[1::2])
if k in MM_TAG_IDS) | python | def read_mm_uic1(fd, byte_order, dtype, count):
"""Read MM_UIC1 tag from file and return as dictionary."""
t = fd.read(8*count)
t = struct.unpack('%s%iI' % (byte_order, 2*count), t)
return dict((MM_TAG_IDS[k], v) for k, v in zip(t[::2], t[1::2])
if k in MM_TAG_IDS) | [
"def",
"read_mm_uic1",
"(",
"fd",
",",
"byte_order",
",",
"dtype",
",",
"count",
")",
":",
"t",
"=",
"fd",
".",
"read",
"(",
"8",
"*",
"count",
")",
"t",
"=",
"struct",
".",
"unpack",
"(",
"'%s%iI'",
"%",
"(",
"byte_order",
",",
"2",
"*",
"count"... | Read MM_UIC1 tag from file and return as dictionary. | [
"Read",
"MM_UIC1",
"tag",
"from",
"file",
"and",
"return",
"as",
"dictionary",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1414-L1419 |
44,158 | newville/wxmplot | examples/tifffile.py | read_mm_uic2 | def read_mm_uic2(fd, byte_order, dtype, count):
"""Read MM_UIC2 tag from file and return as dictionary."""
result = {'number_planes': count}
values = numpy.fromfile(fd, byte_order+'I', 6*count)
result['z_distance'] = values[0::6] // values[1::6]
#result['date_created'] = tuple(values[2::6])
#res... | python | def read_mm_uic2(fd, byte_order, dtype, count):
"""Read MM_UIC2 tag from file and return as dictionary."""
result = {'number_planes': count}
values = numpy.fromfile(fd, byte_order+'I', 6*count)
result['z_distance'] = values[0::6] // values[1::6]
#result['date_created'] = tuple(values[2::6])
#res... | [
"def",
"read_mm_uic2",
"(",
"fd",
",",
"byte_order",
",",
"dtype",
",",
"count",
")",
":",
"result",
"=",
"{",
"'number_planes'",
":",
"count",
"}",
"values",
"=",
"numpy",
".",
"fromfile",
"(",
"fd",
",",
"byte_order",
"+",
"'I'",
",",
"6",
"*",
"co... | Read MM_UIC2 tag from file and return as dictionary. | [
"Read",
"MM_UIC2",
"tag",
"from",
"file",
"and",
"return",
"as",
"dictionary",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1422-L1431 |
44,159 | newville/wxmplot | examples/tifffile.py | read_mm_uic3 | def read_mm_uic3(fd, byte_order, dtype, count):
"""Read MM_UIC3 tag from file and return as dictionary."""
t = numpy.fromfile(fd, byte_order+'I', 2*count)
return {'wavelengths': t[0::2] // t[1::2]} | python | def read_mm_uic3(fd, byte_order, dtype, count):
"""Read MM_UIC3 tag from file and return as dictionary."""
t = numpy.fromfile(fd, byte_order+'I', 2*count)
return {'wavelengths': t[0::2] // t[1::2]} | [
"def",
"read_mm_uic3",
"(",
"fd",
",",
"byte_order",
",",
"dtype",
",",
"count",
")",
":",
"t",
"=",
"numpy",
".",
"fromfile",
"(",
"fd",
",",
"byte_order",
"+",
"'I'",
",",
"2",
"*",
"count",
")",
"return",
"{",
"'wavelengths'",
":",
"t",
"[",
"0"... | Read MM_UIC3 tag from file and return as dictionary. | [
"Read",
"MM_UIC3",
"tag",
"from",
"file",
"and",
"return",
"as",
"dictionary",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1434-L1437 |
44,160 | newville/wxmplot | examples/tifffile.py | read_cz_lsm_info | def read_cz_lsm_info(fd, byte_order, dtype, count):
"""Read CS_LSM_INFO tag from file and return as numpy.rec.array."""
result = numpy.rec.fromfile(fd, CZ_LSM_INFO, 1,
byteorder=byte_order)[0]
{50350412: '1.3', 67127628: '2.0'}[result.magic_number] # validation
return re... | python | def read_cz_lsm_info(fd, byte_order, dtype, count):
"""Read CS_LSM_INFO tag from file and return as numpy.rec.array."""
result = numpy.rec.fromfile(fd, CZ_LSM_INFO, 1,
byteorder=byte_order)[0]
{50350412: '1.3', 67127628: '2.0'}[result.magic_number] # validation
return re... | [
"def",
"read_cz_lsm_info",
"(",
"fd",
",",
"byte_order",
",",
"dtype",
",",
"count",
")",
":",
"result",
"=",
"numpy",
".",
"rec",
".",
"fromfile",
"(",
"fd",
",",
"CZ_LSM_INFO",
",",
"1",
",",
"byteorder",
"=",
"byte_order",
")",
"[",
"0",
"]",
"{",... | Read CS_LSM_INFO tag from file and return as numpy.rec.array. | [
"Read",
"CS_LSM_INFO",
"tag",
"from",
"file",
"and",
"return",
"as",
"numpy",
".",
"rec",
".",
"array",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1447-L1452 |
44,161 | newville/wxmplot | examples/tifffile.py | read_cz_lsm_scan_info | def read_cz_lsm_scan_info(fd, byte_order):
"""Read LSM scan information from file and return as Record."""
block = Record()
blocks = [block]
unpack = struct.unpack
if 0x10000000 != struct.unpack(byte_order+"I", fd.read(4))[0]:
raise ValueError("not a lsm_scan_info structure")
fd.read(8)
... | python | def read_cz_lsm_scan_info(fd, byte_order):
"""Read LSM scan information from file and return as Record."""
block = Record()
blocks = [block]
unpack = struct.unpack
if 0x10000000 != struct.unpack(byte_order+"I", fd.read(4))[0]:
raise ValueError("not a lsm_scan_info structure")
fd.read(8)
... | [
"def",
"read_cz_lsm_scan_info",
"(",
"fd",
",",
"byte_order",
")",
":",
"block",
"=",
"Record",
"(",
")",
"blocks",
"=",
"[",
"block",
"]",
"unpack",
"=",
"struct",
".",
"unpack",
"if",
"0x10000000",
"!=",
"struct",
".",
"unpack",
"(",
"byte_order",
"+",... | Read LSM scan information from file and return as Record. | [
"Read",
"LSM",
"scan",
"information",
"from",
"file",
"and",
"return",
"as",
"Record",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1476-L1514 |
44,162 | newville/wxmplot | examples/tifffile.py | _replace_by | def _replace_by(module_function, warn=False):
"""Try replace decorated function by module.function."""
def decorate(func, module_function=module_function, warn=warn):
sys.path.append(os.path.dirname(__file__))
try:
module, function = module_function.split('.')
func, oldfu... | python | def _replace_by(module_function, warn=False):
"""Try replace decorated function by module.function."""
def decorate(func, module_function=module_function, warn=warn):
sys.path.append(os.path.dirname(__file__))
try:
module, function = module_function.split('.')
func, oldfu... | [
"def",
"_replace_by",
"(",
"module_function",
",",
"warn",
"=",
"False",
")",
":",
"def",
"decorate",
"(",
"func",
",",
"module_function",
"=",
"module_function",
",",
"warn",
"=",
"warn",
")",
":",
"sys",
".",
"path",
".",
"append",
"(",
"os",
".",
"p... | Try replace decorated function by module.function. | [
"Try",
"replace",
"decorated",
"function",
"by",
"module",
".",
"function",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1517-L1531 |
44,163 | newville/wxmplot | examples/tifffile.py | decodepackbits | def decodepackbits(encoded):
"""Decompress PackBits encoded byte string.
PackBits is a simple byte-oriented run-length compression scheme.
"""
func = ord if sys.version[0] == '2' else lambda x: x
result = []
i = 0
try:
while True:
n = func(encoded[i]) + 1
i ... | python | def decodepackbits(encoded):
"""Decompress PackBits encoded byte string.
PackBits is a simple byte-oriented run-length compression scheme.
"""
func = ord if sys.version[0] == '2' else lambda x: x
result = []
i = 0
try:
while True:
n = func(encoded[i]) + 1
i ... | [
"def",
"decodepackbits",
"(",
"encoded",
")",
":",
"func",
"=",
"ord",
"if",
"sys",
".",
"version",
"[",
"0",
"]",
"==",
"'2'",
"else",
"lambda",
"x",
":",
"x",
"result",
"=",
"[",
"]",
"i",
"=",
"0",
"try",
":",
"while",
"True",
":",
"n",
"=",... | Decompress PackBits encoded byte string.
PackBits is a simple byte-oriented run-length compression scheme. | [
"Decompress",
"PackBits",
"encoded",
"byte",
"string",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1535-L1556 |
44,164 | newville/wxmplot | examples/tifffile.py | unpackints | def unpackints(data, dtype, itemsize, runlen=0):
"""Decompress byte string to array of integers of any bit size <= 32.
Parameters
----------
data : byte str
Data to decompress.
dtype : numpy.dtype or str
A numpy boolean or integer type.
itemsize : int
Number of bits per ... | python | def unpackints(data, dtype, itemsize, runlen=0):
"""Decompress byte string to array of integers of any bit size <= 32.
Parameters
----------
data : byte str
Data to decompress.
dtype : numpy.dtype or str
A numpy boolean or integer type.
itemsize : int
Number of bits per ... | [
"def",
"unpackints",
"(",
"data",
",",
"dtype",
",",
"itemsize",
",",
"runlen",
"=",
"0",
")",
":",
"if",
"itemsize",
"==",
"1",
":",
"# bitarray",
"data",
"=",
"numpy",
".",
"fromstring",
"(",
"data",
",",
"'|B'",
")",
"data",
"=",
"numpy",
".",
"... | Decompress byte string to array of integers of any bit size <= 32.
Parameters
----------
data : byte str
Data to decompress.
dtype : numpy.dtype or str
A numpy boolean or integer type.
itemsize : int
Number of bits per integer.
runlen : int
Number of consecutive ... | [
"Decompress",
"byte",
"string",
"to",
"array",
"of",
"integers",
"of",
"any",
"bit",
"size",
"<",
"=",
"32",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1641-L1701 |
44,165 | newville/wxmplot | examples/tifffile.py | stripnull | def stripnull(string):
"""Return string truncated at first null character."""
i = string.find(b'\x00')
return string if (i < 0) else string[:i] | python | def stripnull(string):
"""Return string truncated at first null character."""
i = string.find(b'\x00')
return string if (i < 0) else string[:i] | [
"def",
"stripnull",
"(",
"string",
")",
":",
"i",
"=",
"string",
".",
"find",
"(",
"b'\\x00'",
")",
"return",
"string",
"if",
"(",
"i",
"<",
"0",
")",
"else",
"string",
"[",
":",
"i",
"]"
] | Return string truncated at first null character. | [
"Return",
"string",
"truncated",
"at",
"first",
"null",
"character",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1788-L1791 |
44,166 | newville/wxmplot | examples/tifffile.py | TIFFfile._fromfile | def _fromfile(self):
"""Read TIFF header and all page records from file."""
self._fd.seek(0)
try:
self.byte_order = {b'II': '<', b'MM': '>'}[self._fd.read(2)]
except KeyError:
raise ValueError("not a valid TIFF file")
version = struct.unpack(self.byte_orde... | python | def _fromfile(self):
"""Read TIFF header and all page records from file."""
self._fd.seek(0)
try:
self.byte_order = {b'II': '<', b'MM': '>'}[self._fd.read(2)]
except KeyError:
raise ValueError("not a valid TIFF file")
version = struct.unpack(self.byte_orde... | [
"def",
"_fromfile",
"(",
"self",
")",
":",
"self",
".",
"_fd",
".",
"seek",
"(",
"0",
")",
"try",
":",
"self",
".",
"byte_order",
"=",
"{",
"b'II'",
":",
"'<'",
",",
"b'MM'",
":",
"'>'",
"}",
"[",
"self",
".",
"_fd",
".",
"read",
"(",
"2",
")... | Read TIFF header and all page records from file. | [
"Read",
"TIFF",
"header",
"and",
"all",
"page",
"records",
"from",
"file",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L469-L494 |
44,167 | newville/wxmplot | examples/tifffile.py | TIFFfile.asarray | def asarray(self, key=None, series=None):
"""Return image data of multiple TIFF pages as numpy array.
By default the first image series is returned.
Parameters
----------
key : int, slice, or sequence of page indices
Defines which pages to return as array.
s... | python | def asarray(self, key=None, series=None):
"""Return image data of multiple TIFF pages as numpy array.
By default the first image series is returned.
Parameters
----------
key : int, slice, or sequence of page indices
Defines which pages to return as array.
s... | [
"def",
"asarray",
"(",
"self",
",",
"key",
"=",
"None",
",",
"series",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
"and",
"series",
"is",
"None",
":",
"series",
"=",
"0",
"if",
"series",
"is",
"not",
"None",
":",
"pages",
"=",
"self",
".",
... | Return image data of multiple TIFF pages as numpy array.
By default the first image series is returned.
Parameters
----------
key : int, slice, or sequence of page indices
Defines which pages to return as array.
series : int
Defines which series of pages... | [
"Return",
"image",
"data",
"of",
"multiple",
"TIFF",
"pages",
"as",
"numpy",
"array",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L563-L618 |
44,168 | newville/wxmplot | examples/tifffile.py | TIFFpage._fromfile | def _fromfile(self):
"""Read TIFF IFD structure and its tags from file.
File cursor must be at storage position of IFD offset and is left at
offset to next IFD.
Raises StopIteration if offset (first bytes read) is 0.
"""
fd = self.parent._fd
byte_order = self.p... | python | def _fromfile(self):
"""Read TIFF IFD structure and its tags from file.
File cursor must be at storage position of IFD offset and is left at
offset to next IFD.
Raises StopIteration if offset (first bytes read) is 0.
"""
fd = self.parent._fd
byte_order = self.p... | [
"def",
"_fromfile",
"(",
"self",
")",
":",
"fd",
"=",
"self",
".",
"parent",
".",
"_fd",
"byte_order",
"=",
"self",
".",
"parent",
".",
"byte_order",
"offset_size",
"=",
"self",
".",
"parent",
".",
"offset_size",
"fmt",
"=",
"{",
"4",
":",
"'I'",
","... | Read TIFF IFD structure and its tags from file.
File cursor must be at storage position of IFD offset and is left at
offset to next IFD.
Raises StopIteration if offset (first bytes read) is 0. | [
"Read",
"TIFF",
"IFD",
"structure",
"and",
"its",
"tags",
"from",
"file",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L825-L872 |
44,169 | newville/wxmplot | examples/tifffile.py | TIFFtag._fromdata | def _fromdata(self, code, dtype, count, value, name=None):
"""Initialize instance from arguments."""
self.code = int(code)
self.name = name if name else str(code)
self.dtype = TIFF_DATA_TYPES[dtype]
self.count = int(count)
self.value = value | python | def _fromdata(self, code, dtype, count, value, name=None):
"""Initialize instance from arguments."""
self.code = int(code)
self.name = name if name else str(code)
self.dtype = TIFF_DATA_TYPES[dtype]
self.count = int(count)
self.value = value | [
"def",
"_fromdata",
"(",
"self",
",",
"code",
",",
"dtype",
",",
"count",
",",
"value",
",",
"name",
"=",
"None",
")",
":",
"self",
".",
"code",
"=",
"int",
"(",
"code",
")",
"self",
".",
"name",
"=",
"name",
"if",
"name",
"else",
"str",
"(",
"... | Initialize instance from arguments. | [
"Initialize",
"instance",
"from",
"arguments",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1249-L1255 |
44,170 | newville/wxmplot | examples/tifffile.py | TIFFtag._fromfile | def _fromfile(self, parent):
"""Read tag structure from open file. Advance file cursor."""
fd = parent._fd
byte_order = parent.byte_order
self._offset = fd.tell()
self.value_offset = self._offset + parent.offset_size + 4
fmt, size = {4: ('HHI4s', 12), 8: ('HHQ8s', 20)}[... | python | def _fromfile(self, parent):
"""Read tag structure from open file. Advance file cursor."""
fd = parent._fd
byte_order = parent.byte_order
self._offset = fd.tell()
self.value_offset = self._offset + parent.offset_size + 4
fmt, size = {4: ('HHI4s', 12), 8: ('HHQ8s', 20)}[... | [
"def",
"_fromfile",
"(",
"self",
",",
"parent",
")",
":",
"fd",
"=",
"parent",
".",
"_fd",
"byte_order",
"=",
"parent",
".",
"byte_order",
"self",
".",
"_offset",
"=",
"fd",
".",
"tell",
"(",
")",
"self",
".",
"value_offset",
"=",
"self",
".",
"_offs... | Read tag structure from open file. Advance file cursor. | [
"Read",
"tag",
"structure",
"from",
"open",
"file",
".",
"Advance",
"file",
"cursor",
"."
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1257-L1315 |
44,171 | newville/wxmplot | wxmplot/stackedplotframe.py | StackedPlotFrame.set_xylims | def set_xylims(self, lims, axes=None, panel='top', **kws):
"""set xy limits"""
panel = self.get_panel(panel)
# print("Stacked set_xylims ", panel, self.panel)
panel.set_xylims(lims, axes=axes, **kws) | python | def set_xylims(self, lims, axes=None, panel='top', **kws):
"""set xy limits"""
panel = self.get_panel(panel)
# print("Stacked set_xylims ", panel, self.panel)
panel.set_xylims(lims, axes=axes, **kws) | [
"def",
"set_xylims",
"(",
"self",
",",
"lims",
",",
"axes",
"=",
"None",
",",
"panel",
"=",
"'top'",
",",
"*",
"*",
"kws",
")",
":",
"panel",
"=",
"self",
".",
"get_panel",
"(",
"panel",
")",
"# print(\"Stacked set_xylims \", panel, self.panel)",
"panel",
... | set xy limits | [
"set",
"xy",
"limits"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/stackedplotframe.py#L74-L78 |
44,172 | newville/wxmplot | wxmplot/stackedplotframe.py | StackedPlotFrame.onThemeColor | def onThemeColor(self, color, item):
"""pass theme colors to bottom panel"""
bconf = self.panel_bot.conf
if item == 'grid':
bconf.set_gridcolor(color)
elif item == 'bg':
bconf.set_bgcolor(color)
elif item == 'frame':
bconf.set_framecolor(color)... | python | def onThemeColor(self, color, item):
"""pass theme colors to bottom panel"""
bconf = self.panel_bot.conf
if item == 'grid':
bconf.set_gridcolor(color)
elif item == 'bg':
bconf.set_bgcolor(color)
elif item == 'frame':
bconf.set_framecolor(color)... | [
"def",
"onThemeColor",
"(",
"self",
",",
"color",
",",
"item",
")",
":",
"bconf",
"=",
"self",
".",
"panel_bot",
".",
"conf",
"if",
"item",
"==",
"'grid'",
":",
"bconf",
".",
"set_gridcolor",
"(",
"color",
")",
"elif",
"item",
"==",
"'bg'",
":",
"bco... | pass theme colors to bottom panel | [
"pass",
"theme",
"colors",
"to",
"bottom",
"panel"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/stackedplotframe.py#L210-L221 |
44,173 | benhoff/pluginmanager | pluginmanager/entry_point_manager.py | EntryPointManager.add_entry_points | def add_entry_points(self, names):
"""
adds `names` to the internal collection of entry points to track
`names` can be a single object or an iterable but
must be a string or iterable of strings.
"""
names = util.return_set(names)
self.entry_point_names.update(nam... | python | def add_entry_points(self, names):
"""
adds `names` to the internal collection of entry points to track
`names` can be a single object or an iterable but
must be a string or iterable of strings.
"""
names = util.return_set(names)
self.entry_point_names.update(nam... | [
"def",
"add_entry_points",
"(",
"self",
",",
"names",
")",
":",
"names",
"=",
"util",
".",
"return_set",
"(",
"names",
")",
"self",
".",
"entry_point_names",
".",
"update",
"(",
"names",
")"
] | adds `names` to the internal collection of entry points to track
`names` can be a single object or an iterable but
must be a string or iterable of strings. | [
"adds",
"names",
"to",
"the",
"internal",
"collection",
"of",
"entry",
"points",
"to",
"track"
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/entry_point_manager.py#L18-L26 |
44,174 | benhoff/pluginmanager | pluginmanager/entry_point_manager.py | EntryPointManager.set_entry_points | def set_entry_points(self, names):
"""
sets the internal collection of entry points to be
equal to `names`
`names` can be a single object or an iterable but
must be a string or iterable of strings.
"""
names = util.return_set(names)
self.entry_point_names... | python | def set_entry_points(self, names):
"""
sets the internal collection of entry points to be
equal to `names`
`names` can be a single object or an iterable but
must be a string or iterable of strings.
"""
names = util.return_set(names)
self.entry_point_names... | [
"def",
"set_entry_points",
"(",
"self",
",",
"names",
")",
":",
"names",
"=",
"util",
".",
"return_set",
"(",
"names",
")",
"self",
".",
"entry_point_names",
"=",
"names"
] | sets the internal collection of entry points to be
equal to `names`
`names` can be a single object or an iterable but
must be a string or iterable of strings. | [
"sets",
"the",
"internal",
"collection",
"of",
"entry",
"points",
"to",
"be",
"equal",
"to",
"names"
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/entry_point_manager.py#L28-L37 |
44,175 | benhoff/pluginmanager | pluginmanager/entry_point_manager.py | EntryPointManager.remove_entry_points | def remove_entry_points(self, names):
"""
removes `names` from the set of entry points to track.
`names` can be a single object or an iterable.
"""
names = util.return_set(names)
util.remove_from_set(self.entry_point_names,
names) | python | def remove_entry_points(self, names):
"""
removes `names` from the set of entry points to track.
`names` can be a single object or an iterable.
"""
names = util.return_set(names)
util.remove_from_set(self.entry_point_names,
names) | [
"def",
"remove_entry_points",
"(",
"self",
",",
"names",
")",
":",
"names",
"=",
"util",
".",
"return_set",
"(",
"names",
")",
"util",
".",
"remove_from_set",
"(",
"self",
".",
"entry_point_names",
",",
"names",
")"
] | removes `names` from the set of entry points to track.
`names` can be a single object or an iterable. | [
"removes",
"names",
"from",
"the",
"set",
"of",
"entry",
"points",
"to",
"track",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/entry_point_manager.py#L39-L47 |
44,176 | benhoff/pluginmanager | pluginmanager/util.py | to_absolute_paths | def to_absolute_paths(paths):
"""
helper method to change `paths` to absolute paths.
Returns a `set` object
`paths` can be either a single object or iterable
"""
abspath = os.path.abspath
paths = return_set(paths)
absolute_paths = {abspath(x) for x in paths}
return absolute_paths | python | def to_absolute_paths(paths):
"""
helper method to change `paths` to absolute paths.
Returns a `set` object
`paths` can be either a single object or iterable
"""
abspath = os.path.abspath
paths = return_set(paths)
absolute_paths = {abspath(x) for x in paths}
return absolute_paths | [
"def",
"to_absolute_paths",
"(",
"paths",
")",
":",
"abspath",
"=",
"os",
".",
"path",
".",
"abspath",
"paths",
"=",
"return_set",
"(",
"paths",
")",
"absolute_paths",
"=",
"{",
"abspath",
"(",
"x",
")",
"for",
"x",
"in",
"paths",
"}",
"return",
"absol... | helper method to change `paths` to absolute paths.
Returns a `set` object
`paths` can be either a single object or iterable | [
"helper",
"method",
"to",
"change",
"paths",
"to",
"absolute",
"paths",
".",
"Returns",
"a",
"set",
"object",
"paths",
"can",
"be",
"either",
"a",
"single",
"object",
"or",
"iterable"
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/util.py#L5-L14 |
44,177 | newville/wxmplot | wxmplot/config.py | LineProperties.update | def update(self, line=None):
""" set a matplotlib Line2D to have the current properties"""
if line:
markercolor = self.markercolor
if markercolor is None: markercolor=self.color
# self.set_markeredgecolor(markercolor, line=line)
# self.set_markerfacecolor(... | python | def update(self, line=None):
""" set a matplotlib Line2D to have the current properties"""
if line:
markercolor = self.markercolor
if markercolor is None: markercolor=self.color
# self.set_markeredgecolor(markercolor, line=line)
# self.set_markerfacecolor(... | [
"def",
"update",
"(",
"self",
",",
"line",
"=",
"None",
")",
":",
"if",
"line",
":",
"markercolor",
"=",
"self",
".",
"markercolor",
"if",
"markercolor",
"is",
"None",
":",
"markercolor",
"=",
"self",
".",
"color",
"# self.set_markeredgecolor(markercolor, line... | set a matplotlib Line2D to have the current properties | [
"set",
"a",
"matplotlib",
"Line2D",
"to",
"have",
"the",
"current",
"properties"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/config.py#L102-L116 |
44,178 | newville/wxmplot | wxmplot/config.py | PlotConfig._init_trace | def _init_trace(self, n, color, style,
linewidth=2.5, zorder=None, marker=None, markersize=6):
""" used for building set of traces"""
while n >= len(self.traces):
self.traces.append(LineProperties())
line = self.traces[n]
label = "trace %i" % (n+1)
... | python | def _init_trace(self, n, color, style,
linewidth=2.5, zorder=None, marker=None, markersize=6):
""" used for building set of traces"""
while n >= len(self.traces):
self.traces.append(LineProperties())
line = self.traces[n]
label = "trace %i" % (n+1)
... | [
"def",
"_init_trace",
"(",
"self",
",",
"n",
",",
"color",
",",
"style",
",",
"linewidth",
"=",
"2.5",
",",
"zorder",
"=",
"None",
",",
"marker",
"=",
"None",
",",
"markersize",
"=",
"6",
")",
":",
"while",
"n",
">=",
"len",
"(",
"self",
".",
"tr... | used for building set of traces | [
"used",
"for",
"building",
"set",
"of",
"traces"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/config.py#L306-L323 |
44,179 | newville/wxmplot | wxmplot/config.py | PlotConfig.set_gridcolor | def set_gridcolor(self, color):
"""set color for grid"""
self.gridcolor = color
for ax in self.canvas.figure.get_axes():
for i in ax.get_xgridlines()+ax.get_ygridlines():
i.set_color(color)
i.set_zorder(-1)
if callable(self.theme_color_callback... | python | def set_gridcolor(self, color):
"""set color for grid"""
self.gridcolor = color
for ax in self.canvas.figure.get_axes():
for i in ax.get_xgridlines()+ax.get_ygridlines():
i.set_color(color)
i.set_zorder(-1)
if callable(self.theme_color_callback... | [
"def",
"set_gridcolor",
"(",
"self",
",",
"color",
")",
":",
"self",
".",
"gridcolor",
"=",
"color",
"for",
"ax",
"in",
"self",
".",
"canvas",
".",
"figure",
".",
"get_axes",
"(",
")",
":",
"for",
"i",
"in",
"ax",
".",
"get_xgridlines",
"(",
")",
"... | set color for grid | [
"set",
"color",
"for",
"grid"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/config.py#L401-L409 |
44,180 | newville/wxmplot | wxmplot/config.py | PlotConfig.set_bgcolor | def set_bgcolor(self, color):
"""set color for background of plot"""
self.bgcolor = color
for ax in self.canvas.figure.get_axes():
if matplotlib.__version__ < '2.0':
ax.set_axis_bgcolor(color)
else:
ax.set_facecolor(color)
if callab... | python | def set_bgcolor(self, color):
"""set color for background of plot"""
self.bgcolor = color
for ax in self.canvas.figure.get_axes():
if matplotlib.__version__ < '2.0':
ax.set_axis_bgcolor(color)
else:
ax.set_facecolor(color)
if callab... | [
"def",
"set_bgcolor",
"(",
"self",
",",
"color",
")",
":",
"self",
".",
"bgcolor",
"=",
"color",
"for",
"ax",
"in",
"self",
".",
"canvas",
".",
"figure",
".",
"get_axes",
"(",
")",
":",
"if",
"matplotlib",
".",
"__version__",
"<",
"'2.0'",
":",
"ax",... | set color for background of plot | [
"set",
"color",
"for",
"background",
"of",
"plot"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/config.py#L412-L421 |
44,181 | newville/wxmplot | wxmplot/config.py | PlotConfig.set_framecolor | def set_framecolor(self, color):
"""set color for outer frame"""
self.framecolor = color
self.canvas.figure.set_facecolor(color)
if callable(self.theme_color_callback):
self.theme_color_callback(color, 'frame') | python | def set_framecolor(self, color):
"""set color for outer frame"""
self.framecolor = color
self.canvas.figure.set_facecolor(color)
if callable(self.theme_color_callback):
self.theme_color_callback(color, 'frame') | [
"def",
"set_framecolor",
"(",
"self",
",",
"color",
")",
":",
"self",
".",
"framecolor",
"=",
"color",
"self",
".",
"canvas",
".",
"figure",
".",
"set_facecolor",
"(",
"color",
")",
"if",
"callable",
"(",
"self",
".",
"theme_color_callback",
")",
":",
"s... | set color for outer frame | [
"set",
"color",
"for",
"outer",
"frame"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/config.py#L423-L428 |
44,182 | newville/wxmplot | wxmplot/config.py | PlotConfig.set_textcolor | def set_textcolor(self, color):
"""set color for labels and axis text"""
self.textcolor = color
self.relabel()
if callable(self.theme_color_callback):
self.theme_color_callback(color, 'text') | python | def set_textcolor(self, color):
"""set color for labels and axis text"""
self.textcolor = color
self.relabel()
if callable(self.theme_color_callback):
self.theme_color_callback(color, 'text') | [
"def",
"set_textcolor",
"(",
"self",
",",
"color",
")",
":",
"self",
".",
"textcolor",
"=",
"color",
"self",
".",
"relabel",
"(",
")",
"if",
"callable",
"(",
"self",
".",
"theme_color_callback",
")",
":",
"self",
".",
"theme_color_callback",
"(",
"color",
... | set color for labels and axis text | [
"set",
"color",
"for",
"labels",
"and",
"axis",
"text"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/config.py#L430-L435 |
44,183 | newville/wxmplot | wxmplot/config.py | PlotConfig.draw_legend | def draw_legend(self, show=None, auto_location=True, delay_draw=False):
"redraw the legend"
if show is not None:
self.show_legend = show
axes = self.canvas.figure.get_axes()
# clear existing legend
try:
lgn = self.mpl_legend
if lgn:
... | python | def draw_legend(self, show=None, auto_location=True, delay_draw=False):
"redraw the legend"
if show is not None:
self.show_legend = show
axes = self.canvas.figure.get_axes()
# clear existing legend
try:
lgn = self.mpl_legend
if lgn:
... | [
"def",
"draw_legend",
"(",
"self",
",",
"show",
"=",
"None",
",",
"auto_location",
"=",
"True",
",",
"delay_draw",
"=",
"False",
")",
":",
"if",
"show",
"is",
"not",
"None",
":",
"self",
".",
"show_legend",
"=",
"show",
"axes",
"=",
"self",
".",
"can... | redraw the legend | [
"redraw",
"the",
"legend"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/config.py#L565-L632 |
44,184 | newville/wxmplot | wxmplot/config.py | PlotConfig.set_legend_location | def set_legend_location(self, loc, onaxis):
"set legend location"
self.legend_onaxis = 'on plot'
if not onaxis:
self.legend_onaxis = 'off plot'
if loc == 'best':
loc = 'upper right'
if loc in self.legend_abbrevs:
loc = self.legend_abbre... | python | def set_legend_location(self, loc, onaxis):
"set legend location"
self.legend_onaxis = 'on plot'
if not onaxis:
self.legend_onaxis = 'off plot'
if loc == 'best':
loc = 'upper right'
if loc in self.legend_abbrevs:
loc = self.legend_abbre... | [
"def",
"set_legend_location",
"(",
"self",
",",
"loc",
",",
"onaxis",
")",
":",
"self",
".",
"legend_onaxis",
"=",
"'on plot'",
"if",
"not",
"onaxis",
":",
"self",
".",
"legend_onaxis",
"=",
"'off plot'",
"if",
"loc",
"==",
"'best'",
":",
"loc",
"=",
"'u... | set legend location | [
"set",
"legend",
"location"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/config.py#L634-L644 |
44,185 | newville/wxmplot | wxmplot/config.py | PlotConfig.unzoom | def unzoom(self, full=False, delay_draw=False):
"""unzoom display 1 level or all the way"""
if full:
self.zoom_lims = self.zoom_lims[:1]
self.zoom_lims = []
elif len(self.zoom_lims) > 0:
self.zoom_lims.pop()
self.set_viewlimits()
if not delay_d... | python | def unzoom(self, full=False, delay_draw=False):
"""unzoom display 1 level or all the way"""
if full:
self.zoom_lims = self.zoom_lims[:1]
self.zoom_lims = []
elif len(self.zoom_lims) > 0:
self.zoom_lims.pop()
self.set_viewlimits()
if not delay_d... | [
"def",
"unzoom",
"(",
"self",
",",
"full",
"=",
"False",
",",
"delay_draw",
"=",
"False",
")",
":",
"if",
"full",
":",
"self",
".",
"zoom_lims",
"=",
"self",
".",
"zoom_lims",
"[",
":",
"1",
"]",
"self",
".",
"zoom_lims",
"=",
"[",
"]",
"elif",
"... | unzoom display 1 level or all the way | [
"unzoom",
"display",
"1",
"level",
"or",
"all",
"the",
"way"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/config.py#L676-L685 |
44,186 | newville/wxmplot | wxmplot/plotframe.py | PlotFrame.add_text | def add_text(self, text, x, y, **kws):
"""add text to plot"""
self.panel.add_text(text, x, y, **kws) | python | def add_text(self, text, x, y, **kws):
"""add text to plot"""
self.panel.add_text(text, x, y, **kws) | [
"def",
"add_text",
"(",
"self",
",",
"text",
",",
"x",
",",
"y",
",",
"*",
"*",
"kws",
")",
":",
"self",
".",
"panel",
".",
"add_text",
"(",
"text",
",",
"x",
",",
"y",
",",
"*",
"*",
"kws",
")"
] | add text to plot | [
"add",
"text",
"to",
"plot"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/plotframe.py#L26-L28 |
44,187 | newville/wxmplot | wxmplot/plotframe.py | PlotFrame.add_arrow | def add_arrow(self, x1, y1, x2, y2, **kws):
"""add arrow to plot"""
self.panel.add_arrow(x1, y1, x2, y2, **kws) | python | def add_arrow(self, x1, y1, x2, y2, **kws):
"""add arrow to plot"""
self.panel.add_arrow(x1, y1, x2, y2, **kws) | [
"def",
"add_arrow",
"(",
"self",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"*",
"*",
"kws",
")",
":",
"self",
".",
"panel",
".",
"add_arrow",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"*",
"*",
"kws",
")"
] | add arrow to plot | [
"add",
"arrow",
"to",
"plot"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/plotframe.py#L30-L32 |
44,188 | newville/wxmplot | wxmplot/plotframe.py | PlotFrame.ExportTextFile | def ExportTextFile(self, fname, title='unknown plot'):
"save plot data to external file"
buff = ["# Plot Data for %s" % title,
"#---------------------------------"]
out = []
labels = []
itrace = 0
for ax in self.panel.fig.get_axes():
for line... | python | def ExportTextFile(self, fname, title='unknown plot'):
"save plot data to external file"
buff = ["# Plot Data for %s" % title,
"#---------------------------------"]
out = []
labels = []
itrace = 0
for ax in self.panel.fig.get_axes():
for line... | [
"def",
"ExportTextFile",
"(",
"self",
",",
"fname",
",",
"title",
"=",
"'unknown plot'",
")",
":",
"buff",
"=",
"[",
"\"# Plot Data for %s\"",
"%",
"title",
",",
"\"#---------------------------------\"",
"]",
"out",
"=",
"[",
"]",
"labels",
"=",
"[",
"]",
"i... | save plot data to external file | [
"save",
"plot",
"data",
"to",
"external",
"file"
] | 8e0dc037453e5cdf18c968dc5a3d29efd761edee | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/plotframe.py#L64-L108 |
44,189 | benhoff/pluginmanager | pluginmanager/plugin_interface.py | PluginInterface.add_plugin_filepaths | def add_plugin_filepaths(self, filepaths, except_blacklisted=True):
"""
Adds `filepaths` to internal state. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an iterable
... | python | def add_plugin_filepaths(self, filepaths, except_blacklisted=True):
"""
Adds `filepaths` to internal state. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an iterable
... | [
"def",
"add_plugin_filepaths",
"(",
"self",
",",
"filepaths",
",",
"except_blacklisted",
"=",
"True",
")",
":",
"self",
".",
"file_manager",
".",
"add_plugin_filepaths",
"(",
"filepaths",
",",
"except_blacklisted",
")"
] | Adds `filepaths` to internal state. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an iterable
If `except_blacklisted` is `True`, all `filepaths` that
have been blacklisted... | [
"Adds",
"filepaths",
"to",
"internal",
"state",
".",
"Recommend",
"passing",
"in",
"absolute",
"filepaths",
".",
"Method",
"will",
"attempt",
"to",
"convert",
"to",
"absolute",
"paths",
"if",
"they",
"are",
"not",
"already",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/plugin_interface.py#L214-L226 |
44,190 | benhoff/pluginmanager | pluginmanager/plugin_interface.py | PluginInterface.set_plugin_filepaths | def set_plugin_filepaths(self, filepaths, except_blacklisted=True):
"""
Sets internal state to `filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an iterable.
... | python | def set_plugin_filepaths(self, filepaths, except_blacklisted=True):
"""
Sets internal state to `filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an iterable.
... | [
"def",
"set_plugin_filepaths",
"(",
"self",
",",
"filepaths",
",",
"except_blacklisted",
"=",
"True",
")",
":",
"self",
".",
"file_manager",
".",
"set_plugin_filepaths",
"(",
"filepaths",
",",
"except_blacklisted",
")"
] | Sets internal state to `filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an iterable.
If `except_blacklisted` is `True`, all `filepaths` that
have been blackliste... | [
"Sets",
"internal",
"state",
"to",
"filepaths",
".",
"Recommend",
"passing",
"in",
"absolute",
"filepaths",
".",
"Method",
"will",
"attempt",
"to",
"convert",
"to",
"absolute",
"paths",
"if",
"they",
"are",
"not",
"already",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/plugin_interface.py#L244-L256 |
44,191 | benhoff/pluginmanager | pluginmanager/plugin_interface.py | PluginInterface.add_blacklisted_filepaths | def add_blacklisted_filepaths(self, filepaths, remove_from_stored=True):
"""
Add `filepaths` to blacklisted filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
internal state will be automatically removed.
"""
self.file_manager.add_blacklisted_filepaths(filep... | python | def add_blacklisted_filepaths(self, filepaths, remove_from_stored=True):
"""
Add `filepaths` to blacklisted filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
internal state will be automatically removed.
"""
self.file_manager.add_blacklisted_filepaths(filep... | [
"def",
"add_blacklisted_filepaths",
"(",
"self",
",",
"filepaths",
",",
"remove_from_stored",
"=",
"True",
")",
":",
"self",
".",
"file_manager",
".",
"add_blacklisted_filepaths",
"(",
"filepaths",
",",
"remove_from_stored",
")"
] | Add `filepaths` to blacklisted filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
internal state will be automatically removed. | [
"Add",
"filepaths",
"to",
"blacklisted",
"filepaths",
".",
"If",
"remove_from_stored",
"is",
"True",
"any",
"filepaths",
"in",
"internal",
"state",
"will",
"be",
"automatically",
"removed",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/plugin_interface.py#L411-L418 |
44,192 | benhoff/pluginmanager | pluginmanager/file_manager.py | FileManager.collect_filepaths | def collect_filepaths(self, directories):
"""
Collects and returns every filepath from each directory in
`directories` that is filtered through the `file_filters`.
If no `file_filters` are present, passes every file in directory
as a result.
Always returns a `set` object
... | python | def collect_filepaths(self, directories):
"""
Collects and returns every filepath from each directory in
`directories` that is filtered through the `file_filters`.
If no `file_filters` are present, passes every file in directory
as a result.
Always returns a `set` object
... | [
"def",
"collect_filepaths",
"(",
"self",
",",
"directories",
")",
":",
"plugin_filepaths",
"=",
"set",
"(",
")",
"directories",
"=",
"util",
".",
"to_absolute_paths",
"(",
"directories",
")",
"for",
"directory",
"in",
"directories",
":",
"filepaths",
"=",
"uti... | Collects and returns every filepath from each directory in
`directories` that is filtered through the `file_filters`.
If no `file_filters` are present, passes every file in directory
as a result.
Always returns a `set` object
`directories` can be a object or an iterable. Recomme... | [
"Collects",
"and",
"returns",
"every",
"filepath",
"from",
"each",
"directory",
"in",
"directories",
"that",
"is",
"filtered",
"through",
"the",
"file_filters",
".",
"If",
"no",
"file_filters",
"are",
"present",
"passes",
"every",
"file",
"in",
"directory",
"as"... | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/file_manager.py#L53-L73 |
44,193 | benhoff/pluginmanager | pluginmanager/file_manager.py | FileManager.add_plugin_filepaths | def add_plugin_filepaths(self, filepaths, except_blacklisted=True):
"""
Adds `filepaths` to the `self.plugin_filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an it... | python | def add_plugin_filepaths(self, filepaths, except_blacklisted=True):
"""
Adds `filepaths` to the `self.plugin_filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an it... | [
"def",
"add_plugin_filepaths",
"(",
"self",
",",
"filepaths",
",",
"except_blacklisted",
"=",
"True",
")",
":",
"filepaths",
"=",
"util",
".",
"to_absolute_paths",
"(",
"filepaths",
")",
"if",
"except_blacklisted",
":",
"filepaths",
"=",
"util",
".",
"remove_fro... | Adds `filepaths` to the `self.plugin_filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an iterable
If `except_blacklisted` is `True`, all `filepaths` that
have bee... | [
"Adds",
"filepaths",
"to",
"the",
"self",
".",
"plugin_filepaths",
".",
"Recommend",
"passing",
"in",
"absolute",
"filepaths",
".",
"Method",
"will",
"attempt",
"to",
"convert",
"to",
"absolute",
"paths",
"if",
"they",
"are",
"not",
"already",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/file_manager.py#L75-L91 |
44,194 | benhoff/pluginmanager | pluginmanager/file_manager.py | FileManager.set_plugin_filepaths | def set_plugin_filepaths(self, filepaths, except_blacklisted=True):
"""
Sets `filepaths` to the `self.plugin_filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an it... | python | def set_plugin_filepaths(self, filepaths, except_blacklisted=True):
"""
Sets `filepaths` to the `self.plugin_filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an it... | [
"def",
"set_plugin_filepaths",
"(",
"self",
",",
"filepaths",
",",
"except_blacklisted",
"=",
"True",
")",
":",
"filepaths",
"=",
"util",
".",
"to_absolute_paths",
"(",
"filepaths",
")",
"if",
"except_blacklisted",
":",
"filepaths",
"=",
"util",
".",
"remove_fro... | Sets `filepaths` to the `self.plugin_filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an iterable.
If `except_blacklisted` is `True`, all `filepaths` that
have be... | [
"Sets",
"filepaths",
"to",
"the",
"self",
".",
"plugin_filepaths",
".",
"Recommend",
"passing",
"in",
"absolute",
"filepaths",
".",
"Method",
"will",
"attempt",
"to",
"convert",
"to",
"absolute",
"paths",
"if",
"they",
"are",
"not",
"already",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/file_manager.py#L93-L109 |
44,195 | benhoff/pluginmanager | pluginmanager/file_manager.py | FileManager.remove_plugin_filepaths | def remove_plugin_filepaths(self, filepaths):
"""
Removes `filepaths` from `self.plugin_filepaths`.
Recommend passing in absolute filepaths. Method will
attempt to convert to absolute paths if not passed in.
`filepaths` can be a single object or an iterable.
"""
... | python | def remove_plugin_filepaths(self, filepaths):
"""
Removes `filepaths` from `self.plugin_filepaths`.
Recommend passing in absolute filepaths. Method will
attempt to convert to absolute paths if not passed in.
`filepaths` can be a single object or an iterable.
"""
... | [
"def",
"remove_plugin_filepaths",
"(",
"self",
",",
"filepaths",
")",
":",
"filepaths",
"=",
"util",
".",
"to_absolute_paths",
"(",
"filepaths",
")",
"self",
".",
"plugin_filepaths",
"=",
"util",
".",
"remove_from_set",
"(",
"self",
".",
"plugin_filepaths",
",",... | Removes `filepaths` from `self.plugin_filepaths`.
Recommend passing in absolute filepaths. Method will
attempt to convert to absolute paths if not passed in.
`filepaths` can be a single object or an iterable. | [
"Removes",
"filepaths",
"from",
"self",
".",
"plugin_filepaths",
".",
"Recommend",
"passing",
"in",
"absolute",
"filepaths",
".",
"Method",
"will",
"attempt",
"to",
"convert",
"to",
"absolute",
"paths",
"if",
"not",
"passed",
"in",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/file_manager.py#L111-L121 |
44,196 | benhoff/pluginmanager | pluginmanager/file_manager.py | FileManager.set_file_filters | def set_file_filters(self, file_filters):
"""
Sets internal file filters to `file_filters` by tossing old state.
`file_filters` can be single object or iterable.
"""
file_filters = util.return_list(file_filters)
self.file_filters = file_filters | python | def set_file_filters(self, file_filters):
"""
Sets internal file filters to `file_filters` by tossing old state.
`file_filters` can be single object or iterable.
"""
file_filters = util.return_list(file_filters)
self.file_filters = file_filters | [
"def",
"set_file_filters",
"(",
"self",
",",
"file_filters",
")",
":",
"file_filters",
"=",
"util",
".",
"return_list",
"(",
"file_filters",
")",
"self",
".",
"file_filters",
"=",
"file_filters"
] | Sets internal file filters to `file_filters` by tossing old state.
`file_filters` can be single object or iterable. | [
"Sets",
"internal",
"file",
"filters",
"to",
"file_filters",
"by",
"tossing",
"old",
"state",
".",
"file_filters",
"can",
"be",
"single",
"object",
"or",
"iterable",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/file_manager.py#L129-L135 |
44,197 | benhoff/pluginmanager | pluginmanager/file_manager.py | FileManager.add_file_filters | def add_file_filters(self, file_filters):
"""
Adds `file_filters` to the internal file filters.
`file_filters` can be single object or iterable.
"""
file_filters = util.return_list(file_filters)
self.file_filters.extend(file_filters) | python | def add_file_filters(self, file_filters):
"""
Adds `file_filters` to the internal file filters.
`file_filters` can be single object or iterable.
"""
file_filters = util.return_list(file_filters)
self.file_filters.extend(file_filters) | [
"def",
"add_file_filters",
"(",
"self",
",",
"file_filters",
")",
":",
"file_filters",
"=",
"util",
".",
"return_list",
"(",
"file_filters",
")",
"self",
".",
"file_filters",
".",
"extend",
"(",
"file_filters",
")"
] | Adds `file_filters` to the internal file filters.
`file_filters` can be single object or iterable. | [
"Adds",
"file_filters",
"to",
"the",
"internal",
"file",
"filters",
".",
"file_filters",
"can",
"be",
"single",
"object",
"or",
"iterable",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/file_manager.py#L137-L143 |
44,198 | benhoff/pluginmanager | pluginmanager/file_manager.py | FileManager.remove_file_filters | def remove_file_filters(self, file_filters):
"""
Removes the `file_filters` from the internal state.
`file_filters` can be a single object or an iterable.
"""
self.file_filters = util.remove_from_list(self.file_filters,
file_filte... | python | def remove_file_filters(self, file_filters):
"""
Removes the `file_filters` from the internal state.
`file_filters` can be a single object or an iterable.
"""
self.file_filters = util.remove_from_list(self.file_filters,
file_filte... | [
"def",
"remove_file_filters",
"(",
"self",
",",
"file_filters",
")",
":",
"self",
".",
"file_filters",
"=",
"util",
".",
"remove_from_list",
"(",
"self",
".",
"file_filters",
",",
"file_filters",
")"
] | Removes the `file_filters` from the internal state.
`file_filters` can be a single object or an iterable. | [
"Removes",
"the",
"file_filters",
"from",
"the",
"internal",
"state",
".",
"file_filters",
"can",
"be",
"a",
"single",
"object",
"or",
"an",
"iterable",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/file_manager.py#L145-L151 |
44,199 | benhoff/pluginmanager | pluginmanager/file_manager.py | FileManager.add_blacklisted_filepaths | def add_blacklisted_filepaths(self, filepaths, remove_from_stored=True):
"""
Add `filepaths` to blacklisted filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
`plugin_filepaths` will be automatically removed.
Recommend passing in absolute filepaths but method will ... | python | def add_blacklisted_filepaths(self, filepaths, remove_from_stored=True):
"""
Add `filepaths` to blacklisted filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
`plugin_filepaths` will be automatically removed.
Recommend passing in absolute filepaths but method will ... | [
"def",
"add_blacklisted_filepaths",
"(",
"self",
",",
"filepaths",
",",
"remove_from_stored",
"=",
"True",
")",
":",
"filepaths",
"=",
"util",
".",
"to_absolute_paths",
"(",
"filepaths",
")",
"self",
".",
"blacklisted_filepaths",
".",
"update",
"(",
"filepaths",
... | Add `filepaths` to blacklisted filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
`plugin_filepaths` will be automatically removed.
Recommend passing in absolute filepaths but method will attempt
to convert to absolute filepaths based on current working directory. | [
"Add",
"filepaths",
"to",
"blacklisted",
"filepaths",
".",
"If",
"remove_from_stored",
"is",
"True",
"any",
"filepaths",
"in",
"plugin_filepaths",
"will",
"be",
"automatically",
"removed",
"."
] | a8a184f9ebfbb521703492cb88c1dbda4cd04c06 | https://github.com/benhoff/pluginmanager/blob/a8a184f9ebfbb521703492cb88c1dbda4cd04c06/pluginmanager/file_manager.py#L164-L177 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.