repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_Item.save
def save(self): '''Save all changes on this item (if any) back to Redmine.''' self._check_custom_fields() if not self._changes: return None for tag in self._remap_to_id: self._remap_tag_to_tag_id(tag, self._changes) # Check for custom handlers for tags ...
python
def save(self): '''Save all changes on this item (if any) back to Redmine.''' self._check_custom_fields() if not self._changes: return None for tag in self._remap_to_id: self._remap_tag_to_tag_id(tag, self._changes) # Check for custom handlers for tags ...
[ "def", "save", "(", "self", ")", ":", "self", ".", "_check_custom_fields", "(", ")", "if", "not", "self", ".", "_changes", ":", "return", "None", "for", "tag", "in", "self", ".", "_remap_to_id", ":", "self", ".", "_remap_tag_to_tag_id", "(", "tag", ",", ...
Save all changes on this item (if any) back to Redmine.
[ "Save", "all", "changes", "on", "this", "item", "(", "if", "any", ")", "back", "to", "Redmine", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L233-L271
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_Item.refresh
def refresh(self): '''Refresh this item from data on the server. Will save any unsaved data first.''' if not self._item_path: raise AttributeError('refresh is not available for %s' % self._type) if not self.id: raise RedmineError('%s did not come from the Redmine...
python
def refresh(self): '''Refresh this item from data on the server. Will save any unsaved data first.''' if not self._item_path: raise AttributeError('refresh is not available for %s' % self._type) if not self.id: raise RedmineError('%s did not come from the Redmine...
[ "def", "refresh", "(", "self", ")", ":", "if", "not", "self", ".", "_item_path", ":", "raise", "AttributeError", "(", "'refresh is not available for %s'", "%", "self", ".", "_type", ")", "if", "not", "self", ".", "id", ":", "raise", "RedmineError", "(", "'...
Refresh this item from data on the server. Will save any unsaved data first.
[ "Refresh", "this", "item", "from", "data", "on", "the", "server", ".", "Will", "save", "any", "unsaved", "data", "first", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L284-L302
ianepperson/pyredminews
redmine/redmine_rest.py
Custom_Fields._get_changes
def _get_changes(self): '''Get all changed values.''' result = dict( (f['id'], f.get('value','')) for f in self._data if f.get('changed', False) ) self._clear_changes return result
python
def _get_changes(self): '''Get all changed values.''' result = dict( (f['id'], f.get('value','')) for f in self._data if f.get('changed', False) ) self._clear_changes return result
[ "def", "_get_changes", "(", "self", ")", ":", "result", "=", "dict", "(", "(", "f", "[", "'id'", "]", ",", "f", ".", "get", "(", "'value'", ",", "''", ")", ")", "for", "f", "in", "self", ".", "_data", "if", "f", ".", "get", "(", "'changed'", ...
Get all changed values.
[ "Get", "all", "changed", "values", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L335-L339
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_Items_Manager.iteritems
def iteritems(self, **options): '''Return a query interator with (id, object) pairs.''' iter = self.query(**options) while True: obj = iter.next() yield (obj.id, obj)
python
def iteritems(self, **options): '''Return a query interator with (id, object) pairs.''' iter = self.query(**options) while True: obj = iter.next() yield (obj.id, obj)
[ "def", "iteritems", "(", "self", ",", "*", "*", "options", ")", ":", "iter", "=", "self", ".", "query", "(", "*", "*", "options", ")", "while", "True", ":", "obj", "=", "iter", ".", "next", "(", ")", "yield", "(", "obj", ".", "id", ",", "obj", ...
Return a query interator with (id, object) pairs.
[ "Return", "a", "query", "interator", "with", "(", "id", "object", ")", "pairs", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L488-L493
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_Items_Manager._objectify
def _objectify(self, json_data=None, data={}): '''Return an object derived from the given json data.''' if json_data: # Parse the data try: data = json.loads(json_data) except ValueError: # If parsing failed, then raise the string which...
python
def _objectify(self, json_data=None, data={}): '''Return an object derived from the given json data.''' if json_data: # Parse the data try: data = json.loads(json_data) except ValueError: # If parsing failed, then raise the string which...
[ "def", "_objectify", "(", "self", ",", "json_data", "=", "None", ",", "data", "=", "{", "}", ")", ":", "if", "json_data", ":", "# Parse the data", "try", ":", "data", "=", "json", ".", "loads", "(", "json_data", ")", "except", "ValueError", ":", "# If ...
Return an object derived from the given json data.
[ "Return", "an", "object", "derived", "from", "the", "given", "json", "data", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L503-L520
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_Items_Manager.new
def new(self, **dict): '''Create a new item with the provided dict information. Returns the new item.''' if not self._item_new_path: raise AttributeError('new is not available for %s' % self._item_name) # Remap various tag to tag_id for tag in self._object._remap_to_id: ...
python
def new(self, **dict): '''Create a new item with the provided dict information. Returns the new item.''' if not self._item_new_path: raise AttributeError('new is not available for %s' % self._item_name) # Remap various tag to tag_id for tag in self._object._remap_to_id: ...
[ "def", "new", "(", "self", ",", "*", "*", "dict", ")", ":", "if", "not", "self", ".", "_item_new_path", ":", "raise", "AttributeError", "(", "'new is not available for %s'", "%", "self", ".", "_item_name", ")", "# Remap various tag to tag_id", "for", "tag", "i...
Create a new item with the provided dict information. Returns the new item.
[ "Create", "a", "new", "item", "with", "the", "provided", "dict", "information", ".", "Returns", "the", "new", "item", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L522-L536
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_Items_Manager.get
def get(self, id, **options): '''Get a single item with the given ID''' if not self._item_path: raise AttributeError('get is not available for %s' % self._item_name) target = self._item_path % id json_data = self._redmine.get(target, **options) data = self._redmine.un...
python
def get(self, id, **options): '''Get a single item with the given ID''' if not self._item_path: raise AttributeError('get is not available for %s' % self._item_name) target = self._item_path % id json_data = self._redmine.get(target, **options) data = self._redmine.un...
[ "def", "get", "(", "self", ",", "id", ",", "*", "*", "options", ")", ":", "if", "not", "self", ".", "_item_path", ":", "raise", "AttributeError", "(", "'get is not available for %s'", "%", "self", ".", "_item_name", ")", "target", "=", "self", ".", "_ite...
Get a single item with the given ID
[ "Get", "a", "single", "item", "with", "the", "given", "ID" ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L538-L546
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_Items_Manager.update
def update(self, id, **dict): '''Update a given item with the passed data.''' if not self._item_path: raise AttributeError('update is not available for %s' % self._item_name) target = (self._update_path or self._item_path) % id payload = json.dumps({self._item_type:dict}) ...
python
def update(self, id, **dict): '''Update a given item with the passed data.''' if not self._item_path: raise AttributeError('update is not available for %s' % self._item_name) target = (self._update_path or self._item_path) % id payload = json.dumps({self._item_type:dict}) ...
[ "def", "update", "(", "self", ",", "id", ",", "*", "*", "dict", ")", ":", "if", "not", "self", ".", "_item_path", ":", "raise", "AttributeError", "(", "'update is not available for %s'", "%", "self", ".", "_item_name", ")", "target", "=", "(", "self", "....
Update a given item with the passed data.
[ "Update", "a", "given", "item", "with", "the", "passed", "data", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L548-L555
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_Items_Manager.delete
def delete(self, id): '''Delete a single item with the given ID''' if not self._item_path: raise AttributeError('delete is not available for %s' % self._item_name) target = self._item_path % id self._redmine.delete(target) return None
python
def delete(self, id): '''Delete a single item with the given ID''' if not self._item_path: raise AttributeError('delete is not available for %s' % self._item_name) target = self._item_path % id self._redmine.delete(target) return None
[ "def", "delete", "(", "self", ",", "id", ")", ":", "if", "not", "self", ".", "_item_path", ":", "raise", "AttributeError", "(", "'delete is not available for %s'", "%", "self", ".", "_item_name", ")", "target", "=", "self", ".", "_item_path", "%", "id", "s...
Delete a single item with the given ID
[ "Delete", "a", "single", "item", "with", "the", "given", "ID" ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L557-L563
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_Items_Manager.query
def query(self, **options): '''Return an iterator for the given items.''' if not self._query_path: raise AttributeError('query is not available for %s' % self._item_name) last_item = 0 offset = 0 current_item = None limit = options.get('limit', 25) opt...
python
def query(self, **options): '''Return an iterator for the given items.''' if not self._query_path: raise AttributeError('query is not available for %s' % self._item_name) last_item = 0 offset = 0 current_item = None limit = options.get('limit', 25) opt...
[ "def", "query", "(", "self", ",", "*", "*", "options", ")", ":", "if", "not", "self", ".", "_query_path", ":", "raise", "AttributeError", "(", "'query is not available for %s'", "%", "self", ".", "_item_name", ")", "last_item", "=", "0", "offset", "=", "0"...
Return an iterator for the given items.
[ "Return", "an", "iterator", "for", "the", "given", "items", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L565-L602
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_WS._setup_authentication
def _setup_authentication(self, username, password): '''Create the authentication object with the given credentials.''' ## BUG WORKAROUND if self.version < 1.1: # Version 1.0 had a bug when using the key parameter. # Later versions have the opposite bug (a key in the use...
python
def _setup_authentication(self, username, password): '''Create the authentication object with the given credentials.''' ## BUG WORKAROUND if self.version < 1.1: # Version 1.0 had a bug when using the key parameter. # Later versions have the opposite bug (a key in the use...
[ "def", "_setup_authentication", "(", "self", ",", "username", ",", "password", ")", ":", "## BUG WORKAROUND", "if", "self", ".", "version", "<", "1.1", ":", "# Version 1.0 had a bug when using the key parameter.", "# Later versions have the opposite bug (a key in the username d...
Create the authentication object with the given credentials.
[ "Create", "the", "authentication", "object", "with", "the", "given", "credentials", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L631-L661
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_WS.open_raw
def open_raw(self, page, parms=None, payload=None, HTTPrequest=None, payload_type='application/json' ): '''Opens a page from the server with optional XML. Returns a response file-like object''' if not parms: parms={} # if we're using a key, but it's not going in the header, add it ...
python
def open_raw(self, page, parms=None, payload=None, HTTPrequest=None, payload_type='application/json' ): '''Opens a page from the server with optional XML. Returns a response file-like object''' if not parms: parms={} # if we're using a key, but it's not going in the header, add it ...
[ "def", "open_raw", "(", "self", ",", "page", ",", "parms", "=", "None", ",", "payload", "=", "None", ",", "HTTPrequest", "=", "None", ",", "payload_type", "=", "'application/json'", ")", ":", "if", "not", "parms", ":", "parms", "=", "{", "}", "# if we'...
Opens a page from the server with optional XML. Returns a response file-like object
[ "Opens", "a", "page", "from", "the", "server", "with", "optional", "XML", ".", "Returns", "a", "response", "file", "-", "like", "object" ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L663-L713
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_WS.open
def open(self, page, parms=None, payload=None, HTTPrequest=None ): '''Opens a page from the server with optional content. Returns the string response.''' response = self.open_raw( page, parms, payload, HTTPrequest ) return response.read()
python
def open(self, page, parms=None, payload=None, HTTPrequest=None ): '''Opens a page from the server with optional content. Returns the string response.''' response = self.open_raw( page, parms, payload, HTTPrequest ) return response.read()
[ "def", "open", "(", "self", ",", "page", ",", "parms", "=", "None", ",", "payload", "=", "None", ",", "HTTPrequest", "=", "None", ")", ":", "response", "=", "self", ".", "open_raw", "(", "page", ",", "parms", ",", "payload", ",", "HTTPrequest", ")", ...
Opens a page from the server with optional content. Returns the string response.
[ "Opens", "a", "page", "from", "the", "server", "with", "optional", "content", ".", "Returns", "the", "string", "response", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L715-L718
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_WS.post
def post(self, page, payload, parms=None ): '''Posts a string payload to the server - used to make new Redmine items. Returns an JSON string or error.''' if self.readonlytest: print 'Redmine read only test: Pretending to create: ' + page return payload else: ...
python
def post(self, page, payload, parms=None ): '''Posts a string payload to the server - used to make new Redmine items. Returns an JSON string or error.''' if self.readonlytest: print 'Redmine read only test: Pretending to create: ' + page return payload else: ...
[ "def", "post", "(", "self", ",", "page", ",", "payload", ",", "parms", "=", "None", ")", ":", "if", "self", ".", "readonlytest", ":", "print", "'Redmine read only test: Pretending to create: '", "+", "page", "return", "payload", "else", ":", "return", "self", ...
Posts a string payload to the server - used to make new Redmine items. Returns an JSON string or error.
[ "Posts", "a", "string", "payload", "to", "the", "server", "-", "used", "to", "make", "new", "Redmine", "items", ".", "Returns", "an", "JSON", "string", "or", "error", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L725-L731
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_WS.put
def put(self, page, payload, parms=None ): '''Puts an XML object on the server - used to update Redmine items. Returns nothing useful.''' if self.readonlytest: print 'Redmine read only test: Pretending to update: ' + page else: return self.open( page, parms, payload, HTT...
python
def put(self, page, payload, parms=None ): '''Puts an XML object on the server - used to update Redmine items. Returns nothing useful.''' if self.readonlytest: print 'Redmine read only test: Pretending to update: ' + page else: return self.open( page, parms, payload, HTT...
[ "def", "put", "(", "self", ",", "page", ",", "payload", ",", "parms", "=", "None", ")", ":", "if", "self", ".", "readonlytest", ":", "print", "'Redmine read only test: Pretending to update: '", "+", "page", "else", ":", "return", "self", ".", "open", "(", ...
Puts an XML object on the server - used to update Redmine items. Returns nothing useful.
[ "Puts", "an", "XML", "object", "on", "the", "server", "-", "used", "to", "update", "Redmine", "items", ".", "Returns", "nothing", "useful", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L733-L738
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_WS.delete
def delete(self, page ): '''Deletes a given object on the server - used to remove items from Redmine. Use carefully!''' if self.readonlytest: print 'Redmine read only test: Pretending to delete: ' + page else: return self.open( page, HTTPrequest=self.DELETE_Request )
python
def delete(self, page ): '''Deletes a given object on the server - used to remove items from Redmine. Use carefully!''' if self.readonlytest: print 'Redmine read only test: Pretending to delete: ' + page else: return self.open( page, HTTPrequest=self.DELETE_Request )
[ "def", "delete", "(", "self", ",", "page", ")", ":", "if", "self", ".", "readonlytest", ":", "print", "'Redmine read only test: Pretending to delete: '", "+", "page", "else", ":", "return", "self", ".", "open", "(", "page", ",", "HTTPrequest", "=", "self", "...
Deletes a given object on the server - used to remove items from Redmine. Use carefully!
[ "Deletes", "a", "given", "object", "on", "the", "server", "-", "used", "to", "remove", "items", "from", "Redmine", ".", "Use", "carefully!" ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L740-L745
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_WS.unwrap_json
def unwrap_json(self, type, json_data): '''Decodes a json string, and unwraps any 'type' it finds within.''' # Parse the data try: data = json.loads(json_data) except ValueError: # If parsing failed, then raise the string which likely contains an error message ins...
python
def unwrap_json(self, type, json_data): '''Decodes a json string, and unwraps any 'type' it finds within.''' # Parse the data try: data = json.loads(json_data) except ValueError: # If parsing failed, then raise the string which likely contains an error message ins...
[ "def", "unwrap_json", "(", "self", ",", "type", ",", "json_data", ")", ":", "# Parse the data", "try", ":", "data", "=", "json", ".", "loads", "(", "json_data", ")", "except", "ValueError", ":", "# If parsing failed, then raise the string which likely contains an erro...
Decodes a json string, and unwraps any 'type' it finds within.
[ "Decodes", "a", "json", "string", "and", "unwraps", "any", "type", "it", "finds", "within", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L752-L766
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_WS.find_all_item_classes
def find_all_item_classes(self): '''Finds and stores a reference to all Redmine_Item subclasses for later use.''' # This is a circular import, but performed after the class is defined and an object is instatiated. # We do this in order to get references to any objects definitions in the redmine....
python
def find_all_item_classes(self): '''Finds and stores a reference to all Redmine_Item subclasses for later use.''' # This is a circular import, but performed after the class is defined and an object is instatiated. # We do this in order to get references to any objects definitions in the redmine....
[ "def", "find_all_item_classes", "(", "self", ")", ":", "# This is a circular import, but performed after the class is defined and an object is instatiated.", "# We do this in order to get references to any objects definitions in the redmine.py file", "# without requiring anyone editing the file to d...
Finds and stores a reference to all Redmine_Item subclasses for later use.
[ "Finds", "and", "stores", "a", "reference", "to", "all", "Redmine_Item", "subclasses", "for", "later", "use", "." ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L769-L783
ianepperson/pyredminews
redmine/redmine_rest.py
Redmine_WS.check_cache
def check_cache(self, type, data, obj=None): '''Returns the updated cached version of the given dict''' try: id = data['id'] except: # Not an identifiable item #print 'don\'t know this item %r:%r' % (type, data) return data # If obj was pa...
python
def check_cache(self, type, data, obj=None): '''Returns the updated cached version of the given dict''' try: id = data['id'] except: # Not an identifiable item #print 'don\'t know this item %r:%r' % (type, data) return data # If obj was pa...
[ "def", "check_cache", "(", "self", ",", "type", ",", "data", ",", "obj", "=", "None", ")", ":", "try", ":", "id", "=", "data", "[", "'id'", "]", "except", ":", "# Not an identifiable item", "#print 'don\\'t know this item %r:%r' % (type, data)", "return", "data"...
Returns the updated cached version of the given dict
[ "Returns", "the", "updated", "cached", "version", "of", "the", "given", "dict" ]
train
https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L785-L822
allelos/vectors
vectors/vectors.py
Point.substract
def substract(self, pt): """Return a Point instance as the displacement of two points.""" if isinstance(pt, Point): return Point(pt.x - self.x, pt.y - self.y, pt.z - self.z) else: raise TypeError
python
def substract(self, pt): """Return a Point instance as the displacement of two points.""" if isinstance(pt, Point): return Point(pt.x - self.x, pt.y - self.y, pt.z - self.z) else: raise TypeError
[ "def", "substract", "(", "self", ",", "pt", ")", ":", "if", "isinstance", "(", "pt", ",", "Point", ")", ":", "return", "Point", "(", "pt", ".", "x", "-", "self", ".", "x", ",", "pt", ".", "y", "-", "self", ".", "y", ",", "pt", ".", "z", "-"...
Return a Point instance as the displacement of two points.
[ "Return", "a", "Point", "instance", "as", "the", "displacement", "of", "two", "points", "." ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L54-L59
allelos/vectors
vectors/vectors.py
Point.from_list
def from_list(cls, l): """Return a Point instance from a given list""" if len(l) == 3: x, y, z = map(float, l) return cls(x, y, z) elif len(l) == 2: x, y = map(float, l) return cls(x, y) else: raise AttributeError
python
def from_list(cls, l): """Return a Point instance from a given list""" if len(l) == 3: x, y, z = map(float, l) return cls(x, y, z) elif len(l) == 2: x, y = map(float, l) return cls(x, y) else: raise AttributeError
[ "def", "from_list", "(", "cls", ",", "l", ")", ":", "if", "len", "(", "l", ")", "==", "3", ":", "x", ",", "y", ",", "z", "=", "map", "(", "float", ",", "l", ")", "return", "cls", "(", "x", ",", "y", ",", "z", ")", "elif", "len", "(", "l...
Return a Point instance from a given list
[ "Return", "a", "Point", "instance", "from", "a", "given", "list" ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L62-L71
allelos/vectors
vectors/vectors.py
Vector.multiply
def multiply(self, number): """Return a Vector as the product of the vector and a real number.""" return self.from_list([x * number for x in self.to_list()])
python
def multiply(self, number): """Return a Vector as the product of the vector and a real number.""" return self.from_list([x * number for x in self.to_list()])
[ "def", "multiply", "(", "self", ",", "number", ")", ":", "return", "self", ".", "from_list", "(", "[", "x", "*", "number", "for", "x", "in", "self", ".", "to_list", "(", ")", "]", ")" ]
Return a Vector as the product of the vector and a real number.
[ "Return", "a", "Vector", "as", "the", "product", "of", "the", "vector", "and", "a", "real", "number", "." ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L120-L122
allelos/vectors
vectors/vectors.py
Vector.magnitude
def magnitude(self): """Return magnitude of the vector.""" return math.sqrt( reduce(lambda x, y: x + y, [x ** 2 for x in self.to_list()]) )
python
def magnitude(self): """Return magnitude of the vector.""" return math.sqrt( reduce(lambda x, y: x + y, [x ** 2 for x in self.to_list()]) )
[ "def", "magnitude", "(", "self", ")", ":", "return", "math", ".", "sqrt", "(", "reduce", "(", "lambda", "x", ",", "y", ":", "x", "+", "y", ",", "[", "x", "**", "2", "for", "x", "in", "self", ".", "to_list", "(", ")", "]", ")", ")" ]
Return magnitude of the vector.
[ "Return", "magnitude", "of", "the", "vector", "." ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L124-L128
allelos/vectors
vectors/vectors.py
Vector.sum
def sum(self, vector): """Return a Vector instance as the vector sum of two vectors.""" return self.from_list( [x + vector.vector[i] for i, x in self.to_list()] )
python
def sum(self, vector): """Return a Vector instance as the vector sum of two vectors.""" return self.from_list( [x + vector.vector[i] for i, x in self.to_list()] )
[ "def", "sum", "(", "self", ",", "vector", ")", ":", "return", "self", ".", "from_list", "(", "[", "x", "+", "vector", ".", "vector", "[", "i", "]", "for", "i", ",", "x", "in", "self", ".", "to_list", "(", ")", "]", ")" ]
Return a Vector instance as the vector sum of two vectors.
[ "Return", "a", "Vector", "instance", "as", "the", "vector", "sum", "of", "two", "vectors", "." ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L130-L134
allelos/vectors
vectors/vectors.py
Vector.dot
def dot(self, vector, theta=None): """Return the dot product of two vectors. If theta is given then the dot product is computed as v1*v1 = |v1||v2|cos(theta). Argument theta is measured in degrees. """ if theta is not None: return (self.magnitude() * vector.m...
python
def dot(self, vector, theta=None): """Return the dot product of two vectors. If theta is given then the dot product is computed as v1*v1 = |v1||v2|cos(theta). Argument theta is measured in degrees. """ if theta is not None: return (self.magnitude() * vector.m...
[ "def", "dot", "(", "self", ",", "vector", ",", "theta", "=", "None", ")", ":", "if", "theta", "is", "not", "None", ":", "return", "(", "self", ".", "magnitude", "(", ")", "*", "vector", ".", "magnitude", "(", ")", "*", "math", ".", "degrees", "("...
Return the dot product of two vectors. If theta is given then the dot product is computed as v1*v1 = |v1||v2|cos(theta). Argument theta is measured in degrees.
[ "Return", "the", "dot", "product", "of", "two", "vectors", "." ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L140-L151
allelos/vectors
vectors/vectors.py
Vector.cross
def cross(self, vector): """Return a Vector instance as the cross product of two vectors""" return Vector((self.y * vector.z - self.z * vector.y), (self.z * vector.x - self.x * vector.z), (self.x * vector.y - self.y * vector.x))
python
def cross(self, vector): """Return a Vector instance as the cross product of two vectors""" return Vector((self.y * vector.z - self.z * vector.y), (self.z * vector.x - self.x * vector.z), (self.x * vector.y - self.y * vector.x))
[ "def", "cross", "(", "self", ",", "vector", ")", ":", "return", "Vector", "(", "(", "self", ".", "y", "*", "vector", ".", "z", "-", "self", ".", "z", "*", "vector", ".", "y", ")", ",", "(", "self", ".", "z", "*", "vector", ".", "x", "-", "s...
Return a Vector instance as the cross product of two vectors
[ "Return", "a", "Vector", "instance", "as", "the", "cross", "product", "of", "two", "vectors" ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L153-L157
allelos/vectors
vectors/vectors.py
Vector.unit
def unit(self): """Return a Vector instance of the unit vector""" return Vector( (self.x / self.magnitude()), (self.y / self.magnitude()), (self.z / self.magnitude()) )
python
def unit(self): """Return a Vector instance of the unit vector""" return Vector( (self.x / self.magnitude()), (self.y / self.magnitude()), (self.z / self.magnitude()) )
[ "def", "unit", "(", "self", ")", ":", "return", "Vector", "(", "(", "self", ".", "x", "/", "self", ".", "magnitude", "(", ")", ")", ",", "(", "self", ".", "y", "/", "self", ".", "magnitude", "(", ")", ")", ",", "(", "self", ".", "z", "/", "...
Return a Vector instance of the unit vector
[ "Return", "a", "Vector", "instance", "of", "the", "unit", "vector" ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L159-L165
allelos/vectors
vectors/vectors.py
Vector.angle
def angle(self, vector): """Return the angle between two vectors in degrees.""" return math.degrees( math.acos( self.dot(vector) / (self.magnitude() * vector.magnitude()) ) )
python
def angle(self, vector): """Return the angle between two vectors in degrees.""" return math.degrees( math.acos( self.dot(vector) / (self.magnitude() * vector.magnitude()) ) )
[ "def", "angle", "(", "self", ",", "vector", ")", ":", "return", "math", ".", "degrees", "(", "math", ".", "acos", "(", "self", ".", "dot", "(", "vector", ")", "/", "(", "self", ".", "magnitude", "(", ")", "*", "vector", ".", "magnitude", "(", ")"...
Return the angle between two vectors in degrees.
[ "Return", "the", "angle", "between", "two", "vectors", "in", "degrees", "." ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L167-L174
allelos/vectors
vectors/vectors.py
Vector.non_parallel
def non_parallel(self, vector): """Return True if vectors are non-parallel. Non-parallel vectors are vectors which are neither parallel nor perpendicular to each other. """ if (self.is_parallel(vector) is not True and self.is_perpendicular(vector) is not True): ...
python
def non_parallel(self, vector): """Return True if vectors are non-parallel. Non-parallel vectors are vectors which are neither parallel nor perpendicular to each other. """ if (self.is_parallel(vector) is not True and self.is_perpendicular(vector) is not True): ...
[ "def", "non_parallel", "(", "self", ",", "vector", ")", ":", "if", "(", "self", ".", "is_parallel", "(", "vector", ")", "is", "not", "True", "and", "self", ".", "is_perpendicular", "(", "vector", ")", "is", "not", "True", ")", ":", "return", "True", ...
Return True if vectors are non-parallel. Non-parallel vectors are vectors which are neither parallel nor perpendicular to each other.
[ "Return", "True", "if", "vectors", "are", "non", "-", "parallel", "." ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L188-L197
allelos/vectors
vectors/vectors.py
Vector.rotate
def rotate(self, angle, axis=(0, 0, 1)): """Returns the rotated vector. Assumes angle is in radians""" if not all(isinstance(a, int) for a in axis): raise ValueError x, y, z = self.x, self.y, self.z # Z axis rotation if(axis[2]): x = (self.x * math.cos(an...
python
def rotate(self, angle, axis=(0, 0, 1)): """Returns the rotated vector. Assumes angle is in radians""" if not all(isinstance(a, int) for a in axis): raise ValueError x, y, z = self.x, self.y, self.z # Z axis rotation if(axis[2]): x = (self.x * math.cos(an...
[ "def", "rotate", "(", "self", ",", "angle", ",", "axis", "=", "(", "0", ",", "0", ",", "1", ")", ")", ":", "if", "not", "all", "(", "isinstance", "(", "a", ",", "int", ")", "for", "a", "in", "axis", ")", ":", "raise", "ValueError", "x", ",", ...
Returns the rotated vector. Assumes angle is in radians
[ "Returns", "the", "rotated", "vector", ".", "Assumes", "angle", "is", "in", "radians" ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L199-L220
allelos/vectors
vectors/vectors.py
Vector.from_points
def from_points(cls, point1, point2): """Return a Vector instance from two given points.""" if isinstance(point1, Point) and isinstance(point2, Point): displacement = point1.substract(point2) return cls(displacement.x, displacement.y, displacement.z) raise TypeError
python
def from_points(cls, point1, point2): """Return a Vector instance from two given points.""" if isinstance(point1, Point) and isinstance(point2, Point): displacement = point1.substract(point2) return cls(displacement.x, displacement.y, displacement.z) raise TypeError
[ "def", "from_points", "(", "cls", ",", "point1", ",", "point2", ")", ":", "if", "isinstance", "(", "point1", ",", "Point", ")", "and", "isinstance", "(", "point2", ",", "Point", ")", ":", "displacement", "=", "point1", ".", "substract", "(", "point2", ...
Return a Vector instance from two given points.
[ "Return", "a", "Vector", "instance", "from", "two", "given", "points", "." ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L227-L232
allelos/vectors
vectors/vectors.py
Vector.spherical
def spherical(cls, mag, theta, phi=0): '''Returns a Vector instance from spherical coordinates''' return cls( mag * math.sin(phi) * math.cos(theta), # X mag * math.sin(phi) * math.sin(theta), # Y mag * math.cos(phi) # Z )
python
def spherical(cls, mag, theta, phi=0): '''Returns a Vector instance from spherical coordinates''' return cls( mag * math.sin(phi) * math.cos(theta), # X mag * math.sin(phi) * math.sin(theta), # Y mag * math.cos(phi) # Z )
[ "def", "spherical", "(", "cls", ",", "mag", ",", "theta", ",", "phi", "=", "0", ")", ":", "return", "cls", "(", "mag", "*", "math", ".", "sin", "(", "phi", ")", "*", "math", ".", "cos", "(", "theta", ")", ",", "# X", "mag", "*", "math", ".", ...
Returns a Vector instance from spherical coordinates
[ "Returns", "a", "Vector", "instance", "from", "spherical", "coordinates" ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L235-L241
allelos/vectors
vectors/vectors.py
Vector.cylindrical
def cylindrical(cls, mag, theta, z=0): '''Returns a Vector instance from cylindircal coordinates''' return cls( mag * math.cos(theta), # X mag * math.sin(theta), # Y z # Z )
python
def cylindrical(cls, mag, theta, z=0): '''Returns a Vector instance from cylindircal coordinates''' return cls( mag * math.cos(theta), # X mag * math.sin(theta), # Y z # Z )
[ "def", "cylindrical", "(", "cls", ",", "mag", ",", "theta", ",", "z", "=", "0", ")", ":", "return", "cls", "(", "mag", "*", "math", ".", "cos", "(", "theta", ")", ",", "# X", "mag", "*", "math", ".", "sin", "(", "theta", ")", ",", "# Y", "z",...
Returns a Vector instance from cylindircal coordinates
[ "Returns", "a", "Vector", "instance", "from", "cylindircal", "coordinates" ]
train
https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L244-L250
fitnr/convertdate
convertdate/utils.py
amod
def amod(a, b): '''Modulus function which returns numerator if modulus is zero''' modded = int(a % b) return b if modded is 0 else modded
python
def amod(a, b): '''Modulus function which returns numerator if modulus is zero''' modded = int(a % b) return b if modded is 0 else modded
[ "def", "amod", "(", "a", ",", "b", ")", ":", "modded", "=", "int", "(", "a", "%", "b", ")", "return", "b", "if", "modded", "is", "0", "else", "modded" ]
Modulus function which returns numerator if modulus is zero
[ "Modulus", "function", "which", "returns", "numerator", "if", "modulus", "is", "zero" ]
train
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/utils.py#L24-L27
fitnr/convertdate
convertdate/utils.py
search_weekday
def search_weekday(weekday, jd, direction, offset): '''Determine the Julian date for the next or previous weekday''' return weekday_before(weekday, jd + (direction * offset))
python
def search_weekday(weekday, jd, direction, offset): '''Determine the Julian date for the next or previous weekday''' return weekday_before(weekday, jd + (direction * offset))
[ "def", "search_weekday", "(", "weekday", ",", "jd", ",", "direction", ",", "offset", ")", ":", "return", "weekday_before", "(", "weekday", ",", "jd", "+", "(", "direction", "*", "offset", ")", ")" ]
Determine the Julian date for the next or previous weekday
[ "Determine", "the", "Julian", "date", "for", "the", "next", "or", "previous", "weekday" ]
train
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/utils.py#L44-L46
fitnr/convertdate
convertdate/utils.py
nth_day_of_month
def nth_day_of_month(n, weekday, month, year): """ Return (year, month, day) tuple that represents nth weekday of month in year. If n==0, returns last weekday of month. Weekdays: Monday=0 """ if not (0 <= n <= 5): raise IndexError("Nth day of month must be 0-5. Received: {}".format(n)) ...
python
def nth_day_of_month(n, weekday, month, year): """ Return (year, month, day) tuple that represents nth weekday of month in year. If n==0, returns last weekday of month. Weekdays: Monday=0 """ if not (0 <= n <= 5): raise IndexError("Nth day of month must be 0-5. Received: {}".format(n)) ...
[ "def", "nth_day_of_month", "(", "n", ",", "weekday", ",", "month", ",", "year", ")", ":", "if", "not", "(", "0", "<=", "n", "<=", "5", ")", ":", "raise", "IndexError", "(", "\"Nth day of month must be 0-5. Received: {}\"", ".", "format", "(", "n", ")", "...
Return (year, month, day) tuple that represents nth weekday of month in year. If n==0, returns last weekday of month. Weekdays: Monday=0
[ "Return", "(", "year", "month", "day", ")", "tuple", "that", "represents", "nth", "weekday", "of", "month", "in", "year", ".", "If", "n", "==", "0", "returns", "last", "weekday", "of", "month", ".", "Weekdays", ":", "Monday", "=", "0" ]
train
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/utils.py#L93-L121
spacetelescope/stsci.tools
lib/stsci/tools/irafglob.py
irafglob
def irafglob(inlist, atfile=None): """ Returns a list of filenames based on the type of IRAF input. Handles lists, wild-card characters, and at-files. For special at-files, use the atfile keyword to process them. This function is recursive, so IRAF lists can also contain at-files and wild-card ch...
python
def irafglob(inlist, atfile=None): """ Returns a list of filenames based on the type of IRAF input. Handles lists, wild-card characters, and at-files. For special at-files, use the atfile keyword to process them. This function is recursive, so IRAF lists can also contain at-files and wild-card ch...
[ "def", "irafglob", "(", "inlist", ",", "atfile", "=", "None", ")", ":", "# Sanity check", "if", "inlist", "is", "None", "or", "len", "(", "inlist", ")", "==", "0", ":", "return", "[", "]", "# Determine which form of input was provided:", "if", "isinstance", ...
Returns a list of filenames based on the type of IRAF input. Handles lists, wild-card characters, and at-files. For special at-files, use the atfile keyword to process them. This function is recursive, so IRAF lists can also contain at-files and wild-card characters, e.g. `a.fits`, `@file.lst`, `*flt...
[ "Returns", "a", "list", "of", "filenames", "based", "on", "the", "type", "of", "IRAF", "input", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafglob.py#L13-L54
mjuenema/python-TSIP
tsip/hlapi.py
Packet.pack
def pack(self): """Return binary format of packet. The returned string is the binary format of the packet with stuffing and framing applied. It is ready to be sent to the GPS. """ # Possible structs for packet ID. # try: structs_ = ...
python
def pack(self): """Return binary format of packet. The returned string is the binary format of the packet with stuffing and framing applied. It is ready to be sent to the GPS. """ # Possible structs for packet ID. # try: structs_ = ...
[ "def", "pack", "(", "self", ")", ":", "# Possible structs for packet ID.", "#", "try", ":", "structs_", "=", "get_structs_for_fields", "(", "[", "self", ".", "fields", "[", "0", "]", "]", ")", "except", "(", "TypeError", ")", ":", "# TypeError, if self.fields[...
Return binary format of packet. The returned string is the binary format of the packet with stuffing and framing applied. It is ready to be sent to the GPS.
[ "Return", "binary", "format", "of", "packet", "." ]
train
https://github.com/mjuenema/python-TSIP/blob/e02b68d05772127ea493cd639b3d5f8fb73df402/tsip/hlapi.py#L92-L132
mjuenema/python-TSIP
tsip/hlapi.py
Packet.unpack
def unpack(cls, rawpacket): """Instantiate `Packet` from binary string. :param rawpacket: TSIP pkt in binary format. :type rawpacket: String. `rawpacket` must already have framing (DLE...DLE/ETX) removed and byte stuffing reversed. """ structs_ = g...
python
def unpack(cls, rawpacket): """Instantiate `Packet` from binary string. :param rawpacket: TSIP pkt in binary format. :type rawpacket: String. `rawpacket` must already have framing (DLE...DLE/ETX) removed and byte stuffing reversed. """ structs_ = g...
[ "def", "unpack", "(", "cls", ",", "rawpacket", ")", ":", "structs_", "=", "get_structs_for_rawpacket", "(", "rawpacket", ")", "for", "struct_", "in", "structs_", ":", "try", ":", "return", "cls", "(", "*", "struct_", ".", "unpack", "(", "rawpacket", ")", ...
Instantiate `Packet` from binary string. :param rawpacket: TSIP pkt in binary format. :type rawpacket: String. `rawpacket` must already have framing (DLE...DLE/ETX) removed and byte stuffing reversed.
[ "Instantiate", "Packet", "from", "binary", "string", "." ]
train
https://github.com/mjuenema/python-TSIP/blob/e02b68d05772127ea493cd639b3d5f8fb73df402/tsip/hlapi.py#L136-L160
spacetelescope/stsci.tools
lib/stsci/tools/clipboard_helper.py
ch_handler
def ch_handler(offset=0, length=-1, **kw): """ Handle standard PRIMARY clipboard access. Note that offset and length are passed as strings. This differs from CLIPBOARD. """ global _lastSel offset = int(offset) length = int(length) if length < 0: length = len(_lastSel) return _lastSel[offs...
python
def ch_handler(offset=0, length=-1, **kw): """ Handle standard PRIMARY clipboard access. Note that offset and length are passed as strings. This differs from CLIPBOARD. """ global _lastSel offset = int(offset) length = int(length) if length < 0: length = len(_lastSel) return _lastSel[offs...
[ "def", "ch_handler", "(", "offset", "=", "0", ",", "length", "=", "-", "1", ",", "*", "*", "kw", ")", ":", "global", "_lastSel", "offset", "=", "int", "(", "offset", ")", "length", "=", "int", "(", "length", ")", "if", "length", "<", "0", ":", ...
Handle standard PRIMARY clipboard access. Note that offset and length are passed as strings. This differs from CLIPBOARD.
[ "Handle", "standard", "PRIMARY", "clipboard", "access", ".", "Note", "that", "offset", "and", "length", "are", "passed", "as", "strings", ".", "This", "differs", "from", "CLIPBOARD", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/clipboard_helper.py#L19-L27
spacetelescope/stsci.tools
lib/stsci/tools/clipboard_helper.py
put
def put(text, cbname): """ Put the given string into the given clipboard. """ global _lastSel _checkTkInit() if cbname == 'CLIPBOARD': _theRoot.clipboard_clear() if text: # for clipboard_append, kwds can be -displayof, -format, or -type _theRoot.clipboard_append(t...
python
def put(text, cbname): """ Put the given string into the given clipboard. """ global _lastSel _checkTkInit() if cbname == 'CLIPBOARD': _theRoot.clipboard_clear() if text: # for clipboard_append, kwds can be -displayof, -format, or -type _theRoot.clipboard_append(t...
[ "def", "put", "(", "text", ",", "cbname", ")", ":", "global", "_lastSel", "_checkTkInit", "(", ")", "if", "cbname", "==", "'CLIPBOARD'", ":", "_theRoot", ".", "clipboard_clear", "(", ")", "if", "text", ":", "# for clipboard_append, kwds can be -displayof, -format,...
Put the given string into the given clipboard.
[ "Put", "the", "given", "string", "into", "the", "given", "clipboard", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/clipboard_helper.py#L38-L55
spacetelescope/stsci.tools
lib/stsci/tools/clipboard_helper.py
get
def get(cbname): """ Get the contents of the given clipboard. """ _checkTkInit() if cbname == 'PRIMARY': try: return _theRoot.selection_get(selection='PRIMARY') except: return None if cbname == 'CLIPBOARD': try: return _theRoot.selection_get(se...
python
def get(cbname): """ Get the contents of the given clipboard. """ _checkTkInit() if cbname == 'PRIMARY': try: return _theRoot.selection_get(selection='PRIMARY') except: return None if cbname == 'CLIPBOARD': try: return _theRoot.selection_get(se...
[ "def", "get", "(", "cbname", ")", ":", "_checkTkInit", "(", ")", "if", "cbname", "==", "'PRIMARY'", ":", "try", ":", "return", "_theRoot", ".", "selection_get", "(", "selection", "=", "'PRIMARY'", ")", "except", ":", "return", "None", "if", "cbname", "==...
Get the contents of the given clipboard.
[ "Get", "the", "contents", "of", "the", "given", "clipboard", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/clipboard_helper.py#L58-L71
3ll3d00d/vibe
backend/src/recorder/common/config.py
Config.createDevice
def createDevice(self, deviceCfg): """ Creates a measurement deviceCfg from the input configuration. :param: deviceCfg: the deviceCfg cfg. :param: handlers: the loaded handlers. :return: the constructed deviceCfg. """ ioCfg = deviceCfg['io'] type = deviceC...
python
def createDevice(self, deviceCfg): """ Creates a measurement deviceCfg from the input configuration. :param: deviceCfg: the deviceCfg cfg. :param: handlers: the loaded handlers. :return: the constructed deviceCfg. """ ioCfg = deviceCfg['io'] type = deviceC...
[ "def", "createDevice", "(", "self", ",", "deviceCfg", ")", ":", "ioCfg", "=", "deviceCfg", "[", "'io'", "]", "type", "=", "deviceCfg", "[", "'type'", "]", "if", "type", "==", "'mpu6050'", ":", "fs", "=", "deviceCfg", ".", "get", "(", "'fs'", ")", "na...
Creates a measurement deviceCfg from the input configuration. :param: deviceCfg: the deviceCfg cfg. :param: handlers: the loaded handlers. :return: the constructed deviceCfg.
[ "Creates", "a", "measurement", "deviceCfg", "from", "the", "input", "configuration", ".", ":", "param", ":", "deviceCfg", ":", "the", "deviceCfg", "cfg", ".", ":", "param", ":", "handlers", ":", "the", "loaded", "handlers", ".", ":", "return", ":", "the", ...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/config.py#L57-L86
3ll3d00d/vibe
backend/src/recorder/common/config.py
Config._loadRecordingDevices
def _loadRecordingDevices(self): """ Loads the recordingDevices specified in the configuration. :param: handlers the loaded handlers. :return: the constructed recordingDevices in a dict keyed by name. """ return {device.name: device for device in [self.cre...
python
def _loadRecordingDevices(self): """ Loads the recordingDevices specified in the configuration. :param: handlers the loaded handlers. :return: the constructed recordingDevices in a dict keyed by name. """ return {device.name: device for device in [self.cre...
[ "def", "_loadRecordingDevices", "(", "self", ")", ":", "return", "{", "device", ".", "name", ":", "device", "for", "device", "in", "[", "self", ".", "createDevice", "(", "deviceCfg", ")", "for", "deviceCfg", "in", "self", ".", "config", "[", "'acceleromete...
Loads the recordingDevices specified in the configuration. :param: handlers the loaded handlers. :return: the constructed recordingDevices in a dict keyed by name.
[ "Loads", "the", "recordingDevices", "specified", "in", "the", "configuration", ".", ":", "param", ":", "handlers", "the", "loaded", "handlers", ".", ":", "return", ":", "the", "constructed", "recordingDevices", "in", "a", "dict", "keyed", "by", "name", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/config.py#L88-L95
3ll3d00d/vibe
backend/src/recorder/common/config.py
Config.createHandler
def createHandler(self, handler): """ Creates a data handler from the input configuration. :param handler: the handler cfg. :return: the constructed handler. """ target = handler['target'] if handler['type'] == 'log': self.logger.warning("Initialising ...
python
def createHandler(self, handler): """ Creates a data handler from the input configuration. :param handler: the handler cfg. :return: the constructed handler. """ target = handler['target'] if handler['type'] == 'log': self.logger.warning("Initialising ...
[ "def", "createHandler", "(", "self", ",", "handler", ")", ":", "target", "=", "handler", "[", "'target'", "]", "if", "handler", "[", "'type'", "]", "==", "'log'", ":", "self", ".", "logger", ".", "warning", "(", "\"Initialising csvlogger to log data to \"", ...
Creates a data handler from the input configuration. :param handler: the handler cfg. :return: the constructed handler.
[ "Creates", "a", "data", "handler", "from", "the", "input", "configuration", ".", ":", "param", "handler", ":", "the", "handler", "cfg", ".", ":", "return", ":", "the", "constructed", "handler", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/config.py#L105-L117
3ll3d00d/vibe
backend/src/recorder/common/config.py
Config._loadHandlers
def _loadHandlers(self): """ creates a dictionary of named handler instances :return: the dictionary """ return {handler.name: handler for handler in map(self.createHandler, self.config['handlers'])}
python
def _loadHandlers(self): """ creates a dictionary of named handler instances :return: the dictionary """ return {handler.name: handler for handler in map(self.createHandler, self.config['handlers'])}
[ "def", "_loadHandlers", "(", "self", ")", ":", "return", "{", "handler", ".", "name", ":", "handler", "for", "handler", "in", "map", "(", "self", ".", "createHandler", ",", "self", ".", "config", "[", "'handlers'", "]", ")", "}" ]
creates a dictionary of named handler instances :return: the dictionary
[ "creates", "a", "dictionary", "of", "named", "handler", "instances", ":", "return", ":", "the", "dictionary" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/config.py#L119-L124
3ll3d00d/vibe
backend/src/analyser/resources/upload.py
Upload.put
def put(self, filename, chunkIdx, totalChunks): """ stores a chunk of new file, this is a nop if the file already exists. :param filename: the filename. :param chunkIdx: the chunk idx. :param totalChunks: the no of chunks expected. :return: the no of bytes written and 200...
python
def put(self, filename, chunkIdx, totalChunks): """ stores a chunk of new file, this is a nop if the file already exists. :param filename: the filename. :param chunkIdx: the chunk idx. :param totalChunks: the no of chunks expected. :return: the no of bytes written and 200...
[ "def", "put", "(", "self", ",", "filename", ",", "chunkIdx", ",", "totalChunks", ")", ":", "logger", ".", "info", "(", "'handling chunk '", "+", "chunkIdx", "+", "' of '", "+", "totalChunks", "+", "' for '", "+", "filename", ")", "import", "flask", "bytesW...
stores a chunk of new file, this is a nop if the file already exists. :param filename: the filename. :param chunkIdx: the chunk idx. :param totalChunks: the no of chunks expected. :return: the no of bytes written and 200 or 400 if nothing was written.
[ "stores", "a", "chunk", "of", "new", "file", "this", "is", "a", "nop", "if", "the", "file", "already", "exists", ".", ":", "param", "filename", ":", "the", "filename", ".", ":", "param", "chunkIdx", ":", "the", "chunk", "idx", ".", ":", "param", "tot...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/upload.py#L15-L26
3ll3d00d/vibe
backend/src/analyser/resources/upload.py
Uploads.delete
def delete(self, name): """ Deletes the named file. :param name: the name. :return: 200 if it was deleted, 404 if it doesn't exist or 500 for anything else. """ try: result = self._uploadController.delete(name) return None, 200 if result is not Non...
python
def delete(self, name): """ Deletes the named file. :param name: the name. :return: 200 if it was deleted, 404 if it doesn't exist or 500 for anything else. """ try: result = self._uploadController.delete(name) return None, 200 if result is not Non...
[ "def", "delete", "(", "self", ",", "name", ")", ":", "try", ":", "result", "=", "self", ".", "_uploadController", ".", "delete", "(", "name", ")", "return", "None", ",", "200", "if", "result", "is", "not", "None", "else", "404", "except", "Exception", ...
Deletes the named file. :param name: the name. :return: 200 if it was deleted, 404 if it doesn't exist or 500 for anything else.
[ "Deletes", "the", "named", "file", ".", ":", "param", "name", ":", "the", "name", ".", ":", "return", ":", "200", "if", "it", "was", "deleted", "404", "if", "it", "doesn", "t", "exist", "or", "500", "for", "anything", "else", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/upload.py#L39-L49
3ll3d00d/vibe
backend/src/analyser/resources/upload.py
UploadTarget.put
def put(self, name, start, end): """ Stores a new target. :param name: the name. :param start: start time. :param end: end time. :return: """ entry = self._uploadController.getEntry(name) if entry is not None: return None, 200 if self._...
python
def put(self, name, start, end): """ Stores a new target. :param name: the name. :param start: start time. :param end: end time. :return: """ entry = self._uploadController.getEntry(name) if entry is not None: return None, 200 if self._...
[ "def", "put", "(", "self", ",", "name", ",", "start", ",", "end", ")", ":", "entry", "=", "self", ".", "_uploadController", ".", "getEntry", "(", "name", ")", "if", "entry", "is", "not", "None", ":", "return", "None", ",", "200", "if", "self", ".",...
Stores a new target. :param name: the name. :param start: start time. :param end: end time. :return:
[ "Stores", "a", "new", "target", ".", ":", "param", "name", ":", "the", "name", ".", ":", "param", "start", ":", "start", "time", ".", ":", "param", "end", ":", "end", "time", ".", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/upload.py#L57-L69
3ll3d00d/vibe
backend/src/analyser/resources/upload.py
UploadAnalyser.get
def get(self, name, start, end, resolution, window): """ :param name: :param start: :param end: :param resolution: :param window: :return: an analysed file. """ logger.info( 'Analysing ' + name + ' from ' + start + ' to ' + end + ' at '...
python
def get(self, name, start, end, resolution, window): """ :param name: :param start: :param end: :param resolution: :param window: :return: an analysed file. """ logger.info( 'Analysing ' + name + ' from ' + start + ' to ' + end + ' at '...
[ "def", "get", "(", "self", ",", "name", ",", "start", ",", "end", ",", "resolution", ",", "window", ")", ":", "logger", ".", "info", "(", "'Analysing '", "+", "name", "+", "' from '", "+", "start", "+", "' to '", "+", "end", "+", "' at '", "+", "re...
:param name: :param start: :param end: :param resolution: :param window: :return: an analysed file.
[ ":", "param", "name", ":", ":", "param", "start", ":", ":", "param", "end", ":", ":", "param", "resolution", ":", ":", "param", "window", ":", ":", "return", ":", "an", "analysed", "file", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/upload.py#L76-L106
3ll3d00d/vibe
backend/src/analyser/resources/upload.py
CompleteUpload.put
def put(self, filename, totalChunks, status): """ Completes the specified upload. :param filename: the filename. :param totalChunks: the no of chunks. :param status: the status of the upload. :return: 200. """ logger.info('Completing ' + filename + ' - ' +...
python
def put(self, filename, totalChunks, status): """ Completes the specified upload. :param filename: the filename. :param totalChunks: the no of chunks. :param status: the status of the upload. :return: 200. """ logger.info('Completing ' + filename + ' - ' +...
[ "def", "put", "(", "self", ",", "filename", ",", "totalChunks", ",", "status", ")", ":", "logger", ".", "info", "(", "'Completing '", "+", "filename", "+", "' - '", "+", "status", ")", "self", ".", "_uploadController", ".", "finalise", "(", "filename", "...
Completes the specified upload. :param filename: the filename. :param totalChunks: the no of chunks. :param status: the status of the upload. :return: 200.
[ "Completes", "the", "specified", "upload", ".", ":", "param", "filename", ":", "the", "filename", ".", ":", "param", "totalChunks", ":", "the", "no", "of", "chunks", ".", ":", "param", "status", ":", "the", "status", "of", "the", "upload", ".", ":", "r...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/upload.py#L116-L126
3ll3d00d/vibe
backend/src/analyser/resources/measurement.py
Measurement.patch
def patch(self, measurementId): """ Patches the metadata associated with the new measurement, if this impacts the measurement length then a new measurement is created otherwise it just updates it in place. :param measurementId: :return: """ data = request.get_j...
python
def patch(self, measurementId): """ Patches the metadata associated with the new measurement, if this impacts the measurement length then a new measurement is created otherwise it just updates it in place. :param measurementId: :return: """ data = request.get_j...
[ "def", "patch", "(", "self", ",", "measurementId", ")", ":", "data", "=", "request", ".", "get_json", "(", ")", "if", "data", "is", "not", "None", ":", "logger", ".", "debug", "(", "'Received payload for '", "+", "measurementId", "+", "' - '", "+", "str"...
Patches the metadata associated with the new measurement, if this impacts the measurement length then a new measurement is created otherwise it just updates it in place. :param measurementId: :return:
[ "Patches", "the", "metadata", "associated", "with", "the", "new", "measurement", "if", "this", "impacts", "the", "measurement", "length", "then", "a", "new", "measurement", "is", "created", "otherwise", "it", "just", "updates", "it", "in", "place", ".", ":", ...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L27-L44
3ll3d00d/vibe
backend/src/analyser/resources/measurement.py
Measurement.put
def put(self, measurementId): """ Initiates a new measurement. Accepts a json payload with the following attributes; * duration: in seconds * startTime OR delay: a date in YMD_HMS format or a delay in seconds * description: some free text information about the measurement ...
python
def put(self, measurementId): """ Initiates a new measurement. Accepts a json payload with the following attributes; * duration: in seconds * startTime OR delay: a date in YMD_HMS format or a delay in seconds * description: some free text information about the measurement ...
[ "def", "put", "(", "self", ",", "measurementId", ")", ":", "json", "=", "request", ".", "get_json", "(", ")", "try", ":", "start", "=", "self", ".", "_calculateStartTime", "(", "json", ")", "except", "ValueError", ":", "return", "'invalid date format in requ...
Initiates a new measurement. Accepts a json payload with the following attributes; * duration: in seconds * startTime OR delay: a date in YMD_HMS format or a delay in seconds * description: some free text information about the measurement :return:
[ "Initiates", "a", "new", "measurement", ".", "Accepts", "a", "json", "payload", "with", "the", "following", "attributes", ";" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L46-L68
3ll3d00d/vibe
backend/src/analyser/resources/measurement.py
Measurement._calculateStartTime
def _calculateStartTime(self, json): """ Calculates an absolute start time from the json payload. This is either the given absolute start time (+2s) or the time in delay seconds time. If the resulting date is in the past then now is returned instead. :param json: the payload from the UI ...
python
def _calculateStartTime(self, json): """ Calculates an absolute start time from the json payload. This is either the given absolute start time (+2s) or the time in delay seconds time. If the resulting date is in the past then now is returned instead. :param json: the payload from the UI ...
[ "def", "_calculateStartTime", "(", "self", ",", "json", ")", ":", "start", "=", "json", "[", "'startTime'", "]", "if", "'startTime'", "in", "json", "else", "None", "delay", "=", "json", "[", "'delay'", "]", "if", "'delay'", "in", "json", "else", "None", ...
Calculates an absolute start time from the json payload. This is either the given absolute start time (+2s) or the time in delay seconds time. If the resulting date is in the past then now is returned instead. :param json: the payload from the UI :return: the absolute start time.
[ "Calculates", "an", "absolute", "start", "time", "from", "the", "json", "payload", ".", "This", "is", "either", "the", "given", "absolute", "start", "time", "(", "+", "2s", ")", "or", "the", "time", "in", "delay", "seconds", "time", ".", "If", "the", "...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L70-L93
3ll3d00d/vibe
backend/src/analyser/resources/measurement.py
Measurement._getAbsoluteTime
def _getAbsoluteTime(self, start, delay): """ Adds the delay in seconds to the start time. :param start: :param delay: :return: a datetimem for the specified point in time. """ return start + datetime.timedelta(days=0, seconds=delay)
python
def _getAbsoluteTime(self, start, delay): """ Adds the delay in seconds to the start time. :param start: :param delay: :return: a datetimem for the specified point in time. """ return start + datetime.timedelta(days=0, seconds=delay)
[ "def", "_getAbsoluteTime", "(", "self", ",", "start", ",", "delay", ")", ":", "return", "start", "+", "datetime", ".", "timedelta", "(", "days", "=", "0", ",", "seconds", "=", "delay", ")" ]
Adds the delay in seconds to the start time. :param start: :param delay: :return: a datetimem for the specified point in time.
[ "Adds", "the", "delay", "in", "seconds", "to", "the", "start", "time", ".", ":", "param", "start", ":", ":", "param", "delay", ":", ":", "return", ":", "a", "datetimem", "for", "the", "specified", "point", "in", "time", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L95-L102
3ll3d00d/vibe
backend/src/analyser/resources/measurement.py
Measurement.delete
def delete(self, measurementId): """ Deletes the named measurement. :return: 200 if something was deleted, 404 if the measurement doesn't exist, 500 in any other case. """ message, count, deleted = self._measurementController.delete(measurementId) if count == 0: ...
python
def delete(self, measurementId): """ Deletes the named measurement. :return: 200 if something was deleted, 404 if the measurement doesn't exist, 500 in any other case. """ message, count, deleted = self._measurementController.delete(measurementId) if count == 0: ...
[ "def", "delete", "(", "self", ",", "measurementId", ")", ":", "message", ",", "count", ",", "deleted", "=", "self", ".", "_measurementController", ".", "delete", "(", "measurementId", ")", "if", "count", "==", "0", ":", "return", "message", ",", "404", "...
Deletes the named measurement. :return: 200 if something was deleted, 404 if the measurement doesn't exist, 500 in any other case.
[ "Deletes", "the", "named", "measurement", ".", ":", "return", ":", "200", "if", "something", "was", "deleted", "404", "if", "the", "measurement", "doesn", "t", "exist", "500", "in", "any", "other", "case", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L105-L116
3ll3d00d/vibe
backend/src/analyser/resources/measurement.py
InitialiseMeasurement.put
def put(self, measurementId, deviceId): """ Initialises the measurement session from the given device. :param measurementId: :param deviceId: :return: """ logger.info('Starting measurement ' + measurementId + ' for ' + deviceId) if self._measurementControl...
python
def put(self, measurementId, deviceId): """ Initialises the measurement session from the given device. :param measurementId: :param deviceId: :return: """ logger.info('Starting measurement ' + measurementId + ' for ' + deviceId) if self._measurementControl...
[ "def", "put", "(", "self", ",", "measurementId", ",", "deviceId", ")", ":", "logger", ".", "info", "(", "'Starting measurement '", "+", "measurementId", "+", "' for '", "+", "deviceId", ")", "if", "self", ".", "_measurementController", ".", "startMeasurement", ...
Initialises the measurement session from the given device. :param measurementId: :param deviceId: :return:
[ "Initialises", "the", "measurement", "session", "from", "the", "given", "device", ".", ":", "param", "measurementId", ":", ":", "param", "deviceId", ":", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L123-L136
3ll3d00d/vibe
backend/src/analyser/resources/measurement.py
RecordData.put
def put(self, measurementId, deviceId): """ Store a bunch of data for this measurement session. :param measurementId: :param deviceId: :return: """ data = request.get_json() if data is not None: parsedData = json.loads(data) logger....
python
def put(self, measurementId, deviceId): """ Store a bunch of data for this measurement session. :param measurementId: :param deviceId: :return: """ data = request.get_json() if data is not None: parsedData = json.loads(data) logger....
[ "def", "put", "(", "self", ",", "measurementId", ",", "deviceId", ")", ":", "data", "=", "request", ".", "get_json", "(", ")", "if", "data", "is", "not", "None", ":", "parsedData", "=", "json", ".", "loads", "(", "data", ")", "logger", ".", "debug", ...
Store a bunch of data for this measurement session. :param measurementId: :param deviceId: :return:
[ "Store", "a", "bunch", "of", "data", "for", "this", "measurement", "session", ".", ":", "param", "measurementId", ":", ":", "param", "deviceId", ":", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L143-L162
3ll3d00d/vibe
backend/src/analyser/resources/measurement.py
FailMeasurement.put
def put(self, measurementId, deviceId): """ Fails the measurement for this device. :param measurementId: the measurement name. :param deviceId: the device name. :return: 200 if """ payload = request.get_json() failureReason = json.loads(payload).get('failu...
python
def put(self, measurementId, deviceId): """ Fails the measurement for this device. :param measurementId: the measurement name. :param deviceId: the device name. :return: 200 if """ payload = request.get_json() failureReason = json.loads(payload).get('failu...
[ "def", "put", "(", "self", ",", "measurementId", ",", "deviceId", ")", ":", "payload", "=", "request", ".", "get_json", "(", ")", "failureReason", "=", "json", ".", "loads", "(", "payload", ")", ".", "get", "(", "'failureReason'", ")", "if", "payload", ...
Fails the measurement for this device. :param measurementId: the measurement name. :param deviceId: the device name. :return: 200 if
[ "Fails", "the", "measurement", "for", "this", "device", ".", ":", "param", "measurementId", ":", "the", "measurement", "name", ".", ":", "param", "deviceId", ":", "the", "device", "name", ".", ":", "return", ":", "200", "if" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L189-L204
3ll3d00d/vibe
backend/src/analyser/resources/measurementdevices.py
MeasurementDevice.put
def put(self, deviceId): """ Puts a new device into the device store :param deviceId: :return: """ device = request.get_json() logger.debug("Received /devices/" + deviceId + " - " + str(device)) self._deviceController.accept(deviceId, device) retur...
python
def put(self, deviceId): """ Puts a new device into the device store :param deviceId: :return: """ device = request.get_json() logger.debug("Received /devices/" + deviceId + " - " + str(device)) self._deviceController.accept(deviceId, device) retur...
[ "def", "put", "(", "self", ",", "deviceId", ")", ":", "device", "=", "request", ".", "get_json", "(", ")", "logger", ".", "debug", "(", "\"Received /devices/\"", "+", "deviceId", "+", "\" - \"", "+", "str", "(", "device", ")", ")", "self", ".", "_devic...
Puts a new device into the device store :param deviceId: :return:
[ "Puts", "a", "new", "device", "into", "the", "device", "store", ":", "param", "deviceId", ":", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurementdevices.py#L32-L41
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
printColsAuto
def printColsAuto(in_strings, term_width=80, min_pad=1): """ Print a list of strings centered in columns. Determine the number of columns and lines on the fly. Return the result, ready to print. in_strings is a list/tuple/iterable of strings min_pad is number of spaces to appear on each side of a sing...
python
def printColsAuto(in_strings, term_width=80, min_pad=1): """ Print a list of strings centered in columns. Determine the number of columns and lines on the fly. Return the result, ready to print. in_strings is a list/tuple/iterable of strings min_pad is number of spaces to appear on each side of a sing...
[ "def", "printColsAuto", "(", "in_strings", ",", "term_width", "=", "80", ",", "min_pad", "=", "1", ")", ":", "# sanity check", "assert", "in_strings", "and", "len", "(", "in_strings", ")", ">", "0", ",", "'Unexpected: '", "+", "repr", "(", "in_strings", ")...
Print a list of strings centered in columns. Determine the number of columns and lines on the fly. Return the result, ready to print. in_strings is a list/tuple/iterable of strings min_pad is number of spaces to appear on each side of a single string (so you will see twice this many spaces bet...
[ "Print", "a", "list", "of", "strings", "centered", "in", "columns", ".", "Determine", "the", "number", "of", "columns", "and", "lines", "on", "the", "fly", ".", "Return", "the", "result", "ready", "to", "print", ".", "in_strings", "is", "a", "list", "/",...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L42-L72
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
printCols
def printCols(strlist,cols=5,width=80): """Print elements of list in cols columns""" # This may exist somewhere in the Python standard libraries? # Should probably rewrite this, it is pretty crude. nlines = (len(strlist)+cols-1)//cols line = nlines*[""] for i in range(len(strlist)): c...
python
def printCols(strlist,cols=5,width=80): """Print elements of list in cols columns""" # This may exist somewhere in the Python standard libraries? # Should probably rewrite this, it is pretty crude. nlines = (len(strlist)+cols-1)//cols line = nlines*[""] for i in range(len(strlist)): c...
[ "def", "printCols", "(", "strlist", ",", "cols", "=", "5", ",", "width", "=", "80", ")", ":", "# This may exist somewhere in the Python standard libraries?", "# Should probably rewrite this, it is pretty crude.", "nlines", "=", "(", "len", "(", "strlist", ")", "+", "c...
Print elements of list in cols columns
[ "Print", "elements", "of", "list", "in", "cols", "columns" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L75-L92
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
stripQuotes
def stripQuotes(value): """Strip single or double quotes off string; remove embedded quote pairs""" if value[:1] == '"': value = value[1:] if value[-1:] == '"': value = value[:-1] # replace "" with " value = re.sub(_re_doubleq2, '"', value) elif value[:1] == "'"...
python
def stripQuotes(value): """Strip single or double quotes off string; remove embedded quote pairs""" if value[:1] == '"': value = value[1:] if value[-1:] == '"': value = value[:-1] # replace "" with " value = re.sub(_re_doubleq2, '"', value) elif value[:1] == "'"...
[ "def", "stripQuotes", "(", "value", ")", ":", "if", "value", "[", ":", "1", "]", "==", "'\"'", ":", "value", "=", "value", "[", "1", ":", "]", "if", "value", "[", "-", "1", ":", "]", "==", "'\"'", ":", "value", "=", "value", "[", ":", "-", ...
Strip single or double quotes off string; remove embedded quote pairs
[ "Strip", "single", "or", "double", "quotes", "off", "string", ";", "remove", "embedded", "quote", "pairs" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L97-L113
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
csvSplit
def csvSplit(line, delim=',', allowEol=True): """ Take a string as input (e.g. a line in a csv text file), and break it into tokens separated by commas while ignoring commas embedded inside quoted sections. This is exactly what the 'csv' module is meant for, so we *should* be using it, save that it has...
python
def csvSplit(line, delim=',', allowEol=True): """ Take a string as input (e.g. a line in a csv text file), and break it into tokens separated by commas while ignoring commas embedded inside quoted sections. This is exactly what the 'csv' module is meant for, so we *should* be using it, save that it has...
[ "def", "csvSplit", "(", "line", ",", "delim", "=", "','", ",", "allowEol", "=", "True", ")", ":", "# Algorithm: read chars left to right, go from delimiter to delimiter,", "# but as soon as a single/double/triple quote is hit, scan forward", "# (ignoring all else) until its matching...
Take a string as input (e.g. a line in a csv text file), and break it into tokens separated by commas while ignoring commas embedded inside quoted sections. This is exactly what the 'csv' module is meant for, so we *should* be using it, save that it has two bugs (described next) which limit our use of ...
[ "Take", "a", "string", "as", "input", "(", "e", ".", "g", ".", "a", "line", "in", "a", "csv", "text", "file", ")", "and", "break", "it", "into", "tokens", "separated", "by", "commas", "while", "ignoring", "commas", "embedded", "inside", "quoted", "sect...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L115-L178
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
rglob
def rglob(root, pattern): """ Same thing as glob.glob, but recursively checks subdirs. """ # Thanks to Alex Martelli for basics on Stack Overflow retlist = [] if None not in (pattern, root): for base, dirs, files in os.walk(root): goodfiles = fnmatch.filter(files, pattern) ...
python
def rglob(root, pattern): """ Same thing as glob.glob, but recursively checks subdirs. """ # Thanks to Alex Martelli for basics on Stack Overflow retlist = [] if None not in (pattern, root): for base, dirs, files in os.walk(root): goodfiles = fnmatch.filter(files, pattern) ...
[ "def", "rglob", "(", "root", ",", "pattern", ")", ":", "# Thanks to Alex Martelli for basics on Stack Overflow", "retlist", "=", "[", "]", "if", "None", "not", "in", "(", "pattern", ",", "root", ")", ":", "for", "base", ",", "dirs", ",", "files", "in", "os...
Same thing as glob.glob, but recursively checks subdirs.
[ "Same", "thing", "as", "glob", ".", "glob", "but", "recursively", "checks", "subdirs", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L266-L274
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
setWritePrivs
def setWritePrivs(fname, makeWritable, ignoreErrors=False): """ Set a file named fname to be writable (or not) by user, with the option to ignore errors. There is nothing ground-breaking here, but I was annoyed with having to repeate this little bit of code. """ privs = os.stat(fname).st_mode try: ...
python
def setWritePrivs(fname, makeWritable, ignoreErrors=False): """ Set a file named fname to be writable (or not) by user, with the option to ignore errors. There is nothing ground-breaking here, but I was annoyed with having to repeate this little bit of code. """ privs = os.stat(fname).st_mode try: ...
[ "def", "setWritePrivs", "(", "fname", ",", "makeWritable", ",", "ignoreErrors", "=", "False", ")", ":", "privs", "=", "os", ".", "stat", "(", "fname", ")", ".", "st_mode", "try", ":", "if", "makeWritable", ":", "os", ".", "chmod", "(", "fname", ",", ...
Set a file named fname to be writable (or not) by user, with the option to ignore errors. There is nothing ground-breaking here, but I was annoyed with having to repeate this little bit of code.
[ "Set", "a", "file", "named", "fname", "to", "be", "writable", "(", "or", "not", ")", "by", "user", "with", "the", "option", "to", "ignore", "errors", ".", "There", "is", "nothing", "ground", "-", "breaking", "here", "but", "I", "was", "annoyed", "with"...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L276-L290
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
removeEscapes
def removeEscapes(value, quoted=0): """Remove escapes from in front of quotes (which IRAF seems to just stick in for fun sometimes.) Remove \-newline too. If quoted is true, removes all blanks following \-newline (which is a nasty thing IRAF does for continuations inside quoted strings.) XXX S...
python
def removeEscapes(value, quoted=0): """Remove escapes from in front of quotes (which IRAF seems to just stick in for fun sometimes.) Remove \-newline too. If quoted is true, removes all blanks following \-newline (which is a nasty thing IRAF does for continuations inside quoted strings.) XXX S...
[ "def", "removeEscapes", "(", "value", ",", "quoted", "=", "0", ")", ":", "i", "=", "value", ".", "find", "(", "r'\\\"'", ")", "while", "i", ">=", "0", ":", "value", "=", "value", "[", ":", "i", "]", "+", "value", "[", "i", "+", "1", ":", "]",...
Remove escapes from in front of quotes (which IRAF seems to just stick in for fun sometimes.) Remove \-newline too. If quoted is true, removes all blanks following \-newline (which is a nasty thing IRAF does for continuations inside quoted strings.) XXX Should we remove \\ too?
[ "Remove", "escapes", "from", "in", "front", "of", "quotes", "(", "which", "IRAF", "seems", "to", "just", "stick", "in", "for", "fun", "sometimes", ".", ")", "Remove", "\\", "-", "newline", "too", ".", "If", "quoted", "is", "true", "removes", "all", "bl...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L293-L323
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
translateName
def translateName(s, dot=0): """Convert CL parameter or variable name to Python-acceptable name Translate embedded dollar signs to 'DOLLAR' Add 'PY' prefix to components that are Python reserved words Add 'PY' prefix to components start with a number If dot != 0, also replaces '.' with 'DOT' "...
python
def translateName(s, dot=0): """Convert CL parameter or variable name to Python-acceptable name Translate embedded dollar signs to 'DOLLAR' Add 'PY' prefix to components that are Python reserved words Add 'PY' prefix to components start with a number If dot != 0, also replaces '.' with 'DOT' "...
[ "def", "translateName", "(", "s", ",", "dot", "=", "0", ")", ":", "s", "=", "s", ".", "replace", "(", "'$'", ",", "'DOLLAR'", ")", "sparts", "=", "s", ".", "split", "(", "'.'", ")", "for", "i", "in", "range", "(", "len", "(", "sparts", ")", "...
Convert CL parameter or variable name to Python-acceptable name Translate embedded dollar signs to 'DOLLAR' Add 'PY' prefix to components that are Python reserved words Add 'PY' prefix to components start with a number If dot != 0, also replaces '.' with 'DOT'
[ "Convert", "CL", "parameter", "or", "variable", "name", "to", "Python", "-", "acceptable", "name" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L329-L348
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
init_tk_default_root
def init_tk_default_root(withdraw=True): """ In case the _default_root value is required, you may safely call this ahead of time to ensure that it has been initialized. If it has already been, this is a no-op. """ if not capable.OF_GRAPHICS: raise RuntimeError("Cannot run this command with...
python
def init_tk_default_root(withdraw=True): """ In case the _default_root value is required, you may safely call this ahead of time to ensure that it has been initialized. If it has already been, this is a no-op. """ if not capable.OF_GRAPHICS: raise RuntimeError("Cannot run this command with...
[ "def", "init_tk_default_root", "(", "withdraw", "=", "True", ")", ":", "if", "not", "capable", ".", "OF_GRAPHICS", ":", "raise", "RuntimeError", "(", "\"Cannot run this command without graphics\"", ")", "if", "not", "TKNTR", ".", "_default_root", ":", "# TKNTR impor...
In case the _default_root value is required, you may safely call this ahead of time to ensure that it has been initialized. If it has already been, this is a no-op.
[ "In", "case", "the", "_default_root", "value", "is", "required", "you", "may", "safely", "call", "this", "ahead", "of", "time", "to", "ensure", "that", "it", "has", "been", "initialized", ".", "If", "it", "has", "already", "been", "this", "is", "a", "no"...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L363-L380
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
tkreadline
def tkreadline(file=None): """Read a line from file while running Tk mainloop. If the file is not line-buffered then the Tk mainloop will stop running after one character is typed. The function will still work but Tk widgets will stop updating. This should work OK for stdin and other line-buffer...
python
def tkreadline(file=None): """Read a line from file while running Tk mainloop. If the file is not line-buffered then the Tk mainloop will stop running after one character is typed. The function will still work but Tk widgets will stop updating. This should work OK for stdin and other line-buffer...
[ "def", "tkreadline", "(", "file", "=", "None", ")", ":", "if", "file", "is", "None", ":", "file", "=", "sys", ".", "stdin", "if", "not", "hasattr", "(", "file", ",", "\"readline\"", ")", ":", "raise", "TypeError", "(", "\"file must be a filehandle with a r...
Read a line from file while running Tk mainloop. If the file is not line-buffered then the Tk mainloop will stop running after one character is typed. The function will still work but Tk widgets will stop updating. This should work OK for stdin and other line-buffered filehandles. If file is omitted...
[ "Read", "a", "line", "from", "file", "while", "running", "Tk", "mainloop", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L394-L430
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
launchBrowser
def launchBrowser(url, brow_bin='mozilla', subj=None): """ Given a URL, try to pop it up in a browser on most platforms. brow_bin is only used on OS's where there is no "open" or "start" cmd. """ if not subj: subj = url # Tries to use webbrowser module on most OSes, unless a system command # i...
python
def launchBrowser(url, brow_bin='mozilla', subj=None): """ Given a URL, try to pop it up in a browser on most platforms. brow_bin is only used on OS's where there is no "open" or "start" cmd. """ if not subj: subj = url # Tries to use webbrowser module on most OSes, unless a system command # i...
[ "def", "launchBrowser", "(", "url", ",", "brow_bin", "=", "'mozilla'", ",", "subj", "=", "None", ")", ":", "if", "not", "subj", ":", "subj", "=", "url", "# Tries to use webbrowser module on most OSes, unless a system command", "# is needed. (E.g. win, linux, sun, etc)", ...
Given a URL, try to pop it up in a browser on most platforms. brow_bin is only used on OS's where there is no "open" or "start" cmd.
[ "Given", "a", "URL", "try", "to", "pop", "it", "up", "in", "a", "browser", "on", "most", "platforms", ".", "brow_bin", "is", "only", "used", "on", "OS", "s", "where", "there", "is", "no", "open", "or", "start", "cmd", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L496-L530
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
_TkRead.read
def read(self, file, nbytes): """Read nbytes characters from file while running Tk mainloop""" if not capable.OF_GRAPHICS: raise RuntimeError("Cannot run this command without graphics") if isinstance(file, int): fd = file else: # Otherwise, assume we h...
python
def read(self, file, nbytes): """Read nbytes characters from file while running Tk mainloop""" if not capable.OF_GRAPHICS: raise RuntimeError("Cannot run this command without graphics") if isinstance(file, int): fd = file else: # Otherwise, assume we h...
[ "def", "read", "(", "self", ",", "file", ",", "nbytes", ")", ":", "if", "not", "capable", ".", "OF_GRAPHICS", ":", "raise", "RuntimeError", "(", "\"Cannot run this command without graphics\"", ")", "if", "isinstance", "(", "file", ",", "int", ")", ":", "fd",...
Read nbytes characters from file while running Tk mainloop
[ "Read", "nbytes", "characters", "from", "file", "while", "running", "Tk", "mainloop" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L436-L475
spacetelescope/stsci.tools
lib/stsci/tools/irafutils.py
_TkRead._read
def _read(self, fd, mask): """Read waiting data and terminate Tk mainloop if done""" try: # if EOF was encountered on a tty, avoid reading again because # it actually requests more data if select.select([fd],[],[],0)[0]: snew = os.read(fd, self.nbytes)...
python
def _read(self, fd, mask): """Read waiting data and terminate Tk mainloop if done""" try: # if EOF was encountered on a tty, avoid reading again because # it actually requests more data if select.select([fd],[],[],0)[0]: snew = os.read(fd, self.nbytes)...
[ "def", "_read", "(", "self", ",", "fd", ",", "mask", ")", ":", "try", ":", "# if EOF was encountered on a tty, avoid reading again because", "# it actually requests more data", "if", "select", ".", "select", "(", "[", "fd", "]", ",", "[", "]", ",", "[", "]", "...
Read waiting data and terminate Tk mainloop if done
[ "Read", "waiting", "data", "and", "terminate", "Tk", "mainloop", "if", "done" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L478-L494
3ll3d00d/vibe
backend/src/analyser/common/signal.py
loadSignalFromDelimitedFile
def loadSignalFromDelimitedFile(filename, timeColumnIdx=0, dataColumnIdx=1, delimiter=',', skipHeader=0) -> Signal: """ reads a delimited file and converts into a Signal :param filename: string :param timeColumnIdx: 0 indexed column number :param dataColumnIdx: 0 indexed column number :param delimit...
python
def loadSignalFromDelimitedFile(filename, timeColumnIdx=0, dataColumnIdx=1, delimiter=',', skipHeader=0) -> Signal: """ reads a delimited file and converts into a Signal :param filename: string :param timeColumnIdx: 0 indexed column number :param dataColumnIdx: 0 indexed column number :param delimit...
[ "def", "loadSignalFromDelimitedFile", "(", "filename", ",", "timeColumnIdx", "=", "0", ",", "dataColumnIdx", "=", "1", ",", "delimiter", "=", "','", ",", "skipHeader", "=", "0", ")", "->", "Signal", ":", "data", "=", "np", ".", "genfromtxt", "(", "filename...
reads a delimited file and converts into a Signal :param filename: string :param timeColumnIdx: 0 indexed column number :param dataColumnIdx: 0 indexed column number :param delimiter: char :return a Signal instance
[ "reads", "a", "delimited", "file", "and", "converts", "into", "a", "Signal", ":", "param", "filename", ":", "string", ":", "param", "timeColumnIdx", ":", "0", "indexed", "column", "number", ":", "param", "dataColumnIdx", ":", "0", "indexed", "column", "numbe...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L208-L230
3ll3d00d/vibe
backend/src/analyser/common/signal.py
loadSignalFromWav
def loadSignalFromWav(inputSignalFile, calibrationRealWorldValue=None, calibrationSignalFile=None, start=None, end=None) -> Signal: """ reads a wav file into a Signal and scales the input so that the sample are expressed in real world values (as defined by the calibration signal). :par...
python
def loadSignalFromWav(inputSignalFile, calibrationRealWorldValue=None, calibrationSignalFile=None, start=None, end=None) -> Signal: """ reads a wav file into a Signal and scales the input so that the sample are expressed in real world values (as defined by the calibration signal). :par...
[ "def", "loadSignalFromWav", "(", "inputSignalFile", ",", "calibrationRealWorldValue", "=", "None", ",", "calibrationSignalFile", "=", "None", ",", "start", "=", "None", ",", "end", "=", "None", ")", "->", "Signal", ":", "inputSignal", "=", "readWav", "(", "inp...
reads a wav file into a Signal and scales the input so that the sample are expressed in real world values (as defined by the calibration signal). :param inputSignalFile: a path to the input signal file :param calibrationSignalFile: a path the calibration signal file :param calibrationRealWorldValue: the...
[ "reads", "a", "wav", "file", "into", "a", "Signal", "and", "scales", "the", "input", "so", "that", "the", "sample", "are", "expressed", "in", "real", "world", "values", "(", "as", "defined", "by", "the", "calibration", "signal", ")", ".", ":", "param", ...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L233-L249
3ll3d00d/vibe
backend/src/analyser/common/signal.py
readWav
def readWav(inputSignalFile, selectedChannel=1, start=None, end=None) -> Signal: """ reads a wav file into a Signal. :param inputSignalFile: a path to the input signal file :param selectedChannel: the channel to read. :param start: the time to start reading from in HH:mm:ss.SSS format. :param end: t...
python
def readWav(inputSignalFile, selectedChannel=1, start=None, end=None) -> Signal: """ reads a wav file into a Signal. :param inputSignalFile: a path to the input signal file :param selectedChannel: the channel to read. :param start: the time to start reading from in HH:mm:ss.SSS format. :param end: t...
[ "def", "readWav", "(", "inputSignalFile", ",", "selectedChannel", "=", "1", ",", "start", "=", "None", ",", "end", "=", "None", ")", "->", "Signal", ":", "def", "asFrames", "(", "time", ",", "fs", ")", ":", "hours", ",", "minutes", ",", "seconds", "=...
reads a wav file into a Signal. :param inputSignalFile: a path to the input signal file :param selectedChannel: the channel to read. :param start: the time to start reading from in HH:mm:ss.SSS format. :param end: the time to end reading from in HH:mm:ss.SSS format. :returns: Signal.
[ "reads", "a", "wav", "file", "into", "a", "Signal", ".", ":", "param", "inputSignalFile", ":", "a", "path", "to", "the", "input", "signal", "file", ":", "param", "selectedChannel", ":", "the", "channel", "to", "read", ".", ":", "param", "start", ":", "...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L252-L277
3ll3d00d/vibe
backend/src/analyser/common/signal.py
loadTriAxisSignalFromFile
def loadTriAxisSignalFromFile(filename, timeColumnIdx=0, xIdx=1, yIdx=2, zIdx=3, delimiter=',', skipHeader=0) -> TriAxisSignal: """ A factory method for loading a tri axis measurement from a single file. :param filename: the file to load from. :param timeColumnIdx: the colu...
python
def loadTriAxisSignalFromFile(filename, timeColumnIdx=0, xIdx=1, yIdx=2, zIdx=3, delimiter=',', skipHeader=0) -> TriAxisSignal: """ A factory method for loading a tri axis measurement from a single file. :param filename: the file to load from. :param timeColumnIdx: the colu...
[ "def", "loadTriAxisSignalFromFile", "(", "filename", ",", "timeColumnIdx", "=", "0", ",", "xIdx", "=", "1", ",", "yIdx", "=", "2", ",", "zIdx", "=", "3", ",", "delimiter", "=", "','", ",", "skipHeader", "=", "0", ")", "->", "TriAxisSignal", ":", "retur...
A factory method for loading a tri axis measurement from a single file. :param filename: the file to load from. :param timeColumnIdx: the column containing time data. :param xIdx: the column containing x axis data. :param yIdx: the column containing y axis data. :param zIdx: the column containing z ...
[ "A", "factory", "method", "for", "loading", "a", "tri", "axis", "measurement", "from", "a", "single", "file", ".", ":", "param", "filename", ":", "the", "file", "to", "load", "from", ".", ":", "param", "timeColumnIdx", ":", "the", "column", "containing", ...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L381-L400
3ll3d00d/vibe
backend/src/analyser/common/signal.py
Signal.psd
def psd(self, ref=None, segmentLengthMultiplier=1, mode=None, **kwargs): """ analyses the source and returns a PSD, segment is set to get ~1Hz frequency resolution :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :pa...
python
def psd(self, ref=None, segmentLengthMultiplier=1, mode=None, **kwargs): """ analyses the source and returns a PSD, segment is set to get ~1Hz frequency resolution :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :pa...
[ "def", "psd", "(", "self", ",", "ref", "=", "None", ",", "segmentLengthMultiplier", "=", "1", ",", "mode", "=", "None", ",", "*", "*", "kwargs", ")", ":", "def", "analysisFunc", "(", "x", ",", "nperseg", ",", "*", "*", "kwargs", ")", ":", "f", ",...
analyses the source and returns a PSD, segment is set to get ~1Hz frequency resolution :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :param mode: cq or none. :return: f : ndarray Array of sample fr...
[ "analyses", "the", "source", "and", "returns", "a", "PSD", "segment", "is", "set", "to", "get", "~1Hz", "frequency", "resolution", ":", "param", "ref", ":", "the", "reference", "value", "for", "dB", "purposes", ".", ":", "param", "segmentLengthMultiplier", "...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L67-L90
3ll3d00d/vibe
backend/src/analyser/common/signal.py
Signal.spectrum
def spectrum(self, ref=None, segmentLengthMultiplier=1, mode=None, **kwargs): """ analyses the source to generate the linear spectrum. :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :param mode: cq or none. ...
python
def spectrum(self, ref=None, segmentLengthMultiplier=1, mode=None, **kwargs): """ analyses the source to generate the linear spectrum. :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :param mode: cq or none. ...
[ "def", "spectrum", "(", "self", ",", "ref", "=", "None", ",", "segmentLengthMultiplier", "=", "1", ",", "mode", "=", "None", ",", "*", "*", "kwargs", ")", ":", "def", "analysisFunc", "(", "x", ",", "nperseg", ",", "*", "*", "kwargs", ")", ":", "f",...
analyses the source to generate the linear spectrum. :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :param mode: cq or none. :return: f : ndarray Array of sample frequencies. Pxx : ndarr...
[ "analyses", "the", "source", "to", "generate", "the", "linear", "spectrum", ".", ":", "param", "ref", ":", "the", "reference", "value", "for", "dB", "purposes", ".", ":", "param", "segmentLengthMultiplier", ":", "allow", "for", "increased", "resolution", ".", ...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L92-L120
3ll3d00d/vibe
backend/src/analyser/common/signal.py
Signal.peakSpectrum
def peakSpectrum(self, ref=None, segmentLengthMultiplier=1, mode=None, window='hann'): """ analyses the source to generate the max values per bin per segment :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :param mo...
python
def peakSpectrum(self, ref=None, segmentLengthMultiplier=1, mode=None, window='hann'): """ analyses the source to generate the max values per bin per segment :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :param mo...
[ "def", "peakSpectrum", "(", "self", ",", "ref", "=", "None", ",", "segmentLengthMultiplier", "=", "1", ",", "mode", "=", "None", ",", "window", "=", "'hann'", ")", ":", "def", "analysisFunc", "(", "x", ",", "nperseg", ")", ":", "freqs", ",", "_", ","...
analyses the source to generate the max values per bin per segment :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :param mode: cq or none. :return: f : ndarray Array of sample frequencies. ...
[ "analyses", "the", "source", "to", "generate", "the", "max", "values", "per", "bin", "per", "segment", ":", "param", "ref", ":", "the", "reference", "value", "for", "dB", "purposes", ".", ":", "param", "segmentLengthMultiplier", ":", "allow", "for", "increas...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L122-L153
3ll3d00d/vibe
backend/src/analyser/common/signal.py
Signal.spectrogram
def spectrogram(self, ref=None, segmentLengthMultiplier=1, window='hann'): """ analyses the source to generate a spectrogram :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :return: t : ndarray ...
python
def spectrogram(self, ref=None, segmentLengthMultiplier=1, window='hann'): """ analyses the source to generate a spectrogram :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :return: t : ndarray ...
[ "def", "spectrogram", "(", "self", ",", "ref", "=", "None", ",", "segmentLengthMultiplier", "=", "1", ",", "window", "=", "'hann'", ")", ":", "t", ",", "f", ",", "Sxx", "=", "signal", ".", "spectrogram", "(", "self", ".", "samples", ",", "self", ".",...
analyses the source to generate a spectrogram :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :return: t : ndarray Array of time slices. f : ndarray Array of sample frequencies. ...
[ "analyses", "the", "source", "to", "generate", "a", "spectrogram", ":", "param", "ref", ":", "the", "reference", "value", "for", "dB", "purposes", ".", ":", "param", "segmentLengthMultiplier", ":", "allow", "for", "increased", "resolution", ".", ":", "return",...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L155-L177
3ll3d00d/vibe
backend/src/analyser/common/signal.py
Signal.lowPass
def lowPass(self, *args): """ Creates a copy of the signal with the low pass applied, args specifed are passed through to _butter. :return: """ return Signal(self._butter(self.samples, 'low', *args), fs=self.fs)
python
def lowPass(self, *args): """ Creates a copy of the signal with the low pass applied, args specifed are passed through to _butter. :return: """ return Signal(self._butter(self.samples, 'low', *args), fs=self.fs)
[ "def", "lowPass", "(", "self", ",", "*", "args", ")", ":", "return", "Signal", "(", "self", ".", "_butter", "(", "self", ".", "samples", ",", "'low'", ",", "*", "args", ")", ",", "fs", "=", "self", ".", "fs", ")" ]
Creates a copy of the signal with the low pass applied, args specifed are passed through to _butter. :return:
[ "Creates", "a", "copy", "of", "the", "signal", "with", "the", "low", "pass", "applied", "args", "specifed", "are", "passed", "through", "to", "_butter", ".", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L179-L184
3ll3d00d/vibe
backend/src/analyser/common/signal.py
Signal.highPass
def highPass(self, *args): """ Creates a copy of the signal with the high pass applied, args specifed are passed through to _butter. :return: """ return Signal(self._butter(self.samples, 'high', *args), fs=self.fs)
python
def highPass(self, *args): """ Creates a copy of the signal with the high pass applied, args specifed are passed through to _butter. :return: """ return Signal(self._butter(self.samples, 'high', *args), fs=self.fs)
[ "def", "highPass", "(", "self", ",", "*", "args", ")", ":", "return", "Signal", "(", "self", ".", "_butter", "(", "self", ".", "samples", ",", "'high'", ",", "*", "args", ")", ",", "fs", "=", "self", ".", "fs", ")" ]
Creates a copy of the signal with the high pass applied, args specifed are passed through to _butter. :return:
[ "Creates", "a", "copy", "of", "the", "signal", "with", "the", "high", "pass", "applied", "args", "specifed", "are", "passed", "through", "to", "_butter", ".", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L186-L191
3ll3d00d/vibe
backend/src/analyser/common/signal.py
Signal._butter
def _butter(self, data, btype, f3=2, order=2): """ Applies a digital butterworth filter via filtfilt at the specified f3 and order. Default values are set to correspond to apparently sensible filters that distinguish between vibration and tilt from an accelerometer. :param data: the dat...
python
def _butter(self, data, btype, f3=2, order=2): """ Applies a digital butterworth filter via filtfilt at the specified f3 and order. Default values are set to correspond to apparently sensible filters that distinguish between vibration and tilt from an accelerometer. :param data: the dat...
[ "def", "_butter", "(", "self", ",", "data", ",", "btype", ",", "f3", "=", "2", ",", "order", "=", "2", ")", ":", "b", ",", "a", "=", "signal", ".", "butter", "(", "order", ",", "f3", "/", "(", "0.5", "*", "self", ".", "fs", ")", ",", "btype...
Applies a digital butterworth filter via filtfilt at the specified f3 and order. Default values are set to correspond to apparently sensible filters that distinguish between vibration and tilt from an accelerometer. :param data: the data to filter. :param btype: high or low. :param f3: ...
[ "Applies", "a", "digital", "butterworth", "filter", "via", "filtfilt", "at", "the", "specified", "f3", "and", "order", ".", "Default", "values", "are", "set", "to", "correspond", "to", "apparently", "sensible", "filters", "that", "distinguish", "between", "vibra...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L193-L205
3ll3d00d/vibe
backend/src/analyser/common/signal.py
TriAxisSignal._getAnalysis
def _getAnalysis(self, axis, analysis, ref=None): """ gets the named analysis on the given axis and caches the result (or reads from the cache if data is available already) :param axis: the named axis. :param analysis: the analysis name. :return: the analysis tuple. ...
python
def _getAnalysis(self, axis, analysis, ref=None): """ gets the named analysis on the given axis and caches the result (or reads from the cache if data is available already) :param axis: the named axis. :param analysis: the analysis name. :return: the analysis tuple. ...
[ "def", "_getAnalysis", "(", "self", ",", "axis", ",", "analysis", ",", "ref", "=", "None", ")", ":", "cache", "=", "self", ".", "cache", ".", "get", "(", "str", "(", "ref", ")", ")", "if", "cache", "is", "None", ":", "cache", "=", "{", "'x'", "...
gets the named analysis on the given axis and caches the result (or reads from the cache if data is available already) :param axis: the named axis. :param analysis: the analysis name. :return: the analysis tuple.
[ "gets", "the", "named", "analysis", "on", "the", "given", "axis", "and", "caches", "the", "result", "(", "or", "reads", "from", "the", "cache", "if", "data", "is", "available", "already", ")", ":", "param", "axis", ":", "the", "named", "axis", ".", ":"...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L346-L378
fitnr/convertdate
convertdate/positivist.py
legal_date
def legal_date(year, month, day): '''Checks if a given date is a legal positivist date''' try: assert year >= 1 assert 0 < month <= 14 assert 0 < day <= 28 if month == 14: if isleap(year + YEAR_EPOCH - 1): assert day <= 2 else: ...
python
def legal_date(year, month, day): '''Checks if a given date is a legal positivist date''' try: assert year >= 1 assert 0 < month <= 14 assert 0 < day <= 28 if month == 14: if isleap(year + YEAR_EPOCH - 1): assert day <= 2 else: ...
[ "def", "legal_date", "(", "year", ",", "month", ",", "day", ")", ":", "try", ":", "assert", "year", ">=", "1", "assert", "0", "<", "month", "<=", "14", "assert", "0", "<", "day", "<=", "28", "if", "month", "==", "14", ":", "if", "isleap", "(", ...
Checks if a given date is a legal positivist date
[ "Checks", "if", "a", "given", "date", "is", "a", "legal", "positivist", "date" ]
train
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/positivist.py#L38-L53
fitnr/convertdate
convertdate/positivist.py
to_jd
def to_jd(year, month, day): '''Convert a Positivist date to Julian day count.''' legal_date(year, month, day) gyear = year + YEAR_EPOCH - 1 return ( gregorian.EPOCH - 1 + (365 * (gyear - 1)) + floor((gyear - 1) / 4) + (-floor((gyear - 1) / 100)) + floor((gyear - 1) / 400) + (mo...
python
def to_jd(year, month, day): '''Convert a Positivist date to Julian day count.''' legal_date(year, month, day) gyear = year + YEAR_EPOCH - 1 return ( gregorian.EPOCH - 1 + (365 * (gyear - 1)) + floor((gyear - 1) / 4) + (-floor((gyear - 1) / 100)) + floor((gyear - 1) / 400) + (mo...
[ "def", "to_jd", "(", "year", ",", "month", ",", "day", ")", ":", "legal_date", "(", "year", ",", "month", ",", "day", ")", "gyear", "=", "year", "+", "YEAR_EPOCH", "-", "1", "return", "(", "gregorian", ".", "EPOCH", "-", "1", "+", "(", "365", "*"...
Convert a Positivist date to Julian day count.
[ "Convert", "a", "Positivist", "date", "to", "Julian", "day", "count", "." ]
train
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/positivist.py#L56-L65
fitnr/convertdate
convertdate/positivist.py
from_jd
def from_jd(jd): '''Convert a Julian day count to Positivist date.''' try: assert jd >= EPOCH except AssertionError: raise ValueError('Invalid Julian day') depoch = floor(jd - 0.5) + 0.5 - gregorian.EPOCH quadricent = floor(depoch / gregorian.INTERCALATION_CYCLE_DAYS) dqc = dep...
python
def from_jd(jd): '''Convert a Julian day count to Positivist date.''' try: assert jd >= EPOCH except AssertionError: raise ValueError('Invalid Julian day') depoch = floor(jd - 0.5) + 0.5 - gregorian.EPOCH quadricent = floor(depoch / gregorian.INTERCALATION_CYCLE_DAYS) dqc = dep...
[ "def", "from_jd", "(", "jd", ")", ":", "try", ":", "assert", "jd", ">=", "EPOCH", "except", "AssertionError", ":", "raise", "ValueError", "(", "'Invalid Julian day'", ")", "depoch", "=", "floor", "(", "jd", "-", "0.5", ")", "+", "0.5", "-", "gregorian", ...
Convert a Julian day count to Positivist date.
[ "Convert", "a", "Julian", "day", "count", "to", "Positivist", "date", "." ]
train
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/positivist.py#L68-L108
fitnr/convertdate
convertdate/positivist.py
dayname
def dayname(year, month, day): ''' Give the name of the month and day for a given date. Returns: tuple month_name, day_name ''' legal_date(year, month, day) yearday = (month - 1) * 28 + day if isleap(year + YEAR_EPOCH - 1): dname = data.day_names_leap[yearday - 1] else...
python
def dayname(year, month, day): ''' Give the name of the month and day for a given date. Returns: tuple month_name, day_name ''' legal_date(year, month, day) yearday = (month - 1) * 28 + day if isleap(year + YEAR_EPOCH - 1): dname = data.day_names_leap[yearday - 1] else...
[ "def", "dayname", "(", "year", ",", "month", ",", "day", ")", ":", "legal_date", "(", "year", ",", "month", ",", "day", ")", "yearday", "=", "(", "month", "-", "1", ")", "*", "28", "+", "day", "if", "isleap", "(", "year", "+", "YEAR_EPOCH", "-", ...
Give the name of the month and day for a given date. Returns: tuple month_name, day_name
[ "Give", "the", "name", "of", "the", "month", "and", "day", "for", "a", "given", "date", "." ]
train
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/positivist.py#L119-L135
3ll3d00d/vibe
backend/src/analyser/common/devicecontroller.py
Device.hasExpired
def hasExpired(self): """ :return: true if the lastUpdateTime is more than maxAge seconds ago. """ return (datetime.datetime.utcnow() - self.lastUpdateTime).total_seconds() > self.maxAgeSeconds
python
def hasExpired(self): """ :return: true if the lastUpdateTime is more than maxAge seconds ago. """ return (datetime.datetime.utcnow() - self.lastUpdateTime).total_seconds() > self.maxAgeSeconds
[ "def", "hasExpired", "(", "self", ")", ":", "return", "(", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "-", "self", ".", "lastUpdateTime", ")", ".", "total_seconds", "(", ")", ">", "self", ".", "maxAgeSeconds" ]
:return: true if the lastUpdateTime is more than maxAge seconds ago.
[ ":", "return", ":", "true", "if", "the", "lastUpdateTime", "is", "more", "than", "maxAge", "seconds", "ago", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L33-L37
3ll3d00d/vibe
backend/src/analyser/common/devicecontroller.py
DeviceController.accept
def accept(self, deviceId, device): """ Adds the named device to the store. :param deviceId: :param device: :return: """ storedDevice = self.devices.get(deviceId) if storedDevice is None: logger.info('Initialising device ' + deviceId) ...
python
def accept(self, deviceId, device): """ Adds the named device to the store. :param deviceId: :param device: :return: """ storedDevice = self.devices.get(deviceId) if storedDevice is None: logger.info('Initialising device ' + deviceId) ...
[ "def", "accept", "(", "self", ",", "deviceId", ",", "device", ")", ":", "storedDevice", "=", "self", ".", "devices", ".", "get", "(", "deviceId", ")", "if", "storedDevice", "is", "None", ":", "logger", ".", "info", "(", "'Initialising device '", "+", "de...
Adds the named device to the store. :param deviceId: :param device: :return:
[ "Adds", "the", "named", "device", "to", "the", "store", ".", ":", "param", "deviceId", ":", ":", "param", "device", ":", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L63-L86
3ll3d00d/vibe
backend/src/analyser/common/devicecontroller.py
DeviceController.getDevices
def getDevices(self, status=None): """ The devices in the given state or all devices is the arg is none. :param status: the state to match against. :return: the devices """ return [d for d in self.devices.values() if status is None or d.payload.get('status') == status]
python
def getDevices(self, status=None): """ The devices in the given state or all devices is the arg is none. :param status: the state to match against. :return: the devices """ return [d for d in self.devices.values() if status is None or d.payload.get('status') == status]
[ "def", "getDevices", "(", "self", ",", "status", "=", "None", ")", ":", "return", "[", "d", "for", "d", "in", "self", ".", "devices", ".", "values", "(", ")", "if", "status", "is", "None", "or", "d", ".", "payload", ".", "get", "(", "'status'", "...
The devices in the given state or all devices is the arg is none. :param status: the state to match against. :return: the devices
[ "The", "devices", "in", "the", "given", "state", "or", "all", "devices", "is", "the", "arg", "is", "none", ".", ":", "param", "status", ":", "the", "state", "to", "match", "against", ".", ":", "return", ":", "the", "devices" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L88-L94
3ll3d00d/vibe
backend/src/analyser/common/devicecontroller.py
DeviceController.getDevice
def getDevice(self, id): """ gets the named device. :param id: the id. :return: the device """ return next(iter([d for d in self.devices.values() if d.deviceId == id]), None)
python
def getDevice(self, id): """ gets the named device. :param id: the id. :return: the device """ return next(iter([d for d in self.devices.values() if d.deviceId == id]), None)
[ "def", "getDevice", "(", "self", ",", "id", ")", ":", "return", "next", "(", "iter", "(", "[", "d", "for", "d", "in", "self", ".", "devices", ".", "values", "(", ")", "if", "d", ".", "deviceId", "==", "id", "]", ")", ",", "None", ")" ]
gets the named device. :param id: the id. :return: the device
[ "gets", "the", "named", "device", ".", ":", "param", "id", ":", "the", "id", ".", ":", "return", ":", "the", "device" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L96-L102
3ll3d00d/vibe
backend/src/analyser/common/devicecontroller.py
DeviceController._evictStaleDevices
def _evictStaleDevices(self): """ A housekeeping function which runs in a worker thread and which evicts devices that haven't sent an update for a while. """ while self.running: expiredDeviceIds = [key for key, value in self.devices.items() if value.hasExpired()] ...
python
def _evictStaleDevices(self): """ A housekeeping function which runs in a worker thread and which evicts devices that haven't sent an update for a while. """ while self.running: expiredDeviceIds = [key for key, value in self.devices.items() if value.hasExpired()] ...
[ "def", "_evictStaleDevices", "(", "self", ")", ":", "while", "self", ".", "running", ":", "expiredDeviceIds", "=", "[", "key", "for", "key", ",", "value", "in", "self", ".", "devices", ".", "items", "(", ")", "if", "value", ".", "hasExpired", "(", ")",...
A housekeeping function which runs in a worker thread and which evicts devices that haven't sent an update for a while.
[ "A", "housekeeping", "function", "which", "runs", "in", "a", "worker", "thread", "and", "which", "evicts", "devices", "that", "haven", "t", "sent", "an", "update", "for", "a", "while", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L104-L116
3ll3d00d/vibe
backend/src/analyser/common/devicecontroller.py
DeviceController.scheduleMeasurement
def scheduleMeasurement(self, measurementId, duration, start): """ Schedules the requested measurement session with all INITIALISED devices. :param measurementId: :param duration: :param start: :return: a dict of device vs status. """ # TODO subtract 1s fr...
python
def scheduleMeasurement(self, measurementId, duration, start): """ Schedules the requested measurement session with all INITIALISED devices. :param measurementId: :param duration: :param start: :return: a dict of device vs status. """ # TODO subtract 1s fr...
[ "def", "scheduleMeasurement", "(", "self", ",", "measurementId", ",", "duration", ",", "start", ")", ":", "# TODO subtract 1s from start and format", "results", "=", "{", "}", "for", "device", "in", "self", ".", "getDevices", "(", "RecordingDeviceStatus", ".", "IN...
Schedules the requested measurement session with all INITIALISED devices. :param measurementId: :param duration: :param start: :return: a dict of device vs status.
[ "Schedules", "the", "requested", "measurement", "session", "with", "all", "INITIALISED", "devices", ".", ":", "param", "measurementId", ":", ":", "param", "duration", ":", ":", "param", "start", ":", ":", "return", ":", "a", "dict", "of", "device", "vs", "...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L118-L139
3ll3d00d/vibe
backend/src/analyser/resources/state.py
State.patch
def patch(self): """ Allows the UI to update parameters ensuring that all devices are kept in sync. Payload is json in TargetState format. :return: """ # TODO block until all devices have updated? json = request.get_json() logger.info("Updating target stat...
python
def patch(self): """ Allows the UI to update parameters ensuring that all devices are kept in sync. Payload is json in TargetState format. :return: """ # TODO block until all devices have updated? json = request.get_json() logger.info("Updating target stat...
[ "def", "patch", "(", "self", ")", ":", "# TODO block until all devices have updated?", "json", "=", "request", ".", "get_json", "(", ")", "logger", ".", "info", "(", "\"Updating target state with \"", "+", "str", "(", "json", ")", ")", "self", ".", "_targetState...
Allows the UI to update parameters ensuring that all devices are kept in sync. Payload is json in TargetState format. :return:
[ "Allows", "the", "UI", "to", "update", "parameters", "ensuring", "that", "all", "devices", "are", "kept", "in", "sync", ".", "Payload", "is", "json", "in", "TargetState", "format", ".", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/state.py#L19-L29
spacetelescope/stsci.tools
lib/stsci/tools/fitsdiff.py
list_parse
def list_parse(name_list): """Parse a comma-separated list of values, or a filename (starting with @) containing a list value on each line. """ if name_list and name_list[0] == '@': value = name_list[1:] if not os.path.exists(value): log.warning('The file %s does not exist' ...
python
def list_parse(name_list): """Parse a comma-separated list of values, or a filename (starting with @) containing a list value on each line. """ if name_list and name_list[0] == '@': value = name_list[1:] if not os.path.exists(value): log.warning('The file %s does not exist' ...
[ "def", "list_parse", "(", "name_list", ")", ":", "if", "name_list", "and", "name_list", "[", "0", "]", "==", "'@'", ":", "value", "=", "name_list", "[", "1", ":", "]", "if", "not", "os", ".", "path", ".", "exists", "(", "value", ")", ":", "log", ...
Parse a comma-separated list of values, or a filename (starting with @) containing a list value on each line.
[ "Parse", "a", "comma", "-", "separated", "list", "of", "values", "or", "a", "filename", "(", "starting", "with" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fitsdiff.py#L45-L61
spacetelescope/stsci.tools
lib/stsci/tools/minmatch.py
MinMatchDict._mmInit
def _mmInit(self): """Create the minimum match dictionary of keys""" # cache references to speed up loop a bit mmkeys = {} mmkeysGet = mmkeys.setdefault minkeylength = self.minkeylength for key in self.data.keys(): # add abbreviations as short as minkeylength ...
python
def _mmInit(self): """Create the minimum match dictionary of keys""" # cache references to speed up loop a bit mmkeys = {} mmkeysGet = mmkeys.setdefault minkeylength = self.minkeylength for key in self.data.keys(): # add abbreviations as short as minkeylength ...
[ "def", "_mmInit", "(", "self", ")", ":", "# cache references to speed up loop a bit", "mmkeys", "=", "{", "}", "mmkeysGet", "=", "mmkeys", ".", "setdefault", "minkeylength", "=", "self", ".", "minkeylength", "for", "key", "in", "self", ".", "data", ".", "keys"...
Create the minimum match dictionary of keys
[ "Create", "the", "minimum", "match", "dictionary", "of", "keys" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L67-L80
spacetelescope/stsci.tools
lib/stsci/tools/minmatch.py
MinMatchDict.resolve
def resolve(self, key, keylist): """Hook to resolve ambiguities in selected keys""" raise AmbiguousKeyError("Ambiguous key "+ repr(key) + ", could be any of " + str(sorted(keylist)))
python
def resolve(self, key, keylist): """Hook to resolve ambiguities in selected keys""" raise AmbiguousKeyError("Ambiguous key "+ repr(key) + ", could be any of " + str(sorted(keylist)))
[ "def", "resolve", "(", "self", ",", "key", ",", "keylist", ")", ":", "raise", "AmbiguousKeyError", "(", "\"Ambiguous key \"", "+", "repr", "(", "key", ")", "+", "\", could be any of \"", "+", "str", "(", "sorted", "(", "keylist", ")", ")", ")" ]
Hook to resolve ambiguities in selected keys
[ "Hook", "to", "resolve", "ambiguities", "in", "selected", "keys" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L101-L104
spacetelescope/stsci.tools
lib/stsci/tools/minmatch.py
MinMatchDict.add
def add(self, key, item): """Add a new key/item pair to the dictionary. Resets an existing key value only if this is an exact match to a known key.""" mmkeys = self.mmkeys if mmkeys is not None and not (key in self.data): # add abbreviations as short as minkeylength ...
python
def add(self, key, item): """Add a new key/item pair to the dictionary. Resets an existing key value only if this is an exact match to a known key.""" mmkeys = self.mmkeys if mmkeys is not None and not (key in self.data): # add abbreviations as short as minkeylength ...
[ "def", "add", "(", "self", ",", "key", ",", "item", ")", ":", "mmkeys", "=", "self", ".", "mmkeys", "if", "mmkeys", "is", "not", "None", "and", "not", "(", "key", "in", "self", ".", "data", ")", ":", "# add abbreviations as short as minkeylength", "# alw...
Add a new key/item pair to the dictionary. Resets an existing key value only if this is an exact match to a known key.
[ "Add", "a", "new", "key", "/", "item", "pair", "to", "the", "dictionary", ".", "Resets", "an", "existing", "key", "value", "only", "if", "this", "is", "an", "exact", "match", "to", "a", "known", "key", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L106-L119