partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | SingletonManager.get_queryset | Return the first preferences object for the current site.
If preferences do not exist create it. | preferences/managers.py | def get_queryset(self):
"""
Return the first preferences object for the current site.
If preferences do not exist create it.
"""
queryset = super(SingletonManager, self).get_queryset()
# Get current site
current_site = None
if getattr(settings, 'SITE_ID'... | def get_queryset(self):
"""
Return the first preferences object for the current site.
If preferences do not exist create it.
"""
queryset = super(SingletonManager, self).get_queryset()
# Get current site
current_site = None
if getattr(settings, 'SITE_ID'... | [
"Return",
"the",
"first",
"preferences",
"object",
"for",
"the",
"current",
"site",
".",
"If",
"preferences",
"do",
"not",
"exist",
"create",
"it",
"."
] | praekelt/django-preferences | python | https://github.com/praekelt/django-preferences/blob/724f23da45449e96feb5179cb34e3d380cf151a1/preferences/managers.py#L10-L33 | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"queryset",
"=",
"super",
"(",
"SingletonManager",
",",
"self",
")",
".",
"get_queryset",
"(",
")",
"# Get current site",
"current_site",
"=",
"None",
"if",
"getattr",
"(",
"settings",
",",
"'SITE_ID'",
",",
"Non... | 724f23da45449e96feb5179cb34e3d380cf151a1 |
train | Encoder.load_iterable | Load an ``iterable``.
By default it returns a generator of data loaded via the
:meth:`loads` method.
:param iterable: an iterable over data to load.
:param session: Optional :class:`stdnet.odm.Session`.
:return: an iterable over decoded data. | stdnet/utils/encoders.py | def load_iterable(self, iterable, session=None):
'''Load an ``iterable``.
By default it returns a generator of data loaded via the
:meth:`loads` method.
:param iterable: an iterable over data to load.
:param session: Optional :class:`stdnet.odm.Session`.
:return: an ite... | def load_iterable(self, iterable, session=None):
'''Load an ``iterable``.
By default it returns a generator of data loaded via the
:meth:`loads` method.
:param iterable: an iterable over data to load.
:param session: Optional :class:`stdnet.odm.Session`.
:return: an ite... | [
"Load",
"an",
"iterable",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/encoders.py#L67-L81 | [
"def",
"load_iterable",
"(",
"self",
",",
"iterable",
",",
"session",
"=",
"None",
")",
":",
"data",
"=",
"[",
"]",
"load",
"=",
"self",
".",
"loads",
"for",
"v",
"in",
"iterable",
":",
"data",
".",
"append",
"(",
"load",
"(",
"v",
")",
")",
"ret... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | SearchEngine.search_model | Implements :meth:`stdnet.odm.SearchEngine.search_model`.
It return a new :class:`stdnet.odm.QueryElem` instance from
the input :class:`Query` and the *text* to search. | stdnet/apps/searchengine/__init__.py | def search_model(self, q, text, lookup=None):
'''Implements :meth:`stdnet.odm.SearchEngine.search_model`.
It return a new :class:`stdnet.odm.QueryElem` instance from
the input :class:`Query` and the *text* to search.'''
words = self.words_from_text(text, for_search=True)
if not words:
... | def search_model(self, q, text, lookup=None):
'''Implements :meth:`stdnet.odm.SearchEngine.search_model`.
It return a new :class:`stdnet.odm.QueryElem` instance from
the input :class:`Query` and the *text* to search.'''
words = self.words_from_text(text, for_search=True)
if not words:
... | [
"Implements",
":",
"meth",
":",
"stdnet",
".",
"odm",
".",
"SearchEngine",
".",
"search_model",
".",
"It",
"return",
"a",
"new",
":",
"class",
":",
"stdnet",
".",
"odm",
".",
"QueryElem",
"instance",
"from",
"the",
"input",
":",
"class",
":",
"Query",
... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/__init__.py#L164-L173 | [
"def",
"search_model",
"(",
"self",
",",
"q",
",",
"text",
",",
"lookup",
"=",
"None",
")",
":",
"words",
"=",
"self",
".",
"words_from_text",
"(",
"text",
",",
"for_search",
"=",
"True",
")",
"if",
"not",
"words",
":",
"return",
"q",
"qs",
"=",
"s... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | SearchEngine._search | Full text search. Return a list of queries to intersect. | stdnet/apps/searchengine/__init__.py | def _search(self, words, include=None, exclude=None, lookup=None):
'''Full text search. Return a list of queries to intersect.'''
lookup = lookup or 'contains'
query = self.router.worditem.query()
if include:
query = query.filter(model_type__in=include)
if exclu... | def _search(self, words, include=None, exclude=None, lookup=None):
'''Full text search. Return a list of queries to intersect.'''
lookup = lookup or 'contains'
query = self.router.worditem.query()
if include:
query = query.filter(model_type__in=include)
if exclu... | [
"Full",
"text",
"search",
".",
"Return",
"a",
"list",
"of",
"queries",
"to",
"intersect",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/__init__.py#L207-L227 | [
"def",
"_search",
"(",
"self",
",",
"words",
",",
"include",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"lookup",
"=",
"None",
")",
":",
"lookup",
"=",
"lookup",
"or",
"'contains'",
"query",
"=",
"self",
".",
"router",
".",
"worditem",
".",
"quer... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | redis_client | Get a new redis client.
:param address: a ``host``, ``port`` tuple.
:param connection_pool: optional connection pool.
:param timeout: socket timeout.
:param timeout: socket timeout. | stdnet/backends/redisb/client/__init__.py | def redis_client(address=None, connection_pool=None, timeout=None,
parser=None, **kwargs):
'''Get a new redis client.
:param address: a ``host``, ``port`` tuple.
:param connection_pool: optional connection pool.
:param timeout: socket timeout.
:param timeout: socket timeout.
''... | def redis_client(address=None, connection_pool=None, timeout=None,
parser=None, **kwargs):
'''Get a new redis client.
:param address: a ``host``, ``port`` tuple.
:param connection_pool: optional connection pool.
:param timeout: socket timeout.
:param timeout: socket timeout.
''... | [
"Get",
"a",
"new",
"redis",
"client",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/__init__.py#L16-L35 | [
"def",
"redis_client",
"(",
"address",
"=",
"None",
",",
"connection_pool",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"parser",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"connection_pool",
":",
"if",
"timeout",
"==",
"0",
":",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | to_bytes | Returns a bytestring version of 's',
encoded as specified in 'encoding'. | stdnet/utils/py2py3.py | def to_bytes(s, encoding=None, errors='strict'):
"""Returns a bytestring version of 's',
encoded as specified in 'encoding'."""
encoding = encoding or 'utf-8'
if isinstance(s, bytes):
if encoding != 'utf-8':
return s.decode('utf-8', errors).encode(encoding, errors)
else:
... | def to_bytes(s, encoding=None, errors='strict'):
"""Returns a bytestring version of 's',
encoded as specified in 'encoding'."""
encoding = encoding or 'utf-8'
if isinstance(s, bytes):
if encoding != 'utf-8':
return s.decode('utf-8', errors).encode(encoding, errors)
else:
... | [
"Returns",
"a",
"bytestring",
"version",
"of",
"s",
"encoded",
"as",
"specified",
"in",
"encoding",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/py2py3.py#L80-L91 | [
"def",
"to_bytes",
"(",
"s",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
")",
":",
"encoding",
"=",
"encoding",
"or",
"'utf-8'",
"if",
"isinstance",
"(",
"s",
",",
"bytes",
")",
":",
"if",
"encoding",
"!=",
"'utf-8'",
":",
"return",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | to_string | Inverse of to_bytes | stdnet/utils/py2py3.py | def to_string(s, encoding=None, errors='strict'):
"""Inverse of to_bytes"""
encoding = encoding or 'utf-8'
if isinstance(s, bytes):
return s.decode(encoding, errors)
if not is_string(s):
s = string_type(s)
return s | def to_string(s, encoding=None, errors='strict'):
"""Inverse of to_bytes"""
encoding = encoding or 'utf-8'
if isinstance(s, bytes):
return s.decode(encoding, errors)
if not is_string(s):
s = string_type(s)
return s | [
"Inverse",
"of",
"to_bytes"
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/py2py3.py#L94-L101 | [
"def",
"to_string",
"(",
"s",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
")",
":",
"encoding",
"=",
"encoding",
"or",
"'utf-8'",
"if",
"isinstance",
"(",
"s",
",",
"bytes",
")",
":",
"return",
"s",
".",
"decode",
"(",
"encoding",
"... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | date_decimal_hook | The default JSON decoder hook. It is the inverse of
:class:`stdnet.utils.jsontools.JSONDateDecimalEncoder`. | stdnet/utils/jsontools.py | def date_decimal_hook(dct):
'''The default JSON decoder hook. It is the inverse of
:class:`stdnet.utils.jsontools.JSONDateDecimalEncoder`.'''
if '__datetime__' in dct:
return todatetime(dct['__datetime__'])
elif '__date__' in dct:
return todatetime(dct['__date__']).date()
elif '__decimal... | def date_decimal_hook(dct):
'''The default JSON decoder hook. It is the inverse of
:class:`stdnet.utils.jsontools.JSONDateDecimalEncoder`.'''
if '__datetime__' in dct:
return todatetime(dct['__datetime__'])
elif '__date__' in dct:
return todatetime(dct['__date__']).date()
elif '__decimal... | [
"The",
"default",
"JSON",
"decoder",
"hook",
".",
"It",
"is",
"the",
"inverse",
"of",
":",
"class",
":",
"stdnet",
".",
"utils",
".",
"jsontools",
".",
"JSONDateDecimalEncoder",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L81-L91 | [
"def",
"date_decimal_hook",
"(",
"dct",
")",
":",
"if",
"'__datetime__'",
"in",
"dct",
":",
"return",
"todatetime",
"(",
"dct",
"[",
"'__datetime__'",
"]",
")",
"elif",
"'__date__'",
"in",
"dct",
":",
"return",
"todatetime",
"(",
"dct",
"[",
"'__date__'",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | flat_to_nested | Convert a flat representation of a dictionary to
a nested representation. Fields in the flat representation are separated
by the *splitter* parameters.
:parameter data: a flat dictionary of key value pairs.
:parameter instance: optional instance of a model.
:parameter attribute: optional attribute of a model.
:paramet... | stdnet/utils/jsontools.py | def flat_to_nested(data, instance=None, attname=None,
separator=None, loads=None):
'''Convert a flat representation of a dictionary to
a nested representation. Fields in the flat representation are separated
by the *splitter* parameters.
:parameter data: a flat dictionary of key value pairs.
:pa... | def flat_to_nested(data, instance=None, attname=None,
separator=None, loads=None):
'''Convert a flat representation of a dictionary to
a nested representation. Fields in the flat representation are separated
by the *splitter* parameters.
:parameter data: a flat dictionary of key value pairs.
:pa... | [
"Convert",
"a",
"flat",
"representation",
"of",
"a",
"dictionary",
"to",
"a",
"nested",
"representation",
".",
"Fields",
"in",
"the",
"flat",
"representation",
"are",
"separated",
"by",
"the",
"*",
"splitter",
"*",
"parameters",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L98-L154 | [
"def",
"flat_to_nested",
"(",
"data",
",",
"instance",
"=",
"None",
",",
"attname",
"=",
"None",
",",
"separator",
"=",
"None",
",",
"loads",
"=",
"None",
")",
":",
"separator",
"=",
"separator",
"or",
"JSPLITTER",
"val",
"=",
"{",
"}",
"flat_vals",
"=... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | dict_flat_generator | Convert a nested dictionary into a flat dictionary representation | stdnet/utils/jsontools.py | def dict_flat_generator(value, attname=None, splitter=JSPLITTER,
dumps=None, prefix=None, error=ValueError,
recursive=True):
'''Convert a nested dictionary into a flat dictionary representation'''
if not isinstance(value, dict) or not recursive:
if not pre... | def dict_flat_generator(value, attname=None, splitter=JSPLITTER,
dumps=None, prefix=None, error=ValueError,
recursive=True):
'''Convert a nested dictionary into a flat dictionary representation'''
if not isinstance(value, dict) or not recursive:
if not pre... | [
"Convert",
"a",
"nested",
"dictionary",
"into",
"a",
"flat",
"dictionary",
"representation"
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L157-L178 | [
"def",
"dict_flat_generator",
"(",
"value",
",",
"attname",
"=",
"None",
",",
"splitter",
"=",
"JSPLITTER",
",",
"dumps",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"error",
"=",
"ValueError",
",",
"recursive",
"=",
"True",
")",
":",
"if",
"not",
"i... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | addmul_number_dicts | Multiply dictionaries by a numeric values and add them together.
:parameter series: a tuple of two elements tuples. Each serie is of the form::
(weight,dictionary)
where ``weight`` is a number and ``dictionary`` is a dictionary with
numeric values.
:parameter skip: optional list of field names to ski... | stdnet/utils/jsontools.py | def addmul_number_dicts(series):
'''Multiply dictionaries by a numeric values and add them together.
:parameter series: a tuple of two elements tuples. Each serie is of the form::
(weight,dictionary)
where ``weight`` is a number and ``dictionary`` is a dictionary with
numeric values.
:parameter s... | def addmul_number_dicts(series):
'''Multiply dictionaries by a numeric values and add them together.
:parameter series: a tuple of two elements tuples. Each serie is of the form::
(weight,dictionary)
where ``weight`` is a number and ``dictionary`` is a dictionary with
numeric values.
:parameter s... | [
"Multiply",
"dictionaries",
"by",
"a",
"numeric",
"values",
"and",
"add",
"them",
"together",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L201-L229 | [
"def",
"addmul_number_dicts",
"(",
"series",
")",
":",
"if",
"not",
"series",
":",
"return",
"vtype",
"=",
"value_type",
"(",
"(",
"s",
"[",
"1",
"]",
"for",
"s",
"in",
"series",
")",
")",
"if",
"vtype",
"==",
"1",
":",
"return",
"sum",
"(",
"(",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Download | Submits a cluster job to the build queue to download all TPFs for a given
campaign.
:param int campaign: The `K2` campaign to run
:param str queue: The name of the queue to submit to. Default `build`
:param str email: The email to send job status notifications to. \
Default `None`
:param... | everest/missions/k2/pbs.py | def Download(campaign=0, queue='build', email=None, walltime=8, **kwargs):
'''
Submits a cluster job to the build queue to download all TPFs for a given
campaign.
:param int campaign: The `K2` campaign to run
:param str queue: The name of the queue to submit to. Default `build`
:param str email... | def Download(campaign=0, queue='build', email=None, walltime=8, **kwargs):
'''
Submits a cluster job to the build queue to download all TPFs for a given
campaign.
:param int campaign: The `K2` campaign to run
:param str queue: The name of the queue to submit to. Default `build`
:param str email... | [
"Submits",
"a",
"cluster",
"job",
"to",
"the",
"build",
"queue",
"to",
"download",
"all",
"TPFs",
"for",
"a",
"given",
"campaign",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L34-L75 | [
"def",
"Download",
"(",
"campaign",
"=",
"0",
",",
"queue",
"=",
"'build'",
",",
"email",
"=",
"None",
",",
"walltime",
"=",
"8",
",",
"*",
"*",
"kwargs",
")",
":",
"# Figure out the subcampaign",
"if",
"type",
"(",
"campaign",
")",
"is",
"int",
":",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | _Download | Download all stars from a given campaign. This is
called from ``missions/k2/download.pbs`` | everest/missions/k2/pbs.py | def _Download(campaign, subcampaign):
'''
Download all stars from a given campaign. This is
called from ``missions/k2/download.pbs``
'''
# Are we doing a subcampaign?
if subcampaign != -1:
campaign = campaign + 0.1 * subcampaign
# Get all star IDs for this campaign
stars = [s[0... | def _Download(campaign, subcampaign):
'''
Download all stars from a given campaign. This is
called from ``missions/k2/download.pbs``
'''
# Are we doing a subcampaign?
if subcampaign != -1:
campaign = campaign + 0.1 * subcampaign
# Get all star IDs for this campaign
stars = [s[0... | [
"Download",
"all",
"stars",
"from",
"a",
"given",
"campaign",
".",
"This",
"is",
"called",
"from",
"missions",
"/",
"k2",
"/",
"download",
".",
"pbs"
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L78-L111 | [
"def",
"_Download",
"(",
"campaign",
",",
"subcampaign",
")",
":",
"# Are we doing a subcampaign?",
"if",
"subcampaign",
"!=",
"-",
"1",
":",
"campaign",
"=",
"campaign",
"+",
"0.1",
"*",
"subcampaign",
"# Get all star IDs for this campaign",
"stars",
"=",
"[",
"s... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Run | Submits a cluster job to compute and plot data for all targets
in a given campaign.
:param campaign: The K2 campaign number. If this is an :py:class:`int`, \
returns all targets in that campaign. If a :py:class:`float` \
in the form `X.Y`, runs the `Y^th` decile of campaign `X`.
:para... | everest/missions/k2/pbs.py | def Run(campaign=0, EPIC=None, nodes=5, ppn=12, walltime=100,
mpn=None, email=None, queue=None, **kwargs):
'''
Submits a cluster job to compute and plot data for all targets
in a given campaign.
:param campaign: The K2 campaign number. If this is an :py:class:`int`, \
returns all tar... | def Run(campaign=0, EPIC=None, nodes=5, ppn=12, walltime=100,
mpn=None, email=None, queue=None, **kwargs):
'''
Submits a cluster job to compute and plot data for all targets
in a given campaign.
:param campaign: The K2 campaign number. If this is an :py:class:`int`, \
returns all tar... | [
"Submits",
"a",
"cluster",
"job",
"to",
"compute",
"and",
"plot",
"data",
"for",
"all",
"targets",
"in",
"a",
"given",
"campaign",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L114-L198 | [
"def",
"Run",
"(",
"campaign",
"=",
"0",
",",
"EPIC",
"=",
"None",
",",
"nodes",
"=",
"5",
",",
"ppn",
"=",
"12",
",",
"walltime",
"=",
"100",
",",
"mpn",
"=",
"None",
",",
"email",
"=",
"None",
",",
"queue",
"=",
"None",
",",
"*",
"*",
"kwar... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | _Publish | The actual function that publishes a given campaign; this must
be called from ``missions/k2/publish.pbs``. | everest/missions/k2/pbs.py | def _Publish(campaign, subcampaign, strkwargs):
'''
The actual function that publishes a given campaign; this must
be called from ``missions/k2/publish.pbs``.
'''
# Get kwargs from string
kwargs = pickle.loads(strkwargs.replace('%%%', '\n').encode('utf-8'))
# Check the cadence
cadence... | def _Publish(campaign, subcampaign, strkwargs):
'''
The actual function that publishes a given campaign; this must
be called from ``missions/k2/publish.pbs``.
'''
# Get kwargs from string
kwargs = pickle.loads(strkwargs.replace('%%%', '\n').encode('utf-8'))
# Check the cadence
cadence... | [
"The",
"actual",
"function",
"that",
"publishes",
"a",
"given",
"campaign",
";",
"this",
"must",
"be",
"called",
"from",
"missions",
"/",
"k2",
"/",
"publish",
".",
"pbs",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L322-L350 | [
"def",
"_Publish",
"(",
"campaign",
",",
"subcampaign",
",",
"strkwargs",
")",
":",
"# Get kwargs from string",
"kwargs",
"=",
"pickle",
".",
"loads",
"(",
"strkwargs",
".",
"replace",
"(",
"'%%%'",
",",
"'\\n'",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Status | Shows the progress of the de-trending runs for the specified campaign(s). | everest/missions/k2/pbs.py | def Status(season=range(18), model='nPLD', purge=False, injection=False,
cadence='lc', **kwargs):
'''
Shows the progress of the de-trending runs for the specified campaign(s).
'''
# Mission compatibility
campaign = season
# Injection?
if injection:
return InjectionStatu... | def Status(season=range(18), model='nPLD', purge=False, injection=False,
cadence='lc', **kwargs):
'''
Shows the progress of the de-trending runs for the specified campaign(s).
'''
# Mission compatibility
campaign = season
# Injection?
if injection:
return InjectionStatu... | [
"Shows",
"the",
"progress",
"of",
"the",
"de",
"-",
"trending",
"runs",
"for",
"the",
"specified",
"campaign",
"(",
"s",
")",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L353-L468 | [
"def",
"Status",
"(",
"season",
"=",
"range",
"(",
"18",
")",
",",
"model",
"=",
"'nPLD'",
",",
"purge",
"=",
"False",
",",
"injection",
"=",
"False",
",",
"cadence",
"=",
"'lc'",
",",
"*",
"*",
"kwargs",
")",
":",
"# Mission compatibility",
"campaign"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | InjectionStatus | Shows the progress of the injection de-trending runs for
the specified campaign(s). | everest/missions/k2/pbs.py | def InjectionStatus(campaign=range(18), model='nPLD', purge=False,
depths=[0.01, 0.001, 0.0001], **kwargs):
'''
Shows the progress of the injection de-trending runs for
the specified campaign(s).
'''
if not hasattr(campaign, '__len__'):
if type(campaign) is int:
... | def InjectionStatus(campaign=range(18), model='nPLD', purge=False,
depths=[0.01, 0.001, 0.0001], **kwargs):
'''
Shows the progress of the injection de-trending runs for
the specified campaign(s).
'''
if not hasattr(campaign, '__len__'):
if type(campaign) is int:
... | [
"Shows",
"the",
"progress",
"of",
"the",
"injection",
"de",
"-",
"trending",
"runs",
"for",
"the",
"specified",
"campaign",
"(",
"s",
")",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L471-L533 | [
"def",
"InjectionStatus",
"(",
"campaign",
"=",
"range",
"(",
"18",
")",
",",
"model",
"=",
"'nPLD'",
",",
"purge",
"=",
"False",
",",
"depths",
"=",
"[",
"0.01",
",",
"0.001",
",",
"0.0001",
"]",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | EverestModel | A wrapper around an :py:obj:`everest` model for PBS runs. | everest/missions/k2/pbs.py | def EverestModel(ID, model='nPLD', publish=False, csv=False, **kwargs):
'''
A wrapper around an :py:obj:`everest` model for PBS runs.
'''
if model != 'Inject':
from ... import detrender
# HACK: We need to explicitly mask short cadence planets
if kwargs.get('cadence', 'lc') == ... | def EverestModel(ID, model='nPLD', publish=False, csv=False, **kwargs):
'''
A wrapper around an :py:obj:`everest` model for PBS runs.
'''
if model != 'Inject':
from ... import detrender
# HACK: We need to explicitly mask short cadence planets
if kwargs.get('cadence', 'lc') == ... | [
"A",
"wrapper",
"around",
"an",
":",
"py",
":",
"obj",
":",
"everest",
"model",
"for",
"PBS",
"runs",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L536-L570 | [
"def",
"EverestModel",
"(",
"ID",
",",
"model",
"=",
"'nPLD'",
",",
"publish",
"=",
"False",
",",
"csv",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"model",
"!=",
"'Inject'",
":",
"from",
".",
".",
".",
"import",
"detrender",
"# HACK: We ... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | PrimaryHDU | Construct the primary HDU file containing basic header info. | everest/fits.py | def PrimaryHDU(model):
'''
Construct the primary HDU file containing basic header info.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=0)
if 'KEPMAG' not in [c[0] for c in cards]:
cards.append(('KEPMAG', model.mag, 'Kepler magnitude'))
# Add EVEREST info
... | def PrimaryHDU(model):
'''
Construct the primary HDU file containing basic header info.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=0)
if 'KEPMAG' not in [c[0] for c in cards]:
cards.append(('KEPMAG', model.mag, 'Kepler magnitude'))
# Add EVEREST info
... | [
"Construct",
"the",
"primary",
"HDU",
"file",
"containing",
"basic",
"header",
"info",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L35-L60 | [
"def",
"PrimaryHDU",
"(",
"model",
")",
":",
"# Get mission cards",
"cards",
"=",
"model",
".",
"_mission",
".",
"HDUCards",
"(",
"model",
".",
"meta",
",",
"hdu",
"=",
"0",
")",
"if",
"'KEPMAG'",
"not",
"in",
"[",
"c",
"[",
"0",
"]",
"for",
"c",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | LightcurveHDU | Construct the data HDU file containing the arrays and the observing info. | everest/fits.py | def LightcurveHDU(model):
'''
Construct the data HDU file containing the arrays and the observing info.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=1)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* E... | def LightcurveHDU(model):
'''
Construct the data HDU file containing the arrays and the observing info.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=1)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* E... | [
"Construct",
"the",
"data",
"HDU",
"file",
"containing",
"the",
"arrays",
"and",
"the",
"observing",
"info",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L63-L226 | [
"def",
"LightcurveHDU",
"(",
"model",
")",
":",
"# Get mission cards",
"cards",
"=",
"model",
".",
"_mission",
".",
"HDUCards",
"(",
"model",
".",
"meta",
",",
"hdu",
"=",
"1",
")",
"# Add EVEREST info",
"cards",
".",
"append",
"(",
"(",
"'COMMENT'",
",",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | PixelsHDU | Construct the HDU containing the pixel-level light curve. | everest/fits.py | def PixelsHDU(model):
'''
Construct the HDU containing the pixel-level light curve.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=2)
# Add EVEREST info
cards = []
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVERES... | def PixelsHDU(model):
'''
Construct the HDU containing the pixel-level light curve.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=2)
# Add EVEREST info
cards = []
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVERES... | [
"Construct",
"the",
"HDU",
"containing",
"the",
"pixel",
"-",
"level",
"light",
"curve",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L229-L265 | [
"def",
"PixelsHDU",
"(",
"model",
")",
":",
"# Get mission cards",
"cards",
"=",
"model",
".",
"_mission",
".",
"HDUCards",
"(",
"model",
".",
"meta",
",",
"hdu",
"=",
"2",
")",
"# Add EVEREST info",
"cards",
"=",
"[",
"]",
"cards",
".",
"append",
"(",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | ApertureHDU | Construct the HDU containing the aperture used to de-trend. | everest/fits.py | def ApertureHDU(model):
'''
Construct the HDU containing the aperture used to de-trend.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=3)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVEREST INFO ... | def ApertureHDU(model):
'''
Construct the HDU containing the aperture used to de-trend.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=3)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVEREST INFO ... | [
"Construct",
"the",
"HDU",
"containing",
"the",
"aperture",
"used",
"to",
"de",
"-",
"trend",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L268-L292 | [
"def",
"ApertureHDU",
"(",
"model",
")",
":",
"# Get mission cards",
"cards",
"=",
"model",
".",
"_mission",
".",
"HDUCards",
"(",
"model",
".",
"meta",
",",
"hdu",
"=",
"3",
")",
"# Add EVEREST info",
"cards",
".",
"append",
"(",
"(",
"'COMMENT'",
",",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | ImagesHDU | Construct the HDU containing sample postage stamp images of the target. | everest/fits.py | def ImagesHDU(model):
'''
Construct the HDU containing sample postage stamp images of the target.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=4)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVEREST... | def ImagesHDU(model):
'''
Construct the HDU containing sample postage stamp images of the target.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=4)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVEREST... | [
"Construct",
"the",
"HDU",
"containing",
"sample",
"postage",
"stamp",
"images",
"of",
"the",
"target",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L295-L329 | [
"def",
"ImagesHDU",
"(",
"model",
")",
":",
"# Get mission cards",
"cards",
"=",
"model",
".",
"_mission",
".",
"HDUCards",
"(",
"model",
".",
"meta",
",",
"hdu",
"=",
"4",
")",
"# Add EVEREST info",
"cards",
".",
"append",
"(",
"(",
"'COMMENT'",
",",
"'... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | HiResHDU | Construct the HDU containing the hi res image of the target. | everest/fits.py | def HiResHDU(model):
'''
Construct the HDU containing the hi res image of the target.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=5)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVEREST INFO *'... | def HiResHDU(model):
'''
Construct the HDU containing the hi res image of the target.
'''
# Get mission cards
cards = model._mission.HDUCards(model.meta, hdu=5)
# Add EVEREST info
cards.append(('COMMENT', '************************'))
cards.append(('COMMENT', '* EVEREST INFO *'... | [
"Construct",
"the",
"HDU",
"containing",
"the",
"hi",
"res",
"image",
"of",
"the",
"target",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L332-L359 | [
"def",
"HiResHDU",
"(",
"model",
")",
":",
"# Get mission cards",
"cards",
"=",
"model",
".",
"_mission",
".",
"HDUCards",
"(",
"model",
".",
"meta",
",",
"hdu",
"=",
"5",
")",
"# Add EVEREST info",
"cards",
".",
"append",
"(",
"(",
"'COMMENT'",
",",
"'*... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | MakeFITS | Generate a FITS file for a given :py:mod:`everest` run.
:param model: An :py:mod:`everest` model instance | everest/fits.py | def MakeFITS(model, fitsfile=None):
'''
Generate a FITS file for a given :py:mod:`everest` run.
:param model: An :py:mod:`everest` model instance
'''
# Get the fits file name
if fitsfile is None:
outfile = os.path.join(model.dir, model._mission.FITSFile(
model.ID, model.se... | def MakeFITS(model, fitsfile=None):
'''
Generate a FITS file for a given :py:mod:`everest` run.
:param model: An :py:mod:`everest` model instance
'''
# Get the fits file name
if fitsfile is None:
outfile = os.path.join(model.dir, model._mission.FITSFile(
model.ID, model.se... | [
"Generate",
"a",
"FITS",
"file",
"for",
"a",
"given",
":",
"py",
":",
"mod",
":",
"everest",
"run",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/fits.py#L362-L398 | [
"def",
"MakeFITS",
"(",
"model",
",",
"fitsfile",
"=",
"None",
")",
":",
"# Get the fits file name",
"if",
"fitsfile",
"is",
"None",
":",
"outfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"model",
".",
"dir",
",",
"model",
".",
"_mission",
".",
"FIT... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | get_serializer | Retrieve a serializer register as *name*. If the serializer is not
available a ``ValueError`` exception will raise.
A common usage pattern::
qs = MyModel.objects.query().sort_by('id')
s = odm.get_serializer('json')
s.dump(qs) | stdnet/odm/utils.py | def get_serializer(name, **options):
'''Retrieve a serializer register as *name*. If the serializer is not
available a ``ValueError`` exception will raise.
A common usage pattern::
qs = MyModel.objects.query().sort_by('id')
s = odm.get_serializer('json')
s.dump(qs)
'''
if name in _serializ... | def get_serializer(name, **options):
'''Retrieve a serializer register as *name*. If the serializer is not
available a ``ValueError`` exception will raise.
A common usage pattern::
qs = MyModel.objects.query().sort_by('id')
s = odm.get_serializer('json')
s.dump(qs)
'''
if name in _serializ... | [
"Retrieve",
"a",
"serializer",
"register",
"as",
"*",
"name",
"*",
".",
"If",
"the",
"serializer",
"is",
"not",
"available",
"a",
"ValueError",
"exception",
"will",
"raise",
".",
"A",
"common",
"usage",
"pattern",
"::",
"qs",
"=",
"MyModel",
".",
"objects"... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/utils.py#L34-L47 | [
"def",
"get_serializer",
"(",
"name",
",",
"*",
"*",
"options",
")",
":",
"if",
"name",
"in",
"_serializers",
":",
"serializer",
"=",
"_serializers",
"[",
"name",
"]",
"return",
"serializer",
"(",
"*",
"*",
"options",
")",
"else",
":",
"raise",
"ValueErr... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | register_serializer | \
Register a new serializer to the library.
:parameter name: serializer name (it can override existing serializers).
:parameter serializer: an instance or a derived class of a
:class:`stdnet.odm.Serializer` class or a callable. | stdnet/odm/utils.py | def register_serializer(name, serializer):
'''\
Register a new serializer to the library.
:parameter name: serializer name (it can override existing serializers).
:parameter serializer: an instance or a derived class of a
:class:`stdnet.odm.Serializer` class or a callable.
'''
if not isclass(serial... | def register_serializer(name, serializer):
'''\
Register a new serializer to the library.
:parameter name: serializer name (it can override existing serializers).
:parameter serializer: an instance or a derived class of a
:class:`stdnet.odm.Serializer` class or a callable.
'''
if not isclass(serial... | [
"\\",
"Register",
"a",
"new",
"serializer",
"to",
"the",
"library",
".",
":",
"parameter",
"name",
":",
"serializer",
"name",
"(",
"it",
"can",
"override",
"existing",
"serializers",
")",
".",
":",
"parameter",
"serializer",
":",
"an",
"instance",
"or",
"a... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/utils.py#L50-L60 | [
"def",
"register_serializer",
"(",
"name",
",",
"serializer",
")",
":",
"if",
"not",
"isclass",
"(",
"serializer",
")",
":",
"serializer",
"=",
"serializer",
".",
"__class__",
"_serializers",
"[",
"name",
"]",
"=",
"serializer"
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | MaskSolve | Finds the solution `x` to the linear problem
A x = b
for all contiguous `w`-sized masks applied to
the rows and columns of `A` and to the entries
of `b`.
Returns an array `X` of shape `(N - w + 1, N - w)`,
where the `nth` row is the solution to the equation
A[![n,n+w)]... | everest/masksolve.py | def MaskSolve(A, b, w=5, progress=True, niter=None):
'''
Finds the solution `x` to the linear problem
A x = b
for all contiguous `w`-sized masks applied to
the rows and columns of `A` and to the entries
of `b`.
Returns an array `X` of shape `(N - w + 1, N - w)`,
where t... | def MaskSolve(A, b, w=5, progress=True, niter=None):
'''
Finds the solution `x` to the linear problem
A x = b
for all contiguous `w`-sized masks applied to
the rows and columns of `A` and to the entries
of `b`.
Returns an array `X` of shape `(N - w + 1, N - w)`,
where t... | [
"Finds",
"the",
"solution",
"x",
"to",
"the",
"linear",
"problem",
"A",
"x",
"=",
"b",
"for",
"all",
"contiguous",
"w",
"-",
"sized",
"masks",
"applied",
"to",
"the",
"rows",
"and",
"columns",
"of",
"A",
"and",
"to",
"the",
"entries",
"of",
"b",
".",... | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/masksolve.py#L25-L102 | [
"def",
"MaskSolve",
"(",
"A",
",",
"b",
",",
"w",
"=",
"5",
",",
"progress",
"=",
"True",
",",
"niter",
"=",
"None",
")",
":",
"# Ensure we have choldate installed\r",
"if",
"cholupdate",
"is",
"None",
":",
"log",
".",
"info",
"(",
"\"Running the slow vers... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | MaskSolveSlow | Identical to `MaskSolve`, but computes the solution
the brute-force way. | everest/masksolve.py | def MaskSolveSlow(A, b, w=5, progress=True, niter=None):
'''
Identical to `MaskSolve`, but computes the solution
the brute-force way.
'''
# Number of data points
N = b.shape[0]
# How many iterations? Default is to go through
# the entire dataset
if niter is None:
... | def MaskSolveSlow(A, b, w=5, progress=True, niter=None):
'''
Identical to `MaskSolve`, but computes the solution
the brute-force way.
'''
# Number of data points
N = b.shape[0]
# How many iterations? Default is to go through
# the entire dataset
if niter is None:
... | [
"Identical",
"to",
"MaskSolve",
"but",
"computes",
"the",
"solution",
"the",
"brute",
"-",
"force",
"way",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/masksolve.py#L105-L132 | [
"def",
"MaskSolveSlow",
"(",
"A",
",",
"b",
",",
"w",
"=",
"5",
",",
"progress",
"=",
"True",
",",
"niter",
"=",
"None",
")",
":",
"# Number of data points\r",
"N",
"=",
"b",
".",
"shape",
"[",
"0",
"]",
"# How many iterations? Default is to go through\r",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Overfitting.unmasked | Return the unmasked overfitting metric for a given transit depth. | everest/basecamp.py | def unmasked(self, depth=0.01):
"""Return the unmasked overfitting metric for a given transit depth."""
return 1 - (np.hstack(self._O2) +
np.hstack(self._O3) / depth) / np.hstack(self._O1) | def unmasked(self, depth=0.01):
"""Return the unmasked overfitting metric for a given transit depth."""
return 1 - (np.hstack(self._O2) +
np.hstack(self._O3) / depth) / np.hstack(self._O1) | [
"Return",
"the",
"unmasked",
"overfitting",
"metric",
"for",
"a",
"given",
"transit",
"depth",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L52-L55 | [
"def",
"unmasked",
"(",
"self",
",",
"depth",
"=",
"0.01",
")",
":",
"return",
"1",
"-",
"(",
"np",
".",
"hstack",
"(",
"self",
".",
"_O2",
")",
"+",
"np",
".",
"hstack",
"(",
"self",
".",
"_O3",
")",
"/",
"depth",
")",
"/",
"np",
".",
"hstac... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Overfitting.show | Show the overfitting PDF summary. | everest/basecamp.py | def show(self):
"""Show the overfitting PDF summary."""
try:
if platform.system().lower().startswith('darwin'):
subprocess.call(['open', self.pdf])
elif os.name == 'nt':
os.startfile(self.pdf)
elif os.name == 'posix':
su... | def show(self):
"""Show the overfitting PDF summary."""
try:
if platform.system().lower().startswith('darwin'):
subprocess.call(['open', self.pdf])
elif os.name == 'nt':
os.startfile(self.pdf)
elif os.name == 'posix':
su... | [
"Show",
"the",
"overfitting",
"PDF",
"summary",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L57-L70 | [
"def",
"show",
"(",
"self",
")",
":",
"try",
":",
"if",
"platform",
".",
"system",
"(",
")",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'darwin'",
")",
":",
"subprocess",
".",
"call",
"(",
"[",
"'open'",
",",
"self",
".",
"pdf",
"]",
")",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.season | Return the current observing season.
For *K2*, this is the observing campaign, while for *Kepler*,
it is the current quarter. | everest/basecamp.py | def season(self):
"""
Return the current observing season.
For *K2*, this is the observing campaign, while for *Kepler*,
it is the current quarter.
"""
try:
self._season
except AttributeError:
self._season = self._mission.Season(self.ID)
... | def season(self):
"""
Return the current observing season.
For *K2*, this is the observing campaign, while for *Kepler*,
it is the current quarter.
"""
try:
self._season
except AttributeError:
self._season = self._mission.Season(self.ID)
... | [
"Return",
"the",
"current",
"observing",
"season",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L129-L145 | [
"def",
"season",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_season",
"except",
"AttributeError",
":",
"self",
".",
"_season",
"=",
"self",
".",
"_mission",
".",
"Season",
"(",
"self",
".",
"ID",
")",
"if",
"hasattr",
"(",
"self",
".",
"_season... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.fcor | The CBV-corrected de-trended flux. | everest/basecamp.py | def fcor(self):
'''
The CBV-corrected de-trended flux.
'''
if self.XCBV is None:
return None
else:
return self.flux - self._mission.FitCBVs(self) | def fcor(self):
'''
The CBV-corrected de-trended flux.
'''
if self.XCBV is None:
return None
else:
return self.flux - self._mission.FitCBVs(self) | [
"The",
"CBV",
"-",
"corrected",
"de",
"-",
"trended",
"flux",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L174-L183 | [
"def",
"fcor",
"(",
"self",
")",
":",
"if",
"self",
".",
"XCBV",
"is",
"None",
":",
"return",
"None",
"else",
":",
"return",
"self",
".",
"flux",
"-",
"self",
".",
"_mission",
".",
"FitCBVs",
"(",
"self",
")"
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.mask | The array of indices to be masked. This is the union of the sets of
outliers, bad (flagged) cadences, transit cadences, and :py:obj:`NaN`
cadences. | everest/basecamp.py | def mask(self):
'''
The array of indices to be masked. This is the union of the sets of
outliers, bad (flagged) cadences, transit cadences, and :py:obj:`NaN`
cadences.
'''
return np.array(list(set(np.concatenate([self.outmask, self.badmask,
self.... | def mask(self):
'''
The array of indices to be masked. This is the union of the sets of
outliers, bad (flagged) cadences, transit cadences, and :py:obj:`NaN`
cadences.
'''
return np.array(list(set(np.concatenate([self.outmask, self.badmask,
self.... | [
"The",
"array",
"of",
"indices",
"to",
"be",
"masked",
".",
"This",
"is",
"the",
"union",
"of",
"the",
"sets",
"of",
"outliers",
"bad",
"(",
"flagged",
")",
"cadences",
"transit",
"cadences",
"and",
":",
"py",
":",
"obj",
":",
"NaN",
"cadences",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L232-L241 | [
"def",
"mask",
"(",
"self",
")",
":",
"return",
"np",
".",
"array",
"(",
"list",
"(",
"set",
"(",
"np",
".",
"concatenate",
"(",
"[",
"self",
".",
"outmask",
",",
"self",
".",
"badmask",
",",
"self",
".",
"transitmask",
",",
"self",
".",
"nanmask",... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.X | Computes the design matrix at the given *PLD* order and the given
indices. The columns are the *PLD* vectors for the target at the
corresponding order, computed as the product of the fractional pixel
flux of all sets of :py:obj:`n` pixels, where :py:obj:`n` is the *PLD*
order. | everest/basecamp.py | def X(self, i, j=slice(None, None, None)):
'''
Computes the design matrix at the given *PLD* order and the given
indices. The columns are the *PLD* vectors for the target at the
corresponding order, computed as the product of the fractional pixel
flux of all sets of :py:obj:`n` p... | def X(self, i, j=slice(None, None, None)):
'''
Computes the design matrix at the given *PLD* order and the given
indices. The columns are the *PLD* vectors for the target at the
corresponding order, computed as the product of the fractional pixel
flux of all sets of :py:obj:`n` p... | [
"Computes",
"the",
"design",
"matrix",
"at",
"the",
"given",
"*",
"PLD",
"*",
"order",
"and",
"the",
"given",
"indices",
".",
"The",
"columns",
"are",
"the",
"*",
"PLD",
"*",
"vectors",
"for",
"the",
"target",
"at",
"the",
"corresponding",
"order",
"comp... | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L312-L327 | [
"def",
"X",
"(",
"self",
",",
"i",
",",
"j",
"=",
"slice",
"(",
"None",
",",
"None",
",",
"None",
")",
")",
":",
"X1",
"=",
"self",
".",
"fpix",
"[",
"j",
"]",
"/",
"self",
".",
"norm",
"[",
"j",
"]",
".",
"reshape",
"(",
"-",
"1",
",",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.plot_info | Plots miscellaneous de-trending information on the data
validation summary figure.
:param dvs: A :py:class:`dvs.DVS` figure instance | everest/basecamp.py | def plot_info(self, dvs):
'''
Plots miscellaneous de-trending information on the data
validation summary figure.
:param dvs: A :py:class:`dvs.DVS` figure instance
'''
axl, axc, axr = dvs.title()
axc.annotate("%s %d" % (self._mission.IDSTRING, self.ID),
... | def plot_info(self, dvs):
'''
Plots miscellaneous de-trending information on the data
validation summary figure.
:param dvs: A :py:class:`dvs.DVS` figure instance
'''
axl, axc, axr = dvs.title()
axc.annotate("%s %d" % (self._mission.IDSTRING, self.ID),
... | [
"Plots",
"miscellaneous",
"de",
"-",
"trending",
"information",
"on",
"the",
"data",
"validation",
"summary",
"figure",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L329-L372 | [
"def",
"plot_info",
"(",
"self",
",",
"dvs",
")",
":",
"axl",
",",
"axc",
",",
"axr",
"=",
"dvs",
".",
"title",
"(",
")",
"axc",
".",
"annotate",
"(",
"\"%s %d\"",
"%",
"(",
"self",
".",
"_mission",
".",
"IDSTRING",
",",
"self",
".",
"ID",
")",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.compute | Compute the model for the current value of lambda. | everest/basecamp.py | def compute(self):
'''
Compute the model for the current value of lambda.
'''
# Is there a transit model?
if self.transit_model is not None:
return self.compute_joint()
log.info('Computing the model...')
# Loop over all chunks
model = [None... | def compute(self):
'''
Compute the model for the current value of lambda.
'''
# Is there a transit model?
if self.transit_model is not None:
return self.compute_joint()
log.info('Computing the model...')
# Loop over all chunks
model = [None... | [
"Compute",
"the",
"model",
"for",
"the",
"current",
"value",
"of",
"lambda",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L374-L460 | [
"def",
"compute",
"(",
"self",
")",
":",
"# Is there a transit model?",
"if",
"self",
".",
"transit_model",
"is",
"not",
"None",
":",
"return",
"self",
".",
"compute_joint",
"(",
")",
"log",
".",
"info",
"(",
"'Computing the model...'",
")",
"# Loop over all chu... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.compute_joint | Compute the model in a single step, allowing for a light curve-wide
transit model. This is a bit more expensive to compute. | everest/basecamp.py | def compute_joint(self):
'''
Compute the model in a single step, allowing for a light curve-wide
transit model. This is a bit more expensive to compute.
'''
# Init
log.info('Computing the joint model...')
A = [None for b in self.breakpoints]
B = [None fo... | def compute_joint(self):
'''
Compute the model in a single step, allowing for a light curve-wide
transit model. This is a bit more expensive to compute.
'''
# Init
log.info('Computing the joint model...')
A = [None for b in self.breakpoints]
B = [None fo... | [
"Compute",
"the",
"model",
"in",
"a",
"single",
"step",
"allowing",
"for",
"a",
"light",
"curve",
"-",
"wide",
"transit",
"model",
".",
"This",
"is",
"a",
"bit",
"more",
"expensive",
"to",
"compute",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L462-L585 | [
"def",
"compute_joint",
"(",
"self",
")",
":",
"# Init",
"log",
".",
"info",
"(",
"'Computing the joint model...'",
")",
"A",
"=",
"[",
"None",
"for",
"b",
"in",
"self",
".",
"breakpoints",
"]",
"B",
"=",
"[",
"None",
"for",
"b",
"in",
"self",
".",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.apply_mask | Returns the outlier mask, an array of indices corresponding to the
non-outliers.
:param numpy.ndarray x: If specified, returns the masked version of \
:py:obj:`x` instead. Default :py:obj:`None` | everest/basecamp.py | def apply_mask(self, x=None):
'''
Returns the outlier mask, an array of indices corresponding to the
non-outliers.
:param numpy.ndarray x: If specified, returns the masked version of \
:py:obj:`x` instead. Default :py:obj:`None`
'''
if x is None:
... | def apply_mask(self, x=None):
'''
Returns the outlier mask, an array of indices corresponding to the
non-outliers.
:param numpy.ndarray x: If specified, returns the masked version of \
:py:obj:`x` instead. Default :py:obj:`None`
'''
if x is None:
... | [
"Returns",
"the",
"outlier",
"mask",
"an",
"array",
"of",
"indices",
"corresponding",
"to",
"the",
"non",
"-",
"outliers",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L587-L600 | [
"def",
"apply_mask",
"(",
"self",
",",
"x",
"=",
"None",
")",
":",
"if",
"x",
"is",
"None",
":",
"return",
"np",
".",
"delete",
"(",
"np",
".",
"arange",
"(",
"len",
"(",
"self",
".",
"time",
")",
")",
",",
"self",
".",
"mask",
")",
"else",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.get_chunk | Returns the indices corresponding to a given light curve chunk.
:param int b: The index of the chunk to return
:param numpy.ndarray x: If specified, applies the mask to array \
:py:obj:`x`. Default :py:obj:`None` | everest/basecamp.py | def get_chunk(self, b, x=None, pad=True):
'''
Returns the indices corresponding to a given light curve chunk.
:param int b: The index of the chunk to return
:param numpy.ndarray x: If specified, applies the mask to array \
:py:obj:`x`. Default :py:obj:`None`
'''
... | def get_chunk(self, b, x=None, pad=True):
'''
Returns the indices corresponding to a given light curve chunk.
:param int b: The index of the chunk to return
:param numpy.ndarray x: If specified, applies the mask to array \
:py:obj:`x`. Default :py:obj:`None`
'''
... | [
"Returns",
"the",
"indices",
"corresponding",
"to",
"a",
"given",
"light",
"curve",
"chunk",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L602-L621 | [
"def",
"get_chunk",
"(",
"self",
",",
"b",
",",
"x",
"=",
"None",
",",
"pad",
"=",
"True",
")",
":",
"M",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"self",
".",
"time",
")",
")",
"if",
"b",
">",
"0",
":",
"res",
"=",
"M",
"[",
"(",
"M",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.get_weights | Computes the PLD weights vector :py:obj:`w`.
..warning :: Deprecated and not thoroughly tested. | everest/basecamp.py | def get_weights(self):
'''
Computes the PLD weights vector :py:obj:`w`.
..warning :: Deprecated and not thoroughly tested.
'''
log.info("Computing PLD weights...")
# Loop over all chunks
weights = [None for i in range(len(self.breakpoints))]
for b, brk... | def get_weights(self):
'''
Computes the PLD weights vector :py:obj:`w`.
..warning :: Deprecated and not thoroughly tested.
'''
log.info("Computing PLD weights...")
# Loop over all chunks
weights = [None for i in range(len(self.breakpoints))]
for b, brk... | [
"Computes",
"the",
"PLD",
"weights",
"vector",
":",
"py",
":",
"obj",
":",
"w",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L643-L683 | [
"def",
"get_weights",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Computing PLD weights...\"",
")",
"# Loop over all chunks",
"weights",
"=",
"[",
"None",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"breakpoints",
")",
")",
"]",
"for",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.get_cdpp_arr | Returns the CDPP value in *ppm* for each of the
chunks in the light curve. | everest/basecamp.py | def get_cdpp_arr(self, flux=None):
'''
Returns the CDPP value in *ppm* for each of the
chunks in the light curve.
'''
if flux is None:
flux = self.flux
return np.array([self._mission.CDPP(flux[self.get_masked_chunk(b)],
cadence=self.c... | def get_cdpp_arr(self, flux=None):
'''
Returns the CDPP value in *ppm* for each of the
chunks in the light curve.
'''
if flux is None:
flux = self.flux
return np.array([self._mission.CDPP(flux[self.get_masked_chunk(b)],
cadence=self.c... | [
"Returns",
"the",
"CDPP",
"value",
"in",
"*",
"ppm",
"*",
"for",
"each",
"of",
"the",
"chunks",
"in",
"the",
"light",
"curve",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L685-L696 | [
"def",
"get_cdpp_arr",
"(",
"self",
",",
"flux",
"=",
"None",
")",
":",
"if",
"flux",
"is",
"None",
":",
"flux",
"=",
"self",
".",
"flux",
"return",
"np",
".",
"array",
"(",
"[",
"self",
".",
"_mission",
".",
"CDPP",
"(",
"flux",
"[",
"self",
"."... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.get_cdpp | Returns the scalar CDPP for the light curve. | everest/basecamp.py | def get_cdpp(self, flux=None):
'''
Returns the scalar CDPP for the light curve.
'''
if flux is None:
flux = self.flux
return self._mission.CDPP(self.apply_mask(flux), cadence=self.cadence) | def get_cdpp(self, flux=None):
'''
Returns the scalar CDPP for the light curve.
'''
if flux is None:
flux = self.flux
return self._mission.CDPP(self.apply_mask(flux), cadence=self.cadence) | [
"Returns",
"the",
"scalar",
"CDPP",
"for",
"the",
"light",
"curve",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L698-L706 | [
"def",
"get_cdpp",
"(",
"self",
",",
"flux",
"=",
"None",
")",
":",
"if",
"flux",
"is",
"None",
":",
"flux",
"=",
"self",
".",
"flux",
"return",
"self",
".",
"_mission",
".",
"CDPP",
"(",
"self",
".",
"apply_mask",
"(",
"flux",
")",
",",
"cadence",... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.plot_aperture | Plots the aperture and the pixel images at the beginning, middle,
and end of the time series. Also plots a high resolution image of
the target, if available. | everest/basecamp.py | def plot_aperture(self, axes, labelsize=8):
'''
Plots the aperture and the pixel images at the beginning, middle,
and end of the time series. Also plots a high resolution image of
the target, if available.
'''
log.info('Plotting the aperture...')
# Get colormap... | def plot_aperture(self, axes, labelsize=8):
'''
Plots the aperture and the pixel images at the beginning, middle,
and end of the time series. Also plots a high resolution image of
the target, if available.
'''
log.info('Plotting the aperture...')
# Get colormap... | [
"Plots",
"the",
"aperture",
"and",
"the",
"pixel",
"images",
"at",
"the",
"beginning",
"middle",
"and",
"end",
"of",
"the",
"time",
"series",
".",
"Also",
"plots",
"a",
"high",
"resolution",
"image",
"of",
"the",
"target",
"if",
"available",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L708-L779 | [
"def",
"plot_aperture",
"(",
"self",
",",
"axes",
",",
"labelsize",
"=",
"8",
")",
":",
"log",
".",
"info",
"(",
"'Plotting the aperture...'",
")",
"# Get colormap",
"plasma",
"=",
"pl",
".",
"get_cmap",
"(",
"'plasma'",
")",
"plasma",
".",
"set_bad",
"(",... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.overfit | r"""
Compute the masked & unmasked overfitting metrics for the light curve.
This routine injects a transit model given by `tau` at every cadence
in the light curve and recovers the transit depth when (1) leaving
the transit unmasked and (2) masking the transit prior to performing
... | everest/basecamp.py | def overfit(self, tau=None, plot=True, clobber=False, w=9, **kwargs):
r"""
Compute the masked & unmasked overfitting metrics for the light curve.
This routine injects a transit model given by `tau` at every cadence
in the light curve and recovers the transit depth when (1) leaving
... | def overfit(self, tau=None, plot=True, clobber=False, w=9, **kwargs):
r"""
Compute the masked & unmasked overfitting metrics for the light curve.
This routine injects a transit model given by `tau` at every cadence
in the light curve and recovers the transit depth when (1) leaving
... | [
"r",
"Compute",
"the",
"masked",
"&",
"unmasked",
"overfitting",
"metrics",
"for",
"the",
"light",
"curve",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L814-L1075 | [
"def",
"overfit",
"(",
"self",
",",
"tau",
"=",
"None",
",",
"plot",
"=",
"True",
",",
"clobber",
"=",
"False",
",",
"w",
"=",
"9",
",",
"*",
"*",
"kwargs",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"dir",
",",... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Basecamp.lnlike | r"""
Return the likelihood of the astrophysical model `model`.
Returns the likelihood of `model` marginalized over the PLD model.
:param ndarray model: A vector of the same shape as `self.time` \
corresponding to the astrophysical model.
:param bool refactor: Re-compute ... | everest/basecamp.py | def lnlike(self, model, refactor=False, pos_tol=2.5, neg_tol=50.,
full_output=False):
r"""
Return the likelihood of the astrophysical model `model`.
Returns the likelihood of `model` marginalized over the PLD model.
:param ndarray model: A vector of the same shape as `se... | def lnlike(self, model, refactor=False, pos_tol=2.5, neg_tol=50.,
full_output=False):
r"""
Return the likelihood of the astrophysical model `model`.
Returns the likelihood of `model` marginalized over the PLD model.
:param ndarray model: A vector of the same shape as `se... | [
"r",
"Return",
"the",
"likelihood",
"of",
"the",
"astrophysical",
"model",
"model",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L1077-L1178 | [
"def",
"lnlike",
"(",
"self",
",",
"model",
",",
"refactor",
"=",
"False",
",",
"pos_tol",
"=",
"2.5",
",",
"neg_tol",
"=",
"50.",
",",
"full_output",
"=",
"False",
")",
":",
"lnl",
"=",
"0",
"# Re-factorize the Cholesky decomposition?",
"try",
":",
"self"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Inject | Run one of the :py:obj:`everest` models with injected transits and attempt
to recover the transit depth at the end with a simple linear regression
with a polynomial baseline. The depth is stored in the
:py:obj:`inject` attribute of the model (a dictionary) as
:py:obj:`rec_depth`. A control injection is ... | everest/inject.py | def Inject(ID, inj_model='nPLD', t0=None, per=None, dur=0.1, depth=0.001,
mask=False, trn_win=5, poly_order=3, make_fits=False, **kwargs):
'''
Run one of the :py:obj:`everest` models with injected transits and attempt
to recover the transit depth at the end with a simple linear regression
wit... | def Inject(ID, inj_model='nPLD', t0=None, per=None, dur=0.1, depth=0.001,
mask=False, trn_win=5, poly_order=3, make_fits=False, **kwargs):
'''
Run one of the :py:obj:`everest` models with injected transits and attempt
to recover the transit depth at the end with a simple linear regression
wit... | [
"Run",
"one",
"of",
"the",
":",
"py",
":",
"obj",
":",
"everest",
"models",
"with",
"injected",
"transits",
"and",
"attempt",
"to",
"recover",
"the",
"transit",
"depth",
"at",
"the",
"end",
"with",
"a",
"simple",
"linear",
"regression",
"with",
"a",
"pol... | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/inject.py#L28-L334 | [
"def",
"Inject",
"(",
"ID",
",",
"inj_model",
"=",
"'nPLD'",
",",
"t0",
"=",
"None",
",",
"per",
"=",
"None",
",",
"dur",
"=",
"0.1",
",",
"depth",
"=",
"0.001",
",",
"mask",
"=",
"False",
",",
"trn_win",
"=",
"5",
",",
"poly_order",
"=",
"3",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | WordItem.object | Instance of :attr:`model_type` with id :attr:`object_id`. | stdnet/apps/searchengine/models.py | def object(self, session):
'''Instance of :attr:`model_type` with id :attr:`object_id`.'''
if not hasattr(self, '_object'):
pkname = self.model_type._meta.pkname()
query = session.query(self.model_type).filter(**{pkname:
... | def object(self, session):
'''Instance of :attr:`model_type` with id :attr:`object_id`.'''
if not hasattr(self, '_object'):
pkname = self.model_type._meta.pkname()
query = session.query(self.model_type).filter(**{pkname:
... | [
"Instance",
"of",
":",
"attr",
":",
"model_type",
"with",
"id",
":",
"attr",
":",
"object_id",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/models.py#L36-L44 | [
"def",
"object",
"(",
"self",
",",
"session",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_object'",
")",
":",
"pkname",
"=",
"self",
".",
"model_type",
".",
"_meta",
".",
"pkname",
"(",
")",
"query",
"=",
"session",
".",
"query",
"(",
"s... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | GetData | Returns a :py:obj:`DataContainer` instance with the raw data for the target.
:param int ID: The target ID number
:param int season: The observing season. Default :py:obj:`None`
:param str cadence: The light curve cadence. Default `lc`
:param bool clobber: Overwrite existing files? Default :py:obj:`False`
:... | everest/missions/tess/tess.py | def GetData(ID, season = None, cadence = 'lc', clobber = False, delete_raw = False,
aperture_name = None, saturated_aperture_name = None,
max_pixels = None, download_only = False, saturation_tolerance = None,
bad_bits = None, **kwargs):
'''
Returns a :py:obj:`DataContainer` ins... | def GetData(ID, season = None, cadence = 'lc', clobber = False, delete_raw = False,
aperture_name = None, saturated_aperture_name = None,
max_pixels = None, download_only = False, saturation_tolerance = None,
bad_bits = None, **kwargs):
'''
Returns a :py:obj:`DataContainer` ins... | [
"Returns",
"a",
":",
"py",
":",
"obj",
":",
"DataContainer",
"instance",
"with",
"the",
"raw",
"data",
"for",
"the",
"target",
".",
":",
"param",
"int",
"ID",
":",
"The",
"target",
"ID",
"number",
":",
"param",
"int",
"season",
":",
"The",
"observing",... | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/tess/tess.py#L65-L90 | [
"def",
"GetData",
"(",
"ID",
",",
"season",
"=",
"None",
",",
"cadence",
"=",
"'lc'",
",",
"clobber",
"=",
"False",
",",
"delete_raw",
"=",
"False",
",",
"aperture_name",
"=",
"None",
",",
"saturated_aperture_name",
"=",
"None",
",",
"max_pixels",
"=",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | GetNeighbors | Return `neighbors` random bright stars on the same module as `EPIC`.
:param int ID: The target ID number
:param str model: The :py:obj:`everest` model name. Only used when imposing CDPP bounds. Default :py:obj:`None`
:param int neighbors: Number of neighbors to return. Default None
:param str aperture_name: ... | everest/missions/tess/tess.py | def GetNeighbors(ID, model = None, neighbors = None, mag_range = None,
cdpp_range = None, aperture_name = None,
cadence = 'lc', **kwargs):
'''
Return `neighbors` random bright stars on the same module as `EPIC`.
:param int ID: The target ID number
:param str model: The :py... | def GetNeighbors(ID, model = None, neighbors = None, mag_range = None,
cdpp_range = None, aperture_name = None,
cadence = 'lc', **kwargs):
'''
Return `neighbors` random bright stars on the same module as `EPIC`.
:param int ID: The target ID number
:param str model: The :py... | [
"Return",
"neighbors",
"random",
"bright",
"stars",
"on",
"the",
"same",
"module",
"as",
"EPIC",
".",
":",
"param",
"int",
"ID",
":",
"The",
"target",
"ID",
"number",
":",
"param",
"str",
"model",
":",
"The",
":",
"py",
":",
"obj",
":",
"everest",
"m... | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/tess/tess.py#L92-L109 | [
"def",
"GetNeighbors",
"(",
"ID",
",",
"model",
"=",
"None",
",",
"neighbors",
"=",
"None",
",",
"mag_range",
"=",
"None",
",",
"cdpp_range",
"=",
"None",
",",
"aperture_name",
"=",
"None",
",",
"cadence",
"=",
"'lc'",
",",
"*",
"*",
"kwargs",
")",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | get | Returns the `time` and `flux` for a given EPIC `ID` and
a given `pipeline` name. | everest/missions/k2/pipelines.py | def get(ID, pipeline='everest2', campaign=None):
'''
Returns the `time` and `flux` for a given EPIC `ID` and
a given `pipeline` name.
'''
log.info('Downloading %s light curve for %d...' % (pipeline, ID))
# Dev version hack
if EVEREST_DEV:
if pipeline.lower() == 'everest2' or pipel... | def get(ID, pipeline='everest2', campaign=None):
'''
Returns the `time` and `flux` for a given EPIC `ID` and
a given `pipeline` name.
'''
log.info('Downloading %s light curve for %d...' % (pipeline, ID))
# Dev version hack
if EVEREST_DEV:
if pipeline.lower() == 'everest2' or pipel... | [
"Returns",
"the",
"time",
"and",
"flux",
"for",
"a",
"given",
"EPIC",
"ID",
"and",
"a",
"given",
"pipeline",
"name",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pipelines.py#L39-L88 | [
"def",
"get",
"(",
"ID",
",",
"pipeline",
"=",
"'everest2'",
",",
"campaign",
"=",
"None",
")",
":",
"log",
".",
"info",
"(",
"'Downloading %s light curve for %d...'",
"%",
"(",
"pipeline",
",",
"ID",
")",
")",
"# Dev version hack",
"if",
"EVEREST_DEV",
":",... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | plot | Plots the de-trended flux for the given EPIC `ID` and for
the specified `pipeline`. | everest/missions/k2/pipelines.py | def plot(ID, pipeline='everest2', show=True, campaign=None):
'''
Plots the de-trended flux for the given EPIC `ID` and for
the specified `pipeline`.
'''
# Get the data
time, flux = get(ID, pipeline=pipeline, campaign=campaign)
# Remove nans
mask = np.where(np.isnan(flux))[0]
time ... | def plot(ID, pipeline='everest2', show=True, campaign=None):
'''
Plots the de-trended flux for the given EPIC `ID` and for
the specified `pipeline`.
'''
# Get the data
time, flux = get(ID, pipeline=pipeline, campaign=campaign)
# Remove nans
mask = np.where(np.isnan(flux))[0]
time ... | [
"Plots",
"the",
"de",
"-",
"trended",
"flux",
"for",
"the",
"given",
"EPIC",
"ID",
"and",
"for",
"the",
"specified",
"pipeline",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pipelines.py#L91-L134 | [
"def",
"plot",
"(",
"ID",
",",
"pipeline",
"=",
"'everest2'",
",",
"show",
"=",
"True",
",",
"campaign",
"=",
"None",
")",
":",
"# Get the data",
"time",
",",
"flux",
"=",
"get",
"(",
"ID",
",",
"pipeline",
"=",
"pipeline",
",",
"campaign",
"=",
"cam... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | get_cdpp | Computes the CDPP for a given `campaign` and a given `pipeline`.
Stores the results in a file under "/missions/k2/tables/". | everest/missions/k2/pipelines.py | def get_cdpp(campaign, pipeline='everest2'):
'''
Computes the CDPP for a given `campaign` and a given `pipeline`.
Stores the results in a file under "/missions/k2/tables/".
'''
# Imports
from .k2 import CDPP
from .utils import GetK2Campaign
# Check pipeline
assert pipeline.lower()... | def get_cdpp(campaign, pipeline='everest2'):
'''
Computes the CDPP for a given `campaign` and a given `pipeline`.
Stores the results in a file under "/missions/k2/tables/".
'''
# Imports
from .k2 import CDPP
from .utils import GetK2Campaign
# Check pipeline
assert pipeline.lower()... | [
"Computes",
"the",
"CDPP",
"for",
"a",
"given",
"campaign",
"and",
"a",
"given",
"pipeline",
".",
"Stores",
"the",
"results",
"in",
"a",
"file",
"under",
"/",
"missions",
"/",
"k2",
"/",
"tables",
"/",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pipelines.py#L137-L193 | [
"def",
"get_cdpp",
"(",
"campaign",
",",
"pipeline",
"=",
"'everest2'",
")",
":",
"# Imports",
"from",
".",
"k2",
"import",
"CDPP",
"from",
".",
"utils",
"import",
"GetK2Campaign",
"# Check pipeline",
"assert",
"pipeline",
".",
"lower",
"(",
")",
"in",
"Pipe... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | get_outliers | Computes the number of outliers for a given `campaign`
and a given `pipeline`.
Stores the results in a file under "/missions/k2/tables/".
:param int sigma: The sigma level at which to clip outliers. Default 5 | everest/missions/k2/pipelines.py | def get_outliers(campaign, pipeline='everest2', sigma=5):
'''
Computes the number of outliers for a given `campaign`
and a given `pipeline`.
Stores the results in a file under "/missions/k2/tables/".
:param int sigma: The sigma level at which to clip outliers. Default 5
'''
# Imports
... | def get_outliers(campaign, pipeline='everest2', sigma=5):
'''
Computes the number of outliers for a given `campaign`
and a given `pipeline`.
Stores the results in a file under "/missions/k2/tables/".
:param int sigma: The sigma level at which to clip outliers. Default 5
'''
# Imports
... | [
"Computes",
"the",
"number",
"of",
"outliers",
"for",
"a",
"given",
"campaign",
"and",
"a",
"given",
"pipeline",
".",
"Stores",
"the",
"results",
"in",
"a",
"file",
"under",
"/",
"missions",
"/",
"k2",
"/",
"tables",
"/",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pipelines.py#L196-L308 | [
"def",
"get_outliers",
"(",
"campaign",
",",
"pipeline",
"=",
"'everest2'",
",",
"sigma",
"=",
"5",
")",
":",
"# Imports",
"from",
".",
"utils",
"import",
"GetK2Campaign",
"client",
"=",
"k2plr",
".",
"API",
"(",
")",
"# Check pipeline",
"assert",
"pipeline"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.name | Returns the name of the current :py:class:`Detrender` subclass. | everest/detrender.py | def name(self):
'''
Returns the name of the current :py:class:`Detrender` subclass.
'''
if self.cadence == 'lc':
return self.__class__.__name__
else:
return '%s.sc' % self.__class__.__name__ | def name(self):
'''
Returns the name of the current :py:class:`Detrender` subclass.
'''
if self.cadence == 'lc':
return self.__class__.__name__
else:
return '%s.sc' % self.__class__.__name__ | [
"Returns",
"the",
"name",
"of",
"the",
"current",
":",
"py",
":",
"class",
":",
"Detrender",
"subclass",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L300-L309 | [
"def",
"name",
"(",
"self",
")",
":",
"if",
"self",
".",
"cadence",
"==",
"'lc'",
":",
"return",
"self",
".",
"__class__",
".",
"__name__",
"else",
":",
"return",
"'%s.sc'",
"%",
"self",
".",
"__class__",
".",
"__name__"
] | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.cv_precompute | Pre-compute the matrices :py:obj:`A` and :py:obj:`B`
(cross-validation step only)
for chunk :py:obj:`b`. | everest/detrender.py | def cv_precompute(self, mask, b):
'''
Pre-compute the matrices :py:obj:`A` and :py:obj:`B`
(cross-validation step only)
for chunk :py:obj:`b`.
'''
# Get current chunk and mask outliers
m1 = self.get_masked_chunk(b)
flux = self.fraw[m1]
K = GetCov... | def cv_precompute(self, mask, b):
'''
Pre-compute the matrices :py:obj:`A` and :py:obj:`B`
(cross-validation step only)
for chunk :py:obj:`b`.
'''
# Get current chunk and mask outliers
m1 = self.get_masked_chunk(b)
flux = self.fraw[m1]
K = GetCov... | [
"Pre",
"-",
"compute",
"the",
"matrices",
":",
"py",
":",
"obj",
":",
"A",
"and",
":",
"py",
":",
"obj",
":",
"B",
"(",
"cross",
"-",
"validation",
"step",
"only",
")",
"for",
"chunk",
":",
"py",
":",
"obj",
":",
"b",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L327-L373 | [
"def",
"cv_precompute",
"(",
"self",
",",
"mask",
",",
"b",
")",
":",
"# Get current chunk and mask outliers",
"m1",
"=",
"self",
".",
"get_masked_chunk",
"(",
"b",
")",
"flux",
"=",
"self",
".",
"fraw",
"[",
"m1",
"]",
"K",
"=",
"GetCovariance",
"(",
"s... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.cv_compute | Compute the model (cross-validation step only) for chunk :py:obj:`b`. | everest/detrender.py | def cv_compute(self, b, A, B, C, mK, f, m1, m2):
'''
Compute the model (cross-validation step only) for chunk :py:obj:`b`.
'''
A = np.sum([l * a for l, a in zip(self.lam[b], A)
if l is not None], axis=0)
B = np.sum([l * b for l, b in zip(self.lam[b], B)
... | def cv_compute(self, b, A, B, C, mK, f, m1, m2):
'''
Compute the model (cross-validation step only) for chunk :py:obj:`b`.
'''
A = np.sum([l * a for l, a in zip(self.lam[b], A)
if l is not None], axis=0)
B = np.sum([l * b for l, b in zip(self.lam[b], B)
... | [
"Compute",
"the",
"model",
"(",
"cross",
"-",
"validation",
"step",
"only",
")",
"for",
"chunk",
":",
"py",
":",
"obj",
":",
"b",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L375-L397 | [
"def",
"cv_compute",
"(",
"self",
",",
"b",
",",
"A",
",",
"B",
",",
"C",
",",
"mK",
",",
"f",
",",
"m1",
",",
"m2",
")",
":",
"A",
"=",
"np",
".",
"sum",
"(",
"[",
"l",
"*",
"a",
"for",
"l",
",",
"a",
"in",
"zip",
"(",
"self",
".",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.get_outliers | Performs iterative sigma clipping to get outliers. | everest/detrender.py | def get_outliers(self):
'''
Performs iterative sigma clipping to get outliers.
'''
log.info("Clipping outliers...")
log.info('Iter %d/%d: %d outliers' %
(0, self.oiter, len(self.outmask)))
def M(x): return np.delete(x, np.concatenate(
[self... | def get_outliers(self):
'''
Performs iterative sigma clipping to get outliers.
'''
log.info("Clipping outliers...")
log.info('Iter %d/%d: %d outliers' %
(0, self.oiter, len(self.outmask)))
def M(x): return np.delete(x, np.concatenate(
[self... | [
"Performs",
"iterative",
"sigma",
"clipping",
"to",
"get",
"outliers",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L399-L448 | [
"def",
"get_outliers",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Clipping outliers...\"",
")",
"log",
".",
"info",
"(",
"'Iter %d/%d: %d outliers'",
"%",
"(",
"0",
",",
"self",
".",
"oiter",
",",
"len",
"(",
"self",
".",
"outmask",
")",
")",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.optimize_lambda | Returns the index of :py:attr:`self.lambda_arr` that minimizes the
validation scatter in the segment with minimum at the lowest value
of :py:obj:`lambda`, with
fractional tolerance :py:attr:`self.leps`.
:param numpy.ndarray validation: The scatter in the validation set \
... | everest/detrender.py | def optimize_lambda(self, validation):
'''
Returns the index of :py:attr:`self.lambda_arr` that minimizes the
validation scatter in the segment with minimum at the lowest value
of :py:obj:`lambda`, with
fractional tolerance :py:attr:`self.leps`.
:param numpy.ndarray vali... | def optimize_lambda(self, validation):
'''
Returns the index of :py:attr:`self.lambda_arr` that minimizes the
validation scatter in the segment with minimum at the lowest value
of :py:obj:`lambda`, with
fractional tolerance :py:attr:`self.leps`.
:param numpy.ndarray vali... | [
"Returns",
"the",
"index",
"of",
":",
"py",
":",
"attr",
":",
"self",
".",
"lambda_arr",
"that",
"minimizes",
"the",
"validation",
"scatter",
"in",
"the",
"segment",
"with",
"minimum",
"at",
"the",
"lowest",
"value",
"of",
":",
"py",
":",
"obj",
":",
"... | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L450-L477 | [
"def",
"optimize_lambda",
"(",
"self",
",",
"validation",
")",
":",
"maxm",
"=",
"0",
"minr",
"=",
"len",
"(",
"validation",
")",
"for",
"n",
"in",
"range",
"(",
"validation",
".",
"shape",
"[",
"1",
"]",
")",
":",
"# The index that minimizes the scatter f... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.cross_validate | Cross-validate to find the optimal value of :py:obj:`lambda`.
:param ax: The current :py:obj:`matplotlib.pyplot` axis instance to \
plot the cross-validation results.
:param str info: The label to show in the bottom right-hand corner \
of the plot. Default `''` | everest/detrender.py | def cross_validate(self, ax, info=''):
'''
Cross-validate to find the optimal value of :py:obj:`lambda`.
:param ax: The current :py:obj:`matplotlib.pyplot` axis instance to \
plot the cross-validation results.
:param str info: The label to show in the bottom right-hand co... | def cross_validate(self, ax, info=''):
'''
Cross-validate to find the optimal value of :py:obj:`lambda`.
:param ax: The current :py:obj:`matplotlib.pyplot` axis instance to \
plot the cross-validation results.
:param str info: The label to show in the bottom right-hand co... | [
"Cross",
"-",
"validate",
"to",
"find",
"the",
"optimal",
"value",
"of",
":",
"py",
":",
"obj",
":",
"lambda",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L498-L688 | [
"def",
"cross_validate",
"(",
"self",
",",
"ax",
",",
"info",
"=",
"''",
")",
":",
"# Loop over all chunks",
"ax",
"=",
"np",
".",
"atleast_1d",
"(",
"ax",
")",
"for",
"b",
",",
"brkpt",
"in",
"enumerate",
"(",
"self",
".",
"breakpoints",
")",
":",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.get_ylim | Computes the ideal y-axis limits for the light curve plot. Attempts to
set the limits equal to those of the raw light curve, but if more than
1% of the flux lies either above or below these limits, auto-expands
to include those points. At the end, adds 5% padding to both the
top and the ... | everest/detrender.py | def get_ylim(self):
'''
Computes the ideal y-axis limits for the light curve plot. Attempts to
set the limits equal to those of the raw light curve, but if more than
1% of the flux lies either above or below these limits, auto-expands
to include those points. At the end, adds 5% ... | def get_ylim(self):
'''
Computes the ideal y-axis limits for the light curve plot. Attempts to
set the limits equal to those of the raw light curve, but if more than
1% of the flux lies either above or below these limits, auto-expands
to include those points. At the end, adds 5% ... | [
"Computes",
"the",
"ideal",
"y",
"-",
"axis",
"limits",
"for",
"the",
"light",
"curve",
"plot",
".",
"Attempts",
"to",
"set",
"the",
"limits",
"equal",
"to",
"those",
"of",
"the",
"raw",
"light",
"curve",
"but",
"if",
"more",
"than",
"1%",
"of",
"the",... | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L700-L722 | [
"def",
"get_ylim",
"(",
"self",
")",
":",
"bn",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"set",
"(",
"np",
".",
"concatenate",
"(",
"[",
"self",
".",
"badmask",
",",
"self",
".",
"nanmask",
"]",
")",
")",
")",
",",
"dtype",
"=",
"int",
")",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.plot_lc | Plots the current light curve. This is called at several stages to
plot the de-trending progress as a function of the different
*PLD* orders.
:param ax: The current :py:obj:`matplotlib.pyplot` axis instance
:param str info_left: Information to display at the left of the \
... | everest/detrender.py | def plot_lc(self, ax, info_left='', info_right='', color='b'):
'''
Plots the current light curve. This is called at several stages to
plot the de-trending progress as a function of the different
*PLD* orders.
:param ax: The current :py:obj:`matplotlib.pyplot` axis instance
... | def plot_lc(self, ax, info_left='', info_right='', color='b'):
'''
Plots the current light curve. This is called at several stages to
plot the de-trending progress as a function of the different
*PLD* orders.
:param ax: The current :py:obj:`matplotlib.pyplot` axis instance
... | [
"Plots",
"the",
"current",
"light",
"curve",
".",
"This",
"is",
"called",
"at",
"several",
"stages",
"to",
"plot",
"the",
"de",
"-",
"trending",
"progress",
"as",
"a",
"function",
"of",
"the",
"different",
"*",
"PLD",
"*",
"orders",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L724-L835 | [
"def",
"plot_lc",
"(",
"self",
",",
"ax",
",",
"info_left",
"=",
"''",
",",
"info_right",
"=",
"''",
",",
"color",
"=",
"'b'",
")",
":",
"# Plot",
"if",
"(",
"self",
".",
"cadence",
"==",
"'lc'",
")",
"or",
"(",
"len",
"(",
"self",
".",
"time",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.plot_final | Plots the final de-trended light curve. | everest/detrender.py | def plot_final(self, ax):
'''
Plots the final de-trended light curve.
'''
# Plot the light curve
bnmask = np.array(
list(set(np.concatenate([self.badmask, self.nanmask]))), dtype=int)
def M(x): return np.delete(x, bnmask)
if (self.cadence == 'lc') o... | def plot_final(self, ax):
'''
Plots the final de-trended light curve.
'''
# Plot the light curve
bnmask = np.array(
list(set(np.concatenate([self.badmask, self.nanmask]))), dtype=int)
def M(x): return np.delete(x, bnmask)
if (self.cadence == 'lc') o... | [
"Plots",
"the",
"final",
"de",
"-",
"trended",
"light",
"curve",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L837-L894 | [
"def",
"plot_final",
"(",
"self",
",",
"ax",
")",
":",
"# Plot the light curve",
"bnmask",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"set",
"(",
"np",
".",
"concatenate",
"(",
"[",
"self",
".",
"badmask",
",",
"self",
".",
"nanmask",
"]",
")",
")",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.plot_cbv | Plots the final CBV-corrected light curve. | everest/detrender.py | def plot_cbv(self, ax, flux, info, show_cbv=False):
'''
Plots the final CBV-corrected light curve.
'''
# Plot the light curve
bnmask = np.array(
list(set(np.concatenate([self.badmask, self.nanmask]))), dtype=int)
def M(x): return np.delete(x, bnmask)
... | def plot_cbv(self, ax, flux, info, show_cbv=False):
'''
Plots the final CBV-corrected light curve.
'''
# Plot the light curve
bnmask = np.array(
list(set(np.concatenate([self.badmask, self.nanmask]))), dtype=int)
def M(x): return np.delete(x, bnmask)
... | [
"Plots",
"the",
"final",
"CBV",
"-",
"corrected",
"light",
"curve",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L896-L942 | [
"def",
"plot_cbv",
"(",
"self",
",",
"ax",
",",
"flux",
",",
"info",
",",
"show_cbv",
"=",
"False",
")",
":",
"# Plot the light curve",
"bnmask",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"set",
"(",
"np",
".",
"concatenate",
"(",
"[",
"self",
".",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.load_tpf | Loads the target pixel file. | everest/detrender.py | def load_tpf(self):
'''
Loads the target pixel file.
'''
if not self.loaded:
if self._data is not None:
data = self._data
else:
data = self._mission.GetData(
self.ID, season=self.season,
... | def load_tpf(self):
'''
Loads the target pixel file.
'''
if not self.loaded:
if self._data is not None:
data = self._data
else:
data = self._mission.GetData(
self.ID, season=self.season,
... | [
"Loads",
"the",
"target",
"pixel",
"file",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L944-L997 | [
"def",
"load_tpf",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"loaded",
":",
"if",
"self",
".",
"_data",
"is",
"not",
"None",
":",
"data",
"=",
"self",
".",
"_data",
"else",
":",
"data",
"=",
"self",
".",
"_mission",
".",
"GetData",
"(",
"s... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.load_model | Loads a saved version of the model. | everest/detrender.py | def load_model(self, name=None):
'''
Loads a saved version of the model.
'''
if self.clobber:
return False
if name is None:
name = self.name
file = os.path.join(self.dir, '%s.npz' % name)
if os.path.exists(file):
if not self.... | def load_model(self, name=None):
'''
Loads a saved version of the model.
'''
if self.clobber:
return False
if name is None:
name = self.name
file = os.path.join(self.dir, '%s.npz' % name)
if os.path.exists(file):
if not self.... | [
"Loads",
"a",
"saved",
"version",
"of",
"the",
"model",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L999-L1056 | [
"def",
"load_model",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"self",
".",
"clobber",
":",
"return",
"False",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"self",
".",
"name",
"file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.save_model | Saves all of the de-trending information to disk in an `npz` file
and saves the DVS as a `pdf`. | everest/detrender.py | def save_model(self):
'''
Saves all of the de-trending information to disk in an `npz` file
and saves the DVS as a `pdf`.
'''
# Save the data
log.info("Saving data to '%s.npz'..." % self.name)
d = dict(self.__dict__)
d.pop('_weights', None)
d.pop... | def save_model(self):
'''
Saves all of the de-trending information to disk in an `npz` file
and saves the DVS as a `pdf`.
'''
# Save the data
log.info("Saving data to '%s.npz'..." % self.name)
d = dict(self.__dict__)
d.pop('_weights', None)
d.pop... | [
"Saves",
"all",
"of",
"the",
"de",
"-",
"trending",
"information",
"to",
"disk",
"in",
"an",
"npz",
"file",
"and",
"saves",
"the",
"DVS",
"as",
"a",
"pdf",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1058-L1091 | [
"def",
"save_model",
"(",
"self",
")",
":",
"# Save the data",
"log",
".",
"info",
"(",
"\"Saving data to '%s.npz'...\"",
"%",
"self",
".",
"name",
")",
"d",
"=",
"dict",
"(",
"self",
".",
"__dict__",
")",
"d",
".",
"pop",
"(",
"'_weights'",
",",
"None",... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.exception_handler | A custom exception handler.
:param pdb: If :py:obj:`True`, enters PDB post-mortem \
mode for debugging. | everest/detrender.py | def exception_handler(self, pdb):
'''
A custom exception handler.
:param pdb: If :py:obj:`True`, enters PDB post-mortem \
mode for debugging.
'''
# Grab the exception
exctype, value, tb = sys.exc_info()
# Log the error and create a .err file
... | def exception_handler(self, pdb):
'''
A custom exception handler.
:param pdb: If :py:obj:`True`, enters PDB post-mortem \
mode for debugging.
'''
# Grab the exception
exctype, value, tb = sys.exc_info()
# Log the error and create a .err file
... | [
"A",
"custom",
"exception",
"handler",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1093-L1119 | [
"def",
"exception_handler",
"(",
"self",
",",
"pdb",
")",
":",
"# Grab the exception",
"exctype",
",",
"value",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"# Log the error and create a .err file",
"errfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.update_gp | Calls :py:func:`gp.GetKernelParams` to optimize the GP and obtain the
covariance matrix for the regression. | everest/detrender.py | def update_gp(self):
'''
Calls :py:func:`gp.GetKernelParams` to optimize the GP and obtain the
covariance matrix for the regression.
'''
self.kernel_params = GetKernelParams(self.time, self.flux,
self.fraw_err,
... | def update_gp(self):
'''
Calls :py:func:`gp.GetKernelParams` to optimize the GP and obtain the
covariance matrix for the regression.
'''
self.kernel_params = GetKernelParams(self.time, self.flux,
self.fraw_err,
... | [
"Calls",
":",
"py",
":",
"func",
":",
"gp",
".",
"GetKernelParams",
"to",
"optimize",
"the",
"GP",
"and",
"obtain",
"the",
"covariance",
"matrix",
"for",
"the",
"regression",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1121-L1134 | [
"def",
"update_gp",
"(",
"self",
")",
":",
"self",
".",
"kernel_params",
"=",
"GetKernelParams",
"(",
"self",
".",
"time",
",",
"self",
".",
"flux",
",",
"self",
".",
"fraw_err",
",",
"mask",
"=",
"self",
".",
"mask",
",",
"guess",
"=",
"self",
".",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.init_kernel | Initializes the covariance matrix with a guess at
the GP kernel parameters. | everest/detrender.py | def init_kernel(self):
'''
Initializes the covariance matrix with a guess at
the GP kernel parameters.
'''
if self.kernel_params is None:
X = self.apply_mask(self.fpix / self.flux.reshape(-1, 1))
y = self.apply_mask(self.flux) - np.dot(X, np.linalg.solve... | def init_kernel(self):
'''
Initializes the covariance matrix with a guess at
the GP kernel parameters.
'''
if self.kernel_params is None:
X = self.apply_mask(self.fpix / self.flux.reshape(-1, 1))
y = self.apply_mask(self.flux) - np.dot(X, np.linalg.solve... | [
"Initializes",
"the",
"covariance",
"matrix",
"with",
"a",
"guess",
"at",
"the",
"GP",
"kernel",
"parameters",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1136-L1153 | [
"def",
"init_kernel",
"(",
"self",
")",
":",
"if",
"self",
".",
"kernel_params",
"is",
"None",
":",
"X",
"=",
"self",
".",
"apply_mask",
"(",
"self",
".",
"fpix",
"/",
"self",
".",
"flux",
".",
"reshape",
"(",
"-",
"1",
",",
"1",
")",
")",
"y",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.run | Runs the de-trending step. | everest/detrender.py | def run(self):
'''
Runs the de-trending step.
'''
try:
# Load raw data
log.info("Loading target data...")
self.load_tpf()
self.mask_planets()
self.plot_aperture([self.dvs.top_right() for i in range(4)])
self.init_... | def run(self):
'''
Runs the de-trending step.
'''
try:
# Load raw data
log.info("Loading target data...")
self.load_tpf()
self.mask_planets()
self.plot_aperture([self.dvs.top_right() for i in range(4)])
self.init_... | [
"Runs",
"the",
"de",
"-",
"trending",
"step",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1170-L1219 | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"# Load raw data",
"log",
".",
"info",
"(",
"\"Loading target data...\"",
")",
"self",
".",
"load_tpf",
"(",
")",
"self",
".",
"mask_planets",
"(",
")",
"self",
".",
"plot_aperture",
"(",
"[",
"self",
".",... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | Detrender.publish | Correct the light curve with the CBVs, generate a
cover page for the DVS figure,
and produce a FITS file for publication. | everest/detrender.py | def publish(self, **kwargs):
'''
Correct the light curve with the CBVs, generate a
cover page for the DVS figure,
and produce a FITS file for publication.
'''
try:
# HACK: Force these params for publication
self.cbv_win = 999
self.cb... | def publish(self, **kwargs):
'''
Correct the light curve with the CBVs, generate a
cover page for the DVS figure,
and produce a FITS file for publication.
'''
try:
# HACK: Force these params for publication
self.cbv_win = 999
self.cb... | [
"Correct",
"the",
"light",
"curve",
"with",
"the",
"CBVs",
"generate",
"a",
"cover",
"page",
"for",
"the",
"DVS",
"figure",
"and",
"produce",
"a",
"FITS",
"file",
"for",
"publication",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1221-L1279 | [
"def",
"publish",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"# HACK: Force these params for publication",
"self",
".",
"cbv_win",
"=",
"999",
"self",
".",
"cbv_order",
"=",
"3",
"self",
".",
"cbv_num",
"=",
"1",
"# Get the CBVs",
"self",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | nPLD.setup | This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param tuple cdpp_range: If :py:obj:`parent_model` is set, \
neighbors are selected only if \
their de-trended CDPPs fall within this range. Default `None`
:param t... | everest/detrender.py | def setup(self, **kwargs):
'''
This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param tuple cdpp_range: If :py:obj:`parent_model` is set, \
neighbors are selected only if \
their de-trended CDPPs fall wit... | def setup(self, **kwargs):
'''
This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param tuple cdpp_range: If :py:obj:`parent_model` is set, \
neighbors are selected only if \
their de-trended CDPPs fall wit... | [
"This",
"is",
"called",
"during",
"production",
"de",
"-",
"trending",
"prior",
"to",
"calling",
"the",
":",
"py",
":",
"obj",
":",
"Detrender",
".",
"run",
"()",
"method",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1336-L1458 | [
"def",
"setup",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get neighbors",
"self",
".",
"parent_model",
"=",
"kwargs",
".",
"get",
"(",
"'parent_model'",
",",
"None",
")",
"neighbors",
"=",
"kwargs",
".",
"get",
"(",
"'neighbors'",
",",
"10",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | iPLD.setup | This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param str parent_model: The name of the model to operate on. \
Default `nPLD` | everest/detrender.py | def setup(self, **kwargs):
'''
This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param str parent_model: The name of the model to operate on. \
Default `nPLD`
'''
# Load the parent model
self.pa... | def setup(self, **kwargs):
'''
This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param str parent_model: The name of the model to operate on. \
Default `nPLD`
'''
# Load the parent model
self.pa... | [
"This",
"is",
"called",
"during",
"production",
"de",
"-",
"trending",
"prior",
"to",
"calling",
"the",
":",
"py",
":",
"obj",
":",
"Detrender",
".",
"run",
"()",
"method",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1469-L1505 | [
"def",
"setup",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Load the parent model",
"self",
".",
"parent_model",
"=",
"kwargs",
".",
"get",
"(",
"'parent_model'",
",",
"'nPLD'",
")",
"if",
"not",
"self",
".",
"load_model",
"(",
"self",
".",
"paren... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | pPLD.setup | This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param inter piter: The number of iterations in the minimizer. \
Default 3
:param int pmaxf: The maximum number of function evaluations per \
iteration. Default 300... | everest/detrender.py | def setup(self, **kwargs):
'''
This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param inter piter: The number of iterations in the minimizer. \
Default 3
:param int pmaxf: The maximum number of function evaluati... | def setup(self, **kwargs):
'''
This is called during production de-trending, prior to
calling the :py:obj:`Detrender.run()` method.
:param inter piter: The number of iterations in the minimizer. \
Default 3
:param int pmaxf: The maximum number of function evaluati... | [
"This",
"is",
"called",
"during",
"production",
"de",
"-",
"trending",
"prior",
"to",
"calling",
"the",
":",
"py",
":",
"obj",
":",
"Detrender",
".",
"run",
"()",
"method",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1515-L1539 | [
"def",
"setup",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Check for saved model",
"clobber",
"=",
"self",
".",
"clobber",
"self",
".",
"clobber",
"=",
"False",
"if",
"not",
"self",
".",
"load_model",
"(",
"'nPLD'",
")",
":",
"raise",
"Exception"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | pPLD.run | Runs the de-trending. | everest/detrender.py | def run(self):
'''
Runs the de-trending.
'''
try:
# Plot original
self.plot_aperture([self.dvs.top_right() for i in range(4)])
self.plot_lc(self.dvs.left(), info_right='nPLD', color='k')
# Cross-validate
self.cross_validate(... | def run(self):
'''
Runs the de-trending.
'''
try:
# Plot original
self.plot_aperture([self.dvs.top_right() for i in range(4)])
self.plot_lc(self.dvs.left(), info_right='nPLD', color='k')
# Cross-validate
self.cross_validate(... | [
"Runs",
"the",
"de",
"-",
"trending",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1541-L1569 | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"# Plot original",
"self",
".",
"plot_aperture",
"(",
"[",
"self",
".",
"dvs",
".",
"top_right",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"4",
")",
"]",
")",
"self",
".",
"plot_lc",
"(",
"self",
"... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | pPLD.cross_validate | Performs the cross-validation step. | everest/detrender.py | def cross_validate(self, ax):
'''
Performs the cross-validation step.
'''
# The CDPP to beat
cdpp_opt = self.get_cdpp_arr()
# Loop over all chunks
for b, brkpt in enumerate(self.breakpoints):
log.info("Cross-validating chunk %d/%d..." %
... | def cross_validate(self, ax):
'''
Performs the cross-validation step.
'''
# The CDPP to beat
cdpp_opt = self.get_cdpp_arr()
# Loop over all chunks
for b, brkpt in enumerate(self.breakpoints):
log.info("Cross-validating chunk %d/%d..." %
... | [
"Performs",
"the",
"cross",
"-",
"validation",
"step",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1571-L1676 | [
"def",
"cross_validate",
"(",
"self",
",",
"ax",
")",
":",
"# The CDPP to beat",
"cdpp_opt",
"=",
"self",
".",
"get_cdpp_arr",
"(",
")",
"# Loop over all chunks",
"for",
"b",
",",
"brkpt",
"in",
"enumerate",
"(",
"self",
".",
"breakpoints",
")",
":",
"log",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | pPLD.validation_scatter | Computes the scatter in the validation set. | everest/detrender.py | def validation_scatter(self, log_lam, b, masks, pre_v, gp, flux,
time, med):
'''
Computes the scatter in the validation set.
'''
# Update the lambda matrix
self.lam[b] = 10 ** log_lam
# Validation set scatter
scatter = [None for i in ... | def validation_scatter(self, log_lam, b, masks, pre_v, gp, flux,
time, med):
'''
Computes the scatter in the validation set.
'''
# Update the lambda matrix
self.lam[b] = 10 ** log_lam
# Validation set scatter
scatter = [None for i in ... | [
"Computes",
"the",
"scatter",
"in",
"the",
"validation",
"set",
"."
] | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/detrender.py#L1678-L1703 | [
"def",
"validation_scatter",
"(",
"self",
",",
"log_lam",
",",
"b",
",",
"masks",
",",
"pre_v",
",",
"gp",
",",
"flux",
",",
"time",
",",
"med",
")",
":",
"# Update the lambda matrix",
"self",
".",
"lam",
"[",
"b",
"]",
"=",
"10",
"**",
"log_lam",
"#... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | populate | Utility function for populating lists with random data.
Useful for populating database with data for fuzzy testing.
Supported data-types
* *string*
For example::
populate('string',100, min_len=3, max_len=10)
create a 100 elements list with random strings
with random length between 3 and... | stdnet/utils/populate.py | def populate(datatype='string', size=10, start=None, end=None,
converter=None, choice_from=None, **kwargs):
'''Utility function for populating lists with random data.
Useful for populating database with data for fuzzy testing.
Supported data-types
* *string*
For example::
populat... | def populate(datatype='string', size=10, start=None, end=None,
converter=None, choice_from=None, **kwargs):
'''Utility function for populating lists with random data.
Useful for populating database with data for fuzzy testing.
Supported data-types
* *string*
For example::
populat... | [
"Utility",
"function",
"for",
"populating",
"lists",
"with",
"random",
"data",
".",
"Useful",
"for",
"populating",
"database",
"with",
"data",
"for",
"fuzzy",
"testing",
".",
"Supported",
"data",
"-",
"types",
"*",
"*",
"string",
"*",
"For",
"example",
"::",... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/populate.py#L16-L84 | [
"def",
"populate",
"(",
"datatype",
"=",
"'string'",
",",
"size",
"=",
"10",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"converter",
"=",
"None",
",",
"choice_from",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"[",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Search | NOTE: `pos_tol` is the positive (i.e., above the median)
outlier tolerance in standard deviations.
NOTE: `neg_tol` is the negative (i.e., below the median)
outlier tolerance in standard deviations. | everest/search.py | def Search(star, pos_tol=2.5, neg_tol=50., **ps_kwargs):
'''
NOTE: `pos_tol` is the positive (i.e., above the median)
outlier tolerance in standard deviations.
NOTE: `neg_tol` is the negative (i.e., below the median)
outlier tolerance in standard deviations.
'''
# Smooth the light curve
... | def Search(star, pos_tol=2.5, neg_tol=50., **ps_kwargs):
'''
NOTE: `pos_tol` is the positive (i.e., above the median)
outlier tolerance in standard deviations.
NOTE: `neg_tol` is the negative (i.e., below the median)
outlier tolerance in standard deviations.
'''
# Smooth the light curve
... | [
"NOTE",
":",
"pos_tol",
"is",
"the",
"positive",
"(",
"i",
".",
"e",
".",
"above",
"the",
"median",
")",
"outlier",
"tolerance",
"in",
"standard",
"deviations",
".",
"NOTE",
":",
"neg_tol",
"is",
"the",
"negative",
"(",
"i",
".",
"e",
".",
"below",
"... | rodluger/everest | python | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/search.py#L29-L131 | [
"def",
"Search",
"(",
"star",
",",
"pos_tol",
"=",
"2.5",
",",
"neg_tol",
"=",
"50.",
",",
"*",
"*",
"ps_kwargs",
")",
":",
"# Smooth the light curve",
"t",
"=",
"np",
".",
"delete",
"(",
"star",
".",
"time",
",",
"np",
".",
"concatenate",
"(",
"[",
... | 6779591f9f8b3556847e2fbf761bdfac7520eaea |
train | SessionModel.iterdirty | Ordered iterator over dirty elements. | stdnet/odm/session.py | def iterdirty(self):
'''Ordered iterator over dirty elements.'''
return iter(chain(itervalues(self._new), itervalues(self._modified))) | def iterdirty(self):
'''Ordered iterator over dirty elements.'''
return iter(chain(itervalues(self._new), itervalues(self._modified))) | [
"Ordered",
"iterator",
"over",
"dirty",
"elements",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L108-L110 | [
"def",
"iterdirty",
"(",
"self",
")",
":",
"return",
"iter",
"(",
"chain",
"(",
"itervalues",
"(",
"self",
".",
"_new",
")",
",",
"itervalues",
"(",
"self",
".",
"_modified",
")",
")",
")"
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | SessionModel.add | Add a new instance to this :class:`SessionModel`.
:param modified: Optional flag indicating if the ``instance`` has been
modified. By default its value is ``True``.
:param force_update: if ``instance`` is persistent, it forces an update of the
data rather than a full replacement. This is used by the
... | stdnet/odm/session.py | def add(self, instance, modified=True, persistent=None,
force_update=False):
'''Add a new instance to this :class:`SessionModel`.
:param modified: Optional flag indicating if the ``instance`` has been
modified. By default its value is ``True``.
:param force_update: if ``instance`` is pers... | def add(self, instance, modified=True, persistent=None,
force_update=False):
'''Add a new instance to this :class:`SessionModel`.
:param modified: Optional flag indicating if the ``instance`` has been
modified. By default its value is ``True``.
:param force_update: if ``instance`` is pers... | [
"Add",
"a",
"new",
"instance",
"to",
"this",
":",
"class",
":",
"SessionModel",
".",
":",
"param",
"modified",
":",
"Optional",
"flag",
"indicating",
"if",
"the",
"instance",
"has",
"been",
"modified",
".",
"By",
"default",
"its",
"value",
"is",
"True",
... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L119-L152 | [
"def",
"add",
"(",
"self",
",",
"instance",
",",
"modified",
"=",
"True",
",",
"persistent",
"=",
"None",
",",
"force_update",
"=",
"False",
")",
":",
"if",
"instance",
".",
"_meta",
".",
"type",
"==",
"'structure'",
":",
"return",
"self",
".",
"_add_s... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | SessionModel.delete | delete an *instance* | stdnet/odm/session.py | def delete(self, instance, session):
'''delete an *instance*'''
if instance._meta.type == 'structure':
return self._delete_structure(instance)
inst = self.pop(instance)
instance = inst if inst is not None else instance
if instance is not None:
state... | def delete(self, instance, session):
'''delete an *instance*'''
if instance._meta.type == 'structure':
return self._delete_structure(instance)
inst = self.pop(instance)
instance = inst if inst is not None else instance
if instance is not None:
state... | [
"delete",
"an",
"*",
"instance",
"*"
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L154-L168 | [
"def",
"delete",
"(",
"self",
",",
"instance",
",",
"session",
")",
":",
"if",
"instance",
".",
"_meta",
".",
"type",
"==",
"'structure'",
":",
"return",
"self",
".",
"_delete_structure",
"(",
"instance",
")",
"inst",
"=",
"self",
".",
"pop",
"(",
"ins... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | SessionModel.pop | Remove ``instance`` from the :class:`SessionModel`. Instance
could be a :class:`Model` or an id.
:parameter instance: a :class:`Model` or an ``id``.
:rtype: the :class:`Model` removed from session or ``None`` if
it was not in the session. | stdnet/odm/session.py | def pop(self, instance):
'''Remove ``instance`` from the :class:`SessionModel`. Instance
could be a :class:`Model` or an id.
:parameter instance: a :class:`Model` or an ``id``.
:rtype: the :class:`Model` removed from session or ``None`` if
it was not in the session.
'''
if isinstance(instan... | def pop(self, instance):
'''Remove ``instance`` from the :class:`SessionModel`. Instance
could be a :class:`Model` or an id.
:parameter instance: a :class:`Model` or an ``id``.
:rtype: the :class:`Model` removed from session or ``None`` if
it was not in the session.
'''
if isinstance(instan... | [
"Remove",
"instance",
"from",
"the",
":",
"class",
":",
"SessionModel",
".",
"Instance",
"could",
"be",
"a",
":",
"class",
":",
"Model",
"or",
"an",
"id",
".",
":",
"parameter",
"instance",
":",
"a",
":",
"class",
":",
"Model",
"or",
"an",
"id",
".",... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L170-L190 | [
"def",
"pop",
"(",
"self",
",",
"instance",
")",
":",
"if",
"isinstance",
"(",
"instance",
",",
"self",
".",
"model",
")",
":",
"iid",
"=",
"instance",
".",
"get_state",
"(",
")",
".",
"iid",
"else",
":",
"iid",
"=",
"instance",
"instance",
"=",
"N... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | SessionModel.expunge | Remove *instance* from the :class:`Session`. Instance could be a
:class:`Model` or an id.
:parameter instance: a :class:`Model` or an *id*
:rtype: the :class:`Model` removed from session or ``None`` if
it was not in the session. | stdnet/odm/session.py | def expunge(self, instance):
'''Remove *instance* from the :class:`Session`. Instance could be a
:class:`Model` or an id.
:parameter instance: a :class:`Model` or an *id*
:rtype: the :class:`Model` removed from session or ``None`` if
it was not in the session.
'''
instance = self.pop(instan... | def expunge(self, instance):
'''Remove *instance* from the :class:`Session`. Instance could be a
:class:`Model` or an id.
:parameter instance: a :class:`Model` or an *id*
:rtype: the :class:`Model` removed from session or ``None`` if
it was not in the session.
'''
instance = self.pop(instan... | [
"Remove",
"*",
"instance",
"*",
"from",
"the",
":",
"class",
":",
"Session",
".",
"Instance",
"could",
"be",
"a",
":",
"class",
":",
"Model",
"or",
"an",
"id",
".",
":",
"parameter",
"instance",
":",
"a",
":",
"class",
":",
"Model",
"or",
"an",
"*"... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L192-L202 | [
"def",
"expunge",
"(",
"self",
",",
"instance",
")",
":",
"instance",
"=",
"self",
".",
"pop",
"(",
"instance",
")",
"instance",
".",
"session",
"=",
"None",
"return",
"instance"
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | SessionModel.post_commit | \
Process results after a commit.
:parameter results: iterator over :class:`stdnet.instance_session_result`
items.
:rtype: a two elements tuple containing a list of instances saved and
a list of ids of instances deleted. | stdnet/odm/session.py | def post_commit(self, results):
'''\
Process results after a commit.
:parameter results: iterator over :class:`stdnet.instance_session_result`
items.
:rtype: a two elements tuple containing a list of instances saved and
a list of ids of instances deleted.'''
tpy = self._meta.pk_to_pytho... | def post_commit(self, results):
'''\
Process results after a commit.
:parameter results: iterator over :class:`stdnet.instance_session_result`
items.
:rtype: a two elements tuple containing a list of instances saved and
a list of ids of instances deleted.'''
tpy = self._meta.pk_to_pytho... | [
"\\",
"Process",
"results",
"after",
"a",
"commit",
".",
":",
"parameter",
"results",
":",
"iterator",
"over",
":",
"class",
":",
"stdnet",
".",
"instance_session_result",
"items",
".",
":",
"rtype",
":",
"a",
"two",
"elements",
"tuple",
"containing",
"a",
... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L204-L238 | [
"def",
"post_commit",
"(",
"self",
",",
"results",
")",
":",
"tpy",
"=",
"self",
".",
"_meta",
".",
"pk_to_python",
"instances",
"=",
"[",
"]",
"deleted",
"=",
"[",
"]",
"errors",
"=",
"[",
"]",
"# The length of results must be the same as the length of\r",
"#... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Transaction.commit | Close the transaction and commit session to the backend. | stdnet/odm/session.py | def commit(self, callback=None):
'''Close the transaction and commit session to the backend.'''
if self.executed:
raise InvalidTransaction('Invalid operation. '
'Transaction already executed.')
session = self.session
self.session = N... | def commit(self, callback=None):
'''Close the transaction and commit session to the backend.'''
if self.executed:
raise InvalidTransaction('Invalid operation. '
'Transaction already executed.')
session = self.session
self.session = N... | [
"Close",
"the",
"transaction",
"and",
"commit",
"session",
"to",
"the",
"backend",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L427-L435 | [
"def",
"commit",
"(",
"self",
",",
"callback",
"=",
"None",
")",
":",
"if",
"self",
".",
"executed",
":",
"raise",
"InvalidTransaction",
"(",
"'Invalid operation. '",
"'Transaction already executed.'",
")",
"session",
"=",
"self",
".",
"session",
"self",
".",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Session.dirty | The set of instances in this :class:`Session` which have
been modified. | stdnet/odm/session.py | def dirty(self):
'''The set of instances in this :class:`Session` which have
been modified.'''
return frozenset(chain(*tuple((sm.dirty for sm
in itervalues(self._models))))) | def dirty(self):
'''The set of instances in this :class:`Session` which have
been modified.'''
return frozenset(chain(*tuple((sm.dirty for sm
in itervalues(self._models))))) | [
"The",
"set",
"of",
"instances",
"in",
"this",
":",
"class",
":",
"Session",
"which",
"have",
"been",
"modified",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L547-L551 | [
"def",
"dirty",
"(",
"self",
")",
":",
"return",
"frozenset",
"(",
"chain",
"(",
"*",
"tuple",
"(",
"(",
"sm",
".",
"dirty",
"for",
"sm",
"in",
"itervalues",
"(",
"self",
".",
"_models",
")",
")",
")",
")",
")"
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Session.begin | Begin a new :class:`Transaction`. If this :class:`Session`
is already in a :ref:`transactional state <transactional-state>`,
an error will occur. It returns the :attr:`transaction` attribute.
This method is mostly used within a ``with`` statement block::
with session.begin() as t:
t.add(...)
... | stdnet/odm/session.py | def begin(self, **options):
'''Begin a new :class:`Transaction`. If this :class:`Session`
is already in a :ref:`transactional state <transactional-state>`,
an error will occur. It returns the :attr:`transaction` attribute.
This method is mostly used within a ``with`` statement block::
with session.... | def begin(self, **options):
'''Begin a new :class:`Transaction`. If this :class:`Session`
is already in a :ref:`transactional state <transactional-state>`,
an error will occur. It returns the :attr:`transaction` attribute.
This method is mostly used within a ``with`` statement block::
with session.... | [
"Begin",
"a",
"new",
":",
"class",
":",
"Transaction",
".",
"If",
"this",
":",
"class",
":",
"Session",
"is",
"already",
"in",
"a",
":",
"ref",
":",
"transactional",
"state",
"<transactional",
"-",
"state",
">",
"an",
"error",
"will",
"occur",
".",
"It... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L553-L577 | [
"def",
"begin",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"if",
"self",
".",
"transaction",
"is",
"not",
"None",
":",
"raise",
"InvalidTransaction",
"(",
"\"A transaction is already begun.\"",
")",
"else",
":",
"self",
".",
"transaction",
"=",
"Transa... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Session.query | Create a new :class:`Query` for *model*. | stdnet/odm/session.py | def query(self, model, **kwargs):
'''Create a new :class:`Query` for *model*.'''
sm = self.model(model)
query_class = sm.manager.query_class or Query
return query_class(sm._meta, self, **kwargs) | def query(self, model, **kwargs):
'''Create a new :class:`Query` for *model*.'''
sm = self.model(model)
query_class = sm.manager.query_class or Query
return query_class(sm._meta, self, **kwargs) | [
"Create",
"a",
"new",
":",
"class",
":",
"Query",
"for",
"*",
"model",
"*",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L590-L594 | [
"def",
"query",
"(",
"self",
",",
"model",
",",
"*",
"*",
"kwargs",
")",
":",
"sm",
"=",
"self",
".",
"model",
"(",
"model",
")",
"query_class",
"=",
"sm",
".",
"manager",
".",
"query_class",
"or",
"Query",
"return",
"query_class",
"(",
"sm",
".",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Session.update_or_create | Update or create a new instance of ``model``.
This method can raise an exception if the ``kwargs`` dictionary
contains field data that does not validate.
:param model: a :class:`StdModel`
:param kwargs: dictionary of parameters.
:returns: A two elements tuple containing ... | stdnet/odm/session.py | def update_or_create(self, model, **kwargs):
'''Update or create a new instance of ``model``.
This method can raise an exception if the ``kwargs`` dictionary
contains field data that does not validate.
:param model: a :class:`StdModel`
:param kwargs: dictionary of parame... | def update_or_create(self, model, **kwargs):
'''Update or create a new instance of ``model``.
This method can raise an exception if the ``kwargs`` dictionary
contains field data that does not validate.
:param model: a :class:`StdModel`
:param kwargs: dictionary of parame... | [
"Update",
"or",
"create",
"a",
"new",
"instance",
"of",
"model",
".",
"This",
"method",
"can",
"raise",
"an",
"exception",
"if",
"the",
"kwargs",
"dictionary",
"contains",
"field",
"data",
"that",
"does",
"not",
"validate",
".",
":",
"param",
"model",
":",... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L600-L612 | [
"def",
"update_or_create",
"(",
"self",
",",
"model",
",",
"*",
"*",
"kwargs",
")",
":",
"backend",
"=",
"self",
".",
"model",
"(",
"model",
")",
".",
"backend",
"return",
"backend",
".",
"execute",
"(",
"self",
".",
"_update_or_create",
"(",
"model",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Session.add | Add an ``instance`` to the session.
If the session is not in a
:ref:`transactional state <transactional-state>`, this operation
commits changes to the back-end server immediately.
:parameter instance: a :class:`Model` instance. It must be registered
with the :attr:`r... | stdnet/odm/session.py | def add(self, instance, modified=True, **params):
'''Add an ``instance`` to the session.
If the session is not in a
:ref:`transactional state <transactional-state>`, this operation
commits changes to the back-end server immediately.
:parameter instance: a :class:`Model` ... | def add(self, instance, modified=True, **params):
'''Add an ``instance`` to the session.
If the session is not in a
:ref:`transactional state <transactional-state>`, this operation
commits changes to the back-end server immediately.
:parameter instance: a :class:`Model` ... | [
"Add",
"an",
"instance",
"to",
"the",
"session",
".",
"If",
"the",
"session",
"is",
"not",
"in",
"a",
":",
"ref",
":",
"transactional",
"state",
"<transactional",
"-",
"state",
">",
"this",
"operation",
"commits",
"changes",
"to",
"the",
"back",
"-",
"en... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L614-L638 | [
"def",
"add",
"(",
"self",
",",
"instance",
",",
"modified",
"=",
"True",
",",
"*",
"*",
"params",
")",
":",
"sm",
"=",
"self",
".",
"model",
"(",
"instance",
")",
"instance",
".",
"session",
"=",
"self",
"o",
"=",
"sm",
".",
"add",
"(",
"instanc... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Session.delete | Delete an ``instance`` or a ``query``.
Adds ``instance_or_query`` to this :class:`Session` list
of data to be deleted. If the session is not in a
:ref:`transactional state <transactional-state>`, this operation
commits changes to the backend server immediately.
:paramete... | stdnet/odm/session.py | def delete(self, instance_or_query):
'''Delete an ``instance`` or a ``query``.
Adds ``instance_or_query`` to this :class:`Session` list
of data to be deleted. If the session is not in a
:ref:`transactional state <transactional-state>`, this operation
commits changes to the... | def delete(self, instance_or_query):
'''Delete an ``instance`` or a ``query``.
Adds ``instance_or_query`` to this :class:`Session` list
of data to be deleted. If the session is not in a
:ref:`transactional state <transactional-state>`, this operation
commits changes to the... | [
"Delete",
"an",
"instance",
"or",
"a",
"query",
".",
"Adds",
"instance_or_query",
"to",
"this",
":",
"class",
":",
"Session",
"list",
"of",
"data",
"to",
"be",
"deleted",
".",
"If",
"the",
"session",
"is",
"not",
"in",
"a",
":",
"ref",
":",
"transactio... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L640-L664 | [
"def",
"delete",
"(",
"self",
",",
"instance_or_query",
")",
":",
"sm",
"=",
"self",
".",
"model",
"(",
"instance_or_query",
")",
"# not an instance of a Model. Assume it is a query.\r",
"if",
"is_query",
"(",
"instance_or_query",
")",
":",
"if",
"instance_or_query",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Session.model | Returns the :class:`SessionModel` for ``model`` which
can be :class:`Model`, or a :class:`MetaClass`, or an instance
of :class:`Model`. | stdnet/odm/session.py | def model(self, model, create=True):
'''Returns the :class:`SessionModel` for ``model`` which
can be :class:`Model`, or a :class:`MetaClass`, or an instance
of :class:`Model`.'''
manager = self.manager(model)
sm = self._models.get(manager)
if sm is None and create:
sm ... | def model(self, model, create=True):
'''Returns the :class:`SessionModel` for ``model`` which
can be :class:`Model`, or a :class:`MetaClass`, or an instance
of :class:`Model`.'''
manager = self.manager(model)
sm = self._models.get(manager)
if sm is None and create:
sm ... | [
"Returns",
"the",
":",
"class",
":",
"SessionModel",
"for",
"model",
"which",
"can",
"be",
":",
"class",
":",
"Model",
"or",
"a",
":",
"class",
":",
"MetaClass",
"or",
"an",
"instance",
"of",
":",
"class",
":",
"Model",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L684-L693 | [
"def",
"model",
"(",
"self",
",",
"model",
",",
"create",
"=",
"True",
")",
":",
"manager",
"=",
"self",
".",
"manager",
"(",
"model",
")",
"sm",
"=",
"self",
".",
"_models",
".",
"get",
"(",
"manager",
")",
"if",
"sm",
"is",
"None",
"and",
"crea... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Session.expunge | Remove ``instance`` from this :class:`Session`. If ``instance``
is not given, it removes all instances from this :class:`Session`. | stdnet/odm/session.py | def expunge(self, instance=None):
'''Remove ``instance`` from this :class:`Session`. If ``instance``
is not given, it removes all instances from this :class:`Session`.'''
if instance is not None:
sm = self._models.get(instance._meta)
if sm:
return sm.expunge... | def expunge(self, instance=None):
'''Remove ``instance`` from this :class:`Session`. If ``instance``
is not given, it removes all instances from this :class:`Session`.'''
if instance is not None:
sm = self._models.get(instance._meta)
if sm:
return sm.expunge... | [
"Remove",
"instance",
"from",
"this",
":",
"class",
":",
"Session",
".",
"If",
"instance",
"is",
"not",
"given",
"it",
"removes",
"all",
"instances",
"from",
"this",
":",
"class",
":",
"Session",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L695-L703 | [
"def",
"expunge",
"(",
"self",
",",
"instance",
"=",
"None",
")",
":",
"if",
"instance",
"is",
"not",
"None",
":",
"sm",
"=",
"self",
".",
"_models",
".",
"get",
"(",
"instance",
".",
"_meta",
")",
"if",
"sm",
":",
"return",
"sm",
".",
"expunge",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Session.manager | Retrieve the :class:`Manager` for ``model`` which can be any of the
values valid for the :meth:`model` method. | stdnet/odm/session.py | def manager(self, model):
'''Retrieve the :class:`Manager` for ``model`` which can be any of the
values valid for the :meth:`model` method.'''
try:
return self.router[model]
except KeyError:
meta = getattr(model, '_meta', model)
if meta.type == 'structu... | def manager(self, model):
'''Retrieve the :class:`Manager` for ``model`` which can be any of the
values valid for the :meth:`model` method.'''
try:
return self.router[model]
except KeyError:
meta = getattr(model, '_meta', model)
if meta.type == 'structu... | [
"Retrieve",
"the",
":",
"class",
":",
"Manager",
"for",
"model",
"which",
"can",
"be",
"any",
"of",
"the",
"values",
"valid",
"for",
"the",
":",
"meth",
":",
"model",
"method",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L705-L722 | [
"def",
"manager",
"(",
"self",
",",
"model",
")",
":",
"try",
":",
"return",
"self",
".",
"router",
"[",
"model",
"]",
"except",
"KeyError",
":",
"meta",
"=",
"getattr",
"(",
"model",
",",
"'_meta'",
",",
"model",
")",
"if",
"meta",
".",
"type",
"=... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Manager.new | Create a new instance of :attr:`model` and commit it to the backend
server. This a shortcut method for the more verbose::
instance = manager.session().add(MyModel(**kwargs)) | stdnet/odm/session.py | def new(self, *args, **kwargs):
'''Create a new instance of :attr:`model` and commit it to the backend
server. This a shortcut method for the more verbose::
instance = manager.session().add(MyModel(**kwargs))
'''
return self.session().add(self.model(*args, **kwargs)) | def new(self, *args, **kwargs):
'''Create a new instance of :attr:`model` and commit it to the backend
server. This a shortcut method for the more verbose::
instance = manager.session().add(MyModel(**kwargs))
'''
return self.session().add(self.model(*args, **kwargs)) | [
"Create",
"a",
"new",
"instance",
"of",
":",
"attr",
":",
"model",
"and",
"commit",
"it",
"to",
"the",
"backend",
"server",
".",
"This",
"a",
"shortcut",
"method",
"for",
"the",
"more",
"verbose",
"::",
"instance",
"=",
"manager",
".",
"session",
"()",
... | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L924-L930 | [
"def",
"new",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"session",
"(",
")",
".",
"add",
"(",
"self",
".",
"model",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")"
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Manager.query | Returns a new :class:`Query` for :attr:`Manager.model`. | stdnet/odm/session.py | def query(self, session=None):
'''Returns a new :class:`Query` for :attr:`Manager.model`.'''
if session is None or session.router is not self.router:
session = self.session()
return session.query(self.model) | def query(self, session=None):
'''Returns a new :class:`Query` for :attr:`Manager.model`.'''
if session is None or session.router is not self.router:
session = self.session()
return session.query(self.model) | [
"Returns",
"a",
"new",
":",
"class",
":",
"Query",
"for",
":",
"attr",
":",
"Manager",
".",
"model",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L957-L961 | [
"def",
"query",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"if",
"session",
"is",
"None",
"or",
"session",
".",
"router",
"is",
"not",
"self",
".",
"router",
":",
"session",
"=",
"self",
".",
"session",
"(",
")",
"return",
"session",
".",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | Manager.search | Returns a new :class:`Query` for :attr:`Manager.model` with
a full text search value. | stdnet/odm/session.py | def search(self, text, lookup=None):
'''Returns a new :class:`Query` for :attr:`Manager.model` with
a full text search value.'''
return self.query().search(text, lookup=lookup) | def search(self, text, lookup=None):
'''Returns a new :class:`Query` for :attr:`Manager.model` with
a full text search value.'''
return self.query().search(text, lookup=lookup) | [
"Returns",
"a",
"new",
":",
"class",
":",
"Query",
"for",
":",
"attr",
":",
"Manager",
".",
"model",
"with",
"a",
"full",
"text",
"search",
"value",
"."
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L977-L980 | [
"def",
"search",
"(",
"self",
",",
"text",
",",
"lookup",
"=",
"None",
")",
":",
"return",
"self",
".",
"query",
"(",
")",
".",
"search",
"(",
"text",
",",
"lookup",
"=",
"lookup",
")"
] | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
train | pairs_to_dict | Create a dict given a list of key/value pairs | stdnet/backends/redisb/__init__.py | def pairs_to_dict(response, encoding):
"Create a dict given a list of key/value pairs"
it = iter(response)
return dict(((k.decode(encoding), v) for k, v in zip(it, it))) | def pairs_to_dict(response, encoding):
"Create a dict given a list of key/value pairs"
it = iter(response)
return dict(((k.decode(encoding), v) for k, v in zip(it, it))) | [
"Create",
"a",
"dict",
"given",
"a",
"list",
"of",
"key",
"/",
"value",
"pairs"
] | lsbardel/python-stdnet | python | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/__init__.py#L36-L39 | [
"def",
"pairs_to_dict",
"(",
"response",
",",
"encoding",
")",
":",
"it",
"=",
"iter",
"(",
"response",
")",
"return",
"dict",
"(",
"(",
"(",
"k",
".",
"decode",
"(",
"encoding",
")",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"zip",
"(",
"it",
... | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.