repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
rodluger/everest
everest/transit.py
Get_rhos
def Get_rhos(dur, **kwargs): ''' Returns the value of the stellar density for a given transit duration :py:obj:`dur`, given the :py:class:`everest.pysyzygy` transit :py:obj:`kwargs`. ''' if ps is None: raise Exception("Unable to import `pysyzygy`.") assert dur >= 0.01 and dur <...
python
def Get_rhos(dur, **kwargs): ''' Returns the value of the stellar density for a given transit duration :py:obj:`dur`, given the :py:class:`everest.pysyzygy` transit :py:obj:`kwargs`. ''' if ps is None: raise Exception("Unable to import `pysyzygy`.") assert dur >= 0.01 and dur <...
[ "def", "Get_rhos", "(", "dur", ",", "*", "*", "kwargs", ")", ":", "if", "ps", "is", "None", ":", "raise", "Exception", "(", "\"Unable to import `pysyzygy`.\"", ")", "assert", "dur", ">=", "0.01", "and", "dur", "<=", "0.5", ",", "\"Invalid value for the durat...
Returns the value of the stellar density for a given transit duration :py:obj:`dur`, given the :py:class:`everest.pysyzygy` transit :py:obj:`kwargs`.
[ "Returns", "the", "value", "of", "the", "stellar", "density", "for", "a", "given", "transit", "duration", ":", "py", ":", "obj", ":", "dur", "given", "the", ":", "py", ":", "class", ":", "everest", ".", "pysyzygy", "transit", ":", "py", ":", "obj", "...
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/transit.py#L137-L161
rodluger/everest
everest/transit.py
Transit
def Transit(time, t0=0., dur=0.1, per=3.56789, depth=0.001, **kwargs): ''' A `Mandel-Agol <http://adsabs.harvard.edu/abs/2002ApJ...580L.171M>`_ transit model, but with the depth and the duration as primary input variables. :param numpy.ndarray time: The time array :param float t0: The time of f...
python
def Transit(time, t0=0., dur=0.1, per=3.56789, depth=0.001, **kwargs): ''' A `Mandel-Agol <http://adsabs.harvard.edu/abs/2002ApJ...580L.171M>`_ transit model, but with the depth and the duration as primary input variables. :param numpy.ndarray time: The time array :param float t0: The time of f...
[ "def", "Transit", "(", "time", ",", "t0", "=", "0.", ",", "dur", "=", "0.1", ",", "per", "=", "3.56789", ",", "depth", "=", "0.001", ",", "*", "*", "kwargs", ")", ":", "if", "ps", "is", "None", ":", "raise", "Exception", "(", "\"Unable to import `p...
A `Mandel-Agol <http://adsabs.harvard.edu/abs/2002ApJ...580L.171M>`_ transit model, but with the depth and the duration as primary input variables. :param numpy.ndarray time: The time array :param float t0: The time of first transit in units of \ :py:obj:`BJD` - 2454833. :param float dur...
[ "A", "Mandel", "-", "Agol", "<http", ":", "//", "adsabs", ".", "harvard", ".", "edu", "/", "abs", "/", "2002ApJ", "...", "580L", ".", "171M", ">", "_", "transit", "model", "but", "with", "the", "depth", "and", "the", "duration", "as", "primary", "inp...
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/transit.py#L164-L191
lsbardel/python-stdnet
examples/tsmodels.py
TimeSeries.intervals
def intervals(self, startdate, enddate, parseinterval=None): '''Given a ``startdate`` and an ``enddate`` dates, evaluate the date intervals from which data is not available. It return a list of two-dimensional tuples containing start and end date for the interval. The list could cont...
python
def intervals(self, startdate, enddate, parseinterval=None): '''Given a ``startdate`` and an ``enddate`` dates, evaluate the date intervals from which data is not available. It return a list of two-dimensional tuples containing start and end date for the interval. The list could cont...
[ "def", "intervals", "(", "self", ",", "startdate", ",", "enddate", ",", "parseinterval", "=", "None", ")", ":", "return", "missing_intervals", "(", "startdate", ",", "enddate", ",", "self", ".", "data_start", ",", "self", ".", "data_end", ",", "dateconverter...
Given a ``startdate`` and an ``enddate`` dates, evaluate the date intervals from which data is not available. It return a list of two-dimensional tuples containing start and end date for the interval. The list could contain 0, 1 or 2 tuples.
[ "Given", "a", "startdate", "and", "an", "enddate", "dates", "evaluate", "the", "date", "intervals", "from", "which", "data", "is", "not", "available", ".", "It", "return", "a", "list", "of", "two", "-", "dimensional", "tuples", "containing", "start", "and", ...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/tsmodels.py#L35-L42
lsbardel/python-stdnet
stdnet/apps/columnts/models.py
ColumnTS.front
def front(self, *fields): '''Return the front pair of the structure''' v, f = tuple(self.irange(0, 0, fields=fields)) if v: return (v[0], dict(((field, f[field][0]) for field in f)))
python
def front(self, *fields): '''Return the front pair of the structure''' v, f = tuple(self.irange(0, 0, fields=fields)) if v: return (v[0], dict(((field, f[field][0]) for field in f)))
[ "def", "front", "(", "self", ",", "*", "fields", ")", ":", "v", ",", "f", "=", "tuple", "(", "self", ".", "irange", "(", "0", ",", "0", ",", "fields", "=", "fields", ")", ")", "if", "v", ":", "return", "(", "v", "[", "0", "]", ",", "dict", ...
Return the front pair of the structure
[ "Return", "the", "front", "pair", "of", "the", "structure" ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/models.py#L52-L56
lsbardel/python-stdnet
stdnet/apps/columnts/models.py
ColumnTS.istats
def istats(self, start=0, end=-1, fields=None): '''Perform a multivariate statistic calculation of this :class:`ColumnTS` from *start* to *end*. :param start: Optional index (rank) where to start the analysis. :param end: Optional index (rank) where to end the analysis. :param fields: Optional subset of ...
python
def istats(self, start=0, end=-1, fields=None): '''Perform a multivariate statistic calculation of this :class:`ColumnTS` from *start* to *end*. :param start: Optional index (rank) where to start the analysis. :param end: Optional index (rank) where to end the analysis. :param fields: Optional subset of ...
[ "def", "istats", "(", "self", ",", "start", "=", "0", ",", "end", "=", "-", "1", ",", "fields", "=", "None", ")", ":", "backend", "=", "self", ".", "read_backend", "return", "backend", ".", "execute", "(", "backend", ".", "structure", "(", "self", ...
Perform a multivariate statistic calculation of this :class:`ColumnTS` from *start* to *end*. :param start: Optional index (rank) where to start the analysis. :param end: Optional index (rank) where to end the analysis. :param fields: Optional subset of :meth:`fields` to perform analysis on. If not provided ...
[ "Perform", "a", "multivariate", "statistic", "calculation", "of", "this", ":", "class", ":", "ColumnTS", "from", "*", "start", "*", "to", "*", "end", "*", ".", ":", "param", "start", ":", "Optional", "index", "(", "rank", ")", "where", "to", "start", "...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/models.py#L102-L113
lsbardel/python-stdnet
stdnet/apps/columnts/models.py
ColumnTS.stats
def stats(self, start, end, fields=None): '''Perform a multivariate statistic calculation of this :class:`ColumnTS` from a *start* date/datetime to an *end* date/datetime. :param start: Start date for analysis. :param end: End date for analysis. :param fields: Optional subset of :meth:`fields` to perfo...
python
def stats(self, start, end, fields=None): '''Perform a multivariate statistic calculation of this :class:`ColumnTS` from a *start* date/datetime to an *end* date/datetime. :param start: Start date for analysis. :param end: End date for analysis. :param fields: Optional subset of :meth:`fields` to perfo...
[ "def", "stats", "(", "self", ",", "start", ",", "end", ",", "fields", "=", "None", ")", ":", "start", "=", "self", ".", "pickler", ".", "dumps", "(", "start", ")", "end", "=", "self", ".", "pickler", ".", "dumps", "(", "end", ")", "backend", "=",...
Perform a multivariate statistic calculation of this :class:`ColumnTS` from a *start* date/datetime to an *end* date/datetime. :param start: Start date for analysis. :param end: End date for analysis. :param fields: Optional subset of :meth:`fields` to perform analysis on. If not provided all fields are in...
[ "Perform", "a", "multivariate", "statistic", "calculation", "of", "this", ":", "class", ":", "ColumnTS", "from", "a", "*", "start", "*", "date", "/", "datetime", "to", "an", "*", "end", "*", "date", "/", "datetime", ".", ":", "param", "start", ":", "St...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/models.py#L115-L129
lsbardel/python-stdnet
stdnet/apps/columnts/models.py
ColumnTS.imulti_stats
def imulti_stats(self, start=0, end=-1, series=None, fields=None, stats=None): '''Perform cross multivariate statistics calculation of this :class:`ColumnTS` and other optional *series* from *start* to *end*. :parameter start: the start rank. :parameter start: the end rank :paramet...
python
def imulti_stats(self, start=0, end=-1, series=None, fields=None, stats=None): '''Perform cross multivariate statistics calculation of this :class:`ColumnTS` and other optional *series* from *start* to *end*. :parameter start: the start rank. :parameter start: the end rank :paramet...
[ "def", "imulti_stats", "(", "self", ",", "start", "=", "0", ",", "end", "=", "-", "1", ",", "series", "=", "None", ",", "fields", "=", "None", ",", "stats", "=", "None", ")", ":", "stats", "=", "stats", "or", "self", ".", "default_multi_stats", "ba...
Perform cross multivariate statistics calculation of this :class:`ColumnTS` and other optional *series* from *start* to *end*. :parameter start: the start rank. :parameter start: the end rank :parameter field: name of field to perform multivariate statistics. :parameter series: a list of two elements tuple cont...
[ "Perform", "cross", "multivariate", "statistics", "calculation", "of", "this", ":", "class", ":", "ColumnTS", "and", "other", "optional", "*", "series", "*", "from", "*", "start", "*", "to", "*", "end", "*", ".", ":", "parameter", "start", ":", "the", "s...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/models.py#L131-L149
lsbardel/python-stdnet
stdnet/apps/columnts/models.py
ColumnTS.merge
def merge(self, *series, **kwargs): '''Merge this :class:`ColumnTS` with several other *series*. :parameters series: a list of tuples where the nth element is a tuple of the form:: (wight_n, ts_n1, ts_n2, ..., ts_nMn) The result will be calculated using the formula:: ts = weight_1*ts_1...
python
def merge(self, *series, **kwargs): '''Merge this :class:`ColumnTS` with several other *series*. :parameters series: a list of tuples where the nth element is a tuple of the form:: (wight_n, ts_n1, ts_n2, ..., ts_nMn) The result will be calculated using the formula:: ts = weight_1*ts_1...
[ "def", "merge", "(", "self", ",", "*", "series", ",", "*", "*", "kwargs", ")", ":", "session", "=", "self", ".", "session", "if", "not", "session", ":", "raise", "SessionNotAvailable", "(", "'No session available'", ")", "self", ".", "check_router", "(", ...
Merge this :class:`ColumnTS` with several other *series*. :parameters series: a list of tuples where the nth element is a tuple of the form:: (wight_n, ts_n1, ts_n2, ..., ts_nMn) The result will be calculated using the formula:: ts = weight_1*ts_11*ts_12*...*ts_1M1 + weight_2*ts_21*ts_22*...*ts...
[ "Merge", "this", ":", "class", ":", "ColumnTS", "with", "several", "other", "*", "series", "*", ".", ":", "parameters", "series", ":", "a", "list", "of", "tuples", "where", "the", "nth", "element", "is", "a", "tuple", "of", "the", "form", "::", "(", ...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/models.py#L171-L188
lsbardel/python-stdnet
stdnet/apps/columnts/models.py
ColumnTS.merged_series
def merged_series(cls, *series, **kwargs): '''Merge ``series`` and return the results without storing data in the backend server.''' router, backend = cls.check_router(None, *series) if backend: target = router.register(cls(), backend) router.session().add(target) ...
python
def merged_series(cls, *series, **kwargs): '''Merge ``series`` and return the results without storing data in the backend server.''' router, backend = cls.check_router(None, *series) if backend: target = router.register(cls(), backend) router.session().add(target) ...
[ "def", "merged_series", "(", "cls", ",", "*", "series", ",", "*", "*", "kwargs", ")", ":", "router", ",", "backend", "=", "cls", ".", "check_router", "(", "None", ",", "*", "series", ")", "if", "backend", ":", "target", "=", "router", ".", "register"...
Merge ``series`` and return the results without storing data in the backend server.
[ "Merge", "series", "and", "return", "the", "results", "without", "storing", "data", "in", "the", "backend", "server", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/columnts/models.py#L191-L202
lsbardel/python-stdnet
stdnet/utils/skiplist.py
skiplist.rank
def rank(self, score): '''Return the 0-based index (rank) of ``score``. If the score is not available it returns a negative integer which absolute score is the left most closest index with score less than *score*.''' node = self.__head rank = 0 for i in range(self.__level-1, -1, -1): ...
python
def rank(self, score): '''Return the 0-based index (rank) of ``score``. If the score is not available it returns a negative integer which absolute score is the left most closest index with score less than *score*.''' node = self.__head rank = 0 for i in range(self.__level-1, -1, -1): ...
[ "def", "rank", "(", "self", ",", "score", ")", ":", "node", "=", "self", ".", "__head", "rank", "=", "0", "for", "i", "in", "range", "(", "self", ".", "__level", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "while", "node", ".", "next", ...
Return the 0-based index (rank) of ``score``. If the score is not available it returns a negative integer which absolute score is the left most closest index with score less than *score*.
[ "Return", "the", "0", "-", "based", "index", "(", "rank", ")", "of", "score", ".", "If", "the", "score", "is", "not", "available", "it", "returns", "a", "negative", "integer", "which", "absolute", "score", "is", "the", "left", "most", "closest", "index",...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/skiplist.py#L74-L87
lsbardel/python-stdnet
stdnet/odm/base.py
ModelMeta.make_object
def make_object(self, state=None, backend=None): '''Create a new instance of :attr:`model` from a *state* tuple.''' model = self.model obj = model.__new__(model) self.load_state(obj, state, backend) return obj
python
def make_object(self, state=None, backend=None): '''Create a new instance of :attr:`model` from a *state* tuple.''' model = self.model obj = model.__new__(model) self.load_state(obj, state, backend) return obj
[ "def", "make_object", "(", "self", ",", "state", "=", "None", ",", "backend", "=", "None", ")", ":", "model", "=", "self", ".", "model", "obj", "=", "model", ".", "__new__", "(", "model", ")", "self", ".", "load_state", "(", "obj", ",", "state", ",...
Create a new instance of :attr:`model` from a *state* tuple.
[ "Create", "a", "new", "instance", "of", ":", "attr", ":", "model", "from", "a", "*", "state", "*", "tuple", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L201-L206
lsbardel/python-stdnet
stdnet/odm/base.py
ModelMeta.is_valid
def is_valid(self, instance): '''Perform validation for *instance* and stores serialized data, indexes and errors into local cache. Return ``True`` if the instance is ready to be saved to database.''' dbdata = instance.dbdata data = dbdata['cleaned_data'] = {} errors = dbdata['erro...
python
def is_valid(self, instance): '''Perform validation for *instance* and stores serialized data, indexes and errors into local cache. Return ``True`` if the instance is ready to be saved to database.''' dbdata = instance.dbdata data = dbdata['cleaned_data'] = {} errors = dbdata['erro...
[ "def", "is_valid", "(", "self", ",", "instance", ")", ":", "dbdata", "=", "instance", ".", "dbdata", "data", "=", "dbdata", "[", "'cleaned_data'", "]", "=", "{", "}", "errors", "=", "dbdata", "[", "'errors'", "]", "=", "{", "}", "#Loop over scalar fields...
Perform validation for *instance* and stores serialized data, indexes and errors into local cache. Return ``True`` if the instance is ready to be saved to database.
[ "Perform", "validation", "for", "*", "instance", "*", "and", "stores", "serialized", "data", "indexes", "and", "errors", "into", "local", "cache", ".", "Return", "True", "if", "the", "instance", "is", "ready", "to", "be", "saved", "to", "database", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L239-L262
lsbardel/python-stdnet
stdnet/odm/base.py
ModelMeta.backend_fields
def backend_fields(self, fields): '''Return a two elements tuple containing a list of fields names and a list of field attribute names.''' dfields = self.dfields processed = set() names = [] atts = [] pkname = self.pkname() for name in fields: ...
python
def backend_fields(self, fields): '''Return a two elements tuple containing a list of fields names and a list of field attribute names.''' dfields = self.dfields processed = set() names = [] atts = [] pkname = self.pkname() for name in fields: ...
[ "def", "backend_fields", "(", "self", ",", "fields", ")", ":", "dfields", "=", "self", ".", "dfields", "processed", "=", "set", "(", ")", "names", "=", "[", "]", "atts", "=", "[", "]", "pkname", "=", "self", ".", "pkname", "(", ")", "for", "name", ...
Return a two elements tuple containing a list of fields names and a list of field attribute names.
[ "Return", "a", "two", "elements", "tuple", "containing", "a", "list", "of", "fields", "names", "and", "a", "list", "of", "field", "attribute", "names", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L292-L316
lsbardel/python-stdnet
stdnet/odm/base.py
ModelMeta.as_dict
def as_dict(self): '''Model metadata in a dictionary''' pk = self.pk id_type = 3 if pk.type == 'auto': id_type = 1 return {'id_name': pk.name, 'id_type': id_type, 'sorted': bool(self.ordering), 'autoincr': self....
python
def as_dict(self): '''Model metadata in a dictionary''' pk = self.pk id_type = 3 if pk.type == 'auto': id_type = 1 return {'id_name': pk.name, 'id_type': id_type, 'sorted': bool(self.ordering), 'autoincr': self....
[ "def", "as_dict", "(", "self", ")", ":", "pk", "=", "self", ".", "pk", "id_type", "=", "3", "if", "pk", ".", "type", "==", "'auto'", ":", "id_type", "=", "1", "return", "{", "'id_name'", ":", "pk", ".", "name", ",", "'id_type'", ":", "id_type", "...
Model metadata in a dictionary
[ "Model", "metadata", "in", "a", "dictionary" ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L318-L330
lsbardel/python-stdnet
stdnet/odm/base.py
Model.get_state
def get_state(self, **kwargs): '''Return the current :class:`ModelState` for this :class:`Model`. If ``kwargs`` parameters are passed a new :class:`ModelState` is created, otherwise it returns the cached value.''' dbdata = self.dbdata if 'state' not in dbdata or kwargs: dbdata[...
python
def get_state(self, **kwargs): '''Return the current :class:`ModelState` for this :class:`Model`. If ``kwargs`` parameters are passed a new :class:`ModelState` is created, otherwise it returns the cached value.''' dbdata = self.dbdata if 'state' not in dbdata or kwargs: dbdata[...
[ "def", "get_state", "(", "self", ",", "*", "*", "kwargs", ")", ":", "dbdata", "=", "self", ".", "dbdata", "if", "'state'", "not", "in", "dbdata", "or", "kwargs", ":", "dbdata", "[", "'state'", "]", "=", "ModelState", "(", "self", ",", "*", "*", "kw...
Return the current :class:`ModelState` for this :class:`Model`. If ``kwargs`` parameters are passed a new :class:`ModelState` is created, otherwise it returns the cached value.
[ "Return", "the", "current", ":", "class", ":", "ModelState", "for", "this", ":", "class", ":", "Model", ".", "If", "kwargs", "parameters", "are", "passed", "a", "new", ":", "class", ":", "ModelState", "is", "created", "otherwise", "it", "returns", "the", ...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L475-L482
lsbardel/python-stdnet
stdnet/odm/base.py
Model.uuid
def uuid(self): '''Universally unique identifier for an instance of a :class:`Model`. ''' pk = self.pkvalue() if not pk: raise self.DoesNotExist( 'Object not saved. Cannot obtain universally unique id') return self.get_uuid(pk)
python
def uuid(self): '''Universally unique identifier for an instance of a :class:`Model`. ''' pk = self.pkvalue() if not pk: raise self.DoesNotExist( 'Object not saved. Cannot obtain universally unique id') return self.get_uuid(pk)
[ "def", "uuid", "(", "self", ")", ":", "pk", "=", "self", ".", "pkvalue", "(", ")", "if", "not", "pk", ":", "raise", "self", ".", "DoesNotExist", "(", "'Object not saved. Cannot obtain universally unique id'", ")", "return", "self", ".", "get_uuid", "(", "pk"...
Universally unique identifier for an instance of a :class:`Model`.
[ "Universally", "unique", "identifier", "for", "an", "instance", "of", "a", ":", "class", ":", "Model", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L493-L500
lsbardel/python-stdnet
stdnet/odm/base.py
Model.backend
def backend(self, client=None): '''The :class:`stdnet.BackendDatServer` for this instance. It can be ``None``. ''' session = self.session if session: return session.model(self).backend
python
def backend(self, client=None): '''The :class:`stdnet.BackendDatServer` for this instance. It can be ``None``. ''' session = self.session if session: return session.model(self).backend
[ "def", "backend", "(", "self", ",", "client", "=", "None", ")", ":", "session", "=", "self", ".", "session", "if", "session", ":", "return", "session", ".", "model", "(", "self", ")", ".", "backend" ]
The :class:`stdnet.BackendDatServer` for this instance. It can be ``None``.
[ "The", ":", "class", ":", "stdnet", ".", "BackendDatServer", "for", "this", "instance", ".", "It", "can", "be", "None", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L517-L524
lsbardel/python-stdnet
stdnet/odm/base.py
Model.read_backend
def read_backend(self, client=None): '''The read :class:`stdnet.BackendDatServer` for this instance. It can be ``None``. ''' session = self.session if session: return session.model(self).read_backend
python
def read_backend(self, client=None): '''The read :class:`stdnet.BackendDatServer` for this instance. It can be ``None``. ''' session = self.session if session: return session.model(self).read_backend
[ "def", "read_backend", "(", "self", ",", "client", "=", "None", ")", ":", "session", "=", "self", ".", "session", "if", "session", ":", "return", "session", ".", "model", "(", "self", ")", ".", "read_backend" ]
The read :class:`stdnet.BackendDatServer` for this instance. It can be ``None``.
[ "The", "read", ":", "class", ":", "stdnet", ".", "BackendDatServer", "for", "this", "instance", ".", "It", "can", "be", "None", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/base.py#L527-L534
lsbardel/python-stdnet
stdnet/odm/models.py
create_model
def create_model(name, *attributes, **params): '''Create a :class:`Model` class for objects requiring and interface similar to :class:`StdModel`. We refers to this type of models as :ref:`local models <local-models>` since instances of such models are not persistent on a :class:`stdnet.BackendDataServer`. :param n...
python
def create_model(name, *attributes, **params): '''Create a :class:`Model` class for objects requiring and interface similar to :class:`StdModel`. We refers to this type of models as :ref:`local models <local-models>` since instances of such models are not persistent on a :class:`stdnet.BackendDataServer`. :param n...
[ "def", "create_model", "(", "name", ",", "*", "attributes", ",", "*", "*", "params", ")", ":", "params", "[", "'register'", "]", "=", "False", "params", "[", "'attributes'", "]", "=", "attributes", "kwargs", "=", "{", "'manager_class'", ":", "params", "....
Create a :class:`Model` class for objects requiring and interface similar to :class:`StdModel`. We refers to this type of models as :ref:`local models <local-models>` since instances of such models are not persistent on a :class:`stdnet.BackendDataServer`. :param name: Name of the model class. :param attributes: posit...
[ "Create", "a", ":", "class", ":", "Model", "class", "for", "objects", "requiring", "and", "interface", "similar", "to", ":", "class", ":", "StdModel", ".", "We", "refers", "to", "this", "type", "of", "models", "as", ":", "ref", ":", "local", "models", ...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L290-L307
lsbardel/python-stdnet
stdnet/odm/models.py
StdModel.loadedfields
def loadedfields(self): '''Generator of fields loaded from database''' if self._loadedfields is None: for field in self._meta.scalarfields: yield field else: fields = self._meta.dfields processed = set() for name in self._loadedfiel...
python
def loadedfields(self): '''Generator of fields loaded from database''' if self._loadedfields is None: for field in self._meta.scalarfields: yield field else: fields = self._meta.dfields processed = set() for name in self._loadedfiel...
[ "def", "loadedfields", "(", "self", ")", ":", "if", "self", ".", "_loadedfields", "is", "None", ":", "for", "field", "in", "self", ".", "_meta", ".", "scalarfields", ":", "yield", "field", "else", ":", "fields", "=", "self", ".", "_meta", ".", "dfields...
Generator of fields loaded from database
[ "Generator", "of", "fields", "loaded", "from", "database" ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L57-L77
lsbardel/python-stdnet
stdnet/odm/models.py
StdModel.fieldvalue_pairs
def fieldvalue_pairs(self, exclude_cache=False): '''Generator of fields,values pairs. Fields correspond to the ones which have been loaded (usually all of them) or not loaded but modified. Check the :ref:`load_only <performance-loadonly>` query function for more details. If *exclude_cache* evaluates to ``True`...
python
def fieldvalue_pairs(self, exclude_cache=False): '''Generator of fields,values pairs. Fields correspond to the ones which have been loaded (usually all of them) or not loaded but modified. Check the :ref:`load_only <performance-loadonly>` query function for more details. If *exclude_cache* evaluates to ``True`...
[ "def", "fieldvalue_pairs", "(", "self", ",", "exclude_cache", "=", "False", ")", ":", "for", "field", "in", "self", ".", "_meta", ".", "scalarfields", ":", "if", "exclude_cache", "and", "field", ".", "as_cache", ":", "continue", "name", "=", "field", ".", ...
Generator of fields,values pairs. Fields correspond to the ones which have been loaded (usually all of them) or not loaded but modified. Check the :ref:`load_only <performance-loadonly>` query function for more details. If *exclude_cache* evaluates to ``True``, fields with :attr:`Field.as_cache` attribute set to ``Tru...
[ "Generator", "of", "fields", "values", "pairs", ".", "Fields", "correspond", "to", "the", "ones", "which", "have", "been", "loaded", "(", "usually", "all", "of", "them", ")", "or", "not", "loaded", "but", "modified", ".", "Check", "the", ":", "ref", ":",...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L79-L95
lsbardel/python-stdnet
stdnet/odm/models.py
StdModel.clear_cache_fields
def clear_cache_fields(self): '''Set cache fields to ``None``. Check :attr:`Field.as_cache` for information regarding fields which are considered cache.''' for field in self._meta.scalarfields: if field.as_cache: setattr(self, field.name, None)
python
def clear_cache_fields(self): '''Set cache fields to ``None``. Check :attr:`Field.as_cache` for information regarding fields which are considered cache.''' for field in self._meta.scalarfields: if field.as_cache: setattr(self, field.name, None)
[ "def", "clear_cache_fields", "(", "self", ")", ":", "for", "field", "in", "self", ".", "_meta", ".", "scalarfields", ":", "if", "field", ".", "as_cache", ":", "setattr", "(", "self", ",", "field", ".", "name", ",", "None", ")" ]
Set cache fields to ``None``. Check :attr:`Field.as_cache` for information regarding fields which are considered cache.
[ "Set", "cache", "fields", "to", "None", ".", "Check", ":", "attr", ":", "Field", ".", "as_cache", "for", "information", "regarding", "fields", "which", "are", "considered", "cache", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L97-L102
lsbardel/python-stdnet
stdnet/odm/models.py
StdModel.get_attr_value
def get_attr_value(self, name): '''Retrieve the ``value`` for the attribute ``name``. The ``name`` can be nested following the :ref:`double underscore <tutorial-underscore>` notation, for example ``group__name``. If the attribute is not available it raises :class:`AttributeError`.''' if name in self._me...
python
def get_attr_value(self, name): '''Retrieve the ``value`` for the attribute ``name``. The ``name`` can be nested following the :ref:`double underscore <tutorial-underscore>` notation, for example ``group__name``. If the attribute is not available it raises :class:`AttributeError`.''' if name in self._me...
[ "def", "get_attr_value", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_meta", ".", "dfields", ":", "return", "self", ".", "_meta", ".", "dfields", "[", "name", "]", ".", "get_value", "(", "self", ")", "elif", "not", "name", ...
Retrieve the ``value`` for the attribute ``name``. The ``name`` can be nested following the :ref:`double underscore <tutorial-underscore>` notation, for example ``group__name``. If the attribute is not available it raises :class:`AttributeError`.
[ "Retrieve", "the", "value", "for", "the", "attribute", "name", ".", "The", "name", "can", "be", "nested", "following", "the", ":", "ref", ":", "double", "underscore", "<tutorial", "-", "underscore", ">", "notation", "for", "example", "group__name", ".", "If"...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L104-L119
lsbardel/python-stdnet
stdnet/odm/models.py
StdModel.clone
def clone(self, **data): '''Utility method for cloning the instance as a new object. :parameter data: additional which override field data. :rtype: a new instance of this class. ''' meta = self._meta session = self.session pkname = meta.pkname() pkvalue = data.pop(pkname, None) ...
python
def clone(self, **data): '''Utility method for cloning the instance as a new object. :parameter data: additional which override field data. :rtype: a new instance of this class. ''' meta = self._meta session = self.session pkname = meta.pkname() pkvalue = data.pop(pkname, None) ...
[ "def", "clone", "(", "self", ",", "*", "*", "data", ")", ":", "meta", "=", "self", ".", "_meta", "session", "=", "self", ".", "session", "pkname", "=", "meta", ".", "pkname", "(", ")", "pkvalue", "=", "data", ".", "pop", "(", "pkname", ",", "None...
Utility method for cloning the instance as a new object. :parameter data: additional which override field data. :rtype: a new instance of this class.
[ "Utility", "method", "for", "cloning", "the", "instance", "as", "a", "new", "object", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L121-L136
lsbardel/python-stdnet
stdnet/odm/models.py
StdModel.todict
def todict(self, exclude_cache=False): '''Return a dictionary of serialised scalar field for pickling. If the *exclude_cache* flag is ``True``, fields with :attr:`Field.as_cache` attribute set to ``True`` will be excluded.''' odict = {} for field, value in self.fieldvalue_pairs(exclude_cache=exc...
python
def todict(self, exclude_cache=False): '''Return a dictionary of serialised scalar field for pickling. If the *exclude_cache* flag is ``True``, fields with :attr:`Field.as_cache` attribute set to ``True`` will be excluded.''' odict = {} for field, value in self.fieldvalue_pairs(exclude_cache=exc...
[ "def", "todict", "(", "self", ",", "exclude_cache", "=", "False", ")", ":", "odict", "=", "{", "}", "for", "field", ",", "value", "in", "self", ".", "fieldvalue_pairs", "(", "exclude_cache", "=", "exclude_cache", ")", ":", "value", "=", "field", ".", "...
Return a dictionary of serialised scalar field for pickling. If the *exclude_cache* flag is ``True``, fields with :attr:`Field.as_cache` attribute set to ``True`` will be excluded.
[ "Return", "a", "dictionary", "of", "serialised", "scalar", "field", "for", "pickling", ".", "If", "the", "*", "exclude_cache", "*", "flag", "is", "True", "fields", "with", ":", "attr", ":", "Field", ".", "as_cache", "attribute", "set", "to", "True", "will"...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L145-L156
lsbardel/python-stdnet
stdnet/odm/models.py
StdModel.load_fields
def load_fields(self, *fields): '''Load extra fields to this :class:`StdModel`.''' if self._loadedfields is not None: if self.session is None: raise SessionNotAvailable('No session available') meta = self._meta kwargs = {meta.pkname(): self.pkvalue()} ...
python
def load_fields(self, *fields): '''Load extra fields to this :class:`StdModel`.''' if self._loadedfields is not None: if self.session is None: raise SessionNotAvailable('No session available') meta = self._meta kwargs = {meta.pkname(): self.pkvalue()} ...
[ "def", "load_fields", "(", "self", ",", "*", "fields", ")", ":", "if", "self", ".", "_loadedfields", "is", "not", "None", ":", "if", "self", ".", "session", "is", "None", ":", "raise", "SessionNotAvailable", "(", "'No session available'", ")", "meta", "=",...
Load extra fields to this :class:`StdModel`.
[ "Load", "extra", "fields", "to", "this", ":", "class", ":", "StdModel", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L172-L184
lsbardel/python-stdnet
stdnet/odm/models.py
StdModel.load_related_model
def load_related_model(self, name, load_only=None, dont_load=None): '''Load a the :class:`ForeignKey` field ``name`` if this is part of the fields of this model and if the related object is not already loaded. It is used by the lazy loading mechanism of :ref:`one-to-many <one-to-many>` relationships. :paramete...
python
def load_related_model(self, name, load_only=None, dont_load=None): '''Load a the :class:`ForeignKey` field ``name`` if this is part of the fields of this model and if the related object is not already loaded. It is used by the lazy loading mechanism of :ref:`one-to-many <one-to-many>` relationships. :paramete...
[ "def", "load_related_model", "(", "self", ",", "name", ",", "load_only", "=", "None", ",", "dont_load", "=", "None", ")", ":", "field", "=", "self", ".", "_meta", ".", "dfields", ".", "get", "(", "name", ")", "if", "not", "field", ":", "raise", "Valu...
Load a the :class:`ForeignKey` field ``name`` if this is part of the fields of this model and if the related object is not already loaded. It is used by the lazy loading mechanism of :ref:`one-to-many <one-to-many>` relationships. :parameter name: the :attr:`Field.name` of the :class:`ForeignKey` to load. :parameter l...
[ "Load", "a", "the", ":", "class", ":", "ForeignKey", "field", "name", "if", "this", "is", "part", "of", "the", "fields", "of", "this", "model", "and", "if", "the", "related", "object", "is", "not", "already", "loaded", ".", "It", "is", "used", "by", ...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L189-L205
lsbardel/python-stdnet
stdnet/odm/models.py
StdModel.from_base64_data
def from_base64_data(cls, **kwargs): '''Load a :class:`StdModel` from possibly base64encoded data. This method is used to load models from data obtained from the :meth:`tojson` method.''' o = cls() meta = cls._meta pkname = meta.pkname() for name, value in iteritems(kwargs): ...
python
def from_base64_data(cls, **kwargs): '''Load a :class:`StdModel` from possibly base64encoded data. This method is used to load models from data obtained from the :meth:`tojson` method.''' o = cls() meta = cls._meta pkname = meta.pkname() for name, value in iteritems(kwargs): ...
[ "def", "from_base64_data", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "o", "=", "cls", "(", ")", "meta", "=", "cls", ".", "_meta", "pkname", "=", "meta", ".", "pkname", "(", ")", "for", "name", ",", "value", "in", "iteritems", "(", "kwargs", ...
Load a :class:`StdModel` from possibly base64encoded data. This method is used to load models from data obtained from the :meth:`tojson` method.
[ "Load", "a", ":", "class", ":", "StdModel", "from", "possibly", "base64encoded", "data", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/models.py#L214-L231
rodluger/everest
everest/standalone.py
DetrendFITS
def DetrendFITS(fitsfile, raw=False, season=None, clobber=False, **kwargs): """ De-trend a K2 FITS file using :py:class:`everest.detrender.rPLD`. :param str fitsfile: The full path to the FITS file :param ndarray aperture: A 2D integer array corresponding to the \ desired photometric apertur...
python
def DetrendFITS(fitsfile, raw=False, season=None, clobber=False, **kwargs): """ De-trend a K2 FITS file using :py:class:`everest.detrender.rPLD`. :param str fitsfile: The full path to the FITS file :param ndarray aperture: A 2D integer array corresponding to the \ desired photometric apertur...
[ "def", "DetrendFITS", "(", "fitsfile", ",", "raw", "=", "False", ",", "season", "=", "None", ",", "clobber", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# Get info", "EPIC", "=", "pyfits", ".", "getheader", "(", "fitsfile", ",", "0", ")", "[", ...
De-trend a K2 FITS file using :py:class:`everest.detrender.rPLD`. :param str fitsfile: The full path to the FITS file :param ndarray aperture: A 2D integer array corresponding to the \ desired photometric aperture (1 = in aperture, 0 = outside \ aperture). Default is to interactively sele...
[ "De", "-", "trend", "a", "K2", "FITS", "file", "using", ":", "py", ":", "class", ":", "everest", ".", "detrender", ".", "rPLD", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/standalone.py#L42-L86
rodluger/everest
everest/standalone.py
GetData
def GetData(fitsfile, EPIC, campaign, clobber=False, saturation_tolerance=-0.1, bad_bits=[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17], get_hires=False, get_nearby=False, aperture=None, **kwargs): ''' Returns a :py:obj:`DataContainer` instance with the r...
python
def GetData(fitsfile, EPIC, campaign, clobber=False, saturation_tolerance=-0.1, bad_bits=[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17], get_hires=False, get_nearby=False, aperture=None, **kwargs): ''' Returns a :py:obj:`DataContainer` instance with the r...
[ "def", "GetData", "(", "fitsfile", ",", "EPIC", ",", "campaign", ",", "clobber", "=", "False", ",", "saturation_tolerance", "=", "-", "0.1", ",", "bad_bits", "=", "[", "1", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "8", "...
Returns a :py:obj:`DataContainer` instance with the raw data for the target. :param str fitsfile: The full raw target pixel file path :param bool clobber: Overwrite existing files? Default :py:obj:`False` :param float saturation_tolerance: Target is considered saturated \ if flux is within t...
[ "Returns", "a", ":", "py", ":", "obj", ":", "DataContainer", "instance", "with", "the", "raw", "data", "for", "the", "target", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/standalone.py#L380-L651
rodluger/everest
everest/dvs.py
DVS.title
def title(self): ''' Returns the axis instance where the title will be printed ''' return self.title_left(on=False), self.title_center(on=False), \ self.title_right(on=False)
python
def title(self): ''' Returns the axis instance where the title will be printed ''' return self.title_left(on=False), self.title_center(on=False), \ self.title_right(on=False)
[ "def", "title", "(", "self", ")", ":", "return", "self", ".", "title_left", "(", "on", "=", "False", ")", ",", "self", ".", "title_center", "(", "on", "=", "False", ")", ",", "self", ".", "title_right", "(", "on", "=", "False", ")" ]
Returns the axis instance where the title will be printed
[ "Returns", "the", "axis", "instance", "where", "the", "title", "will", "be", "printed" ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/dvs.py#L132-L139
rodluger/everest
everest/dvs.py
DVS.footer
def footer(self): ''' Returns the axis instance where the footer will be printed ''' return self.footer_left(on=False), self.footer_center(on=False), \ self.footer_right(on=False)
python
def footer(self): ''' Returns the axis instance where the footer will be printed ''' return self.footer_left(on=False), self.footer_center(on=False), \ self.footer_right(on=False)
[ "def", "footer", "(", "self", ")", ":", "return", "self", ".", "footer_left", "(", "on", "=", "False", ")", ",", "self", ".", "footer_center", "(", "on", "=", "False", ")", ",", "self", ".", "footer_right", "(", "on", "=", "False", ")" ]
Returns the axis instance where the footer will be printed
[ "Returns", "the", "axis", "instance", "where", "the", "footer", "will", "be", "printed" ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/dvs.py#L141-L148
rodluger/everest
everest/dvs.py
DVS.top_right
def top_right(self): ''' Returns the axis instance at the top right of the page, where the postage stamp and aperture is displayed ''' res = self.body_top_right[self.tcount]() self.tcount += 1 return res
python
def top_right(self): ''' Returns the axis instance at the top right of the page, where the postage stamp and aperture is displayed ''' res = self.body_top_right[self.tcount]() self.tcount += 1 return res
[ "def", "top_right", "(", "self", ")", ":", "res", "=", "self", ".", "body_top_right", "[", "self", ".", "tcount", "]", "(", ")", "self", ".", "tcount", "+=", "1", "return", "res" ]
Returns the axis instance at the top right of the page, where the postage stamp and aperture is displayed
[ "Returns", "the", "axis", "instance", "at", "the", "top", "right", "of", "the", "page", "where", "the", "postage", "stamp", "and", "aperture", "is", "displayed" ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/dvs.py#L150-L159
rodluger/everest
everest/dvs.py
DVS.left
def left(self): ''' Returns the current axis instance on the left side of the page where each successive light curve is displayed ''' res = self.body_left[self.lcount]() self.lcount += 1 return res
python
def left(self): ''' Returns the current axis instance on the left side of the page where each successive light curve is displayed ''' res = self.body_left[self.lcount]() self.lcount += 1 return res
[ "def", "left", "(", "self", ")", ":", "res", "=", "self", ".", "body_left", "[", "self", ".", "lcount", "]", "(", ")", "self", ".", "lcount", "+=", "1", "return", "res" ]
Returns the current axis instance on the left side of the page where each successive light curve is displayed
[ "Returns", "the", "current", "axis", "instance", "on", "the", "left", "side", "of", "the", "page", "where", "each", "successive", "light", "curve", "is", "displayed" ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/dvs.py#L170-L179
rodluger/everest
everest/dvs.py
DVS.right
def right(self): ''' Returns the current axis instance on the right side of the page, where cross-validation information is displayed ''' res = self.body_right[self.rcount]() self.rcount += 1 return res
python
def right(self): ''' Returns the current axis instance on the right side of the page, where cross-validation information is displayed ''' res = self.body_right[self.rcount]() self.rcount += 1 return res
[ "def", "right", "(", "self", ")", ":", "res", "=", "self", ".", "body_right", "[", "self", ".", "rcount", "]", "(", ")", "self", ".", "rcount", "+=", "1", "return", "res" ]
Returns the current axis instance on the right side of the page, where cross-validation information is displayed
[ "Returns", "the", "current", "axis", "instance", "on", "the", "right", "side", "of", "the", "page", "where", "cross", "-", "validation", "information", "is", "displayed" ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/dvs.py#L181-L190
rodluger/everest
everest/dvs.py
CBV.body
def body(self): ''' Returns the axis instance where the light curves will be shown ''' res = self._body[self.bcount]() self.bcount += 1 return res
python
def body(self): ''' Returns the axis instance where the light curves will be shown ''' res = self._body[self.bcount]() self.bcount += 1 return res
[ "def", "body", "(", "self", ")", ":", "res", "=", "self", ".", "_body", "[", "self", ".", "bcount", "]", "(", ")", "self", ".", "bcount", "+=", "1", "return", "res" ]
Returns the axis instance where the light curves will be shown
[ "Returns", "the", "axis", "instance", "where", "the", "light", "curves", "will", "be", "shown" ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/dvs.py#L230-L238
lsbardel/python-stdnet
stdnet/odm/globals.py
hashmodel
def hashmodel(model, library=None): '''Calculate the Hash id of metaclass ``meta``''' library = library or 'python-stdnet' meta = model._meta sha = hashlib.sha1(to_bytes('{0}({1})'.format(library, meta))) hash = sha.hexdigest()[:8] meta.hash = hash if hash in _model_dict: rai...
python
def hashmodel(model, library=None): '''Calculate the Hash id of metaclass ``meta``''' library = library or 'python-stdnet' meta = model._meta sha = hashlib.sha1(to_bytes('{0}({1})'.format(library, meta))) hash = sha.hexdigest()[:8] meta.hash = hash if hash in _model_dict: rai...
[ "def", "hashmodel", "(", "model", ",", "library", "=", "None", ")", ":", "library", "=", "library", "or", "'python-stdnet'", "meta", "=", "model", ".", "_meta", "sha", "=", "hashlib", ".", "sha1", "(", "to_bytes", "(", "'{0}({1})'", ".", "format", "(", ...
Calculate the Hash id of metaclass ``meta``
[ "Calculate", "the", "Hash", "id", "of", "metaclass", "meta" ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/globals.py#L40-L50
lsbardel/python-stdnet
stdnet/odm/globals.py
Event.bind
def bind(self, callback, sender=None): '''Bind a ``callback`` for a given ``sender``.''' key = (_make_id(callback), _make_id(sender)) self.callbacks.append((key, callback))
python
def bind(self, callback, sender=None): '''Bind a ``callback`` for a given ``sender``.''' key = (_make_id(callback), _make_id(sender)) self.callbacks.append((key, callback))
[ "def", "bind", "(", "self", ",", "callback", ",", "sender", "=", "None", ")", ":", "key", "=", "(", "_make_id", "(", "callback", ")", ",", "_make_id", "(", "sender", ")", ")", "self", ".", "callbacks", ".", "append", "(", "(", "key", ",", "callback...
Bind a ``callback`` for a given ``sender``.
[ "Bind", "a", "callback", "for", "a", "given", "sender", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/globals.py#L64-L67
lsbardel/python-stdnet
stdnet/odm/globals.py
Event.fire
def fire(self, sender=None, **params): '''Fire callbacks from a ``sender``.''' keys = (_make_id(None), _make_id(sender)) results = [] for (_, key), callback in self.callbacks: if key in keys: results.append(callback(self, sender, **params)) retu...
python
def fire(self, sender=None, **params): '''Fire callbacks from a ``sender``.''' keys = (_make_id(None), _make_id(sender)) results = [] for (_, key), callback in self.callbacks: if key in keys: results.append(callback(self, sender, **params)) retu...
[ "def", "fire", "(", "self", ",", "sender", "=", "None", ",", "*", "*", "params", ")", ":", "keys", "=", "(", "_make_id", "(", "None", ")", ",", "_make_id", "(", "sender", ")", ")", "results", "=", "[", "]", "for", "(", "_", ",", "key", ")", "...
Fire callbacks from a ``sender``.
[ "Fire", "callbacks", "from", "a", "sender", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/globals.py#L69-L76
lsbardel/python-stdnet
stdnet/backends/redisb/client/prefixed.py
PrefixedRedisMixin.execute_command
def execute_command(self, cmnd, *args, **options): "Execute a command and return a parsed response" args, options = self.preprocess_command(cmnd, *args, **options) return self.client.execute_command(cmnd, *args, **options)
python
def execute_command(self, cmnd, *args, **options): "Execute a command and return a parsed response" args, options = self.preprocess_command(cmnd, *args, **options) return self.client.execute_command(cmnd, *args, **options)
[ "def", "execute_command", "(", "self", ",", "cmnd", ",", "*", "args", ",", "*", "*", "options", ")", ":", "args", ",", "options", "=", "self", ".", "preprocess_command", "(", "cmnd", ",", "*", "args", ",", "*", "*", "options", ")", "return", "self", ...
Execute a command and return a parsed response
[ "Execute", "a", "command", "and", "return", "a", "parsed", "response" ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/prefixed.py#L122-L125
rodluger/everest
everest/missions/k2/utils.py
_range10_90
def _range10_90(x): ''' Returns the 10th-90th percentile range of array :py:obj:`x`. ''' x = np.delete(x, np.where(np.isnan(x))) i = np.argsort(x) a = int(0.1 * len(x)) b = int(0.9 * len(x)) return x[i][b] - x[i][a]
python
def _range10_90(x): ''' Returns the 10th-90th percentile range of array :py:obj:`x`. ''' x = np.delete(x, np.where(np.isnan(x))) i = np.argsort(x) a = int(0.1 * len(x)) b = int(0.9 * len(x)) return x[i][b] - x[i][a]
[ "def", "_range10_90", "(", "x", ")", ":", "x", "=", "np", ".", "delete", "(", "x", ",", "np", ".", "where", "(", "np", ".", "isnan", "(", "x", ")", ")", ")", "i", "=", "np", ".", "argsort", "(", "x", ")", "a", "=", "int", "(", "0.1", "*",...
Returns the 10th-90th percentile range of array :py:obj:`x`.
[ "Returns", "the", "10th", "-", "90th", "percentile", "range", "of", "array", ":", "py", ":", "obj", ":", "x", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L45-L55
rodluger/everest
everest/missions/k2/utils.py
Campaign
def Campaign(EPIC, **kwargs): ''' Returns the campaign number(s) for a given EPIC target. If target is not found, returns :py:obj:`None`. :param int EPIC: The EPIC number of the target. ''' campaigns = [] for campaign, stars in GetK2Stars().items(): if EPIC in [s[0] for s in stars...
python
def Campaign(EPIC, **kwargs): ''' Returns the campaign number(s) for a given EPIC target. If target is not found, returns :py:obj:`None`. :param int EPIC: The EPIC number of the target. ''' campaigns = [] for campaign, stars in GetK2Stars().items(): if EPIC in [s[0] for s in stars...
[ "def", "Campaign", "(", "EPIC", ",", "*", "*", "kwargs", ")", ":", "campaigns", "=", "[", "]", "for", "campaign", ",", "stars", "in", "GetK2Stars", "(", ")", ".", "items", "(", ")", ":", "if", "EPIC", "in", "[", "s", "[", "0", "]", "for", "s", ...
Returns the campaign number(s) for a given EPIC target. If target is not found, returns :py:obj:`None`. :param int EPIC: The EPIC number of the target.
[ "Returns", "the", "campaign", "number", "(", "s", ")", "for", "a", "given", "EPIC", "target", ".", "If", "target", "is", "not", "found", "returns", ":", "py", ":", "obj", ":", "None", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L152-L170
rodluger/everest
everest/missions/k2/utils.py
GetK2Stars
def GetK2Stars(clobber=False): ''' Download and return a :py:obj:`dict` of all *K2* stars organized by campaign. Saves each campaign to a `.stars` file in the `everest/missions/k2/tables` directory. :param bool clobber: If :py:obj:`True`, download and overwrite \ existing files. Default ...
python
def GetK2Stars(clobber=False): ''' Download and return a :py:obj:`dict` of all *K2* stars organized by campaign. Saves each campaign to a `.stars` file in the `everest/missions/k2/tables` directory. :param bool clobber: If :py:obj:`True`, download and overwrite \ existing files. Default ...
[ "def", "GetK2Stars", "(", "clobber", "=", "False", ")", ":", "# Download", "if", "clobber", ":", "print", "(", "\"Downloading K2 star list...\"", ")", "stars", "=", "kplr_client", ".", "k2_star_info", "(", ")", "print", "(", "\"Writing star list to disk...\"", ")"...
Download and return a :py:obj:`dict` of all *K2* stars organized by campaign. Saves each campaign to a `.stars` file in the `everest/missions/k2/tables` directory. :param bool clobber: If :py:obj:`True`, download and overwrite \ existing files. Default :py:obj:`False` .. note:: The keys of ...
[ "Download", "and", "return", "a", ":", "py", ":", "obj", ":", "dict", "of", "all", "*", "K2", "*", "stars", "organized", "by", "campaign", ".", "Saves", "each", "campaign", "to", "a", ".", "stars", "file", "in", "the", "everest", "/", "missions", "/"...
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L173-L227
rodluger/everest
everest/missions/k2/utils.py
GetK2Campaign
def GetK2Campaign(campaign, clobber=False, split=False, epics_only=False, cadence='lc'): ''' Return all stars in a given *K2* 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 \ ...
python
def GetK2Campaign(campaign, clobber=False, split=False, epics_only=False, cadence='lc'): ''' Return all stars in a given *K2* 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 \ ...
[ "def", "GetK2Campaign", "(", "campaign", ",", "clobber", "=", "False", ",", "split", "=", "False", ",", "epics_only", "=", "False", ",", "cadence", "=", "'lc'", ")", ":", "all", "=", "GetK2Stars", "(", "clobber", "=", "clobber", ")", "if", "int", "(", ...
Return all stars in a given *K2* 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 :py:obj:`X.Y`, runs the :py:obj:`Y^th` decile of campaign \ :py:obj:`X`. :param bool...
[ "Return", "all", "stars", "in", "a", "given", "*", "K2", "*", "campaign", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L230-L291
rodluger/everest
everest/missions/k2/utils.py
Channel
def Channel(EPIC, campaign=None): ''' Returns the channel number for a given EPIC target. ''' if campaign is None: campaign = Campaign(EPIC) if hasattr(campaign, '__len__'): raise AttributeError( "Please choose a campaign/season for this target: %s." % campaign) try...
python
def Channel(EPIC, campaign=None): ''' Returns the channel number for a given EPIC target. ''' if campaign is None: campaign = Campaign(EPIC) if hasattr(campaign, '__len__'): raise AttributeError( "Please choose a campaign/season for this target: %s." % campaign) try...
[ "def", "Channel", "(", "EPIC", ",", "campaign", "=", "None", ")", ":", "if", "campaign", "is", "None", ":", "campaign", "=", "Campaign", "(", "EPIC", ")", "if", "hasattr", "(", "campaign", ",", "'__len__'", ")", ":", "raise", "AttributeError", "(", "\"...
Returns the channel number for a given EPIC target.
[ "Returns", "the", "channel", "number", "for", "a", "given", "EPIC", "target", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L294-L312
rodluger/everest
everest/missions/k2/utils.py
Module
def Module(EPIC, campaign=None): ''' Returns the module number for a given EPIC target. ''' channel = Channel(EPIC, campaign=campaign) nums = {2: 1, 3: 5, 4: 9, 6: 13, 7: 17, 8: 21, 9: 25, 10: 29, 11: 33, 12: 37, 13: 41, 14: 45, 15: 49, 16: 53, 17: 57, 18: 61, 19: 65, 20: 6...
python
def Module(EPIC, campaign=None): ''' Returns the module number for a given EPIC target. ''' channel = Channel(EPIC, campaign=campaign) nums = {2: 1, 3: 5, 4: 9, 6: 13, 7: 17, 8: 21, 9: 25, 10: 29, 11: 33, 12: 37, 13: 41, 14: 45, 15: 49, 16: 53, 17: 57, 18: 61, 19: 65, 20: 6...
[ "def", "Module", "(", "EPIC", ",", "campaign", "=", "None", ")", ":", "channel", "=", "Channel", "(", "EPIC", ",", "campaign", "=", "campaign", ")", "nums", "=", "{", "2", ":", "1", ",", "3", ":", "5", ",", "4", ":", "9", ",", "6", ":", "13",...
Returns the module number for a given EPIC target.
[ "Returns", "the", "module", "number", "for", "a", "given", "EPIC", "target", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L315-L331
rodluger/everest
everest/missions/k2/utils.py
Channels
def Channels(module): ''' Returns the channels contained in the given K2 module. ''' nums = {2: 1, 3: 5, 4: 9, 6: 13, 7: 17, 8: 21, 9: 25, 10: 29, 11: 33, 12: 37, 13: 41, 14: 45, 15: 49, 16: 53, 17: 57, 18: 61, 19: 65, 20: 69, 22: 73, 23: 77, 24: 81} if module ...
python
def Channels(module): ''' Returns the channels contained in the given K2 module. ''' nums = {2: 1, 3: 5, 4: 9, 6: 13, 7: 17, 8: 21, 9: 25, 10: 29, 11: 33, 12: 37, 13: 41, 14: 45, 15: 49, 16: 53, 17: 57, 18: 61, 19: 65, 20: 69, 22: 73, 23: 77, 24: 81} if module ...
[ "def", "Channels", "(", "module", ")", ":", "nums", "=", "{", "2", ":", "1", ",", "3", ":", "5", ",", "4", ":", "9", ",", "6", ":", "13", ",", "7", ":", "17", ",", "8", ":", "21", ",", "9", ":", "25", ",", "10", ":", "29", ",", "11", ...
Returns the channels contained in the given K2 module.
[ "Returns", "the", "channels", "contained", "in", "the", "given", "K2", "module", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L334-L349
rodluger/everest
everest/missions/k2/utils.py
KepMag
def KepMag(EPIC, campaign=None): ''' Returns the *Kepler* magnitude for a given EPIC target. ''' if campaign is None: campaign = Campaign(EPIC) if hasattr(campaign, '__len__'): raise AttributeError( "Please choose a campaign/season for this target: %s." % campaign) ...
python
def KepMag(EPIC, campaign=None): ''' Returns the *Kepler* magnitude for a given EPIC target. ''' if campaign is None: campaign = Campaign(EPIC) if hasattr(campaign, '__len__'): raise AttributeError( "Please choose a campaign/season for this target: %s." % campaign) ...
[ "def", "KepMag", "(", "EPIC", ",", "campaign", "=", "None", ")", ":", "if", "campaign", "is", "None", ":", "campaign", "=", "Campaign", "(", "EPIC", ")", "if", "hasattr", "(", "campaign", ",", "'__len__'", ")", ":", "raise", "AttributeError", "(", "\"P...
Returns the *Kepler* magnitude for a given EPIC target.
[ "Returns", "the", "*", "Kepler", "*", "magnitude", "for", "a", "given", "EPIC", "target", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L352-L365
rodluger/everest
everest/missions/k2/utils.py
RemoveBackground
def RemoveBackground(EPIC, campaign=None): ''' Returns :py:obj:`True` or :py:obj:`False`, indicating whether or not to remove the background flux for the target. If ``campaign < 3``, returns :py:obj:`True`, otherwise returns :py:obj:`False`. ''' if campaign is None: campaign = Campaign...
python
def RemoveBackground(EPIC, campaign=None): ''' Returns :py:obj:`True` or :py:obj:`False`, indicating whether or not to remove the background flux for the target. If ``campaign < 3``, returns :py:obj:`True`, otherwise returns :py:obj:`False`. ''' if campaign is None: campaign = Campaign...
[ "def", "RemoveBackground", "(", "EPIC", ",", "campaign", "=", "None", ")", ":", "if", "campaign", "is", "None", ":", "campaign", "=", "Campaign", "(", "EPIC", ")", "if", "hasattr", "(", "campaign", ",", "'__len__'", ")", ":", "raise", "AttributeError", "...
Returns :py:obj:`True` or :py:obj:`False`, indicating whether or not to remove the background flux for the target. If ``campaign < 3``, returns :py:obj:`True`, otherwise returns :py:obj:`False`.
[ "Returns", ":", "py", ":", "obj", ":", "True", "or", ":", "py", ":", "obj", ":", "False", "indicating", "whether", "or", "not", "to", "remove", "the", "background", "flux", "for", "the", "target", ".", "If", "campaign", "<", "3", "returns", ":", "py"...
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L368-L384
rodluger/everest
everest/missions/k2/utils.py
GetNeighboringChannels
def GetNeighboringChannels(channel): ''' Returns all channels on the same module as :py:obj:`channel`. ''' x = divmod(channel - 1, 4)[1] return channel + np.array(range(-x, -x + 4), dtype=int)
python
def GetNeighboringChannels(channel): ''' Returns all channels on the same module as :py:obj:`channel`. ''' x = divmod(channel - 1, 4)[1] return channel + np.array(range(-x, -x + 4), dtype=int)
[ "def", "GetNeighboringChannels", "(", "channel", ")", ":", "x", "=", "divmod", "(", "channel", "-", "1", ",", "4", ")", "[", "1", "]", "return", "channel", "+", "np", ".", "array", "(", "range", "(", "-", "x", ",", "-", "x", "+", "4", ")", ",",...
Returns all channels on the same module as :py:obj:`channel`.
[ "Returns", "all", "channels", "on", "the", "same", "module", "as", ":", "py", ":", "obj", ":", "channel", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L387-L394
rodluger/everest
everest/missions/k2/utils.py
MASTRADec
def MASTRADec(ra, dec, darcsec, stars_only=False): ''' Detector location retrieval based upon RA and Dec. Adapted from `PyKE <http://keplergo.arc.nasa.gov/PyKE.shtml>`_. ''' # coordinate limits darcsec /= 3600.0 ra1 = ra - darcsec / np.cos(dec * np.pi / 180) ra2 = ra + darcsec / np.cos...
python
def MASTRADec(ra, dec, darcsec, stars_only=False): ''' Detector location retrieval based upon RA and Dec. Adapted from `PyKE <http://keplergo.arc.nasa.gov/PyKE.shtml>`_. ''' # coordinate limits darcsec /= 3600.0 ra1 = ra - darcsec / np.cos(dec * np.pi / 180) ra2 = ra + darcsec / np.cos...
[ "def", "MASTRADec", "(", "ra", ",", "dec", ",", "darcsec", ",", "stars_only", "=", "False", ")", ":", "# coordinate limits", "darcsec", "/=", "3600.0", "ra1", "=", "ra", "-", "darcsec", "/", "np", ".", "cos", "(", "dec", "*", "np", ".", "pi", "/", ...
Detector location retrieval based upon RA and Dec. Adapted from `PyKE <http://keplergo.arc.nasa.gov/PyKE.shtml>`_.
[ "Detector", "location", "retrieval", "based", "upon", "RA", "and", "Dec", ".", "Adapted", "from", "PyKE", "<http", ":", "//", "keplergo", ".", "arc", ".", "nasa", ".", "gov", "/", "PyKE", ".", "shtml", ">", "_", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L397-L454
rodluger/everest
everest/missions/k2/utils.py
sex2dec
def sex2dec(ra, dec): ''' Convert sexadecimal hours to decimal degrees. Adapted from `PyKE <http://keplergo.arc.nasa.gov/PyKE.shtml>`_. :param float ra: The right ascension :param float dec: The declination :returns: The same values, but in decimal degrees ''' ra = re.sub('\s+', '|',...
python
def sex2dec(ra, dec): ''' Convert sexadecimal hours to decimal degrees. Adapted from `PyKE <http://keplergo.arc.nasa.gov/PyKE.shtml>`_. :param float ra: The right ascension :param float dec: The declination :returns: The same values, but in decimal degrees ''' ra = re.sub('\s+', '|',...
[ "def", "sex2dec", "(", "ra", ",", "dec", ")", ":", "ra", "=", "re", ".", "sub", "(", "'\\s+'", ",", "'|'", ",", "ra", ".", "strip", "(", ")", ")", "ra", "=", "re", ".", "sub", "(", "':'", ",", "'|'", ",", "ra", ".", "strip", "(", ")", ")"...
Convert sexadecimal hours to decimal degrees. Adapted from `PyKE <http://keplergo.arc.nasa.gov/PyKE.shtml>`_. :param float ra: The right ascension :param float dec: The declination :returns: The same values, but in decimal degrees
[ "Convert", "sexadecimal", "hours", "to", "decimal", "degrees", ".", "Adapted", "from", "PyKE", "<http", ":", "//", "keplergo", ".", "arc", ".", "nasa", ".", "gov", "/", "PyKE", ".", "shtml", ">", "_", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L457-L488
rodluger/everest
everest/missions/k2/utils.py
GetSources
def GetSources(ID, darcsec=None, stars_only=False): ''' Grabs the EPIC coordinates from the TPF and searches MAST for other EPIC targets within the same aperture. :param int ID: The 9-digit :py:obj:`EPIC` number of the target :param float darcsec: The search radius in arcseconds. \ Defau...
python
def GetSources(ID, darcsec=None, stars_only=False): ''' Grabs the EPIC coordinates from the TPF and searches MAST for other EPIC targets within the same aperture. :param int ID: The 9-digit :py:obj:`EPIC` number of the target :param float darcsec: The search radius in arcseconds. \ Defau...
[ "def", "GetSources", "(", "ID", ",", "darcsec", "=", "None", ",", "stars_only", "=", "False", ")", ":", "client", "=", "kplr", ".", "API", "(", ")", "star", "=", "client", ".", "k2_star", "(", "ID", ")", "tpf", "=", "star", ".", "get_target_pixel_fil...
Grabs the EPIC coordinates from the TPF and searches MAST for other EPIC targets within the same aperture. :param int ID: The 9-digit :py:obj:`EPIC` number of the target :param float darcsec: The search radius in arcseconds. \ Default is four times the largest dimension of the aperture. :par...
[ "Grabs", "the", "EPIC", "coordinates", "from", "the", "TPF", "and", "searches", "MAST", "for", "other", "EPIC", "targets", "within", "the", "same", "aperture", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L491-L542
rodluger/everest
everest/missions/k2/utils.py
GetHiResImage
def GetHiResImage(ID): ''' Queries the Palomar Observatory Sky Survey II catalog to obtain a higher resolution optical image of the star with EPIC number :py:obj:`ID`. ''' # Get the TPF info client = kplr.API() star = client.k2_star(ID) k2ra = star.k2_ra k2dec = star.k2_dec ...
python
def GetHiResImage(ID): ''' Queries the Palomar Observatory Sky Survey II catalog to obtain a higher resolution optical image of the star with EPIC number :py:obj:`ID`. ''' # Get the TPF info client = kplr.API() star = client.k2_star(ID) k2ra = star.k2_ra k2dec = star.k2_dec ...
[ "def", "GetHiResImage", "(", "ID", ")", ":", "# Get the TPF info", "client", "=", "kplr", ".", "API", "(", ")", "star", "=", "client", ".", "k2_star", "(", "ID", ")", "k2ra", "=", "star", ".", "k2_ra", "k2dec", "=", "star", ".", "k2_dec", "tpf", "=",...
Queries the Palomar Observatory Sky Survey II catalog to obtain a higher resolution optical image of the star with EPIC number :py:obj:`ID`.
[ "Queries", "the", "Palomar", "Observatory", "Sky", "Survey", "II", "catalog", "to", "obtain", "a", "higher", "resolution", "optical", "image", "of", "the", "star", "with", "EPIC", "number", ":", "py", ":", "obj", ":", "ID", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L545-L615
rodluger/everest
everest/missions/k2/utils.py
SaturationFlux
def SaturationFlux(EPIC, campaign=None, **kwargs): ''' Returns the well depth for the target. If any of the target's pixels have flux larger than this value, they are likely to be saturated and cause charge bleeding. The well depths were obtained from Table 13 of the Kepler instrument handbook. We a...
python
def SaturationFlux(EPIC, campaign=None, **kwargs): ''' Returns the well depth for the target. If any of the target's pixels have flux larger than this value, they are likely to be saturated and cause charge bleeding. The well depths were obtained from Table 13 of the Kepler instrument handbook. We a...
[ "def", "SaturationFlux", "(", "EPIC", ",", "campaign", "=", "None", ",", "*", "*", "kwargs", ")", ":", "channel", ",", "well_depth", "=", "np", ".", "loadtxt", "(", "os", ".", "path", ".", "join", "(", "EVEREST_SRC", ",", "'missions'", ",", "'k2'", "...
Returns the well depth for the target. If any of the target's pixels have flux larger than this value, they are likely to be saturated and cause charge bleeding. The well depths were obtained from Table 13 of the Kepler instrument handbook. We assume an exposure time of 6.02s.
[ "Returns", "the", "well", "depth", "for", "the", "target", ".", "If", "any", "of", "the", "target", "s", "pixels", "have", "flux", "larger", "than", "this", "value", "they", "are", "likely", "to", "be", "saturated", "and", "cause", "charge", "bleeding", ...
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L627-L641
rodluger/everest
everest/missions/k2/sysrem.py
GetChunk
def GetChunk(time, breakpoints, b, mask=[]): ''' Returns the indices corresponding to a given light curve chunk. :param int b: The index of the chunk to return ''' M = np.delete(np.arange(len(time)), mask, axis=0) if b > 0: res = M[(M > breakpoints[b - 1]) & (M <= breakpoints[b])] ...
python
def GetChunk(time, breakpoints, b, mask=[]): ''' Returns the indices corresponding to a given light curve chunk. :param int b: The index of the chunk to return ''' M = np.delete(np.arange(len(time)), mask, axis=0) if b > 0: res = M[(M > breakpoints[b - 1]) & (M <= breakpoints[b])] ...
[ "def", "GetChunk", "(", "time", ",", "breakpoints", ",", "b", ",", "mask", "=", "[", "]", ")", ":", "M", "=", "np", ".", "delete", "(", "np", ".", "arange", "(", "len", "(", "time", ")", ")", ",", "mask", ",", "axis", "=", "0", ")", "if", "...
Returns the indices corresponding to a given light curve chunk. :param int b: The index of the chunk to return
[ "Returns", "the", "indices", "corresponding", "to", "a", "given", "light", "curve", "chunk", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/sysrem.py#L25-L38
rodluger/everest
everest/missions/k2/sysrem.py
GetStars
def GetStars(campaign, module, model='nPLD', **kwargs): ''' Returns de-trended light curves for all stars on a given module in a given campaign. ''' # Get the channel numbers channels = Channels(module) assert channels is not None, "No channels available on this module." # Get the EPI...
python
def GetStars(campaign, module, model='nPLD', **kwargs): ''' Returns de-trended light curves for all stars on a given module in a given campaign. ''' # Get the channel numbers channels = Channels(module) assert channels is not None, "No channels available on this module." # Get the EPI...
[ "def", "GetStars", "(", "campaign", ",", "module", ",", "model", "=", "'nPLD'", ",", "*", "*", "kwargs", ")", ":", "# Get the channel numbers", "channels", "=", "Channels", "(", "module", ")", "assert", "channels", "is", "not", "None", ",", "\"No channels av...
Returns de-trended light curves for all stars on a given module in a given campaign.
[ "Returns", "de", "-", "trended", "light", "curves", "for", "all", "stars", "on", "a", "given", "module", "in", "a", "given", "campaign", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/sysrem.py#L41-L102
rodluger/everest
everest/missions/k2/sysrem.py
SysRem
def SysRem(time, flux, err, ncbv=5, niter=50, sv_win=999, sv_order=3, **kwargs): ''' Applies :py:obj:`SysRem` to a given set of light curves. :param array_like time: The time array for all of the light curves :param array_like flux: A 2D array of the fluxes for each of the light \ ...
python
def SysRem(time, flux, err, ncbv=5, niter=50, sv_win=999, sv_order=3, **kwargs): ''' Applies :py:obj:`SysRem` to a given set of light curves. :param array_like time: The time array for all of the light curves :param array_like flux: A 2D array of the fluxes for each of the light \ ...
[ "def", "SysRem", "(", "time", ",", "flux", ",", "err", ",", "ncbv", "=", "5", ",", "niter", "=", "50", ",", "sv_win", "=", "999", ",", "sv_order", "=", "3", ",", "*", "*", "kwargs", ")", ":", "nflx", ",", "tlen", "=", "flux", ".", "shape", "#...
Applies :py:obj:`SysRem` to a given set of light curves. :param array_like time: The time array for all of the light curves :param array_like flux: A 2D array of the fluxes for each of the light \ curves, shape `(nfluxes, ntime)` :param array_like err: A 2D array of the flux errors for each of t...
[ "Applies", ":", "py", ":", "obj", ":", "SysRem", "to", "a", "given", "set", "of", "light", "curves", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/sysrem.py#L105-L162
rodluger/everest
everest/missions/k2/sysrem.py
GetCBVs
def GetCBVs(campaign, model='nPLD', clobber=False, **kwargs): ''' Computes the CBVs for a given campaign. :param int campaign: The campaign number :param str model: The name of the :py:obj:`everest` model. Default `nPLD` :param bool clobber: Overwrite existing files? Default `False` ''' #...
python
def GetCBVs(campaign, model='nPLD', clobber=False, **kwargs): ''' Computes the CBVs for a given campaign. :param int campaign: The campaign number :param str model: The name of the :py:obj:`everest` model. Default `nPLD` :param bool clobber: Overwrite existing files? Default `False` ''' #...
[ "def", "GetCBVs", "(", "campaign", ",", "model", "=", "'nPLD'", ",", "clobber", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# Initialize logging?", "if", "len", "(", "logging", ".", "getLogger", "(", ")", ".", "handlers", ")", "==", "0", ":", "...
Computes the CBVs for a given campaign. :param int campaign: The campaign number :param str model: The name of the :py:obj:`everest` model. Default `nPLD` :param bool clobber: Overwrite existing files? Default `False`
[ "Computes", "the", "CBVs", "for", "a", "given", "campaign", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/sysrem.py#L165-L263
lsbardel/python-stdnet
stdnet/backends/redisb/client/extensions.py
read_lua_file
def read_lua_file(dotted_module, path=None, context=None): '''Load lua script from the stdnet/lib/lua directory''' path = path or DEFAULT_LUA_PATH bits = dotted_module.split('.') bits[-1] += '.lua' name = os.path.join(path, *bits) with open(name) as f: data = f.read() if cont...
python
def read_lua_file(dotted_module, path=None, context=None): '''Load lua script from the stdnet/lib/lua directory''' path = path or DEFAULT_LUA_PATH bits = dotted_module.split('.') bits[-1] += '.lua' name = os.path.join(path, *bits) with open(name) as f: data = f.read() if cont...
[ "def", "read_lua_file", "(", "dotted_module", ",", "path", "=", "None", ",", "context", "=", "None", ")", ":", "path", "=", "path", "or", "DEFAULT_LUA_PATH", "bits", "=", "dotted_module", ".", "split", "(", "'.'", ")", "bits", "[", "-", "1", "]", "+=",...
Load lua script from the stdnet/lib/lua directory
[ "Load", "lua", "script", "from", "the", "stdnet", "/", "lib", "/", "lua", "directory" ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/extensions.py#L46-L56
lsbardel/python-stdnet
stdnet/backends/redisb/client/extensions.py
parse_info
def parse_info(response): '''Parse the response of Redis's INFO command into a Python dict. In doing so, convert byte data into unicode.''' info = {} response = response.decode('utf-8') def get_value(value): if ',' and '=' not in value: return value sub_dict = {} ...
python
def parse_info(response): '''Parse the response of Redis's INFO command into a Python dict. In doing so, convert byte data into unicode.''' info = {} response = response.decode('utf-8') def get_value(value): if ',' and '=' not in value: return value sub_dict = {} ...
[ "def", "parse_info", "(", "response", ")", ":", "info", "=", "{", "}", "response", "=", "response", ".", "decode", "(", "'utf-8'", ")", "def", "get_value", "(", "value", ")", ":", "if", "','", "and", "'='", "not", "in", "value", ":", "return", "value...
Parse the response of Redis's INFO command into a Python dict. In doing so, convert byte data into unicode.
[ "Parse", "the", "response", "of", "Redis", "s", "INFO", "command", "into", "a", "Python", "dict", ".", "In", "doing", "so", "convert", "byte", "data", "into", "unicode", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/extensions.py#L59-L88
lsbardel/python-stdnet
stdnet/backends/redisb/client/extensions.py
RedisExtensionsMixin.zdiffstore
def zdiffstore(self, dest, keys, withscores=False): '''Compute the difference of multiple sorted. The difference of sets specified by ``keys`` into a new sorted set in ``dest``. ''' keys = (dest,) + tuple(keys) wscores = 'withscores' if withscores else '' ...
python
def zdiffstore(self, dest, keys, withscores=False): '''Compute the difference of multiple sorted. The difference of sets specified by ``keys`` into a new sorted set in ``dest``. ''' keys = (dest,) + tuple(keys) wscores = 'withscores' if withscores else '' ...
[ "def", "zdiffstore", "(", "self", ",", "dest", ",", "keys", ",", "withscores", "=", "False", ")", ":", "keys", "=", "(", "dest", ",", ")", "+", "tuple", "(", "keys", ")", "wscores", "=", "'withscores'", "if", "withscores", "else", "''", "return", "se...
Compute the difference of multiple sorted. The difference of sets specified by ``keys`` into a new sorted set in ``dest``.
[ "Compute", "the", "difference", "of", "multiple", "sorted", ".", "The", "difference", "of", "sets", "specified", "by", "keys", "into", "a", "new", "sorted", "set", "in", "dest", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/extensions.py#L156-L165
lsbardel/python-stdnet
stdnet/backends/redisb/client/extensions.py
RedisExtensionsMixin.zpopbyrank
def zpopbyrank(self, name, start, stop=None, withscores=False, desc=False): '''Pop a range by rank. ''' stop = stop if stop is not None else start return self.execute_script('zpop', (name,), 'rank', start, stop, int(desc), int(withscores), ...
python
def zpopbyrank(self, name, start, stop=None, withscores=False, desc=False): '''Pop a range by rank. ''' stop = stop if stop is not None else start return self.execute_script('zpop', (name,), 'rank', start, stop, int(desc), int(withscores), ...
[ "def", "zpopbyrank", "(", "self", ",", "name", ",", "start", ",", "stop", "=", "None", ",", "withscores", "=", "False", ",", "desc", "=", "False", ")", ":", "stop", "=", "stop", "if", "stop", "is", "not", "None", "else", "start", "return", "self", ...
Pop a range by rank.
[ "Pop", "a", "range", "by", "rank", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/extensions.py#L167-L173
lsbardel/python-stdnet
stdnet/backends/redisb/client/extensions.py
RedisDbManager.delete
def delete(self, instance): '''Delete an instance''' flushdb(self.client) if flushdb else self.client.flushdb()
python
def delete(self, instance): '''Delete an instance''' flushdb(self.client) if flushdb else self.client.flushdb()
[ "def", "delete", "(", "self", ",", "instance", ")", ":", "flushdb", "(", "self", ".", "client", ")", "if", "flushdb", "else", "self", ".", "client", ".", "flushdb", "(", ")" ]
Delete an instance
[ "Delete", "an", "instance" ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/extensions.py#L432-L434
rodluger/everest
docs/mcmc.py
lnprior
def lnprior(x): """Return the log prior given parameter vector `x`.""" per, t0, b = x if b < -1 or b > 1: return -np.inf elif per < 7 or per > 10: return -np.inf elif t0 < 1978 or t0 > 1979: return -np.inf else: return 0.
python
def lnprior(x): """Return the log prior given parameter vector `x`.""" per, t0, b = x if b < -1 or b > 1: return -np.inf elif per < 7 or per > 10: return -np.inf elif t0 < 1978 or t0 > 1979: return -np.inf else: return 0.
[ "def", "lnprior", "(", "x", ")", ":", "per", ",", "t0", ",", "b", "=", "x", "if", "b", "<", "-", "1", "or", "b", ">", "1", ":", "return", "-", "np", ".", "inf", "elif", "per", "<", "7", "or", "per", ">", "10", ":", "return", "-", "np", ...
Return the log prior given parameter vector `x`.
[ "Return", "the", "log", "prior", "given", "parameter", "vector", "x", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/docs/mcmc.py#L11-L21
rodluger/everest
docs/mcmc.py
lnlike
def lnlike(x, star): """Return the log likelihood given parameter vector `x`.""" ll = lnprior(x) if np.isinf(ll): return ll, (np.nan, np.nan) per, t0, b = x model = TransitModel('b', per=per, t0=t0, b=b, rhos=10.)(star.time) like, d, vard = star.lnlike(model, full_output=True) ll += ...
python
def lnlike(x, star): """Return the log likelihood given parameter vector `x`.""" ll = lnprior(x) if np.isinf(ll): return ll, (np.nan, np.nan) per, t0, b = x model = TransitModel('b', per=per, t0=t0, b=b, rhos=10.)(star.time) like, d, vard = star.lnlike(model, full_output=True) ll += ...
[ "def", "lnlike", "(", "x", ",", "star", ")", ":", "ll", "=", "lnprior", "(", "x", ")", "if", "np", ".", "isinf", "(", "ll", ")", ":", "return", "ll", ",", "(", "np", ".", "nan", ",", "np", ".", "nan", ")", "per", ",", "t0", ",", "b", "=",...
Return the log likelihood given parameter vector `x`.
[ "Return", "the", "log", "likelihood", "given", "parameter", "vector", "x", "." ]
train
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/docs/mcmc.py#L24-L33
lsbardel/python-stdnet
examples/permissions.py
GroupManager.check_user
def check_user(self, username, email): '''username and email (if provided) must be unique.''' users = self.router.user avail = yield users.filter(username=username).count() if avail: raise FieldError('Username %s not available' % username) if email: avail ...
python
def check_user(self, username, email): '''username and email (if provided) must be unique.''' users = self.router.user avail = yield users.filter(username=username).count() if avail: raise FieldError('Username %s not available' % username) if email: avail ...
[ "def", "check_user", "(", "self", ",", "username", ",", "email", ")", ":", "users", "=", "self", ".", "router", ".", "user", "avail", "=", "yield", "users", ".", "filter", "(", "username", "=", "username", ")", ".", "count", "(", ")", "if", "avail", ...
username and email (if provided) must be unique.
[ "username", "and", "email", "(", "if", "provided", ")", "must", "be", "unique", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/permissions.py#L150-L159
lsbardel/python-stdnet
examples/permissions.py
GroupManager.permitted_query
def permitted_query(self, query, group, operations): '''Change the ``query`` so that only instances for which ``group`` has roles with permission on ``operations`` are returned.''' session = query.session models = session.router user = group.user if user.is_superuser: # super-u...
python
def permitted_query(self, query, group, operations): '''Change the ``query`` so that only instances for which ``group`` has roles with permission on ``operations`` are returned.''' session = query.session models = session.router user = group.user if user.is_superuser: # super-u...
[ "def", "permitted_query", "(", "self", ",", "query", ",", "group", ",", "operations", ")", ":", "session", "=", "query", ".", "session", "models", "=", "session", ".", "router", "user", "=", "group", ".", "user", "if", "user", ".", "is_superuser", ":", ...
Change the ``query`` so that only instances for which ``group`` has roles with permission on ``operations`` are returned.
[ "Change", "the", "query", "so", "that", "only", "instances", "for", "which", "group", "has", "roles", "with", "permission", "on", "operations", "are", "returned", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/permissions.py#L168-L202
lsbardel/python-stdnet
examples/permissions.py
Subject.create_role
def create_role(self, name): '''Create a new :class:`Role` owned by this :class:`Subject`''' models = self.session.router return models.role.new(name=name, owner=self)
python
def create_role(self, name): '''Create a new :class:`Role` owned by this :class:`Subject`''' models = self.session.router return models.role.new(name=name, owner=self)
[ "def", "create_role", "(", "self", ",", "name", ")", ":", "models", "=", "self", ".", "session", ".", "router", "return", "models", ".", "role", ".", "new", "(", "name", "=", "name", ",", "owner", "=", "self", ")" ]
Create a new :class:`Role` owned by this :class:`Subject`
[ "Create", "a", "new", ":", "class", ":", "Role", "owned", "by", "this", ":", "class", ":", "Subject" ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/permissions.py#L208-L211
lsbardel/python-stdnet
examples/permissions.py
Subject.assign
def assign(self, role): '''Assign :class:`Role` ``role`` to this :class:`Subject`. If this :class:`Subject` is the :attr:`Role.owner`, this method does nothing.''' if role.owner_id != self.id: return self.roles.add(role)
python
def assign(self, role): '''Assign :class:`Role` ``role`` to this :class:`Subject`. If this :class:`Subject` is the :attr:`Role.owner`, this method does nothing.''' if role.owner_id != self.id: return self.roles.add(role)
[ "def", "assign", "(", "self", ",", "role", ")", ":", "if", "role", ".", "owner_id", "!=", "self", ".", "id", ":", "return", "self", ".", "roles", ".", "add", "(", "role", ")" ]
Assign :class:`Role` ``role`` to this :class:`Subject`. If this :class:`Subject` is the :attr:`Role.owner`, this method does nothing.
[ "Assign", ":", "class", ":", "Role", "role", "to", "this", ":", "class", ":", "Subject", ".", "If", "this", ":", "class", ":", "Subject", "is", "the", ":", "attr", ":", "Role", ".", "owner", "this", "method", "does", "nothing", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/permissions.py#L213-L217
lsbardel/python-stdnet
examples/permissions.py
Subject.has_permissions
def has_permissions(self, object, group, operations): '''Check if this :class:`Subject` has permissions for ``operations`` on an ``object``. It returns the number of valid permissions.''' if self.is_superuser: return 1 else: models = self.session.router # vali...
python
def has_permissions(self, object, group, operations): '''Check if this :class:`Subject` has permissions for ``operations`` on an ``object``. It returns the number of valid permissions.''' if self.is_superuser: return 1 else: models = self.session.router # vali...
[ "def", "has_permissions", "(", "self", ",", "object", ",", "group", ",", "operations", ")", ":", "if", "self", ".", "is_superuser", ":", "return", "1", "else", ":", "models", "=", "self", ".", "session", ".", "router", "# valid permissions", "query", "=", ...
Check if this :class:`Subject` has permissions for ``operations`` on an ``object``. It returns the number of valid permissions.
[ "Check", "if", "this", ":", "class", ":", "Subject", "has", "permissions", "for", "operations", "on", "an", "object", ".", "It", "returns", "the", "number", "of", "valid", "permissions", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/permissions.py#L219-L230
lsbardel/python-stdnet
examples/permissions.py
Role.add_permission
def add_permission(self, resource, operation): '''Add a new :class:`Permission` for ``resource`` to perform an ``operation``. The resource can be either an object or a model.''' if isclass(resource): model_type = resource pk = '' else: model_type = resource.__...
python
def add_permission(self, resource, operation): '''Add a new :class:`Permission` for ``resource`` to perform an ``operation``. The resource can be either an object or a model.''' if isclass(resource): model_type = resource pk = '' else: model_type = resource.__...
[ "def", "add_permission", "(", "self", ",", "resource", ",", "operation", ")", ":", "if", "isclass", "(", "resource", ")", ":", "model_type", "=", "resource", "pk", "=", "''", "else", ":", "model_type", "=", "resource", ".", "__class__", "pk", "=", "resou...
Add a new :class:`Permission` for ``resource`` to perform an ``operation``. The resource can be either an object or a model.
[ "Add", "a", "new", ":", "class", ":", "Permission", "for", "resource", "to", "perform", "an", "operation", ".", "The", "resource", "can", "be", "either", "an", "object", "or", "a", "model", "." ]
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/permissions.py#L305-L325
rbw/flask-snow
flask_snow/__init__.py
Snow.init_app
def init_app(self, app, session=None, parameters=None): """Initializes snow extension Set config default and find out which client type to use :param app: App passed from constructor or directly to init_app (factory) :param session: requests-compatible session to pass along to init_app...
python
def init_app(self, app, session=None, parameters=None): """Initializes snow extension Set config default and find out which client type to use :param app: App passed from constructor or directly to init_app (factory) :param session: requests-compatible session to pass along to init_app...
[ "def", "init_app", "(", "self", ",", "app", ",", "session", "=", "None", ",", "parameters", "=", "None", ")", ":", "if", "parameters", "is", "not", "None", "and", "not", "isinstance", "(", "parameters", ",", "ParamsBuilder", ")", ":", "raise", "InvalidUs...
Initializes snow extension Set config default and find out which client type to use :param app: App passed from constructor or directly to init_app (factory) :param session: requests-compatible session to pass along to init_app :param parameters: `ParamsBuilder` object passed to `Clien...
[ "Initializes", "snow", "extension" ]
train
https://github.com/rbw/flask-snow/blob/8efae4c276c95044e67e41bccba1f24f9f8ef75e/flask_snow/__init__.py#L43-L74
rbw/flask-snow
flask_snow/__init__.py
Snow.connection
def connection(self): """Snow connection instance, stores a `pysnow.Client` instance and `pysnow.Resource` instances Creates a new :class:`pysnow.Client` object if it doesn't exist in the app slice of the context stack :returns: :class:`pysnow.Client` object """ ctx = stack.to...
python
def connection(self): """Snow connection instance, stores a `pysnow.Client` instance and `pysnow.Resource` instances Creates a new :class:`pysnow.Client` object if it doesn't exist in the app slice of the context stack :returns: :class:`pysnow.Client` object """ ctx = stack.to...
[ "def", "connection", "(", "self", ")", ":", "ctx", "=", "stack", ".", "top", ".", "app", "if", "ctx", "is", "not", "None", ":", "if", "not", "hasattr", "(", "ctx", ",", "'snow'", ")", ":", "if", "self", ".", "_client_type_oauth", ":", "if", "not", ...
Snow connection instance, stores a `pysnow.Client` instance and `pysnow.Resource` instances Creates a new :class:`pysnow.Client` object if it doesn't exist in the app slice of the context stack :returns: :class:`pysnow.Client` object
[ "Snow", "connection", "instance", "stores", "a", "pysnow", ".", "Client", "instance", "and", "pysnow", ".", "Resource", "instances" ]
train
https://github.com/rbw/flask-snow/blob/8efae4c276c95044e67e41bccba1f24f9f8ef75e/flask_snow/__init__.py#L126-L151
behalf-oss/behave2cucumber
behave2cucumber/__main__.py
usage
def usage(): """Print out a usage message""" global options l = len(options['long']) options['shortlist'] = [s for s in options['short'] if s is not ":"] print("python -m behave2cucumber [-h] [-d level|--debug=level]") for i in range(l): print(" -{0}|--{1:20} {2}".format(options['sh...
python
def usage(): """Print out a usage message""" global options l = len(options['long']) options['shortlist'] = [s for s in options['short'] if s is not ":"] print("python -m behave2cucumber [-h] [-d level|--debug=level]") for i in range(l): print(" -{0}|--{1:20} {2}".format(options['sh...
[ "def", "usage", "(", ")", ":", "global", "options", "l", "=", "len", "(", "options", "[", "'long'", "]", ")", "options", "[", "'shortlist'", "]", "=", "[", "s", "for", "s", "in", "options", "[", "'short'", "]", "if", "s", "is", "not", "\":\"", "]...
Print out a usage message
[ "Print", "out", "a", "usage", "message" ]
train
https://github.com/behalf-oss/behave2cucumber/blob/a0ce3ebb8b2cd9bff5ba14c81e73dba7be36e657/behave2cucumber/__main__.py#L44-L53
behalf-oss/behave2cucumber
behave2cucumber/__main__.py
main
def main(argv): """Main""" global options opts = None try: opts, args = getopt.getopt(argv, options['short'], options['long']) except getopt.GetoptError: usage() exit(2) for opt, arg in opts: if opt in ("-h", "--help"): usage() exit() ...
python
def main(argv): """Main""" global options opts = None try: opts, args = getopt.getopt(argv, options['short'], options['long']) except getopt.GetoptError: usage() exit(2) for opt, arg in opts: if opt in ("-h", "--help"): usage() exit() ...
[ "def", "main", "(", "argv", ")", ":", "global", "options", "opts", "=", "None", "try", ":", "opts", ",", "args", "=", "getopt", ".", "getopt", "(", "argv", ",", "options", "[", "'short'", "]", ",", "options", "[", "'long'", "]", ")", "except", "get...
Main
[ "Main" ]
train
https://github.com/behalf-oss/behave2cucumber/blob/a0ce3ebb8b2cd9bff5ba14c81e73dba7be36e657/behave2cucumber/__main__.py#L56-L123
xingjiepan/cylinder_fitting
cylinder_fitting/fitting.py
direction
def direction(theta, phi): '''Return the direction vector of a cylinder defined by the spherical coordinates theta and phi. ''' return np.array([np.cos(phi) * np.sin(theta), np.sin(phi) * np.sin(theta), np.cos(theta)])
python
def direction(theta, phi): '''Return the direction vector of a cylinder defined by the spherical coordinates theta and phi. ''' return np.array([np.cos(phi) * np.sin(theta), np.sin(phi) * np.sin(theta), np.cos(theta)])
[ "def", "direction", "(", "theta", ",", "phi", ")", ":", "return", "np", ".", "array", "(", "[", "np", ".", "cos", "(", "phi", ")", "*", "np", ".", "sin", "(", "theta", ")", ",", "np", ".", "sin", "(", "phi", ")", "*", "np", ".", "sin", "(",...
Return the direction vector of a cylinder defined by the spherical coordinates theta and phi.
[ "Return", "the", "direction", "vector", "of", "a", "cylinder", "defined", "by", "the", "spherical", "coordinates", "theta", "and", "phi", "." ]
train
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L4-L9
xingjiepan/cylinder_fitting
cylinder_fitting/fitting.py
projection_matrix
def projection_matrix(w): '''Return the projection matrix of a direction w.''' return np.identity(3) - np.dot(np.reshape(w, (3,1)), np.reshape(w, (1, 3)))
python
def projection_matrix(w): '''Return the projection matrix of a direction w.''' return np.identity(3) - np.dot(np.reshape(w, (3,1)), np.reshape(w, (1, 3)))
[ "def", "projection_matrix", "(", "w", ")", ":", "return", "np", ".", "identity", "(", "3", ")", "-", "np", ".", "dot", "(", "np", ".", "reshape", "(", "w", ",", "(", "3", ",", "1", ")", ")", ",", "np", ".", "reshape", "(", "w", ",", "(", "1...
Return the projection matrix of a direction w.
[ "Return", "the", "projection", "matrix", "of", "a", "direction", "w", "." ]
train
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L11-L13
xingjiepan/cylinder_fitting
cylinder_fitting/fitting.py
skew_matrix
def skew_matrix(w): '''Return the skew matrix of a direction w.''' return np.array([[0, -w[2], w[1]], [w[2], 0, -w[0]], [-w[1], w[0], 0]])
python
def skew_matrix(w): '''Return the skew matrix of a direction w.''' return np.array([[0, -w[2], w[1]], [w[2], 0, -w[0]], [-w[1], w[0], 0]])
[ "def", "skew_matrix", "(", "w", ")", ":", "return", "np", ".", "array", "(", "[", "[", "0", ",", "-", "w", "[", "2", "]", ",", "w", "[", "1", "]", "]", ",", "[", "w", "[", "2", "]", ",", "0", ",", "-", "w", "[", "0", "]", "]", ",", ...
Return the skew matrix of a direction w.
[ "Return", "the", "skew", "matrix", "of", "a", "direction", "w", "." ]
train
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L15-L19
xingjiepan/cylinder_fitting
cylinder_fitting/fitting.py
calc_A
def calc_A(Ys): '''Return the matrix A from a list of Y vectors.''' return sum(np.dot(np.reshape(Y, (3,1)), np.reshape(Y, (1, 3))) for Y in Ys)
python
def calc_A(Ys): '''Return the matrix A from a list of Y vectors.''' return sum(np.dot(np.reshape(Y, (3,1)), np.reshape(Y, (1, 3))) for Y in Ys)
[ "def", "calc_A", "(", "Ys", ")", ":", "return", "sum", "(", "np", ".", "dot", "(", "np", ".", "reshape", "(", "Y", ",", "(", "3", ",", "1", ")", ")", ",", "np", ".", "reshape", "(", "Y", ",", "(", "1", ",", "3", ")", ")", ")", "for", "Y...
Return the matrix A from a list of Y vectors.
[ "Return", "the", "matrix", "A", "from", "a", "list", "of", "Y", "vectors", "." ]
train
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L21-L24
xingjiepan/cylinder_fitting
cylinder_fitting/fitting.py
calc_A_hat
def calc_A_hat(A, S): '''Return the A_hat matrix of A given the skew matrix S''' return np.dot(S, np.dot(A, np.transpose(S)))
python
def calc_A_hat(A, S): '''Return the A_hat matrix of A given the skew matrix S''' return np.dot(S, np.dot(A, np.transpose(S)))
[ "def", "calc_A_hat", "(", "A", ",", "S", ")", ":", "return", "np", ".", "dot", "(", "S", ",", "np", ".", "dot", "(", "A", ",", "np", ".", "transpose", "(", "S", ")", ")", ")" ]
Return the A_hat matrix of A given the skew matrix S
[ "Return", "the", "A_hat", "matrix", "of", "A", "given", "the", "skew", "matrix", "S" ]
train
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L26-L28
xingjiepan/cylinder_fitting
cylinder_fitting/fitting.py
preprocess_data
def preprocess_data(Xs_raw): '''Translate the center of mass (COM) of the data to the origin. Return the prossed data and the shift of the COM''' n = len(Xs_raw) Xs_raw_mean = sum(X for X in Xs_raw) / n return [X - Xs_raw_mean for X in Xs_raw], Xs_raw_mean
python
def preprocess_data(Xs_raw): '''Translate the center of mass (COM) of the data to the origin. Return the prossed data and the shift of the COM''' n = len(Xs_raw) Xs_raw_mean = sum(X for X in Xs_raw) / n return [X - Xs_raw_mean for X in Xs_raw], Xs_raw_mean
[ "def", "preprocess_data", "(", "Xs_raw", ")", ":", "n", "=", "len", "(", "Xs_raw", ")", "Xs_raw_mean", "=", "sum", "(", "X", "for", "X", "in", "Xs_raw", ")", "/", "n", "return", "[", "X", "-", "Xs_raw_mean", "for", "X", "in", "Xs_raw", "]", ",", ...
Translate the center of mass (COM) of the data to the origin. Return the prossed data and the shift of the COM
[ "Translate", "the", "center", "of", "mass", "(", "COM", ")", "of", "the", "data", "to", "the", "origin", ".", "Return", "the", "prossed", "data", "and", "the", "shift", "of", "the", "COM" ]
train
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L30-L36
xingjiepan/cylinder_fitting
cylinder_fitting/fitting.py
G
def G(w, Xs): '''Calculate the G function given a cylinder direction w and a list of data points Xs to be fitted.''' n = len(Xs) P = projection_matrix(w) Ys = [np.dot(P, X) for X in Xs] A = calc_A(Ys) A_hat = calc_A_hat(A, skew_matrix(w)) u = sum(np.dot(Y, Y) for Y in Ys) / n v...
python
def G(w, Xs): '''Calculate the G function given a cylinder direction w and a list of data points Xs to be fitted.''' n = len(Xs) P = projection_matrix(w) Ys = [np.dot(P, X) for X in Xs] A = calc_A(Ys) A_hat = calc_A_hat(A, skew_matrix(w)) u = sum(np.dot(Y, Y) for Y in Ys) / n v...
[ "def", "G", "(", "w", ",", "Xs", ")", ":", "n", "=", "len", "(", "Xs", ")", "P", "=", "projection_matrix", "(", "w", ")", "Ys", "=", "[", "np", ".", "dot", "(", "P", ",", "X", ")", "for", "X", "in", "Xs", "]", "A", "=", "calc_A", "(", "...
Calculate the G function given a cylinder direction w and a list of data points Xs to be fitted.
[ "Calculate", "the", "G", "function", "given", "a", "cylinder", "direction", "w", "and", "a", "list", "of", "data", "points", "Xs", "to", "be", "fitted", "." ]
train
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L38-L51
xingjiepan/cylinder_fitting
cylinder_fitting/fitting.py
C
def C(w, Xs): '''Calculate the cylinder center given the cylinder direction and a list of data points. ''' n = len(Xs) P = projection_matrix(w) Ys = [np.dot(P, X) for X in Xs] A = calc_A(Ys) A_hat = calc_A_hat(A, skew_matrix(w)) return np.dot(A_hat, sum(np.dot(Y, Y) * Y for Y in Ys...
python
def C(w, Xs): '''Calculate the cylinder center given the cylinder direction and a list of data points. ''' n = len(Xs) P = projection_matrix(w) Ys = [np.dot(P, X) for X in Xs] A = calc_A(Ys) A_hat = calc_A_hat(A, skew_matrix(w)) return np.dot(A_hat, sum(np.dot(Y, Y) * Y for Y in Ys...
[ "def", "C", "(", "w", ",", "Xs", ")", ":", "n", "=", "len", "(", "Xs", ")", "P", "=", "projection_matrix", "(", "w", ")", "Ys", "=", "[", "np", ".", "dot", "(", "P", ",", "X", ")", "for", "X", "in", "Xs", "]", "A", "=", "calc_A", "(", "...
Calculate the cylinder center given the cylinder direction and a list of data points.
[ "Calculate", "the", "cylinder", "center", "given", "the", "cylinder", "direction", "and", "a", "list", "of", "data", "points", "." ]
train
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L53-L63
xingjiepan/cylinder_fitting
cylinder_fitting/fitting.py
r
def r(w, Xs): '''Calculate the radius given the cylinder direction and a list of data points. ''' n = len(Xs) P = projection_matrix(w) c = C(w, Xs) return np.sqrt(sum(np.dot(c - X, np.dot(P, c - X)) for X in Xs) / n)
python
def r(w, Xs): '''Calculate the radius given the cylinder direction and a list of data points. ''' n = len(Xs) P = projection_matrix(w) c = C(w, Xs) return np.sqrt(sum(np.dot(c - X, np.dot(P, c - X)) for X in Xs) / n)
[ "def", "r", "(", "w", ",", "Xs", ")", ":", "n", "=", "len", "(", "Xs", ")", "P", "=", "projection_matrix", "(", "w", ")", "c", "=", "C", "(", "w", ",", "Xs", ")", "return", "np", ".", "sqrt", "(", "sum", "(", "np", ".", "dot", "(", "c", ...
Calculate the radius given the cylinder direction and a list of data points.
[ "Calculate", "the", "radius", "given", "the", "cylinder", "direction", "and", "a", "list", "of", "data", "points", "." ]
train
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L65-L73
xingjiepan/cylinder_fitting
cylinder_fitting/fitting.py
fit
def fit(data, guess_angles=None): '''Fit a list of data points to a cylinder surface. The algorithm implemented here is from David Eberly's paper "Fitting 3D Data with a Cylinder" from https://www.geometrictools.com/Documentation/CylinderFitting.pdf Arguments: data - A list of 3D data points t...
python
def fit(data, guess_angles=None): '''Fit a list of data points to a cylinder surface. The algorithm implemented here is from David Eberly's paper "Fitting 3D Data with a Cylinder" from https://www.geometrictools.com/Documentation/CylinderFitting.pdf Arguments: data - A list of 3D data points t...
[ "def", "fit", "(", "data", ",", "guess_angles", "=", "None", ")", ":", "Xs", ",", "t", "=", "preprocess_data", "(", "data", ")", "# Set the start points", "start_points", "=", "[", "(", "0", ",", "0", ")", ",", "(", "np", ".", "pi", "/", "2", ",", ...
Fit a list of data points to a cylinder surface. The algorithm implemented here is from David Eberly's paper "Fitting 3D Data with a Cylinder" from https://www.geometrictools.com/Documentation/CylinderFitting.pdf Arguments: data - A list of 3D data points to be fitted. guess_angles[0] - Gu...
[ "Fit", "a", "list", "of", "data", "points", "to", "a", "cylinder", "surface", ".", "The", "algorithm", "implemented", "here", "is", "from", "David", "Eberly", "s", "paper", "Fitting", "3D", "Data", "with", "a", "Cylinder", "from", "https", ":", "//", "ww...
train
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L75-L114
s4int/robotframework-KafkaLibrary
KafkaLibrary/Producer.py
Producer.connect_producer
def connect_producer(self, bootstrap_servers='127.0.0.1:9092', client_id='Robot', **kwargs): """A Kafka client that publishes records to the Kafka cluster. Keyword Arguments: - ``bootstrap_servers``: 'host[:port]' string (or list of 'host[:port]' strings) that the producer should ...
python
def connect_producer(self, bootstrap_servers='127.0.0.1:9092', client_id='Robot', **kwargs): """A Kafka client that publishes records to the Kafka cluster. Keyword Arguments: - ``bootstrap_servers``: 'host[:port]' string (or list of 'host[:port]' strings) that the producer should ...
[ "def", "connect_producer", "(", "self", ",", "bootstrap_servers", "=", "'127.0.0.1:9092'", ",", "client_id", "=", "'Robot'", ",", "*", "*", "kwargs", ")", ":", "self", ".", "producer", "=", "KafkaProducer", "(", "bootstrap_servers", "=", "bootstrap_servers", ","...
A Kafka client that publishes records to the Kafka cluster. Keyword Arguments: - ``bootstrap_servers``: 'host[:port]' string (or list of 'host[:port]' strings) that the producer should contact to bootstrap initial cluster metadata. This does not have to be the full node list. ...
[ "A", "Kafka", "client", "that", "publishes", "records", "to", "the", "Kafka", "cluster", ".", "Keyword", "Arguments", ":", "-", "bootstrap_servers", ":", "host", "[", ":", "port", "]", "string", "(", "or", "list", "of", "host", "[", ":", "port", "]", "...
train
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Producer.py#L7-L25
s4int/robotframework-KafkaLibrary
KafkaLibrary/Producer.py
Producer.send
def send(self, topic, value=None, timeout=60, key=None, partition=None, timestamp_ms=None): """Publish a message to a topic. - ``topic`` (str): topic where the message will be published - ``value``: message value. Must be type bytes, or be serializable to bytes via configured value_serializer. ...
python
def send(self, topic, value=None, timeout=60, key=None, partition=None, timestamp_ms=None): """Publish a message to a topic. - ``topic`` (str): topic where the message will be published - ``value``: message value. Must be type bytes, or be serializable to bytes via configured value_serializer. ...
[ "def", "send", "(", "self", ",", "topic", ",", "value", "=", "None", ",", "timeout", "=", "60", ",", "key", "=", "None", ",", "partition", "=", "None", ",", "timestamp_ms", "=", "None", ")", ":", "future", "=", "self", ".", "producer", ".", "send",...
Publish a message to a topic. - ``topic`` (str): topic where the message will be published - ``value``: message value. Must be type bytes, or be serializable to bytes via configured value_serializer. If value is None, key is required and message acts as a `delete`. - ``timeout`` ...
[ "Publish", "a", "message", "to", "a", "topic", "." ]
train
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Producer.py#L27-L44
s4int/robotframework-KafkaLibrary
KafkaLibrary/Consumer.py
Consumer.connect_consumer
def connect_consumer( self, bootstrap_servers='127.0.0.1:9092', client_id='Robot', group_id=None, auto_offset_reset='latest', enable_auto_commit=True, **kwargs ): """Connect kafka consumer. Keyword Arguments: ...
python
def connect_consumer( self, bootstrap_servers='127.0.0.1:9092', client_id='Robot', group_id=None, auto_offset_reset='latest', enable_auto_commit=True, **kwargs ): """Connect kafka consumer. Keyword Arguments: ...
[ "def", "connect_consumer", "(", "self", ",", "bootstrap_servers", "=", "'127.0.0.1:9092'", ",", "client_id", "=", "'Robot'", ",", "group_id", "=", "None", ",", "auto_offset_reset", "=", "'latest'", ",", "enable_auto_commit", "=", "True", ",", "*", "*", "kwargs",...
Connect kafka consumer. Keyword Arguments: - ``bootstrap_servers``: 'host[:port]' string (or list of 'host[:port]' strings) that the consumer should contact to bootstrap initial cluster metadata. This does not have to be the full node list. It just needs to have ...
[ "Connect", "kafka", "consumer", ".", "Keyword", "Arguments", ":", "-", "bootstrap_servers", ":", "host", "[", ":", "port", "]", "string", "(", "or", "list", "of", "host", "[", ":", "port", "]", "strings", ")", "that", "the", "consumer", "should", "contac...
train
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L7-L53
s4int/robotframework-KafkaLibrary
KafkaLibrary/Consumer.py
Consumer.assign_to_topic_partition
def assign_to_topic_partition(self, topic_partition=None): """Assign a list of TopicPartitions to this consumer. - ``partitions`` (list of `TopicPartition`): Assignment for this instance. """ if isinstance(topic_partition, TopicPartition): topic_partition = [topic_p...
python
def assign_to_topic_partition(self, topic_partition=None): """Assign a list of TopicPartitions to this consumer. - ``partitions`` (list of `TopicPartition`): Assignment for this instance. """ if isinstance(topic_partition, TopicPartition): topic_partition = [topic_p...
[ "def", "assign_to_topic_partition", "(", "self", ",", "topic_partition", "=", "None", ")", ":", "if", "isinstance", "(", "topic_partition", ",", "TopicPartition", ")", ":", "topic_partition", "=", "[", "topic_partition", "]", "if", "not", "self", ".", "_is_assig...
Assign a list of TopicPartitions to this consumer. - ``partitions`` (list of `TopicPartition`): Assignment for this instance.
[ "Assign", "a", "list", "of", "TopicPartitions", "to", "this", "consumer", ".", "-", "partitions", "(", "list", "of", "TopicPartition", ")", ":", "Assignment", "for", "this", "instance", "." ]
train
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L75-L84
s4int/robotframework-KafkaLibrary
KafkaLibrary/Consumer.py
Consumer.subscribe_topic
def subscribe_topic(self, topics=[], pattern=None): """Subscribe to a list of topics, or a topic regex pattern. - ``topics`` (list): List of topics for subscription. - ``pattern`` (str): Pattern to match available topics. You must provide either topics or pattern, but not both...
python
def subscribe_topic(self, topics=[], pattern=None): """Subscribe to a list of topics, or a topic regex pattern. - ``topics`` (list): List of topics for subscription. - ``pattern`` (str): Pattern to match available topics. You must provide either topics or pattern, but not both...
[ "def", "subscribe_topic", "(", "self", ",", "topics", "=", "[", "]", ",", "pattern", "=", "None", ")", ":", "if", "not", "isinstance", "(", "topics", ",", "list", ")", ":", "topics", "=", "[", "topics", "]", "self", ".", "consumer", ".", "subscribe",...
Subscribe to a list of topics, or a topic regex pattern. - ``topics`` (list): List of topics for subscription. - ``pattern`` (str): Pattern to match available topics. You must provide either topics or pattern, but not both.
[ "Subscribe", "to", "a", "list", "of", "topics", "or", "a", "topic", "regex", "pattern", ".", "-", "topics", "(", "list", ")", ":", "List", "of", "topics", "for", "subscription", ".", "-", "pattern", "(", "str", ")", ":", "Pattern", "to", "match", "av...
train
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L86-L96
s4int/robotframework-KafkaLibrary
KafkaLibrary/Consumer.py
Consumer.get_position
def get_position(self, topic_partition=None): """Return offset of the next record that will be fetched. - ``topic_partition`` (TopicPartition): Partition to check """ if isinstance(topic_partition, TopicPartition): return self.consumer.position(topic_partition) ...
python
def get_position(self, topic_partition=None): """Return offset of the next record that will be fetched. - ``topic_partition`` (TopicPartition): Partition to check """ if isinstance(topic_partition, TopicPartition): return self.consumer.position(topic_partition) ...
[ "def", "get_position", "(", "self", ",", "topic_partition", "=", "None", ")", ":", "if", "isinstance", "(", "topic_partition", ",", "TopicPartition", ")", ":", "return", "self", ".", "consumer", ".", "position", "(", "topic_partition", ")", "else", ":", "rai...
Return offset of the next record that will be fetched. - ``topic_partition`` (TopicPartition): Partition to check
[ "Return", "offset", "of", "the", "next", "record", "that", "will", "be", "fetched", ".", "-", "topic_partition", "(", "TopicPartition", ")", ":", "Partition", "to", "check" ]
train
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L98-L107
s4int/robotframework-KafkaLibrary
KafkaLibrary/Consumer.py
Consumer.seek
def seek(self, offset, topic_partition=None): """Manually specify the fetch offset for a TopicPartition. - ``offset``: Message offset in partition - ``topic_partition`` (`TopicPartition`): Partition for seek operation """ if isinstance(topic_partition, TopicPartition): ...
python
def seek(self, offset, topic_partition=None): """Manually specify the fetch offset for a TopicPartition. - ``offset``: Message offset in partition - ``topic_partition`` (`TopicPartition`): Partition for seek operation """ if isinstance(topic_partition, TopicPartition): ...
[ "def", "seek", "(", "self", ",", "offset", ",", "topic_partition", "=", "None", ")", ":", "if", "isinstance", "(", "topic_partition", ",", "TopicPartition", ")", ":", "self", ".", "consumer", ".", "seek", "(", "topic_partition", ",", "offset", "=", "offset...
Manually specify the fetch offset for a TopicPartition. - ``offset``: Message offset in partition - ``topic_partition`` (`TopicPartition`): Partition for seek operation
[ "Manually", "specify", "the", "fetch", "offset", "for", "a", "TopicPartition", ".", "-", "offset", ":", "Message", "offset", "in", "partition", "-", "topic_partition", "(", "TopicPartition", ")", ":", "Partition", "for", "seek", "operation" ]
train
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L109-L119
s4int/robotframework-KafkaLibrary
KafkaLibrary/Consumer.py
Consumer.seek_to_beginning
def seek_to_beginning(self, topic_partition=None): """Seek to the oldest available offset for partitions. - ``topic_partition``: Optionally provide specific TopicPartitions, otherwise default to all assigned partitions. """ if isinstance(topic_partition, TopicPartitio...
python
def seek_to_beginning(self, topic_partition=None): """Seek to the oldest available offset for partitions. - ``topic_partition``: Optionally provide specific TopicPartitions, otherwise default to all assigned partitions. """ if isinstance(topic_partition, TopicPartitio...
[ "def", "seek_to_beginning", "(", "self", ",", "topic_partition", "=", "None", ")", ":", "if", "isinstance", "(", "topic_partition", ",", "TopicPartition", ")", ":", "self", ".", "consumer", ".", "seek_to_beginning", "(", "topic_partition", ")", "else", ":", "r...
Seek to the oldest available offset for partitions. - ``topic_partition``: Optionally provide specific TopicPartitions, otherwise default to all assigned partitions.
[ "Seek", "to", "the", "oldest", "available", "offset", "for", "partitions", ".", "-", "topic_partition", ":", "Optionally", "provide", "specific", "TopicPartitions", "otherwise", "default", "to", "all", "assigned", "partitions", "." ]
train
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L121-L131
s4int/robotframework-KafkaLibrary
KafkaLibrary/Consumer.py
Consumer.seek_to_end
def seek_to_end(self, topic_partition=None): """Seek to the most recent available offset for partitions. - ``topic_partition``: Optionally provide specific `TopicPartitions`, otherwise default to all assigned partitions. """ if isinstance(topic_partition, TopicPartiti...
python
def seek_to_end(self, topic_partition=None): """Seek to the most recent available offset for partitions. - ``topic_partition``: Optionally provide specific `TopicPartitions`, otherwise default to all assigned partitions. """ if isinstance(topic_partition, TopicPartiti...
[ "def", "seek_to_end", "(", "self", ",", "topic_partition", "=", "None", ")", ":", "if", "isinstance", "(", "topic_partition", ",", "TopicPartition", ")", ":", "self", ".", "consumer", ".", "seek_to_end", "(", "topic_partition", ")", "else", ":", "raise", "Ty...
Seek to the most recent available offset for partitions. - ``topic_partition``: Optionally provide specific `TopicPartitions`, otherwise default to all assigned partitions.
[ "Seek", "to", "the", "most", "recent", "available", "offset", "for", "partitions", ".", "-", "topic_partition", ":", "Optionally", "provide", "specific", "TopicPartitions", "otherwise", "default", "to", "all", "assigned", "partitions", "." ]
train
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L133-L143
s4int/robotframework-KafkaLibrary
KafkaLibrary/Consumer.py
Consumer.get_number_of_messages_in_topics
def get_number_of_messages_in_topics(self, topics): """Retrun number of messages in topics. - ``topics`` (list): list of topics. """ if not isinstance(topics, list): topics = [topics] number_of_messages = 0 for t in topics: part = self.g...
python
def get_number_of_messages_in_topics(self, topics): """Retrun number of messages in topics. - ``topics`` (list): list of topics. """ if not isinstance(topics, list): topics = [topics] number_of_messages = 0 for t in topics: part = self.g...
[ "def", "get_number_of_messages_in_topics", "(", "self", ",", "topics", ")", ":", "if", "not", "isinstance", "(", "topics", ",", "list", ")", ":", "topics", "=", "[", "topics", "]", "number_of_messages", "=", "0", "for", "t", "in", "topics", ":", "part", ...
Retrun number of messages in topics. - ``topics`` (list): list of topics.
[ "Retrun", "number", "of", "messages", "in", "topics", ".", "-", "topics", "(", "list", ")", ":", "list", "of", "topics", "." ]
train
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L150-L165
s4int/robotframework-KafkaLibrary
KafkaLibrary/Consumer.py
Consumer.get_number_of_messages_in_topicpartition
def get_number_of_messages_in_topicpartition(self, topic_partition=None): """Return number of messages in TopicPartition. - ``topic_partition`` (list of TopicPartition) """ if isinstance(topic_partition, TopicPartition): topic_partition = [topic_partition] ...
python
def get_number_of_messages_in_topicpartition(self, topic_partition=None): """Return number of messages in TopicPartition. - ``topic_partition`` (list of TopicPartition) """ if isinstance(topic_partition, TopicPartition): topic_partition = [topic_partition] ...
[ "def", "get_number_of_messages_in_topicpartition", "(", "self", ",", "topic_partition", "=", "None", ")", ":", "if", "isinstance", "(", "topic_partition", ",", "TopicPartition", ")", ":", "topic_partition", "=", "[", "topic_partition", "]", "number_of_messages", "=", ...
Return number of messages in TopicPartition. - ``topic_partition`` (list of TopicPartition)
[ "Return", "number", "of", "messages", "in", "TopicPartition", ".", "-", "topic_partition", "(", "list", "of", "TopicPartition", ")" ]
train
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L167-L194
s4int/robotframework-KafkaLibrary
KafkaLibrary/Consumer.py
Consumer.poll
def poll(self, timeout_ms=0, max_records=None): """Fetch data from assigned topics / partitions. - ``max_records`` (int): maximum number of records to poll. Default: Inherit value from max_poll_records. - ``timeout_ms`` (int): Milliseconds spent waiting in poll if data is not available ...
python
def poll(self, timeout_ms=0, max_records=None): """Fetch data from assigned topics / partitions. - ``max_records`` (int): maximum number of records to poll. Default: Inherit value from max_poll_records. - ``timeout_ms`` (int): Milliseconds spent waiting in poll if data is not available ...
[ "def", "poll", "(", "self", ",", "timeout_ms", "=", "0", ",", "max_records", "=", "None", ")", ":", "messages", "=", "self", ".", "consumer", ".", "poll", "(", "timeout_ms", "=", "timeout_ms", ",", "max_records", "=", "max_records", ")", "result", "=", ...
Fetch data from assigned topics / partitions. - ``max_records`` (int): maximum number of records to poll. Default: Inherit value from max_poll_records. - ``timeout_ms`` (int): Milliseconds spent waiting in poll if data is not available in the buffer. If 0, returns immediately with any...
[ "Fetch", "data", "from", "assigned", "topics", "/", "partitions", ".", "-", "max_records", "(", "int", ")", ":", "maximum", "number", "of", "records", "to", "poll", ".", "Default", ":", "Inherit", "value", "from", "max_poll_records", ".", "-", "timeout_ms", ...
train
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L196-L211
colab/colab
colab/accounts/views.py
EmailView.get
def get(self, request, key): """Validate an email with the given key""" try: email_val = EmailAddressValidation.objects.get(validation_key=key) except EmailAddressValidation.DoesNotExist: messages.error(request, _('The email address you are trying to ' ...
python
def get(self, request, key): """Validate an email with the given key""" try: email_val = EmailAddressValidation.objects.get(validation_key=key) except EmailAddressValidation.DoesNotExist: messages.error(request, _('The email address you are trying to ' ...
[ "def", "get", "(", "self", ",", "request", ",", "key", ")", ":", "try", ":", "email_val", "=", "EmailAddressValidation", ".", "objects", ".", "get", "(", "validation_key", "=", "key", ")", "except", "EmailAddressValidation", ".", "DoesNotExist", ":", "messag...
Validate an email with the given key
[ "Validate", "an", "email", "with", "the", "given", "key" ]
train
https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/accounts/views.py#L91-L123
colab/colab
colab/accounts/views.py
EmailView.delete
def delete(self, request, key): """Remove an email address, validated or not.""" request.DELETE = http.QueryDict(request.body) email_addr = request.DELETE.get('email') user_id = request.DELETE.get('user') if not email_addr: return http.HttpResponseBadRequest() ...
python
def delete(self, request, key): """Remove an email address, validated or not.""" request.DELETE = http.QueryDict(request.body) email_addr = request.DELETE.get('email') user_id = request.DELETE.get('user') if not email_addr: return http.HttpResponseBadRequest() ...
[ "def", "delete", "(", "self", ",", "request", ",", "key", ")", ":", "request", ".", "DELETE", "=", "http", ".", "QueryDict", "(", "request", ".", "body", ")", "email_addr", "=", "request", ".", "DELETE", ".", "get", "(", "'email'", ")", "user_id", "=...
Remove an email address, validated or not.
[ "Remove", "an", "email", "address", "validated", "or", "not", "." ]
train
https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/accounts/views.py#L151-L178