repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
BertrandBordage/django-terms | terms/menu.py | TermsMenu.get_nodes | def get_nodes(self, request):
"""
This method is used to build the menu tree.
"""
nodes = []
for term in Term.objects.only('pk', 'name', 'url'):
try:
url = term.get_absolute_url()
except NoReverseMatch:
continue
... | python | def get_nodes(self, request):
"""
This method is used to build the menu tree.
"""
nodes = []
for term in Term.objects.only('pk', 'name', 'url'):
try:
url = term.get_absolute_url()
except NoReverseMatch:
continue
... | [
"def",
"get_nodes",
"(",
"self",
",",
"request",
")",
":",
"nodes",
"=",
"[",
"]",
"for",
"term",
"in",
"Term",
".",
"objects",
".",
"only",
"(",
"'pk'",
",",
"'name'",
",",
"'url'",
")",
":",
"try",
":",
"url",
"=",
"term",
".",
"get_absolute_url"... | This method is used to build the menu tree. | [
"This",
"method",
"is",
"used",
"to",
"build",
"the",
"menu",
"tree",
"."
] | 2555c2cf5abf14adef9a8e2dd22c4a9076396a10 | https://github.com/BertrandBordage/django-terms/blob/2555c2cf5abf14adef9a8e2dd22c4a9076396a10/terms/menu.py#L16-L32 | train | This method returns a list of NavigationNode objects that are used to build the menu tree. |
juju/theblues | theblues/charmstore.py | _get_path | def _get_path(entity_id):
'''Get the entity_id as a string if it is a Reference.
@param entity_id The ID either a reference or a string of the entity
to get.
@return entity_id as a string
'''
try:
path = entity_id.path()
except AttributeError:
path = entity_id
if p... | python | def _get_path(entity_id):
'''Get the entity_id as a string if it is a Reference.
@param entity_id The ID either a reference or a string of the entity
to get.
@return entity_id as a string
'''
try:
path = entity_id.path()
except AttributeError:
path = entity_id
if p... | [
"def",
"_get_path",
"(",
"entity_id",
")",
":",
"try",
":",
"path",
"=",
"entity_id",
".",
"path",
"(",
")",
"except",
"AttributeError",
":",
"path",
"=",
"entity_id",
"if",
"path",
".",
"startswith",
"(",
"'cs:'",
")",
":",
"path",
"=",
"path",
"[",
... | Get the entity_id as a string if it is a Reference.
@param entity_id The ID either a reference or a string of the entity
to get.
@return entity_id as a string | [
"Get",
"the",
"entity_id",
"as",
"a",
"string",
"if",
"it",
"is",
"a",
"Reference",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L482-L495 | train | Get the entity_id as a string if it is a Reference.
|
juju/theblues | theblues/charmstore.py | CharmStore._get | def _get(self, url):
"""Make a get request against the charmstore.
This method is used by other API methods to standardize querying.
@param url The full url to query
(e.g. https://api.jujucharms.com/charmstore/v4/macaroon)
"""
try:
response = requests.get... | python | def _get(self, url):
"""Make a get request against the charmstore.
This method is used by other API methods to standardize querying.
@param url The full url to query
(e.g. https://api.jujucharms.com/charmstore/v4/macaroon)
"""
try:
response = requests.get... | [
"def",
"_get",
"(",
"self",
",",
"url",
")",
":",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"verify",
"=",
"self",
".",
"verify",
",",
"cookies",
"=",
"self",
".",
"cookies",
",",
"timeout",
"=",
"self",
".",
"timeout",
... | Make a get request against the charmstore.
This method is used by other API methods to standardize querying.
@param url The full url to query
(e.g. https://api.jujucharms.com/charmstore/v4/macaroon) | [
"Make",
"a",
"get",
"request",
"against",
"the",
"charmstore",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L66-L106 | train | Make a get request against the charmstore. |
juju/theblues | theblues/charmstore.py | CharmStore._meta | def _meta(self, entity_id, includes, channel=None):
'''Retrieve metadata about an entity in the charmstore.
@param entity_id The ID either a reference or a string of the entity
to get.
@param includes Which metadata fields to include in the response.
@param channel Option... | python | def _meta(self, entity_id, includes, channel=None):
'''Retrieve metadata about an entity in the charmstore.
@param entity_id The ID either a reference or a string of the entity
to get.
@param includes Which metadata fields to include in the response.
@param channel Option... | [
"def",
"_meta",
"(",
"self",
",",
"entity_id",
",",
"includes",
",",
"channel",
"=",
"None",
")",
":",
"queries",
"=",
"[",
"]",
"if",
"includes",
"is",
"not",
"None",
":",
"queries",
".",
"extend",
"(",
"[",
"(",
"'include'",
",",
"include",
")",
... | Retrieve metadata about an entity in the charmstore.
@param entity_id The ID either a reference or a string of the entity
to get.
@param includes Which metadata fields to include in the response.
@param channel Optional channel name, e.g. `stable`. | [
"Retrieve",
"metadata",
"about",
"an",
"entity",
"in",
"the",
"charmstore",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L108-L127 | train | Retrieve metadata about an entity in the charmstore. |
juju/theblues | theblues/charmstore.py | CharmStore.entity | def entity(self, entity_id, get_files=False, channel=None,
include_stats=True, includes=None):
'''Get the default data for any entity (e.g. bundle or charm).
@param entity_id The entity's id either as a reference or a string
@param get_files Whether to fetch the files for the cha... | python | def entity(self, entity_id, get_files=False, channel=None,
include_stats=True, includes=None):
'''Get the default data for any entity (e.g. bundle or charm).
@param entity_id The entity's id either as a reference or a string
@param get_files Whether to fetch the files for the cha... | [
"def",
"entity",
"(",
"self",
",",
"entity_id",
",",
"get_files",
"=",
"False",
",",
"channel",
"=",
"None",
",",
"include_stats",
"=",
"True",
",",
"includes",
"=",
"None",
")",
":",
"if",
"includes",
"is",
"None",
":",
"includes",
"=",
"DEFAULT_INCLUDE... | Get the default data for any entity (e.g. bundle or charm).
@param entity_id The entity's id either as a reference or a string
@param get_files Whether to fetch the files for the charm or not.
@param channel Optional channel name.
@param include_stats Optionally disable stats collection... | [
"Get",
"the",
"default",
"data",
"for",
"any",
"entity",
"(",
"e",
".",
"g",
".",
"bundle",
"or",
"charm",
")",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L129-L146 | train | Get the default data for the given entity. |
juju/theblues | theblues/charmstore.py | CharmStore.entities | def entities(self, entity_ids):
'''Get the default data for entities.
@param entity_ids A list of entity ids either as strings or references.
'''
url = '%s/meta/any?include=id&' % self.url
for entity_id in entity_ids:
url += 'id=%s&' % _get_path(entity_id)
# ... | python | def entities(self, entity_ids):
'''Get the default data for entities.
@param entity_ids A list of entity ids either as strings or references.
'''
url = '%s/meta/any?include=id&' % self.url
for entity_id in entity_ids:
url += 'id=%s&' % _get_path(entity_id)
# ... | [
"def",
"entities",
"(",
"self",
",",
"entity_ids",
")",
":",
"url",
"=",
"'%s/meta/any?include=id&'",
"%",
"self",
".",
"url",
"for",
"entity_id",
"in",
"entity_ids",
":",
"url",
"+=",
"'id=%s&'",
"%",
"_get_path",
"(",
"entity_id",
")",
"# Remove the trailing... | Get the default data for entities.
@param entity_ids A list of entity ids either as strings or references. | [
"Get",
"the",
"default",
"data",
"for",
"entities",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L148-L159 | train | Get the default data for entities. |
juju/theblues | theblues/charmstore.py | CharmStore.bundle | def bundle(self, bundle_id, channel=None):
'''Get the default data for a bundle.
@param bundle_id The bundle's id.
@param channel Optional channel name.
'''
return self.entity(bundle_id, get_files=True, channel=channel) | python | def bundle(self, bundle_id, channel=None):
'''Get the default data for a bundle.
@param bundle_id The bundle's id.
@param channel Optional channel name.
'''
return self.entity(bundle_id, get_files=True, channel=channel) | [
"def",
"bundle",
"(",
"self",
",",
"bundle_id",
",",
"channel",
"=",
"None",
")",
":",
"return",
"self",
".",
"entity",
"(",
"bundle_id",
",",
"get_files",
"=",
"True",
",",
"channel",
"=",
"channel",
")"
] | Get the default data for a bundle.
@param bundle_id The bundle's id.
@param channel Optional channel name. | [
"Get",
"the",
"default",
"data",
"for",
"a",
"bundle",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L161-L167 | train | Get the default data for a bundle. |
juju/theblues | theblues/charmstore.py | CharmStore.charm | def charm(self, charm_id, channel=None):
'''Get the default data for a charm.
@param charm_id The charm's id.
@param channel Optional channel name.
'''
return self.entity(charm_id, get_files=True, channel=channel) | python | def charm(self, charm_id, channel=None):
'''Get the default data for a charm.
@param charm_id The charm's id.
@param channel Optional channel name.
'''
return self.entity(charm_id, get_files=True, channel=channel) | [
"def",
"charm",
"(",
"self",
",",
"charm_id",
",",
"channel",
"=",
"None",
")",
":",
"return",
"self",
".",
"entity",
"(",
"charm_id",
",",
"get_files",
"=",
"True",
",",
"channel",
"=",
"channel",
")"
] | Get the default data for a charm.
@param charm_id The charm's id.
@param channel Optional channel name. | [
"Get",
"the",
"default",
"data",
"for",
"a",
"charm",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L169-L175 | train | Get the default data for a charm. |
juju/theblues | theblues/charmstore.py | CharmStore.charm_icon_url | def charm_icon_url(self, charm_id, channel=None):
'''Generate the path to the icon for charms.
@param charm_id The ID of the charm.
@param channel Optional channel name.
@return The url to the icon.
'''
url = '{}/{}/icon.svg'.format(self.url, _get_path(charm_id))
... | python | def charm_icon_url(self, charm_id, channel=None):
'''Generate the path to the icon for charms.
@param charm_id The ID of the charm.
@param channel Optional channel name.
@return The url to the icon.
'''
url = '{}/{}/icon.svg'.format(self.url, _get_path(charm_id))
... | [
"def",
"charm_icon_url",
"(",
"self",
",",
"charm_id",
",",
"channel",
"=",
"None",
")",
":",
"url",
"=",
"'{}/{}/icon.svg'",
".",
"format",
"(",
"self",
".",
"url",
",",
"_get_path",
"(",
"charm_id",
")",
")",
"return",
"_add_channel",
"(",
"url",
",",
... | Generate the path to the icon for charms.
@param charm_id The ID of the charm.
@param channel Optional channel name.
@return The url to the icon. | [
"Generate",
"the",
"path",
"to",
"the",
"icon",
"for",
"charms",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L177-L185 | train | Generate the path to the icon for charms. |
juju/theblues | theblues/charmstore.py | CharmStore.charm_icon | def charm_icon(self, charm_id, channel=None):
'''Get the charm icon.
@param charm_id The ID of the charm.
@param channel Optional channel name.
'''
url = self.charm_icon_url(charm_id, channel=channel)
response = self._get(url)
return response.content | python | def charm_icon(self, charm_id, channel=None):
'''Get the charm icon.
@param charm_id The ID of the charm.
@param channel Optional channel name.
'''
url = self.charm_icon_url(charm_id, channel=channel)
response = self._get(url)
return response.content | [
"def",
"charm_icon",
"(",
"self",
",",
"charm_id",
",",
"channel",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"charm_icon_url",
"(",
"charm_id",
",",
"channel",
"=",
"channel",
")",
"response",
"=",
"self",
".",
"_get",
"(",
"url",
")",
"return",
... | Get the charm icon.
@param charm_id The ID of the charm.
@param channel Optional channel name. | [
"Get",
"the",
"charm",
"icon",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L187-L195 | train | Get the charm icon. |
juju/theblues | theblues/charmstore.py | CharmStore.bundle_visualization | def bundle_visualization(self, bundle_id, channel=None):
'''Get the bundle visualization.
@param bundle_id The ID of the bundle.
@param channel Optional channel name.
'''
url = self.bundle_visualization_url(bundle_id, channel=channel)
response = self._get(url)
re... | python | def bundle_visualization(self, bundle_id, channel=None):
'''Get the bundle visualization.
@param bundle_id The ID of the bundle.
@param channel Optional channel name.
'''
url = self.bundle_visualization_url(bundle_id, channel=channel)
response = self._get(url)
re... | [
"def",
"bundle_visualization",
"(",
"self",
",",
"bundle_id",
",",
"channel",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"bundle_visualization_url",
"(",
"bundle_id",
",",
"channel",
"=",
"channel",
")",
"response",
"=",
"self",
".",
"_get",
"(",
"url... | Get the bundle visualization.
@param bundle_id The ID of the bundle.
@param channel Optional channel name. | [
"Get",
"the",
"bundle",
"visualization",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L197-L205 | train | Get the bundle visualization. |
juju/theblues | theblues/charmstore.py | CharmStore.bundle_visualization_url | def bundle_visualization_url(self, bundle_id, channel=None):
'''Generate the path to the visualization for bundles.
@param charm_id The ID of the bundle.
@param channel Optional channel name.
@return The url to the visualization.
'''
url = '{}/{}/diagram.svg'.format(self... | python | def bundle_visualization_url(self, bundle_id, channel=None):
'''Generate the path to the visualization for bundles.
@param charm_id The ID of the bundle.
@param channel Optional channel name.
@return The url to the visualization.
'''
url = '{}/{}/diagram.svg'.format(self... | [
"def",
"bundle_visualization_url",
"(",
"self",
",",
"bundle_id",
",",
"channel",
"=",
"None",
")",
":",
"url",
"=",
"'{}/{}/diagram.svg'",
".",
"format",
"(",
"self",
".",
"url",
",",
"_get_path",
"(",
"bundle_id",
")",
")",
"return",
"_add_channel",
"(",
... | Generate the path to the visualization for bundles.
@param charm_id The ID of the bundle.
@param channel Optional channel name.
@return The url to the visualization. | [
"Generate",
"the",
"path",
"to",
"the",
"visualization",
"for",
"bundles",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L207-L215 | train | Generate the path to the visualization for bundles. |
juju/theblues | theblues/charmstore.py | CharmStore.entity_readme_url | def entity_readme_url(self, entity_id, channel=None):
'''Generate the url path for the readme of an entity.
@entity_id The id of the entity (i.e. charm, bundle).
@param channel Optional channel name.
'''
url = '{}/{}/readme'.format(self.url, _get_path(entity_id))
return ... | python | def entity_readme_url(self, entity_id, channel=None):
'''Generate the url path for the readme of an entity.
@entity_id The id of the entity (i.e. charm, bundle).
@param channel Optional channel name.
'''
url = '{}/{}/readme'.format(self.url, _get_path(entity_id))
return ... | [
"def",
"entity_readme_url",
"(",
"self",
",",
"entity_id",
",",
"channel",
"=",
"None",
")",
":",
"url",
"=",
"'{}/{}/readme'",
".",
"format",
"(",
"self",
".",
"url",
",",
"_get_path",
"(",
"entity_id",
")",
")",
"return",
"_add_channel",
"(",
"url",
",... | Generate the url path for the readme of an entity.
@entity_id The id of the entity (i.e. charm, bundle).
@param channel Optional channel name. | [
"Generate",
"the",
"url",
"path",
"for",
"the",
"readme",
"of",
"an",
"entity",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L217-L224 | train | Generate the url path for the readme of an entity. |
juju/theblues | theblues/charmstore.py | CharmStore.entity_readme_content | def entity_readme_content(self, entity_id, channel=None):
'''Get the readme for an entity.
@entity_id The id of the entity (i.e. charm, bundle).
@param channel Optional channel name.
'''
readme_url = self.entity_readme_url(entity_id, channel=channel)
response = self._get... | python | def entity_readme_content(self, entity_id, channel=None):
'''Get the readme for an entity.
@entity_id The id of the entity (i.e. charm, bundle).
@param channel Optional channel name.
'''
readme_url = self.entity_readme_url(entity_id, channel=channel)
response = self._get... | [
"def",
"entity_readme_content",
"(",
"self",
",",
"entity_id",
",",
"channel",
"=",
"None",
")",
":",
"readme_url",
"=",
"self",
".",
"entity_readme_url",
"(",
"entity_id",
",",
"channel",
"=",
"channel",
")",
"response",
"=",
"self",
".",
"_get",
"(",
"re... | Get the readme for an entity.
@entity_id The id of the entity (i.e. charm, bundle).
@param channel Optional channel name. | [
"Get",
"the",
"readme",
"for",
"an",
"entity",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L226-L234 | train | Get the readme for an entity. |
juju/theblues | theblues/charmstore.py | CharmStore.archive_url | def archive_url(self, entity_id, channel=None):
'''Generate a URL for the archive of an entity..
@param entity_id The ID of the entity to look up as a string
or reference.
@param channel Optional channel name.
'''
url = '{}/{}/archive'.format(self.url, _get_path(e... | python | def archive_url(self, entity_id, channel=None):
'''Generate a URL for the archive of an entity..
@param entity_id The ID of the entity to look up as a string
or reference.
@param channel Optional channel name.
'''
url = '{}/{}/archive'.format(self.url, _get_path(e... | [
"def",
"archive_url",
"(",
"self",
",",
"entity_id",
",",
"channel",
"=",
"None",
")",
":",
"url",
"=",
"'{}/{}/archive'",
".",
"format",
"(",
"self",
".",
"url",
",",
"_get_path",
"(",
"entity_id",
")",
")",
"return",
"_add_channel",
"(",
"url",
",",
... | Generate a URL for the archive of an entity..
@param entity_id The ID of the entity to look up as a string
or reference.
@param channel Optional channel name. | [
"Generate",
"a",
"URL",
"for",
"the",
"archive",
"of",
"an",
"entity",
".."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L236-L244 | train | Generate a URL for the archive of an entity. |
juju/theblues | theblues/charmstore.py | CharmStore.file_url | def file_url(self, entity_id, filename, channel=None):
'''Generate a URL for a file in an archive without requesting it.
@param entity_id The ID of the entity to look up.
@param filename The name of the file in the archive.
@param channel Optional channel name.
'''
url =... | python | def file_url(self, entity_id, filename, channel=None):
'''Generate a URL for a file in an archive without requesting it.
@param entity_id The ID of the entity to look up.
@param filename The name of the file in the archive.
@param channel Optional channel name.
'''
url =... | [
"def",
"file_url",
"(",
"self",
",",
"entity_id",
",",
"filename",
",",
"channel",
"=",
"None",
")",
":",
"url",
"=",
"'{}/{}/archive/{}'",
".",
"format",
"(",
"self",
".",
"url",
",",
"_get_path",
"(",
"entity_id",
")",
",",
"filename",
")",
"return",
... | Generate a URL for a file in an archive without requesting it.
@param entity_id The ID of the entity to look up.
@param filename The name of the file in the archive.
@param channel Optional channel name. | [
"Generate",
"a",
"URL",
"for",
"a",
"file",
"in",
"an",
"archive",
"without",
"requesting",
"it",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L246-L255 | train | Generate a URL for a file in an archive without requesting it. |
juju/theblues | theblues/charmstore.py | CharmStore.files | def files(self, entity_id, manifest=None, filename=None,
read_file=False, channel=None):
'''
Get the files or file contents of a file for an entity.
If all files are requested, a dictionary of filenames and urls for the
files in the archive are returned.
If filena... | python | def files(self, entity_id, manifest=None, filename=None,
read_file=False, channel=None):
'''
Get the files or file contents of a file for an entity.
If all files are requested, a dictionary of filenames and urls for the
files in the archive are returned.
If filena... | [
"def",
"files",
"(",
"self",
",",
"entity_id",
",",
"manifest",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"read_file",
"=",
"False",
",",
"channel",
"=",
"None",
")",
":",
"if",
"manifest",
"is",
"None",
":",
"manifest_url",
"=",
"'{}/{}/meta/manif... | Get the files or file contents of a file for an entity.
If all files are requested, a dictionary of filenames and urls for the
files in the archive are returned.
If filename is provided, the url of just that file is returned, if it
exists.
If filename is provided and read_file... | [
"Get",
"the",
"files",
"or",
"file",
"contents",
"of",
"a",
"file",
"for",
"an",
"entity",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L257-L303 | train | Get the files or file contents of a file for an entity. |
juju/theblues | theblues/charmstore.py | CharmStore.resource_url | def resource_url(self, entity_id, name, revision):
'''
Return the resource url for a given resource on an entity.
@param entity_id The id of the entity to get resource for.
@param name The name of the resource.
@param revision The revision of the resource.
'''
re... | python | def resource_url(self, entity_id, name, revision):
'''
Return the resource url for a given resource on an entity.
@param entity_id The id of the entity to get resource for.
@param name The name of the resource.
@param revision The revision of the resource.
'''
re... | [
"def",
"resource_url",
"(",
"self",
",",
"entity_id",
",",
"name",
",",
"revision",
")",
":",
"return",
"'{}/{}/resource/{}/{}'",
".",
"format",
"(",
"self",
".",
"url",
",",
"_get_path",
"(",
"entity_id",
")",
",",
"name",
",",
"revision",
")"
] | Return the resource url for a given resource on an entity.
@param entity_id The id of the entity to get resource for.
@param name The name of the resource.
@param revision The revision of the resource. | [
"Return",
"the",
"resource",
"url",
"for",
"a",
"given",
"resource",
"on",
"an",
"entity",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L305-L316 | train | Return the resource url for a given resource on an entity. |
juju/theblues | theblues/charmstore.py | CharmStore.config | def config(self, charm_id, channel=None):
'''Get the config data for a charm.
@param charm_id The charm's id.
@param channel Optional channel name.
'''
url = '{}/{}/meta/charm-config'.format(self.url, _get_path(charm_id))
data = self._get(_add_channel(url, channel))
... | python | def config(self, charm_id, channel=None):
'''Get the config data for a charm.
@param charm_id The charm's id.
@param channel Optional channel name.
'''
url = '{}/{}/meta/charm-config'.format(self.url, _get_path(charm_id))
data = self._get(_add_channel(url, channel))
... | [
"def",
"config",
"(",
"self",
",",
"charm_id",
",",
"channel",
"=",
"None",
")",
":",
"url",
"=",
"'{}/{}/meta/charm-config'",
".",
"format",
"(",
"self",
".",
"url",
",",
"_get_path",
"(",
"charm_id",
")",
")",
"data",
"=",
"self",
".",
"_get",
"(",
... | Get the config data for a charm.
@param charm_id The charm's id.
@param channel Optional channel name. | [
"Get",
"the",
"config",
"data",
"for",
"a",
"charm",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L318-L326 | train | Get the config data for a charm. |
juju/theblues | theblues/charmstore.py | CharmStore.search | def search(self, text, includes=None, doc_type=None, limit=None,
autocomplete=False, promulgated_only=False, tags=None,
sort=None, owner=None, series=None):
'''
Search for entities in the charmstore.
@param text The text to search for.
@param includes What ... | python | def search(self, text, includes=None, doc_type=None, limit=None,
autocomplete=False, promulgated_only=False, tags=None,
sort=None, owner=None, series=None):
'''
Search for entities in the charmstore.
@param text The text to search for.
@param includes What ... | [
"def",
"search",
"(",
"self",
",",
"text",
",",
"includes",
"=",
"None",
",",
"doc_type",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"autocomplete",
"=",
"False",
",",
"promulgated_only",
"=",
"False",
",",
"tags",
"=",
"None",
",",
"sort",
"=",
"N... | Search for entities in the charmstore.
@param text The text to search for.
@param includes What metadata to return in results (e.g. charm-config).
@param doc_type Filter to this type: bundle or charm.
@param limit Maximum number of results to return.
@param autocomplete Whether ... | [
"Search",
"for",
"entities",
"in",
"the",
"charmstore",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L339-L376 | train | Search for entities in the charmstore. |
juju/theblues | theblues/charmstore.py | CharmStore.list | def list(self, includes=None, doc_type=None, promulgated_only=False,
sort=None, owner=None, series=None):
'''
List entities in the charmstore.
@param includes What metadata to return in results (e.g. charm-config).
@param doc_type Filter to this type: bundle or charm.
... | python | def list(self, includes=None, doc_type=None, promulgated_only=False,
sort=None, owner=None, series=None):
'''
List entities in the charmstore.
@param includes What metadata to return in results (e.g. charm-config).
@param doc_type Filter to this type: bundle or charm.
... | [
"def",
"list",
"(",
"self",
",",
"includes",
"=",
"None",
",",
"doc_type",
"=",
"None",
",",
"promulgated_only",
"=",
"False",
",",
"sort",
"=",
"None",
",",
"owner",
"=",
"None",
",",
"series",
"=",
"None",
")",
":",
"queries",
"=",
"self",
".",
"... | List entities in the charmstore.
@param includes What metadata to return in results (e.g. charm-config).
@param doc_type Filter to this type: bundle or charm.
@param promulgated_only Whether to filter to only promulgated charms.
@param sort Sorting the result based on the sort string pr... | [
"List",
"entities",
"in",
"the",
"charmstore",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L378-L400 | train | List the entities in the charmstore. |
juju/theblues | theblues/charmstore.py | CharmStore._common_query_parameters | def _common_query_parameters(self, doc_type, includes, owner,
promulgated_only, series, sort):
'''
Extract common query parameters between search and list into slice.
@param includes What metadata to return in results (e.g. charm-config).
@param doc_type... | python | def _common_query_parameters(self, doc_type, includes, owner,
promulgated_only, series, sort):
'''
Extract common query parameters between search and list into slice.
@param includes What metadata to return in results (e.g. charm-config).
@param doc_type... | [
"def",
"_common_query_parameters",
"(",
"self",
",",
"doc_type",
",",
"includes",
",",
"owner",
",",
"promulgated_only",
",",
"series",
",",
"sort",
")",
":",
"queries",
"=",
"[",
"]",
"if",
"includes",
"is",
"not",
"None",
":",
"queries",
".",
"extend",
... | Extract common query parameters between search and list into slice.
@param includes What metadata to return in results (e.g. charm-config).
@param doc_type Filter to this type: bundle or charm.
@param promulgated_only Whether to filter to only promulgated charms.
@param sort Sorting the... | [
"Extract",
"common",
"query",
"parameters",
"between",
"search",
"and",
"list",
"into",
"slice",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L402-L432 | train | Extract common query parameters between search and list into slice. |
juju/theblues | theblues/charmstore.py | CharmStore.fetch_related | def fetch_related(self, ids):
"""Fetch related entity information.
Fetches metadata, stats and extra-info for the supplied entities.
@param ids The entity ids to fetch related information for. A list of
entity id dicts from the charmstore.
"""
if not ids:
... | python | def fetch_related(self, ids):
"""Fetch related entity information.
Fetches metadata, stats and extra-info for the supplied entities.
@param ids The entity ids to fetch related information for. A list of
entity id dicts from the charmstore.
"""
if not ids:
... | [
"def",
"fetch_related",
"(",
"self",
",",
"ids",
")",
":",
"if",
"not",
"ids",
":",
"return",
"[",
"]",
"meta",
"=",
"'&id='",
".",
"join",
"(",
"id",
"[",
"'Id'",
"]",
"for",
"id",
"in",
"ids",
")",
"url",
"=",
"(",
"'{url}/meta/any?id={meta}'",
"... | Fetch related entity information.
Fetches metadata, stats and extra-info for the supplied entities.
@param ids The entity ids to fetch related information for. A list of
entity id dicts from the charmstore. | [
"Fetch",
"related",
"entity",
"information",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L436-L453 | train | Fetch related entity information for the supplied entity ids. |
juju/theblues | theblues/charmstore.py | CharmStore.fetch_interfaces | def fetch_interfaces(self, interface, way):
"""Get the list of charms that provides or requires this interface.
@param interface The interface for the charm relation.
@param way The type of relation, either "provides" or "requires".
@return List of charms
"""
if not inte... | python | def fetch_interfaces(self, interface, way):
"""Get the list of charms that provides or requires this interface.
@param interface The interface for the charm relation.
@param way The type of relation, either "provides" or "requires".
@return List of charms
"""
if not inte... | [
"def",
"fetch_interfaces",
"(",
"self",
",",
"interface",
",",
"way",
")",
":",
"if",
"not",
"interface",
":",
"return",
"[",
"]",
"if",
"way",
"==",
"'requires'",
":",
"request",
"=",
"'&requires='",
"+",
"interface",
"else",
":",
"request",
"=",
"'&pro... | Get the list of charms that provides or requires this interface.
@param interface The interface for the charm relation.
@param way The type of relation, either "provides" or "requires".
@return List of charms | [
"Get",
"the",
"list",
"of",
"charms",
"that",
"provides",
"or",
"requires",
"this",
"interface",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L455-L473 | train | Get the list of charms that provides or requires this interface. |
juju/theblues | theblues/charmstore.py | CharmStore.debug | def debug(self):
'''Retrieve the debug information from the charmstore.'''
url = '{}/debug/status'.format(self.url)
data = self._get(url)
return data.json() | python | def debug(self):
'''Retrieve the debug information from the charmstore.'''
url = '{}/debug/status'.format(self.url)
data = self._get(url)
return data.json() | [
"def",
"debug",
"(",
"self",
")",
":",
"url",
"=",
"'{}/debug/status'",
".",
"format",
"(",
"self",
".",
"url",
")",
"data",
"=",
"self",
".",
"_get",
"(",
"url",
")",
"return",
"data",
".",
"json",
"(",
")"
] | Retrieve the debug information from the charmstore. | [
"Retrieve",
"the",
"debug",
"information",
"from",
"the",
"charmstore",
"."
] | f4431f29e43d04fc32f38f4f86cea45cd4e6ae98 | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L475-L479 | train | Retrieve the debug information from the charmstore. |
DarkEnergySurvey/ugali | ugali/isochrone/parsec.py | ParsecIsochrone.query_server | def query_server(self,outfile,age,metallicity):
""" Server query for the isochrone file.
Parameters:
-----------
outfile : name of output isochrone file
age : isochrone age
metallicity : isochrone metallicity
Returns:
--------
... | python | def query_server(self,outfile,age,metallicity):
""" Server query for the isochrone file.
Parameters:
-----------
outfile : name of output isochrone file
age : isochrone age
metallicity : isochrone metallicity
Returns:
--------
... | [
"def",
"query_server",
"(",
"self",
",",
"outfile",
",",
"age",
",",
"metallicity",
")",
":",
"params",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"download_defaults",
")",
"epsilon",
"=",
"1e-4",
"lage",
"=",
"np",
".",
"log10",
"(",
"age",
"*",
... | Server query for the isochrone file.
Parameters:
-----------
outfile : name of output isochrone file
age : isochrone age
metallicity : isochrone metallicity
Returns:
--------
outfile : name of output isochrone file | [
"Server",
"query",
"for",
"the",
"isochrone",
"file",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/isochrone/parsec.py#L138-L192 | train | Query the server for the isochrone file. |
DarkEnergySurvey/ugali | ugali/analysis/scan.py | Scan.run | def run(self, coords=None, debug=False):
"""
Run the likelihood grid search
"""
#self.grid.precompute()
self.grid.search(coords=coords)
return self.grid | python | def run(self, coords=None, debug=False):
"""
Run the likelihood grid search
"""
#self.grid.precompute()
self.grid.search(coords=coords)
return self.grid | [
"def",
"run",
"(",
"self",
",",
"coords",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"#self.grid.precompute()",
"self",
".",
"grid",
".",
"search",
"(",
"coords",
"=",
"coords",
")",
"return",
"self",
".",
"grid"
] | Run the likelihood grid search | [
"Run",
"the",
"likelihood",
"grid",
"search"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/analysis/scan.py#L52-L58 | train | Run the likelihood grid search |
DarkEnergySurvey/ugali | ugali/analysis/scan.py | GridSearch.precompute | def precompute(self, distance_modulus_array=None):
"""
DEPRECATED: ADW 20170627
Precompute color probabilities for background ('u_background')
and signal ('u_color') for each star in catalog. Precompute
observable fraction in each ROI pixel. # Precompute still
operates... | python | def precompute(self, distance_modulus_array=None):
"""
DEPRECATED: ADW 20170627
Precompute color probabilities for background ('u_background')
and signal ('u_color') for each star in catalog. Precompute
observable fraction in each ROI pixel. # Precompute still
operates... | [
"def",
"precompute",
"(",
"self",
",",
"distance_modulus_array",
"=",
"None",
")",
":",
"msg",
"=",
"\"'%s.precompute': ADW 2017-09-20\"",
"%",
"self",
".",
"__class__",
".",
"__name__",
"DeprecationWarning",
"(",
"msg",
")",
"if",
"distance_modulus_array",
"is",
... | DEPRECATED: ADW 20170627
Precompute color probabilities for background ('u_background')
and signal ('u_color') for each star in catalog. Precompute
observable fraction in each ROI pixel. # Precompute still
operates over the full ROI, not just the likelihood region
Parameters:... | [
"DEPRECATED",
":",
"ADW",
"20170627"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/analysis/scan.py#L99-L149 | train | Precompute color probabilities for background and signal for each star in catalog. |
DarkEnergySurvey/ugali | ugali/analysis/scan.py | GridSearch.search | def search(self, coords=None, distance_modulus=None, tolerance=1.e-2):
"""
Organize a grid search over ROI target pixels and distance moduli in distance_modulus_array
coords: (lon,lat)
distance_modulus: scalar
"""
nmoduli = len(self.distance_modulus_array)
npixels... | python | def search(self, coords=None, distance_modulus=None, tolerance=1.e-2):
"""
Organize a grid search over ROI target pixels and distance moduli in distance_modulus_array
coords: (lon,lat)
distance_modulus: scalar
"""
nmoduli = len(self.distance_modulus_array)
npixels... | [
"def",
"search",
"(",
"self",
",",
"coords",
"=",
"None",
",",
"distance_modulus",
"=",
"None",
",",
"tolerance",
"=",
"1.e-2",
")",
":",
"nmoduli",
"=",
"len",
"(",
"self",
".",
"distance_modulus_array",
")",
"npixels",
"=",
"len",
"(",
"self",
".",
"... | Organize a grid search over ROI target pixels and distance moduli in distance_modulus_array
coords: (lon,lat)
distance_modulus: scalar | [
"Organize",
"a",
"grid",
"search",
"over",
"ROI",
"target",
"pixels",
"and",
"distance",
"moduli",
"in",
"distance_modulus_array",
"coords",
":",
"(",
"lon",
"lat",
")",
"distance_modulus",
":",
"scalar"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/analysis/scan.py#L151-L258 | train | Search over the distance moduli in distance_modulus_array and store the results in self. log_likelihood_sparse_array loggers and self. richness_lower_sparse_array loggers. |
DarkEnergySurvey/ugali | ugali/analysis/scan.py | GridSearch.err | def err(self):
"""
A few rough approximations of the fit uncertainty. These
values shouldn't be trusted for anything real (use MCMC instead).
"""
# Initiallize error to nan
err = odict(self.mle())
err.update([(k,np.nan*np.ones(2)) for k in err.keys()])
# ... | python | def err(self):
"""
A few rough approximations of the fit uncertainty. These
values shouldn't be trusted for anything real (use MCMC instead).
"""
# Initiallize error to nan
err = odict(self.mle())
err.update([(k,np.nan*np.ones(2)) for k in err.keys()])
# ... | [
"def",
"err",
"(",
"self",
")",
":",
"# Initiallize error to nan",
"err",
"=",
"odict",
"(",
"self",
".",
"mle",
"(",
")",
")",
"err",
".",
"update",
"(",
"[",
"(",
"k",
",",
"np",
".",
"nan",
"*",
"np",
".",
"ones",
"(",
"2",
")",
")",
"for",
... | A few rough approximations of the fit uncertainty. These
values shouldn't be trusted for anything real (use MCMC instead). | [
"A",
"few",
"rough",
"approximations",
"of",
"the",
"fit",
"uncertainty",
".",
"These",
"values",
"shouldn",
"t",
"be",
"trusted",
"for",
"anything",
"real",
"(",
"use",
"MCMC",
"instead",
")",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/analysis/scan.py#L281-L324 | train | A few rough approximations of the fit uncertainty. These values should be trusted for anything real. |
DarkEnergySurvey/ugali | ugali/analysis/scan.py | GridSearch.write | def write(self, outfile):
"""
Save the likelihood results as a sparse HEALPix map.
"""
data = odict()
data['PIXEL']=self.roi.pixels_target
# Full data output (too large for survey)
if self.config['scan']['full_pdf']:
data['LOG_LIKELIHOOD']=self.log_lik... | python | def write(self, outfile):
"""
Save the likelihood results as a sparse HEALPix map.
"""
data = odict()
data['PIXEL']=self.roi.pixels_target
# Full data output (too large for survey)
if self.config['scan']['full_pdf']:
data['LOG_LIKELIHOOD']=self.log_lik... | [
"def",
"write",
"(",
"self",
",",
"outfile",
")",
":",
"data",
"=",
"odict",
"(",
")",
"data",
"[",
"'PIXEL'",
"]",
"=",
"self",
".",
"roi",
".",
"pixels_target",
"# Full data output (too large for survey)",
"if",
"self",
".",
"config",
"[",
"'scan'",
"]",... | Save the likelihood results as a sparse HEALPix map. | [
"Save",
"the",
"likelihood",
"results",
"as",
"a",
"sparse",
"HEALPix",
"map",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/analysis/scan.py#L326-L381 | train | Write the likelihood results to a file. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.from_uri | def from_uri(cls, uri, socket_timeout=None, auto_decode=False):
"""Construct a synchronous Beanstalk Client from a URI.
The URI may be of the form beanstalk://host:port or beanstalkd://host:port
IPv6 literals must be wrapped in brackets as per RFC 2732.
"""
parts = six.moves.ur... | python | def from_uri(cls, uri, socket_timeout=None, auto_decode=False):
"""Construct a synchronous Beanstalk Client from a URI.
The URI may be of the form beanstalk://host:port or beanstalkd://host:port
IPv6 literals must be wrapped in brackets as per RFC 2732.
"""
parts = six.moves.ur... | [
"def",
"from_uri",
"(",
"cls",
",",
"uri",
",",
"socket_timeout",
"=",
"None",
",",
"auto_decode",
"=",
"False",
")",
":",
"parts",
"=",
"six",
".",
"moves",
".",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"uri",
")",
"if",
"parts",
".",
"scheme",... | Construct a synchronous Beanstalk Client from a URI.
The URI may be of the form beanstalk://host:port or beanstalkd://host:port
IPv6 literals must be wrapped in brackets as per RFC 2732. | [
"Construct",
"a",
"synchronous",
"Beanstalk",
"Client",
"from",
"a",
"URI",
"."
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L96-L117 | train | Construct a synchronous Beanstalk Client from a URI. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient._re_establish_use_watch | def _re_establish_use_watch(self):
"""Call after a close/re-connect.
Automatically re-establishes the USE and WATCH configs previously setup.
"""
if self.current_tube != self.desired_tube:
self.use(self.desired_tube)
if self._watchlist != self.desired_watchlist:
... | python | def _re_establish_use_watch(self):
"""Call after a close/re-connect.
Automatically re-establishes the USE and WATCH configs previously setup.
"""
if self.current_tube != self.desired_tube:
self.use(self.desired_tube)
if self._watchlist != self.desired_watchlist:
... | [
"def",
"_re_establish_use_watch",
"(",
"self",
")",
":",
"if",
"self",
".",
"current_tube",
"!=",
"self",
".",
"desired_tube",
":",
"self",
".",
"use",
"(",
"self",
".",
"desired_tube",
")",
"if",
"self",
".",
"_watchlist",
"!=",
"self",
".",
"desired_watc... | Call after a close/re-connect.
Automatically re-establishes the USE and WATCH configs previously setup. | [
"Call",
"after",
"a",
"close",
"/",
"re",
"-",
"connect",
"."
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L140-L148 | train | Call after a close or re - connect. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.list_tubes | def list_tubes(self):
"""Return a list of tubes that this beanstalk instance knows about
:rtype: list of tubes
"""
with self._sock_ctx() as sock:
self._send_message('list-tubes', sock)
body = self._receive_data_with_prefix(b'OK', sock)
tubes = yaml_lo... | python | def list_tubes(self):
"""Return a list of tubes that this beanstalk instance knows about
:rtype: list of tubes
"""
with self._sock_ctx() as sock:
self._send_message('list-tubes', sock)
body = self._receive_data_with_prefix(b'OK', sock)
tubes = yaml_lo... | [
"def",
"list_tubes",
"(",
"self",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"sock",
":",
"self",
".",
"_send_message",
"(",
"'list-tubes'",
",",
"sock",
")",
"body",
"=",
"self",
".",
"_receive_data_with_prefix",
"(",
"b'OK'",
",",
"soc... | Return a list of tubes that this beanstalk instance knows about
:rtype: list of tubes | [
"Return",
"a",
"list",
"of",
"tubes",
"that",
"this",
"beanstalk",
"instance",
"knows",
"about"
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L246-L255 | train | Return a list of tubes that this beanstalk instance knows about. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.stats | def stats(self):
"""Return a dictionary with a bunch of instance-wide statistics
:rtype: dict
"""
with self._sock_ctx() as socket:
self._send_message('stats', socket)
body = self._receive_data_with_prefix(b'OK', socket)
stats = yaml_load(body)
... | python | def stats(self):
"""Return a dictionary with a bunch of instance-wide statistics
:rtype: dict
"""
with self._sock_ctx() as socket:
self._send_message('stats', socket)
body = self._receive_data_with_prefix(b'OK', socket)
stats = yaml_load(body)
... | [
"def",
"stats",
"(",
"self",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"self",
".",
"_send_message",
"(",
"'stats'",
",",
"socket",
")",
"body",
"=",
"self",
".",
"_receive_data_with_prefix",
"(",
"b'OK'",
",",
"socket",
... | Return a dictionary with a bunch of instance-wide statistics
:rtype: dict | [
"Return",
"a",
"dictionary",
"with",
"a",
"bunch",
"of",
"instance",
"-",
"wide",
"statistics"
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L257-L266 | train | Return a bunch of instance - wide statistics for the current user. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.put_job | def put_job(self, data, pri=65536, delay=0, ttr=120):
"""Insert a new job into whatever queue is currently USEd
:param data: Job body
:type data: Text (either str which will be encoded as utf-8, or bytes which are already utf-8
:param pri: Priority for the job
:type pri: int
... | python | def put_job(self, data, pri=65536, delay=0, ttr=120):
"""Insert a new job into whatever queue is currently USEd
:param data: Job body
:type data: Text (either str which will be encoded as utf-8, or bytes which are already utf-8
:param pri: Priority for the job
:type pri: int
... | [
"def",
"put_job",
"(",
"self",
",",
"data",
",",
"pri",
"=",
"65536",
",",
"delay",
"=",
"0",
",",
"ttr",
"=",
"120",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"message",
"=",
"'put {pri} {delay} {ttr} {datalen}\\r\\n'",
... | Insert a new job into whatever queue is currently USEd
:param data: Job body
:type data: Text (either str which will be encoded as utf-8, or bytes which are already utf-8
:param pri: Priority for the job
:type pri: int
:param delay: Delay in seconds before the job should be plac... | [
"Insert",
"a",
"new",
"job",
"into",
"whatever",
"queue",
"is",
"currently",
"USEd"
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L268-L298 | train | Insert a new job into the queue. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.put_job_into | def put_job_into(self, tube_name, data, pri=65536, delay=0, ttr=120):
"""Insert a new job into a specific queue. Wrapper around :func:`put_job`.
:param tube_name: Tube name
:type tube_name: str
:param data: Job body
:type data: Text (either str which will be encoded as utf-8, or... | python | def put_job_into(self, tube_name, data, pri=65536, delay=0, ttr=120):
"""Insert a new job into a specific queue. Wrapper around :func:`put_job`.
:param tube_name: Tube name
:type tube_name: str
:param data: Job body
:type data: Text (either str which will be encoded as utf-8, or... | [
"def",
"put_job_into",
"(",
"self",
",",
"tube_name",
",",
"data",
",",
"pri",
"=",
"65536",
",",
"delay",
"=",
"0",
",",
"ttr",
"=",
"120",
")",
":",
"with",
"self",
".",
"using",
"(",
"tube_name",
")",
"as",
"inserter",
":",
"return",
"inserter",
... | Insert a new job into a specific queue. Wrapper around :func:`put_job`.
:param tube_name: Tube name
:type tube_name: str
:param data: Job body
:type data: Text (either str which will be encoded as utf-8, or bytes which are already utf-8
:param pri: Priority for the job
:... | [
"Insert",
"a",
"new",
"job",
"into",
"a",
"specific",
"queue",
".",
"Wrapper",
"around",
":",
"func",
":",
"put_job",
"."
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L300-L324 | train | Insert a new job into a specific queue. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.watchlist | def watchlist(self, tubes):
"""Set the watchlist to the given tubes
:param tubes: A list of tubes to watch
Automatically un-watches any tubes that are not on the target list
"""
tubes = set(tubes)
for tube in tubes - self._watchlist:
self.watch(tube)
... | python | def watchlist(self, tubes):
"""Set the watchlist to the given tubes
:param tubes: A list of tubes to watch
Automatically un-watches any tubes that are not on the target list
"""
tubes = set(tubes)
for tube in tubes - self._watchlist:
self.watch(tube)
... | [
"def",
"watchlist",
"(",
"self",
",",
"tubes",
")",
":",
"tubes",
"=",
"set",
"(",
"tubes",
")",
"for",
"tube",
"in",
"tubes",
"-",
"self",
".",
"_watchlist",
":",
"self",
".",
"watch",
"(",
"tube",
")",
"for",
"tube",
"in",
"self",
".",
"_watchlis... | Set the watchlist to the given tubes
:param tubes: A list of tubes to watch
Automatically un-watches any tubes that are not on the target list | [
"Set",
"the",
"watchlist",
"to",
"the",
"given",
"tubes"
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L331-L342 | train | Sets the watchlist to the given tubes
|
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.watch | def watch(self, tube):
"""Add the given tube to the watchlist.
:param tube: Name of the tube to add to the watchlist
Note: Initially, all connections are watching a tube named "default". If
you manually call :func:`watch()`, we will un-watch the "default" tube.
To keep it in yo... | python | def watch(self, tube):
"""Add the given tube to the watchlist.
:param tube: Name of the tube to add to the watchlist
Note: Initially, all connections are watching a tube named "default". If
you manually call :func:`watch()`, we will un-watch the "default" tube.
To keep it in yo... | [
"def",
"watch",
"(",
"self",
",",
"tube",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"self",
".",
"desired_watchlist",
".",
"add",
"(",
"tube",
")",
"if",
"tube",
"not",
"in",
"self",
".",
"_watchlist",
":",
"self",
... | Add the given tube to the watchlist.
:param tube: Name of the tube to add to the watchlist
Note: Initially, all connections are watching a tube named "default". If
you manually call :func:`watch()`, we will un-watch the "default" tube.
To keep it in your list, first call :func:`watch()... | [
"Add",
"the",
"given",
"tube",
"to",
"the",
"watchlist",
"."
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L344-L363 | train | Add the given tube to the watchlist. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.ignore | def ignore(self, tube):
"""Remove the given tube from the watchlist.
:param tube: Name of tube to remove from the watchlist
If all tubes are :func:`ignore()` d, beanstalk will auto-add "default" to the watchlist
to prevent the list from being empty. See :func:`watch()` for more unforma... | python | def ignore(self, tube):
"""Remove the given tube from the watchlist.
:param tube: Name of tube to remove from the watchlist
If all tubes are :func:`ignore()` d, beanstalk will auto-add "default" to the watchlist
to prevent the list from being empty. See :func:`watch()` for more unforma... | [
"def",
"ignore",
"(",
"self",
",",
"tube",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"if",
"tube",
"not",
"in",
"self",
".",
"_watchlist",
":",
"raise",
"KeyError",
"(",
"tube",
")",
"if",
"tube",
"!=",
"'default'",
... | Remove the given tube from the watchlist.
:param tube: Name of tube to remove from the watchlist
If all tubes are :func:`ignore()` d, beanstalk will auto-add "default" to the watchlist
to prevent the list from being empty. See :func:`watch()` for more unformation. | [
"Remove",
"the",
"given",
"tube",
"from",
"the",
"watchlist",
"."
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L365-L383 | train | Remove the given tube from the watchlist. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.stats_job | def stats_job(self, job_id):
"""Fetch statistics about a single job
:rtype: dict
"""
with self._sock_ctx() as socket:
if hasattr(job_id, 'job_id'):
job_id = job_id.job_id
self._send_message('stats-job {0}'.format(job_id), socket)
body ... | python | def stats_job(self, job_id):
"""Fetch statistics about a single job
:rtype: dict
"""
with self._sock_ctx() as socket:
if hasattr(job_id, 'job_id'):
job_id = job_id.job_id
self._send_message('stats-job {0}'.format(job_id), socket)
body ... | [
"def",
"stats_job",
"(",
"self",
",",
"job_id",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"if",
"hasattr",
"(",
"job_id",
",",
"'job_id'",
")",
":",
"job_id",
"=",
"job_id",
".",
"job_id",
"self",
".",
"_send_message",
... | Fetch statistics about a single job
:rtype: dict | [
"Fetch",
"statistics",
"about",
"a",
"single",
"job"
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L385-L396 | train | Fetch statistics about a single job. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.stats_tube | def stats_tube(self, tube_name):
"""Fetch statistics about a single tube
:param tube_name: Tube to fetch stats about
:rtype: dict
"""
with self._sock_ctx() as socket:
self._send_message('stats-tube {0}'.format(tube_name), socket)
body = self._receive_data... | python | def stats_tube(self, tube_name):
"""Fetch statistics about a single tube
:param tube_name: Tube to fetch stats about
:rtype: dict
"""
with self._sock_ctx() as socket:
self._send_message('stats-tube {0}'.format(tube_name), socket)
body = self._receive_data... | [
"def",
"stats_tube",
"(",
"self",
",",
"tube_name",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"self",
".",
"_send_message",
"(",
"'stats-tube {0}'",
".",
"format",
"(",
"tube_name",
")",
",",
"socket",
")",
"body",
"=",
... | Fetch statistics about a single tube
:param tube_name: Tube to fetch stats about
:rtype: dict | [
"Fetch",
"statistics",
"about",
"a",
"single",
"tube"
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L398-L407 | train | Fetch statistics about a single tube |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.reserve_job | def reserve_job(self, timeout=5):
"""Reserve a job for this connection. Blocks for TIMEOUT secionds and raises TIMED_OUT if no job was available
:param timeout: Time to wait for a job, in seconds.
:type timeout: int
"""
timeout = int(timeout)
if self.socket_timeout is no... | python | def reserve_job(self, timeout=5):
"""Reserve a job for this connection. Blocks for TIMEOUT secionds and raises TIMED_OUT if no job was available
:param timeout: Time to wait for a job, in seconds.
:type timeout: int
"""
timeout = int(timeout)
if self.socket_timeout is no... | [
"def",
"reserve_job",
"(",
"self",
",",
"timeout",
"=",
"5",
")",
":",
"timeout",
"=",
"int",
"(",
"timeout",
")",
"if",
"self",
".",
"socket_timeout",
"is",
"not",
"None",
":",
"if",
"timeout",
">=",
"self",
".",
"socket_timeout",
":",
"raise",
"Value... | Reserve a job for this connection. Blocks for TIMEOUT secionds and raises TIMED_OUT if no job was available
:param timeout: Time to wait for a job, in seconds.
:type timeout: int | [
"Reserve",
"a",
"job",
"for",
"this",
"connection",
".",
"Blocks",
"for",
"TIMEOUT",
"secionds",
"and",
"raises",
"TIMED_OUT",
"if",
"no",
"job",
"was",
"available"
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L409-L424 | train | Reserves a job for this connection. Blocks for TIMEOUT secionds and raises TIMED_OUT if no job was available. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient._peek_common | def _peek_common(self, typ):
"""Common implementation for the peek_* functions"""
with self._sock_ctx() as socket:
self._send_message('peek-{0}'.format(typ), socket)
job_id, job_data = self._receive_id_and_data_with_prefix(b'FOUND', socket)
return Job(job_id, job_data... | python | def _peek_common(self, typ):
"""Common implementation for the peek_* functions"""
with self._sock_ctx() as socket:
self._send_message('peek-{0}'.format(typ), socket)
job_id, job_data = self._receive_id_and_data_with_prefix(b'FOUND', socket)
return Job(job_id, job_data... | [
"def",
"_peek_common",
"(",
"self",
",",
"typ",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"self",
".",
"_send_message",
"(",
"'peek-{0}'",
".",
"format",
"(",
"typ",
")",
",",
"socket",
")",
"job_id",
",",
"job_data",
... | Common implementation for the peek_* functions | [
"Common",
"implementation",
"for",
"the",
"peek_",
"*",
"functions"
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L426-L431 | train | Common implementation for the peek_* functions. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.delete_job | def delete_job(self, job_id):
"""Delete the given job id. The job must have been previously reserved by this connection"""
if hasattr(job_id, 'job_id'):
job_id = job_id.job_id
with self._sock_ctx() as socket:
self._send_message('delete {0}'.format(job_id), socket)
... | python | def delete_job(self, job_id):
"""Delete the given job id. The job must have been previously reserved by this connection"""
if hasattr(job_id, 'job_id'):
job_id = job_id.job_id
with self._sock_ctx() as socket:
self._send_message('delete {0}'.format(job_id), socket)
... | [
"def",
"delete_job",
"(",
"self",
",",
"job_id",
")",
":",
"if",
"hasattr",
"(",
"job_id",
",",
"'job_id'",
")",
":",
"job_id",
"=",
"job_id",
".",
"job_id",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"self",
".",
"_send_message",... | Delete the given job id. The job must have been previously reserved by this connection | [
"Delete",
"the",
"given",
"job",
"id",
".",
"The",
"job",
"must",
"have",
"been",
"previously",
"reserved",
"by",
"this",
"connection"
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L474-L480 | train | Delete the given job id. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.bury_job | def bury_job(self, job_id, pri=65536):
"""Mark the given job_id as buried. The job must have been previously reserved by this connection
:param job_id: Job to bury
:param pri: Priority for the newly-buried job. If not passed, will keep its current priority
:type pri: int
"""
... | python | def bury_job(self, job_id, pri=65536):
"""Mark the given job_id as buried. The job must have been previously reserved by this connection
:param job_id: Job to bury
:param pri: Priority for the newly-buried job. If not passed, will keep its current priority
:type pri: int
"""
... | [
"def",
"bury_job",
"(",
"self",
",",
"job_id",
",",
"pri",
"=",
"65536",
")",
":",
"if",
"hasattr",
"(",
"job_id",
",",
"'job_id'",
")",
":",
"job_id",
"=",
"job_id",
".",
"job_id",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"... | Mark the given job_id as buried. The job must have been previously reserved by this connection
:param job_id: Job to bury
:param pri: Priority for the newly-buried job. If not passed, will keep its current priority
:type pri: int | [
"Mark",
"the",
"given",
"job_id",
"as",
"buried",
".",
"The",
"job",
"must",
"have",
"been",
"previously",
"reserved",
"by",
"this",
"connection"
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L482-L493 | train | Mark the given job_id as buried. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.release_job | def release_job(self, job_id, pri=65536, delay=0):
"""Put a job back on the queue to be processed (indicating that you've aborted it)
You can only release a job which you have reserved using :func:`reserve_job()` or :func:`reserve_iter()`.
:param job_id: Job ID to return
:param pri: Ne... | python | def release_job(self, job_id, pri=65536, delay=0):
"""Put a job back on the queue to be processed (indicating that you've aborted it)
You can only release a job which you have reserved using :func:`reserve_job()` or :func:`reserve_iter()`.
:param job_id: Job ID to return
:param pri: Ne... | [
"def",
"release_job",
"(",
"self",
",",
"job_id",
",",
"pri",
"=",
"65536",
",",
"delay",
"=",
"0",
")",
":",
"if",
"hasattr",
"(",
"job_id",
",",
"'job_id'",
")",
":",
"job_id",
"=",
"job_id",
".",
"job_id",
"with",
"self",
".",
"_sock_ctx",
"(",
... | Put a job back on the queue to be processed (indicating that you've aborted it)
You can only release a job which you have reserved using :func:`reserve_job()` or :func:`reserve_iter()`.
:param job_id: Job ID to return
:param pri: New priority (if not passed, will use old priority)
:typ... | [
"Put",
"a",
"job",
"back",
"on",
"the",
"queue",
"to",
"be",
"processed",
"(",
"indicating",
"that",
"you",
"ve",
"aborted",
"it",
")"
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L495-L510 | train | Release a reserved job from the queue. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.kick_job | def kick_job(self, job_id):
"""Kick the given job id. The job must either be in the DELAYED or BURIED state and will be immediately moved to
the READY state."""
if hasattr(job_id, 'job_id'):
job_id = job_id.job_id
with self._sock_ctx() as socket:
self._send_messag... | python | def kick_job(self, job_id):
"""Kick the given job id. The job must either be in the DELAYED or BURIED state and will be immediately moved to
the READY state."""
if hasattr(job_id, 'job_id'):
job_id = job_id.job_id
with self._sock_ctx() as socket:
self._send_messag... | [
"def",
"kick_job",
"(",
"self",
",",
"job_id",
")",
":",
"if",
"hasattr",
"(",
"job_id",
",",
"'job_id'",
")",
":",
"job_id",
"=",
"job_id",
".",
"job_id",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"self",
".",
"_send_message",
... | Kick the given job id. The job must either be in the DELAYED or BURIED state and will be immediately moved to
the READY state. | [
"Kick",
"the",
"given",
"job",
"id",
".",
"The",
"job",
"must",
"either",
"be",
"in",
"the",
"DELAYED",
"or",
"BURIED",
"state",
"and",
"will",
"be",
"immediately",
"moved",
"to",
"the",
"READY",
"state",
"."
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L512-L519 | train | Kick the given job id. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.use | def use(self, tube):
"""Start producing jobs into the given tube.
:param tube: Name of the tube to USE
Subsequent calls to :func:`put_job` insert jobs into this tube.
"""
with self._sock_ctx() as socket:
if self.current_tube != tube:
self.desired_tub... | python | def use(self, tube):
"""Start producing jobs into the given tube.
:param tube: Name of the tube to USE
Subsequent calls to :func:`put_job` insert jobs into this tube.
"""
with self._sock_ctx() as socket:
if self.current_tube != tube:
self.desired_tub... | [
"def",
"use",
"(",
"self",
",",
"tube",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"if",
"self",
".",
"current_tube",
"!=",
"tube",
":",
"self",
".",
"desired_tube",
"=",
"tube",
"self",
".",
"_send_message",
"(",
"'us... | Start producing jobs into the given tube.
:param tube: Name of the tube to USE
Subsequent calls to :func:`put_job` insert jobs into this tube. | [
"Start",
"producing",
"jobs",
"into",
"the",
"given",
"tube",
"."
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L521-L533 | train | Start producing jobs into the given tube. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.using | def using(self, tube):
"""Context-manager to insert jobs into a specific tube
:param tube: Tube to insert to
Yields out an instance of :class:`BeanstalkInsertingProxy` to insert items into that tube
.. seealso::
:func:`use()`
Change the default tube
... | python | def using(self, tube):
"""Context-manager to insert jobs into a specific tube
:param tube: Tube to insert to
Yields out an instance of :class:`BeanstalkInsertingProxy` to insert items into that tube
.. seealso::
:func:`use()`
Change the default tube
... | [
"def",
"using",
"(",
"self",
",",
"tube",
")",
":",
"try",
":",
"current_tube",
"=",
"self",
".",
"current_tube",
"self",
".",
"use",
"(",
"tube",
")",
"yield",
"BeanstalkInsertingProxy",
"(",
"self",
",",
"tube",
")",
"finally",
":",
"self",
".",
"use... | Context-manager to insert jobs into a specific tube
:param tube: Tube to insert to
Yields out an instance of :class:`BeanstalkInsertingProxy` to insert items into that tube
.. seealso::
:func:`use()`
Change the default tube
:func:`put_job()`
... | [
"Context",
"-",
"manager",
"to",
"insert",
"jobs",
"into",
"a",
"specific",
"tube"
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L536-L559 | train | Context - manager to insert jobs into a specific tube. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.kick_jobs | def kick_jobs(self, num_jobs):
"""Kick some number of jobs from the buried queue onto the ready queue.
:param num_jobs: Number of jobs to kick
:type num_jobs: int
If not that many jobs are in the buried queue, it will kick as many as it can."""
with self._sock_ctx() as socket:
... | python | def kick_jobs(self, num_jobs):
"""Kick some number of jobs from the buried queue onto the ready queue.
:param num_jobs: Number of jobs to kick
:type num_jobs: int
If not that many jobs are in the buried queue, it will kick as many as it can."""
with self._sock_ctx() as socket:
... | [
"def",
"kick_jobs",
"(",
"self",
",",
"num_jobs",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"self",
".",
"_send_message",
"(",
"'kick {0}'",
".",
"format",
"(",
"num_jobs",
")",
",",
"socket",
")",
"return",
"self",
"."... | Kick some number of jobs from the buried queue onto the ready queue.
:param num_jobs: Number of jobs to kick
:type num_jobs: int
If not that many jobs are in the buried queue, it will kick as many as it can. | [
"Kick",
"some",
"number",
"of",
"jobs",
"from",
"the",
"buried",
"queue",
"onto",
"the",
"ready",
"queue",
"."
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L561-L570 | train | Kick some number of jobs from the buried queue onto the ready queue. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.pause_tube | def pause_tube(self, tube, delay=3600):
"""Pause a tube for some number of seconds, preventing it from issuing jobs.
:param delay: Time to pause for, in seconds
:type delay: int
There is no way to permanently pause a tube; passing 0 for delay actually un-pauses the tube.
.. se... | python | def pause_tube(self, tube, delay=3600):
"""Pause a tube for some number of seconds, preventing it from issuing jobs.
:param delay: Time to pause for, in seconds
:type delay: int
There is no way to permanently pause a tube; passing 0 for delay actually un-pauses the tube.
.. se... | [
"def",
"pause_tube",
"(",
"self",
",",
"tube",
",",
"delay",
"=",
"3600",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"delay",
"=",
"int",
"(",
"delay",
")",
"self",
".",
"_send_message",
"(",
"'pause-tube {0} {1}'",
".",... | Pause a tube for some number of seconds, preventing it from issuing jobs.
:param delay: Time to pause for, in seconds
:type delay: int
There is no way to permanently pause a tube; passing 0 for delay actually un-pauses the tube.
.. seealso::
:func:`unpause_tube()` | [
"Pause",
"a",
"tube",
"for",
"some",
"number",
"of",
"seconds",
"preventing",
"it",
"from",
"issuing",
"jobs",
"."
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L572-L587 | train | Pause a tube for some number of seconds. |
EasyPost/pystalk | pystalk/client.py | BeanstalkClient.unpause_tube | def unpause_tube(self, tube):
"""Unpause a tube which was previously paused with :func:`pause_tube()`.
.. seealso::
:func:`pause_tube()`
"""
with self._sock_ctx() as socket:
self._send_message('pause-tube {0} 0'.format(tube), socket)
return self._rece... | python | def unpause_tube(self, tube):
"""Unpause a tube which was previously paused with :func:`pause_tube()`.
.. seealso::
:func:`pause_tube()`
"""
with self._sock_ctx() as socket:
self._send_message('pause-tube {0} 0'.format(tube), socket)
return self._rece... | [
"def",
"unpause_tube",
"(",
"self",
",",
"tube",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"self",
".",
"_send_message",
"(",
"'pause-tube {0} 0'",
".",
"format",
"(",
"tube",
")",
",",
"socket",
")",
"return",
"self",
... | Unpause a tube which was previously paused with :func:`pause_tube()`.
.. seealso::
:func:`pause_tube()` | [
"Unpause",
"a",
"tube",
"which",
"was",
"previously",
"paused",
"with",
":",
"func",
":",
"pause_tube",
"()",
"."
] | 96759ad1fda264b9897ee5346eef7926892a3a4c | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L589-L598 | train | Unpause a tube. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | interval | def interval(best,lo=np.nan,hi=np.nan):
"""
Pythonized interval for easy output to yaml
"""
return [float(best),[float(lo),float(hi)]] | python | def interval(best,lo=np.nan,hi=np.nan):
"""
Pythonized interval for easy output to yaml
"""
return [float(best),[float(lo),float(hi)]] | [
"def",
"interval",
"(",
"best",
",",
"lo",
"=",
"np",
".",
"nan",
",",
"hi",
"=",
"np",
".",
"nan",
")",
":",
"return",
"[",
"float",
"(",
"best",
")",
",",
"[",
"float",
"(",
"lo",
")",
",",
"float",
"(",
"hi",
")",
"]",
"]"
] | Pythonized interval for easy output to yaml | [
"Pythonized",
"interval",
"for",
"easy",
"output",
"to",
"yaml"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L28-L32 | train | Pythonized interval for easy output to yaml
|
DarkEnergySurvey/ugali | ugali/utils/stats.py | mean_interval | def mean_interval(data, alpha=_alpha):
"""
Interval assuming gaussian posterior.
"""
mean =np.mean(data)
sigma = np.std(data)
scale = scipy.stats.norm.ppf(1-alpha/2.)
return interval(mean,mean-scale*sigma,mean+scale*sigma) | python | def mean_interval(data, alpha=_alpha):
"""
Interval assuming gaussian posterior.
"""
mean =np.mean(data)
sigma = np.std(data)
scale = scipy.stats.norm.ppf(1-alpha/2.)
return interval(mean,mean-scale*sigma,mean+scale*sigma) | [
"def",
"mean_interval",
"(",
"data",
",",
"alpha",
"=",
"_alpha",
")",
":",
"mean",
"=",
"np",
".",
"mean",
"(",
"data",
")",
"sigma",
"=",
"np",
".",
"std",
"(",
"data",
")",
"scale",
"=",
"scipy",
".",
"stats",
".",
"norm",
".",
"ppf",
"(",
"... | Interval assuming gaussian posterior. | [
"Interval",
"assuming",
"gaussian",
"posterior",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L34-L41 | train | Returns an interval assuming gaussian posterior. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | median_interval | def median_interval(data, alpha=_alpha):
"""
Median including bayesian credible interval.
"""
q = [100*alpha/2., 50, 100*(1-alpha/2.)]
lo,med,hi = np.percentile(data,q)
return interval(med,lo,hi) | python | def median_interval(data, alpha=_alpha):
"""
Median including bayesian credible interval.
"""
q = [100*alpha/2., 50, 100*(1-alpha/2.)]
lo,med,hi = np.percentile(data,q)
return interval(med,lo,hi) | [
"def",
"median_interval",
"(",
"data",
",",
"alpha",
"=",
"_alpha",
")",
":",
"q",
"=",
"[",
"100",
"*",
"alpha",
"/",
"2.",
",",
"50",
",",
"100",
"*",
"(",
"1",
"-",
"alpha",
"/",
"2.",
")",
"]",
"lo",
",",
"med",
",",
"hi",
"=",
"np",
".... | Median including bayesian credible interval. | [
"Median",
"including",
"bayesian",
"credible",
"interval",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L43-L49 | train | Returns a median interval. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | kde | def kde(data, npoints=_npoints):
"""
Identify peak using Gaussian kernel density estimator.
Parameters:
-----------
data : The 1d data sample
npoints : The number of kde points to evaluate
"""
# Clipping of severe outliers to concentrate more KDE samples in the parameter range of ... | python | def kde(data, npoints=_npoints):
"""
Identify peak using Gaussian kernel density estimator.
Parameters:
-----------
data : The 1d data sample
npoints : The number of kde points to evaluate
"""
# Clipping of severe outliers to concentrate more KDE samples in the parameter range of ... | [
"def",
"kde",
"(",
"data",
",",
"npoints",
"=",
"_npoints",
")",
":",
"# Clipping of severe outliers to concentrate more KDE samples in the parameter range of interest",
"mad",
"=",
"np",
".",
"median",
"(",
"np",
".",
"fabs",
"(",
"np",
".",
"median",
"(",
"data",
... | Identify peak using Gaussian kernel density estimator.
Parameters:
-----------
data : The 1d data sample
npoints : The number of kde points to evaluate | [
"Identify",
"peak",
"using",
"Gaussian",
"kernel",
"density",
"estimator",
".",
"Parameters",
":",
"-----------",
"data",
":",
"The",
"1d",
"data",
"sample",
"npoints",
":",
"The",
"number",
"of",
"kde",
"points",
"to",
"evaluate"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L62-L80 | train | Identify peak using Gaussian kernel density estimator. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | peak_interval | def peak_interval(data, alpha=_alpha, npoints=_npoints):
"""
Identify interval using Gaussian kernel density estimator.
"""
peak = kde_peak(data,npoints)
x = np.sort(data.flat); n = len(x)
# The number of entries in the interval
window = int(np.rint((1.0-alpha)*n))
# The start, stop, and... | python | def peak_interval(data, alpha=_alpha, npoints=_npoints):
"""
Identify interval using Gaussian kernel density estimator.
"""
peak = kde_peak(data,npoints)
x = np.sort(data.flat); n = len(x)
# The number of entries in the interval
window = int(np.rint((1.0-alpha)*n))
# The start, stop, and... | [
"def",
"peak_interval",
"(",
"data",
",",
"alpha",
"=",
"_alpha",
",",
"npoints",
"=",
"_npoints",
")",
":",
"peak",
"=",
"kde_peak",
"(",
"data",
",",
"npoints",
")",
"x",
"=",
"np",
".",
"sort",
"(",
"data",
".",
"flat",
")",
"n",
"=",
"len",
"... | Identify interval using Gaussian kernel density estimator. | [
"Identify",
"interval",
"using",
"Gaussian",
"kernel",
"density",
"estimator",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L82-L101 | train | Identify interval using Gaussian kernel density estimator. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | sky | def sky(lon=None,lat=None,size=1):
"""
Outputs uniform points on sphere from:
[0 < lon < 360] & [-90 < lat < 90]
"""
if lon is None:
umin,umax = 0,1
else:
lon = np.asarray(lon)
lon = np.radians(lon + 360.*(lon<0))
if lon.size==1: umin=umax=lon/(2*np.pi)
... | python | def sky(lon=None,lat=None,size=1):
"""
Outputs uniform points on sphere from:
[0 < lon < 360] & [-90 < lat < 90]
"""
if lon is None:
umin,umax = 0,1
else:
lon = np.asarray(lon)
lon = np.radians(lon + 360.*(lon<0))
if lon.size==1: umin=umax=lon/(2*np.pi)
... | [
"def",
"sky",
"(",
"lon",
"=",
"None",
",",
"lat",
"=",
"None",
",",
"size",
"=",
"1",
")",
":",
"if",
"lon",
"is",
"None",
":",
"umin",
",",
"umax",
"=",
"0",
",",
"1",
"else",
":",
"lon",
"=",
"np",
".",
"asarray",
"(",
"lon",
")",
"lon",... | Outputs uniform points on sphere from:
[0 < lon < 360] & [-90 < lat < 90] | [
"Outputs",
"uniform",
"points",
"on",
"sphere",
"from",
":",
"[",
"0",
"<",
"lon",
"<",
"360",
"]",
"&",
"[",
"-",
"90",
"<",
"lat",
"<",
"90",
"]"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L131-L156 | train | Outputs uniform points on sphere from lon lat |
DarkEnergySurvey/ugali | ugali/utils/stats.py | Samples.supplement | def supplement(self,coordsys='gal'):
""" Add some supplemental columns """
from ugali.utils.projector import gal2cel, gal2cel_angle
from ugali.utils.projector import cel2gal, cel2gal_angle
coordsys = coordsys.lower()
kwargs = dict(usemask=False, asrecarray=True)
out = co... | python | def supplement(self,coordsys='gal'):
""" Add some supplemental columns """
from ugali.utils.projector import gal2cel, gal2cel_angle
from ugali.utils.projector import cel2gal, cel2gal_angle
coordsys = coordsys.lower()
kwargs = dict(usemask=False, asrecarray=True)
out = co... | [
"def",
"supplement",
"(",
"self",
",",
"coordsys",
"=",
"'gal'",
")",
":",
"from",
"ugali",
".",
"utils",
".",
"projector",
"import",
"gal2cel",
",",
"gal2cel_angle",
"from",
"ugali",
".",
"utils",
".",
"projector",
"import",
"cel2gal",
",",
"cel2gal_angle",... | Add some supplemental columns | [
"Add",
"some",
"supplemental",
"columns"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L201-L244 | train | Add some supplemental columns to the current object. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | Samples.mean | def mean(self, name, **kwargs):
"""
Mean of the distribution.
"""
return np.mean(self.get(name,**kwargs)) | python | def mean(self, name, **kwargs):
"""
Mean of the distribution.
"""
return np.mean(self.get(name,**kwargs)) | [
"def",
"mean",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"np",
".",
"mean",
"(",
"self",
".",
"get",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
")"
] | Mean of the distribution. | [
"Mean",
"of",
"the",
"distribution",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L280-L284 | train | Mean of the distribution. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | Samples.mean_interval | def mean_interval(self, name, alpha=_alpha, **kwargs):
"""
Interval assuming gaussian posterior.
"""
data = self.get(name,**kwargs)
#return ugali.utils.stats.mean_interval(data,alpha)
return mean_interval(data,alpha) | python | def mean_interval(self, name, alpha=_alpha, **kwargs):
"""
Interval assuming gaussian posterior.
"""
data = self.get(name,**kwargs)
#return ugali.utils.stats.mean_interval(data,alpha)
return mean_interval(data,alpha) | [
"def",
"mean_interval",
"(",
"self",
",",
"name",
",",
"alpha",
"=",
"_alpha",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"get",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"#return ugali.utils.stats.mean_interval(data,alpha)",
"return",
"... | Interval assuming gaussian posterior. | [
"Interval",
"assuming",
"gaussian",
"posterior",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L286-L292 | train | Return the mean interval of a set of items. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | Samples.median | def median(self, name, **kwargs):
"""
Median of the distribution.
"""
data = self.get(name,**kwargs)
return np.percentile(data,[50]) | python | def median(self, name, **kwargs):
"""
Median of the distribution.
"""
data = self.get(name,**kwargs)
return np.percentile(data,[50]) | [
"def",
"median",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"get",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"return",
"np",
".",
"percentile",
"(",
"data",
",",
"[",
"50",
"]",
")"
] | Median of the distribution. | [
"Median",
"of",
"the",
"distribution",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L294-L299 | train | Return the median of the data for the given name. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | Samples.median_interval | def median_interval(self, name, alpha=_alpha, **kwargs):
"""
Median including bayesian credible interval.
"""
data = self.get(name,**kwargs)
return median_interval(data,alpha) | python | def median_interval(self, name, alpha=_alpha, **kwargs):
"""
Median including bayesian credible interval.
"""
data = self.get(name,**kwargs)
return median_interval(data,alpha) | [
"def",
"median_interval",
"(",
"self",
",",
"name",
",",
"alpha",
"=",
"_alpha",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"get",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"return",
"median_interval",
"(",
"data",
",",
"alpha",
... | Median including bayesian credible interval. | [
"Median",
"including",
"bayesian",
"credible",
"interval",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L301-L306 | train | Return the median interval of the named entry. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | Samples.kde_peak | def kde_peak(self, name, npoints=_npoints, **kwargs):
"""
Calculate peak of kernel density estimator
"""
data = self.get(name,**kwargs)
return kde_peak(data,npoints) | python | def kde_peak(self, name, npoints=_npoints, **kwargs):
"""
Calculate peak of kernel density estimator
"""
data = self.get(name,**kwargs)
return kde_peak(data,npoints) | [
"def",
"kde_peak",
"(",
"self",
",",
"name",
",",
"npoints",
"=",
"_npoints",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"get",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"return",
"kde_peak",
"(",
"data",
",",
"npoints",
")"
] | Calculate peak of kernel density estimator | [
"Calculate",
"peak",
"of",
"kernel",
"density",
"estimator"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L312-L317 | train | Calculates the peak of kernel density estimator for a given set of points |
DarkEnergySurvey/ugali | ugali/utils/stats.py | Samples.kde | def kde(self, name, npoints=_npoints, **kwargs):
"""
Calculate kernel density estimator for parameter
"""
data = self.get(name,**kwargs)
return kde(data,npoints) | python | def kde(self, name, npoints=_npoints, **kwargs):
"""
Calculate kernel density estimator for parameter
"""
data = self.get(name,**kwargs)
return kde(data,npoints) | [
"def",
"kde",
"(",
"self",
",",
"name",
",",
"npoints",
"=",
"_npoints",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"get",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"return",
"kde",
"(",
"data",
",",
"npoints",
")"
] | Calculate kernel density estimator for parameter | [
"Calculate",
"kernel",
"density",
"estimator",
"for",
"parameter"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L319-L324 | train | Calculates kernel density estimator for a parameter set. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | Samples.peak_interval | def peak_interval(self, name, alpha=_alpha, npoints=_npoints, **kwargs):
"""
Calculate peak interval for parameter.
"""
data = self.get(name, **kwargs)
return peak_interval(data,alpha,npoints) | python | def peak_interval(self, name, alpha=_alpha, npoints=_npoints, **kwargs):
"""
Calculate peak interval for parameter.
"""
data = self.get(name, **kwargs)
return peak_interval(data,alpha,npoints) | [
"def",
"peak_interval",
"(",
"self",
",",
"name",
",",
"alpha",
"=",
"_alpha",
",",
"npoints",
"=",
"_npoints",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"get",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"return",
"peak_interval",
... | Calculate peak interval for parameter. | [
"Calculate",
"peak",
"interval",
"for",
"parameter",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L326-L331 | train | Calculate peak interval for a given resource. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | Samples.min_interval | def min_interval(self,name, alpha=_alpha, **kwargs):
"""
Calculate minimum interval for parameter.
"""
data = self.get(name, **kwargs)
return min_interval(data,alpha) | python | def min_interval(self,name, alpha=_alpha, **kwargs):
"""
Calculate minimum interval for parameter.
"""
data = self.get(name, **kwargs)
return min_interval(data,alpha) | [
"def",
"min_interval",
"(",
"self",
",",
"name",
",",
"alpha",
"=",
"_alpha",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"get",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"return",
"min_interval",
"(",
"data",
",",
"alpha",
")"
] | Calculate minimum interval for parameter. | [
"Calculate",
"minimum",
"interval",
"for",
"parameter",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L333-L338 | train | Calculates minimum interval for a resource. |
DarkEnergySurvey/ugali | ugali/utils/stats.py | Samples.results | def results(self, names=None, alpha=_alpha, mode='peak', **kwargs):
"""
Calculate the results for a set of parameters.
"""
if names is None: names = self.names
ret = odict()
for n in names:
ret[n] = getattr(self,'%s_interval'%mode)(n, **kwargs)
return ... | python | def results(self, names=None, alpha=_alpha, mode='peak', **kwargs):
"""
Calculate the results for a set of parameters.
"""
if names is None: names = self.names
ret = odict()
for n in names:
ret[n] = getattr(self,'%s_interval'%mode)(n, **kwargs)
return ... | [
"def",
"results",
"(",
"self",
",",
"names",
"=",
"None",
",",
"alpha",
"=",
"_alpha",
",",
"mode",
"=",
"'peak'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"names",
"is",
"None",
":",
"names",
"=",
"self",
".",
"names",
"ret",
"=",
"odict",
"(",
... | Calculate the results for a set of parameters. | [
"Calculate",
"the",
"results",
"for",
"a",
"set",
"of",
"parameters",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/stats.py#L340-L348 | train | Calculate the results for a set of parameters. |
DarkEnergySurvey/ugali | ugali/utils/parabola.py | Parabola.densify | def densify(self, factor=10):
"""
Increase the density of points along the parabolic curve.
"""
x = []
y = []
for ii in range(0, len(self.x) - 2):
p = Parabola(self.x[ii: ii + 3], self.y[ii: ii + 3])
x.append(np.linspace(self.x[ii], self.x[ii + 1],... | python | def densify(self, factor=10):
"""
Increase the density of points along the parabolic curve.
"""
x = []
y = []
for ii in range(0, len(self.x) - 2):
p = Parabola(self.x[ii: ii + 3], self.y[ii: ii + 3])
x.append(np.linspace(self.x[ii], self.x[ii + 1],... | [
"def",
"densify",
"(",
"self",
",",
"factor",
"=",
"10",
")",
":",
"x",
"=",
"[",
"]",
"y",
"=",
"[",
"]",
"for",
"ii",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"self",
".",
"x",
")",
"-",
"2",
")",
":",
"p",
"=",
"Parabola",
"(",
"self"... | Increase the density of points along the parabolic curve. | [
"Increase",
"the",
"density",
"of",
"points",
"along",
"the",
"parabolic",
"curve",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/parabola.py#L83-L105 | train | Increase the density of points along the parabolic curve. |
DarkEnergySurvey/ugali | ugali/utils/parabola.py | Parabola.profileUpperLimit | def profileUpperLimit(self, delta = 2.71):
"""
Compute one-sided upperlimit via profile method.
"""
a = self.p_2
b = self.p_1
if self.vertex_x < 0:
c = self.p_0 + delta
else:
c = self.p_0 - self.vertex_y + delta
if b**2 - 4. * a * ... | python | def profileUpperLimit(self, delta = 2.71):
"""
Compute one-sided upperlimit via profile method.
"""
a = self.p_2
b = self.p_1
if self.vertex_x < 0:
c = self.p_0 + delta
else:
c = self.p_0 - self.vertex_y + delta
if b**2 - 4. * a * ... | [
"def",
"profileUpperLimit",
"(",
"self",
",",
"delta",
"=",
"2.71",
")",
":",
"a",
"=",
"self",
".",
"p_2",
"b",
"=",
"self",
".",
"p_1",
"if",
"self",
".",
"vertex_x",
"<",
"0",
":",
"c",
"=",
"self",
".",
"p_0",
"+",
"delta",
"else",
":",
"c"... | Compute one-sided upperlimit via profile method. | [
"Compute",
"one",
"-",
"sided",
"upperlimit",
"via",
"profile",
"method",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/parabola.py#L107-L123 | train | Compute one - sided upperlimit via profile method. |
DarkEnergySurvey/ugali | ugali/utils/parabola.py | Parabola.bayesianUpperLimit | def bayesianUpperLimit(self, alpha, steps=1.e5, plot=False):
"""
Compute one-sided upper limit using Bayesian Method of Helene.
Several methods of increasing numerical stability have been implemented.
"""
x_dense, y_dense = self.densify()
y_dense -= np.max(y_dense) # Nume... | python | def bayesianUpperLimit(self, alpha, steps=1.e5, plot=False):
"""
Compute one-sided upper limit using Bayesian Method of Helene.
Several methods of increasing numerical stability have been implemented.
"""
x_dense, y_dense = self.densify()
y_dense -= np.max(y_dense) # Nume... | [
"def",
"bayesianUpperLimit",
"(",
"self",
",",
"alpha",
",",
"steps",
"=",
"1.e5",
",",
"plot",
"=",
"False",
")",
":",
"x_dense",
",",
"y_dense",
"=",
"self",
".",
"densify",
"(",
")",
"y_dense",
"-=",
"np",
".",
"max",
"(",
"y_dense",
")",
"# Numer... | Compute one-sided upper limit using Bayesian Method of Helene.
Several methods of increasing numerical stability have been implemented. | [
"Compute",
"one",
"-",
"sided",
"upper",
"limit",
"using",
"Bayesian",
"Method",
"of",
"Helene",
".",
"Several",
"methods",
"of",
"increasing",
"numerical",
"stability",
"have",
"been",
"implemented",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/parabola.py#L125-L148 | train | Compute one - sided upper limit using Bayesian Method of Helene. |
DarkEnergySurvey/ugali | ugali/utils/parabola.py | Parabola.bayesianUpperLimit2 | def bayesianUpperLimit2(self, alpha, steps=1.e5, plot=False):
"""
Compute one-sided upper limit using Bayesian Method of Helene.
"""
cut = ((self.y / 2.) > -30.) # Numeric stability
try:
f = scipy.interpolate.interp1d(self.x[cut], self.y[cut], kind='cubic')
ex... | python | def bayesianUpperLimit2(self, alpha, steps=1.e5, plot=False):
"""
Compute one-sided upper limit using Bayesian Method of Helene.
"""
cut = ((self.y / 2.) > -30.) # Numeric stability
try:
f = scipy.interpolate.interp1d(self.x[cut], self.y[cut], kind='cubic')
ex... | [
"def",
"bayesianUpperLimit2",
"(",
"self",
",",
"alpha",
",",
"steps",
"=",
"1.e5",
",",
"plot",
"=",
"False",
")",
":",
"cut",
"=",
"(",
"(",
"self",
".",
"y",
"/",
"2.",
")",
">",
"-",
"30.",
")",
"# Numeric stability",
"try",
":",
"f",
"=",
"s... | Compute one-sided upper limit using Bayesian Method of Helene. | [
"Compute",
"one",
"-",
"sided",
"upper",
"limit",
"using",
"Bayesian",
"Method",
"of",
"Helene",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/parabola.py#L150-L171 | train | Compute one - sided upper limit using Bayesian Method of Helene. |
DarkEnergySurvey/ugali | ugali/utils/parabola.py | Parabola.confidenceInterval | def confidenceInterval(self, alpha=0.6827, steps=1.e5, plot=False):
"""
Compute two-sided confidence interval by taking x-values corresponding to the largest PDF-values first.
"""
x_dense, y_dense = self.densify()
y_dense -= np.max(y_dense) # Numeric stability
f = scipy.i... | python | def confidenceInterval(self, alpha=0.6827, steps=1.e5, plot=False):
"""
Compute two-sided confidence interval by taking x-values corresponding to the largest PDF-values first.
"""
x_dense, y_dense = self.densify()
y_dense -= np.max(y_dense) # Numeric stability
f = scipy.i... | [
"def",
"confidenceInterval",
"(",
"self",
",",
"alpha",
"=",
"0.6827",
",",
"steps",
"=",
"1.e5",
",",
"plot",
"=",
"False",
")",
":",
"x_dense",
",",
"y_dense",
"=",
"self",
".",
"densify",
"(",
")",
"y_dense",
"-=",
"np",
".",
"max",
"(",
"y_dense"... | Compute two-sided confidence interval by taking x-values corresponding to the largest PDF-values first. | [
"Compute",
"two",
"-",
"sided",
"confidence",
"interval",
"by",
"taking",
"x",
"-",
"values",
"corresponding",
"to",
"the",
"largest",
"PDF",
"-",
"values",
"first",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/parabola.py#L174-L196 | train | Compute two - sided confidence interval by taking x - values corresponding to the largest PDF - values first. |
DarkEnergySurvey/ugali | ugali/utils/projector.py | aitoffSphereToImage | def aitoffSphereToImage(lon, lat):
"""
Hammer-Aitoff projection (deg).
"""
lon = lon - 360.*(lon>180)
lon = np.radians(lon)
lat = np.radians(lat)
half_lon = lon/2.
cos_lat = np.cos(lat)
gamma = (180. / np.pi) * np.sqrt(2. / (1. + (cos_lat * np.cos(half_lon))))
x = 2. * gam... | python | def aitoffSphereToImage(lon, lat):
"""
Hammer-Aitoff projection (deg).
"""
lon = lon - 360.*(lon>180)
lon = np.radians(lon)
lat = np.radians(lat)
half_lon = lon/2.
cos_lat = np.cos(lat)
gamma = (180. / np.pi) * np.sqrt(2. / (1. + (cos_lat * np.cos(half_lon))))
x = 2. * gam... | [
"def",
"aitoffSphereToImage",
"(",
"lon",
",",
"lat",
")",
":",
"lon",
"=",
"lon",
"-",
"360.",
"*",
"(",
"lon",
">",
"180",
")",
"lon",
"=",
"np",
".",
"radians",
"(",
"lon",
")",
"lat",
"=",
"np",
".",
"radians",
"(",
"lat",
")",
"half_lon",
... | Hammer-Aitoff projection (deg). | [
"Hammer",
"-",
"Aitoff",
"projection",
"(",
"deg",
")",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L159-L173 | train | Convert aitoff spherical coordinates to image coordinates. |
DarkEnergySurvey/ugali | ugali/utils/projector.py | aitoffImageToSphere | def aitoffImageToSphere(x, y):
"""
Inverse Hammer-Aitoff projection (deg).
"""
x = x - 360.*(x>180)
x = np.asarray(np.radians(x))
y = np.asarray(np.radians(y))
z = np.sqrt(1. - (x / 4.)**2 - (y / 2.)**2) # rad
lon = 2. * np.arctan2((2. * z**2) - 1, (z / 2.) * x)
lat = np.arcsin( y * ... | python | def aitoffImageToSphere(x, y):
"""
Inverse Hammer-Aitoff projection (deg).
"""
x = x - 360.*(x>180)
x = np.asarray(np.radians(x))
y = np.asarray(np.radians(y))
z = np.sqrt(1. - (x / 4.)**2 - (y / 2.)**2) # rad
lon = 2. * np.arctan2((2. * z**2) - 1, (z / 2.) * x)
lat = np.arcsin( y * ... | [
"def",
"aitoffImageToSphere",
"(",
"x",
",",
"y",
")",
":",
"x",
"=",
"x",
"-",
"360.",
"*",
"(",
"x",
">",
"180",
")",
"x",
"=",
"np",
".",
"asarray",
"(",
"np",
".",
"radians",
"(",
"x",
")",
")",
"y",
"=",
"np",
".",
"asarray",
"(",
"np"... | Inverse Hammer-Aitoff projection (deg). | [
"Inverse",
"Hammer",
"-",
"Aitoff",
"projection",
"(",
"deg",
")",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L175-L185 | train | Convert an image from Hammer - Aitoff to Sphere. |
DarkEnergySurvey/ugali | ugali/utils/projector.py | gnomonicSphereToImage | def gnomonicSphereToImage(lon, lat):
"""
Gnomonic projection (deg).
"""
# Convert angle to [-180, 180] interval
lon = lon - 360.*(lon>180)
lon = np.radians(lon)
lat = np.radians(lat)
r_theta = (180. / np.pi) / np.tan(lat)
x = r_theta * np.cos(lon)
y = r_theta * np.sin(lon)
re... | python | def gnomonicSphereToImage(lon, lat):
"""
Gnomonic projection (deg).
"""
# Convert angle to [-180, 180] interval
lon = lon - 360.*(lon>180)
lon = np.radians(lon)
lat = np.radians(lat)
r_theta = (180. / np.pi) / np.tan(lat)
x = r_theta * np.cos(lon)
y = r_theta * np.sin(lon)
re... | [
"def",
"gnomonicSphereToImage",
"(",
"lon",
",",
"lat",
")",
":",
"# Convert angle to [-180, 180] interval",
"lon",
"=",
"lon",
"-",
"360.",
"*",
"(",
"lon",
">",
"180",
")",
"lon",
"=",
"np",
".",
"radians",
"(",
"lon",
")",
"lat",
"=",
"np",
".",
"ra... | Gnomonic projection (deg). | [
"Gnomonic",
"projection",
"(",
"deg",
")",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L189-L200 | train | Convert a point on the gnomonic sphere to an image. |
DarkEnergySurvey/ugali | ugali/utils/projector.py | gnomonicImageToSphere | def gnomonicImageToSphere(x, y):
"""
Inverse gnomonic projection (deg).
"""
# Convert angle to [-180, 180] interval
x = x - 360.*(x>180)
x = np.asarray(x)
y = np.asarray(y)
lon = np.degrees(np.arctan2(y, x))
r_theta = np.sqrt(x**2 + y**2)
lat = np.degrees(np.arctan(180. / (np.pi ... | python | def gnomonicImageToSphere(x, y):
"""
Inverse gnomonic projection (deg).
"""
# Convert angle to [-180, 180] interval
x = x - 360.*(x>180)
x = np.asarray(x)
y = np.asarray(y)
lon = np.degrees(np.arctan2(y, x))
r_theta = np.sqrt(x**2 + y**2)
lat = np.degrees(np.arctan(180. / (np.pi ... | [
"def",
"gnomonicImageToSphere",
"(",
"x",
",",
"y",
")",
":",
"# Convert angle to [-180, 180] interval",
"x",
"=",
"x",
"-",
"360.",
"*",
"(",
"x",
">",
"180",
")",
"x",
"=",
"np",
".",
"asarray",
"(",
"x",
")",
"y",
"=",
"np",
".",
"asarray",
"(",
... | Inverse gnomonic projection (deg). | [
"Inverse",
"gnomonic",
"projection",
"(",
"deg",
")",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L202-L213 | train | Convert a Gnomonic image to a Sphere. |
DarkEnergySurvey/ugali | ugali/utils/projector.py | angsep2 | def angsep2(lon_1, lat_1, lon_2, lat_2):
"""
Angular separation (deg) between two sky coordinates.
"""
import healpy
v10, v11, v12 = healpy.ang2vec(np.radians(90. - lat_1), np.radians(lon_1)).transpose()
v20, v21, v22 = healpy.ang2vec(np.radians(90. - lat_2), np.radians(lon_2)).transpose()
... | python | def angsep2(lon_1, lat_1, lon_2, lat_2):
"""
Angular separation (deg) between two sky coordinates.
"""
import healpy
v10, v11, v12 = healpy.ang2vec(np.radians(90. - lat_1), np.radians(lon_1)).transpose()
v20, v21, v22 = healpy.ang2vec(np.radians(90. - lat_2), np.radians(lon_2)).transpose()
... | [
"def",
"angsep2",
"(",
"lon_1",
",",
"lat_1",
",",
"lon_2",
",",
"lat_2",
")",
":",
"import",
"healpy",
"v10",
",",
"v11",
",",
"v12",
"=",
"healpy",
".",
"ang2vec",
"(",
"np",
".",
"radians",
"(",
"90.",
"-",
"lat_1",
")",
",",
"np",
".",
"radia... | Angular separation (deg) between two sky coordinates. | [
"Angular",
"separation",
"(",
"deg",
")",
"between",
"two",
"sky",
"coordinates",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L217-L227 | train | Returns the angle between two sky coordinates. |
DarkEnergySurvey/ugali | ugali/utils/projector.py | galToCel | def galToCel(ll, bb):
"""
Converts Galactic (deg) to Celestial J2000 (deg) coordinates
"""
bb = np.radians(bb)
sin_bb = np.sin(bb)
cos_bb = np.cos(bb)
ll = np.radians(ll)
ra_gp = np.radians(192.85948)
de_gp = np.radians(27.12825)
lcp = np.radians(122.932)
sin_lcp_ll = np.si... | python | def galToCel(ll, bb):
"""
Converts Galactic (deg) to Celestial J2000 (deg) coordinates
"""
bb = np.radians(bb)
sin_bb = np.sin(bb)
cos_bb = np.cos(bb)
ll = np.radians(ll)
ra_gp = np.radians(192.85948)
de_gp = np.radians(27.12825)
lcp = np.radians(122.932)
sin_lcp_ll = np.si... | [
"def",
"galToCel",
"(",
"ll",
",",
"bb",
")",
":",
"bb",
"=",
"np",
".",
"radians",
"(",
"bb",
")",
"sin_bb",
"=",
"np",
".",
"sin",
"(",
"bb",
")",
"cos_bb",
"=",
"np",
".",
"cos",
"(",
"bb",
")",
"ll",
"=",
"np",
".",
"radians",
"(",
"ll"... | Converts Galactic (deg) to Celestial J2000 (deg) coordinates | [
"Converts",
"Galactic",
"(",
"deg",
")",
"to",
"Celestial",
"J2000",
"(",
"deg",
")",
"coordinates"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L262-L285 | train | Converts Galactic to Celestial J2000 coordinates |
DarkEnergySurvey/ugali | ugali/utils/projector.py | celToGal | def celToGal(ra, dec):
"""
Converts Celestial J2000 (deg) to Calactic (deg) coordinates
"""
dec = np.radians(dec)
sin_dec = np.sin(dec)
cos_dec = np.cos(dec)
ra = np.radians(ra)
ra_gp = np.radians(192.85948)
de_gp = np.radians(27.12825)
sin_ra_gp = np.sin(ra - ra_gp)
co... | python | def celToGal(ra, dec):
"""
Converts Celestial J2000 (deg) to Calactic (deg) coordinates
"""
dec = np.radians(dec)
sin_dec = np.sin(dec)
cos_dec = np.cos(dec)
ra = np.radians(ra)
ra_gp = np.radians(192.85948)
de_gp = np.radians(27.12825)
sin_ra_gp = np.sin(ra - ra_gp)
co... | [
"def",
"celToGal",
"(",
"ra",
",",
"dec",
")",
":",
"dec",
"=",
"np",
".",
"radians",
"(",
"dec",
")",
"sin_dec",
"=",
"np",
".",
"sin",
"(",
"dec",
")",
"cos_dec",
"=",
"np",
".",
"cos",
"(",
"dec",
")",
"ra",
"=",
"np",
".",
"radians",
"(",... | Converts Celestial J2000 (deg) to Calactic (deg) coordinates | [
"Converts",
"Celestial",
"J2000",
"(",
"deg",
")",
"to",
"Calactic",
"(",
"deg",
")",
"coordinates"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L289-L312 | train | Converts a Celestial J2000 to a Calactic. |
DarkEnergySurvey/ugali | ugali/utils/projector.py | estimate_angle | def estimate_angle(angle, origin, new_frame, offset=1e-7):
"""
https://github.com/astropy/astropy/issues/3093
"""
from astropy.coordinates import SkyCoord
import astropy.units as u
angle_deg = angle*np.pi/180
newlat = offset * np.cos(angle_deg) + origin.data.lat.degree
newlon = (offset *... | python | def estimate_angle(angle, origin, new_frame, offset=1e-7):
"""
https://github.com/astropy/astropy/issues/3093
"""
from astropy.coordinates import SkyCoord
import astropy.units as u
angle_deg = angle*np.pi/180
newlat = offset * np.cos(angle_deg) + origin.data.lat.degree
newlon = (offset *... | [
"def",
"estimate_angle",
"(",
"angle",
",",
"origin",
",",
"new_frame",
",",
"offset",
"=",
"1e-7",
")",
":",
"from",
"astropy",
".",
"coordinates",
"import",
"SkyCoord",
"import",
"astropy",
".",
"units",
"as",
"u",
"angle_deg",
"=",
"angle",
"*",
"np",
... | https://github.com/astropy/astropy/issues/3093 | [
"https",
":",
"//",
"github",
".",
"com",
"/",
"astropy",
"/",
"astropy",
"/",
"issues",
"/",
"3093"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L316-L328 | train | Estimate the angle of a node in a new frame. |
DarkEnergySurvey/ugali | ugali/utils/projector.py | dec2hms | def dec2hms(dec):
"""
ADW: This should really be replaced by astropy
"""
DEGREE = 360.
HOUR = 24.
MINUTE = 60.
SECOND = 3600.
dec = float(dec)
fhour = dec*(HOUR/DEGREE)
hour = int(fhour)
fminute = (fhour - hour)*MINUTE
minute = int(fminute)
second = (fminut... | python | def dec2hms(dec):
"""
ADW: This should really be replaced by astropy
"""
DEGREE = 360.
HOUR = 24.
MINUTE = 60.
SECOND = 3600.
dec = float(dec)
fhour = dec*(HOUR/DEGREE)
hour = int(fhour)
fminute = (fhour - hour)*MINUTE
minute = int(fminute)
second = (fminut... | [
"def",
"dec2hms",
"(",
"dec",
")",
":",
"DEGREE",
"=",
"360.",
"HOUR",
"=",
"24.",
"MINUTE",
"=",
"60.",
"SECOND",
"=",
"3600.",
"dec",
"=",
"float",
"(",
"dec",
")",
"fhour",
"=",
"dec",
"*",
"(",
"HOUR",
"/",
"DEGREE",
")",
"hour",
"=",
"int",
... | ADW: This should really be replaced by astropy | [
"ADW",
":",
"This",
"should",
"really",
"be",
"replaced",
"by",
"astropy"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L380-L397 | train | Convert decimal degrees to hours minutes and seconds. |
DarkEnergySurvey/ugali | ugali/utils/projector.py | dec2dms | def dec2dms(dec):
"""
ADW: This should really be replaced by astropy
"""
DEGREE = 360.
HOUR = 24.
MINUTE = 60.
SECOND = 3600.
dec = float(dec)
sign = np.copysign(1.0,dec)
fdeg = np.abs(dec)
deg = int(fdeg)
fminute = (fdeg - deg)*MINUTE
minute = int(fminute)
... | python | def dec2dms(dec):
"""
ADW: This should really be replaced by astropy
"""
DEGREE = 360.
HOUR = 24.
MINUTE = 60.
SECOND = 3600.
dec = float(dec)
sign = np.copysign(1.0,dec)
fdeg = np.abs(dec)
deg = int(fdeg)
fminute = (fdeg - deg)*MINUTE
minute = int(fminute)
... | [
"def",
"dec2dms",
"(",
"dec",
")",
":",
"DEGREE",
"=",
"360.",
"HOUR",
"=",
"24.",
"MINUTE",
"=",
"60.",
"SECOND",
"=",
"3600.",
"dec",
"=",
"float",
"(",
"dec",
")",
"sign",
"=",
"np",
".",
"copysign",
"(",
"1.0",
",",
"dec",
")",
"fdeg",
"=",
... | ADW: This should really be replaced by astropy | [
"ADW",
":",
"This",
"should",
"really",
"be",
"replaced",
"by",
"astropy"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L399-L420 | train | Convert a decimal degrees to degrees minutes and seconds. |
DarkEnergySurvey/ugali | ugali/utils/projector.py | hms2dec | def hms2dec(hms):
"""
Convert longitude from hours,minutes,seconds in string or 3-array
format to decimal degrees.
ADW: This really should be replaced by astropy
"""
DEGREE = 360.
HOUR = 24.
MINUTE = 60.
SECOND = 3600.
if isstring(hms):
hour,minute,second = np.array(re.... | python | def hms2dec(hms):
"""
Convert longitude from hours,minutes,seconds in string or 3-array
format to decimal degrees.
ADW: This really should be replaced by astropy
"""
DEGREE = 360.
HOUR = 24.
MINUTE = 60.
SECOND = 3600.
if isstring(hms):
hour,minute,second = np.array(re.... | [
"def",
"hms2dec",
"(",
"hms",
")",
":",
"DEGREE",
"=",
"360.",
"HOUR",
"=",
"24.",
"MINUTE",
"=",
"60.",
"SECOND",
"=",
"3600.",
"if",
"isstring",
"(",
"hms",
")",
":",
"hour",
",",
"minute",
",",
"second",
"=",
"np",
".",
"array",
"(",
"re",
"."... | Convert longitude from hours,minutes,seconds in string or 3-array
format to decimal degrees.
ADW: This really should be replaced by astropy | [
"Convert",
"longitude",
"from",
"hours",
"minutes",
"seconds",
"in",
"string",
"or",
"3",
"-",
"array",
"format",
"to",
"decimal",
"degrees",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L422-L440 | train | Convert longitude from hours minutes seconds in string or 3 - array
format to decimal degrees. |
DarkEnergySurvey/ugali | ugali/utils/projector.py | dms2dec | def dms2dec(dms):
"""
Convert latitude from degrees,minutes,seconds in string or 3-array
format to decimal degrees.
"""
DEGREE = 360.
HOUR = 24.
MINUTE = 60.
SECOND = 3600.
# Be careful here, degree needs to be a float so that negative zero
# can have its signbit set:
# http:... | python | def dms2dec(dms):
"""
Convert latitude from degrees,minutes,seconds in string or 3-array
format to decimal degrees.
"""
DEGREE = 360.
HOUR = 24.
MINUTE = 60.
SECOND = 3600.
# Be careful here, degree needs to be a float so that negative zero
# can have its signbit set:
# http:... | [
"def",
"dms2dec",
"(",
"dms",
")",
":",
"DEGREE",
"=",
"360.",
"HOUR",
"=",
"24.",
"MINUTE",
"=",
"60.",
"SECOND",
"=",
"3600.",
"# Be careful here, degree needs to be a float so that negative zero",
"# can have its signbit set:",
"# http://docs.scipy.org/doc/numpy-1.7.0/refe... | Convert latitude from degrees,minutes,seconds in string or 3-array
format to decimal degrees. | [
"Convert",
"latitude",
"from",
"degrees",
"minutes",
"seconds",
"in",
"string",
"or",
"3",
"-",
"array",
"format",
"to",
"decimal",
"degrees",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L442-L464 | train | Convert latitude from degrees minutes seconds in string or 3 - array
format to decimal degrees. |
DarkEnergySurvey/ugali | ugali/utils/projector.py | match | def match(lon1, lat1, lon2, lat2, tol=None, nnearest=1):
"""
Adapted from Eric Tollerud.
Finds matches in one catalog to another.
Parameters
lon1 : array-like
Longitude of the first catalog (degrees)
lat1 : array-like
Latitude of the first catalog (shape of array must match `lo... | python | def match(lon1, lat1, lon2, lat2, tol=None, nnearest=1):
"""
Adapted from Eric Tollerud.
Finds matches in one catalog to another.
Parameters
lon1 : array-like
Longitude of the first catalog (degrees)
lat1 : array-like
Latitude of the first catalog (shape of array must match `lo... | [
"def",
"match",
"(",
"lon1",
",",
"lat1",
",",
"lon2",
",",
"lat2",
",",
"tol",
"=",
"None",
",",
"nnearest",
"=",
"1",
")",
":",
"from",
"scipy",
".",
"spatial",
"import",
"cKDTree",
"lon1",
"=",
"np",
".",
"asarray",
"(",
"lon1",
")",
"lat1",
"... | Adapted from Eric Tollerud.
Finds matches in one catalog to another.
Parameters
lon1 : array-like
Longitude of the first catalog (degrees)
lat1 : array-like
Latitude of the first catalog (shape of array must match `lon1`)
lon2 : array-like
Longitude of the second catalog
... | [
"Adapted",
"from",
"Eric",
"Tollerud",
".",
"Finds",
"matches",
"in",
"one",
"catalog",
"to",
"another",
".",
"Parameters",
"lon1",
":",
"array",
"-",
"like",
"Longitude",
"of",
"the",
"first",
"catalog",
"(",
"degrees",
")",
"lat1",
":",
"array",
"-",
"... | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L541-L621 | train | Returns a new tree that matches the given two points. |
warrenspe/hconf | hconf/subparsers/cmdline.py | Cmdline.getArgumentParser | def getArgumentParser(self, configManager, config):
"""
May be overidden to provide custom functionality.
Constructs an argparse.ArgumentParser used to parse configuration options from the command line.
Inputs: configManager - Our parent ConfigManager instance which is constructing the ... | python | def getArgumentParser(self, configManager, config):
"""
May be overidden to provide custom functionality.
Constructs an argparse.ArgumentParser used to parse configuration options from the command line.
Inputs: configManager - Our parent ConfigManager instance which is constructing the ... | [
"def",
"getArgumentParser",
"(",
"self",
",",
"configManager",
",",
"config",
")",
":",
"argParser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"self",
".",
"description",
")",
"for",
"configName",
",",
"configDict",
"in",
"configManager",
".",
"configs",
".... | May be overidden to provide custom functionality.
Constructs an argparse.ArgumentParser used to parse configuration options from the command line.
Inputs: configManager - Our parent ConfigManager instance which is constructing the Config object.
config - The _Config object contai... | [
"May",
"be",
"overidden",
"to",
"provide",
"custom",
"functionality",
".",
"Constructs",
"an",
"argparse",
".",
"ArgumentParser",
"used",
"to",
"parse",
"configuration",
"options",
"from",
"the",
"command",
"line",
"."
] | 12074d15dc3641d3903488c95d89a507386a32d5 | https://github.com/warrenspe/hconf/blob/12074d15dc3641d3903488c95d89a507386a32d5/hconf/subparsers/cmdline.py#L41-L61 | train | This method returns an argparse. ArgumentParser object that can be used to parse configuration options from the command line. |
warrenspe/hconf | hconf/subparsers/cmdline.py | Cmdline.parse | def parse(self, configManager, config):
"""
Parses commandline arguments, given a series of configuration options.
Inputs: configManager - Our parent ConfigManager instance which is constructing the Config object.
config - The _Config object containing configuration optio... | python | def parse(self, configManager, config):
"""
Parses commandline arguments, given a series of configuration options.
Inputs: configManager - Our parent ConfigManager instance which is constructing the Config object.
config - The _Config object containing configuration optio... | [
"def",
"parse",
"(",
"self",
",",
"configManager",
",",
"config",
")",
":",
"argParser",
"=",
"self",
".",
"getArgumentParser",
"(",
"configManager",
",",
"config",
")",
"return",
"vars",
"(",
"argParser",
".",
"parse_args",
"(",
")",
")"
] | Parses commandline arguments, given a series of configuration options.
Inputs: configManager - Our parent ConfigManager instance which is constructing the Config object.
config - The _Config object containing configuration options populated thus far.
Outputs: A dictionary of new... | [
"Parses",
"commandline",
"arguments",
"given",
"a",
"series",
"of",
"configuration",
"options",
"."
] | 12074d15dc3641d3903488c95d89a507386a32d5 | https://github.com/warrenspe/hconf/blob/12074d15dc3641d3903488c95d89a507386a32d5/hconf/subparsers/cmdline.py#L63-L74 | train | Parses commandline arguments and returns a dictionary of new configuration options. |
totalgood/pugnlp | src/pugnlp/detector_morse.py | Detector.candidates | def candidates(text):
"""
Given a `text` string, get candidates and context for feature
extraction and classification
"""
for Pmatch in finditer(TARGET, text):
# the punctuation mark itself
P = Pmatch.group(1)
# is it a boundary?
B ... | python | def candidates(text):
"""
Given a `text` string, get candidates and context for feature
extraction and classification
"""
for Pmatch in finditer(TARGET, text):
# the punctuation mark itself
P = Pmatch.group(1)
# is it a boundary?
B ... | [
"def",
"candidates",
"(",
"text",
")",
":",
"for",
"Pmatch",
"in",
"finditer",
"(",
"TARGET",
",",
"text",
")",
":",
"# the punctuation mark itself",
"P",
"=",
"Pmatch",
".",
"group",
"(",
"1",
")",
"# is it a boundary?",
"B",
"=",
"bool",
"(",
"match",
... | Given a `text` string, get candidates and context for feature
extraction and classification | [
"Given",
"a",
"text",
"string",
"get",
"candidates",
"and",
"context",
"for",
"feature",
"extraction",
"and",
"classification"
] | c43445b14afddfdeadc5f3076675c9e8fc1ee67c | https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/detector_morse.py#L105-L127 | train | Given a text string get candidates and context for feature
extraction and classification
|
totalgood/pugnlp | src/pugnlp/detector_morse.py | Detector.extract_one | def extract_one(self, L, P, R):
"""
Given left context `L`, punctuation mark `P`, and right context
R`, extract features. Probability distributions for any
quantile-based features will not be modified.
"""
yield "*bias*"
# L feature(s)
if match(QUOTE, L):
... | python | def extract_one(self, L, P, R):
"""
Given left context `L`, punctuation mark `P`, and right context
R`, extract features. Probability distributions for any
quantile-based features will not be modified.
"""
yield "*bias*"
# L feature(s)
if match(QUOTE, L):
... | [
"def",
"extract_one",
"(",
"self",
",",
"L",
",",
"P",
",",
"R",
")",
":",
"yield",
"\"*bias*\"",
"# L feature(s)",
"if",
"match",
"(",
"QUOTE",
",",
"L",
")",
":",
"L",
"=",
"QUOTE_TOKEN",
"elif",
"isnumberlike",
"(",
"L",
")",
":",
"L",
"=",
"NUM... | Given left context `L`, punctuation mark `P`, and right context
R`, extract features. Probability distributions for any
quantile-based features will not be modified. | [
"Given",
"left",
"context",
"L",
"punctuation",
"mark",
"P",
"and",
"right",
"context",
"R",
"extract",
"features",
".",
"Probability",
"distributions",
"for",
"any",
"quantile",
"-",
"based",
"features",
"will",
"not",
"be",
"modified",
"."
] | c43445b14afddfdeadc5f3076675c9e8fc1ee67c | https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/detector_morse.py#L132-L173 | train | Given left context L punctuation mark P and right context R extract features. |
totalgood/pugnlp | src/pugnlp/detector_morse.py | Detector.fit | def fit(self, text, epochs=EPOCHS):
""" Given a string `text`, use it to train the segmentation classifier for `epochs` iterations.
"""
logger.debug("Extracting features and classifications.")
Phi = []
Y = []
for (L, P, R, gold, _) in Detector.candidates(text):
... | python | def fit(self, text, epochs=EPOCHS):
""" Given a string `text`, use it to train the segmentation classifier for `epochs` iterations.
"""
logger.debug("Extracting features and classifications.")
Phi = []
Y = []
for (L, P, R, gold, _) in Detector.candidates(text):
... | [
"def",
"fit",
"(",
"self",
",",
"text",
",",
"epochs",
"=",
"EPOCHS",
")",
":",
"logger",
".",
"debug",
"(",
"\"Extracting features and classifications.\"",
")",
"Phi",
"=",
"[",
"]",
"Y",
"=",
"[",
"]",
"for",
"(",
"L",
",",
"P",
",",
"R",
",",
"g... | Given a string `text`, use it to train the segmentation classifier for `epochs` iterations. | [
"Given",
"a",
"string",
"text",
"use",
"it",
"to",
"train",
"the",
"segmentation",
"classifier",
"for",
"epochs",
"iterations",
"."
] | c43445b14afddfdeadc5f3076675c9e8fc1ee67c | https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/detector_morse.py#L177-L187 | train | Given a string text use it to train the segmentation classifier for epochs iterations. |
totalgood/pugnlp | src/pugnlp/detector_morse.py | Detector.predict | def predict(self, L, P, R):
"""
Given an left context `L`, punctuation mark `P`, and right context
`R`, return True iff this observation is hypothesized to be a
sentence boundary.
"""
phi = self.extract_one(L, P, R)
return self.classifier.predict(phi) | python | def predict(self, L, P, R):
"""
Given an left context `L`, punctuation mark `P`, and right context
`R`, return True iff this observation is hypothesized to be a
sentence boundary.
"""
phi = self.extract_one(L, P, R)
return self.classifier.predict(phi) | [
"def",
"predict",
"(",
"self",
",",
"L",
",",
"P",
",",
"R",
")",
":",
"phi",
"=",
"self",
".",
"extract_one",
"(",
"L",
",",
"P",
",",
"R",
")",
"return",
"self",
".",
"classifier",
".",
"predict",
"(",
"phi",
")"
] | Given an left context `L`, punctuation mark `P`, and right context
`R`, return True iff this observation is hypothesized to be a
sentence boundary. | [
"Given",
"an",
"left",
"context",
"L",
"punctuation",
"mark",
"P",
"and",
"right",
"context",
"R",
"return",
"True",
"iff",
"this",
"observation",
"is",
"hypothesized",
"to",
"be",
"a",
"sentence",
"boundary",
"."
] | c43445b14afddfdeadc5f3076675c9e8fc1ee67c | https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/detector_morse.py#L189-L196 | train | Given an observation L P and R return True iff this observation is hypothesized to be a
sentence boundary. |
totalgood/pugnlp | src/pugnlp/detector_morse.py | Detector.segments | def segments(self, text):
"""
Given a string of `text`, return a generator yielding each
hypothesized sentence string
"""
start = 0
for (L, P, R, B, end) in Detector.candidates(text):
# if there's already a newline there, we have nothing to do
if B... | python | def segments(self, text):
"""
Given a string of `text`, return a generator yielding each
hypothesized sentence string
"""
start = 0
for (L, P, R, B, end) in Detector.candidates(text):
# if there's already a newline there, we have nothing to do
if B... | [
"def",
"segments",
"(",
"self",
",",
"text",
")",
":",
"start",
"=",
"0",
"for",
"(",
"L",
",",
"P",
",",
"R",
",",
"B",
",",
"end",
")",
"in",
"Detector",
".",
"candidates",
"(",
"text",
")",
":",
"# if there's already a newline there, we have nothing t... | Given a string of `text`, return a generator yielding each
hypothesized sentence string | [
"Given",
"a",
"string",
"of",
"text",
"return",
"a",
"generator",
"yielding",
"each",
"hypothesized",
"sentence",
"string"
] | c43445b14afddfdeadc5f3076675c9e8fc1ee67c | https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/detector_morse.py#L198-L212 | train | Given a string of text return a generator yielding each hypothesized sentence string |
totalgood/pugnlp | src/pugnlp/detector_morse.py | Detector.evaluate | def evaluate(self, text):
"""
Given a string of `text`, compute confusion matrix for the
classification task.
"""
cx = BinaryConfusion()
for (L, P, R, gold, _) in Detector.candidates(text):
guess = self.predict(L, P, R)
cx.update(gold, guess)
... | python | def evaluate(self, text):
"""
Given a string of `text`, compute confusion matrix for the
classification task.
"""
cx = BinaryConfusion()
for (L, P, R, gold, _) in Detector.candidates(text):
guess = self.predict(L, P, R)
cx.update(gold, guess)
... | [
"def",
"evaluate",
"(",
"self",
",",
"text",
")",
":",
"cx",
"=",
"BinaryConfusion",
"(",
")",
"for",
"(",
"L",
",",
"P",
",",
"R",
",",
"gold",
",",
"_",
")",
"in",
"Detector",
".",
"candidates",
"(",
"text",
")",
":",
"guess",
"=",
"self",
".... | Given a string of `text`, compute confusion matrix for the
classification task. | [
"Given",
"a",
"string",
"of",
"text",
"compute",
"confusion",
"matrix",
"for",
"the",
"classification",
"task",
"."
] | c43445b14afddfdeadc5f3076675c9e8fc1ee67c | https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/detector_morse.py#L214-L227 | train | Given a string of text compute the confusion matrix for the classification task. |
DarkEnergySurvey/ugali | ugali/observation/mask.py | readMangleFile | def readMangleFile(infile, lon, lat, index = None):
"""
DEPRECATED: 2018-05-04
Mangle must be set up on your system.
The index argument is a temporary file naming convention to avoid file conflicts.
Coordinates must be given in the native coordinate system of the Mangle file.
"""
msg = "'mas... | python | def readMangleFile(infile, lon, lat, index = None):
"""
DEPRECATED: 2018-05-04
Mangle must be set up on your system.
The index argument is a temporary file naming convention to avoid file conflicts.
Coordinates must be given in the native coordinate system of the Mangle file.
"""
msg = "'mas... | [
"def",
"readMangleFile",
"(",
"infile",
",",
"lon",
",",
"lat",
",",
"index",
"=",
"None",
")",
":",
"msg",
"=",
"\"'mask.readMangleFile': ADW 2018-05-05\"",
"DeprecationWarning",
"(",
"msg",
")",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"np",
".",
... | DEPRECATED: 2018-05-04
Mangle must be set up on your system.
The index argument is a temporary file naming convention to avoid file conflicts.
Coordinates must be given in the native coordinate system of the Mangle file. | [
"DEPRECATED",
":",
"2018",
"-",
"05",
"-",
"04",
"Mangle",
"must",
"be",
"set",
"up",
"on",
"your",
"system",
".",
"The",
"index",
"argument",
"is",
"a",
"temporary",
"file",
"naming",
"convention",
"to",
"avoid",
"file",
"conflicts",
".",
"Coordinates",
... | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/observation/mask.py#L946-L994 | train | Reads a Mangle file and returns a numpy array. |
DarkEnergySurvey/ugali | ugali/observation/mask.py | scale | def scale(mask, mag_scale, outfile=None):
"""
Scale the completeness depth of a mask such that mag_new = mag + mag_scale.
Input is a full HEALPix map.
Optionally write out the scaled mask as an sparse HEALPix map.
"""
msg = "'mask.scale': ADW 2018-05-05"
DeprecationWarning(msg)
mask_new ... | python | def scale(mask, mag_scale, outfile=None):
"""
Scale the completeness depth of a mask such that mag_new = mag + mag_scale.
Input is a full HEALPix map.
Optionally write out the scaled mask as an sparse HEALPix map.
"""
msg = "'mask.scale': ADW 2018-05-05"
DeprecationWarning(msg)
mask_new ... | [
"def",
"scale",
"(",
"mask",
",",
"mag_scale",
",",
"outfile",
"=",
"None",
")",
":",
"msg",
"=",
"\"'mask.scale': ADW 2018-05-05\"",
"DeprecationWarning",
"(",
"msg",
")",
"mask_new",
"=",
"hp",
".",
"UNSEEN",
"*",
"np",
".",
"ones",
"(",
"len",
"(",
"m... | Scale the completeness depth of a mask such that mag_new = mag + mag_scale.
Input is a full HEALPix map.
Optionally write out the scaled mask as an sparse HEALPix map. | [
"Scale",
"the",
"completeness",
"depth",
"of",
"a",
"mask",
"such",
"that",
"mag_new",
"=",
"mag",
"+",
"mag_scale",
".",
"Input",
"is",
"a",
"full",
"HEALPix",
"map",
".",
"Optionally",
"write",
"out",
"the",
"scaled",
"mask",
"as",
"an",
"sparse",
"HEA... | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/observation/mask.py#L1007-L1025 | train | Scale the completeness depth of a HEALPix map. |
DarkEnergySurvey/ugali | ugali/observation/mask.py | Mask.mask_roi_unique | def mask_roi_unique(self):
"""
Assemble a set of unique magnitude tuples for the ROI
"""
# There is no good inherent way in numpy to do this...
# http://stackoverflow.com/q/16970982/
# Also possible and simple:
#return np.unique(zip(self.mask_1.mask_roi_sparse,se... | python | def mask_roi_unique(self):
"""
Assemble a set of unique magnitude tuples for the ROI
"""
# There is no good inherent way in numpy to do this...
# http://stackoverflow.com/q/16970982/
# Also possible and simple:
#return np.unique(zip(self.mask_1.mask_roi_sparse,se... | [
"def",
"mask_roi_unique",
"(",
"self",
")",
":",
"# There is no good inherent way in numpy to do this...",
"# http://stackoverflow.com/q/16970982/",
"# Also possible and simple:",
"#return np.unique(zip(self.mask_1.mask_roi_sparse,self.mask_2.mask_roi_sparse))",
"A",
"=",
"np",
".",
"vst... | Assemble a set of unique magnitude tuples for the ROI | [
"Assemble",
"a",
"set",
"of",
"unique",
"magnitude",
"tuples",
"for",
"the",
"ROI"
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/observation/mask.py#L55-L67 | train | Assemble a set of unique magnitude tuples for the ROI
|
DarkEnergySurvey/ugali | ugali/observation/mask.py | Mask.mask_roi_digi | def mask_roi_digi(self):
"""
Get the index of the unique magnitude tuple for each pixel in the ROI.
"""
# http://stackoverflow.com/q/24205045/#24206440
A = np.vstack([self.mask_1.mask_roi_sparse,self.mask_2.mask_roi_sparse]).T
B = self.mask_roi_unique
AA = np.asc... | python | def mask_roi_digi(self):
"""
Get the index of the unique magnitude tuple for each pixel in the ROI.
"""
# http://stackoverflow.com/q/24205045/#24206440
A = np.vstack([self.mask_1.mask_roi_sparse,self.mask_2.mask_roi_sparse]).T
B = self.mask_roi_unique
AA = np.asc... | [
"def",
"mask_roi_digi",
"(",
"self",
")",
":",
"# http://stackoverflow.com/q/24205045/#24206440",
"A",
"=",
"np",
".",
"vstack",
"(",
"[",
"self",
".",
"mask_1",
".",
"mask_roi_sparse",
",",
"self",
".",
"mask_2",
".",
"mask_roi_sparse",
"]",
")",
".",
"T",
... | Get the index of the unique magnitude tuple for each pixel in the ROI. | [
"Get",
"the",
"index",
"of",
"the",
"unique",
"magnitude",
"tuple",
"for",
"each",
"pixel",
"in",
"the",
"ROI",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/observation/mask.py#L70-L87 | train | Get the index of the unique magnitude tuple for each pixel in the ROI. |
DarkEnergySurvey/ugali | ugali/observation/mask.py | Mask._fracRoiSparse | def _fracRoiSparse(self):
"""
Calculate an approximate pixel coverage fraction from the two masks.
We have no way to know a priori how much the coverage of the
two masks overlap in a give pixel. For example, masks that each
have frac = 0.5 could have a combined frac = [0.0 to 0.... | python | def _fracRoiSparse(self):
"""
Calculate an approximate pixel coverage fraction from the two masks.
We have no way to know a priori how much the coverage of the
two masks overlap in a give pixel. For example, masks that each
have frac = 0.5 could have a combined frac = [0.0 to 0.... | [
"def",
"_fracRoiSparse",
"(",
"self",
")",
":",
"self",
".",
"frac_roi_sparse",
"=",
"np",
".",
"min",
"(",
"[",
"self",
".",
"mask_1",
".",
"frac_roi_sparse",
",",
"self",
".",
"mask_2",
".",
"frac_roi_sparse",
"]",
",",
"axis",
"=",
"0",
")",
"return... | Calculate an approximate pixel coverage fraction from the two masks.
We have no way to know a priori how much the coverage of the
two masks overlap in a give pixel. For example, masks that each
have frac = 0.5 could have a combined frac = [0.0 to 0.5].
The limits will be:
ma... | [
"Calculate",
"an",
"approximate",
"pixel",
"coverage",
"fraction",
"from",
"the",
"two",
"masks",
"."
] | 21e890b4117fc810afb6fb058e8055d564f03382 | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/observation/mask.py#L97-L113 | train | Calculate an approximate pixel coverage fraction from the two masks. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.