id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
45,300 | jgorset/django-respite | respite/decorators.py | before | def before(method_name):
"""
Run the given method prior to the decorated view.
If you return anything besides ``None`` from the given method,
its return values will replace the arguments of the decorated
view.
If you return an instance of ``HttpResponse`` from the given method,
Respite wil... | python | def before(method_name):
"""
Run the given method prior to the decorated view.
If you return anything besides ``None`` from the given method,
its return values will replace the arguments of the decorated
view.
If you return an instance of ``HttpResponse`` from the given method,
Respite wil... | [
"def",
"before",
"(",
"method_name",
")",
":",
"def",
"decorator",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"returns",
"=",
"getattr",
"(",
"s... | Run the given method prior to the decorated view.
If you return anything besides ``None`` from the given method,
its return values will replace the arguments of the decorated
view.
If you return an instance of ``HttpResponse`` from the given method,
Respite will return it immediately without deleg... | [
"Run",
"the",
"given",
"method",
"prior",
"to",
"the",
"decorated",
"view",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/decorators.py#L54-L101 |
45,301 | jgorset/django-respite | respite/views/resource.py | Resource.index | def index(self, request):
"""Render a list of objects."""
objects = self.model.objects.all()
return self._render(
request = request,
template = 'index',
context = {
cc2us(pluralize(self.model.__name__)): objects,
},
sta... | python | def index(self, request):
"""Render a list of objects."""
objects = self.model.objects.all()
return self._render(
request = request,
template = 'index',
context = {
cc2us(pluralize(self.model.__name__)): objects,
},
sta... | [
"def",
"index",
"(",
"self",
",",
"request",
")",
":",
"objects",
"=",
"self",
".",
"model",
".",
"objects",
".",
"all",
"(",
")",
"return",
"self",
".",
"_render",
"(",
"request",
"=",
"request",
",",
"template",
"=",
"'index'",
",",
"context",
"=",... | Render a list of objects. | [
"Render",
"a",
"list",
"of",
"objects",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/views/resource.py#L31-L42 |
45,302 | jgorset/django-respite | respite/views/resource.py | Resource.new | def new(self, request):
"""Render a form to create a new object."""
form = (self.form or generate_form(self.model))()
return self._render(
request = request,
template = 'new',
context = {
'form': form
},
status = 200
... | python | def new(self, request):
"""Render a form to create a new object."""
form = (self.form or generate_form(self.model))()
return self._render(
request = request,
template = 'new',
context = {
'form': form
},
status = 200
... | [
"def",
"new",
"(",
"self",
",",
"request",
")",
":",
"form",
"=",
"(",
"self",
".",
"form",
"or",
"generate_form",
"(",
"self",
".",
"model",
")",
")",
"(",
")",
"return",
"self",
".",
"_render",
"(",
"request",
"=",
"request",
",",
"template",
"="... | Render a form to create a new object. | [
"Render",
"a",
"form",
"to",
"create",
"a",
"new",
"object",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/views/resource.py#L78-L89 |
45,303 | jgorset/django-respite | respite/views/resource.py | Resource.edit | def edit(self, request, id):
"""Render a form to edit an object."""
try:
object = self.model.objects.get(id=id)
except self.model.DoesNotExist:
return self._render(
request = request,
template = '404',
context = {
... | python | def edit(self, request, id):
"""Render a form to edit an object."""
try:
object = self.model.objects.get(id=id)
except self.model.DoesNotExist:
return self._render(
request = request,
template = '404',
context = {
... | [
"def",
"edit",
"(",
"self",
",",
"request",
",",
"id",
")",
":",
"try",
":",
"object",
"=",
"self",
".",
"model",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"id",
")",
"except",
"self",
".",
"model",
".",
"DoesNotExist",
":",
"return",
"self",
"... | Render a form to edit an object. | [
"Render",
"a",
"form",
"to",
"edit",
"an",
"object",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/views/resource.py#L126-L154 |
45,304 | jgorset/django-respite | respite/views/resource.py | Resource.update | def update(self, request, id):
"""Update an object."""
try:
object = self.model.objects.get(id=id)
except self.model.DoesNotExist:
return self._render(
request = request,
template = '404',
context = {
'er... | python | def update(self, request, id):
"""Update an object."""
try:
object = self.model.objects.get(id=id)
except self.model.DoesNotExist:
return self._render(
request = request,
template = '404',
context = {
'er... | [
"def",
"update",
"(",
"self",
",",
"request",
",",
"id",
")",
":",
"try",
":",
"object",
"=",
"self",
".",
"model",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"id",
")",
"except",
"self",
".",
"model",
".",
"DoesNotExist",
":",
"return",
"self",
... | Update an object. | [
"Update",
"an",
"object",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/views/resource.py#L161-L205 |
45,305 | jgorset/django-respite | respite/views/resource.py | Resource.replace | def replace(self, request, id):
"""Replace an object."""
try:
object = self.model.objects.get(id=id)
except self.model.DoesNotExist:
return self._render(
request = request,
template = '404',
context = {
'... | python | def replace(self, request, id):
"""Replace an object."""
try:
object = self.model.objects.get(id=id)
except self.model.DoesNotExist:
return self._render(
request = request,
template = '404',
context = {
'... | [
"def",
"replace",
"(",
"self",
",",
"request",
",",
"id",
")",
":",
"try",
":",
"object",
"=",
"self",
".",
"model",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"id",
")",
"except",
"self",
".",
"model",
".",
"DoesNotExist",
":",
"return",
"self",
... | Replace an object. | [
"Replace",
"an",
"object",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/views/resource.py#L212-L241 |
45,306 | inmagik/django-search-views | search_views/filters.py | build_q | def build_q(fields_dict, params_dict, request=None):
"""
Returns a Q object from filters config and actual parmeters.
"""
# Building search query
# queries generated by different search_fields are ANDed
# if a search field is defined for more than one field, are put together with OR
and_quer... | python | def build_q(fields_dict, params_dict, request=None):
"""
Returns a Q object from filters config and actual parmeters.
"""
# Building search query
# queries generated by different search_fields are ANDed
# if a search field is defined for more than one field, are put together with OR
and_quer... | [
"def",
"build_q",
"(",
"fields_dict",
",",
"params_dict",
",",
"request",
"=",
"None",
")",
":",
"# Building search query",
"# queries generated by different search_fields are ANDed",
"# if a search field is defined for more than one field, are put together with OR",
"and_query",
"="... | Returns a Q object from filters config and actual parmeters. | [
"Returns",
"a",
"Q",
"object",
"from",
"filters",
"config",
"and",
"actual",
"parmeters",
"."
] | 315cbe8e6cac158884ced02069aa945bc7438dba | https://github.com/inmagik/django-search-views/blob/315cbe8e6cac158884ced02069aa945bc7438dba/search_views/filters.py#L3-L83 |
45,307 | inmagik/django-search-views | search_views/filters.py | BaseFilter.get_search_fields | def get_search_fields(cls):
"""
Returns search fields in sfdict
"""
sfdict = {}
for klass in tuple(cls.__bases__) + (cls, ):
if hasattr(klass, 'search_fields'):
sfdict.update(klass.search_fields)
return sfdict | python | def get_search_fields(cls):
"""
Returns search fields in sfdict
"""
sfdict = {}
for klass in tuple(cls.__bases__) + (cls, ):
if hasattr(klass, 'search_fields'):
sfdict.update(klass.search_fields)
return sfdict | [
"def",
"get_search_fields",
"(",
"cls",
")",
":",
"sfdict",
"=",
"{",
"}",
"for",
"klass",
"in",
"tuple",
"(",
"cls",
".",
"__bases__",
")",
"+",
"(",
"cls",
",",
")",
":",
"if",
"hasattr",
"(",
"klass",
",",
"'search_fields'",
")",
":",
"sfdict",
... | Returns search fields in sfdict | [
"Returns",
"search",
"fields",
"in",
"sfdict"
] | 315cbe8e6cac158884ced02069aa945bc7438dba | https://github.com/inmagik/django-search-views/blob/315cbe8e6cac158884ced02069aa945bc7438dba/search_views/filters.py#L100-L108 |
45,308 | jgorset/django-respite | respite/formats.py | find | def find(identifier):
"""
Find and return a format by name, acronym or extension.
:param identifier: A string describing the format.
"""
for format in FORMATS:
if identifier in [format.name, format.acronym, format.extension]:
return format
raise UnknownFormat('No format fou... | python | def find(identifier):
"""
Find and return a format by name, acronym or extension.
:param identifier: A string describing the format.
"""
for format in FORMATS:
if identifier in [format.name, format.acronym, format.extension]:
return format
raise UnknownFormat('No format fou... | [
"def",
"find",
"(",
"identifier",
")",
":",
"for",
"format",
"in",
"FORMATS",
":",
"if",
"identifier",
"in",
"[",
"format",
".",
"name",
",",
"format",
".",
"acronym",
",",
"format",
".",
"extension",
"]",
":",
"return",
"format",
"raise",
"UnknownFormat... | Find and return a format by name, acronym or extension.
:param identifier: A string describing the format. | [
"Find",
"and",
"return",
"a",
"format",
"by",
"name",
"acronym",
"or",
"extension",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/formats.py#L45-L55 |
45,309 | jgorset/django-respite | respite/formats.py | find_by_name | def find_by_name(name):
"""
Find and return a format by name.
:param name: A string describing the name of the format.
"""
for format in FORMATS:
if name == format.name:
return format
raise UnknownFormat('No format found with name "%s"' % name) | python | def find_by_name(name):
"""
Find and return a format by name.
:param name: A string describing the name of the format.
"""
for format in FORMATS:
if name == format.name:
return format
raise UnknownFormat('No format found with name "%s"' % name) | [
"def",
"find_by_name",
"(",
"name",
")",
":",
"for",
"format",
"in",
"FORMATS",
":",
"if",
"name",
"==",
"format",
".",
"name",
":",
"return",
"format",
"raise",
"UnknownFormat",
"(",
"'No format found with name \"%s\"'",
"%",
"name",
")"
] | Find and return a format by name.
:param name: A string describing the name of the format. | [
"Find",
"and",
"return",
"a",
"format",
"by",
"name",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/formats.py#L57-L67 |
45,310 | jgorset/django-respite | respite/formats.py | find_by_extension | def find_by_extension(extension):
"""
Find and return a format by extension.
:param extension: A string describing the extension of the format.
"""
for format in FORMATS:
if extension in format.extensions:
return format
raise UnknownFormat('No format found with extension "%... | python | def find_by_extension(extension):
"""
Find and return a format by extension.
:param extension: A string describing the extension of the format.
"""
for format in FORMATS:
if extension in format.extensions:
return format
raise UnknownFormat('No format found with extension "%... | [
"def",
"find_by_extension",
"(",
"extension",
")",
":",
"for",
"format",
"in",
"FORMATS",
":",
"if",
"extension",
"in",
"format",
".",
"extensions",
":",
"return",
"format",
"raise",
"UnknownFormat",
"(",
"'No format found with extension \"%s\"'",
"%",
"extension",
... | Find and return a format by extension.
:param extension: A string describing the extension of the format. | [
"Find",
"and",
"return",
"a",
"format",
"by",
"extension",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/formats.py#L69-L79 |
45,311 | jgorset/django-respite | respite/formats.py | find_by_content_type | def find_by_content_type(content_type):
"""
Find and return a format by content type.
:param content_type: A string describing the internet media type of the format.
"""
for format in FORMATS:
if content_type in format.content_types:
return format
raise UnknownFormat('No fo... | python | def find_by_content_type(content_type):
"""
Find and return a format by content type.
:param content_type: A string describing the internet media type of the format.
"""
for format in FORMATS:
if content_type in format.content_types:
return format
raise UnknownFormat('No fo... | [
"def",
"find_by_content_type",
"(",
"content_type",
")",
":",
"for",
"format",
"in",
"FORMATS",
":",
"if",
"content_type",
"in",
"format",
".",
"content_types",
":",
"return",
"format",
"raise",
"UnknownFormat",
"(",
"'No format found with content type \"%s\"'",
"%",
... | Find and return a format by content type.
:param content_type: A string describing the internet media type of the format. | [
"Find",
"and",
"return",
"a",
"format",
"by",
"content",
"type",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/formats.py#L81-L91 |
45,312 | jgorset/django-respite | respite/views/views.py | Views.options | def options(self, request, map, *args, **kwargs):
"""List communication options."""
options = {}
for method, function in map.items():
options[method] = function.__doc__
return self._render(
request = request,
template = 'options',
context ... | python | def options(self, request, map, *args, **kwargs):
"""List communication options."""
options = {}
for method, function in map.items():
options[method] = function.__doc__
return self._render(
request = request,
template = 'options',
context ... | [
"def",
"options",
"(",
"self",
",",
"request",
",",
"map",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"options",
"=",
"{",
"}",
"for",
"method",
",",
"function",
"in",
"map",
".",
"items",
"(",
")",
":",
"options",
"[",
"method",
"]",
... | List communication options. | [
"List",
"communication",
"options",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/views/views.py#L23-L39 |
45,313 | jgorset/django-respite | respite/views/views.py | Views._get_format | def _get_format(self, request):
"""
Determine and return a 'formats.Format' instance describing the most desired response format
that is supported by these views.
:param request: A django.http.HttpRequest instance.
Formats specified by extension (e.g. '/articles/index.html') ta... | python | def _get_format(self, request):
"""
Determine and return a 'formats.Format' instance describing the most desired response format
that is supported by these views.
:param request: A django.http.HttpRequest instance.
Formats specified by extension (e.g. '/articles/index.html') ta... | [
"def",
"_get_format",
"(",
"self",
",",
"request",
")",
":",
"# Derive a list of 'formats.Format' instances from the list of formats these views support.",
"supported_formats",
"=",
"[",
"formats",
".",
"find",
"(",
"format",
")",
"for",
"format",
"in",
"self",
".",
"su... | Determine and return a 'formats.Format' instance describing the most desired response format
that is supported by these views.
:param request: A django.http.HttpRequest instance.
Formats specified by extension (e.g. '/articles/index.html') take precedence over formats
given in the HTTP... | [
"Determine",
"and",
"return",
"a",
"formats",
".",
"Format",
"instance",
"describing",
"the",
"most",
"desired",
"response",
"format",
"that",
"is",
"supported",
"by",
"these",
"views",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/views/views.py#L41-L105 |
45,314 | jgorset/django-respite | respite/views/views.py | Views._render | def _render(self, request, template=None, status=200, context={}, headers={}, prefix_template_path=True):
"""
Render a HTTP response.
:param request: A django.http.HttpRequest instance.
:param template: A string describing the path to a template.
:param status: An integer descri... | python | def _render(self, request, template=None, status=200, context={}, headers={}, prefix_template_path=True):
"""
Render a HTTP response.
:param request: A django.http.HttpRequest instance.
:param template: A string describing the path to a template.
:param status: An integer descri... | [
"def",
"_render",
"(",
"self",
",",
"request",
",",
"template",
"=",
"None",
",",
"status",
"=",
"200",
",",
"context",
"=",
"{",
"}",
",",
"headers",
"=",
"{",
"}",
",",
"prefix_template_path",
"=",
"True",
")",
":",
"format",
"=",
"self",
".",
"_... | Render a HTTP response.
:param request: A django.http.HttpRequest instance.
:param template: A string describing the path to a template.
:param status: An integer describing the HTTP status code to respond with.
:param context: A dictionary describing variables to populate the template ... | [
"Render",
"a",
"HTTP",
"response",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/views/views.py#L107-L188 |
45,315 | jgorset/django-respite | respite/views/views.py | Views._error | def _error(self, request, status, headers={}, prefix_template_path=False, **kwargs):
"""
Convenience method to render an error response. The template is inferred from the status code.
:param request: A django.http.HttpRequest instance.
:param status: An integer describing the HTTP statu... | python | def _error(self, request, status, headers={}, prefix_template_path=False, **kwargs):
"""
Convenience method to render an error response. The template is inferred from the status code.
:param request: A django.http.HttpRequest instance.
:param status: An integer describing the HTTP statu... | [
"def",
"_error",
"(",
"self",
",",
"request",
",",
"status",
",",
"headers",
"=",
"{",
"}",
",",
"prefix_template_path",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_render",
"(",
"request",
"=",
"request",
",",
"template",... | Convenience method to render an error response. The template is inferred from the status code.
:param request: A django.http.HttpRequest instance.
:param status: An integer describing the HTTP status code to respond with.
:param headers: A dictionary describing HTTP headers.
:param pref... | [
"Convenience",
"method",
"to",
"render",
"an",
"error",
"response",
".",
"The",
"template",
"is",
"inferred",
"from",
"the",
"status",
"code",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/views/views.py#L190-L212 |
45,316 | jgorset/django-respite | respite/serializers/__init__.py | find | def find(format):
"""
Find and return a serializer for the given format.
Arguments:
format -- A Format instance.
"""
try:
serializer = SERIALIZERS[format]
except KeyError:
raise UnknownSerializer('No serializer found for %s' % format.acronym)
return serializer | python | def find(format):
"""
Find and return a serializer for the given format.
Arguments:
format -- A Format instance.
"""
try:
serializer = SERIALIZERS[format]
except KeyError:
raise UnknownSerializer('No serializer found for %s' % format.acronym)
return serializer | [
"def",
"find",
"(",
"format",
")",
":",
"try",
":",
"serializer",
"=",
"SERIALIZERS",
"[",
"format",
"]",
"except",
"KeyError",
":",
"raise",
"UnknownSerializer",
"(",
"'No serializer found for %s'",
"%",
"format",
".",
"acronym",
")",
"return",
"serializer"
] | Find and return a serializer for the given format.
Arguments:
format -- A Format instance. | [
"Find",
"and",
"return",
"a",
"serializer",
"for",
"the",
"given",
"format",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/serializers/__init__.py#L12-L24 |
45,317 | inmagik/django-search-views | search_views/views.py | SearchListView.get_form_kwargs | def get_form_kwargs(self):
"""
Returns the keyword arguments for instantiating the search form.
"""
update_data ={}
sfdict = self.filter_class.get_search_fields()
for fieldname in sfdict:
try:
has_multiple = sfdict[fieldname].get('multiple', Fa... | python | def get_form_kwargs(self):
"""
Returns the keyword arguments for instantiating the search form.
"""
update_data ={}
sfdict = self.filter_class.get_search_fields()
for fieldname in sfdict:
try:
has_multiple = sfdict[fieldname].get('multiple', Fa... | [
"def",
"get_form_kwargs",
"(",
"self",
")",
":",
"update_data",
"=",
"{",
"}",
"sfdict",
"=",
"self",
".",
"filter_class",
".",
"get_search_fields",
"(",
")",
"for",
"fieldname",
"in",
"sfdict",
":",
"try",
":",
"has_multiple",
"=",
"sfdict",
"[",
"fieldna... | Returns the keyword arguments for instantiating the search form. | [
"Returns",
"the",
"keyword",
"arguments",
"for",
"instantiating",
"the",
"search",
"form",
"."
] | 315cbe8e6cac158884ced02069aa945bc7438dba | https://github.com/inmagik/django-search-views/blob/315cbe8e6cac158884ced02069aa945bc7438dba/search_views/views.py#L42-L76 |
45,318 | jgorset/django-respite | respite/inflector.py | pluralize | def pluralize(word) :
"""Pluralize an English noun."""
rules = [
['(?i)(quiz)$' , '\\1zes'],
['^(?i)(ox)$' , '\\1en'],
['(?i)([m|l])ouse$' , '\\1ice'],
['(?i)(matr|vert|ind)ix|ex$' , '\\1ices'],
['(?i)(x|ch|ss|sh)$' , '\\1es'],
['(... | python | def pluralize(word) :
"""Pluralize an English noun."""
rules = [
['(?i)(quiz)$' , '\\1zes'],
['^(?i)(ox)$' , '\\1en'],
['(?i)([m|l])ouse$' , '\\1ice'],
['(?i)(matr|vert|ind)ix|ex$' , '\\1ices'],
['(?i)(x|ch|ss|sh)$' , '\\1es'],
['(... | [
"def",
"pluralize",
"(",
"word",
")",
":",
"rules",
"=",
"[",
"[",
"'(?i)(quiz)$'",
",",
"'\\\\1zes'",
"]",
",",
"[",
"'^(?i)(ox)$'",
",",
"'\\\\1en'",
"]",
",",
"[",
"'(?i)([m|l])ouse$'",
",",
"'\\\\1ice'",
"]",
",",
"[",
"'(?i)(matr|vert|ind)ix|ex$'",
",",... | Pluralize an English noun. | [
"Pluralize",
"an",
"English",
"noun",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/inflector.py#L3-L58 |
45,319 | jgorset/django-respite | respite/inflector.py | us2mc | def us2mc(string):
"""Transform an underscore_case string to a mixedCase string"""
return re.sub(r'_([a-z])', lambda m: (m.group(1).upper()), string) | python | def us2mc(string):
"""Transform an underscore_case string to a mixedCase string"""
return re.sub(r'_([a-z])', lambda m: (m.group(1).upper()), string) | [
"def",
"us2mc",
"(",
"string",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r'_([a-z])'",
",",
"lambda",
"m",
":",
"(",
"m",
".",
"group",
"(",
"1",
")",
".",
"upper",
"(",
")",
")",
",",
"string",
")"
] | Transform an underscore_case string to a mixedCase string | [
"Transform",
"an",
"underscore_case",
"string",
"to",
"a",
"mixedCase",
"string"
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/inflector.py#L131-L133 |
45,320 | jgorset/django-respite | respite/utils/__init__.py | generate_form | def generate_form(model, form=None, fields=False, exclude=False):
"""
Generate a form from a model.
:param model: A Django model.
:param form: A Django form.
:param fields: A list of fields to include in this form.
:param exclude: A list of fields to exclude in this form.
"""
_model, _f... | python | def generate_form(model, form=None, fields=False, exclude=False):
"""
Generate a form from a model.
:param model: A Django model.
:param form: A Django form.
:param fields: A list of fields to include in this form.
:param exclude: A list of fields to exclude in this form.
"""
_model, _f... | [
"def",
"generate_form",
"(",
"model",
",",
"form",
"=",
"None",
",",
"fields",
"=",
"False",
",",
"exclude",
"=",
"False",
")",
":",
"_model",
",",
"_fields",
",",
"_exclude",
"=",
"model",
",",
"fields",
",",
"exclude",
"class",
"Form",
"(",
"form",
... | Generate a form from a model.
:param model: A Django model.
:param form: A Django form.
:param fields: A list of fields to include in this form.
:param exclude: A list of fields to exclude in this form. | [
"Generate",
"a",
"form",
"from",
"a",
"model",
"."
] | 719469d11baf91d05917bab1623bd82adc543546 | https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/utils/__init__.py#L5-L26 |
45,321 | pkgw/pwkit | pwkit/msmt.py | sample_double_norm | def sample_double_norm(mean, std_upper, std_lower, size):
"""Note that this function requires Scipy."""
from scipy.special import erfinv
# There's probably a better way to do this. We first draw percentiles
# uniformly between 0 and 1. We want the peak of the distribution to occur
# at `mean`. Howe... | python | def sample_double_norm(mean, std_upper, std_lower, size):
"""Note that this function requires Scipy."""
from scipy.special import erfinv
# There's probably a better way to do this. We first draw percentiles
# uniformly between 0 and 1. We want the peak of the distribution to occur
# at `mean`. Howe... | [
"def",
"sample_double_norm",
"(",
"mean",
",",
"std_upper",
",",
"std_lower",
",",
"size",
")",
":",
"from",
"scipy",
".",
"special",
"import",
"erfinv",
"# There's probably a better way to do this. We first draw percentiles",
"# uniformly between 0 and 1. We want the peak of t... | Note that this function requires Scipy. | [
"Note",
"that",
"this",
"function",
"requires",
"Scipy",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/msmt.py#L125-L153 |
45,322 | pkgw/pwkit | pwkit/msmt.py | find_gamma_params | def find_gamma_params(mode, std):
"""Given a modal value and a standard deviation, compute corresponding
parameters for the gamma distribution.
Intended to be used to replace normal distributions when the value must be
positive and the uncertainty is comparable to the best value. Conversion
equatio... | python | def find_gamma_params(mode, std):
"""Given a modal value and a standard deviation, compute corresponding
parameters for the gamma distribution.
Intended to be used to replace normal distributions when the value must be
positive and the uncertainty is comparable to the best value. Conversion
equatio... | [
"def",
"find_gamma_params",
"(",
"mode",
",",
"std",
")",
":",
"if",
"mode",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'input mode must be positive for gamma; got %e'",
"%",
"mode",
")",
"var",
"=",
"std",
"**",
"2",
"beta",
"=",
"(",
"mode",
"+",
"np",
... | Given a modal value and a standard deviation, compute corresponding
parameters for the gamma distribution.
Intended to be used to replace normal distributions when the value must be
positive and the uncertainty is comparable to the best value. Conversion
equations determined from the relations given in... | [
"Given",
"a",
"modal",
"value",
"and",
"a",
"standard",
"deviation",
"compute",
"corresponding",
"parameters",
"for",
"the",
"gamma",
"distribution",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/msmt.py#L179-L201 |
45,323 | pkgw/pwkit | pwkit/msmt.py | _lval_add_towards_polarity | def _lval_add_towards_polarity(x, polarity):
"""Compute the appropriate Lval "kind" for the limit of value `x` towards
`polarity`. Either 'toinf' or 'pastzero' depending on the sign of `x` and
the infinity direction of polarity.
"""
if x < 0:
if polarity < 0:
return Lval('toinf'... | python | def _lval_add_towards_polarity(x, polarity):
"""Compute the appropriate Lval "kind" for the limit of value `x` towards
`polarity`. Either 'toinf' or 'pastzero' depending on the sign of `x` and
the infinity direction of polarity.
"""
if x < 0:
if polarity < 0:
return Lval('toinf'... | [
"def",
"_lval_add_towards_polarity",
"(",
"x",
",",
"polarity",
")",
":",
"if",
"x",
"<",
"0",
":",
"if",
"polarity",
"<",
"0",
":",
"return",
"Lval",
"(",
"'toinf'",
",",
"x",
")",
"return",
"Lval",
"(",
"'pastzero'",
",",
"x",
")",
"elif",
"polarit... | Compute the appropriate Lval "kind" for the limit of value `x` towards
`polarity`. Either 'toinf' or 'pastzero' depending on the sign of `x` and
the infinity direction of polarity. | [
"Compute",
"the",
"appropriate",
"Lval",
"kind",
"for",
"the",
"limit",
"of",
"value",
"x",
"towards",
"polarity",
".",
"Either",
"toinf",
"or",
"pastzero",
"depending",
"on",
"the",
"sign",
"of",
"x",
"and",
"the",
"infinity",
"direction",
"of",
"polarity",... | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/msmt.py#L806-L818 |
45,324 | pkgw/pwkit | pwkit/msmt.py | limtype | def limtype(msmt):
"""Return -1 if this value is some kind of upper limit, 1 if this value
is some kind of lower limit, 0 otherwise."""
if np.isscalar(msmt):
return 0
if isinstance(msmt, Uval):
return 0
if isinstance(msmt, Lval):
if msmt.kind == 'undef':
raise Va... | python | def limtype(msmt):
"""Return -1 if this value is some kind of upper limit, 1 if this value
is some kind of lower limit, 0 otherwise."""
if np.isscalar(msmt):
return 0
if isinstance(msmt, Uval):
return 0
if isinstance(msmt, Lval):
if msmt.kind == 'undef':
raise Va... | [
"def",
"limtype",
"(",
"msmt",
")",
":",
"if",
"np",
".",
"isscalar",
"(",
"msmt",
")",
":",
"return",
"0",
"if",
"isinstance",
"(",
"msmt",
",",
"Uval",
")",
":",
"return",
"0",
"if",
"isinstance",
"(",
"msmt",
",",
"Lval",
")",
":",
"if",
"msmt... | Return -1 if this value is some kind of upper limit, 1 if this value
is some kind of lower limit, 0 otherwise. | [
"Return",
"-",
"1",
"if",
"this",
"value",
"is",
"some",
"kind",
"of",
"upper",
"limit",
"1",
"if",
"this",
"value",
"is",
"some",
"kind",
"of",
"lower",
"limit",
"0",
"otherwise",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/msmt.py#L1903-L1927 |
45,325 | pkgw/pwkit | pwkit/msmt.py | Uval.from_pcount | def from_pcount(nevents):
"""We assume a Poisson process. nevents is the number of events in
some interval. The distribution of values is the distribution of the
Poisson rate parameter given this observed number of events, where the
"rate" is in units of events per interval of the same d... | python | def from_pcount(nevents):
"""We assume a Poisson process. nevents is the number of events in
some interval. The distribution of values is the distribution of the
Poisson rate parameter given this observed number of events, where the
"rate" is in units of events per interval of the same d... | [
"def",
"from_pcount",
"(",
"nevents",
")",
":",
"if",
"nevents",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'Poisson parameter `nevents` must be nonnegative'",
")",
"return",
"Uval",
"(",
"np",
".",
"random",
".",
"gamma",
"(",
"nevents",
"+",
"1",
",",
"si... | We assume a Poisson process. nevents is the number of events in
some interval. The distribution of values is the distribution of the
Poisson rate parameter given this observed number of events, where the
"rate" is in units of events per interval of the same duration. The
max-likelihood v... | [
"We",
"assume",
"a",
"Poisson",
"process",
".",
"nevents",
"is",
"the",
"number",
"of",
"events",
"in",
"some",
"interval",
".",
"The",
"distribution",
"of",
"values",
"is",
"the",
"distribution",
"of",
"the",
"Poisson",
"rate",
"parameter",
"given",
"this",... | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/msmt.py#L353-L363 |
45,326 | pkgw/pwkit | pwkit/msmt.py | Uval.repvals | def repvals(self, method):
"""Compute representative statistical values for this Uval. `method`
may be either 'pct' or 'gauss'.
Returns (best, plus_one_sigma, minus_one_sigma), where `best` is the
"best" value in some sense, and the others correspond to values at
the ~84 and 16 ... | python | def repvals(self, method):
"""Compute representative statistical values for this Uval. `method`
may be either 'pct' or 'gauss'.
Returns (best, plus_one_sigma, minus_one_sigma), where `best` is the
"best" value in some sense, and the others correspond to values at
the ~84 and 16 ... | [
"def",
"repvals",
"(",
"self",
",",
"method",
")",
":",
"if",
"method",
"==",
"'pct'",
":",
"return",
"pk_scoreatpercentile",
"(",
"self",
".",
"d",
",",
"[",
"50.",
",",
"84.134",
",",
"15.866",
"]",
")",
"if",
"method",
"==",
"'gauss'",
":",
"m",
... | Compute representative statistical values for this Uval. `method`
may be either 'pct' or 'gauss'.
Returns (best, plus_one_sigma, minus_one_sigma), where `best` is the
"best" value in some sense, and the others correspond to values at
the ~84 and 16 percentile limits, respectively. Becau... | [
"Compute",
"representative",
"statistical",
"values",
"for",
"this",
"Uval",
".",
"method",
"may",
"be",
"either",
"pct",
"or",
"gauss",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/msmt.py#L374-L396 |
45,327 | pkgw/pwkit | pwkit/msmt.py | Textual.repval | def repval(self, limitsok=False):
"""Get a best-effort representative value as a float. This can be
DANGEROUS because it discards limit information, which is rarely wise."""
if not limitsok and self.dkind in ('lower', 'upper'):
raise LimitError()
if self.dkind == 'unif':
... | python | def repval(self, limitsok=False):
"""Get a best-effort representative value as a float. This can be
DANGEROUS because it discards limit information, which is rarely wise."""
if not limitsok and self.dkind in ('lower', 'upper'):
raise LimitError()
if self.dkind == 'unif':
... | [
"def",
"repval",
"(",
"self",
",",
"limitsok",
"=",
"False",
")",
":",
"if",
"not",
"limitsok",
"and",
"self",
".",
"dkind",
"in",
"(",
"'lower'",
",",
"'upper'",
")",
":",
"raise",
"LimitError",
"(",
")",
"if",
"self",
".",
"dkind",
"==",
"'unif'",
... | Get a best-effort representative value as a float. This can be
DANGEROUS because it discards limit information, which is rarely wise. | [
"Get",
"a",
"best",
"-",
"effort",
"representative",
"value",
"as",
"a",
"float",
".",
"This",
"can",
"be",
"DANGEROUS",
"because",
"it",
"discards",
"limit",
"information",
"which",
"is",
"rarely",
"wise",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/msmt.py#L1662-L1681 |
45,328 | pkgw/pwkit | pwkit/colormaps.py | moreland_adjusthue | def moreland_adjusthue (msh, m_unsat):
"""Moreland's AdjustHue procedure to adjust the hue value of an Msh color
based on ... some criterion.
*msh* should be of of shape (3, ). *m_unsat* is a scalar.
Return value is the adjusted h (hue) value.
"""
if msh[M] >= m_unsat:
return msh[H] #... | python | def moreland_adjusthue (msh, m_unsat):
"""Moreland's AdjustHue procedure to adjust the hue value of an Msh color
based on ... some criterion.
*msh* should be of of shape (3, ). *m_unsat* is a scalar.
Return value is the adjusted h (hue) value.
"""
if msh[M] >= m_unsat:
return msh[H] #... | [
"def",
"moreland_adjusthue",
"(",
"msh",
",",
"m_unsat",
")",
":",
"if",
"msh",
"[",
"M",
"]",
">=",
"m_unsat",
":",
"return",
"msh",
"[",
"H",
"]",
"# \"Best we can do\"",
"hspin",
"=",
"(",
"msh",
"[",
"S",
"]",
"*",
"np",
".",
"sqrt",
"(",
"m_un... | Moreland's AdjustHue procedure to adjust the hue value of an Msh color
based on ... some criterion.
*msh* should be of of shape (3, ). *m_unsat* is a scalar.
Return value is the adjusted h (hue) value. | [
"Moreland",
"s",
"AdjustHue",
"procedure",
"to",
"adjust",
"the",
"hue",
"value",
"of",
"an",
"Msh",
"color",
"based",
"on",
"...",
"some",
"criterion",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/colormaps.py#L322-L339 |
45,329 | kapadia/usgs | scripts/get_datasets_in_node.py | get_datasets_in_nodes | def get_datasets_in_nodes():
"""
Get the node associated with each dataset. Some datasets
will have an ambiguous node since they exists in more than
one node.
"""
data_dir = os.path.join(scriptdir, "..", "usgs", "data")
cwic = map(lambda d: d["datasetName"], api.datasets(None, CWIC_LSI_EXP... | python | def get_datasets_in_nodes():
"""
Get the node associated with each dataset. Some datasets
will have an ambiguous node since they exists in more than
one node.
"""
data_dir = os.path.join(scriptdir, "..", "usgs", "data")
cwic = map(lambda d: d["datasetName"], api.datasets(None, CWIC_LSI_EXP... | [
"def",
"get_datasets_in_nodes",
"(",
")",
":",
"data_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"scriptdir",
",",
"\"..\"",
",",
"\"usgs\"",
",",
"\"data\"",
")",
"cwic",
"=",
"map",
"(",
"lambda",
"d",
":",
"d",
"[",
"\"datasetName\"",
"]",
",",
... | Get the node associated with each dataset. Some datasets
will have an ambiguous node since they exists in more than
one node. | [
"Get",
"the",
"node",
"associated",
"with",
"each",
"dataset",
".",
"Some",
"datasets",
"will",
"have",
"an",
"ambiguous",
"node",
"since",
"they",
"exists",
"in",
"more",
"than",
"one",
"node",
"."
] | 0608346f0bc3c34e20f4ecc77ad71d0b514db7ee | https://github.com/kapadia/usgs/blob/0608346f0bc3c34e20f4ecc77ad71d0b514db7ee/scripts/get_datasets_in_node.py#L13-L44 |
45,330 | pkgw/pwkit | pwkit/synphot.py | pivot_wavelength_ee | def pivot_wavelength_ee(bpass):
"""Compute pivot wavelength assuming equal-energy convention.
`bpass` should have two properties, `resp` and `wlen`. The units of `wlen`
can be anything, and `resp` need not be normalized in any particular way.
"""
from scipy.integrate import simps
return np.sqr... | python | def pivot_wavelength_ee(bpass):
"""Compute pivot wavelength assuming equal-energy convention.
`bpass` should have two properties, `resp` and `wlen`. The units of `wlen`
can be anything, and `resp` need not be normalized in any particular way.
"""
from scipy.integrate import simps
return np.sqr... | [
"def",
"pivot_wavelength_ee",
"(",
"bpass",
")",
":",
"from",
"scipy",
".",
"integrate",
"import",
"simps",
"return",
"np",
".",
"sqrt",
"(",
"simps",
"(",
"bpass",
".",
"resp",
",",
"bpass",
".",
"wlen",
")",
"/",
"simps",
"(",
"bpass",
".",
"resp",
... | Compute pivot wavelength assuming equal-energy convention.
`bpass` should have two properties, `resp` and `wlen`. The units of `wlen`
can be anything, and `resp` need not be normalized in any particular way. | [
"Compute",
"pivot",
"wavelength",
"assuming",
"equal",
"-",
"energy",
"convention",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L169-L178 |
45,331 | pkgw/pwkit | pwkit/synphot.py | get_std_registry | def get_std_registry():
"""Get a Registry object pre-filled with information for standard
telescopes.
"""
from six import itervalues
reg = Registry()
for fn in itervalues(builtin_registrars):
fn(reg)
return reg | python | def get_std_registry():
"""Get a Registry object pre-filled with information for standard
telescopes.
"""
from six import itervalues
reg = Registry()
for fn in itervalues(builtin_registrars):
fn(reg)
return reg | [
"def",
"get_std_registry",
"(",
")",
":",
"from",
"six",
"import",
"itervalues",
"reg",
"=",
"Registry",
"(",
")",
"for",
"fn",
"in",
"itervalues",
"(",
"builtin_registrars",
")",
":",
"fn",
"(",
"reg",
")",
"return",
"reg"
] | Get a Registry object pre-filled with information for standard
telescopes. | [
"Get",
"a",
"Registry",
"object",
"pre",
"-",
"filled",
"with",
"information",
"for",
"standard",
"telescopes",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L513-L522 |
45,332 | pkgw/pwkit | pwkit/synphot.py | Bandpass.pivot_wavelength | def pivot_wavelength(self):
"""Get the bandpass' pivot wavelength.
Unlike calc_pivot_wavelength(), this function will use a cached
value if available.
"""
wl = self.registry._pivot_wavelengths.get((self.telescope, self.band))
if wl is not None:
return wl
... | python | def pivot_wavelength(self):
"""Get the bandpass' pivot wavelength.
Unlike calc_pivot_wavelength(), this function will use a cached
value if available.
"""
wl = self.registry._pivot_wavelengths.get((self.telescope, self.band))
if wl is not None:
return wl
... | [
"def",
"pivot_wavelength",
"(",
"self",
")",
":",
"wl",
"=",
"self",
".",
"registry",
".",
"_pivot_wavelengths",
".",
"get",
"(",
"(",
"self",
".",
"telescope",
",",
"self",
".",
"band",
")",
")",
"if",
"wl",
"is",
"not",
"None",
":",
"return",
"wl",... | Get the bandpass' pivot wavelength.
Unlike calc_pivot_wavelength(), this function will use a cached
value if available. | [
"Get",
"the",
"bandpass",
"pivot",
"wavelength",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L292-L305 |
45,333 | pkgw/pwkit | pwkit/synphot.py | Bandpass.calc_halfmax_points | def calc_halfmax_points(self):
"""Calculate the wavelengths of the filter half-maximum values.
"""
d = self._ensure_data()
return interpolated_halfmax_points(d.wlen, d.resp) | python | def calc_halfmax_points(self):
"""Calculate the wavelengths of the filter half-maximum values.
"""
d = self._ensure_data()
return interpolated_halfmax_points(d.wlen, d.resp) | [
"def",
"calc_halfmax_points",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"_ensure_data",
"(",
")",
"return",
"interpolated_halfmax_points",
"(",
"d",
".",
"wlen",
",",
"d",
".",
"resp",
")"
] | Calculate the wavelengths of the filter half-maximum values. | [
"Calculate",
"the",
"wavelengths",
"of",
"the",
"filter",
"half",
"-",
"maximum",
"values",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L308-L313 |
45,334 | pkgw/pwkit | pwkit/synphot.py | Bandpass.halfmax_points | def halfmax_points(self):
"""Get the bandpass' half-maximum wavelengths. These can be used to
compute a representative bandwidth, or for display purposes.
Unlike calc_halfmax_points(), this function will use a cached value if
available.
"""
t = self.registry._halfmaxes.... | python | def halfmax_points(self):
"""Get the bandpass' half-maximum wavelengths. These can be used to
compute a representative bandwidth, or for display purposes.
Unlike calc_halfmax_points(), this function will use a cached value if
available.
"""
t = self.registry._halfmaxes.... | [
"def",
"halfmax_points",
"(",
"self",
")",
":",
"t",
"=",
"self",
".",
"registry",
".",
"_halfmaxes",
".",
"get",
"(",
"(",
"self",
".",
"telescope",
",",
"self",
".",
"band",
")",
")",
"if",
"t",
"is",
"not",
"None",
":",
"return",
"t",
"t",
"="... | Get the bandpass' half-maximum wavelengths. These can be used to
compute a representative bandwidth, or for display purposes.
Unlike calc_halfmax_points(), this function will use a cached value if
available. | [
"Get",
"the",
"bandpass",
"half",
"-",
"maximum",
"wavelengths",
".",
"These",
"can",
"be",
"used",
"to",
"compute",
"a",
"representative",
"bandwidth",
"or",
"for",
"display",
"purposes",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L316-L330 |
45,335 | pkgw/pwkit | pwkit/synphot.py | Registry.bands | def bands(self, telescope):
"""Return a list of bands associated with the specified telescope."""
q = self._seen_bands.get(telescope)
if q is None:
return []
return list(q) | python | def bands(self, telescope):
"""Return a list of bands associated with the specified telescope."""
q = self._seen_bands.get(telescope)
if q is None:
return []
return list(q) | [
"def",
"bands",
"(",
"self",
",",
"telescope",
")",
":",
"q",
"=",
"self",
".",
"_seen_bands",
".",
"get",
"(",
"telescope",
")",
"if",
"q",
"is",
"None",
":",
"return",
"[",
"]",
"return",
"list",
"(",
"q",
")"
] | Return a list of bands associated with the specified telescope. | [
"Return",
"a",
"list",
"of",
"bands",
"associated",
"with",
"the",
"specified",
"telescope",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L456-L461 |
45,336 | pkgw/pwkit | pwkit/synphot.py | Registry.register_pivot_wavelength | def register_pivot_wavelength(self, telescope, band, wlen):
"""Register precomputed pivot wavelengths."""
if (telescope, band) in self._pivot_wavelengths:
raise AlreadyDefinedError('pivot wavelength for %s/%s already '
'defined', telescope, band)
... | python | def register_pivot_wavelength(self, telescope, band, wlen):
"""Register precomputed pivot wavelengths."""
if (telescope, band) in self._pivot_wavelengths:
raise AlreadyDefinedError('pivot wavelength for %s/%s already '
'defined', telescope, band)
... | [
"def",
"register_pivot_wavelength",
"(",
"self",
",",
"telescope",
",",
"band",
",",
"wlen",
")",
":",
"if",
"(",
"telescope",
",",
"band",
")",
"in",
"self",
".",
"_pivot_wavelengths",
":",
"raise",
"AlreadyDefinedError",
"(",
"'pivot wavelength for %s/%s already... | Register precomputed pivot wavelengths. | [
"Register",
"precomputed",
"pivot",
"wavelengths",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L464-L471 |
45,337 | pkgw/pwkit | pwkit/synphot.py | Registry.register_halfmaxes | def register_halfmaxes(self, telescope, band, lower, upper):
"""Register precomputed half-max points."""
if (telescope, band) in self._halfmaxes:
raise AlreadyDefinedError('half-max points for %s/%s already '
'defined', telescope, band)
self._no... | python | def register_halfmaxes(self, telescope, band, lower, upper):
"""Register precomputed half-max points."""
if (telescope, band) in self._halfmaxes:
raise AlreadyDefinedError('half-max points for %s/%s already '
'defined', telescope, band)
self._no... | [
"def",
"register_halfmaxes",
"(",
"self",
",",
"telescope",
",",
"band",
",",
"lower",
",",
"upper",
")",
":",
"if",
"(",
"telescope",
",",
"band",
")",
"in",
"self",
".",
"_halfmaxes",
":",
"raise",
"AlreadyDefinedError",
"(",
"'half-max points for %s/%s alre... | Register precomputed half-max points. | [
"Register",
"precomputed",
"half",
"-",
"max",
"points",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L474-L482 |
45,338 | pkgw/pwkit | pwkit/synphot.py | Registry.register_bpass | def register_bpass(self, telescope, klass):
"""Register a Bandpass class."""
if telescope in self._bpass_classes:
raise AlreadyDefinedError('bandpass class for %s already '
'defined', telescope)
self._note(telescope, None)
self._bpass_cl... | python | def register_bpass(self, telescope, klass):
"""Register a Bandpass class."""
if telescope in self._bpass_classes:
raise AlreadyDefinedError('bandpass class for %s already '
'defined', telescope)
self._note(telescope, None)
self._bpass_cl... | [
"def",
"register_bpass",
"(",
"self",
",",
"telescope",
",",
"klass",
")",
":",
"if",
"telescope",
"in",
"self",
".",
"_bpass_classes",
":",
"raise",
"AlreadyDefinedError",
"(",
"'bandpass class for %s already '",
"'defined'",
",",
"telescope",
")",
"self",
".",
... | Register a Bandpass class. | [
"Register",
"a",
"Bandpass",
"class",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L485-L493 |
45,339 | pkgw/pwkit | pwkit/synphot.py | Registry.get | def get(self, telescope, band):
"""Get a Bandpass object for a known telescope and filter."""
klass = self._bpass_classes.get(telescope)
if klass is None:
raise NotDefinedError('bandpass data for %s not defined', telescope)
bp = klass()
bp.registry = self
bp... | python | def get(self, telescope, band):
"""Get a Bandpass object for a known telescope and filter."""
klass = self._bpass_classes.get(telescope)
if klass is None:
raise NotDefinedError('bandpass data for %s not defined', telescope)
bp = klass()
bp.registry = self
bp... | [
"def",
"get",
"(",
"self",
",",
"telescope",
",",
"band",
")",
":",
"klass",
"=",
"self",
".",
"_bpass_classes",
".",
"get",
"(",
"telescope",
")",
"if",
"klass",
"is",
"None",
":",
"raise",
"NotDefinedError",
"(",
"'bandpass data for %s not defined'",
",",
... | Get a Bandpass object for a known telescope and filter. | [
"Get",
"a",
"Bandpass",
"object",
"for",
"a",
"known",
"telescope",
"and",
"filter",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L496-L507 |
45,340 | pkgw/pwkit | pwkit/synphot.py | WiseBandpass._load_data | def _load_data(self, band):
"""From the WISE All-Sky Explanatory Supplement, IV.4.h.i.1, and Jarrett+
2011. These are relative response per erg and so can be integrated
directly against F_nu spectra. Wavelengths are in micron,
uncertainties are in parts per thousand.
"""
... | python | def _load_data(self, band):
"""From the WISE All-Sky Explanatory Supplement, IV.4.h.i.1, and Jarrett+
2011. These are relative response per erg and so can be integrated
directly against F_nu spectra. Wavelengths are in micron,
uncertainties are in parts per thousand.
"""
... | [
"def",
"_load_data",
"(",
"self",
",",
"band",
")",
":",
"# `band` should be 1, 2, 3, or 4.",
"df",
"=",
"bandpass_data_frame",
"(",
"'filter_wise_'",
"+",
"str",
"(",
"band",
")",
"+",
"'.dat'",
",",
"'wlen resp uncert'",
")",
"df",
".",
"wlen",
"*=",
"1e4",
... | From the WISE All-Sky Explanatory Supplement, IV.4.h.i.1, and Jarrett+
2011. These are relative response per erg and so can be integrated
directly against F_nu spectra. Wavelengths are in micron,
uncertainties are in parts per thousand. | [
"From",
"the",
"WISE",
"All",
"-",
"Sky",
"Explanatory",
"Supplement",
"IV",
".",
"4",
".",
"h",
".",
"i",
".",
"1",
"and",
"Jarrett",
"+",
"2011",
".",
"These",
"are",
"relative",
"response",
"per",
"erg",
"and",
"so",
"can",
"be",
"integrated",
"di... | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L930-L943 |
45,341 | bibanon/BASC-py4chan | basc_py4chan/util.py | clean_comment_body | def clean_comment_body(body):
"""Returns given comment HTML as plaintext.
Converts all HTML tags and entities within 4chan comments
into human-readable text equivalents.
"""
body = _parser.unescape(body)
body = re.sub(r'<a [^>]+>(.+?)</a>', r'\1', body)
body = body.replace('<br>', '\n')
... | python | def clean_comment_body(body):
"""Returns given comment HTML as plaintext.
Converts all HTML tags and entities within 4chan comments
into human-readable text equivalents.
"""
body = _parser.unescape(body)
body = re.sub(r'<a [^>]+>(.+?)</a>', r'\1', body)
body = body.replace('<br>', '\n')
... | [
"def",
"clean_comment_body",
"(",
"body",
")",
":",
"body",
"=",
"_parser",
".",
"unescape",
"(",
"body",
")",
"body",
"=",
"re",
".",
"sub",
"(",
"r'<a [^>]+>(.+?)</a>'",
",",
"r'\\1'",
",",
"body",
")",
"body",
"=",
"body",
".",
"replace",
"(",
"'<br... | Returns given comment HTML as plaintext.
Converts all HTML tags and entities within 4chan comments
into human-readable text equivalents. | [
"Returns",
"given",
"comment",
"HTML",
"as",
"plaintext",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/util.py#L16-L26 |
45,342 | pkgw/pwkit | pwkit/astimage.py | _create_wcs | def _create_wcs (fitsheader):
"""For compatibility between astropy and pywcs."""
wcsmodule = _load_wcs_module ()
is_pywcs = hasattr (wcsmodule, 'UnitConverter')
wcs = wcsmodule.WCS (fitsheader)
wcs.wcs.set ()
wcs.wcs.fix () # I'm interested in MJD computation via datfix()
if hasattr (wcs, ... | python | def _create_wcs (fitsheader):
"""For compatibility between astropy and pywcs."""
wcsmodule = _load_wcs_module ()
is_pywcs = hasattr (wcsmodule, 'UnitConverter')
wcs = wcsmodule.WCS (fitsheader)
wcs.wcs.set ()
wcs.wcs.fix () # I'm interested in MJD computation via datfix()
if hasattr (wcs, ... | [
"def",
"_create_wcs",
"(",
"fitsheader",
")",
":",
"wcsmodule",
"=",
"_load_wcs_module",
"(",
")",
"is_pywcs",
"=",
"hasattr",
"(",
"wcsmodule",
",",
"'UnitConverter'",
")",
"wcs",
"=",
"wcsmodule",
".",
"WCS",
"(",
"fitsheader",
")",
"wcs",
".",
"wcs",
".... | For compatibility between astropy and pywcs. | [
"For",
"compatibility",
"between",
"astropy",
"and",
"pywcs",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/astimage.py#L101-L114 |
45,343 | pkgw/pwkit | pwkit/environments/casa/util.py | sanitize_unicode | def sanitize_unicode(item):
"""Safely pass string values to the CASA tools.
item
A value to be passed to a CASA tool.
In Python 2, the bindings to CASA tasks expect to receive all string values
as binary data (:class:`str`) and not Unicode. But :mod:`pwkit` often uses
the ``from __future__ i... | python | def sanitize_unicode(item):
"""Safely pass string values to the CASA tools.
item
A value to be passed to a CASA tool.
In Python 2, the bindings to CASA tasks expect to receive all string values
as binary data (:class:`str`) and not Unicode. But :mod:`pwkit` often uses
the ``from __future__ i... | [
"def",
"sanitize_unicode",
"(",
"item",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"text_type",
")",
":",
"return",
"item",
".",
"encode",
"(",
"'utf8'",
")",
"if",
"isinstance",
"(",
"item",
",",
"dict",
")",
":",
"return",
"dict",
"(",
"(",
"s... | Safely pass string values to the CASA tools.
item
A value to be passed to a CASA tool.
In Python 2, the bindings to CASA tasks expect to receive all string values
as binary data (:class:`str`) and not Unicode. But :mod:`pwkit` often uses
the ``from __future__ import unicode_literals`` statement ... | [
"Safely",
"pass",
"string",
"values",
"to",
"the",
"CASA",
"tools",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/util.py#L62-L103 |
45,344 | pkgw/pwkit | pwkit/environments/casa/util.py | datadir | def datadir(*subdirs):
"""Get a path within the CASA data directory.
subdirs
Extra elements to append to the returned path.
This function locates the directory where CASA resource data files (tables
of time offsets, calibrator models, etc.) are stored. If called with no
arguments, it simply ... | python | def datadir(*subdirs):
"""Get a path within the CASA data directory.
subdirs
Extra elements to append to the returned path.
This function locates the directory where CASA resource data files (tables
of time offsets, calibrator models, etc.) are stored. If called with no
arguments, it simply ... | [
"def",
"datadir",
"(",
"*",
"subdirs",
")",
":",
"import",
"os",
".",
"path",
"data",
"=",
"None",
"if",
"'CASAPATH'",
"in",
"os",
".",
"environ",
":",
"data",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"environ",
"[",
"'CASAPATH'",
"]",
... | Get a path within the CASA data directory.
subdirs
Extra elements to append to the returned path.
This function locates the directory where CASA resource data files (tables
of time offsets, calibrator models, etc.) are stored. If called with no
arguments, it simply returns that path. If argument... | [
"Get",
"a",
"path",
"within",
"the",
"CASA",
"data",
"directory",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/util.py#L108-L163 |
45,345 | pkgw/pwkit | pwkit/environments/casa/util.py | logger | def logger(filter='WARN'):
"""Set up CASA to write log messages to standard output.
filter
The log level filter: less urgent messages will not be shown. Valid values
are strings: "DEBUG1", "INFO5", ... "INFO1", "INFO", "WARN", "SEVERE".
This function creates and returns a CASA ”log sink” objec... | python | def logger(filter='WARN'):
"""Set up CASA to write log messages to standard output.
filter
The log level filter: less urgent messages will not be shown. Valid values
are strings: "DEBUG1", "INFO5", ... "INFO1", "INFO", "WARN", "SEVERE".
This function creates and returns a CASA ”log sink” objec... | [
"def",
"logger",
"(",
"filter",
"=",
"'WARN'",
")",
":",
"import",
"os",
",",
"shutil",
",",
"tempfile",
"cwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"tempdir",
"=",
"None",
"try",
":",
"tempdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"prefix",
"=",
... | Set up CASA to write log messages to standard output.
filter
The log level filter: less urgent messages will not be shown. Valid values
are strings: "DEBUG1", "INFO5", ... "INFO1", "INFO", "WARN", "SEVERE".
This function creates and returns a CASA ”log sink” object that is
configured to write ... | [
"Set",
"up",
"CASA",
"to",
"write",
"log",
"messages",
"to",
"standard",
"output",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/util.py#L176-L218 |
45,346 | pkgw/pwkit | pwkit/environments/casa/util.py | forkandlog | def forkandlog(function, filter='INFO5', debug=False):
"""Fork a child process and read its CASA log output.
function
A function to run in the child process
filter
The CASA log level filter to apply in the child process: less urgent
messages will not be shown. Valid values are strings: "D... | python | def forkandlog(function, filter='INFO5', debug=False):
"""Fork a child process and read its CASA log output.
function
A function to run in the child process
filter
The CASA log level filter to apply in the child process: less urgent
messages will not be shown. Valid values are strings: "D... | [
"def",
"forkandlog",
"(",
"function",
",",
"filter",
"=",
"'INFO5'",
",",
"debug",
"=",
"False",
")",
":",
"import",
"sys",
",",
"os",
"readfd",
",",
"writefd",
"=",
"os",
".",
"pipe",
"(",
")",
"pid",
"=",
"os",
".",
"fork",
"(",
")",
"if",
"pid... | Fork a child process and read its CASA log output.
function
A function to run in the child process
filter
The CASA log level filter to apply in the child process: less urgent
messages will not be shown. Valid values are strings: "DEBUG1", "INFO5",
... "INFO1", "INFO", "WARN", "SEVERE".
... | [
"Fork",
"a",
"child",
"process",
"and",
"read",
"its",
"CASA",
"log",
"output",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/util.py#L221-L306 |
45,347 | kapadia/usgs | usgs/api.py | _get_extended | def _get_extended(scene, resp):
"""
Parse metadata returned from the metadataUrl of a USGS scene.
:param scene:
Dictionary representation of a USGS scene
:param resp:
Response object from requests/grequests
"""
root = ElementTree.fromstring(resp.text)
items = root.findall("e... | python | def _get_extended(scene, resp):
"""
Parse metadata returned from the metadataUrl of a USGS scene.
:param scene:
Dictionary representation of a USGS scene
:param resp:
Response object from requests/grequests
"""
root = ElementTree.fromstring(resp.text)
items = root.findall("e... | [
"def",
"_get_extended",
"(",
"scene",
",",
"resp",
")",
":",
"root",
"=",
"ElementTree",
".",
"fromstring",
"(",
"resp",
".",
"text",
")",
"items",
"=",
"root",
".",
"findall",
"(",
"\"eemetadata:metadataFields/eemetadata:metadataField\"",
",",
"NAMESPACES",
")"... | Parse metadata returned from the metadataUrl of a USGS scene.
:param scene:
Dictionary representation of a USGS scene
:param resp:
Response object from requests/grequests | [
"Parse",
"metadata",
"returned",
"from",
"the",
"metadataUrl",
"of",
"a",
"USGS",
"scene",
"."
] | 0608346f0bc3c34e20f4ecc77ad71d0b514db7ee | https://github.com/kapadia/usgs/blob/0608346f0bc3c34e20f4ecc77ad71d0b514db7ee/usgs/api.py#L38-L51 |
45,348 | kapadia/usgs | usgs/api.py | _async_requests | def _async_requests(urls):
"""
Sends multiple non-blocking requests. Returns
a list of responses.
:param urls:
List of urls
"""
session = FuturesSession(max_workers=30)
futures = [
session.get(url)
for url in urls
]
return [ future.result() for future in futu... | python | def _async_requests(urls):
"""
Sends multiple non-blocking requests. Returns
a list of responses.
:param urls:
List of urls
"""
session = FuturesSession(max_workers=30)
futures = [
session.get(url)
for url in urls
]
return [ future.result() for future in futu... | [
"def",
"_async_requests",
"(",
"urls",
")",
":",
"session",
"=",
"FuturesSession",
"(",
"max_workers",
"=",
"30",
")",
"futures",
"=",
"[",
"session",
".",
"get",
"(",
"url",
")",
"for",
"url",
"in",
"urls",
"]",
"return",
"[",
"future",
".",
"result",... | Sends multiple non-blocking requests. Returns
a list of responses.
:param urls:
List of urls | [
"Sends",
"multiple",
"non",
"-",
"blocking",
"requests",
".",
"Returns",
"a",
"list",
"of",
"responses",
"."
] | 0608346f0bc3c34e20f4ecc77ad71d0b514db7ee | https://github.com/kapadia/usgs/blob/0608346f0bc3c34e20f4ecc77ad71d0b514db7ee/usgs/api.py#L54-L67 |
45,349 | kapadia/usgs | usgs/api.py | metadata | def metadata(dataset, node, entityids, extended=False, api_key=None):
"""
Request metadata for a given scene in a USGS dataset.
:param dataset:
:param node:
:param entityids:
:param extended:
Send a second request to the metadata url to get extended metadata on the scene.
:param api... | python | def metadata(dataset, node, entityids, extended=False, api_key=None):
"""
Request metadata for a given scene in a USGS dataset.
:param dataset:
:param node:
:param entityids:
:param extended:
Send a second request to the metadata url to get extended metadata on the scene.
:param api... | [
"def",
"metadata",
"(",
"dataset",
",",
"node",
",",
"entityids",
",",
"extended",
"=",
"False",
",",
"api_key",
"=",
"None",
")",
":",
"api_key",
"=",
"_get_api_key",
"(",
"api_key",
")",
"url",
"=",
"'{}/metadata'",
".",
"format",
"(",
"USGS_API",
")",... | Request metadata for a given scene in a USGS dataset.
:param dataset:
:param node:
:param entityids:
:param extended:
Send a second request to the metadata url to get extended metadata on the scene.
:param api_key: | [
"Request",
"metadata",
"for",
"a",
"given",
"scene",
"in",
"a",
"USGS",
"dataset",
"."
] | 0608346f0bc3c34e20f4ecc77ad71d0b514db7ee | https://github.com/kapadia/usgs/blob/0608346f0bc3c34e20f4ecc77ad71d0b514db7ee/usgs/api.py#L217-L244 |
45,350 | pkgw/pwkit | pwkit/__init__.py | reraise_context | def reraise_context(fmt, *args):
"""Reraise an exception with its message modified to specify additional
context.
This function tries to help provide context when a piece of code
encounters an exception while trying to get something done, and it wishes
to propagate contextual information farther up... | python | def reraise_context(fmt, *args):
"""Reraise an exception with its message modified to specify additional
context.
This function tries to help provide context when a piece of code
encounters an exception while trying to get something done, and it wishes
to propagate contextual information farther up... | [
"def",
"reraise_context",
"(",
"fmt",
",",
"*",
"args",
")",
":",
"import",
"sys",
"if",
"len",
"(",
"args",
")",
":",
"cstr",
"=",
"fmt",
"%",
"args",
"else",
":",
"cstr",
"=",
"text_type",
"(",
"fmt",
")",
"ex",
"=",
"sys",
".",
"exc_info",
"("... | Reraise an exception with its message modified to specify additional
context.
This function tries to help provide context when a piece of code
encounters an exception while trying to get something done, and it wishes
to propagate contextual information farther up the call stack. It only
makes sense... | [
"Reraise",
"an",
"exception",
"with",
"its",
"message",
"modified",
"to",
"specify",
"additional",
"context",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/__init__.py#L59-L114 |
45,351 | pkgw/pwkit | pwkit/__init__.py | Holder.copy | def copy(self):
"""Return a shallow copy of this object.
"""
new = self.__class__()
new.__dict__ = dict(self.__dict__)
return new | python | def copy(self):
"""Return a shallow copy of this object.
"""
new = self.__class__()
new.__dict__ = dict(self.__dict__)
return new | [
"def",
"copy",
"(",
"self",
")",
":",
"new",
"=",
"self",
".",
"__class__",
"(",
")",
"new",
".",
"__dict__",
"=",
"dict",
"(",
"self",
".",
"__dict__",
")",
"return",
"new"
] | Return a shallow copy of this object. | [
"Return",
"a",
"shallow",
"copy",
"of",
"this",
"object",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/__init__.py#L205-L211 |
45,352 | bibanon/BASC-py4chan | basc_py4chan/board.py | get_all_boards | def get_all_boards(*args, **kwargs):
"""Returns every board on 4chan.
Returns:
dict of :class:`basc_py4chan.Board`: All boards.
"""
# Use https based on how the Board class instances are to be instantiated
https = kwargs.get('https', args[1] if len(args) > 1 else False)
# Dummy URL gen... | python | def get_all_boards(*args, **kwargs):
"""Returns every board on 4chan.
Returns:
dict of :class:`basc_py4chan.Board`: All boards.
"""
# Use https based on how the Board class instances are to be instantiated
https = kwargs.get('https', args[1] if len(args) > 1 else False)
# Dummy URL gen... | [
"def",
"get_all_boards",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Use https based on how the Board class instances are to be instantiated",
"https",
"=",
"kwargs",
".",
"get",
"(",
"'https'",
",",
"args",
"[",
"1",
"]",
"if",
"len",
"(",
"args",
... | Returns every board on 4chan.
Returns:
dict of :class:`basc_py4chan.Board`: All boards. | [
"Returns",
"every",
"board",
"on",
"4chan",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/board.py#L57-L70 |
45,353 | bibanon/BASC-py4chan | basc_py4chan/board.py | Board.get_thread | def get_thread(self, thread_id, update_if_cached=True, raise_404=False):
"""Get a thread from 4chan via 4chan API.
Args:
thread_id (int): Thread ID
update_if_cached (bool): Whether the thread should be updated if it's already in our cache
raise_404 (bool): Raise an E... | python | def get_thread(self, thread_id, update_if_cached=True, raise_404=False):
"""Get a thread from 4chan via 4chan API.
Args:
thread_id (int): Thread ID
update_if_cached (bool): Whether the thread should be updated if it's already in our cache
raise_404 (bool): Raise an E... | [
"def",
"get_thread",
"(",
"self",
",",
"thread_id",
",",
"update_if_cached",
"=",
"True",
",",
"raise_404",
"=",
"False",
")",
":",
"# see if already cached",
"cached_thread",
"=",
"self",
".",
"_thread_cache",
".",
"get",
"(",
"thread_id",
")",
"if",
"cached_... | Get a thread from 4chan via 4chan API.
Args:
thread_id (int): Thread ID
update_if_cached (bool): Whether the thread should be updated if it's already in our cache
raise_404 (bool): Raise an Exception if thread has 404'd
Returns:
:class:`basc_py4chan.Thre... | [
"Get",
"a",
"thread",
"from",
"4chan",
"via",
"4chan",
"API",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/board.py#L110-L143 |
45,354 | bibanon/BASC-py4chan | basc_py4chan/board.py | Board.thread_exists | def thread_exists(self, thread_id):
"""Check if a thread exists or has 404'd.
Args:
thread_id (int): Thread ID
Returns:
bool: Whether the given thread exists on this board.
"""
return self._requests_session.head(
self._url.thread_api_url(
... | python | def thread_exists(self, thread_id):
"""Check if a thread exists or has 404'd.
Args:
thread_id (int): Thread ID
Returns:
bool: Whether the given thread exists on this board.
"""
return self._requests_session.head(
self._url.thread_api_url(
... | [
"def",
"thread_exists",
"(",
"self",
",",
"thread_id",
")",
":",
"return",
"self",
".",
"_requests_session",
".",
"head",
"(",
"self",
".",
"_url",
".",
"thread_api_url",
"(",
"thread_id",
"=",
"thread_id",
")",
")",
".",
"ok"
] | Check if a thread exists or has 404'd.
Args:
thread_id (int): Thread ID
Returns:
bool: Whether the given thread exists on this board. | [
"Check",
"if",
"a",
"thread",
"exists",
"or",
"has",
"404",
"d",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/board.py#L145-L158 |
45,355 | bibanon/BASC-py4chan | basc_py4chan/board.py | Board.get_threads | def get_threads(self, page=1):
"""Returns all threads on a certain page.
Gets a list of Thread objects for every thread on the given page. If a thread is
already in our cache, the cached version is returned and thread.want_update is
set to True on the specific thread object.
Pa... | python | def get_threads(self, page=1):
"""Returns all threads on a certain page.
Gets a list of Thread objects for every thread on the given page. If a thread is
already in our cache, the cached version is returned and thread.want_update is
set to True on the specific thread object.
Pa... | [
"def",
"get_threads",
"(",
"self",
",",
"page",
"=",
"1",
")",
":",
"url",
"=",
"self",
".",
"_url",
".",
"page_url",
"(",
"page",
")",
"return",
"self",
".",
"_request_threads",
"(",
"url",
")"
] | Returns all threads on a certain page.
Gets a list of Thread objects for every thread on the given page. If a thread is
already in our cache, the cached version is returned and thread.want_update is
set to True on the specific thread object.
Pages on 4chan are indexed from 1 onwards.
... | [
"Returns",
"all",
"threads",
"on",
"a",
"certain",
"page",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/board.py#L192-L208 |
45,356 | bibanon/BASC-py4chan | basc_py4chan/board.py | Board.get_all_thread_ids | def get_all_thread_ids(self):
"""Return the ID of every thread on this board.
Returns:
list of ints: List of IDs of every thread on this board.
"""
json = self._get_json(self._url.thread_list())
return [thread['no'] for page in json for thread in page['threads']] | python | def get_all_thread_ids(self):
"""Return the ID of every thread on this board.
Returns:
list of ints: List of IDs of every thread on this board.
"""
json = self._get_json(self._url.thread_list())
return [thread['no'] for page in json for thread in page['threads']] | [
"def",
"get_all_thread_ids",
"(",
"self",
")",
":",
"json",
"=",
"self",
".",
"_get_json",
"(",
"self",
".",
"_url",
".",
"thread_list",
"(",
")",
")",
"return",
"[",
"thread",
"[",
"'no'",
"]",
"for",
"page",
"in",
"json",
"for",
"thread",
"in",
"pa... | Return the ID of every thread on this board.
Returns:
list of ints: List of IDs of every thread on this board. | [
"Return",
"the",
"ID",
"of",
"every",
"thread",
"on",
"this",
"board",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/board.py#L210-L217 |
45,357 | bibanon/BASC-py4chan | basc_py4chan/board.py | Board.get_all_threads | def get_all_threads(self, expand=False):
"""Return every thread on this board.
If not expanded, result is same as get_threads run across all board pages,
with last 3-5 replies included.
Uses the catalog when not expanding, and uses the flat thread ID listing
at /{board}/threads... | python | def get_all_threads(self, expand=False):
"""Return every thread on this board.
If not expanded, result is same as get_threads run across all board pages,
with last 3-5 replies included.
Uses the catalog when not expanding, and uses the flat thread ID listing
at /{board}/threads... | [
"def",
"get_all_threads",
"(",
"self",
",",
"expand",
"=",
"False",
")",
":",
"if",
"not",
"expand",
":",
"return",
"self",
".",
"_request_threads",
"(",
"self",
".",
"_url",
".",
"catalog",
"(",
")",
")",
"thread_ids",
"=",
"self",
".",
"get_all_thread_... | Return every thread on this board.
If not expanded, result is same as get_threads run across all board pages,
with last 3-5 replies included.
Uses the catalog when not expanding, and uses the flat thread ID listing
at /{board}/threads.json when expanding for more efficient resource usa... | [
"Return",
"every",
"thread",
"on",
"this",
"board",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/board.py#L219-L243 |
45,358 | bibanon/BASC-py4chan | basc_py4chan/board.py | Board.refresh_cache | def refresh_cache(self, if_want_update=False):
"""Update all threads currently stored in our cache."""
for thread in tuple(self._thread_cache.values()):
if if_want_update:
if not thread.want_update:
continue
thread.update() | python | def refresh_cache(self, if_want_update=False):
"""Update all threads currently stored in our cache."""
for thread in tuple(self._thread_cache.values()):
if if_want_update:
if not thread.want_update:
continue
thread.update() | [
"def",
"refresh_cache",
"(",
"self",
",",
"if_want_update",
"=",
"False",
")",
":",
"for",
"thread",
"in",
"tuple",
"(",
"self",
".",
"_thread_cache",
".",
"values",
"(",
")",
")",
":",
"if",
"if_want_update",
":",
"if",
"not",
"thread",
".",
"want_updat... | Update all threads currently stored in our cache. | [
"Update",
"all",
"threads",
"currently",
"stored",
"in",
"our",
"cache",
"."
] | 88e4866d73853e1025e549fbbe9744e750522359 | https://github.com/bibanon/BASC-py4chan/blob/88e4866d73853e1025e549fbbe9744e750522359/basc_py4chan/board.py#L245-L251 |
45,359 | pkgw/pwkit | pwkit/environments/casa/__init__.py | CasaEnvironment.modify_environment | def modify_environment(self, env):
"""Maintaining compatibility with different CASA versions is a pain."""
# Ugh. I don't see any way out of special-casing the RPM-based
# installations ... which only exist on NRAO computers, AFAICT.
# Hardcoding 64-bitness, hopefully that won't come ba... | python | def modify_environment(self, env):
"""Maintaining compatibility with different CASA versions is a pain."""
# Ugh. I don't see any way out of special-casing the RPM-based
# installations ... which only exist on NRAO computers, AFAICT.
# Hardcoding 64-bitness, hopefully that won't come ba... | [
"def",
"modify_environment",
"(",
"self",
",",
"env",
")",
":",
"# Ugh. I don't see any way out of special-casing the RPM-based",
"# installations ... which only exist on NRAO computers, AFAICT.",
"# Hardcoding 64-bitness, hopefully that won't come back to bite me.",
"is_rpm_install",
"=",
... | Maintaining compatibility with different CASA versions is a pain. | [
"Maintaining",
"compatibility",
"with",
"different",
"CASA",
"versions",
"is",
"a",
"pain",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/__init__.py#L86-L140 |
45,360 | pkgw/pwkit | pwkit/environments/ciao/analysis.py | compute_bgband | def compute_bgband (evtpath, srcreg, bkgreg, ebins, env=None):
"""Compute background information for a source in one or more energy bands.
evtpath
Path to a CIAO events file
srcreg
String specifying the source region to consider; use 'region(path.reg)' if you
have the region saved in a fi... | python | def compute_bgband (evtpath, srcreg, bkgreg, ebins, env=None):
"""Compute background information for a source in one or more energy bands.
evtpath
Path to a CIAO events file
srcreg
String specifying the source region to consider; use 'region(path.reg)' if you
have the region saved in a fi... | [
"def",
"compute_bgband",
"(",
"evtpath",
",",
"srcreg",
",",
"bkgreg",
",",
"ebins",
",",
"env",
"=",
"None",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"pandas",
"as",
"pd",
"from",
"scipy",
".",
"special",
"import",
"erfcinv",
",",
"gammaln",
... | Compute background information for a source in one or more energy bands.
evtpath
Path to a CIAO events file
srcreg
String specifying the source region to consider; use 'region(path.reg)' if you
have the region saved in a file.
bkgreg
String specifying the background region to consid... | [
"Compute",
"background",
"information",
"for",
"a",
"source",
"in",
"one",
"or",
"more",
"energy",
"bands",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/ciao/analysis.py#L50-L129 |
45,361 | pkgw/pwkit | pwkit/environments/ciao/analysis.py | simple_srcflux | def simple_srcflux(env, infile=None, psfmethod='arfcorr', conf=0.68,
verbose=0, **kwargs):
"""Run the CIAO "srcflux" script and retrieve its results.
*infile*
The input events file; must be specified. The computation is done
in a temporary directory, so this path — and all others... | python | def simple_srcflux(env, infile=None, psfmethod='arfcorr', conf=0.68,
verbose=0, **kwargs):
"""Run the CIAO "srcflux" script and retrieve its results.
*infile*
The input events file; must be specified. The computation is done
in a temporary directory, so this path — and all others... | [
"def",
"simple_srcflux",
"(",
"env",
",",
"infile",
"=",
"None",
",",
"psfmethod",
"=",
"'arfcorr'",
",",
"conf",
"=",
"0.68",
",",
"verbose",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
".",
".",
"io",
"import",
"Path",
"import",
"sh... | Run the CIAO "srcflux" script and retrieve its results.
*infile*
The input events file; must be specified. The computation is done
in a temporary directory, so this path — and all others passed in
as arguments — **must be made absolute**.
*psfmethod* = "arfcorr"
The PSF modeling method ... | [
"Run",
"the",
"CIAO",
"srcflux",
"script",
"and",
"retrieve",
"its",
"results",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/ciao/analysis.py#L136-L199 |
45,362 | pkgw/pwkit | pwkit/fk10.py | Calculator.new_for_fk10_fig9 | def new_for_fk10_fig9(cls, shlib_path):
"""Create a calculator initialized to reproduce Figure 9 from FK10.
This is mostly to provide a handy way to create a new
:class:`Calculator` instance that is initialized with reasonable
values for all of its parameters.
"""
inst ... | python | def new_for_fk10_fig9(cls, shlib_path):
"""Create a calculator initialized to reproduce Figure 9 from FK10.
This is mostly to provide a handy way to create a new
:class:`Calculator` instance that is initialized with reasonable
values for all of its parameters.
"""
inst ... | [
"def",
"new_for_fk10_fig9",
"(",
"cls",
",",
"shlib_path",
")",
":",
"inst",
"=",
"(",
"cls",
"(",
"shlib_path",
")",
".",
"set_thermal_background",
"(",
"2.1e7",
",",
"3e9",
")",
".",
"set_bfield",
"(",
"48",
")",
".",
"set_edist_powerlaw",
"(",
"0.016",
... | Create a calculator initialized to reproduce Figure 9 from FK10.
This is mostly to provide a handy way to create a new
:class:`Calculator` instance that is initialized with reasonable
values for all of its parameters. | [
"Create",
"a",
"calculator",
"initialized",
"to",
"reproduce",
"Figure",
"9",
"from",
"FK10",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L322-L344 |
45,363 | pkgw/pwkit | pwkit/fk10.py | Calculator.set_bfield | def set_bfield(self, B_G):
"""Set the strength of the local magnetic field.
**Call signature**
*B_G*
The magnetic field strength, in Gauss
Returns
*self* for convenience in chaining.
"""
if not (B_G > 0):
raise ValueError('must have B_G >... | python | def set_bfield(self, B_G):
"""Set the strength of the local magnetic field.
**Call signature**
*B_G*
The magnetic field strength, in Gauss
Returns
*self* for convenience in chaining.
"""
if not (B_G > 0):
raise ValueError('must have B_G >... | [
"def",
"set_bfield",
"(",
"self",
",",
"B_G",
")",
":",
"if",
"not",
"(",
"B_G",
">",
"0",
")",
":",
"raise",
"ValueError",
"(",
"'must have B_G > 0; got %r'",
"%",
"(",
"B_G",
",",
")",
")",
"self",
".",
"in_vals",
"[",
"IN_VAL_B",
"]",
"=",
"B_G",
... | Set the strength of the local magnetic field.
**Call signature**
*B_G*
The magnetic field strength, in Gauss
Returns
*self* for convenience in chaining. | [
"Set",
"the",
"strength",
"of",
"the",
"local",
"magnetic",
"field",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L364-L378 |
45,364 | pkgw/pwkit | pwkit/fk10.py | Calculator.set_bfield_for_s0 | def set_bfield_for_s0(self, s0):
"""Set B to probe a certain harmonic number.
**Call signature**
*s0*
The harmonic number to probe at the lowest frequency
Returns
*self* for convenience in chaining.
This just proceeds from the relation ``nu = s nu_c = s e B... | python | def set_bfield_for_s0(self, s0):
"""Set B to probe a certain harmonic number.
**Call signature**
*s0*
The harmonic number to probe at the lowest frequency
Returns
*self* for convenience in chaining.
This just proceeds from the relation ``nu = s nu_c = s e B... | [
"def",
"set_bfield_for_s0",
"(",
"self",
",",
"s0",
")",
":",
"if",
"not",
"(",
"s0",
">",
"0",
")",
":",
"raise",
"ValueError",
"(",
"'must have s0 > 0; got %r'",
"%",
"(",
"s0",
",",
")",
")",
"B0",
"=",
"2",
"*",
"np",
".",
"pi",
"*",
"cgs",
"... | Set B to probe a certain harmonic number.
**Call signature**
*s0*
The harmonic number to probe at the lowest frequency
Returns
*self* for convenience in chaining.
This just proceeds from the relation ``nu = s nu_c = s e B / 2 pi m_e
c``. Since *s* and *nu* ... | [
"Set",
"B",
"to",
"probe",
"a",
"certain",
"harmonic",
"number",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L381-L402 |
45,365 | pkgw/pwkit | pwkit/fk10.py | Calculator.set_edist_powerlaw | def set_edist_powerlaw(self, emin_mev, emax_mev, delta, ne_cc):
"""Set the energy distribution function to a power law.
**Call signature**
*emin_mev*
The minimum energy of the distribution, in MeV
*emax_mev*
The maximum energy of the distribution, in MeV
*de... | python | def set_edist_powerlaw(self, emin_mev, emax_mev, delta, ne_cc):
"""Set the energy distribution function to a power law.
**Call signature**
*emin_mev*
The minimum energy of the distribution, in MeV
*emax_mev*
The maximum energy of the distribution, in MeV
*de... | [
"def",
"set_edist_powerlaw",
"(",
"self",
",",
"emin_mev",
",",
"emax_mev",
",",
"delta",
",",
"ne_cc",
")",
":",
"if",
"not",
"(",
"emin_mev",
">=",
"0",
")",
":",
"raise",
"ValueError",
"(",
"'must have emin_mev >= 0; got %r'",
"%",
"(",
"emin_mev",
",",
... | Set the energy distribution function to a power law.
**Call signature**
*emin_mev*
The minimum energy of the distribution, in MeV
*emax_mev*
The maximum energy of the distribution, in MeV
*delta*
The power-law index of the distribution
*ne_cc*
... | [
"Set",
"the",
"energy",
"distribution",
"function",
"to",
"a",
"power",
"law",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L405-L435 |
45,366 | pkgw/pwkit | pwkit/fk10.py | Calculator.set_edist_powerlaw_gamma | def set_edist_powerlaw_gamma(self, gmin, gmax, delta, ne_cc):
"""Set the energy distribution function to a power law in the Lorentz factor
**Call signature**
*gmin*
The minimum Lorentz factor of the distribution
*gmax*
The maximum Lorentz factor of the distribution
... | python | def set_edist_powerlaw_gamma(self, gmin, gmax, delta, ne_cc):
"""Set the energy distribution function to a power law in the Lorentz factor
**Call signature**
*gmin*
The minimum Lorentz factor of the distribution
*gmax*
The maximum Lorentz factor of the distribution
... | [
"def",
"set_edist_powerlaw_gamma",
"(",
"self",
",",
"gmin",
",",
"gmax",
",",
"delta",
",",
"ne_cc",
")",
":",
"if",
"not",
"(",
"gmin",
">=",
"1",
")",
":",
"raise",
"ValueError",
"(",
"'must have gmin >= 1; got %r'",
"%",
"(",
"gmin",
",",
")",
")",
... | Set the energy distribution function to a power law in the Lorentz factor
**Call signature**
*gmin*
The minimum Lorentz factor of the distribution
*gmax*
The maximum Lorentz factor of the distribution
*delta*
The power-law index of the distribution
... | [
"Set",
"the",
"energy",
"distribution",
"function",
"to",
"a",
"power",
"law",
"in",
"the",
"Lorentz",
"factor"
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L438-L468 |
45,367 | pkgw/pwkit | pwkit/fk10.py | Calculator.set_freqs | def set_freqs(self, n, f_lo_ghz, f_hi_ghz):
"""Set the frequency grid on which to perform the calculations.
**Call signature**
*n*
The number of frequency points to sample.
*f_lo_ghz*
The lowest frequency to sample, in GHz.
*f_hi_ghz*
The highest f... | python | def set_freqs(self, n, f_lo_ghz, f_hi_ghz):
"""Set the frequency grid on which to perform the calculations.
**Call signature**
*n*
The number of frequency points to sample.
*f_lo_ghz*
The lowest frequency to sample, in GHz.
*f_hi_ghz*
The highest f... | [
"def",
"set_freqs",
"(",
"self",
",",
"n",
",",
"f_lo_ghz",
",",
"f_hi_ghz",
")",
":",
"if",
"not",
"(",
"f_lo_ghz",
">=",
"0",
")",
":",
"raise",
"ValueError",
"(",
"'must have f_lo_ghz >= 0; got %r'",
"%",
"(",
"f_lo_ghz",
",",
")",
")",
"if",
"not",
... | Set the frequency grid on which to perform the calculations.
**Call signature**
*n*
The number of frequency points to sample.
*f_lo_ghz*
The lowest frequency to sample, in GHz.
*f_hi_ghz*
The highest frequency to sample, in GHz.
Returns
*... | [
"Set",
"the",
"frequency",
"grid",
"on",
"which",
"to",
"perform",
"the",
"calculations",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L471-L496 |
45,368 | pkgw/pwkit | pwkit/fk10.py | Calculator.set_obs_angle | def set_obs_angle(self, theta_rad):
"""Set the observer angle relative to the field.
**Call signature**
*theta_rad*
The angle between the ray path and the local magnetic field,
in radians.
Returns
*self* for convenience in chaining.
"""
sel... | python | def set_obs_angle(self, theta_rad):
"""Set the observer angle relative to the field.
**Call signature**
*theta_rad*
The angle between the ray path and the local magnetic field,
in radians.
Returns
*self* for convenience in chaining.
"""
sel... | [
"def",
"set_obs_angle",
"(",
"self",
",",
"theta_rad",
")",
":",
"self",
".",
"in_vals",
"[",
"IN_VAL_THETA",
"]",
"=",
"theta_rad",
"*",
"180",
"/",
"np",
".",
"pi",
"# rad => deg",
"return",
"self"
] | Set the observer angle relative to the field.
**Call signature**
*theta_rad*
The angle between the ray path and the local magnetic field,
in radians.
Returns
*self* for convenience in chaining. | [
"Set",
"the",
"observer",
"angle",
"relative",
"to",
"the",
"field",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L550-L562 |
45,369 | pkgw/pwkit | pwkit/fk10.py | Calculator.set_one_freq | def set_one_freq(self, f_ghz):
"""Set the code to calculate results at just one frequency.
**Call signature**
*f_ghz*
The frequency to sample, in GHz.
Returns
*self* for convenience in chaining.
"""
if not (f_ghz >= 0):
raise ValueError(... | python | def set_one_freq(self, f_ghz):
"""Set the code to calculate results at just one frequency.
**Call signature**
*f_ghz*
The frequency to sample, in GHz.
Returns
*self* for convenience in chaining.
"""
if not (f_ghz >= 0):
raise ValueError(... | [
"def",
"set_one_freq",
"(",
"self",
",",
"f_ghz",
")",
":",
"if",
"not",
"(",
"f_ghz",
">=",
"0",
")",
":",
"raise",
"ValueError",
"(",
"'must have f_lo_ghz >= 0; got %r'",
"%",
"(",
"f_lo_ghz",
",",
")",
")",
"self",
".",
"in_vals",
"[",
"IN_VAL_NFREQ",
... | Set the code to calculate results at just one frequency.
**Call signature**
*f_ghz*
The frequency to sample, in GHz.
Returns
*self* for convenience in chaining. | [
"Set",
"the",
"code",
"to",
"calculate",
"results",
"at",
"just",
"one",
"frequency",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L565-L582 |
45,370 | pkgw/pwkit | pwkit/fk10.py | Calculator.set_padist_gaussian_loss_cone | def set_padist_gaussian_loss_cone(self, boundary_rad, expwidth):
"""Set the pitch-angle distribution to a Gaussian loss cone.
**Call signature**
*boundary_rad*
The angle inside which there are no losses, in radians.
*expwidth*
The characteristic width of the Gaussia... | python | def set_padist_gaussian_loss_cone(self, boundary_rad, expwidth):
"""Set the pitch-angle distribution to a Gaussian loss cone.
**Call signature**
*boundary_rad*
The angle inside which there are no losses, in radians.
*expwidth*
The characteristic width of the Gaussia... | [
"def",
"set_padist_gaussian_loss_cone",
"(",
"self",
",",
"boundary_rad",
",",
"expwidth",
")",
":",
"self",
".",
"in_vals",
"[",
"IN_VAL_PADIST",
"]",
"=",
"PADIST_GLC",
"self",
".",
"in_vals",
"[",
"IN_VAL_LCBDY",
"]",
"=",
"boundary_rad",
"*",
"180",
"/",
... | Set the pitch-angle distribution to a Gaussian loss cone.
**Call signature**
*boundary_rad*
The angle inside which there are no losses, in radians.
*expwidth*
The characteristic width of the Gaussian loss profile
*in direction-cosine units*.
Returns
... | [
"Set",
"the",
"pitch",
"-",
"angle",
"distribution",
"to",
"a",
"Gaussian",
"loss",
"cone",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L585-L606 |
45,371 | pkgw/pwkit | pwkit/fk10.py | Calculator.set_thermal_background | def set_thermal_background(self, T_K, nth_cc):
"""Set the properties of the background thermal plasma.
**Call signature**
*T_K*
The temperature of the background plasma, in Kelvin.
*nth_cc*
The number density of thermal electrons, in cm^-3.
Returns
... | python | def set_thermal_background(self, T_K, nth_cc):
"""Set the properties of the background thermal plasma.
**Call signature**
*T_K*
The temperature of the background plasma, in Kelvin.
*nth_cc*
The number density of thermal electrons, in cm^-3.
Returns
... | [
"def",
"set_thermal_background",
"(",
"self",
",",
"T_K",
",",
"nth_cc",
")",
":",
"if",
"not",
"(",
"T_K",
">=",
"0",
")",
":",
"raise",
"ValueError",
"(",
"'must have T_K >= 0; got %r'",
"%",
"(",
"T_K",
",",
")",
")",
"if",
"not",
"(",
"nth_cc",
">=... | Set the properties of the background thermal plasma.
**Call signature**
*T_K*
The temperature of the background plasma, in Kelvin.
*nth_cc*
The number density of thermal electrons, in cm^-3.
Returns
*self* for convenience in chaining.
Note that th... | [
"Set",
"the",
"properties",
"of",
"the",
"background",
"thermal",
"plasma",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L640-L669 |
45,372 | pkgw/pwkit | pwkit/fk10.py | Calculator.set_trapezoidal_integration | def set_trapezoidal_integration(self, n):
"""Set the code to use trapezoidal integration.
**Call signature**
*n*
Use this many nodes
Returns
*self* for convenience in chaining.
"""
if not (n >= 2):
raise ValueError('must have n >= 2; got... | python | def set_trapezoidal_integration(self, n):
"""Set the code to use trapezoidal integration.
**Call signature**
*n*
Use this many nodes
Returns
*self* for convenience in chaining.
"""
if not (n >= 2):
raise ValueError('must have n >= 2; got... | [
"def",
"set_trapezoidal_integration",
"(",
"self",
",",
"n",
")",
":",
"if",
"not",
"(",
"n",
">=",
"2",
")",
":",
"raise",
"ValueError",
"(",
"'must have n >= 2; got %r'",
"%",
"(",
"n",
",",
")",
")",
"self",
".",
"in_vals",
"[",
"IN_VAL_INTEG_METH",
"... | Set the code to use trapezoidal integration.
**Call signature**
*n*
Use this many nodes
Returns
*self* for convenience in chaining. | [
"Set",
"the",
"code",
"to",
"use",
"trapezoidal",
"integration",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L672-L687 |
45,373 | pkgw/pwkit | pwkit/fk10.py | Calculator.find_rt_coefficients | def find_rt_coefficients(self, depth0=None):
"""Figure out emission and absorption coefficients for the current parameters.
**Argument**
*depth0* (default None)
A first guess to use for a good integration depth, in cm. If None,
the most recent value is used.
**Retu... | python | def find_rt_coefficients(self, depth0=None):
"""Figure out emission and absorption coefficients for the current parameters.
**Argument**
*depth0* (default None)
A first guess to use for a good integration depth, in cm. If None,
the most recent value is used.
**Retu... | [
"def",
"find_rt_coefficients",
"(",
"self",
",",
"depth0",
"=",
"None",
")",
":",
"if",
"self",
".",
"in_vals",
"[",
"IN_VAL_NFREQ",
"]",
"!=",
"1",
":",
"raise",
"Exception",
"(",
"'must have nfreq=1 to run Calculator.find_rt_coefficients()'",
")",
"if",
"depth0"... | Figure out emission and absorption coefficients for the current parameters.
**Argument**
*depth0* (default None)
A first guess to use for a good integration depth, in cm. If None,
the most recent value is used.
**Return value**
A tuple ``(j_O, alpha_O, j_X, alpha_... | [
"Figure",
"out",
"emission",
"and",
"absorption",
"coefficients",
"for",
"the",
"current",
"parameters",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L690-L805 |
45,374 | pkgw/pwkit | pwkit/fk10.py | Calculator.find_rt_coefficients_tot_intens | def find_rt_coefficients_tot_intens(self, depth0=None):
"""Figure out total-intensity emission and absorption coefficients for the
current parameters.
**Argument**
*depth0* (default None)
A first guess to use for a good integration depth, in cm. If None,
the most re... | python | def find_rt_coefficients_tot_intens(self, depth0=None):
"""Figure out total-intensity emission and absorption coefficients for the
current parameters.
**Argument**
*depth0* (default None)
A first guess to use for a good integration depth, in cm. If None,
the most re... | [
"def",
"find_rt_coefficients_tot_intens",
"(",
"self",
",",
"depth0",
"=",
"None",
")",
":",
"j_O",
",",
"alpha_O",
",",
"j_X",
",",
"alpha_X",
"=",
"self",
".",
"find_rt_coefficients",
"(",
"depth0",
"=",
"depth0",
")",
"j_I",
"=",
"j_O",
"+",
"j_X",
"a... | Figure out total-intensity emission and absorption coefficients for the
current parameters.
**Argument**
*depth0* (default None)
A first guess to use for a good integration depth, in cm. If None,
the most recent value is used.
**Return value**
A tuple ``(j... | [
"Figure",
"out",
"total",
"-",
"intensity",
"emission",
"and",
"absorption",
"coefficients",
"for",
"the",
"current",
"parameters",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/fk10.py#L808-L835 |
45,375 | pkgw/pwkit | pwkit/io.py | make_path_func | def make_path_func (*baseparts):
"""Return a function that joins paths onto some base directory."""
from os.path import join
base = join (*baseparts)
def path_func (*args):
return join (base, *args)
return path_func | python | def make_path_func (*baseparts):
"""Return a function that joins paths onto some base directory."""
from os.path import join
base = join (*baseparts)
def path_func (*args):
return join (base, *args)
return path_func | [
"def",
"make_path_func",
"(",
"*",
"baseparts",
")",
":",
"from",
"os",
".",
"path",
"import",
"join",
"base",
"=",
"join",
"(",
"*",
"baseparts",
")",
"def",
"path_func",
"(",
"*",
"args",
")",
":",
"return",
"join",
"(",
"base",
",",
"*",
"args",
... | Return a function that joins paths onto some base directory. | [
"Return",
"a",
"function",
"that",
"joins",
"paths",
"onto",
"some",
"base",
"directory",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L125-L131 |
45,376 | pkgw/pwkit | pwkit/io.py | djoin | def djoin (*args):
"""'dotless' join, for nicer paths."""
from os.path import join
i = 0
alen = len (args)
while i < alen and (args[i] == '' or args[i] == '.'):
i += 1
if i == alen:
return '.'
return join (*args[i:]) | python | def djoin (*args):
"""'dotless' join, for nicer paths."""
from os.path import join
i = 0
alen = len (args)
while i < alen and (args[i] == '' or args[i] == '.'):
i += 1
if i == alen:
return '.'
return join (*args[i:]) | [
"def",
"djoin",
"(",
"*",
"args",
")",
":",
"from",
"os",
".",
"path",
"import",
"join",
"i",
"=",
"0",
"alen",
"=",
"len",
"(",
"args",
")",
"while",
"i",
"<",
"alen",
"and",
"(",
"args",
"[",
"i",
"]",
"==",
"''",
"or",
"args",
"[",
"i",
... | dotless' join, for nicer paths. | [
"dotless",
"join",
"for",
"nicer",
"paths",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L134-L147 |
45,377 | pkgw/pwkit | pwkit/io.py | ensure_symlink | def ensure_symlink (src, dst):
"""Ensure the existence of a symbolic link pointing to src named dst. Returns
a boolean indicating whether the symlink already existed.
"""
try:
os.symlink (src, dst)
except OSError as e:
if e.errno == 17: # EEXIST
return True
raise... | python | def ensure_symlink (src, dst):
"""Ensure the existence of a symbolic link pointing to src named dst. Returns
a boolean indicating whether the symlink already existed.
"""
try:
os.symlink (src, dst)
except OSError as e:
if e.errno == 17: # EEXIST
return True
raise... | [
"def",
"ensure_symlink",
"(",
"src",
",",
"dst",
")",
":",
"try",
":",
"os",
".",
"symlink",
"(",
"src",
",",
"dst",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"==",
"17",
":",
"# EEXIST",
"return",
"True",
"raise",
"return"... | Ensure the existence of a symbolic link pointing to src named dst. Returns
a boolean indicating whether the symlink already existed. | [
"Ensure",
"the",
"existence",
"of",
"a",
"symbolic",
"link",
"pointing",
"to",
"src",
"named",
"dst",
".",
"Returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"symlink",
"already",
"existed",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L189-L200 |
45,378 | pkgw/pwkit | pwkit/io.py | Path.ensure_dir | def ensure_dir (self, mode=0o777, parents=False):
"""Ensure that this path exists as a directory.
This function calls :meth:`mkdir` on this path, but does not raise an
exception if it already exists. It does raise an exception if this
path exists but is not a directory. If the directory... | python | def ensure_dir (self, mode=0o777, parents=False):
"""Ensure that this path exists as a directory.
This function calls :meth:`mkdir` on this path, but does not raise an
exception if it already exists. It does raise an exception if this
path exists but is not a directory. If the directory... | [
"def",
"ensure_dir",
"(",
"self",
",",
"mode",
"=",
"0o777",
",",
"parents",
"=",
"False",
")",
":",
"if",
"parents",
":",
"p",
"=",
"self",
".",
"parent",
"if",
"p",
"==",
"self",
":",
"return",
"False",
"# can never create root; avoids loop when parents=Tr... | Ensure that this path exists as a directory.
This function calls :meth:`mkdir` on this path, but does not raise an
exception if it already exists. It does raise an exception if this
path exists but is not a directory. If the directory is created,
*mode* is used to set the permissions of... | [
"Ensure",
"that",
"this",
"path",
"exists",
"as",
"a",
"directory",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L402-L437 |
45,379 | pkgw/pwkit | pwkit/io.py | Path.make_tempfile | def make_tempfile (self, want='handle', resolution='try_unlink', suffix='', **kwargs):
"""Get a context manager that creates and cleans up a uniquely-named temporary
file with a name similar to this path.
This function returns a context manager that creates a secure
temporary file with ... | python | def make_tempfile (self, want='handle', resolution='try_unlink', suffix='', **kwargs):
"""Get a context manager that creates and cleans up a uniquely-named temporary
file with a name similar to this path.
This function returns a context manager that creates a secure
temporary file with ... | [
"def",
"make_tempfile",
"(",
"self",
",",
"want",
"=",
"'handle'",
",",
"resolution",
"=",
"'try_unlink'",
",",
"suffix",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"want",
"not",
"in",
"(",
"'handle'",
",",
"'path'",
")",
":",
"raise",
"Val... | Get a context manager that creates and cleans up a uniquely-named temporary
file with a name similar to this path.
This function returns a context manager that creates a secure
temporary file with a path similar to *self*. In particular, if
``str(self)`` is something like ``foo/bar``, t... | [
"Get",
"a",
"context",
"manager",
"that",
"creates",
"and",
"cleans",
"up",
"a",
"uniquely",
"-",
"named",
"temporary",
"file",
"with",
"a",
"name",
"similar",
"to",
"this",
"path",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L516-L574 |
45,380 | pkgw/pwkit | pwkit/io.py | Path.try_unlink | def try_unlink (self):
"""Try to unlink this path. If it doesn't exist, no error is returned. Returns
a boolean indicating whether the path was really unlinked.
"""
try:
self.unlink ()
return True
except OSError as e:
if e.errno == 2:
... | python | def try_unlink (self):
"""Try to unlink this path. If it doesn't exist, no error is returned. Returns
a boolean indicating whether the path was really unlinked.
"""
try:
self.unlink ()
return True
except OSError as e:
if e.errno == 2:
... | [
"def",
"try_unlink",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"unlink",
"(",
")",
"return",
"True",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"==",
"2",
":",
"return",
"False",
"# ENOENT",
"raise"
] | Try to unlink this path. If it doesn't exist, no error is returned. Returns
a boolean indicating whether the path was really unlinked. | [
"Try",
"to",
"unlink",
"this",
"path",
".",
"If",
"it",
"doesn",
"t",
"exist",
"no",
"error",
"is",
"returned",
".",
"Returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"path",
"was",
"really",
"unlinked",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L645-L656 |
45,381 | pkgw/pwkit | pwkit/io.py | Path.read_pickles | def read_pickles (self):
"""Generate a sequence of objects by opening the path and unpickling items
until EOF is reached.
"""
try:
import cPickle as pickle
except ImportError:
import pickle
with self.open (mode='rb') as f:
while True:... | python | def read_pickles (self):
"""Generate a sequence of objects by opening the path and unpickling items
until EOF is reached.
"""
try:
import cPickle as pickle
except ImportError:
import pickle
with self.open (mode='rb') as f:
while True:... | [
"def",
"read_pickles",
"(",
"self",
")",
":",
"try",
":",
"import",
"cPickle",
"as",
"pickle",
"except",
"ImportError",
":",
"import",
"pickle",
"with",
"self",
".",
"open",
"(",
"mode",
"=",
"'rb'",
")",
"as",
"f",
":",
"while",
"True",
":",
"try",
... | Generate a sequence of objects by opening the path and unpickling items
until EOF is reached. | [
"Generate",
"a",
"sequence",
"of",
"objects",
"by",
"opening",
"the",
"path",
"and",
"unpickling",
"items",
"until",
"EOF",
"is",
"reached",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L923-L939 |
45,382 | pkgw/pwkit | pwkit/io.py | Path.read_text | def read_text(self, encoding=None, errors=None, newline=None):
"""Read this path as one large chunk of text.
This function reads in the entire file as one big piece of text and
returns it. The *encoding*, *errors*, and *newline* keywords are
passed to :meth:`open`.
This is not ... | python | def read_text(self, encoding=None, errors=None, newline=None):
"""Read this path as one large chunk of text.
This function reads in the entire file as one big piece of text and
returns it. The *encoding*, *errors*, and *newline* keywords are
passed to :meth:`open`.
This is not ... | [
"def",
"read_text",
"(",
"self",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
",",
"newline",
"=",
"None",
")",
":",
"with",
"self",
".",
"open",
"(",
"mode",
"=",
"'rt'",
",",
"encoding",
"=",
"encoding",
",",
"errors",
"=",
"errors",
... | Read this path as one large chunk of text.
This function reads in the entire file as one big piece of text and
returns it. The *encoding*, *errors*, and *newline* keywords are
passed to :meth:`open`.
This is not a good way to read files unless you know for sure that they
are sm... | [
"Read",
"this",
"path",
"as",
"one",
"large",
"chunk",
"of",
"text",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L964-L976 |
45,383 | pkgw/pwkit | pwkit/io.py | Path.read_toml | def read_toml(self, encoding=None, errors=None, newline=None, **kwargs):
"""Read this path as a TOML document.
The `TOML <https://github.com/toml-lang/toml>`_ parsing is done with
the :mod:`pytoml` module. The *encoding*, *errors*, and *newline*
keywords are passed to :meth:`open`. The ... | python | def read_toml(self, encoding=None, errors=None, newline=None, **kwargs):
"""Read this path as a TOML document.
The `TOML <https://github.com/toml-lang/toml>`_ parsing is done with
the :mod:`pytoml` module. The *encoding*, *errors*, and *newline*
keywords are passed to :meth:`open`. The ... | [
"def",
"read_toml",
"(",
"self",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
",",
"newline",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"pytoml",
"with",
"self",
".",
"open",
"(",
"mode",
"=",
"'rt'",
",",
"encoding",
"... | Read this path as a TOML document.
The `TOML <https://github.com/toml-lang/toml>`_ parsing is done with
the :mod:`pytoml` module. The *encoding*, *errors*, and *newline*
keywords are passed to :meth:`open`. The remaining *kwargs* are passed
to :meth:`toml.load`.
Returns the dec... | [
"Read",
"this",
"path",
"as",
"a",
"TOML",
"document",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L979-L993 |
45,384 | pkgw/pwkit | pwkit/io.py | Path.read_yaml | def read_yaml (self, encoding=None, errors=None, newline=None, **kwargs):
"""Read this path as a YAML document.
The YAML parsing is done with the :mod:`yaml` module. The *encoding*,
*errors*, and *newline* keywords are passed to :meth:`open`. The
remaining *kwargs* are passed to :meth:`... | python | def read_yaml (self, encoding=None, errors=None, newline=None, **kwargs):
"""Read this path as a YAML document.
The YAML parsing is done with the :mod:`yaml` module. The *encoding*,
*errors*, and *newline* keywords are passed to :meth:`open`. The
remaining *kwargs* are passed to :meth:`... | [
"def",
"read_yaml",
"(",
"self",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
",",
"newline",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"yaml",
"with",
"self",
".",
"open",
"(",
"mode",
"=",
"'rt'",
",",
"encoding",
"="... | Read this path as a YAML document.
The YAML parsing is done with the :mod:`yaml` module. The *encoding*,
*errors*, and *newline* keywords are passed to :meth:`open`. The
remaining *kwargs* are passed to :meth:`yaml.load`.
Returns the decoded data structure. | [
"Read",
"this",
"path",
"as",
"a",
"YAML",
"document",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L996-L1009 |
45,385 | pkgw/pwkit | pwkit/simpleenum.py | enumeration | def enumeration (cls):
"""A very simple decorator for creating enumerations. Unlike Python 3.4
enumerations, this just gives a way to use a class declaration to create
an immutable object containing only the values specified in the class.
If the attribute ``__pickle_compat__`` is set to True in the dec... | python | def enumeration (cls):
"""A very simple decorator for creating enumerations. Unlike Python 3.4
enumerations, this just gives a way to use a class declaration to create
an immutable object containing only the values specified in the class.
If the attribute ``__pickle_compat__`` is set to True in the dec... | [
"def",
"enumeration",
"(",
"cls",
")",
":",
"from",
"pwkit",
"import",
"unicode_to_str",
"name",
"=",
"cls",
".",
"__name__",
"pickle_compat",
"=",
"getattr",
"(",
"cls",
",",
"'__pickle_compat__'",
",",
"False",
")",
"def",
"__unicode__",
"(",
"self",
")",
... | A very simple decorator for creating enumerations. Unlike Python 3.4
enumerations, this just gives a way to use a class declaration to create
an immutable object containing only the values specified in the class.
If the attribute ``__pickle_compat__`` is set to True in the decorated
class, the resultin... | [
"A",
"very",
"simple",
"decorator",
"for",
"creating",
"enumerations",
".",
"Unlike",
"Python",
"3",
".",
"4",
"enumerations",
"this",
"just",
"gives",
"a",
"way",
"to",
"use",
"a",
"class",
"declaration",
"to",
"create",
"an",
"immutable",
"object",
"contai... | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/simpleenum.py#L45-L88 |
45,386 | pkgw/pwkit | pwkit/numutil.py | slice_around_gaps | def slice_around_gaps (values, maxgap):
"""Given an ordered array of values, generate a set of slices that traverse
all of the values. Within each slice, no gap between adjacent values is
larger than `maxgap`. In other words, these slices break the array into
chunks separated by gaps of size larger than... | python | def slice_around_gaps (values, maxgap):
"""Given an ordered array of values, generate a set of slices that traverse
all of the values. Within each slice, no gap between adjacent values is
larger than `maxgap`. In other words, these slices break the array into
chunks separated by gaps of size larger than... | [
"def",
"slice_around_gaps",
"(",
"values",
",",
"maxgap",
")",
":",
"if",
"not",
"(",
"maxgap",
">",
"0",
")",
":",
"# above test catches NaNs, other weird cases",
"raise",
"ValueError",
"(",
"'maxgap must be positive; got %r'",
"%",
"maxgap",
")",
"values",
"=",
... | Given an ordered array of values, generate a set of slices that traverse
all of the values. Within each slice, no gap between adjacent values is
larger than `maxgap`. In other words, these slices break the array into
chunks separated by gaps of size larger than maxgap. | [
"Given",
"an",
"ordered",
"array",
"of",
"values",
"generate",
"a",
"set",
"of",
"slices",
"that",
"traverse",
"all",
"of",
"the",
"values",
".",
"Within",
"each",
"slice",
"no",
"gap",
"between",
"adjacent",
"values",
"is",
"larger",
"than",
"maxgap",
"."... | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/numutil.py#L221-L245 |
45,387 | pkgw/pwkit | pwkit/numutil.py | reduce_data_frame | def reduce_data_frame (df, chunk_slicers,
avg_cols=(),
uavg_cols=(),
minmax_cols=(),
nchunk_colname='nchunk',
uncert_prefix='u',
min_points_per_chunk=3):
""""Reduce" a DataFrame ... | python | def reduce_data_frame (df, chunk_slicers,
avg_cols=(),
uavg_cols=(),
minmax_cols=(),
nchunk_colname='nchunk',
uncert_prefix='u',
min_points_per_chunk=3):
""""Reduce" a DataFrame ... | [
"def",
"reduce_data_frame",
"(",
"df",
",",
"chunk_slicers",
",",
"avg_cols",
"=",
"(",
")",
",",
"uavg_cols",
"=",
"(",
")",
",",
"minmax_cols",
"=",
"(",
")",
",",
"nchunk_colname",
"=",
"'nchunk'",
",",
"uncert_prefix",
"=",
"'u'",
",",
"min_points_per_... | Reduce" a DataFrame by collapsing rows in grouped chunks. Returns another
DataFrame with similar columns but fewer rows.
Arguments:
df
The input :class:`pandas.DataFrame`.
chunk_slicers
An iterable that returns values that are used to slice *df* with its
:meth:`pandas.DataFrame.iloc`... | [
"Reduce",
"a",
"DataFrame",
"by",
"collapsing",
"rows",
"in",
"grouped",
"chunks",
".",
"Returns",
"another",
"DataFrame",
"with",
"similar",
"columns",
"but",
"fewer",
"rows",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/numutil.py#L283-L348 |
45,388 | pkgw/pwkit | pwkit/numutil.py | reduce_data_frame_evenly_with_gaps | def reduce_data_frame_evenly_with_gaps (df, valcol, target_len, maxgap, **kwargs):
""""Reduce" a DataFrame by collapsing rows in grouped chunks, grouping based on
gaps in one of the columns.
This function combines :func:`reduce_data_frame` with
:func:`slice_evenly_with_gaps`.
"""
return reduce... | python | def reduce_data_frame_evenly_with_gaps (df, valcol, target_len, maxgap, **kwargs):
""""Reduce" a DataFrame by collapsing rows in grouped chunks, grouping based on
gaps in one of the columns.
This function combines :func:`reduce_data_frame` with
:func:`slice_evenly_with_gaps`.
"""
return reduce... | [
"def",
"reduce_data_frame_evenly_with_gaps",
"(",
"df",
",",
"valcol",
",",
"target_len",
",",
"maxgap",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"reduce_data_frame",
"(",
"df",
",",
"slice_evenly_with_gaps",
"(",
"df",
"[",
"valcol",
"]",
",",
"target_len... | Reduce" a DataFrame by collapsing rows in grouped chunks, grouping based on
gaps in one of the columns.
This function combines :func:`reduce_data_frame` with
:func:`slice_evenly_with_gaps`. | [
"Reduce",
"a",
"DataFrame",
"by",
"collapsing",
"rows",
"in",
"grouped",
"chunks",
"grouping",
"based",
"on",
"gaps",
"in",
"one",
"of",
"the",
"columns",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/numutil.py#L351-L361 |
45,389 | pkgw/pwkit | pwkit/numutil.py | usmooth | def usmooth (window, uncerts, *data, **kwargs):
"""Smooth data series according to a window, weighting based on uncertainties.
Arguments:
window
The smoothing window.
uncerts
An array of uncertainties used to weight the smoothing.
data
One or more data series, of the same size as... | python | def usmooth (window, uncerts, *data, **kwargs):
"""Smooth data series according to a window, weighting based on uncertainties.
Arguments:
window
The smoothing window.
uncerts
An array of uncertainties used to weight the smoothing.
data
One or more data series, of the same size as... | [
"def",
"usmooth",
"(",
"window",
",",
"uncerts",
",",
"*",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"window",
"=",
"np",
".",
"asarray",
"(",
"window",
")",
"uncerts",
"=",
"np",
".",
"asarray",
"(",
"uncerts",
")",
"# Hacky keyword argument handling b... | Smooth data series according to a window, weighting based on uncertainties.
Arguments:
window
The smoothing window.
uncerts
An array of uncertainties used to weight the smoothing.
data
One or more data series, of the same size as *uncerts*.
k = None
If specified, only every... | [
"Smooth",
"data",
"series",
"according",
"to",
"a",
"window",
"weighting",
"based",
"on",
"uncertainties",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/numutil.py#L366-L420 |
45,390 | pkgw/pwkit | pwkit/numutil.py | weighted_variance | def weighted_variance (x, weights):
"""Return the variance of a weighted sample.
The weighted sample mean is calculated and subtracted off, so the returned
variance is upweighted by ``n / (n - 1)``. If the sample mean is known to
be zero, you should just compute ``np.average (x**2, weights=weights)``.
... | python | def weighted_variance (x, weights):
"""Return the variance of a weighted sample.
The weighted sample mean is calculated and subtracted off, so the returned
variance is upweighted by ``n / (n - 1)``. If the sample mean is known to
be zero, you should just compute ``np.average (x**2, weights=weights)``.
... | [
"def",
"weighted_variance",
"(",
"x",
",",
"weights",
")",
":",
"n",
"=",
"len",
"(",
"x",
")",
"if",
"n",
"<",
"3",
":",
"raise",
"ValueError",
"(",
"'cannot calculate meaningful variance of fewer '",
"'than three samples'",
")",
"wt_mean",
"=",
"np",
".",
... | Return the variance of a weighted sample.
The weighted sample mean is calculated and subtracted off, so the returned
variance is upweighted by ``n / (n - 1)``. If the sample mean is known to
be zero, you should just compute ``np.average (x**2, weights=weights)``. | [
"Return",
"the",
"variance",
"of",
"a",
"weighted",
"sample",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/numutil.py#L674-L687 |
45,391 | pkgw/pwkit | pwkit/numutil.py | unit_tophat_ee | def unit_tophat_ee (x):
"""Tophat function on the unit interval, left-exclusive and right-exclusive.
Returns 1 if 0 < x < 1, 0 otherwise.
"""
x = np.asarray (x)
x1 = np.atleast_1d (x)
r = ((0 < x1) & (x1 < 1)).astype (x.dtype)
if x.ndim == 0:
return np.asscalar (r)
return r | python | def unit_tophat_ee (x):
"""Tophat function on the unit interval, left-exclusive and right-exclusive.
Returns 1 if 0 < x < 1, 0 otherwise.
"""
x = np.asarray (x)
x1 = np.atleast_1d (x)
r = ((0 < x1) & (x1 < 1)).astype (x.dtype)
if x.ndim == 0:
return np.asscalar (r)
return r | [
"def",
"unit_tophat_ee",
"(",
"x",
")",
":",
"x",
"=",
"np",
".",
"asarray",
"(",
"x",
")",
"x1",
"=",
"np",
".",
"atleast_1d",
"(",
"x",
")",
"r",
"=",
"(",
"(",
"0",
"<",
"x1",
")",
"&",
"(",
"x1",
"<",
"1",
")",
")",
".",
"astype",
"("... | Tophat function on the unit interval, left-exclusive and right-exclusive.
Returns 1 if 0 < x < 1, 0 otherwise. | [
"Tophat",
"function",
"on",
"the",
"unit",
"interval",
"left",
"-",
"exclusive",
"and",
"right",
"-",
"exclusive",
".",
"Returns",
"1",
"if",
"0",
"<",
"x",
"<",
"1",
"0",
"otherwise",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/numutil.py#L698-L708 |
45,392 | pkgw/pwkit | pwkit/numutil.py | make_tophat_ee | def make_tophat_ee (lower, upper):
"""Return a ufunc-like tophat function on the defined range, left-exclusive
and right-exclusive. Returns 1 if lower < x < upper, 0 otherwise.
"""
if not np.isfinite (lower):
raise ValueError ('"lower" argument must be finite number; got %r' % lower)
if not... | python | def make_tophat_ee (lower, upper):
"""Return a ufunc-like tophat function on the defined range, left-exclusive
and right-exclusive. Returns 1 if lower < x < upper, 0 otherwise.
"""
if not np.isfinite (lower):
raise ValueError ('"lower" argument must be finite number; got %r' % lower)
if not... | [
"def",
"make_tophat_ee",
"(",
"lower",
",",
"upper",
")",
":",
"if",
"not",
"np",
".",
"isfinite",
"(",
"lower",
")",
":",
"raise",
"ValueError",
"(",
"'\"lower\" argument must be finite number; got %r'",
"%",
"lower",
")",
"if",
"not",
"np",
".",
"isfinite",
... | Return a ufunc-like tophat function on the defined range, left-exclusive
and right-exclusive. Returns 1 if lower < x < upper, 0 otherwise. | [
"Return",
"a",
"ufunc",
"-",
"like",
"tophat",
"function",
"on",
"the",
"defined",
"range",
"left",
"-",
"exclusive",
"and",
"right",
"-",
"exclusive",
".",
"Returns",
"1",
"if",
"lower",
"<",
"x",
"<",
"upper",
"0",
"otherwise",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/numutil.py#L750-L771 |
45,393 | pkgw/pwkit | pwkit/numutil.py | make_tophat_ei | def make_tophat_ei (lower, upper):
"""Return a ufunc-like tophat function on the defined range, left-exclusive
and right-inclusive. Returns 1 if lower < x <= upper, 0 otherwise.
"""
if not np.isfinite (lower):
raise ValueError ('"lower" argument must be finite number; got %r' % lower)
if no... | python | def make_tophat_ei (lower, upper):
"""Return a ufunc-like tophat function on the defined range, left-exclusive
and right-inclusive. Returns 1 if lower < x <= upper, 0 otherwise.
"""
if not np.isfinite (lower):
raise ValueError ('"lower" argument must be finite number; got %r' % lower)
if no... | [
"def",
"make_tophat_ei",
"(",
"lower",
",",
"upper",
")",
":",
"if",
"not",
"np",
".",
"isfinite",
"(",
"lower",
")",
":",
"raise",
"ValueError",
"(",
"'\"lower\" argument must be finite number; got %r'",
"%",
"lower",
")",
"if",
"not",
"np",
".",
"isfinite",
... | Return a ufunc-like tophat function on the defined range, left-exclusive
and right-inclusive. Returns 1 if lower < x <= upper, 0 otherwise. | [
"Return",
"a",
"ufunc",
"-",
"like",
"tophat",
"function",
"on",
"the",
"defined",
"range",
"left",
"-",
"exclusive",
"and",
"right",
"-",
"inclusive",
".",
"Returns",
"1",
"if",
"lower",
"<",
"x",
"<",
"=",
"upper",
"0",
"otherwise",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/numutil.py#L774-L795 |
45,394 | pkgw/pwkit | pwkit/numutil.py | make_tophat_ie | def make_tophat_ie (lower, upper):
"""Return a ufunc-like tophat function on the defined range, left-inclusive
and right-exclusive. Returns 1 if lower <= x < upper, 0 otherwise.
"""
if not np.isfinite (lower):
raise ValueError ('"lower" argument must be finite number; got %r' % lower)
if no... | python | def make_tophat_ie (lower, upper):
"""Return a ufunc-like tophat function on the defined range, left-inclusive
and right-exclusive. Returns 1 if lower <= x < upper, 0 otherwise.
"""
if not np.isfinite (lower):
raise ValueError ('"lower" argument must be finite number; got %r' % lower)
if no... | [
"def",
"make_tophat_ie",
"(",
"lower",
",",
"upper",
")",
":",
"if",
"not",
"np",
".",
"isfinite",
"(",
"lower",
")",
":",
"raise",
"ValueError",
"(",
"'\"lower\" argument must be finite number; got %r'",
"%",
"lower",
")",
"if",
"not",
"np",
".",
"isfinite",
... | Return a ufunc-like tophat function on the defined range, left-inclusive
and right-exclusive. Returns 1 if lower <= x < upper, 0 otherwise. | [
"Return",
"a",
"ufunc",
"-",
"like",
"tophat",
"function",
"on",
"the",
"defined",
"range",
"left",
"-",
"inclusive",
"and",
"right",
"-",
"exclusive",
".",
"Returns",
"1",
"if",
"lower",
"<",
"=",
"x",
"<",
"upper",
"0",
"otherwise",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/numutil.py#L798-L819 |
45,395 | pkgw/pwkit | pwkit/numutil.py | make_tophat_ii | def make_tophat_ii (lower, upper):
"""Return a ufunc-like tophat function on the defined range, left-inclusive
and right-inclusive. Returns 1 if lower < x < upper, 0 otherwise.
"""
if not np.isfinite (lower):
raise ValueError ('"lower" argument must be finite number; got %r' % lower)
if not... | python | def make_tophat_ii (lower, upper):
"""Return a ufunc-like tophat function on the defined range, left-inclusive
and right-inclusive. Returns 1 if lower < x < upper, 0 otherwise.
"""
if not np.isfinite (lower):
raise ValueError ('"lower" argument must be finite number; got %r' % lower)
if not... | [
"def",
"make_tophat_ii",
"(",
"lower",
",",
"upper",
")",
":",
"if",
"not",
"np",
".",
"isfinite",
"(",
"lower",
")",
":",
"raise",
"ValueError",
"(",
"'\"lower\" argument must be finite number; got %r'",
"%",
"lower",
")",
"if",
"not",
"np",
".",
"isfinite",
... | Return a ufunc-like tophat function on the defined range, left-inclusive
and right-inclusive. Returns 1 if lower < x < upper, 0 otherwise. | [
"Return",
"a",
"ufunc",
"-",
"like",
"tophat",
"function",
"on",
"the",
"defined",
"range",
"left",
"-",
"inclusive",
"and",
"right",
"-",
"inclusive",
".",
"Returns",
"1",
"if",
"lower",
"<",
"x",
"<",
"upper",
"0",
"otherwise",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/numutil.py#L822-L843 |
45,396 | pkgw/pwkit | pwkit/numutil.py | make_step_lcont | def make_step_lcont (transition):
"""Return a ufunc-like step function that is left-continuous. Returns 1 if
x > transition, 0 otherwise.
"""
if not np.isfinite (transition):
raise ValueError ('"transition" argument must be finite number; got %r' % transition)
def step_lcont (x):
x... | python | def make_step_lcont (transition):
"""Return a ufunc-like step function that is left-continuous. Returns 1 if
x > transition, 0 otherwise.
"""
if not np.isfinite (transition):
raise ValueError ('"transition" argument must be finite number; got %r' % transition)
def step_lcont (x):
x... | [
"def",
"make_step_lcont",
"(",
"transition",
")",
":",
"if",
"not",
"np",
".",
"isfinite",
"(",
"transition",
")",
":",
"raise",
"ValueError",
"(",
"'\"transition\" argument must be finite number; got %r'",
"%",
"transition",
")",
"def",
"step_lcont",
"(",
"x",
")... | Return a ufunc-like step function that is left-continuous. Returns 1 if
x > transition, 0 otherwise. | [
"Return",
"a",
"ufunc",
"-",
"like",
"step",
"function",
"that",
"is",
"left",
"-",
"continuous",
".",
"Returns",
"1",
"if",
"x",
">",
"transition",
"0",
"otherwise",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/numutil.py#L848-L866 |
45,397 | pkgw/pwkit | pwkit/numutil.py | make_step_rcont | def make_step_rcont (transition):
"""Return a ufunc-like step function that is right-continuous. Returns 1 if
x >= transition, 0 otherwise.
"""
if not np.isfinite (transition):
raise ValueError ('"transition" argument must be finite number; got %r' % transition)
def step_rcont (x):
... | python | def make_step_rcont (transition):
"""Return a ufunc-like step function that is right-continuous. Returns 1 if
x >= transition, 0 otherwise.
"""
if not np.isfinite (transition):
raise ValueError ('"transition" argument must be finite number; got %r' % transition)
def step_rcont (x):
... | [
"def",
"make_step_rcont",
"(",
"transition",
")",
":",
"if",
"not",
"np",
".",
"isfinite",
"(",
"transition",
")",
":",
"raise",
"ValueError",
"(",
"'\"transition\" argument must be finite number; got %r'",
"%",
"transition",
")",
"def",
"step_rcont",
"(",
"x",
")... | Return a ufunc-like step function that is right-continuous. Returns 1 if
x >= transition, 0 otherwise. | [
"Return",
"a",
"ufunc",
"-",
"like",
"step",
"function",
"that",
"is",
"right",
"-",
"continuous",
".",
"Returns",
"1",
"if",
"x",
">",
"=",
"transition",
"0",
"otherwise",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/numutil.py#L869-L887 |
45,398 | pkgw/pwkit | pwkit/sherpa.py | make_fixed_temp_multi_apec | def make_fixed_temp_multi_apec(kTs, name_template='apec%d', norm=None):
"""Create a model summing multiple APEC components at fixed temperatures.
*kTs*
An iterable of temperatures for the components, in keV.
*name_template* = 'apec%d'
A template to use for the names of each component; it is str... | python | def make_fixed_temp_multi_apec(kTs, name_template='apec%d', norm=None):
"""Create a model summing multiple APEC components at fixed temperatures.
*kTs*
An iterable of temperatures for the components, in keV.
*name_template* = 'apec%d'
A template to use for the names of each component; it is str... | [
"def",
"make_fixed_temp_multi_apec",
"(",
"kTs",
",",
"name_template",
"=",
"'apec%d'",
",",
"norm",
"=",
"None",
")",
":",
"total_model",
"=",
"None",
"sub_models",
"=",
"[",
"]",
"for",
"i",
",",
"kT",
"in",
"enumerate",
"(",
"kTs",
")",
":",
"componen... | Create a model summing multiple APEC components at fixed temperatures.
*kTs*
An iterable of temperatures for the components, in keV.
*name_template* = 'apec%d'
A template to use for the names of each component; it is string-formatted
with the 0-based component number as an argument.
*norm... | [
"Create",
"a",
"model",
"summing",
"multiple",
"APEC",
"components",
"at",
"fixed",
"temperatures",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/sherpa.py#L102-L140 |
45,399 | pkgw/pwkit | pwkit/sherpa.py | expand_rmf_matrix | def expand_rmf_matrix(rmf):
"""Expand an RMF matrix stored in compressed form.
*rmf*
An RMF object as might be returned by ``sherpa.astro.ui.get_rmf()``.
Returns:
A non-sparse RMF matrix.
The Response Matrix Function (RMF) of an X-ray telescope like Chandra can
be stored in a sparse fo... | python | def expand_rmf_matrix(rmf):
"""Expand an RMF matrix stored in compressed form.
*rmf*
An RMF object as might be returned by ``sherpa.astro.ui.get_rmf()``.
Returns:
A non-sparse RMF matrix.
The Response Matrix Function (RMF) of an X-ray telescope like Chandra can
be stored in a sparse fo... | [
"def",
"expand_rmf_matrix",
"(",
"rmf",
")",
":",
"n_chan",
"=",
"rmf",
".",
"e_min",
".",
"size",
"n_energy",
"=",
"rmf",
".",
"n_grp",
".",
"size",
"expanded",
"=",
"np",
".",
"zeros",
"(",
"(",
"n_energy",
",",
"n_chan",
")",
")",
"mtx_ofs",
"=",
... | Expand an RMF matrix stored in compressed form.
*rmf*
An RMF object as might be returned by ``sherpa.astro.ui.get_rmf()``.
Returns:
A non-sparse RMF matrix.
The Response Matrix Function (RMF) of an X-ray telescope like Chandra can
be stored in a sparse format as defined in `OGIP Calibratio... | [
"Expand",
"an",
"RMF",
"matrix",
"stored",
"in",
"compressed",
"form",
"."
] | d40957a1c3d2ea34e7ceac2267ee9635135f2793 | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/sherpa.py#L143-L175 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.