id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
54,200
caseyjlaw/rtpipe
rtpipe/cli.py
nbcompile
def nbcompile(filename, html, basenb, agdir): """ Compile the baseinteract.ipynb notebook into an analysis notebook for filename """ filename = os.path.abspath(filename) pc.nbcompile(os.path.dirname(filename), os.path.basename(filename), html=html, basenb=basenb, agdir=agdir)
python
def nbcompile(filename, html, basenb, agdir): """ Compile the baseinteract.ipynb notebook into an analysis notebook for filename """ filename = os.path.abspath(filename) pc.nbcompile(os.path.dirname(filename), os.path.basename(filename), html=html, basenb=basenb, agdir=agdir)
[ "def", "nbcompile", "(", "filename", ",", "html", ",", "basenb", ",", "agdir", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "pc", ".", "nbcompile", "(", "os", ".", "path", ".", "dirname", "(", "filename", ")", ...
Compile the baseinteract.ipynb notebook into an analysis notebook for filename
[ "Compile", "the", "baseinteract", ".", "ipynb", "notebook", "into", "an", "analysis", "notebook", "for", "filename" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/cli.py#L105-L110
54,201
phareous/insteonlocal
insteonlocal/Switch.py
Switch.start_all_linking
def start_all_linking(self, link_type, group_id): """Start all linking""" self.logger.info("Start_all_linking for device %s type %s group %s", self.device_id, link_type, group_id) self.hub.direct_command(self.device_id, '02', '64' + link_type + group_id)
python
def start_all_linking(self, link_type, group_id): """Start all linking""" self.logger.info("Start_all_linking for device %s type %s group %s", self.device_id, link_type, group_id) self.hub.direct_command(self.device_id, '02', '64' + link_type + group_id)
[ "def", "start_all_linking", "(", "self", ",", "link_type", ",", "group_id", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Start_all_linking for device %s type %s group %s\"", ",", "self", ".", "device_id", ",", "link_type", ",", "group_id", ")", "self", ...
Start all linking
[ "Start", "all", "linking" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Switch.py#L33-L37
54,202
phareous/insteonlocal
insteonlocal/Switch.py
Switch.cancel_all_linking
def cancel_all_linking(self): """Cancel all linking""" self.logger.info("Cancel_all_linking for device %s", self.device_id) self.hub.direct_command(self.device_id, '02', '65')
python
def cancel_all_linking(self): """Cancel all linking""" self.logger.info("Cancel_all_linking for device %s", self.device_id) self.hub.direct_command(self.device_id, '02', '65')
[ "def", "cancel_all_linking", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Cancel_all_linking for device %s\"", ",", "self", ".", "device_id", ")", "self", ".", "hub", ".", "direct_command", "(", "self", ".", "device_id", ",", "'02'", ",...
Cancel all linking
[ "Cancel", "all", "linking" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Switch.py#L48-L51
54,203
charettes/django-admin-enhancer
admin_enhancer/admin.py
EnhancedAdminMixin.delete_view
def delete_view(self, request, object_id, extra_context=None): """Sets is_popup context variable to hide admin header.""" if not extra_context: extra_context = {} extra_context['is_popup'] = request.REQUEST.get('_popup', 0) return super(EnhancedAdminMixin, self).delete_view(r...
python
def delete_view(self, request, object_id, extra_context=None): """Sets is_popup context variable to hide admin header.""" if not extra_context: extra_context = {} extra_context['is_popup'] = request.REQUEST.get('_popup', 0) return super(EnhancedAdminMixin, self).delete_view(r...
[ "def", "delete_view", "(", "self", ",", "request", ",", "object_id", ",", "extra_context", "=", "None", ")", ":", "if", "not", "extra_context", ":", "extra_context", "=", "{", "}", "extra_context", "[", "'is_popup'", "]", "=", "request", ".", "REQUEST", "....
Sets is_popup context variable to hide admin header.
[ "Sets", "is_popup", "context", "variable", "to", "hide", "admin", "header", "." ]
ed4eb944cd1afafcad4e42f41cfc3de1d8bac4d1
https://github.com/charettes/django-admin-enhancer/blob/ed4eb944cd1afafcad4e42f41cfc3de1d8bac4d1/admin_enhancer/admin.py#L29-L34
54,204
bitprophet/pytest-relaxed
tasks.py
coverage
def coverage(c, html=True): """ Run coverage with coverage.py. """ # NOTE: this MUST use coverage itself, and not pytest-cov, because the # latter is apparently unable to prevent pytest plugins from being loaded # before pytest-cov itself is able to start up coverage.py! The result is # that...
python
def coverage(c, html=True): """ Run coverage with coverage.py. """ # NOTE: this MUST use coverage itself, and not pytest-cov, because the # latter is apparently unable to prevent pytest plugins from being loaded # before pytest-cov itself is able to start up coverage.py! The result is # that...
[ "def", "coverage", "(", "c", ",", "html", "=", "True", ")", ":", "# NOTE: this MUST use coverage itself, and not pytest-cov, because the", "# latter is apparently unable to prevent pytest plugins from being loaded", "# before pytest-cov itself is able to start up coverage.py! The result is",...
Run coverage with coverage.py.
[ "Run", "coverage", "with", "coverage", ".", "py", "." ]
1fb4cecfc516812206a2401e76314aa3226b4d4f
https://github.com/bitprophet/pytest-relaxed/blob/1fb4cecfc516812206a2401e76314aa3226b4d4f/tasks.py#L8-L23
54,205
limpyd/redis-limpyd
limpyd/contrib/related.py
RelatedModel.delete
def delete(self): """ When the instance is deleted, we propagate the deletion to the related collections, which will remove it from the related fields. """ for related_collection_name in self.related_collections: related_collection = getattr(self, related_collection_n...
python
def delete(self): """ When the instance is deleted, we propagate the deletion to the related collections, which will remove it from the related fields. """ for related_collection_name in self.related_collections: related_collection = getattr(self, related_collection_n...
[ "def", "delete", "(", "self", ")", ":", "for", "related_collection_name", "in", "self", ".", "related_collections", ":", "related_collection", "=", "getattr", "(", "self", ",", "related_collection_name", ")", "related_collection", ".", "remove_instance", "(", ")", ...
When the instance is deleted, we propagate the deletion to the related collections, which will remove it from the related fields.
[ "When", "the", "instance", "is", "deleted", "we", "propagate", "the", "deletion", "to", "the", "related", "collections", "which", "will", "remove", "it", "from", "the", "related", "fields", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/related.py#L129-L137
54,206
limpyd/redis-limpyd
limpyd/contrib/related.py
RelatedFieldMixin._attach_to_model
def _attach_to_model(self, model): """ When we have a model, save the relation in the database, to later create RelatedCollection objects in the related model """ super(RelatedFieldMixin, self)._attach_to_model(model) if model.abstract: # do not manage the re...
python
def _attach_to_model(self, model): """ When we have a model, save the relation in the database, to later create RelatedCollection objects in the related model """ super(RelatedFieldMixin, self)._attach_to_model(model) if model.abstract: # do not manage the re...
[ "def", "_attach_to_model", "(", "self", ",", "model", ")", ":", "super", "(", "RelatedFieldMixin", ",", "self", ")", ".", "_attach_to_model", "(", "model", ")", "if", "model", ".", "abstract", ":", "# do not manage the relation if it's an abstract model", "return", ...
When we have a model, save the relation in the database, to later create RelatedCollection objects in the related model
[ "When", "we", "have", "a", "model", "save", "the", "relation", "in", "the", "database", "to", "later", "create", "RelatedCollection", "objects", "in", "the", "related", "model" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/related.py#L238-L265
54,207
limpyd/redis-limpyd
limpyd/contrib/related.py
RelatedFieldMixin._assert_relation_does_not_exists
def _assert_relation_does_not_exists(self): """ Check if a relation with the current related_name doesn't already exists for the related model """ relations = self.database._relations[self.related_to] existing = [r for r in relations if r[2] == self.related_name] ...
python
def _assert_relation_does_not_exists(self): """ Check if a relation with the current related_name doesn't already exists for the related model """ relations = self.database._relations[self.related_to] existing = [r for r in relations if r[2] == self.related_name] ...
[ "def", "_assert_relation_does_not_exists", "(", "self", ")", ":", "relations", "=", "self", ".", "database", ".", "_relations", "[", "self", ".", "related_to", "]", "existing", "=", "[", "r", "for", "r", "in", "relations", "if", "r", "[", "2", "]", "==",...
Check if a relation with the current related_name doesn't already exists for the related model
[ "Check", "if", "a", "relation", "with", "the", "current", "related_name", "doesn", "t", "already", "exists", "for", "the", "related", "model" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/related.py#L267-L278
54,208
limpyd/redis-limpyd
limpyd/contrib/related.py
RelatedFieldMixin.from_python
def from_python(self, value): """ Provide the ability to pass a RedisModel instances or a FK field as value instead of passing the PK. The value will then be translated in the real PK. """ if isinstance(value, model.RedisModel): value = value._pk elif ...
python
def from_python(self, value): """ Provide the ability to pass a RedisModel instances or a FK field as value instead of passing the PK. The value will then be translated in the real PK. """ if isinstance(value, model.RedisModel): value = value._pk elif ...
[ "def", "from_python", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "model", ".", "RedisModel", ")", ":", "value", "=", "value", ".", "_pk", "elif", "isinstance", "(", "value", ",", "SimpleValueRelatedFieldMixin", ")", ":", ...
Provide the ability to pass a RedisModel instances or a FK field as value instead of passing the PK. The value will then be translated in the real PK.
[ "Provide", "the", "ability", "to", "pass", "a", "RedisModel", "instances", "or", "a", "FK", "field", "as", "value", "instead", "of", "passing", "the", "PK", ".", "The", "value", "will", "then", "be", "translated", "in", "the", "real", "PK", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/related.py#L354-L364
54,209
limpyd/redis-limpyd
limpyd/contrib/related.py
SimpleValueRelatedFieldMixin.instance
def instance(self, skip_exist_test=False): """ Returns the instance of the related object linked by the field. """ model = self.database._models[self.related_to] meth = model.lazy_connect if skip_exist_test else model return meth(self.proxy_get())
python
def instance(self, skip_exist_test=False): """ Returns the instance of the related object linked by the field. """ model = self.database._models[self.related_to] meth = model.lazy_connect if skip_exist_test else model return meth(self.proxy_get())
[ "def", "instance", "(", "self", ",", "skip_exist_test", "=", "False", ")", ":", "model", "=", "self", ".", "database", ".", "_models", "[", "self", ".", "related_to", "]", "meth", "=", "model", ".", "lazy_connect", "if", "skip_exist_test", "else", "model",...
Returns the instance of the related object linked by the field.
[ "Returns", "the", "instance", "of", "the", "related", "object", "linked", "by", "the", "field", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/related.py#L419-L425
54,210
limpyd/redis-limpyd
limpyd/contrib/database.py
PipelineDatabase.transaction
def transaction(self, func, *watches, **kwargs): """ Convenience method for executing the callable `func` as a transaction while watching all keys specified in `watches`. The 'func' callable should expect a single arguement which is a Pipeline object. """ with self.pipeli...
python
def transaction(self, func, *watches, **kwargs): """ Convenience method for executing the callable `func` as a transaction while watching all keys specified in `watches`. The 'func' callable should expect a single arguement which is a Pipeline object. """ with self.pipeli...
[ "def", "transaction", "(", "self", ",", "func", ",", "*", "watches", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "pipeline", "(", "True", ",", "share_in_threads", "=", "kwargs", ".", "get", "(", "'share_in_threads'", ",", "False", ")", ")",...
Convenience method for executing the callable `func` as a transaction while watching all keys specified in `watches`. The 'func' callable should expect a single arguement which is a Pipeline object.
[ "Convenience", "method", "for", "executing", "the", "callable", "func", "as", "a", "transaction", "while", "watching", "all", "keys", "specified", "in", "watches", ".", "The", "func", "callable", "should", "expect", "a", "single", "arguement", "which", "is", "...
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/database.py#L64-L78
54,211
limpyd/redis-limpyd
limpyd/contrib/database.py
PipelineDatabase._connection
def _connection(self): """ If we have a pipeline, shared in thread, or in the good thread, return it else use the direct connection """ if self._pipelined_connection is not None: if self._pipelined_connection.share_in_threads or \ threading.current...
python
def _connection(self): """ If we have a pipeline, shared in thread, or in the good thread, return it else use the direct connection """ if self._pipelined_connection is not None: if self._pipelined_connection.share_in_threads or \ threading.current...
[ "def", "_connection", "(", "self", ")", ":", "if", "self", ".", "_pipelined_connection", "is", "not", "None", ":", "if", "self", ".", "_pipelined_connection", ".", "share_in_threads", "or", "threading", ".", "current_thread", "(", ")", ".", "ident", "==", "s...
If we have a pipeline, shared in thread, or in the good thread, return it else use the direct connection
[ "If", "we", "have", "a", "pipeline", "shared", "in", "thread", "or", "in", "the", "good", "thread", "return", "it", "else", "use", "the", "direct", "connection" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/database.py#L81-L92
54,212
limpyd/redis-limpyd
limpyd/contrib/database.py
PipelineDatabase._connection
def _connection(self, value): """ If the value is a pipeline, save it as the connection to use for pipelines if to be shared in threads or goot thread. Do not remove the direct connection. If it is not a pipeline, clear it, and set the direct connection again. """ if isin...
python
def _connection(self, value): """ If the value is a pipeline, save it as the connection to use for pipelines if to be shared in threads or goot thread. Do not remove the direct connection. If it is not a pipeline, clear it, and set the direct connection again. """ if isin...
[ "def", "_connection", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "_Pipeline", ")", ":", "self", ".", "_pipelined_connection", "=", "value", "else", ":", "self", ".", "_direct_connection", "=", "value", "self", ".", "_pipeli...
If the value is a pipeline, save it as the connection to use for pipelines if to be shared in threads or goot thread. Do not remove the direct connection. If it is not a pipeline, clear it, and set the direct connection again.
[ "If", "the", "value", "is", "a", "pipeline", "save", "it", "as", "the", "connection", "to", "use", "for", "pipelines", "if", "to", "be", "shared", "in", "threads", "or", "goot", "thread", ".", "Do", "not", "remove", "the", "direct", "connection", ".", ...
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/database.py#L95-L105
54,213
limpyd/redis-limpyd
limpyd/contrib/database.py
_Pipeline.watch
def watch(self, *names): """ Override the default watch method to allow the user to pass RedisField objects as names, which will be translated to their real keys and passed to the default watch method """ watches = [] for watch in names: if isinstance(...
python
def watch(self, *names): """ Override the default watch method to allow the user to pass RedisField objects as names, which will be translated to their real keys and passed to the default watch method """ watches = [] for watch in names: if isinstance(...
[ "def", "watch", "(", "self", ",", "*", "names", ")", ":", "watches", "=", "[", "]", "for", "watch", "in", "names", ":", "if", "isinstance", "(", "watch", ",", "RedisField", ")", ":", "watch", "=", "watch", ".", "key", "watches", ".", "append", "(",...
Override the default watch method to allow the user to pass RedisField objects as names, which will be translated to their real keys and passed to the default watch method
[ "Override", "the", "default", "watch", "method", "to", "allow", "the", "user", "to", "pass", "RedisField", "objects", "as", "names", "which", "will", "be", "translated", "to", "their", "real", "keys", "and", "passed", "to", "the", "default", "watch", "method...
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/database.py#L128-L139
54,214
caseyjlaw/rtpipe
rtpipe/parsecands.py
read_candidates
def read_candidates(candsfile, snrmin=0, snrmax=999, returnstate=False): """ Reads candidate file and returns data as python object. candsfile is pkl file (for now) with (1) state dict and (2) cands object. cands object can either be a dictionary or tuple of two numpy arrays. Return tuple of two n...
python
def read_candidates(candsfile, snrmin=0, snrmax=999, returnstate=False): """ Reads candidate file and returns data as python object. candsfile is pkl file (for now) with (1) state dict and (2) cands object. cands object can either be a dictionary or tuple of two numpy arrays. Return tuple of two n...
[ "def", "read_candidates", "(", "candsfile", ",", "snrmin", "=", "0", ",", "snrmax", "=", "999", ",", "returnstate", "=", "False", ")", ":", "# read in pickle file of candidates", "assert", "os", ".", "path", ".", "exists", "(", "candsfile", ")", "try", ":", ...
Reads candidate file and returns data as python object. candsfile is pkl file (for now) with (1) state dict and (2) cands object. cands object can either be a dictionary or tuple of two numpy arrays. Return tuple of two numpy arrays (location, properties). returned values can be filtered by snrmin...
[ "Reads", "candidate", "file", "and", "returns", "data", "as", "python", "object", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecands.py#L13-L83
54,215
caseyjlaw/rtpipe
rtpipe/parsecands.py
read_noise
def read_noise(noisefile): """ Function to read a noise file and parse columns. Works with both per-scan and merged noise files. """ noises = pickle.load(open(noisefile, 'r')) scan = []; seg = []; noiseperbl = []; flagfrac = []; imnoise = [] if len(noises[0]) == 4: for noise in noises:...
python
def read_noise(noisefile): """ Function to read a noise file and parse columns. Works with both per-scan and merged noise files. """ noises = pickle.load(open(noisefile, 'r')) scan = []; seg = []; noiseperbl = []; flagfrac = []; imnoise = [] if len(noises[0]) == 4: for noise in noises:...
[ "def", "read_noise", "(", "noisefile", ")", ":", "noises", "=", "pickle", ".", "load", "(", "open", "(", "noisefile", ",", "'r'", ")", ")", "scan", "=", "[", "]", "seg", "=", "[", "]", "noiseperbl", "=", "[", "]", "flagfrac", "=", "[", "]", "imno...
Function to read a noise file and parse columns. Works with both per-scan and merged noise files.
[ "Function", "to", "read", "a", "noise", "file", "and", "parse", "columns", ".", "Works", "with", "both", "per", "-", "scan", "and", "merged", "noise", "files", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecands.py#L86-L106
54,216
caseyjlaw/rtpipe
rtpipe/parsecands.py
merge_noises
def merge_noises(pkllist, outroot=''): """ Merge noise files from multiple segments. Output noise file has scan number at start of each entry. """ assert isinstance(pkllist, list), "pkllist must be list of file names" if not outroot: outroot = '_'.join(pkllist[0].split('_')[1:-1]) work...
python
def merge_noises(pkllist, outroot=''): """ Merge noise files from multiple segments. Output noise file has scan number at start of each entry. """ assert isinstance(pkllist, list), "pkllist must be list of file names" if not outroot: outroot = '_'.join(pkllist[0].split('_')[1:-1]) work...
[ "def", "merge_noises", "(", "pkllist", ",", "outroot", "=", "''", ")", ":", "assert", "isinstance", "(", "pkllist", ",", "list", ")", ",", "\"pkllist must be list of file names\"", "if", "not", "outroot", ":", "outroot", "=", "'_'", ".", "join", "(", "pkllis...
Merge noise files from multiple segments. Output noise file has scan number at start of each entry.
[ "Merge", "noise", "files", "from", "multiple", "segments", ".", "Output", "noise", "file", "has", "scan", "number", "at", "start", "of", "each", "entry", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecands.py#L211-L243
54,217
caseyjlaw/rtpipe
rtpipe/parsecands.py
split_candidates
def split_candidates(candsfile, featind1, featind2, candsfile1, candsfile2): """ Split features from one candsfile into two new candsfiles featind1/2 is list of indices to take from d['features']. New features and updated state dict go to candsfile1/2. """ with open(candsfile, 'rb') as pkl: ...
python
def split_candidates(candsfile, featind1, featind2, candsfile1, candsfile2): """ Split features from one candsfile into two new candsfiles featind1/2 is list of indices to take from d['features']. New features and updated state dict go to candsfile1/2. """ with open(candsfile, 'rb') as pkl: ...
[ "def", "split_candidates", "(", "candsfile", ",", "featind1", ",", "featind2", ",", "candsfile1", ",", "candsfile2", ")", ":", "with", "open", "(", "candsfile", ",", "'rb'", ")", "as", "pkl", ":", "d", "=", "pickle", ".", "load", "(", "pkl", ")", "cand...
Split features from one candsfile into two new candsfiles featind1/2 is list of indices to take from d['features']. New features and updated state dict go to candsfile1/2.
[ "Split", "features", "from", "one", "candsfile", "into", "two", "new", "candsfiles" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecands.py#L339-L368
54,218
caseyjlaw/rtpipe
rtpipe/parsecands.py
nbcompile
def nbcompile(workdir, fileroot, html=True, basenb='', agdir=''): """ Run analysis pipeline from jupyter base notebook and save as notebook and html. html will also compile static html version basenb can be provided, else will get distributed version. agdir is the activegit repo (optional) """ ...
python
def nbcompile(workdir, fileroot, html=True, basenb='', agdir=''): """ Run analysis pipeline from jupyter base notebook and save as notebook and html. html will also compile static html version basenb can be provided, else will get distributed version. agdir is the activegit repo (optional) """ ...
[ "def", "nbcompile", "(", "workdir", ",", "fileroot", ",", "html", "=", "True", ",", "basenb", "=", "''", ",", "agdir", "=", "''", ")", ":", "from", "shutil", "import", "copy", "from", "rtpipe", "import", "get_notebook", "from", "subprocess", "import", "c...
Run analysis pipeline from jupyter base notebook and save as notebook and html. html will also compile static html version basenb can be provided, else will get distributed version. agdir is the activegit repo (optional)
[ "Run", "analysis", "pipeline", "from", "jupyter", "base", "notebook", "and", "save", "as", "notebook", "and", "html", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecands.py#L371-L402
54,219
caseyjlaw/rtpipe
rtpipe/parsecands.py
thresholdcands
def thresholdcands(candsfile, threshold, numberperscan=1): """ Returns list of significant candidate loc in candsfile. Can define threshold and maximum number of locs per scan. Works on merge or per-scan cands pkls. """ # read metadata and define columns of interest loc, prop, d = read_candidat...
python
def thresholdcands(candsfile, threshold, numberperscan=1): """ Returns list of significant candidate loc in candsfile. Can define threshold and maximum number of locs per scan. Works on merge or per-scan cands pkls. """ # read metadata and define columns of interest loc, prop, d = read_candidat...
[ "def", "thresholdcands", "(", "candsfile", ",", "threshold", ",", "numberperscan", "=", "1", ")", ":", "# read metadata and define columns of interest", "loc", ",", "prop", ",", "d", "=", "read_candidates", "(", "candsfile", ",", "returnstate", "=", "True", ")", ...
Returns list of significant candidate loc in candsfile. Can define threshold and maximum number of locs per scan. Works on merge or per-scan cands pkls.
[ "Returns", "list", "of", "significant", "candidate", "loc", "in", "candsfile", ".", "Can", "define", "threshold", "and", "maximum", "number", "of", "locs", "per", "scan", ".", "Works", "on", "merge", "or", "per", "-", "scan", "cands", "pkls", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecands.py#L405-L445
54,220
caseyjlaw/rtpipe
rtpipe/parsecands.py
int2mjd
def int2mjd(d, loc): """ Function to convert segment+integration into mjd seconds. """ # needs to take merge pkl dict if len(loc): intcol = d['featureind'].index('int') segmentcol = d['featureind'].index('segment') if d.has_key('segmenttimesdict'): # using merged pkl ...
python
def int2mjd(d, loc): """ Function to convert segment+integration into mjd seconds. """ # needs to take merge pkl dict if len(loc): intcol = d['featureind'].index('int') segmentcol = d['featureind'].index('segment') if d.has_key('segmenttimesdict'): # using merged pkl ...
[ "def", "int2mjd", "(", "d", ",", "loc", ")", ":", "# needs to take merge pkl dict", "if", "len", "(", "loc", ")", ":", "intcol", "=", "d", "[", "'featureind'", "]", ".", "index", "(", "'int'", ")", "segmentcol", "=", "d", "[", "'featureind'", "]", ".",...
Function to convert segment+integration into mjd seconds.
[ "Function", "to", "convert", "segment", "+", "integration", "into", "mjd", "seconds", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecands.py#L448-L464
54,221
caseyjlaw/rtpipe
rtpipe/parsecands.py
plot_full
def plot_full(candsfile, cands, mode='im'): """ Plot 'full' features, such as cutout image and spectrum. """ loc, prop, d = read_candidates(candsfile, returnstate=True) npixx, npixy = prop[0][4].shape nints, nchan, npol = prop[0][5].shape bin = 10 plt.figure(1) for i in cands: ...
python
def plot_full(candsfile, cands, mode='im'): """ Plot 'full' features, such as cutout image and spectrum. """ loc, prop, d = read_candidates(candsfile, returnstate=True) npixx, npixy = prop[0][4].shape nints, nchan, npol = prop[0][5].shape bin = 10 plt.figure(1) for i in cands: ...
[ "def", "plot_full", "(", "candsfile", ",", "cands", ",", "mode", "=", "'im'", ")", ":", "loc", ",", "prop", ",", "d", "=", "read_candidates", "(", "candsfile", ",", "returnstate", "=", "True", ")", "npixx", ",", "npixy", "=", "prop", "[", "0", "]", ...
Plot 'full' features, such as cutout image and spectrum.
[ "Plot", "full", "features", "such", "as", "cutout", "image", "and", "spectrum", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecands.py#L467-L487
54,222
caseyjlaw/rtpipe
rtpipe/parsecands.py
mock_fluxratio
def mock_fluxratio(candsfile, mockcandsfile, dmbin=0): """ Associates mock cands with detections in candsfile by integration. Returns ratio of detected to expected flux for all associations. """ loc, prop = read_candidates(candsfile) loc2, prop2 = read_candidates(mockcandsfile) dmselect = np.w...
python
def mock_fluxratio(candsfile, mockcandsfile, dmbin=0): """ Associates mock cands with detections in candsfile by integration. Returns ratio of detected to expected flux for all associations. """ loc, prop = read_candidates(candsfile) loc2, prop2 = read_candidates(mockcandsfile) dmselect = np.w...
[ "def", "mock_fluxratio", "(", "candsfile", ",", "mockcandsfile", ",", "dmbin", "=", "0", ")", ":", "loc", ",", "prop", "=", "read_candidates", "(", "candsfile", ")", "loc2", ",", "prop2", "=", "read_candidates", "(", "mockcandsfile", ")", "dmselect", "=", ...
Associates mock cands with detections in candsfile by integration. Returns ratio of detected to expected flux for all associations.
[ "Associates", "mock", "cands", "with", "detections", "in", "candsfile", "by", "integration", ".", "Returns", "ratio", "of", "detected", "to", "expected", "flux", "for", "all", "associations", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecands.py#L620-L640
54,223
caseyjlaw/rtpipe
rtpipe/rtlib_numba.py
flag_calcmad
def flag_calcmad(data): """ Calculate median absolute deviation of data array """ absdev = np.abs(data - np.median(data)) return np.median(absdev)
python
def flag_calcmad(data): """ Calculate median absolute deviation of data array """ absdev = np.abs(data - np.median(data)) return np.median(absdev)
[ "def", "flag_calcmad", "(", "data", ")", ":", "absdev", "=", "np", ".", "abs", "(", "data", "-", "np", ".", "median", "(", "data", ")", ")", "return", "np", ".", "median", "(", "absdev", ")" ]
Calculate median absolute deviation of data array
[ "Calculate", "median", "absolute", "deviation", "of", "data", "array" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/rtlib_numba.py#L17-L21
54,224
phareous/insteonlocal
insteonlocal/Hub.py
Hub.brightness_to_hex
def brightness_to_hex(self, level): """Convert numeric brightness percentage into hex for insteon""" level_int = int(level) new_int = int((level_int * 255)/100) new_level = format(new_int, '02X') self.logger.debug("brightness_to_hex: %s to %s", level, str(new_level)) retu...
python
def brightness_to_hex(self, level): """Convert numeric brightness percentage into hex for insteon""" level_int = int(level) new_int = int((level_int * 255)/100) new_level = format(new_int, '02X') self.logger.debug("brightness_to_hex: %s to %s", level, str(new_level)) retu...
[ "def", "brightness_to_hex", "(", "self", ",", "level", ")", ":", "level_int", "=", "int", "(", "level", ")", "new_int", "=", "int", "(", "(", "level_int", "*", "255", ")", "/", "100", ")", "new_level", "=", "format", "(", "new_int", ",", "'02X'", ")"...
Convert numeric brightness percentage into hex for insteon
[ "Convert", "numeric", "brightness", "percentage", "into", "hex", "for", "insteon" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Hub.py#L77-L83
54,225
phareous/insteonlocal
insteonlocal/Hub.py
Hub.post_direct_command
def post_direct_command(self, command_url): """Send raw command via post""" self.logger.info("post_direct_command: %s", command_url) req = requests.post(command_url, timeout=self.timeout, auth=requests.auth.HTTPBasicAuth(self.username, ...
python
def post_direct_command(self, command_url): """Send raw command via post""" self.logger.info("post_direct_command: %s", command_url) req = requests.post(command_url, timeout=self.timeout, auth=requests.auth.HTTPBasicAuth(self.username, ...
[ "def", "post_direct_command", "(", "self", ",", "command_url", ")", ":", "self", ".", "logger", ".", "info", "(", "\"post_direct_command: %s\"", ",", "command_url", ")", "req", "=", "requests", ".", "post", "(", "command_url", ",", "timeout", "=", "self", "....
Send raw command via post
[ "Send", "raw", "command", "via", "post" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Hub.py#L86-L94
54,226
phareous/insteonlocal
insteonlocal/Hub.py
Hub.get_direct_command
def get_direct_command(self, command_url): """Send raw command via get""" self.logger.info("get_direct_command: %s", command_url) req = requests.get(command_url, timeout=self.timeout, auth=requests.auth.HTTPBasicAuth(self.username, ...
python
def get_direct_command(self, command_url): """Send raw command via get""" self.logger.info("get_direct_command: %s", command_url) req = requests.get(command_url, timeout=self.timeout, auth=requests.auth.HTTPBasicAuth(self.username, ...
[ "def", "get_direct_command", "(", "self", ",", "command_url", ")", ":", "self", ".", "logger", ".", "info", "(", "\"get_direct_command: %s\"", ",", "command_url", ")", "req", "=", "requests", ".", "get", "(", "command_url", ",", "timeout", "=", "self", ".", ...
Send raw command via get
[ "Send", "raw", "command", "via", "get" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Hub.py#L97-L105
54,227
phareous/insteonlocal
insteonlocal/Hub.py
Hub.direct_command_hub
def direct_command_hub(self, command): """Send direct hub command""" self.logger.info("direct_command_hub: Command %s", command) command_url = (self.hub_url + '/3?' + command + "=I=3") return self.post_direct_command(command_url)
python
def direct_command_hub(self, command): """Send direct hub command""" self.logger.info("direct_command_hub: Command %s", command) command_url = (self.hub_url + '/3?' + command + "=I=3") return self.post_direct_command(command_url)
[ "def", "direct_command_hub", "(", "self", ",", "command", ")", ":", "self", ".", "logger", ".", "info", "(", "\"direct_command_hub: Command %s\"", ",", "command", ")", "command_url", "=", "(", "self", ".", "hub_url", "+", "'/3?'", "+", "command", "+", "\"=I=...
Send direct hub command
[ "Send", "direct", "hub", "command" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Hub.py#L155-L159
54,228
phareous/insteonlocal
insteonlocal/Hub.py
Hub.get_device_category
def get_device_category(self, cat): """Return the device category and name given the category id""" if cat in self.device_categories: return self.device_categories[cat] else: return False
python
def get_device_category(self, cat): """Return the device category and name given the category id""" if cat in self.device_categories: return self.device_categories[cat] else: return False
[ "def", "get_device_category", "(", "self", ",", "cat", ")", ":", "if", "cat", "in", "self", ".", "device_categories", ":", "return", "self", ".", "device_categories", "[", "cat", "]", "else", ":", "return", "False" ]
Return the device category and name given the category id
[ "Return", "the", "device", "category", "and", "name", "given", "the", "category", "id" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Hub.py#L281-L286
54,229
phareous/insteonlocal
insteonlocal/Hub.py
Hub.check_success
def check_success(self, device_id, sent_cmd1, sent_cmd2): """Check if last command succeeded by checking buffer""" device_id = device_id.upper() self.logger.info('check_success: for device %s cmd1 %s cmd2 %s', device_id, sent_cmd1, sent_cmd2) sleep(2) s...
python
def check_success(self, device_id, sent_cmd1, sent_cmd2): """Check if last command succeeded by checking buffer""" device_id = device_id.upper() self.logger.info('check_success: for device %s cmd1 %s cmd2 %s', device_id, sent_cmd1, sent_cmd2) sleep(2) s...
[ "def", "check_success", "(", "self", ",", "device_id", ",", "sent_cmd1", ",", "sent_cmd2", ")", ":", "device_id", "=", "device_id", ".", "upper", "(", ")", "self", ".", "logger", ".", "info", "(", "'check_success: for device %s cmd1 %s cmd2 %s'", ",", "device_id...
Check if last command succeeded by checking buffer
[ "Check", "if", "last", "command", "succeeded", "by", "checking", "buffer" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Hub.py#L1072-L1091
54,230
phareous/insteonlocal
insteonlocal/Hub.py
Hub.clear_buffer
def clear_buffer(self): """Clear the hub buffer""" command_url = self.hub_url + '/1?XB=M=1' response = self.post_direct_command(command_url) self.logger.info("clear_buffer: %s", response) return response
python
def clear_buffer(self): """Clear the hub buffer""" command_url = self.hub_url + '/1?XB=M=1' response = self.post_direct_command(command_url) self.logger.info("clear_buffer: %s", response) return response
[ "def", "clear_buffer", "(", "self", ")", ":", "command_url", "=", "self", ".", "hub_url", "+", "'/1?XB=M=1'", "response", "=", "self", ".", "post_direct_command", "(", "command_url", ")", "self", ".", "logger", ".", "info", "(", "\"clear_buffer: %s\"", ",", ...
Clear the hub buffer
[ "Clear", "the", "hub", "buffer" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Hub.py#L1094-L1099
54,231
phareous/insteonlocal
insteonlocal/Hub.py
Hub.start_all_linking
def start_all_linking(self, link_type, group_id): """Begin all linking""" self.logger.info("start_all_linking for type %s group %s", link_type, group_id) self.direct_command_hub('0264' + link_type + group_id)
python
def start_all_linking(self, link_type, group_id): """Begin all linking""" self.logger.info("start_all_linking for type %s group %s", link_type, group_id) self.direct_command_hub('0264' + link_type + group_id)
[ "def", "start_all_linking", "(", "self", ",", "link_type", ",", "group_id", ")", ":", "self", ".", "logger", ".", "info", "(", "\"start_all_linking for type %s group %s\"", ",", "link_type", ",", "group_id", ")", "self", ".", "direct_command_hub", "(", "'0264'", ...
Begin all linking
[ "Begin", "all", "linking" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Hub.py#L1110-L1114
54,232
limpyd/redis-limpyd
limpyd/database.py
RedisDatabase.connect
def connect(self, **settings): """ Connect to redis and cache the new connection """ # compute a unique key for this settings, for caching. Work on the whole # dict without directly using known keys to allow the use of unix socket # connection or any other (future ?) way ...
python
def connect(self, **settings): """ Connect to redis and cache the new connection """ # compute a unique key for this settings, for caching. Work on the whole # dict without directly using known keys to allow the use of unix socket # connection or any other (future ?) way ...
[ "def", "connect", "(", "self", ",", "*", "*", "settings", ")", ":", "# compute a unique key for this settings, for caching. Work on the whole", "# dict without directly using known keys to allow the use of unix socket", "# connection or any other (future ?) way to connect to redis", "if", ...
Connect to redis and cache the new connection
[ "Connect", "to", "redis", "and", "cache", "the", "new", "connection" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/database.py#L49-L62
54,233
limpyd/redis-limpyd
limpyd/database.py
RedisDatabase.redis_version
def redis_version(self): """Return the redis version as a tuple""" if not hasattr(self, '_redis_version'): self._redis_version = tuple( map(int, self.connection.info().get('redis_version').split('.')[:3]) ) return self._redis_version
python
def redis_version(self): """Return the redis version as a tuple""" if not hasattr(self, '_redis_version'): self._redis_version = tuple( map(int, self.connection.info().get('redis_version').split('.')[:3]) ) return self._redis_version
[ "def", "redis_version", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_redis_version'", ")", ":", "self", ".", "_redis_version", "=", "tuple", "(", "map", "(", "int", ",", "self", ".", "connection", ".", "info", "(", ")", ".", "g...
Return the redis version as a tuple
[ "Return", "the", "redis", "version", "as", "a", "tuple" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/database.py#L135-L141
54,234
limpyd/redis-limpyd
limpyd/database.py
RedisDatabase.call_script
def call_script(self, script_dict, keys=None, args=None): """Call a redis script with keys and args The first time we call a script, we register it to speed up later calls. We expect a dict with a ``lua`` key having the script, and the dict will be updated with a ``script_object`` key, ...
python
def call_script(self, script_dict, keys=None, args=None): """Call a redis script with keys and args The first time we call a script, we register it to speed up later calls. We expect a dict with a ``lua`` key having the script, and the dict will be updated with a ``script_object`` key, ...
[ "def", "call_script", "(", "self", ",", "script_dict", ",", "keys", "=", "None", ",", "args", "=", "None", ")", ":", "if", "keys", "is", "None", ":", "keys", "=", "[", "]", "if", "args", "is", "None", ":", "args", "=", "[", "]", "if", "'script_ob...
Call a redis script with keys and args The first time we call a script, we register it to speed up later calls. We expect a dict with a ``lua`` key having the script, and the dict will be updated with a ``script_object`` key, with the content returned by the the redis-py ``register_scri...
[ "Call", "a", "redis", "script", "with", "keys", "and", "args" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/database.py#L171-L200
54,235
limpyd/redis-limpyd
limpyd/database.py
RedisDatabase.scan_keys
def scan_keys(self, match=None, count=None): """Take a pattern expected by the redis `scan` command and iter on all matching keys Parameters ---------- match: str The pattern of keys to look for count: int, default to None (redis uses 10) Hint for redis a...
python
def scan_keys(self, match=None, count=None): """Take a pattern expected by the redis `scan` command and iter on all matching keys Parameters ---------- match: str The pattern of keys to look for count: int, default to None (redis uses 10) Hint for redis a...
[ "def", "scan_keys", "(", "self", ",", "match", "=", "None", ",", "count", "=", "None", ")", ":", "cursor", "=", "0", "while", "True", ":", "cursor", ",", "keys", "=", "self", ".", "connection", ".", "scan", "(", "cursor", ",", "match", "=", "match"...
Take a pattern expected by the redis `scan` command and iter on all matching keys Parameters ---------- match: str The pattern of keys to look for count: int, default to None (redis uses 10) Hint for redis about the number of expected result Yields ...
[ "Take", "a", "pattern", "expected", "by", "the", "redis", "scan", "command", "and", "iter", "on", "all", "matching", "keys" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/database.py#L202-L225
54,236
xiongchiamiov/pyfixit
pyfixit/line.py
Line._update
def _update(self, data): '''Update the line using the blob of json-parsed data directly from the API. ''' self.bullet = data['bullet'] self.level = data['level'] self.text = WikiText(data['text_raw'], data['text_rendered'])
python
def _update(self, data): '''Update the line using the blob of json-parsed data directly from the API. ''' self.bullet = data['bullet'] self.level = data['level'] self.text = WikiText(data['text_raw'], data['text_rendered'])
[ "def", "_update", "(", "self", ",", "data", ")", ":", "self", ".", "bullet", "=", "data", "[", "'bullet'", "]", "self", ".", "level", "=", "data", "[", "'level'", "]", "self", ".", "text", "=", "WikiText", "(", "data", "[", "'text_raw'", "]", ",", ...
Update the line using the blob of json-parsed data directly from the API.
[ "Update", "the", "line", "using", "the", "blob", "of", "json", "-", "parsed", "data", "directly", "from", "the", "API", "." ]
808a0c852a26e4211b2e3a72da972ab34a586dc4
https://github.com/xiongchiamiov/pyfixit/blob/808a0c852a26e4211b2e3a72da972ab34a586dc4/pyfixit/line.py#L47-L54
54,237
caseyjlaw/rtpipe
rtpipe/parsecal.py
calcChebyshev
def calcChebyshev(coeffs, validDomain, freqs): """ Given a set of coefficients, this method evaluates a Chebyshev approximation. Used for CASA bandpass reading. input coeffs and freqs are numpy arrays """ logger = logging.getLogger(__name__) domain = (validDomain[1] - validDomain[0])[0...
python
def calcChebyshev(coeffs, validDomain, freqs): """ Given a set of coefficients, this method evaluates a Chebyshev approximation. Used for CASA bandpass reading. input coeffs and freqs are numpy arrays """ logger = logging.getLogger(__name__) domain = (validDomain[1] - validDomain[0])[0...
[ "def", "calcChebyshev", "(", "coeffs", ",", "validDomain", ",", "freqs", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "domain", "=", "(", "validDomain", "[", "1", "]", "-", "validDomain", "[", "0", "]", ")", "[", "0", "...
Given a set of coefficients, this method evaluates a Chebyshev approximation. Used for CASA bandpass reading. input coeffs and freqs are numpy arrays
[ "Given", "a", "set", "of", "coefficients", "this", "method", "evaluates", "a", "Chebyshev", "approximation", ".", "Used", "for", "CASA", "bandpass", "reading", ".", "input", "coeffs", "and", "freqs", "are", "numpy", "arrays" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecal.py#L378-L394
54,238
caseyjlaw/rtpipe
rtpipe/parsecal.py
casa_sol.calc_flag
def calc_flag(self, sig=3.0): """ Calculates antennas to flag, based on bad gain and bp solutions. """ if len(self.gain.shape) == 4: gamp = n.abs(self.gain).mean(axis=0) # mean gain amp for each ant over time elif len(self.gain.shape) == 3: gamp = n.abs(self.g...
python
def calc_flag(self, sig=3.0): """ Calculates antennas to flag, based on bad gain and bp solutions. """ if len(self.gain.shape) == 4: gamp = n.abs(self.gain).mean(axis=0) # mean gain amp for each ant over time elif len(self.gain.shape) == 3: gamp = n.abs(self.g...
[ "def", "calc_flag", "(", "self", ",", "sig", "=", "3.0", ")", ":", "if", "len", "(", "self", ".", "gain", ".", "shape", ")", "==", "4", ":", "gamp", "=", "n", ".", "abs", "(", "self", ".", "gain", ")", ".", "mean", "(", "axis", "=", "0", ")...
Calculates antennas to flag, based on bad gain and bp solutions.
[ "Calculates", "antennas", "to", "flag", "based", "on", "bad", "gain", "and", "bp", "solutions", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecal.py#L239-L253
54,239
caseyjlaw/rtpipe
rtpipe/parsecal.py
casa_sol.plot
def plot(self): """ Quick visualization of calibration solution. """ import pylab as p p.clf() fig = p.figure(1) nspw = len(self.gain[0]) ext = n.ceil(n.sqrt(nspw)) # find best squre plot (simplest) for spw in range(len(self.gain[0])): ax = fi...
python
def plot(self): """ Quick visualization of calibration solution. """ import pylab as p p.clf() fig = p.figure(1) nspw = len(self.gain[0]) ext = n.ceil(n.sqrt(nspw)) # find best squre plot (simplest) for spw in range(len(self.gain[0])): ax = fi...
[ "def", "plot", "(", "self", ")", ":", "import", "pylab", "as", "p", "p", ".", "clf", "(", ")", "fig", "=", "p", ".", "figure", "(", "1", ")", "nspw", "=", "len", "(", "self", ".", "gain", "[", "0", "]", ")", "ext", "=", "n", ".", "ceil", ...
Quick visualization of calibration solution.
[ "Quick", "visualization", "of", "calibration", "solution", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecal.py#L297-L310
54,240
caseyjlaw/rtpipe
rtpipe/parsecal.py
telcal_sol.flagants
def flagants(self, threshold=50): """ Flags solutions with amplitude more than threshold larger than median. """ # identify very low gain amps not already flagged badsols = n.where( (n.median(self.amp)/self.amp > threshold) & (self.flagged == False))[0] if len(badsols): ...
python
def flagants(self, threshold=50): """ Flags solutions with amplitude more than threshold larger than median. """ # identify very low gain amps not already flagged badsols = n.where( (n.median(self.amp)/self.amp > threshold) & (self.flagged == False))[0] if len(badsols): ...
[ "def", "flagants", "(", "self", ",", "threshold", "=", "50", ")", ":", "# identify very low gain amps not already flagged", "badsols", "=", "n", ".", "where", "(", "(", "n", ".", "median", "(", "self", ".", "amp", ")", "/", "self", ".", "amp", ">", "thre...
Flags solutions with amplitude more than threshold larger than median.
[ "Flags", "solutions", "with", "amplitude", "more", "than", "threshold", "larger", "than", "median", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsecal.py#L413-L422
54,241
spatialaudio/python-pa-ringbuffer
src/pa_ringbuffer.py
init
def init(ffi, lib): """Return RingBuffer class using the given CFFI instance.""" class RingBuffer(_RingBufferBase): __doc__ = _RingBufferBase.__doc__ _ffi = ffi _lib = lib return RingBuffer
python
def init(ffi, lib): """Return RingBuffer class using the given CFFI instance.""" class RingBuffer(_RingBufferBase): __doc__ = _RingBufferBase.__doc__ _ffi = ffi _lib = lib return RingBuffer
[ "def", "init", "(", "ffi", ",", "lib", ")", ":", "class", "RingBuffer", "(", "_RingBufferBase", ")", ":", "__doc__", "=", "_RingBufferBase", ".", "__doc__", "_ffi", "=", "ffi", "_lib", "=", "lib", "return", "RingBuffer" ]
Return RingBuffer class using the given CFFI instance.
[ "Return", "RingBuffer", "class", "using", "the", "given", "CFFI", "instance", "." ]
b4a5eaa9b53a437c05d196ed59e1791db159e4b0
https://github.com/spatialaudio/python-pa-ringbuffer/blob/b4a5eaa9b53a437c05d196ed59e1791db159e4b0/src/pa_ringbuffer.py#L44-L52
54,242
spatialaudio/python-pa-ringbuffer
src/pa_ringbuffer.py
_RingBufferBase.write
def write(self, data, size=-1): """Write data to the ring buffer. This advances the write index after writing; calling :meth:`advance_write_index` is *not* necessary. :param data: Data to write to the buffer. :type data: CData pointer or buffer or bytes :param size: The...
python
def write(self, data, size=-1): """Write data to the ring buffer. This advances the write index after writing; calling :meth:`advance_write_index` is *not* necessary. :param data: Data to write to the buffer. :type data: CData pointer or buffer or bytes :param size: The...
[ "def", "write", "(", "self", ",", "data", ",", "size", "=", "-", "1", ")", ":", "try", ":", "data", "=", "self", ".", "_ffi", ".", "from_buffer", "(", "data", ")", "except", "TypeError", ":", "pass", "# input is not a buffer", "if", "size", "<", "0",...
Write data to the ring buffer. This advances the write index after writing; calling :meth:`advance_write_index` is *not* necessary. :param data: Data to write to the buffer. :type data: CData pointer or buffer or bytes :param size: The number of elements to be written. ...
[ "Write", "data", "to", "the", "ring", "buffer", "." ]
b4a5eaa9b53a437c05d196ed59e1791db159e4b0
https://github.com/spatialaudio/python-pa-ringbuffer/blob/b4a5eaa9b53a437c05d196ed59e1791db159e4b0/src/pa_ringbuffer.py#L131-L154
54,243
spatialaudio/python-pa-ringbuffer
src/pa_ringbuffer.py
_RingBufferBase.read
def read(self, size=-1): """Read data from the ring buffer into a new buffer. This advances the read index after reading; calling :meth:`advance_read_index` is *not* necessary. :param size: The number of elements to be read. If not specified, all available elements are read...
python
def read(self, size=-1): """Read data from the ring buffer into a new buffer. This advances the read index after reading; calling :meth:`advance_read_index` is *not* necessary. :param size: The number of elements to be read. If not specified, all available elements are read...
[ "def", "read", "(", "self", ",", "size", "=", "-", "1", ")", ":", "if", "size", "<", "0", ":", "size", "=", "self", ".", "read_available", "data", "=", "self", ".", "_ffi", ".", "new", "(", "'unsigned char[]'", ",", "size", "*", "self", ".", "ele...
Read data from the ring buffer into a new buffer. This advances the read index after reading; calling :meth:`advance_read_index` is *not* necessary. :param size: The number of elements to be read. If not specified, all available elements are read. :type size: int, optional ...
[ "Read", "data", "from", "the", "ring", "buffer", "into", "a", "new", "buffer", "." ]
b4a5eaa9b53a437c05d196ed59e1791db159e4b0
https://github.com/spatialaudio/python-pa-ringbuffer/blob/b4a5eaa9b53a437c05d196ed59e1791db159e4b0/src/pa_ringbuffer.py#L156-L175
54,244
spatialaudio/python-pa-ringbuffer
src/pa_ringbuffer.py
_RingBufferBase.readinto
def readinto(self, data): """Read data from the ring buffer into a user-provided buffer. This advances the read index after reading; calling :meth:`advance_read_index` is *not* necessary. :param data: The memory where the data should be stored. :type data: CData pointer or buff...
python
def readinto(self, data): """Read data from the ring buffer into a user-provided buffer. This advances the read index after reading; calling :meth:`advance_read_index` is *not* necessary. :param data: The memory where the data should be stored. :type data: CData pointer or buff...
[ "def", "readinto", "(", "self", ",", "data", ")", ":", "try", ":", "data", "=", "self", ".", "_ffi", ".", "from_buffer", "(", "data", ")", "except", "TypeError", ":", "pass", "# input is not a buffer", "size", ",", "rest", "=", "divmod", "(", "self", "...
Read data from the ring buffer into a user-provided buffer. This advances the read index after reading; calling :meth:`advance_read_index` is *not* necessary. :param data: The memory where the data should be stored. :type data: CData pointer or buffer :returns: The number of e...
[ "Read", "data", "from", "the", "ring", "buffer", "into", "a", "user", "-", "provided", "buffer", "." ]
b4a5eaa9b53a437c05d196ed59e1791db159e4b0
https://github.com/spatialaudio/python-pa-ringbuffer/blob/b4a5eaa9b53a437c05d196ed59e1791db159e4b0/src/pa_ringbuffer.py#L177-L198
54,245
wikier/keepalive
keepalive/keepalive.py
KeepAliveHandler.close_all
def close_all(self): """close all open connections""" for host, conns in self._cm.get_all().items(): for h in conns: self._cm.remove(h) h.close()
python
def close_all(self): """close all open connections""" for host, conns in self._cm.get_all().items(): for h in conns: self._cm.remove(h) h.close()
[ "def", "close_all", "(", "self", ")", ":", "for", "host", ",", "conns", "in", "self", ".", "_cm", ".", "get_all", "(", ")", ".", "items", "(", ")", ":", "for", "h", "in", "conns", ":", "self", ".", "_cm", ".", "remove", "(", "h", ")", "h", "....
close all open connections
[ "close", "all", "open", "connections" ]
13aefc925b7000965a3af0ba7890ef3b3c46283f
https://github.com/wikier/keepalive/blob/13aefc925b7000965a3af0ba7890ef3b3c46283f/keepalive/keepalive.py#L196-L201
54,246
caseyjlaw/rtpipe
rtpipe/parsesdm.py
read_bdf
def read_bdf(sdmfile, scannum, nskip=0, readints=0, bdfdir=''): """ Uses sdmpy to read a given range of integrations from sdm of given scan. readints=0 will read all of bdf (skipping nskip). """ assert os.path.exists(sdmfile), 'sdmfile %s does not exist' % sdmfile sdm = getsdm(sdmfile, bdfdir=bdf...
python
def read_bdf(sdmfile, scannum, nskip=0, readints=0, bdfdir=''): """ Uses sdmpy to read a given range of integrations from sdm of given scan. readints=0 will read all of bdf (skipping nskip). """ assert os.path.exists(sdmfile), 'sdmfile %s does not exist' % sdmfile sdm = getsdm(sdmfile, bdfdir=bdf...
[ "def", "read_bdf", "(", "sdmfile", ",", "scannum", ",", "nskip", "=", "0", ",", "readints", "=", "0", ",", "bdfdir", "=", "''", ")", ":", "assert", "os", ".", "path", ".", "exists", "(", "sdmfile", ")", ",", "'sdmfile %s does not exist'", "%", "sdmfile...
Uses sdmpy to read a given range of integrations from sdm of given scan. readints=0 will read all of bdf (skipping nskip).
[ "Uses", "sdmpy", "to", "read", "a", "given", "range", "of", "integrations", "from", "sdm", "of", "given", "scan", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsesdm.py#L245-L265
54,247
caseyjlaw/rtpipe
rtpipe/parsesdm.py
get_uvw_segment
def get_uvw_segment(d, segment=-1): """ Calculates uvw for each baseline at mid time of a given segment. d defines pipeline state. assumes segmenttimes defined by RT.set_pipeline. """ # define times to read if segment != -1: assert 'segmenttimes' in d, 'd must have segmenttimes defined' ...
python
def get_uvw_segment(d, segment=-1): """ Calculates uvw for each baseline at mid time of a given segment. d defines pipeline state. assumes segmenttimes defined by RT.set_pipeline. """ # define times to read if segment != -1: assert 'segmenttimes' in d, 'd must have segmenttimes defined' ...
[ "def", "get_uvw_segment", "(", "d", ",", "segment", "=", "-", "1", ")", ":", "# define times to read", "if", "segment", "!=", "-", "1", ":", "assert", "'segmenttimes'", "in", "d", ",", "'d must have segmenttimes defined'", "t0", "=", "d", "[", "'segmenttimes'"...
Calculates uvw for each baseline at mid time of a given segment. d defines pipeline state. assumes segmenttimes defined by RT.set_pipeline.
[ "Calculates", "uvw", "for", "each", "baseline", "at", "mid", "time", "of", "a", "given", "segment", ".", "d", "defines", "pipeline", "state", ".", "assumes", "segmenttimes", "defined", "by", "RT", ".", "set_pipeline", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsesdm.py#L469-L495
54,248
caseyjlaw/rtpipe
rtpipe/parsesdm.py
read_sources
def read_sources(sdmname): """ Use sdmpy to get all sources and ra,dec per scan as dict """ sdm = getsdm(sdmname) sourcedict = {} for row in sdm['Field']: src = str(row.fieldName) sourcenum = int(row.sourceId) direction = str(row.referenceDir) (ra,dec) = [float(val) for...
python
def read_sources(sdmname): """ Use sdmpy to get all sources and ra,dec per scan as dict """ sdm = getsdm(sdmname) sourcedict = {} for row in sdm['Field']: src = str(row.fieldName) sourcenum = int(row.sourceId) direction = str(row.referenceDir) (ra,dec) = [float(val) for...
[ "def", "read_sources", "(", "sdmname", ")", ":", "sdm", "=", "getsdm", "(", "sdmname", ")", "sourcedict", "=", "{", "}", "for", "row", "in", "sdm", "[", "'Field'", "]", ":", "src", "=", "str", "(", "row", ".", "fieldName", ")", "sourcenum", "=", "i...
Use sdmpy to get all sources and ra,dec per scan as dict
[ "Use", "sdmpy", "to", "get", "all", "sources", "and", "ra", "dec", "per", "scan", "as", "dict" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsesdm.py#L498-L515
54,249
caseyjlaw/rtpipe
rtpipe/parsesdm.py
read_scans
def read_scans(sdmfile, bdfdir=''): """ Use sdmpy to get all scans and info needed for rtpipe as dict """ sdm = getsdm(sdmfile, bdfdir=bdfdir) scandict = {} skippedscans = [] for scan in sdm.scans(): scannum = int(scan.idx) scandict[scannum] = {} intentstr = ' '.join(scan....
python
def read_scans(sdmfile, bdfdir=''): """ Use sdmpy to get all scans and info needed for rtpipe as dict """ sdm = getsdm(sdmfile, bdfdir=bdfdir) scandict = {} skippedscans = [] for scan in sdm.scans(): scannum = int(scan.idx) scandict[scannum] = {} intentstr = ' '.join(scan....
[ "def", "read_scans", "(", "sdmfile", ",", "bdfdir", "=", "''", ")", ":", "sdm", "=", "getsdm", "(", "sdmfile", ",", "bdfdir", "=", "bdfdir", ")", "scandict", "=", "{", "}", "skippedscans", "=", "[", "]", "for", "scan", "in", "sdm", ".", "scans", "(...
Use sdmpy to get all scans and info needed for rtpipe as dict
[ "Use", "sdmpy", "to", "get", "all", "scans", "and", "info", "needed", "for", "rtpipe", "as", "dict" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsesdm.py#L518-L559
54,250
caseyjlaw/rtpipe
rtpipe/parsesdm.py
getsdm
def getsdm(*args, **kwargs): """ Wrap sdmpy.SDM to get around schema change error """ try: sdm = sdmpy.SDM(*args, **kwargs) except XMLSyntaxError: kwargs['use_xsd'] = False sdm = sdmpy.SDM(*args, **kwargs) return sdm
python
def getsdm(*args, **kwargs): """ Wrap sdmpy.SDM to get around schema change error """ try: sdm = sdmpy.SDM(*args, **kwargs) except XMLSyntaxError: kwargs['use_xsd'] = False sdm = sdmpy.SDM(*args, **kwargs) return sdm
[ "def", "getsdm", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "sdm", "=", "sdmpy", ".", "SDM", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "XMLSyntaxError", ":", "kwargs", "[", "'use_xsd'", "]", "=", "False", "sd...
Wrap sdmpy.SDM to get around schema change error
[ "Wrap", "sdmpy", ".", "SDM", "to", "get", "around", "schema", "change", "error" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsesdm.py#L598-L607
54,251
phareous/insteonlocal
insteonlocal/Dimmer.py
Dimmer.start_change
def start_change(self, direction): """Start changing light level manually. Direction should be 'up' or 'down'""" self.logger.info("Dimmer %s start_change: %s", self.device_id, direction) if direction == 'up': level = '01' elif direction == 'down': level = '00' ...
python
def start_change(self, direction): """Start changing light level manually. Direction should be 'up' or 'down'""" self.logger.info("Dimmer %s start_change: %s", self.device_id, direction) if direction == 'up': level = '01' elif direction == 'down': level = '00' ...
[ "def", "start_change", "(", "self", ",", "direction", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Dimmer %s start_change: %s\"", ",", "self", ".", "device_id", ",", "direction", ")", "if", "direction", "==", "'up'", ":", "level", "=", "'01'", "el...
Start changing light level manually. Direction should be 'up' or 'down
[ "Start", "changing", "light", "level", "manually", ".", "Direction", "should", "be", "up", "or", "down" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Dimmer.py#L156-L180
54,252
phareous/insteonlocal
insteonlocal/Dimmer.py
Dimmer.stop_change
def stop_change(self): """Stop changing light level manually""" self.logger.info("Dimmer %s stop_change", self.device_id) self.hub.direct_command(self.device_id, '18', '00') success = self.hub.check_success(self.device_id, '18', '00') if success: self.logger.info("Di...
python
def stop_change(self): """Stop changing light level manually""" self.logger.info("Dimmer %s stop_change", self.device_id) self.hub.direct_command(self.device_id, '18', '00') success = self.hub.check_success(self.device_id, '18', '00') if success: self.logger.info("Di...
[ "def", "stop_change", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Dimmer %s stop_change\"", ",", "self", ".", "device_id", ")", "self", ".", "hub", ".", "direct_command", "(", "self", ".", "device_id", ",", "'18'", ",", "'00'", ")"...
Stop changing light level manually
[ "Stop", "changing", "light", "level", "manually" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Dimmer.py#L183-L197
54,253
phareous/insteonlocal
insteonlocal/Dimmer.py
Dimmer.beep
def beep(self): """Make dimmer beep. Not all devices support this""" self.logger.info("Dimmer %s beep", self.device_id) self.hub.direct_command(self.device_id, '30', '00') success = self.hub.check_success(self.device_id, '30', '00') return success
python
def beep(self): """Make dimmer beep. Not all devices support this""" self.logger.info("Dimmer %s beep", self.device_id) self.hub.direct_command(self.device_id, '30', '00') success = self.hub.check_success(self.device_id, '30', '00') return success
[ "def", "beep", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Dimmer %s beep\"", ",", "self", ".", "device_id", ")", "self", ".", "hub", ".", "direct_command", "(", "self", ".", "device_id", ",", "'30'", ",", "'00'", ")", "success",...
Make dimmer beep. Not all devices support this
[ "Make", "dimmer", "beep", ".", "Not", "all", "devices", "support", "this" ]
a4544a17d143fb285852cb873e862c270d55dd00
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Dimmer.py#L200-L208
54,254
limpyd/redis-limpyd
limpyd/collection.py
CollectionManager._get_pk
def _get_pk(self): """ Return None if we don't have any filter on a pk, the pk if we have one, or raise a ValueError if we have more than one. For internal use only. """ pk = None if self._lazy_collection['pks']: if len(self._lazy_collection['pks']) > ...
python
def _get_pk(self): """ Return None if we don't have any filter on a pk, the pk if we have one, or raise a ValueError if we have more than one. For internal use only. """ pk = None if self._lazy_collection['pks']: if len(self._lazy_collection['pks']) > ...
[ "def", "_get_pk", "(", "self", ")", ":", "pk", "=", "None", "if", "self", ".", "_lazy_collection", "[", "'pks'", "]", ":", "if", "len", "(", "self", ".", "_lazy_collection", "[", "'pks'", "]", ")", ">", "1", ":", "raise", "ValueError", "(", "'Too muc...
Return None if we don't have any filter on a pk, the pk if we have one, or raise a ValueError if we have more than one. For internal use only.
[ "Return", "None", "if", "we", "don", "t", "have", "any", "filter", "on", "a", "pk", "the", "pk", "if", "we", "have", "one", "or", "raise", "a", "ValueError", "if", "we", "have", "more", "than", "one", ".", "For", "internal", "use", "only", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/collection.py#L193-L204
54,255
limpyd/redis-limpyd
limpyd/collection.py
CollectionManager._prepare_sort_options
def _prepare_sort_options(self, has_pk): """ Prepare "sort" options to use when calling the collection, depending on "_sort" and "_sort_limits" attributes """ sort_options = {} if self._sort is not None and not has_pk: sort_options.update(self._sort) i...
python
def _prepare_sort_options(self, has_pk): """ Prepare "sort" options to use when calling the collection, depending on "_sort" and "_sort_limits" attributes """ sort_options = {} if self._sort is not None and not has_pk: sort_options.update(self._sort) i...
[ "def", "_prepare_sort_options", "(", "self", ",", "has_pk", ")", ":", "sort_options", "=", "{", "}", "if", "self", ".", "_sort", "is", "not", "None", "and", "not", "has_pk", ":", "sort_options", ".", "update", "(", "self", ".", "_sort", ")", "if", "sel...
Prepare "sort" options to use when calling the collection, depending on "_sort" and "_sort_limits" attributes
[ "Prepare", "sort", "options", "to", "use", "when", "calling", "the", "collection", "depending", "on", "_sort", "and", "_sort_limits", "attributes" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/collection.py#L206-L222
54,256
limpyd/redis-limpyd
limpyd/collection.py
CollectionManager._collection
def _collection(self): """ Effectively retrieve data according to lazy_collection. """ old_sort_limits_and_len_mode = None if self._sort_limits is None else self._sort_limits.copy(), self._len_mode try: # try block to always reset the _sort_limits in the "finally" part ...
python
def _collection(self): """ Effectively retrieve data according to lazy_collection. """ old_sort_limits_and_len_mode = None if self._sort_limits is None else self._sort_limits.copy(), self._len_mode try: # try block to always reset the _sort_limits in the "finally" part ...
[ "def", "_collection", "(", "self", ")", ":", "old_sort_limits_and_len_mode", "=", "None", "if", "self", ".", "_sort_limits", "is", "None", "else", "self", ".", "_sort_limits", ".", "copy", "(", ")", ",", "self", ".", "_len_mode", "try", ":", "# try block to ...
Effectively retrieve data according to lazy_collection.
[ "Effectively", "retrieve", "data", "according", "to", "lazy_collection", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/collection.py#L225-L288
54,257
limpyd/redis-limpyd
limpyd/collection.py
CollectionManager._final_redis_call
def _final_redis_call(self, final_set, sort_options): """ The final redis call to obtain the values to return from the "final_set" with some sort options. """ conn = self.cls.get_connection() if sort_options is not None: # a sort, or values, call the SORT com...
python
def _final_redis_call(self, final_set, sort_options): """ The final redis call to obtain the values to return from the "final_set" with some sort options. """ conn = self.cls.get_connection() if sort_options is not None: # a sort, or values, call the SORT com...
[ "def", "_final_redis_call", "(", "self", ",", "final_set", ",", "sort_options", ")", ":", "conn", "=", "self", ".", "cls", ".", "get_connection", "(", ")", "if", "sort_options", "is", "not", "None", ":", "# a sort, or values, call the SORT command on the set", "re...
The final redis call to obtain the values to return from the "final_set" with some sort options.
[ "The", "final", "redis", "call", "to", "obtain", "the", "values", "to", "return", "from", "the", "final_set", "with", "some", "sort", "options", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/collection.py#L290-L302
54,258
limpyd/redis-limpyd
limpyd/collection.py
CollectionManager._to_instances
def _to_instances(self, pks): """ Returns a list of instances for each given pk, respecting the condition about checking or not if a pk exists. """ # we want instances, so create an object for each pk, without # checking for pk existence if asked meth = self.cls.l...
python
def _to_instances(self, pks): """ Returns a list of instances for each given pk, respecting the condition about checking or not if a pk exists. """ # we want instances, so create an object for each pk, without # checking for pk existence if asked meth = self.cls.l...
[ "def", "_to_instances", "(", "self", ",", "pks", ")", ":", "# we want instances, so create an object for each pk, without", "# checking for pk existence if asked", "meth", "=", "self", ".", "cls", ".", "lazy_connect", "if", "self", ".", "_instances_skip_exist_test", "else",...
Returns a list of instances for each given pk, respecting the condition about checking or not if a pk exists.
[ "Returns", "a", "list", "of", "instances", "for", "each", "given", "pk", "respecting", "the", "condition", "about", "checking", "or", "not", "if", "a", "pk", "exists", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/collection.py#L311-L319
54,259
limpyd/redis-limpyd
limpyd/collection.py
CollectionManager._prepare_results
def _prepare_results(self, results): """ Called in _collection to prepare results from redis before returning them. """ if self._instances: results = self._to_instances(results) else: results = list(results) # cache the len for future use ...
python
def _prepare_results(self, results): """ Called in _collection to prepare results from redis before returning them. """ if self._instances: results = self._to_instances(results) else: results = list(results) # cache the len for future use ...
[ "def", "_prepare_results", "(", "self", ",", "results", ")", ":", "if", "self", ".", "_instances", ":", "results", "=", "self", ".", "_to_instances", "(", "results", ")", "else", ":", "results", "=", "list", "(", "results", ")", "# cache the len for future u...
Called in _collection to prepare results from redis before returning them.
[ "Called", "in", "_collection", "to", "prepare", "results", "from", "redis", "before", "returning", "them", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/collection.py#L321-L334
54,260
limpyd/redis-limpyd
limpyd/collection.py
CollectionManager._combine_sets
def _combine_sets(self, sets, final_set): """ Given a list of set, combine them to create the final set that will be used to make the final redis call. """ self.cls.get_connection().sinterstore(final_set, list(sets)) return final_set
python
def _combine_sets(self, sets, final_set): """ Given a list of set, combine them to create the final set that will be used to make the final redis call. """ self.cls.get_connection().sinterstore(final_set, list(sets)) return final_set
[ "def", "_combine_sets", "(", "self", ",", "sets", ",", "final_set", ")", ":", "self", ".", "cls", ".", "get_connection", "(", ")", ".", "sinterstore", "(", "final_set", ",", "list", "(", "sets", ")", ")", "return", "final_set" ]
Given a list of set, combine them to create the final set that will be used to make the final redis call.
[ "Given", "a", "list", "of", "set", "combine", "them", "to", "create", "the", "final", "set", "that", "will", "be", "used", "to", "make", "the", "final", "redis", "call", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/collection.py#L425-L431
54,261
limpyd/redis-limpyd
limpyd/collection.py
CollectionManager._add_filters
def _add_filters(self, **filters): """Define self._lazy_collection according to filters.""" for key, value in filters.items(): if self._field_is_pk(key): pk = self.cls.get_field('pk').normalize(value) self._lazy_collection['pks'].add(pk) else: ...
python
def _add_filters(self, **filters): """Define self._lazy_collection according to filters.""" for key, value in filters.items(): if self._field_is_pk(key): pk = self.cls.get_field('pk').normalize(value) self._lazy_collection['pks'].add(pk) else: ...
[ "def", "_add_filters", "(", "self", ",", "*", "*", "filters", ")", ":", "for", "key", ",", "value", "in", "filters", ".", "items", "(", ")", ":", "if", "self", ".", "_field_is_pk", "(", "key", ")", ":", "pk", "=", "self", ".", "cls", ".", "get_fi...
Define self._lazy_collection according to filters.
[ "Define", "self", ".", "_lazy_collection", "according", "to", "filters", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/collection.py#L487-L500
54,262
limpyd/redis-limpyd
limpyd/collection.py
CollectionManager.instances
def instances(self, skip_exist_test=False): """ Ask the collection to return a list of instances. If skip_exist_test is set to True, the instances returned by the collection won't have their primary key checked for existence. """ self.reset_result_type() self._ins...
python
def instances(self, skip_exist_test=False): """ Ask the collection to return a list of instances. If skip_exist_test is set to True, the instances returned by the collection won't have their primary key checked for existence. """ self.reset_result_type() self._ins...
[ "def", "instances", "(", "self", ",", "skip_exist_test", "=", "False", ")", ":", "self", ".", "reset_result_type", "(", ")", "self", ".", "_instances", "=", "True", "self", ".", "_instances_skip_exist_test", "=", "skip_exist_test", "return", "self" ]
Ask the collection to return a list of instances. If skip_exist_test is set to True, the instances returned by the collection won't have their primary key checked for existence.
[ "Ask", "the", "collection", "to", "return", "a", "list", "of", "instances", ".", "If", "skip_exist_test", "is", "set", "to", "True", "the", "instances", "returned", "by", "the", "collection", "won", "t", "have", "their", "primary", "key", "checked", "for", ...
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/collection.py#L518-L527
54,263
caseyjlaw/rtpipe
rtpipe/reproduce.py
list_cands
def list_cands(candsfile, threshold=0.): """ Prints candidate info in time order above some threshold """ loc, prop, d0 = pc.read_candidates(candsfile, snrmin=threshold, returnstate=True) if 'snr2' in d0['features']: snrcol = d0['features'].index('snr2') elif 'snr1' in d0['features']: ...
python
def list_cands(candsfile, threshold=0.): """ Prints candidate info in time order above some threshold """ loc, prop, d0 = pc.read_candidates(candsfile, snrmin=threshold, returnstate=True) if 'snr2' in d0['features']: snrcol = d0['features'].index('snr2') elif 'snr1' in d0['features']: ...
[ "def", "list_cands", "(", "candsfile", ",", "threshold", "=", "0.", ")", ":", "loc", ",", "prop", ",", "d0", "=", "pc", ".", "read_candidates", "(", "candsfile", ",", "snrmin", "=", "threshold", ",", "returnstate", "=", "True", ")", "if", "'snr2'", "in...
Prints candidate info in time order above some threshold
[ "Prints", "candidate", "info", "in", "time", "order", "above", "some", "threshold" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/reproduce.py#L136-L155
54,264
caseyjlaw/rtpipe
rtpipe/reproduce.py
refine_cand
def refine_cand(candsfile, candloc=[], candnum=-1, threshold=0, scaledm=2.1, scalepix=2, scaleuv=1.0, chans=[], returndata=False): """ Helper function to interact with merged cands file and refine analysis candsfile is merged pkl file candloc (scan, segment, candint, dmind, dtind, beamnum) is as above. ...
python
def refine_cand(candsfile, candloc=[], candnum=-1, threshold=0, scaledm=2.1, scalepix=2, scaleuv=1.0, chans=[], returndata=False): """ Helper function to interact with merged cands file and refine analysis candsfile is merged pkl file candloc (scan, segment, candint, dmind, dtind, beamnum) is as above. ...
[ "def", "refine_cand", "(", "candsfile", ",", "candloc", "=", "[", "]", ",", "candnum", "=", "-", "1", ",", "threshold", "=", "0", ",", "scaledm", "=", "2.1", ",", "scalepix", "=", "2", ",", "scaleuv", "=", "1.0", ",", "chans", "=", "[", "]", ",",...
Helper function to interact with merged cands file and refine analysis candsfile is merged pkl file candloc (scan, segment, candint, dmind, dtind, beamnum) is as above. if no candloc, then it prints out cands above threshold.
[ "Helper", "function", "to", "interact", "with", "merged", "cands", "file", "and", "refine", "analysis" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/reproduce.py#L158-L181
54,265
caseyjlaw/rtpipe
rtpipe/reproduce.py
refine_cands
def refine_cands(candsfile, threshold=0, scaledm=2.1, scalepix=2, scaleuv=1.0, chans=[], savepkl=True): """ Runs refine_cand on all positive SNR candidates above threshold. Any detected at higher SNR are highlighted. """ # get snrs above threshold locs, props, d = pc.read_candidates(candsfile, snrmin=thres...
python
def refine_cands(candsfile, threshold=0, scaledm=2.1, scalepix=2, scaleuv=1.0, chans=[], savepkl=True): """ Runs refine_cand on all positive SNR candidates above threshold. Any detected at higher SNR are highlighted. """ # get snrs above threshold locs, props, d = pc.read_candidates(candsfile, snrmin=thres...
[ "def", "refine_cands", "(", "candsfile", ",", "threshold", "=", "0", ",", "scaledm", "=", "2.1", ",", "scalepix", "=", "2", ",", "scaleuv", "=", "1.0", ",", "chans", "=", "[", "]", ",", "savepkl", "=", "True", ")", ":", "# get snrs above threshold", "l...
Runs refine_cand on all positive SNR candidates above threshold. Any detected at higher SNR are highlighted.
[ "Runs", "refine_cand", "on", "all", "positive", "SNR", "candidates", "above", "threshold", ".", "Any", "detected", "at", "higher", "SNR", "are", "highlighted", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/reproduce.py#L184-L224
54,266
caseyjlaw/rtpipe
rtpipe/reproduce.py
convertloc
def convertloc(candsfile, candloc, memory_limit): """ For given state and location that are too bulky, calculate new location given memory_limit. """ scan, segment, candint, dmind, dtind, beamnum = candloc # set up state and find absolute integration of candidate d0 = pickle.load(open(candsfile, 'r'))...
python
def convertloc(candsfile, candloc, memory_limit): """ For given state and location that are too bulky, calculate new location given memory_limit. """ scan, segment, candint, dmind, dtind, beamnum = candloc # set up state and find absolute integration of candidate d0 = pickle.load(open(candsfile, 'r'))...
[ "def", "convertloc", "(", "candsfile", ",", "candloc", ",", "memory_limit", ")", ":", "scan", ",", "segment", ",", "candint", ",", "dmind", ",", "dtind", ",", "beamnum", "=", "candloc", "# set up state and find absolute integration of candidate", "d0", "=", "pickl...
For given state and location that are too bulky, calculate new location given memory_limit.
[ "For", "given", "state", "and", "location", "that", "are", "too", "bulky", "calculate", "new", "location", "given", "memory_limit", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/reproduce.py#L639-L679
54,267
caseyjlaw/rtpipe
rtpipe/reproduce.py
deg2HMS
def deg2HMS(ra='', dec='', round=False): """ quick and dirty coord conversion. googled to find bdnyc.org. """ RA, DEC, rs, ds = '', '', '', '' if dec: if str(dec)[0] == '-': ds, dec = '-', abs(dec) deg = int(dec) decM = abs(int((dec-deg)*60)) if round: ...
python
def deg2HMS(ra='', dec='', round=False): """ quick and dirty coord conversion. googled to find bdnyc.org. """ RA, DEC, rs, ds = '', '', '', '' if dec: if str(dec)[0] == '-': ds, dec = '-', abs(dec) deg = int(dec) decM = abs(int((dec-deg)*60)) if round: ...
[ "def", "deg2HMS", "(", "ra", "=", "''", ",", "dec", "=", "''", ",", "round", "=", "False", ")", ":", "RA", ",", "DEC", ",", "rs", ",", "ds", "=", "''", ",", "''", ",", "''", ",", "''", "if", "dec", ":", "if", "str", "(", "dec", ")", "[", ...
quick and dirty coord conversion. googled to find bdnyc.org.
[ "quick", "and", "dirty", "coord", "conversion", ".", "googled", "to", "find", "bdnyc", ".", "org", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/reproduce.py#L694-L723
54,268
django-blog-zinnia/wordpress2zinnia
zinnia_wordpress/management/commands/wp2zinnia.py
Command.guess_wxr_version
def guess_wxr_version(self, tree): """ We will try to guess the wxr version used to complete the wordpress xml namespace name. """ for v in ('1.2', '1.1', '1.0'): try: tree.find('channel/{%s}wxr_version' % (WP_NS % v)).text return v ...
python
def guess_wxr_version(self, tree): """ We will try to guess the wxr version used to complete the wordpress xml namespace name. """ for v in ('1.2', '1.1', '1.0'): try: tree.find('channel/{%s}wxr_version' % (WP_NS % v)).text return v ...
[ "def", "guess_wxr_version", "(", "self", ",", "tree", ")", ":", "for", "v", "in", "(", "'1.2'", ",", "'1.1'", ",", "'1.0'", ")", ":", "try", ":", "tree", ".", "find", "(", "'channel/{%s}wxr_version'", "%", "(", "WP_NS", "%", "v", ")", ")", ".", "te...
We will try to guess the wxr version used to complete the wordpress xml namespace name.
[ "We", "will", "try", "to", "guess", "the", "wxr", "version", "used", "to", "complete", "the", "wordpress", "xml", "namespace", "name", "." ]
656df6d431418a660f0e590d2226af5e6dd7a3e6
https://github.com/django-blog-zinnia/wordpress2zinnia/blob/656df6d431418a660f0e590d2226af5e6dd7a3e6/zinnia_wordpress/management/commands/wp2zinnia.py#L121-L132
54,269
django-blog-zinnia/wordpress2zinnia
zinnia_wordpress/management/commands/wp2zinnia.py
Command.import_authors
def import_authors(self, tree): """ Retrieve all the authors used in posts and convert it to new or existing author and return the conversion. """ self.write_out(self.style.STEP('- Importing authors\n')) post_authors = set() for item in tree.findall('chan...
python
def import_authors(self, tree): """ Retrieve all the authors used in posts and convert it to new or existing author and return the conversion. """ self.write_out(self.style.STEP('- Importing authors\n')) post_authors = set() for item in tree.findall('chan...
[ "def", "import_authors", "(", "self", ",", "tree", ")", ":", "self", ".", "write_out", "(", "self", ".", "style", ".", "STEP", "(", "'- Importing authors\\n'", ")", ")", "post_authors", "=", "set", "(", ")", "for", "item", "in", "tree", ".", "findall", ...
Retrieve all the authors used in posts and convert it to new or existing author and return the conversion.
[ "Retrieve", "all", "the", "authors", "used", "in", "posts", "and", "convert", "it", "to", "new", "or", "existing", "author", "and", "return", "the", "conversion", "." ]
656df6d431418a660f0e590d2226af5e6dd7a3e6
https://github.com/django-blog-zinnia/wordpress2zinnia/blob/656df6d431418a660f0e590d2226af5e6dd7a3e6/zinnia_wordpress/management/commands/wp2zinnia.py#L134-L158
54,270
django-blog-zinnia/wordpress2zinnia
zinnia_wordpress/management/commands/wp2zinnia.py
Command.migrate_author
def migrate_author(self, author_name): """ Handle actions for migrating the authors. """ action_text = "The author '%s' needs to be migrated to an user:\n"\ "1. Use an existing user ?\n"\ "2. Create a new user ?\n"\ "Pleas...
python
def migrate_author(self, author_name): """ Handle actions for migrating the authors. """ action_text = "The author '%s' needs to be migrated to an user:\n"\ "1. Use an existing user ?\n"\ "2. Create a new user ?\n"\ "Pleas...
[ "def", "migrate_author", "(", "self", ",", "author_name", ")", ":", "action_text", "=", "\"The author '%s' needs to be migrated to an user:\\n\"", "\"1. Use an existing user ?\\n\"", "\"2. Create a new user ?\\n\"", "\"Please select a choice: \"", "%", "self", ".", "style", ".", ...
Handle actions for migrating the authors.
[ "Handle", "actions", "for", "migrating", "the", "authors", "." ]
656df6d431418a660f0e590d2226af5e6dd7a3e6
https://github.com/django-blog-zinnia/wordpress2zinnia/blob/656df6d431418a660f0e590d2226af5e6dd7a3e6/zinnia_wordpress/management/commands/wp2zinnia.py#L160-L216
54,271
django-blog-zinnia/wordpress2zinnia
zinnia_wordpress/management/commands/wp2zinnia.py
Command.get_entry_tags
def get_entry_tags(self, categories): """ Return a list of entry's tags, by using the nicename for url compatibility. """ tags = [] for category in categories: domain = category.attrib.get('domain', 'category') if 'tag' in domain and category.attri...
python
def get_entry_tags(self, categories): """ Return a list of entry's tags, by using the nicename for url compatibility. """ tags = [] for category in categories: domain = category.attrib.get('domain', 'category') if 'tag' in domain and category.attri...
[ "def", "get_entry_tags", "(", "self", ",", "categories", ")", ":", "tags", "=", "[", "]", "for", "category", "in", "categories", ":", "domain", "=", "category", ".", "attrib", ".", "get", "(", "'domain'", ",", "'category'", ")", "if", "'tag'", "in", "d...
Return a list of entry's tags, by using the nicename for url compatibility.
[ "Return", "a", "list", "of", "entry", "s", "tags", "by", "using", "the", "nicename", "for", "url", "compatibility", "." ]
656df6d431418a660f0e590d2226af5e6dd7a3e6
https://github.com/django-blog-zinnia/wordpress2zinnia/blob/656df6d431418a660f0e590d2226af5e6dd7a3e6/zinnia_wordpress/management/commands/wp2zinnia.py#L260-L270
54,272
django-blog-zinnia/wordpress2zinnia
zinnia_wordpress/management/commands/wp2zinnia.py
Command.get_entry_categories
def get_entry_categories(self, category_nodes): """ Return a list of entry's categories based on imported categories. """ categories = [] for category_node in category_nodes: domain = category_node.attrib.get('domain') if domain == 'category': ...
python
def get_entry_categories(self, category_nodes): """ Return a list of entry's categories based on imported categories. """ categories = [] for category_node in category_nodes: domain = category_node.attrib.get('domain') if domain == 'category': ...
[ "def", "get_entry_categories", "(", "self", ",", "category_nodes", ")", ":", "categories", "=", "[", "]", "for", "category_node", "in", "category_nodes", ":", "domain", "=", "category_node", ".", "attrib", ".", "get", "(", "'domain'", ")", "if", "domain", "=...
Return a list of entry's categories based on imported categories.
[ "Return", "a", "list", "of", "entry", "s", "categories", "based", "on", "imported", "categories", "." ]
656df6d431418a660f0e590d2226af5e6dd7a3e6
https://github.com/django-blog-zinnia/wordpress2zinnia/blob/656df6d431418a660f0e590d2226af5e6dd7a3e6/zinnia_wordpress/management/commands/wp2zinnia.py#L272-L282
54,273
django-blog-zinnia/wordpress2zinnia
zinnia_wordpress/management/commands/wp2zinnia.py
Command.import_entries
def import_entries(self, items): """ Loops over items and find entry to import, an entry need to have 'post_type' set to 'post' and have content. """ self.write_out(self.style.STEP('- Importing entries\n')) for item_node in items: title = (item_node.f...
python
def import_entries(self, items): """ Loops over items and find entry to import, an entry need to have 'post_type' set to 'post' and have content. """ self.write_out(self.style.STEP('- Importing entries\n')) for item_node in items: title = (item_node.f...
[ "def", "import_entries", "(", "self", ",", "items", ")", ":", "self", ".", "write_out", "(", "self", ".", "style", ".", "STEP", "(", "'- Importing entries\\n'", ")", ")", "for", "item_node", "in", "items", ":", "title", "=", "(", "item_node", ".", "find"...
Loops over items and find entry to import, an entry need to have 'post_type' set to 'post' and have content.
[ "Loops", "over", "items", "and", "find", "entry", "to", "import", "an", "entry", "need", "to", "have", "post_type", "set", "to", "post", "and", "have", "content", "." ]
656df6d431418a660f0e590d2226af5e6dd7a3e6
https://github.com/django-blog-zinnia/wordpress2zinnia/blob/656df6d431418a660f0e590d2226af5e6dd7a3e6/zinnia_wordpress/management/commands/wp2zinnia.py#L357-L387
54,274
django-blog-zinnia/wordpress2zinnia
zinnia_wordpress/management/commands/wp2zinnia.py
Command.import_comments
def import_comments(self, entry, comment_nodes): """ Loops over comments nodes and import then in django_comments. """ for comment_node in comment_nodes: is_pingback = comment_node.find( '{%s}comment_type' % WP_NS).text == PINGBACK is_track...
python
def import_comments(self, entry, comment_nodes): """ Loops over comments nodes and import then in django_comments. """ for comment_node in comment_nodes: is_pingback = comment_node.find( '{%s}comment_type' % WP_NS).text == PINGBACK is_track...
[ "def", "import_comments", "(", "self", ",", "entry", ",", "comment_nodes", ")", ":", "for", "comment_node", "in", "comment_nodes", ":", "is_pingback", "=", "comment_node", ".", "find", "(", "'{%s}comment_type'", "%", "WP_NS", ")", ".", "text", "==", "PINGBACK"...
Loops over comments nodes and import then in django_comments.
[ "Loops", "over", "comments", "nodes", "and", "import", "then", "in", "django_comments", "." ]
656df6d431418a660f0e590d2226af5e6dd7a3e6
https://github.com/django-blog-zinnia/wordpress2zinnia/blob/656df6d431418a660f0e590d2226af5e6dd7a3e6/zinnia_wordpress/management/commands/wp2zinnia.py#L404-L469
54,275
dfm/modeling.py
modeling.py
Model.compute_gradient
def compute_gradient(self, *args, **kwargs): """ Compute the "gradient" of the model for the current parameters The default implementation computes the gradients numerically using a first order forward scheme. For better performance, this method should be overloaded by subclasse...
python
def compute_gradient(self, *args, **kwargs): """ Compute the "gradient" of the model for the current parameters The default implementation computes the gradients numerically using a first order forward scheme. For better performance, this method should be overloaded by subclasse...
[ "def", "compute_gradient", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_EPS", "=", "1.254e-5", "vector", "=", "self", ".", "get_parameter_vector", "(", ")", "value0", "=", "self", ".", "get_value", "(", "*", "args", ",", "*", "...
Compute the "gradient" of the model for the current parameters The default implementation computes the gradients numerically using a first order forward scheme. For better performance, this method should be overloaded by subclasses. The output of this function should be an array where t...
[ "Compute", "the", "gradient", "of", "the", "model", "for", "the", "current", "parameters" ]
8b872b1f9140829cfe3c0f742a4864db32a52d0d
https://github.com/dfm/modeling.py/blob/8b872b1f9140829cfe3c0f742a4864db32a52d0d/modeling.py#L132-L153
54,276
limpyd/redis-limpyd
limpyd/model.py
RedisModel.connect
def connect(self): """ Connect the instance to redis by checking the existence of its primary key. Do nothing if already connected. """ if self.connected: return pk = self._pk if self.exists(pk=pk): self._connected = True else: ...
python
def connect(self): """ Connect the instance to redis by checking the existence of its primary key. Do nothing if already connected. """ if self.connected: return pk = self._pk if self.exists(pk=pk): self._connected = True else: ...
[ "def", "connect", "(", "self", ")", ":", "if", "self", ".", "connected", ":", "return", "pk", "=", "self", ".", "_pk", "if", "self", ".", "exists", "(", "pk", "=", "pk", ")", ":", "self", ".", "_connected", "=", "True", "else", ":", "self", ".", ...
Connect the instance to redis by checking the existence of its primary key. Do nothing if already connected.
[ "Connect", "the", "instance", "to", "redis", "by", "checking", "the", "existence", "of", "its", "primary", "key", ".", "Do", "nothing", "if", "already", "connected", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/model.py#L226-L239
54,277
limpyd/redis-limpyd
limpyd/model.py
RedisModel.lazy_connect
def lazy_connect(cls, pk): """ Create an object, setting its primary key without testing it. So the instance is not connected """ instance = cls() instance._pk = instance.pk.normalize(pk) instance._connected = False return instance
python
def lazy_connect(cls, pk): """ Create an object, setting its primary key without testing it. So the instance is not connected """ instance = cls() instance._pk = instance.pk.normalize(pk) instance._connected = False return instance
[ "def", "lazy_connect", "(", "cls", ",", "pk", ")", ":", "instance", "=", "cls", "(", ")", "instance", ".", "_pk", "=", "instance", ".", "pk", ".", "normalize", "(", "pk", ")", "instance", ".", "_connected", "=", "False", "return", "instance" ]
Create an object, setting its primary key without testing it. So the instance is not connected
[ "Create", "an", "object", "setting", "its", "primary", "key", "without", "testing", "it", ".", "So", "the", "instance", "is", "not", "connected" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/model.py#L242-L250
54,278
limpyd/redis-limpyd
limpyd/model.py
RedisModel._set_defaults
def _set_defaults(self): """ Set default values to fields. We assume that they are not yet populated as this method is called just after creation of a new pk. """ for field_name in self._fields: if field_name in self._init_fields: continue ...
python
def _set_defaults(self): """ Set default values to fields. We assume that they are not yet populated as this method is called just after creation of a new pk. """ for field_name in self._fields: if field_name in self._init_fields: continue ...
[ "def", "_set_defaults", "(", "self", ")", ":", "for", "field_name", "in", "self", ".", "_fields", ":", "if", "field_name", "in", "self", ".", "_init_fields", ":", "continue", "field", "=", "self", ".", "get_field", "(", "field_name", ")", "if", "hasattr", ...
Set default values to fields. We assume that they are not yet populated as this method is called just after creation of a new pk.
[ "Set", "default", "values", "to", "fields", ".", "We", "assume", "that", "they", "are", "not", "yet", "populated", "as", "this", "method", "is", "called", "just", "after", "creation", "of", "a", "new", "pk", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/model.py#L319-L329
54,279
limpyd/redis-limpyd
limpyd/model.py
RedisModel.exists
def exists(cls, **kwargs): """ A model with the values defined by kwargs exists in db? `kwargs` are mandatory. """ if not kwargs: raise ValueError(u"`Exists` method requires at least one kwarg.") # special case to check for a simple pk if len(kwargs)...
python
def exists(cls, **kwargs): """ A model with the values defined by kwargs exists in db? `kwargs` are mandatory. """ if not kwargs: raise ValueError(u"`Exists` method requires at least one kwarg.") # special case to check for a simple pk if len(kwargs)...
[ "def", "exists", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "if", "not", "kwargs", ":", "raise", "ValueError", "(", "u\"`Exists` method requires at least one kwarg.\"", ")", "# special case to check for a simple pk", "if", "len", "(", "kwargs", ")", "==", "1",...
A model with the values defined by kwargs exists in db? `kwargs` are mandatory.
[ "A", "model", "with", "the", "values", "defined", "by", "kwargs", "exists", "in", "db?" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/model.py#L352-L371
54,280
limpyd/redis-limpyd
limpyd/model.py
RedisModel.get
def get(cls, *args, **kwargs): """ Retrieve one instance from db according to given kwargs. Optionnaly, one arg could be used to retrieve it from pk. """ if len(args) == 1: # Guess it's a pk pk = args[0] elif kwargs: # special case to check for a...
python
def get(cls, *args, **kwargs): """ Retrieve one instance from db according to given kwargs. Optionnaly, one arg could be used to retrieve it from pk. """ if len(args) == 1: # Guess it's a pk pk = args[0] elif kwargs: # special case to check for a...
[ "def", "get", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", "==", "1", ":", "# Guess it's a pk", "pk", "=", "args", "[", "0", "]", "elif", "kwargs", ":", "# special case to check for a simple pk", "if",...
Retrieve one instance from db according to given kwargs. Optionnaly, one arg could be used to retrieve it from pk.
[ "Retrieve", "one", "instance", "from", "db", "according", "to", "given", "kwargs", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/model.py#L374-L401
54,281
limpyd/redis-limpyd
limpyd/model.py
RedisModel.get_or_connect
def get_or_connect(cls, **kwargs): """ Try to retrieve an object in db, and create it if it does not exist. """ try: inst = cls.get(**kwargs) created = False except DoesNotExist: inst = cls(**kwargs) created = True except Ex...
python
def get_or_connect(cls, **kwargs): """ Try to retrieve an object in db, and create it if it does not exist. """ try: inst = cls.get(**kwargs) created = False except DoesNotExist: inst = cls(**kwargs) created = True except Ex...
[ "def", "get_or_connect", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "try", ":", "inst", "=", "cls", ".", "get", "(", "*", "*", "kwargs", ")", "created", "=", "False", "except", "DoesNotExist", ":", "inst", "=", "cls", "(", "*", "*", "kwargs", ...
Try to retrieve an object in db, and create it if it does not exist.
[ "Try", "to", "retrieve", "an", "object", "in", "db", "and", "create", "it", "if", "it", "does", "not", "exist", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/model.py#L404-L416
54,282
limpyd/redis-limpyd
limpyd/model.py
RedisModel.hmget
def hmget(self, *args): """ This command on the model allow getting many instancehash fields with only one redis call. You must pass hash name to retrieve as arguments. """ if args and not any(arg in self._instancehash_fields for arg in args): raise ValueError("Only I...
python
def hmget(self, *args): """ This command on the model allow getting many instancehash fields with only one redis call. You must pass hash name to retrieve as arguments. """ if args and not any(arg in self._instancehash_fields for arg in args): raise ValueError("Only I...
[ "def", "hmget", "(", "self", ",", "*", "args", ")", ":", "if", "args", "and", "not", "any", "(", "arg", "in", "self", ".", "_instancehash_fields", "for", "arg", "in", "args", ")", ":", "raise", "ValueError", "(", "\"Only InstanceHashField can be used here.\"...
This command on the model allow getting many instancehash fields with only one redis call. You must pass hash name to retrieve as arguments.
[ "This", "command", "on", "the", "model", "allow", "getting", "many", "instancehash", "fields", "with", "only", "one", "redis", "call", ".", "You", "must", "pass", "hash", "name", "to", "retrieve", "as", "arguments", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/model.py#L442-L450
54,283
limpyd/redis-limpyd
limpyd/model.py
RedisModel.hmset
def hmset(self, **kwargs): """ This command on the model allow setting many instancehash fields with only one redis call. You must pass kwargs with field names as keys, with their value. """ if kwargs and not any(kwarg in self._instancehash_fields for kwarg in iterkeys(kw...
python
def hmset(self, **kwargs): """ This command on the model allow setting many instancehash fields with only one redis call. You must pass kwargs with field names as keys, with their value. """ if kwargs and not any(kwarg in self._instancehash_fields for kwarg in iterkeys(kw...
[ "def", "hmset", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", "and", "not", "any", "(", "kwarg", "in", "self", ".", "_instancehash_fields", "for", "kwarg", "in", "iterkeys", "(", "kwargs", ")", ")", ":", "raise", "ValueError", "(", ...
This command on the model allow setting many instancehash fields with only one redis call. You must pass kwargs with field names as keys, with their value.
[ "This", "command", "on", "the", "model", "allow", "setting", "many", "instancehash", "fields", "with", "only", "one", "redis", "call", ".", "You", "must", "pass", "kwargs", "with", "field", "names", "as", "keys", "with", "their", "value", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/model.py#L452-L487
54,284
limpyd/redis-limpyd
limpyd/model.py
RedisModel.hdel
def hdel(self, *args): """ This command on the model allow deleting many instancehash fields with only one redis call. You must pass hash names to retrieve as arguments """ if args and not any(arg in self._instancehash_fields for arg in args): raise ValueError("Only I...
python
def hdel(self, *args): """ This command on the model allow deleting many instancehash fields with only one redis call. You must pass hash names to retrieve as arguments """ if args and not any(arg in self._instancehash_fields for arg in args): raise ValueError("Only I...
[ "def", "hdel", "(", "self", ",", "*", "args", ")", ":", "if", "args", "and", "not", "any", "(", "arg", "in", "self", ".", "_instancehash_fields", "for", "arg", "in", "args", ")", ":", "raise", "ValueError", "(", "\"Only InstanceHashField can be used here.\""...
This command on the model allow deleting many instancehash fields with only one redis call. You must pass hash names to retrieve as arguments
[ "This", "command", "on", "the", "model", "allow", "deleting", "many", "instancehash", "fields", "with", "only", "one", "redis", "call", ".", "You", "must", "pass", "hash", "names", "to", "retrieve", "as", "arguments" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/model.py#L489-L504
54,285
limpyd/redis-limpyd
limpyd/model.py
RedisModel.delete
def delete(self): """ Delete the instance from redis storage. """ # Delete each field for field_name in self._fields: field = self.get_field(field_name) if not isinstance(field, PKField): # pk has no stored key field.delete(...
python
def delete(self): """ Delete the instance from redis storage. """ # Delete each field for field_name in self._fields: field = self.get_field(field_name) if not isinstance(field, PKField): # pk has no stored key field.delete(...
[ "def", "delete", "(", "self", ")", ":", "# Delete each field", "for", "field_name", "in", "self", ".", "_fields", ":", "field", "=", "self", ".", "get_field", "(", "field_name", ")", "if", "not", "isinstance", "(", "field", ",", "PKField", ")", ":", "# p...
Delete the instance from redis storage.
[ "Delete", "the", "instance", "from", "redis", "storage", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/model.py#L506-L519
54,286
limpyd/redis-limpyd
limpyd/model.py
RedisModel.scan_keys
def scan_keys(self, count=None): """Iter on all the key related to the current instance fields, using redis SCAN command Parameters ---------- count: int, default to None (redis uses 10) Hint for redis about the number of expected result Yields ------- ...
python
def scan_keys(self, count=None): """Iter on all the key related to the current instance fields, using redis SCAN command Parameters ---------- count: int, default to None (redis uses 10) Hint for redis about the number of expected result Yields ------- ...
[ "def", "scan_keys", "(", "self", ",", "count", "=", "None", ")", ":", "pattern", "=", "self", ".", "make_key", "(", "self", ".", "_name", ",", "self", ".", "pk", ".", "get", "(", ")", ",", "'*'", ")", "return", "self", ".", "database", ".", "scan...
Iter on all the key related to the current instance fields, using redis SCAN command Parameters ---------- count: int, default to None (redis uses 10) Hint for redis about the number of expected result Yields ------- str All keys found by the sca...
[ "Iter", "on", "all", "the", "key", "related", "to", "the", "current", "instance", "fields", "using", "redis", "SCAN", "command" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/model.py#L548-L570
54,287
limpyd/redis-limpyd
limpyd/model.py
RedisModel.scan_model_keys
def scan_model_keys(cls, count=None): """Iter on all the key related to the current model, using redis SCAN command Parameters ---------- count: int, default to None (redis uses 10) Hint for redis about the number of expected result Yields ------- st...
python
def scan_model_keys(cls, count=None): """Iter on all the key related to the current model, using redis SCAN command Parameters ---------- count: int, default to None (redis uses 10) Hint for redis about the number of expected result Yields ------- st...
[ "def", "scan_model_keys", "(", "cls", ",", "count", "=", "None", ")", ":", "pattern", "=", "cls", ".", "make_key", "(", "cls", ".", "_name", ",", "\"*\"", ",", ")", "return", "cls", ".", "database", ".", "scan_keys", "(", "pattern", ",", "count", ")"...
Iter on all the key related to the current model, using redis SCAN command Parameters ---------- count: int, default to None (redis uses 10) Hint for redis about the number of expected result Yields ------- str All keys found by the scan, one by ...
[ "Iter", "on", "all", "the", "key", "related", "to", "the", "current", "model", "using", "redis", "SCAN", "command" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/model.py#L573-L594
54,288
dfunckt/django-connections
connections/models.py
get_model
def get_model(model): """ Given a model name as ``app_label.ModelName``, returns the Django model. """ try: if isinstance(model, str): app_label, model_name = model.split('.', 1) m = loading.get_model(app_label, model_name) if not m: # pragma: no cover ...
python
def get_model(model): """ Given a model name as ``app_label.ModelName``, returns the Django model. """ try: if isinstance(model, str): app_label, model_name = model.split('.', 1) m = loading.get_model(app_label, model_name) if not m: # pragma: no cover ...
[ "def", "get_model", "(", "model", ")", ":", "try", ":", "if", "isinstance", "(", "model", ",", "str", ")", ":", "app_label", ",", "model_name", "=", "model", ".", "split", "(", "'.'", ",", "1", ")", "m", "=", "loading", ".", "get_model", "(", "app_...
Given a model name as ``app_label.ModelName``, returns the Django model.
[ "Given", "a", "model", "name", "as", "app_label", ".", "ModelName", "returns", "the", "Django", "model", "." ]
15f40d187df673da6e6245ccfeca3cf13355f0ab
https://github.com/dfunckt/django-connections/blob/15f40d187df673da6e6245ccfeca3cf13355f0ab/connections/models.py#L19-L34
54,289
dfunckt/django-connections
connections/models.py
Relationship._validate_ctypes
def _validate_ctypes(self, from_obj, to_obj): """ Asserts that the content types for the given object are valid for this relationship. If validation fails, ``AssertionError`` will be raised. """ if from_obj: from_ctype = ContentType.objects.get_for_model(from_obj) ...
python
def _validate_ctypes(self, from_obj, to_obj): """ Asserts that the content types for the given object are valid for this relationship. If validation fails, ``AssertionError`` will be raised. """ if from_obj: from_ctype = ContentType.objects.get_for_model(from_obj) ...
[ "def", "_validate_ctypes", "(", "self", ",", "from_obj", ",", "to_obj", ")", ":", "if", "from_obj", ":", "from_ctype", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "from_obj", ")", "assert", "from_ctype", ".", "natural_key", "(", ")", "==",...
Asserts that the content types for the given object are valid for this relationship. If validation fails, ``AssertionError`` will be raised.
[ "Asserts", "that", "the", "content", "types", "for", "the", "given", "object", "are", "valid", "for", "this", "relationship", ".", "If", "validation", "fails", "AssertionError", "will", "be", "raised", "." ]
15f40d187df673da6e6245ccfeca3cf13355f0ab
https://github.com/dfunckt/django-connections/blob/15f40d187df673da6e6245ccfeca3cf13355f0ab/connections/models.py#L99-L113
54,290
dfunckt/django-connections
connections/models.py
Relationship.create_connection
def create_connection(self, from_obj, to_obj): """ Creates and returns a connection between the given objects. If a connection already exists, that connection will be returned instead. """ self._validate_ctypes(from_obj, to_obj) return Connection.objects.get_or_create(rel...
python
def create_connection(self, from_obj, to_obj): """ Creates and returns a connection between the given objects. If a connection already exists, that connection will be returned instead. """ self._validate_ctypes(from_obj, to_obj) return Connection.objects.get_or_create(rel...
[ "def", "create_connection", "(", "self", ",", "from_obj", ",", "to_obj", ")", ":", "self", ".", "_validate_ctypes", "(", "from_obj", ",", "to_obj", ")", "return", "Connection", ".", "objects", ".", "get_or_create", "(", "relationship_name", "=", "self", ".", ...
Creates and returns a connection between the given objects. If a connection already exists, that connection will be returned instead.
[ "Creates", "and", "returns", "a", "connection", "between", "the", "given", "objects", ".", "If", "a", "connection", "already", "exists", "that", "connection", "will", "be", "returned", "instead", "." ]
15f40d187df673da6e6245ccfeca3cf13355f0ab
https://github.com/dfunckt/django-connections/blob/15f40d187df673da6e6245ccfeca3cf13355f0ab/connections/models.py#L122-L129
54,291
dfunckt/django-connections
connections/models.py
Relationship.get_connection
def get_connection(self, from_obj, to_obj): """ Returns a ``Connection`` instance for the given objects or ``None`` if there's no connection. """ self._validate_ctypes(from_obj, to_obj) try: return self.connections.get(from_pk=from_obj.pk, to_pk=to_obj.pk) ...
python
def get_connection(self, from_obj, to_obj): """ Returns a ``Connection`` instance for the given objects or ``None`` if there's no connection. """ self._validate_ctypes(from_obj, to_obj) try: return self.connections.get(from_pk=from_obj.pk, to_pk=to_obj.pk) ...
[ "def", "get_connection", "(", "self", ",", "from_obj", ",", "to_obj", ")", ":", "self", ".", "_validate_ctypes", "(", "from_obj", ",", "to_obj", ")", "try", ":", "return", "self", ".", "connections", ".", "get", "(", "from_pk", "=", "from_obj", ".", "pk"...
Returns a ``Connection`` instance for the given objects or ``None`` if there's no connection.
[ "Returns", "a", "Connection", "instance", "for", "the", "given", "objects", "or", "None", "if", "there", "s", "no", "connection", "." ]
15f40d187df673da6e6245ccfeca3cf13355f0ab
https://github.com/dfunckt/django-connections/blob/15f40d187df673da6e6245ccfeca3cf13355f0ab/connections/models.py#L131-L140
54,292
dfunckt/django-connections
connections/models.py
Relationship.connection_exists
def connection_exists(self, from_obj, to_obj): """ Returns ``True`` if a connection between the given objects exists, else ``False``. """ self._validate_ctypes(from_obj, to_obj) return self.connections.filter(from_pk=from_obj.pk, to_pk=to_obj.pk).exists()
python
def connection_exists(self, from_obj, to_obj): """ Returns ``True`` if a connection between the given objects exists, else ``False``. """ self._validate_ctypes(from_obj, to_obj) return self.connections.filter(from_pk=from_obj.pk, to_pk=to_obj.pk).exists()
[ "def", "connection_exists", "(", "self", ",", "from_obj", ",", "to_obj", ")", ":", "self", ".", "_validate_ctypes", "(", "from_obj", ",", "to_obj", ")", "return", "self", ".", "connections", ".", "filter", "(", "from_pk", "=", "from_obj", ".", "pk", ",", ...
Returns ``True`` if a connection between the given objects exists, else ``False``.
[ "Returns", "True", "if", "a", "connection", "between", "the", "given", "objects", "exists", "else", "False", "." ]
15f40d187df673da6e6245ccfeca3cf13355f0ab
https://github.com/dfunckt/django-connections/blob/15f40d187df673da6e6245ccfeca3cf13355f0ab/connections/models.py#L142-L148
54,293
dfunckt/django-connections
connections/models.py
Relationship.connections_from_object
def connections_from_object(self, from_obj): """ Returns a ``Connection`` query set matching all connections with the given object as a source. """ self._validate_ctypes(from_obj, None) return self.connections.filter(from_pk=from_obj.pk)
python
def connections_from_object(self, from_obj): """ Returns a ``Connection`` query set matching all connections with the given object as a source. """ self._validate_ctypes(from_obj, None) return self.connections.filter(from_pk=from_obj.pk)
[ "def", "connections_from_object", "(", "self", ",", "from_obj", ")", ":", "self", ".", "_validate_ctypes", "(", "from_obj", ",", "None", ")", "return", "self", ".", "connections", ".", "filter", "(", "from_pk", "=", "from_obj", ".", "pk", ")" ]
Returns a ``Connection`` query set matching all connections with the given object as a source.
[ "Returns", "a", "Connection", "query", "set", "matching", "all", "connections", "with", "the", "given", "object", "as", "a", "source", "." ]
15f40d187df673da6e6245ccfeca3cf13355f0ab
https://github.com/dfunckt/django-connections/blob/15f40d187df673da6e6245ccfeca3cf13355f0ab/connections/models.py#L150-L156
54,294
dfunckt/django-connections
connections/models.py
Relationship.connections_to_object
def connections_to_object(self, to_obj): """ Returns a ``Connection`` query set matching all connections with the given object as a destination. """ self._validate_ctypes(None, to_obj) return self.connections.filter(to_pk=to_obj.pk)
python
def connections_to_object(self, to_obj): """ Returns a ``Connection`` query set matching all connections with the given object as a destination. """ self._validate_ctypes(None, to_obj) return self.connections.filter(to_pk=to_obj.pk)
[ "def", "connections_to_object", "(", "self", ",", "to_obj", ")", ":", "self", ".", "_validate_ctypes", "(", "None", ",", "to_obj", ")", "return", "self", ".", "connections", ".", "filter", "(", "to_pk", "=", "to_obj", ".", "pk", ")" ]
Returns a ``Connection`` query set matching all connections with the given object as a destination.
[ "Returns", "a", "Connection", "query", "set", "matching", "all", "connections", "with", "the", "given", "object", "as", "a", "destination", "." ]
15f40d187df673da6e6245ccfeca3cf13355f0ab
https://github.com/dfunckt/django-connections/blob/15f40d187df673da6e6245ccfeca3cf13355f0ab/connections/models.py#L158-L164
54,295
dfunckt/django-connections
connections/models.py
Relationship.connected_objects
def connected_objects(self, from_obj): """ Returns a query set matching all connected objects with the given object as a source. """ return self.to_content_type.get_all_objects_for_this_type(pk__in=self.connected_object_ids(from_obj))
python
def connected_objects(self, from_obj): """ Returns a query set matching all connected objects with the given object as a source. """ return self.to_content_type.get_all_objects_for_this_type(pk__in=self.connected_object_ids(from_obj))
[ "def", "connected_objects", "(", "self", ",", "from_obj", ")", ":", "return", "self", ".", "to_content_type", ".", "get_all_objects_for_this_type", "(", "pk__in", "=", "self", ".", "connected_object_ids", "(", "from_obj", ")", ")" ]
Returns a query set matching all connected objects with the given object as a source.
[ "Returns", "a", "query", "set", "matching", "all", "connected", "objects", "with", "the", "given", "object", "as", "a", "source", "." ]
15f40d187df673da6e6245ccfeca3cf13355f0ab
https://github.com/dfunckt/django-connections/blob/15f40d187df673da6e6245ccfeca3cf13355f0ab/connections/models.py#L166-L171
54,296
dfunckt/django-connections
connections/models.py
Relationship.connected_to_objects
def connected_to_objects(self, to_obj): """ Returns a query set matching all connected objects with the given object as a destination. """ return self.from_content_type.get_all_objects_for_this_type(pk__in=self.connected_to_object_ids(to_obj))
python
def connected_to_objects(self, to_obj): """ Returns a query set matching all connected objects with the given object as a destination. """ return self.from_content_type.get_all_objects_for_this_type(pk__in=self.connected_to_object_ids(to_obj))
[ "def", "connected_to_objects", "(", "self", ",", "to_obj", ")", ":", "return", "self", ".", "from_content_type", ".", "get_all_objects_for_this_type", "(", "pk__in", "=", "self", ".", "connected_to_object_ids", "(", "to_obj", ")", ")" ]
Returns a query set matching all connected objects with the given object as a destination.
[ "Returns", "a", "query", "set", "matching", "all", "connected", "objects", "with", "the", "given", "object", "as", "a", "destination", "." ]
15f40d187df673da6e6245ccfeca3cf13355f0ab
https://github.com/dfunckt/django-connections/blob/15f40d187df673da6e6245ccfeca3cf13355f0ab/connections/models.py#L180-L185
54,297
dfunckt/django-connections
connections/models.py
Relationship.distance_between
def distance_between(self, from_obj, to_obj, limit=2): """ Calculates the distance between two objects. Distance 0 means ``from_obj`` and ``to_obj`` are the same objects, 1 means ``from_obj`` has a direct connection to ``to_obj``, 2 means that one or more of ``from_obj``'s connec...
python
def distance_between(self, from_obj, to_obj, limit=2): """ Calculates the distance between two objects. Distance 0 means ``from_obj`` and ``to_obj`` are the same objects, 1 means ``from_obj`` has a direct connection to ``to_obj``, 2 means that one or more of ``from_obj``'s connec...
[ "def", "distance_between", "(", "self", ",", "from_obj", ",", "to_obj", ",", "limit", "=", "2", ")", ":", "self", ".", "_validate_ctypes", "(", "from_obj", ",", "to_obj", ")", "if", "from_obj", "==", "to_obj", ":", "return", "0", "d", "=", "1", "pk", ...
Calculates the distance between two objects. Distance 0 means ``from_obj`` and ``to_obj`` are the same objects, 1 means ``from_obj`` has a direct connection to ``to_obj``, 2 means that one or more of ``from_obj``'s connected objects are directly connected to ``to_obj``, etc. ...
[ "Calculates", "the", "distance", "between", "two", "objects", ".", "Distance", "0", "means", "from_obj", "and", "to_obj", "are", "the", "same", "objects", "1", "means", "from_obj", "has", "a", "direct", "connection", "to", "to_obj", "2", "means", "that", "on...
15f40d187df673da6e6245ccfeca3cf13355f0ab
https://github.com/dfunckt/django-connections/blob/15f40d187df673da6e6245ccfeca3cf13355f0ab/connections/models.py#L194-L224
54,298
caseyjlaw/rtpipe
rtpipe/calpipe.py
pipe.genms
def genms(self, scans=[]): """ Generate an MS that contains all calibrator scans with 1 s integration time. """ if len(scans): scanstr = string.join([str(ss) for ss in sorted(scans)], ',') else: scanstr = self.allstr print 'Splitting out all cal scans (%...
python
def genms(self, scans=[]): """ Generate an MS that contains all calibrator scans with 1 s integration time. """ if len(scans): scanstr = string.join([str(ss) for ss in sorted(scans)], ',') else: scanstr = self.allstr print 'Splitting out all cal scans (%...
[ "def", "genms", "(", "self", ",", "scans", "=", "[", "]", ")", ":", "if", "len", "(", "scans", ")", ":", "scanstr", "=", "string", ".", "join", "(", "[", "str", "(", "ss", ")", "for", "ss", "in", "sorted", "(", "scans", ")", "]", ",", "','", ...
Generate an MS that contains all calibrator scans with 1 s integration time.
[ "Generate", "an", "MS", "that", "contains", "all", "calibrator", "scans", "with", "1", "s", "integration", "time", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/calpipe.py#L64-L76
54,299
Fantomas42/django-emoticons
emoticons/templatetags/emoticons_tags.py
regexp_replace_emoticons
def regexp_replace_emoticons(content): """ Replace the emoticons string by HTML images, with regular expressions. """ for emoticon, emoticon_html in EMOTICONS_COMPILED: if emoticon.search(content): content = emoticon.sub(emoticon_html, content) return content
python
def regexp_replace_emoticons(content): """ Replace the emoticons string by HTML images, with regular expressions. """ for emoticon, emoticon_html in EMOTICONS_COMPILED: if emoticon.search(content): content = emoticon.sub(emoticon_html, content) return content
[ "def", "regexp_replace_emoticons", "(", "content", ")", ":", "for", "emoticon", ",", "emoticon_html", "in", "EMOTICONS_COMPILED", ":", "if", "emoticon", ".", "search", "(", "content", ")", ":", "content", "=", "emoticon", ".", "sub", "(", "emoticon_html", ",",...
Replace the emoticons string by HTML images, with regular expressions.
[ "Replace", "the", "emoticons", "string", "by", "HTML", "images", "with", "regular", "expressions", "." ]
14a9895505874dfdd28e74d563a5fc521e3a315f
https://github.com/Fantomas42/django-emoticons/blob/14a9895505874dfdd28e74d563a5fc521e3a315f/emoticons/templatetags/emoticons_tags.py#L14-L22