repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
IrafPar._getField
def _getField(self, field, native=0, prompt=1): """Get a parameter field value""" try: # expand field name using minimum match field = _getFieldDict[field] except KeyError as e: # re-raise the exception with a bit more info raise SyntaxError("Canno...
python
def _getField(self, field, native=0, prompt=1): """Get a parameter field value""" try: # expand field name using minimum match field = _getFieldDict[field] except KeyError as e: # re-raise the exception with a bit more info raise SyntaxError("Canno...
[ "def", "_getField", "(", "self", ",", "field", ",", "native", "=", "0", ",", "prompt", "=", "1", ")", ":", "try", ":", "# expand field name using minimum match", "field", "=", "_getFieldDict", "[", "field", "]", "except", "KeyError", "as", "e", ":", "# re-...
Get a parameter field value
[ "Get", "a", "parameter", "field", "value" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L670-L720
train
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
IrafPar._setField
def _setField(self, value, field, check=1): """Set a parameter field value""" try: # expand field name using minimum match field = _setFieldDict[field] except KeyError as e: raise SyntaxError("Cannot set field " + field + " for parameter " ...
python
def _setField(self, value, field, check=1): """Set a parameter field value""" try: # expand field name using minimum match field = _setFieldDict[field] except KeyError as e: raise SyntaxError("Cannot set field " + field + " for parameter " ...
[ "def", "_setField", "(", "self", ",", "value", ",", "field", ",", "check", "=", "1", ")", ":", "try", ":", "# expand field name using minimum match", "field", "=", "_setFieldDict", "[", "field", "]", "except", "KeyError", "as", "e", ":", "raise", "SyntaxErro...
Set a parameter field value
[ "Set", "a", "parameter", "field", "value" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L722-L752
train
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
IrafArrayPar.save
def save(self, dolist=0): """Return .par format string for this parameter If dolist is set, returns fields as a list of strings. Default is to return a single string appropriate for writing to a file. """ quoted = not dolist array_size = 1 for d in self.shape: ...
python
def save(self, dolist=0): """Return .par format string for this parameter If dolist is set, returns fields as a list of strings. Default is to return a single string appropriate for writing to a file. """ quoted = not dolist array_size = 1 for d in self.shape: ...
[ "def", "save", "(", "self", ",", "dolist", "=", "0", ")", ":", "quoted", "=", "not", "dolist", "array_size", "=", "1", "for", "d", "in", "self", ".", "shape", ":", "array_size", "=", "d", "*", "array_size", "ndim", "=", "len", "(", "self", ".", "...
Return .par format string for this parameter If dolist is set, returns fields as a list of strings. Default is to return a single string appropriate for writing to a file.
[ "Return", ".", "par", "format", "string", "for", "this", "parameter" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L864-L913
train
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
IrafArrayPar.dpar
def dpar(self, cl=1): """Return dpar-style executable assignment for parameter Default is to write CL version of code; if cl parameter is false, writes Python executable code instead. Note that dpar doesn't even work for arrays in the CL, so we just use Python syntax here. ...
python
def dpar(self, cl=1): """Return dpar-style executable assignment for parameter Default is to write CL version of code; if cl parameter is false, writes Python executable code instead. Note that dpar doesn't even work for arrays in the CL, so we just use Python syntax here. ...
[ "def", "dpar", "(", "self", ",", "cl", "=", "1", ")", ":", "sval", "=", "list", "(", "map", "(", "self", ".", "toString", ",", "self", ".", "value", ",", "len", "(", "self", ".", "value", ")", "*", "[", "1", "]", ")", ")", "for", "i", "in",...
Return dpar-style executable assignment for parameter Default is to write CL version of code; if cl parameter is false, writes Python executable code instead. Note that dpar doesn't even work for arrays in the CL, so we just use Python syntax here.
[ "Return", "dpar", "-", "style", "executable", "assignment", "for", "parameter" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L915-L928
train
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
IrafArrayPar.get
def get(self, field=None, index=None, lpar=0, prompt=1, native=0, mode="h"): """Return value of this parameter as a string (or in native format if native is non-zero.)""" if field: return self._getField(field,native=native,prompt=prompt) # may prompt for value if prompt flag is set ...
python
def get(self, field=None, index=None, lpar=0, prompt=1, native=0, mode="h"): """Return value of this parameter as a string (or in native format if native is non-zero.)""" if field: return self._getField(field,native=native,prompt=prompt) # may prompt for value if prompt flag is set ...
[ "def", "get", "(", "self", ",", "field", "=", "None", ",", "index", "=", "None", ",", "lpar", "=", "0", ",", "prompt", "=", "1", ",", "native", "=", "0", ",", "mode", "=", "\"h\"", ")", ":", "if", "field", ":", "return", "self", ".", "_getField...
Return value of this parameter as a string (or in native format if native is non-zero.)
[ "Return", "value", "of", "this", "parameter", "as", "a", "string", "(", "or", "in", "native", "format", "if", "native", "is", "non", "-", "zero", ".", ")" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L930-L960
train
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
IrafArrayPar.set
def set(self, value, field=None, index=None, check=1): """Set value of this parameter from a string or other value. Field is optional parameter field (p_prompt, p_minimum, etc.) Index is optional array index (zero-based). Set check=0 to assign the value without checking to see if it is ...
python
def set(self, value, field=None, index=None, check=1): """Set value of this parameter from a string or other value. Field is optional parameter field (p_prompt, p_minimum, etc.) Index is optional array index (zero-based). Set check=0 to assign the value without checking to see if it is ...
[ "def", "set", "(", "self", ",", "value", ",", "field", "=", "None", ",", "index", "=", "None", ",", "check", "=", "1", ")", ":", "if", "index", "is", "not", "None", ":", "sumindex", "=", "self", ".", "_sumindex", "(", "index", ")", "try", ":", ...
Set value of this parameter from a string or other value. Field is optional parameter field (p_prompt, p_minimum, etc.) Index is optional array index (zero-based). Set check=0 to assign the value without checking to see if it is within the min-max range or in the choice list.
[ "Set", "value", "of", "this", "parameter", "from", "a", "string", "or", "other", "value", ".", "Field", "is", "optional", "parameter", "field", "(", "p_prompt", "p_minimum", "etc", ".", ")", "Index", "is", "optional", "array", "index", "(", "zero", "-", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L962-L988
train
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
IrafArrayPar.checkValue
def checkValue(self,value,strict=0): """Check and convert a parameter value. Raises an exception if the value is not permitted for this parameter. Otherwise returns the value (converted to the right type.) """ v = self._coerceValue(value,strict) for i in range(l...
python
def checkValue(self,value,strict=0): """Check and convert a parameter value. Raises an exception if the value is not permitted for this parameter. Otherwise returns the value (converted to the right type.) """ v = self._coerceValue(value,strict) for i in range(l...
[ "def", "checkValue", "(", "self", ",", "value", ",", "strict", "=", "0", ")", ":", "v", "=", "self", ".", "_coerceValue", "(", "value", ",", "strict", ")", "for", "i", "in", "range", "(", "len", "(", "v", ")", ")", ":", "self", ".", "checkOneValu...
Check and convert a parameter value. Raises an exception if the value is not permitted for this parameter. Otherwise returns the value (converted to the right type.)
[ "Check", "and", "convert", "a", "parameter", "value", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L990-L1000
train
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
IrafArrayPar._sumindex
def _sumindex(self, index=None): """Convert tuple index to 1-D index into value""" try: ndim = len(index) except TypeError: # turn index into a 1-tuple index = (index,) ndim = 1 if len(self.shape) != ndim: raise ValueError("Inde...
python
def _sumindex(self, index=None): """Convert tuple index to 1-D index into value""" try: ndim = len(index) except TypeError: # turn index into a 1-tuple index = (index,) ndim = 1 if len(self.shape) != ndim: raise ValueError("Inde...
[ "def", "_sumindex", "(", "self", ",", "index", "=", "None", ")", ":", "try", ":", "ndim", "=", "len", "(", "index", ")", "except", "TypeError", ":", "# turn index into a 1-tuple", "index", "=", "(", "index", ",", ")", "ndim", "=", "1", "if", "len", "...
Convert tuple index to 1-D index into value
[ "Convert", "tuple", "index", "to", "1", "-", "D", "index", "into", "value" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L1034-L1052
train
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
IrafArrayPar._coerceValue
def _coerceValue(self,value,strict=0): """Coerce parameter to appropriate type Should accept None or null string. Must be an array. """ try: if isinstance(value,str): # allow single blank-separated string as input value = value.split() ...
python
def _coerceValue(self,value,strict=0): """Coerce parameter to appropriate type Should accept None or null string. Must be an array. """ try: if isinstance(value,str): # allow single blank-separated string as input value = value.split() ...
[ "def", "_coerceValue", "(", "self", ",", "value", ",", "strict", "=", "0", ")", ":", "try", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "# allow single blank-separated string as input", "value", "=", "value", ".", "split", "(", ")", "if", ...
Coerce parameter to appropriate type Should accept None or null string. Must be an array.
[ "Coerce", "parameter", "to", "appropriate", "type" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L1058-L1075
train
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
_StringMixin._setChoiceDict
def _setChoiceDict(self): """Create min-match dictionary for choice list""" # value is full name of choice parameter self.choiceDict = minmatch.MinMatchDict() for c in self.choice: self.choiceDict.add(c, c)
python
def _setChoiceDict(self): """Create min-match dictionary for choice list""" # value is full name of choice parameter self.choiceDict = minmatch.MinMatchDict() for c in self.choice: self.choiceDict.add(c, c)
[ "def", "_setChoiceDict", "(", "self", ")", ":", "# value is full name of choice parameter", "self", ".", "choiceDict", "=", "minmatch", ".", "MinMatchDict", "(", ")", "for", "c", "in", "self", ".", "choice", ":", "self", ".", "choiceDict", ".", "add", "(", "...
Create min-match dictionary for choice list
[ "Create", "min", "-", "match", "dictionary", "for", "choice", "list" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L1163-L1167
train
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
_BooleanMixin._checkAttribs
def _checkAttribs(self, strict): """Check initial attributes to make sure they are legal""" if self.min: warning("Minimum value not allowed for boolean-type parameter " + self.name, strict) self.min = None if self.max: if not self.prompt: ...
python
def _checkAttribs(self, strict): """Check initial attributes to make sure they are legal""" if self.min: warning("Minimum value not allowed for boolean-type parameter " + self.name, strict) self.min = None if self.max: if not self.prompt: ...
[ "def", "_checkAttribs", "(", "self", ",", "strict", ")", ":", "if", "self", ".", "min", ":", "warning", "(", "\"Minimum value not allowed for boolean-type parameter \"", "+", "self", ".", "name", ",", "strict", ")", "self", ".", "min", "=", "None", "if", "se...
Check initial attributes to make sure they are legal
[ "Check", "initial", "attributes", "to", "make", "sure", "they", "are", "legal" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L1234-L1254
train
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
_RealMixin._checkAttribs
def _checkAttribs(self, strict): """Check initial attributes to make sure they are legal""" if self.choice: warning("Choice values not allowed for real-type parameter " + self.name, strict) self.choice = None
python
def _checkAttribs(self, strict): """Check initial attributes to make sure they are legal""" if self.choice: warning("Choice values not allowed for real-type parameter " + self.name, strict) self.choice = None
[ "def", "_checkAttribs", "(", "self", ",", "strict", ")", ":", "if", "self", ".", "choice", ":", "warning", "(", "\"Choice values not allowed for real-type parameter \"", "+", "self", ".", "name", ",", "strict", ")", "self", ".", "choice", "=", "None" ]
Check initial attributes to make sure they are legal
[ "Check", "initial", "attributes", "to", "make", "sure", "they", "are", "legal" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L1458-L1463
train
3ll3d00d/vibe
backend/src/recorder/resources/recordingdevices.py
RecordingDevice.patch
def patch(self, deviceId): """ Updates the device with the given data. Supports a json payload like { fs: newFs samplesPerBatch: samplesPerBatch gyroEnabled: true gyroSensitivity: 500 accelerometerEnabled: true accelerometer...
python
def patch(self, deviceId): """ Updates the device with the given data. Supports a json payload like { fs: newFs samplesPerBatch: samplesPerBatch gyroEnabled: true gyroSensitivity: 500 accelerometerEnabled: true accelerometer...
[ "def", "patch", "(", "self", ",", "deviceId", ")", ":", "try", ":", "device", "=", "self", ".", "recordingDevices", ".", "get", "(", "deviceId", ")", "if", "device", ".", "status", "==", "RecordingDeviceStatus", ".", "INITIALISED", ":", "errors", "=", "s...
Updates the device with the given data. Supports a json payload like { fs: newFs samplesPerBatch: samplesPerBatch gyroEnabled: true gyroSensitivity: 500 accelerometerEnabled: true accelerometerSensitivity: 2 } A heartbeat is...
[ "Updates", "the", "device", "with", "the", "given", "data", ".", "Supports", "a", "json", "payload", "like", "{", "fs", ":", "newFs", "samplesPerBatch", ":", "samplesPerBatch", "gyroEnabled", ":", "true", "gyroSensitivity", ":", "500", "accelerometerEnabled", ":...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/recordingdevices.py#L36-L62
train
fitnr/convertdate
convertdate/gregorian.py
legal_date
def legal_date(year, month, day): '''Check if this is a legal date in the Gregorian calendar''' if month == 2: daysinmonth = 29 if isleap(year) else 28 else: daysinmonth = 30 if month in HAVE_30_DAYS else 31 if not (0 < day <= daysinmonth): raise ValueError("Month {} doesn't hav...
python
def legal_date(year, month, day): '''Check if this is a legal date in the Gregorian calendar''' if month == 2: daysinmonth = 29 if isleap(year) else 28 else: daysinmonth = 30 if month in HAVE_30_DAYS else 31 if not (0 < day <= daysinmonth): raise ValueError("Month {} doesn't hav...
[ "def", "legal_date", "(", "year", ",", "month", ",", "day", ")", ":", "if", "month", "==", "2", ":", "daysinmonth", "=", "29", "if", "isleap", "(", "year", ")", "else", "28", "else", ":", "daysinmonth", "=", "30", "if", "month", "in", "HAVE_30_DAYS",...
Check if this is a legal date in the Gregorian calendar
[ "Check", "if", "this", "is", "a", "legal", "date", "in", "the", "Gregorian", "calendar" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/gregorian.py#L30-L40
train
fitnr/convertdate
convertdate/gregorian.py
to_jd2
def to_jd2(year, month, day): '''Gregorian to Julian Day Count for years between 1801-2099''' # http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html legal_date(year, month, day) if month <= 2: year = year - 1 month = month + 12 a = floor(year / 100) b = floor(a / 4) c = ...
python
def to_jd2(year, month, day): '''Gregorian to Julian Day Count for years between 1801-2099''' # http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html legal_date(year, month, day) if month <= 2: year = year - 1 month = month + 12 a = floor(year / 100) b = floor(a / 4) c = ...
[ "def", "to_jd2", "(", "year", ",", "month", ",", "day", ")", ":", "# http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html", "legal_date", "(", "year", ",", "month", ",", "day", ")", "if", "month", "<=", "2", ":", "year", "=", "year", "-", "1", "month", "...
Gregorian to Julian Day Count for years between 1801-2099
[ "Gregorian", "to", "Julian", "Day", "Count", "for", "years", "between", "1801", "-", "2099" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/gregorian.py#L43-L58
train
fitnr/convertdate
convertdate/gregorian.py
from_jd
def from_jd(jd): '''Return Gregorian date in a (Y, M, D) tuple''' wjd = floor(jd - 0.5) + 0.5 depoch = wjd - EPOCH quadricent = floor(depoch / INTERCALATION_CYCLE_DAYS) dqc = depoch % INTERCALATION_CYCLE_DAYS cent = floor(dqc / LEAP_SUPPRESSION_DAYS) dcent = dqc % LEAP_SUPPRESSION_DAYS ...
python
def from_jd(jd): '''Return Gregorian date in a (Y, M, D) tuple''' wjd = floor(jd - 0.5) + 0.5 depoch = wjd - EPOCH quadricent = floor(depoch / INTERCALATION_CYCLE_DAYS) dqc = depoch % INTERCALATION_CYCLE_DAYS cent = floor(dqc / LEAP_SUPPRESSION_DAYS) dcent = dqc % LEAP_SUPPRESSION_DAYS ...
[ "def", "from_jd", "(", "jd", ")", ":", "wjd", "=", "floor", "(", "jd", "-", "0.5", ")", "+", "0.5", "depoch", "=", "wjd", "-", "EPOCH", "quadricent", "=", "floor", "(", "depoch", "/", "INTERCALATION_CYCLE_DAYS", ")", "dqc", "=", "depoch", "%", "INTER...
Return Gregorian date in a (Y, M, D) tuple
[ "Return", "Gregorian", "date", "in", "a", "(", "Y", "M", "D", ")", "tuple" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/gregorian.py#L80-L118
train
3ll3d00d/vibe
backend/src/analyser/common/targetcontroller.py
TargetController.storeFromHinge
def storeFromHinge(self, name, hingePoints): """ Stores a new item in the cache if it is allowed in. :param name: the name. :param hingePoints: the hinge points. :return: true if it is stored. """ if name not in self._cache: if self._valid(hingePoints...
python
def storeFromHinge(self, name, hingePoints): """ Stores a new item in the cache if it is allowed in. :param name: the name. :param hingePoints: the hinge points. :return: true if it is stored. """ if name not in self._cache: if self._valid(hingePoints...
[ "def", "storeFromHinge", "(", "self", ",", "name", ",", "hingePoints", ")", ":", "if", "name", "not", "in", "self", ".", "_cache", ":", "if", "self", ".", "_valid", "(", "hingePoints", ")", ":", "self", ".", "_cache", "[", "name", "]", "=", "{", "'...
Stores a new item in the cache if it is allowed in. :param name: the name. :param hingePoints: the hinge points. :return: true if it is stored.
[ "Stores", "a", "new", "item", "in", "the", "cache", "if", "it", "is", "allowed", "in", ".", ":", "param", "name", ":", "the", "name", ".", ":", "param", "hingePoints", ":", "the", "hinge", "points", ".", ":", "return", ":", "true", "if", "it", "is"...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetcontroller.py#L23-L35
train
3ll3d00d/vibe
backend/src/analyser/common/targetcontroller.py
TargetController.storeFromWav
def storeFromWav(self, uploadCacheEntry, start, end): """ Stores a new item in the cache. :param name: file name. :param start: start time. :param end: end time. :return: true if stored. """ prefix = uploadCacheEntry['name'] + '_' + start + '_' + end ...
python
def storeFromWav(self, uploadCacheEntry, start, end): """ Stores a new item in the cache. :param name: file name. :param start: start time. :param end: end time. :return: true if stored. """ prefix = uploadCacheEntry['name'] + '_' + start + '_' + end ...
[ "def", "storeFromWav", "(", "self", ",", "uploadCacheEntry", ",", "start", ",", "end", ")", ":", "prefix", "=", "uploadCacheEntry", "[", "'name'", "]", "+", "'_'", "+", "start", "+", "'_'", "+", "end", "match", "=", "next", "(", "(", "x", "for", "x",...
Stores a new item in the cache. :param name: file name. :param start: start time. :param end: end time. :return: true if stored.
[ "Stores", "a", "new", "item", "in", "the", "cache", ".", ":", "param", "name", ":", "file", "name", ".", ":", "param", "start", ":", "start", "time", ".", ":", "param", "end", ":", "end", "time", ".", ":", "return", ":", "true", "if", "stored", "...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetcontroller.py#L37-L62
train
3ll3d00d/vibe
backend/src/analyser/common/targetcontroller.py
TargetController.delete
def delete(self, name): """ Deletes the named entry in the cache. :param name: the name. :return: true if it is deleted. """ if name in self._cache: del self._cache[name] self.writeCache() # TODO clean files return True ...
python
def delete(self, name): """ Deletes the named entry in the cache. :param name: the name. :return: true if it is deleted. """ if name in self._cache: del self._cache[name] self.writeCache() # TODO clean files return True ...
[ "def", "delete", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_cache", ":", "del", "self", ".", "_cache", "[", "name", "]", "self", ".", "writeCache", "(", ")", "# TODO clean files", "return", "True", "return", "False" ]
Deletes the named entry in the cache. :param name: the name. :return: true if it is deleted.
[ "Deletes", "the", "named", "entry", "in", "the", "cache", ".", ":", "param", "name", ":", "the", "name", ".", ":", "return", ":", "true", "if", "it", "is", "deleted", "." ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetcontroller.py#L64-L75
train
3ll3d00d/vibe
backend/src/analyser/common/targetcontroller.py
TargetController.analyse
def analyse(self, name): """ reads the specified file. :param name: the name. :return: the analysis as frequency/Pxx. """ if name in self._cache: target = self._cache[name] if target['type'] == 'wav': signal = self._uploadController...
python
def analyse(self, name): """ reads the specified file. :param name: the name. :return: the analysis as frequency/Pxx. """ if name in self._cache: target = self._cache[name] if target['type'] == 'wav': signal = self._uploadController...
[ "def", "analyse", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_cache", ":", "target", "=", "self", ".", "_cache", "[", "name", "]", "if", "target", "[", "'type'", "]", "==", "'wav'", ":", "signal", "=", "self", ".", "_up...
reads the specified file. :param name: the name. :return: the analysis as frequency/Pxx.
[ "reads", "the", "specified", "file", ".", ":", "param", "name", ":", "the", "name", ".", ":", "return", ":", "the", "analysis", "as", "frequency", "/", "Pxx", "." ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetcontroller.py#L91-L130
train
3ll3d00d/vibe
backend/src/analyser/common/targetcontroller.py
TargetController.log_interp1d
def log_interp1d(self, xx, yy, kind='linear'): """ Performs a log space 1d interpolation. :param xx: the x values. :param yy: the y values. :param kind: the type of interpolation to apply (as per scipy interp1d) :return: the interpolation function. """ log...
python
def log_interp1d(self, xx, yy, kind='linear'): """ Performs a log space 1d interpolation. :param xx: the x values. :param yy: the y values. :param kind: the type of interpolation to apply (as per scipy interp1d) :return: the interpolation function. """ log...
[ "def", "log_interp1d", "(", "self", ",", "xx", ",", "yy", ",", "kind", "=", "'linear'", ")", ":", "logx", "=", "np", ".", "log10", "(", "xx", ")", "logy", "=", "np", ".", "log10", "(", "yy", ")", "lin_interp", "=", "interp1d", "(", "logx", ",", ...
Performs a log space 1d interpolation. :param xx: the x values. :param yy: the y values. :param kind: the type of interpolation to apply (as per scipy interp1d) :return: the interpolation function.
[ "Performs", "a", "log", "space", "1d", "interpolation", ".", ":", "param", "xx", ":", "the", "x", "values", ".", ":", "param", "yy", ":", "the", "y", "values", ".", ":", "param", "kind", ":", "the", "type", "of", "interpolation", "to", "apply", "(", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetcontroller.py#L140-L152
train
fitnr/convertdate
convertdate/coptic.py
to_jd
def to_jd(year, month, day): "Retrieve the Julian date equivalent for this date" return day + (month - 1) * 30 + (year - 1) * 365 + floor(year / 4) + EPOCH - 1
python
def to_jd(year, month, day): "Retrieve the Julian date equivalent for this date" return day + (month - 1) * 30 + (year - 1) * 365 + floor(year / 4) + EPOCH - 1
[ "def", "to_jd", "(", "year", ",", "month", ",", "day", ")", ":", "return", "day", "+", "(", "month", "-", "1", ")", "*", "30", "+", "(", "year", "-", "1", ")", "*", "365", "+", "floor", "(", "year", "/", "4", ")", "+", "EPOCH", "-", "1" ]
Retrieve the Julian date equivalent for this date
[ "Retrieve", "the", "Julian", "date", "equivalent", "for", "this", "date" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/coptic.py#L24-L26
train
fitnr/convertdate
convertdate/coptic.py
from_jd
def from_jd(jdc): "Create a new date from a Julian date." cdc = floor(jdc) + 0.5 - EPOCH year = floor((cdc - floor((cdc + 366) / 1461)) / 365) + 1 yday = jdc - to_jd(year, 1, 1) month = floor(yday / 30) + 1 day = yday - (month - 1) * 30 + 1 return year, month, day
python
def from_jd(jdc): "Create a new date from a Julian date." cdc = floor(jdc) + 0.5 - EPOCH year = floor((cdc - floor((cdc + 366) / 1461)) / 365) + 1 yday = jdc - to_jd(year, 1, 1) month = floor(yday / 30) + 1 day = yday - (month - 1) * 30 + 1 return year, month, day
[ "def", "from_jd", "(", "jdc", ")", ":", "cdc", "=", "floor", "(", "jdc", ")", "+", "0.5", "-", "EPOCH", "year", "=", "floor", "(", "(", "cdc", "-", "floor", "(", "(", "cdc", "+", "366", ")", "/", "1461", ")", ")", "/", "365", ")", "+", "1",...
Create a new date from a Julian date.
[ "Create", "a", "new", "date", "from", "a", "Julian", "date", "." ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/coptic.py#L29-L38
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
troll
def troll(roll, dec, v2, v3): """ Computes the roll angle at the target position based on:: the roll angle at the V1 axis(roll), the dec of the target(dec), and the V2/V3 position of the aperture (v2,v3) in arcseconds. Based on the algorithm provided by Colin Cox that i...
python
def troll(roll, dec, v2, v3): """ Computes the roll angle at the target position based on:: the roll angle at the V1 axis(roll), the dec of the target(dec), and the V2/V3 position of the aperture (v2,v3) in arcseconds. Based on the algorithm provided by Colin Cox that i...
[ "def", "troll", "(", "roll", ",", "dec", ",", "v2", ",", "v3", ")", ":", "# Convert all angles to radians", "_roll", "=", "DEGTORAD", "(", "roll", ")", "_dec", "=", "DEGTORAD", "(", "dec", ")", "_v2", "=", "DEGTORAD", "(", "v2", "/", "3600.", ")", "_...
Computes the roll angle at the target position based on:: the roll angle at the V1 axis(roll), the dec of the target(dec), and the V2/V3 position of the aperture (v2,v3) in arcseconds. Based on the algorithm provided by Colin Cox that is used in Generic Conversion a...
[ "Computes", "the", "roll", "angle", "at", "the", "target", "position", "based", "on", "::" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L106-L135
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.print_archive
def print_archive(self,format=True): """ Prints out archived WCS keywords.""" if len(list(self.orig_wcs.keys())) > 0: block = 'Original WCS keywords for ' + self.rootname+ '\n' block += ' backed up on '+repr(self.orig_wcs['WCSCDATE'])+'\n' if not format: ...
python
def print_archive(self,format=True): """ Prints out archived WCS keywords.""" if len(list(self.orig_wcs.keys())) > 0: block = 'Original WCS keywords for ' + self.rootname+ '\n' block += ' backed up on '+repr(self.orig_wcs['WCSCDATE'])+'\n' if not format: ...
[ "def", "print_archive", "(", "self", ",", "format", "=", "True", ")", ":", "if", "len", "(", "list", "(", "self", ".", "orig_wcs", ".", "keys", "(", ")", ")", ")", ">", "0", ":", "block", "=", "'Original WCS keywords for '", "+", "self", ".", "rootna...
Prints out archived WCS keywords.
[ "Prints", "out", "archived", "WCS", "keywords", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L420-L439
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.set_pscale
def set_pscale(self): """ Compute the pixel scale based on active WCS values. """ if self.new: self.pscale = 1.0 else: self.pscale = self.compute_pscale(self.cd11,self.cd21)
python
def set_pscale(self): """ Compute the pixel scale based on active WCS values. """ if self.new: self.pscale = 1.0 else: self.pscale = self.compute_pscale(self.cd11,self.cd21)
[ "def", "set_pscale", "(", "self", ")", ":", "if", "self", ".", "new", ":", "self", ".", "pscale", "=", "1.0", "else", ":", "self", ".", "pscale", "=", "self", ".", "compute_pscale", "(", "self", ".", "cd11", ",", "self", ".", "cd21", ")" ]
Compute the pixel scale based on active WCS values.
[ "Compute", "the", "pixel", "scale", "based", "on", "active", "WCS", "values", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L445-L450
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.compute_pscale
def compute_pscale(self,cd11,cd21): """ Compute the pixel scale based on active WCS values. """ return N.sqrt(N.power(cd11,2)+N.power(cd21,2)) * 3600.
python
def compute_pscale(self,cd11,cd21): """ Compute the pixel scale based on active WCS values. """ return N.sqrt(N.power(cd11,2)+N.power(cd21,2)) * 3600.
[ "def", "compute_pscale", "(", "self", ",", "cd11", ",", "cd21", ")", ":", "return", "N", ".", "sqrt", "(", "N", ".", "power", "(", "cd11", ",", "2", ")", "+", "N", ".", "power", "(", "cd21", ",", "2", ")", ")", "*", "3600." ]
Compute the pixel scale based on active WCS values.
[ "Compute", "the", "pixel", "scale", "based", "on", "active", "WCS", "values", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L452-L454
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.set_orient
def set_orient(self): """ Return the computed orientation based on CD matrix. """ self.orient = RADTODEG(N.arctan2(self.cd12,self.cd22))
python
def set_orient(self): """ Return the computed orientation based on CD matrix. """ self.orient = RADTODEG(N.arctan2(self.cd12,self.cd22))
[ "def", "set_orient", "(", "self", ")", ":", "self", ".", "orient", "=", "RADTODEG", "(", "N", ".", "arctan2", "(", "self", ".", "cd12", ",", "self", ".", "cd22", ")", ")" ]
Return the computed orientation based on CD matrix.
[ "Return", "the", "computed", "orientation", "based", "on", "CD", "matrix", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L460-L462
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.updateWCS
def updateWCS(self, pixel_scale=None, orient=None,refpos=None,refval=None,size=None): """ Create a new CD Matrix from the absolute pixel scale and reference image orientation. """ # Set up parameters necessary for updating WCS # Check to see if new value is provided, ...
python
def updateWCS(self, pixel_scale=None, orient=None,refpos=None,refval=None,size=None): """ Create a new CD Matrix from the absolute pixel scale and reference image orientation. """ # Set up parameters necessary for updating WCS # Check to see if new value is provided, ...
[ "def", "updateWCS", "(", "self", ",", "pixel_scale", "=", "None", ",", "orient", "=", "None", ",", "refpos", "=", "None", ",", "refval", "=", "None", ",", "size", "=", "None", ")", ":", "# Set up parameters necessary for updating WCS", "# Check to see if new val...
Create a new CD Matrix from the absolute pixel scale and reference image orientation.
[ "Create", "a", "new", "CD", "Matrix", "from", "the", "absolute", "pixel", "scale", "and", "reference", "image", "orientation", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L469-L540
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.scale_WCS
def scale_WCS(self,pixel_scale,retain=True): ''' Scale the WCS to a new pixel_scale. The 'retain' parameter [default value: True] controls whether or not to retain the original distortion solution in the CD matrix. ''' _ratio = pixel_scale / self.pscale # Correct the siz...
python
def scale_WCS(self,pixel_scale,retain=True): ''' Scale the WCS to a new pixel_scale. The 'retain' parameter [default value: True] controls whether or not to retain the original distortion solution in the CD matrix. ''' _ratio = pixel_scale / self.pscale # Correct the siz...
[ "def", "scale_WCS", "(", "self", ",", "pixel_scale", ",", "retain", "=", "True", ")", ":", "_ratio", "=", "pixel_scale", "/", "self", ".", "pscale", "# Correct the size of the image and CRPIX values for scaled WCS", "self", ".", "naxis1", "/=", "_ratio", "self", "...
Scale the WCS to a new pixel_scale. The 'retain' parameter [default value: True] controls whether or not to retain the original distortion solution in the CD matrix.
[ "Scale", "the", "WCS", "to", "a", "new", "pixel_scale", ".", "The", "retain", "parameter", "[", "default", "value", ":", "True", "]", "controls", "whether", "or", "not", "to", "retain", "the", "original", "distortion", "solution", "in", "the", "CD", "matri...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L542-L570
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.xy2rd
def xy2rd(self,pos): """ This method would apply the WCS keywords to a position to generate a new sky position. The algorithm comes directly from 'imgtools.xy2rd' translate (x,y) to (ra, dec) """ if self.ctype1.find('TAN') < 0 or self.ctype2.find('TAN') < 0: ...
python
def xy2rd(self,pos): """ This method would apply the WCS keywords to a position to generate a new sky position. The algorithm comes directly from 'imgtools.xy2rd' translate (x,y) to (ra, dec) """ if self.ctype1.find('TAN') < 0 or self.ctype2.find('TAN') < 0: ...
[ "def", "xy2rd", "(", "self", ",", "pos", ")", ":", "if", "self", ".", "ctype1", ".", "find", "(", "'TAN'", ")", "<", "0", "or", "self", ".", "ctype2", ".", "find", "(", "'TAN'", ")", "<", "0", ":", "print", "(", "'XY2RD only supported for TAN project...
This method would apply the WCS keywords to a position to generate a new sky position. The algorithm comes directly from 'imgtools.xy2rd' translate (x,y) to (ra, dec)
[ "This", "method", "would", "apply", "the", "WCS", "keywords", "to", "a", "position", "to", "generate", "a", "new", "sky", "position", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L572-L612
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.rd2xy
def rd2xy(self,skypos,hour=no): """ This method would use the WCS keywords to compute the XY position from a given RA/Dec tuple (in deg). NOTE: Investigate how to let this function accept arrays as well as single positions. WJH 27Mar03 """ if self.ctype1.find('T...
python
def rd2xy(self,skypos,hour=no): """ This method would use the WCS keywords to compute the XY position from a given RA/Dec tuple (in deg). NOTE: Investigate how to let this function accept arrays as well as single positions. WJH 27Mar03 """ if self.ctype1.find('T...
[ "def", "rd2xy", "(", "self", ",", "skypos", ",", "hour", "=", "no", ")", ":", "if", "self", ".", "ctype1", ".", "find", "(", "'TAN'", ")", "<", "0", "or", "self", ".", "ctype2", ".", "find", "(", "'TAN'", ")", "<", "0", ":", "print", "(", "'R...
This method would use the WCS keywords to compute the XY position from a given RA/Dec tuple (in deg). NOTE: Investigate how to let this function accept arrays as well as single positions. WJH 27Mar03
[ "This", "method", "would", "use", "the", "WCS", "keywords", "to", "compute", "the", "XY", "position", "from", "a", "given", "RA", "/", "Dec", "tuple", "(", "in", "deg", ")", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L615-L657
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.rotateCD
def rotateCD(self,orient): """ Rotates WCS CD matrix to new orientation given by 'orient' """ # Determine where member CRVAL position falls in ref frame # Find out whether this needs to be rotated to align with # reference frame. _delta = self.get_orient() - orient ...
python
def rotateCD(self,orient): """ Rotates WCS CD matrix to new orientation given by 'orient' """ # Determine where member CRVAL position falls in ref frame # Find out whether this needs to be rotated to align with # reference frame. _delta = self.get_orient() - orient ...
[ "def", "rotateCD", "(", "self", ",", "orient", ")", ":", "# Determine where member CRVAL position falls in ref frame", "# Find out whether this needs to be rotated to align with", "# reference frame.", "_delta", "=", "self", ".", "get_orient", "(", ")", "-", "orient", "if", ...
Rotates WCS CD matrix to new orientation given by 'orient'
[ "Rotates", "WCS", "CD", "matrix", "to", "new", "orientation", "given", "by", "orient" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L659-L679
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.write
def write(self,fitsname=None,wcs=None,archive=True,overwrite=False,quiet=True): """ Write out the values of the WCS keywords to the specified image. If it is a GEIS image and 'fitsname' has been provided, it will automatically make a multi-extension FITS copy of the GEIS...
python
def write(self,fitsname=None,wcs=None,archive=True,overwrite=False,quiet=True): """ Write out the values of the WCS keywords to the specified image. If it is a GEIS image and 'fitsname' has been provided, it will automatically make a multi-extension FITS copy of the GEIS...
[ "def", "write", "(", "self", ",", "fitsname", "=", "None", ",", "wcs", "=", "None", ",", "archive", "=", "True", ",", "overwrite", "=", "False", ",", "quiet", "=", "True", ")", ":", "## Start by making sure all derived values are in sync with CD matrix", "self",...
Write out the values of the WCS keywords to the specified image. If it is a GEIS image and 'fitsname' has been provided, it will automatically make a multi-extension FITS copy of the GEIS and update that file. Otherwise, it throw an Exception if the user attempts to directly upd...
[ "Write", "out", "the", "values", "of", "the", "WCS", "keywords", "to", "the", "specified", "image", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L756-L809
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.restore
def restore(self): """ Reset the active WCS keywords to values stored in the backup keywords. """ # If there are no backup keys, do nothing... if len(list(self.backup.keys())) == 0: return for key in self.backup.keys(): if key != 'WCSCDATE': ...
python
def restore(self): """ Reset the active WCS keywords to values stored in the backup keywords. """ # If there are no backup keys, do nothing... if len(list(self.backup.keys())) == 0: return for key in self.backup.keys(): if key != 'WCSCDATE': ...
[ "def", "restore", "(", "self", ")", ":", "# If there are no backup keys, do nothing...", "if", "len", "(", "list", "(", "self", ".", "backup", ".", "keys", "(", ")", ")", ")", "==", "0", ":", "return", "for", "key", "in", "self", ".", "backup", ".", "k...
Reset the active WCS keywords to values stored in the backup keywords.
[ "Reset", "the", "active", "WCS", "keywords", "to", "values", "stored", "in", "the", "backup", "keywords", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L811-L822
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.archive
def archive(self,prepend=None,overwrite=no,quiet=yes): """ Create backup copies of the WCS keywords with the given prepended string. If backup keywords are already present, only update them if 'overwrite' is set to 'yes', otherwise, do warn the user and do nothing. ...
python
def archive(self,prepend=None,overwrite=no,quiet=yes): """ Create backup copies of the WCS keywords with the given prepended string. If backup keywords are already present, only update them if 'overwrite' is set to 'yes', otherwise, do warn the user and do nothing. ...
[ "def", "archive", "(", "self", ",", "prepend", "=", "None", ",", "overwrite", "=", "no", ",", "quiet", "=", "yes", ")", ":", "# Verify that existing backup values are not overwritten accidentally.", "if", "len", "(", "list", "(", "self", ".", "backup", ".", "k...
Create backup copies of the WCS keywords with the given prepended string. If backup keywords are already present, only update them if 'overwrite' is set to 'yes', otherwise, do warn the user and do nothing. Set the WCSDATE at this time as well.
[ "Create", "backup", "copies", "of", "the", "WCS", "keywords", "with", "the", "given", "prepended", "string", ".", "If", "backup", "keywords", "are", "already", "present", "only", "update", "them", "if", "overwrite", "is", "set", "to", "yes", "otherwise", "do...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L824-L864
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.read_archive
def read_archive(self,header,prepend=None): """ Extract a copy of WCS keywords from an open file header, if they have already been created and remember the prefix used for those keywords. Otherwise, setup the current WCS keywords as the archive values. """ # S...
python
def read_archive(self,header,prepend=None): """ Extract a copy of WCS keywords from an open file header, if they have already been created and remember the prefix used for those keywords. Otherwise, setup the current WCS keywords as the archive values. """ # S...
[ "def", "read_archive", "(", "self", ",", "header", ",", "prepend", "=", "None", ")", ":", "# Start by looking for the any backup WCS keywords to", "# determine whether archived values are present and to set", "# the prefix used.", "_prefix", "=", "None", "_archive", "=", "Fal...
Extract a copy of WCS keywords from an open file header, if they have already been created and remember the prefix used for those keywords. Otherwise, setup the current WCS keywords as the archive values.
[ "Extract", "a", "copy", "of", "WCS", "keywords", "from", "an", "open", "file", "header", "if", "they", "have", "already", "been", "created", "and", "remember", "the", "prefix", "used", "for", "those", "keywords", ".", "Otherwise", "setup", "the", "current", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L866-L920
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.write_archive
def write_archive(self,fitsname=None,overwrite=no,quiet=yes): """ Saves a copy of the WCS keywords from the image header as new keywords with the user-supplied 'prepend' character(s) prepended to the old keyword names. If the file is a GEIS image and 'fitsname' is not None, ...
python
def write_archive(self,fitsname=None,overwrite=no,quiet=yes): """ Saves a copy of the WCS keywords from the image header as new keywords with the user-supplied 'prepend' character(s) prepended to the old keyword names. If the file is a GEIS image and 'fitsname' is not None, ...
[ "def", "write_archive", "(", "self", ",", "fitsname", "=", "None", ",", "overwrite", "=", "no", ",", "quiet", "=", "yes", ")", ":", "_fitsname", "=", "fitsname", "# Open image in update mode", "# Copying of GEIS images handled by 'openImage'.", "fimg", "=", "file...
Saves a copy of the WCS keywords from the image header as new keywords with the user-supplied 'prepend' character(s) prepended to the old keyword names. If the file is a GEIS image and 'fitsname' is not None, create a FITS copy and update that version; otherwise, raise ...
[ "Saves", "a", "copy", "of", "the", "WCS", "keywords", "from", "the", "image", "header", "as", "new", "keywords", "with", "the", "user", "-", "supplied", "prepend", "character", "(", "s", ")", "prepended", "to", "the", "old", "keyword", "names", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L922-L981
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.restoreWCS
def restoreWCS(self,prepend=None): """ Resets the WCS values to the original values stored in the backup keywords recorded in self.backup. """ # Open header for image image = self.rootname if prepend: _prepend = prepend elif self.prepend: _prepend = self.prep...
python
def restoreWCS(self,prepend=None): """ Resets the WCS values to the original values stored in the backup keywords recorded in self.backup. """ # Open header for image image = self.rootname if prepend: _prepend = prepend elif self.prepend: _prepend = self.prep...
[ "def", "restoreWCS", "(", "self", ",", "prepend", "=", "None", ")", ":", "# Open header for image", "image", "=", "self", ".", "rootname", "if", "prepend", ":", "_prepend", "=", "prepend", "elif", "self", ".", "prepend", ":", "_prepend", "=", "self", ".", ...
Resets the WCS values to the original values stored in the backup keywords recorded in self.backup.
[ "Resets", "the", "WCS", "values", "to", "the", "original", "values", "stored", "in", "the", "backup", "keywords", "recorded", "in", "self", ".", "backup", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L983-L1023
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.createReferenceWCS
def createReferenceWCS(self,refname,overwrite=yes): """ Write out the values of the WCS keywords to the NEW specified image 'fitsname'. """ hdu = self.createWcsHDU() # If refname already exists, delete it to make way for new file if os.path.exists(refname): ...
python
def createReferenceWCS(self,refname,overwrite=yes): """ Write out the values of the WCS keywords to the NEW specified image 'fitsname'. """ hdu = self.createWcsHDU() # If refname already exists, delete it to make way for new file if os.path.exists(refname): ...
[ "def", "createReferenceWCS", "(", "self", ",", "refname", ",", "overwrite", "=", "yes", ")", ":", "hdu", "=", "self", ".", "createWcsHDU", "(", ")", "# If refname already exists, delete it to make way for new file", "if", "os", ".", "path", ".", "exists", "(", "...
Write out the values of the WCS keywords to the NEW specified image 'fitsname'.
[ "Write", "out", "the", "values", "of", "the", "WCS", "keywords", "to", "the", "NEW", "specified", "image", "fitsname", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L1025-L1053
train
spacetelescope/stsci.tools
lib/stsci/tools/wcsutil.py
WCSObject.createWcsHDU
def createWcsHDU(self): """ Generate a WCS header object that can be used to populate a reference WCS HDU. """ hdu = fits.ImageHDU() hdu.header['EXTNAME'] = 'WCS' hdu.header['EXTVER'] = 1 # Now, update original image size information hdu.header['WCSAXE...
python
def createWcsHDU(self): """ Generate a WCS header object that can be used to populate a reference WCS HDU. """ hdu = fits.ImageHDU() hdu.header['EXTNAME'] = 'WCS' hdu.header['EXTVER'] = 1 # Now, update original image size information hdu.header['WCSAXE...
[ "def", "createWcsHDU", "(", "self", ")", ":", "hdu", "=", "fits", ".", "ImageHDU", "(", ")", "hdu", ".", "header", "[", "'EXTNAME'", "]", "=", "'WCS'", "hdu", ".", "header", "[", "'EXTVER'", "]", "=", "1", "# Now, update original image size information", "...
Generate a WCS header object that can be used to populate a reference WCS HDU.
[ "Generate", "a", "WCS", "header", "object", "that", "can", "be", "used", "to", "populate", "a", "reference", "WCS", "HDU", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L1055-L1076
train
3ll3d00d/vibe
backend/src/analyser/app.py
main
def main(args=None): """ The main routine. """ logger = cfg.configureLogger() for root, dirs, files in os.walk(cfg.dataDir): for dir in dirs: newDir = os.path.join(root, dir) try: os.removedirs(newDir) logger.info("Deleted empty dir " + str(new...
python
def main(args=None): """ The main routine. """ logger = cfg.configureLogger() for root, dirs, files in os.walk(cfg.dataDir): for dir in dirs: newDir = os.path.join(root, dir) try: os.removedirs(newDir) logger.info("Deleted empty dir " + str(new...
[ "def", "main", "(", "args", "=", "None", ")", ":", "logger", "=", "cfg", ".", "configureLogger", "(", ")", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "cfg", ".", "dataDir", ")", ":", "for", "dir", "in", "dirs", ":", ...
The main routine.
[ "The", "main", "routine", "." ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/app.py#L120-L219
train
fitnr/convertdate
convertdate/french_republican.py
leap
def leap(year, method=None): ''' Determine if this is a leap year in the FR calendar using one of three methods: 4, 100, 128 (every 4th years, every 4th or 400th but not 100th, every 4th but not 128th) ''' method = method or 'equinox' if year in (3, 7, 11): return True elif year < ...
python
def leap(year, method=None): ''' Determine if this is a leap year in the FR calendar using one of three methods: 4, 100, 128 (every 4th years, every 4th or 400th but not 100th, every 4th but not 128th) ''' method = method or 'equinox' if year in (3, 7, 11): return True elif year < ...
[ "def", "leap", "(", "year", ",", "method", "=", "None", ")", ":", "method", "=", "method", "or", "'equinox'", "if", "year", "in", "(", "3", ",", "7", ",", "11", ")", ":", "return", "True", "elif", "year", "<", "15", ":", "return", "False", "if", ...
Determine if this is a leap year in the FR calendar using one of three methods: 4, 100, 128 (every 4th years, every 4th or 400th but not 100th, every 4th but not 128th)
[ "Determine", "if", "this", "is", "a", "leap", "year", "in", "the", "FR", "calendar", "using", "one", "of", "three", "methods", ":", "4", "100", "128", "(", "every", "4th", "years", "every", "4th", "or", "400th", "but", "not", "100th", "every", "4th", ...
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L48-L78
train
fitnr/convertdate
convertdate/french_republican.py
premier_da_la_annee
def premier_da_la_annee(jd): '''Determine the year in the French revolutionary calendar in which a given Julian day falls. Returns Julian day number containing fall equinox (first day of the FR year)''' p = ephem.previous_fall_equinox(dublin.from_jd(jd)) previous = trunc(dublin.to_jd(p) - 0.5) + 0.5 ...
python
def premier_da_la_annee(jd): '''Determine the year in the French revolutionary calendar in which a given Julian day falls. Returns Julian day number containing fall equinox (first day of the FR year)''' p = ephem.previous_fall_equinox(dublin.from_jd(jd)) previous = trunc(dublin.to_jd(p) - 0.5) + 0.5 ...
[ "def", "premier_da_la_annee", "(", "jd", ")", ":", "p", "=", "ephem", ".", "previous_fall_equinox", "(", "dublin", ".", "from_jd", "(", "jd", ")", ")", "previous", "=", "trunc", "(", "dublin", ".", "to_jd", "(", "p", ")", "-", "0.5", ")", "+", "0.5",...
Determine the year in the French revolutionary calendar in which a given Julian day falls. Returns Julian day number containing fall equinox (first day of the FR year)
[ "Determine", "the", "year", "in", "the", "French", "revolutionary", "calendar", "in", "which", "a", "given", "Julian", "day", "falls", ".", "Returns", "Julian", "day", "number", "containing", "fall", "equinox", "(", "first", "day", "of", "the", "FR", "year",...
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L81-L95
train
fitnr/convertdate
convertdate/french_republican.py
to_jd
def to_jd(year, month, day, method=None): '''Obtain Julian day from a given French Revolutionary calendar date.''' method = method or 'equinox' if day < 1 or day > 30: raise ValueError("Invalid day for this calendar") if month > 13: raise ValueError("Invalid month for this calendar") ...
python
def to_jd(year, month, day, method=None): '''Obtain Julian day from a given French Revolutionary calendar date.''' method = method or 'equinox' if day < 1 or day > 30: raise ValueError("Invalid day for this calendar") if month > 13: raise ValueError("Invalid month for this calendar") ...
[ "def", "to_jd", "(", "year", ",", "month", ",", "day", ",", "method", "=", "None", ")", ":", "method", "=", "method", "or", "'equinox'", "if", "day", "<", "1", "or", "day", ">", "30", ":", "raise", "ValueError", "(", "\"Invalid day for this calendar\"", ...
Obtain Julian day from a given French Revolutionary calendar date.
[ "Obtain", "Julian", "day", "from", "a", "given", "French", "Revolutionary", "calendar", "date", "." ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L98-L115
train
fitnr/convertdate
convertdate/french_republican.py
_to_jd_schematic
def _to_jd_schematic(year, month, day, method): '''Calculate JD using various leap-year calculation methods''' y0, y1, y2, y3, y4, y5 = 0, 0, 0, 0, 0, 0 intercal_cycle_yrs, over_cycle_yrs, leap_suppression_yrs = None, None, None # Use the every-four-years method below year 16 (madler) or below 15 (ro...
python
def _to_jd_schematic(year, month, day, method): '''Calculate JD using various leap-year calculation methods''' y0, y1, y2, y3, y4, y5 = 0, 0, 0, 0, 0, 0 intercal_cycle_yrs, over_cycle_yrs, leap_suppression_yrs = None, None, None # Use the every-four-years method below year 16 (madler) or below 15 (ro...
[ "def", "_to_jd_schematic", "(", "year", ",", "month", ",", "day", ",", "method", ")", ":", "y0", ",", "y1", ",", "y2", ",", "y3", ",", "y4", ",", "y5", "=", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", "intercal_cycle_yrs", ",", "ov...
Calculate JD using various leap-year calculation methods
[ "Calculate", "JD", "using", "various", "leap", "-", "year", "calculation", "methods" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L118-L181
train
fitnr/convertdate
convertdate/french_republican.py
from_jd
def from_jd(jd, method=None): '''Calculate date in the French Revolutionary calendar from Julian day. The five or six "sansculottides" are considered a thirteenth month in the results of this function.''' method = method or 'equinox' if method == 'equinox': return _from_jd_equinox(jd) ...
python
def from_jd(jd, method=None): '''Calculate date in the French Revolutionary calendar from Julian day. The five or six "sansculottides" are considered a thirteenth month in the results of this function.''' method = method or 'equinox' if method == 'equinox': return _from_jd_equinox(jd) ...
[ "def", "from_jd", "(", "jd", ",", "method", "=", "None", ")", ":", "method", "=", "method", "or", "'equinox'", "if", "method", "==", "'equinox'", ":", "return", "_from_jd_equinox", "(", "jd", ")", "else", ":", "return", "_from_jd_schematic", "(", "jd", "...
Calculate date in the French Revolutionary calendar from Julian day. The five or six "sansculottides" are considered a thirteenth month in the results of this function.
[ "Calculate", "date", "in", "the", "French", "Revolutionary", "calendar", "from", "Julian", "day", ".", "The", "five", "or", "six", "sansculottides", "are", "considered", "a", "thirteenth", "month", "in", "the", "results", "of", "this", "function", "." ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L190-L201
train
fitnr/convertdate
convertdate/french_republican.py
_from_jd_schematic
def _from_jd_schematic(jd, method): '''Convert from JD using various leap-year calculation methods''' if jd < EPOCH: raise ValueError("Can't convert days before the French Revolution") # days since Epoch J = trunc(jd) + 0.5 - EPOCH y0, y1, y2, y3, y4, y5 = 0, 0, 0, 0, 0, 0 intercal_cyc...
python
def _from_jd_schematic(jd, method): '''Convert from JD using various leap-year calculation methods''' if jd < EPOCH: raise ValueError("Can't convert days before the French Revolution") # days since Epoch J = trunc(jd) + 0.5 - EPOCH y0, y1, y2, y3, y4, y5 = 0, 0, 0, 0, 0, 0 intercal_cyc...
[ "def", "_from_jd_schematic", "(", "jd", ",", "method", ")", ":", "if", "jd", "<", "EPOCH", ":", "raise", "ValueError", "(", "\"Can't convert days before the French Revolution\"", ")", "# days since Epoch", "J", "=", "trunc", "(", "jd", ")", "+", "0.5", "-", "E...
Convert from JD using various leap-year calculation methods
[ "Convert", "from", "JD", "using", "various", "leap", "-", "year", "calculation", "methods" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L204-L288
train
fitnr/convertdate
convertdate/french_republican.py
_from_jd_equinox
def _from_jd_equinox(jd): '''Calculate the FR day using the equinox as day 1''' jd = trunc(jd) + 0.5 equinoxe = premier_da_la_annee(jd) an = gregorian.from_jd(equinoxe)[0] - YEAR_EPOCH mois = trunc((jd - equinoxe) / 30.) + 1 jour = int((jd - equinoxe) % 30) + 1 return (an, mois, jour)
python
def _from_jd_equinox(jd): '''Calculate the FR day using the equinox as day 1''' jd = trunc(jd) + 0.5 equinoxe = premier_da_la_annee(jd) an = gregorian.from_jd(equinoxe)[0] - YEAR_EPOCH mois = trunc((jd - equinoxe) / 30.) + 1 jour = int((jd - equinoxe) % 30) + 1 return (an, mois, jour)
[ "def", "_from_jd_equinox", "(", "jd", ")", ":", "jd", "=", "trunc", "(", "jd", ")", "+", "0.5", "equinoxe", "=", "premier_da_la_annee", "(", "jd", ")", "an", "=", "gregorian", ".", "from_jd", "(", "equinoxe", ")", "[", "0", "]", "-", "YEAR_EPOCH", "m...
Calculate the FR day using the equinox as day 1
[ "Calculate", "the", "FR", "day", "using", "the", "equinox", "as", "day", "1" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L291-L300
train
fitnr/convertdate
convertdate/indian_civil.py
to_jd
def to_jd(year, month, day): '''Obtain Julian day for Indian Civil date''' gyear = year + 78 leap = isleap(gyear) # // Is this a leap year ? # 22 - leap = 21 if leap, 22 non-leap start = gregorian.to_jd(gyear, 3, 22 - leap) if leap: Caitra = 31 else: Caitra = 30 if...
python
def to_jd(year, month, day): '''Obtain Julian day for Indian Civil date''' gyear = year + 78 leap = isleap(gyear) # // Is this a leap year ? # 22 - leap = 21 if leap, 22 non-leap start = gregorian.to_jd(gyear, 3, 22 - leap) if leap: Caitra = 31 else: Caitra = 30 if...
[ "def", "to_jd", "(", "year", ",", "month", ",", "day", ")", ":", "gyear", "=", "year", "+", "78", "leap", "=", "isleap", "(", "gyear", ")", "# // Is this a leap year ?", "# 22 - leap = 21 if leap, 22 non-leap", "start", "=", "gregorian", ".", "to_jd", "(", "...
Obtain Julian day for Indian Civil date
[ "Obtain", "Julian", "day", "for", "Indian", "Civil", "date" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/indian_civil.py#L47-L74
train
fitnr/convertdate
convertdate/indian_civil.py
from_jd
def from_jd(jd): '''Calculate Indian Civil date from Julian day Offset in years from Saka era to Gregorian epoch''' start = 80 # Day offset between Saka and Gregorian jd = trunc(jd) + 0.5 greg = gregorian.from_jd(jd) # Gregorian date for Julian day leap = isleap(greg[0]) # Is this a leap...
python
def from_jd(jd): '''Calculate Indian Civil date from Julian day Offset in years from Saka era to Gregorian epoch''' start = 80 # Day offset between Saka and Gregorian jd = trunc(jd) + 0.5 greg = gregorian.from_jd(jd) # Gregorian date for Julian day leap = isleap(greg[0]) # Is this a leap...
[ "def", "from_jd", "(", "jd", ")", ":", "start", "=", "80", "# Day offset between Saka and Gregorian", "jd", "=", "trunc", "(", "jd", ")", "+", "0.5", "greg", "=", "gregorian", ".", "from_jd", "(", "jd", ")", "# Gregorian date for Julian day", "leap", "=", "i...
Calculate Indian Civil date from Julian day Offset in years from Saka era to Gregorian epoch
[ "Calculate", "Indian", "Civil", "date", "from", "Julian", "day", "Offset", "in", "years", "from", "Saka", "era", "to", "Gregorian", "epoch" ]
e920f168a87f99183b0aa7290d6c3af222582d43
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/indian_civil.py#L77-L117
train
ionelmc/python-aspectlib
src/aspectlib/debug.py
format_stack
def format_stack(skip=0, length=6, _sep=os.path.sep): """ Returns a one-line string with the current callstack. """ return ' < '.join("%s:%s:%s" % ( '/'.join(f.f_code.co_filename.split(_sep)[-2:]), f.f_lineno, f.f_code.co_name ) for f in islice(frame_iterator(sys._getframe(1 ...
python
def format_stack(skip=0, length=6, _sep=os.path.sep): """ Returns a one-line string with the current callstack. """ return ' < '.join("%s:%s:%s" % ( '/'.join(f.f_code.co_filename.split(_sep)[-2:]), f.f_lineno, f.f_code.co_name ) for f in islice(frame_iterator(sys._getframe(1 ...
[ "def", "format_stack", "(", "skip", "=", "0", ",", "length", "=", "6", ",", "_sep", "=", "os", ".", "path", ".", "sep", ")", ":", "return", "' < '", ".", "join", "(", "\"%s:%s:%s\"", "%", "(", "'/'", ".", "join", "(", "f", ".", "f_code", ".", "...
Returns a one-line string with the current callstack.
[ "Returns", "a", "one", "-", "line", "string", "with", "the", "current", "callstack", "." ]
7dba7651ab76160b9ce66c9c11e770f7844e95ec
https://github.com/ionelmc/python-aspectlib/blob/7dba7651ab76160b9ce66c9c11e770f7844e95ec/src/aspectlib/debug.py#L27-L35
train
ionelmc/python-aspectlib
src/aspectlib/debug.py
log
def log(func=None, stacktrace=10, stacktrace_align=60, attributes=(), module=True, call=True, call_args=True, call_args_repr=repr, result=True, exception=True, exception_repr=repr, result_repr=strip_non_ascii, use_logging='C...
python
def log(func=None, stacktrace=10, stacktrace_align=60, attributes=(), module=True, call=True, call_args=True, call_args_repr=repr, result=True, exception=True, exception_repr=repr, result_repr=strip_non_ascii, use_logging='C...
[ "def", "log", "(", "func", "=", "None", ",", "stacktrace", "=", "10", ",", "stacktrace_align", "=", "60", ",", "attributes", "=", "(", ")", ",", "module", "=", "True", ",", "call", "=", "True", ",", "call_args", "=", "True", ",", "call_args_repr", "=...
Decorates `func` to have logging. Args func (function): Function to decorate. If missing log returns a partial which you can use as a decorator. stacktrace (int): Number of frames to show. stacktrace_align (int): Column to align the framelist to. ...
[ "Decorates", "func", "to", "have", "logging", "." ]
7dba7651ab76160b9ce66c9c11e770f7844e95ec
https://github.com/ionelmc/python-aspectlib/blob/7dba7651ab76160b9ce66c9c11e770f7844e95ec/src/aspectlib/debug.py#L48-L233
train
3ll3d00d/vibe
backend/src/recorder/app.py
wireHandlers
def wireHandlers(cfg): """ If the device is configured to run against a remote server, ping that device on a scheduled basis with our current state. :param cfg: the config object. :return: """ logger = logging.getLogger('recorder') httpPoster = cfg.handlers.get('remote') csvLogger = ...
python
def wireHandlers(cfg): """ If the device is configured to run against a remote server, ping that device on a scheduled basis with our current state. :param cfg: the config object. :return: """ logger = logging.getLogger('recorder') httpPoster = cfg.handlers.get('remote') csvLogger = ...
[ "def", "wireHandlers", "(", "cfg", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "'recorder'", ")", "httpPoster", "=", "cfg", ".", "handlers", ".", "get", "(", "'remote'", ")", "csvLogger", "=", "cfg", ".", "handlers", ".", "get", "(", "'l...
If the device is configured to run against a remote server, ping that device on a scheduled basis with our current state. :param cfg: the config object. :return:
[ "If", "the", "device", "is", "configured", "to", "run", "against", "a", "remote", "server", "ping", "that", "device", "on", "a", "scheduled", "basis", "with", "our", "current", "state", ".", ":", "param", "cfg", ":", "the", "config", "object", ".", ":", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/app.py#L55-L83
train
3ll3d00d/vibe
backend/src/recorder/app.py
main
def main(args=None): """ The main routine. """ cfg.configureLogger() wireHandlers(cfg) # get config from a flask standard place not our config yml app.run(debug=cfg.runInDebug(), host='0.0.0.0', port=cfg.getPort())
python
def main(args=None): """ The main routine. """ cfg.configureLogger() wireHandlers(cfg) # get config from a flask standard place not our config yml app.run(debug=cfg.runInDebug(), host='0.0.0.0', port=cfg.getPort())
[ "def", "main", "(", "args", "=", "None", ")", ":", "cfg", ".", "configureLogger", "(", ")", "wireHandlers", "(", "cfg", ")", "# get config from a flask standard place not our config yml", "app", ".", "run", "(", "debug", "=", "cfg", ".", "runInDebug", "(", ")"...
The main routine.
[ "The", "main", "routine", "." ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/app.py#L86-L91
train
3ll3d00d/vibe
backend/src/recorder/resources/measurements.py
Measurements.get
def get(self, deviceId): """ lists all known active measurements. """ measurementsByName = self.measurements.get(deviceId) if measurementsByName is None: return [] else: return list(measurementsByName.values())
python
def get(self, deviceId): """ lists all known active measurements. """ measurementsByName = self.measurements.get(deviceId) if measurementsByName is None: return [] else: return list(measurementsByName.values())
[ "def", "get", "(", "self", ",", "deviceId", ")", ":", "measurementsByName", "=", "self", ".", "measurements", ".", "get", "(", "deviceId", ")", "if", "measurementsByName", "is", "None", ":", "return", "[", "]", "else", ":", "return", "list", "(", "measur...
lists all known active measurements.
[ "lists", "all", "known", "active", "measurements", "." ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L25-L33
train
3ll3d00d/vibe
backend/src/recorder/resources/measurements.py
Measurement.get
def get(self, deviceId, measurementId): """ details the specific measurement. """ record = self.measurements.get(deviceId) if record is not None: return record.get(measurementId) return None
python
def get(self, deviceId, measurementId): """ details the specific measurement. """ record = self.measurements.get(deviceId) if record is not None: return record.get(measurementId) return None
[ "def", "get", "(", "self", ",", "deviceId", ",", "measurementId", ")", ":", "record", "=", "self", ".", "measurements", ".", "get", "(", "deviceId", ")", "if", "record", "is", "not", "None", ":", "return", "record", ".", "get", "(", "measurementId", ")...
details the specific measurement.
[ "details", "the", "specific", "measurement", "." ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L42-L49
train
3ll3d00d/vibe
backend/src/recorder/resources/measurements.py
Measurement.put
def put(self, deviceId, measurementId): """ Schedules a new measurement at the specified time. :param deviceId: the device to measure. :param measurementId: the name of the measurement. :return: 200 if it was scheduled, 400 if the device is busy, 500 if the device is bad. ...
python
def put(self, deviceId, measurementId): """ Schedules a new measurement at the specified time. :param deviceId: the device to measure. :param measurementId: the name of the measurement. :return: 200 if it was scheduled, 400 if the device is busy, 500 if the device is bad. ...
[ "def", "put", "(", "self", ",", "deviceId", ",", "measurementId", ")", ":", "record", "=", "self", ".", "measurements", ".", "get", "(", "deviceId", ")", "if", "record", "is", "not", "None", ":", "measurement", "=", "record", ".", "get", "(", "measurem...
Schedules a new measurement at the specified time. :param deviceId: the device to measure. :param measurementId: the name of the measurement. :return: 200 if it was scheduled, 400 if the device is busy, 500 if the device is bad.
[ "Schedules", "a", "new", "measurement", "at", "the", "specified", "time", ".", ":", "param", "deviceId", ":", "the", "device", "to", "measure", ".", ":", "param", "measurementId", ":", "the", "name", "of", "the", "measurement", ".", ":", "return", ":", "...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L52-L81
train
3ll3d00d/vibe
backend/src/recorder/resources/measurements.py
Measurement.delete
def delete(self, deviceId, measurementId): """ Deletes a stored measurement. :param deviceId: the device to measure. :param measurementId: the name of the measurement. :return: 200 if it was deleted, 400 if no such measurement (or device). """ record = self.measur...
python
def delete(self, deviceId, measurementId): """ Deletes a stored measurement. :param deviceId: the device to measure. :param measurementId: the name of the measurement. :return: 200 if it was deleted, 400 if no such measurement (or device). """ record = self.measur...
[ "def", "delete", "(", "self", ",", "deviceId", ",", "measurementId", ")", ":", "record", "=", "self", ".", "measurements", ".", "get", "(", "deviceId", ")", "if", "record", "is", "not", "None", ":", "popped", "=", "record", ".", "pop", "(", "measuremen...
Deletes a stored measurement. :param deviceId: the device to measure. :param measurementId: the name of the measurement. :return: 200 if it was deleted, 400 if no such measurement (or device).
[ "Deletes", "a", "stored", "measurement", ".", ":", "param", "deviceId", ":", "the", "device", "to", "measure", ".", ":", "param", "measurementId", ":", "the", "name", "of", "the", "measurement", ".", ":", "return", ":", "200", "if", "it", "was", "deleted...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L84-L95
train
3ll3d00d/vibe
backend/src/recorder/resources/measurements.py
AbortMeasurement.get
def get(self, deviceId, measurementId): """ signals a stop for the given measurement. :param deviceId: the device to measure. :param measurementId: the name of the measurement. :return: 200 if stop is signalled, 400 if it doesn't exist or is not running. """ recor...
python
def get(self, deviceId, measurementId): """ signals a stop for the given measurement. :param deviceId: the device to measure. :param measurementId: the name of the measurement. :return: 200 if stop is signalled, 400 if it doesn't exist or is not running. """ recor...
[ "def", "get", "(", "self", ",", "deviceId", ",", "measurementId", ")", ":", "record", "=", "self", ".", "measurements", ".", "get", "(", "deviceId", ")", "if", "record", "is", "not", "None", ":", "measurement", "=", "record", ".", "get", "(", "measurem...
signals a stop for the given measurement. :param deviceId: the device to measure. :param measurementId: the name of the measurement. :return: 200 if stop is signalled, 400 if it doesn't exist or is not running.
[ "signals", "a", "stop", "for", "the", "given", "measurement", ".", ":", "param", "deviceId", ":", "the", "device", "to", "measure", ".", ":", "param", "measurementId", ":", "the", "name", "of", "the", "measurement", ".", ":", "return", ":", "200", "if", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L104-L120
train
3ll3d00d/vibe
backend/src/recorder/resources/measurements.py
ScheduledMeasurement.schedule
def schedule(self, duration, at=None, delay=None, callback=None): """ schedules the measurement (to execute asynchronously). :param duration: how long to run for. :param at: the time to start at. :param delay: the time to wait til starting (use at or delay). :param callba...
python
def schedule(self, duration, at=None, delay=None, callback=None): """ schedules the measurement (to execute asynchronously). :param duration: how long to run for. :param at: the time to start at. :param delay: the time to wait til starting (use at or delay). :param callba...
[ "def", "schedule", "(", "self", ",", "duration", ",", "at", "=", "None", ",", "delay", "=", "None", ",", "callback", "=", "None", ")", ":", "delay", "=", "self", ".", "calculateDelay", "(", "at", ",", "delay", ")", "self", ".", "callback", "=", "ca...
schedules the measurement (to execute asynchronously). :param duration: how long to run for. :param at: the time to start at. :param delay: the time to wait til starting (use at or delay). :param callback: a callback. :return: nothing.
[ "schedules", "the", "measurement", "(", "to", "execute", "asynchronously", ")", ".", ":", "param", "duration", ":", "how", "long", "to", "run", "for", ".", ":", "param", "at", ":", "the", "time", "to", "start", "at", ".", ":", "param", "delay", ":", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L148-L161
train
3ll3d00d/vibe
backend/src/recorder/resources/measurements.py
ScheduledMeasurement.execute
def execute(self, duration): """ Executes the measurement, recording the event status. :param duration: the time to run for. :return: nothing. """ self.statuses.append({'name': ScheduledMeasurementStatus.RUNNING.name, 'time': datetime.utcnow()}) try: s...
python
def execute(self, duration): """ Executes the measurement, recording the event status. :param duration: the time to run for. :return: nothing. """ self.statuses.append({'name': ScheduledMeasurementStatus.RUNNING.name, 'time': datetime.utcnow()}) try: s...
[ "def", "execute", "(", "self", ",", "duration", ")", ":", "self", ".", "statuses", ".", "append", "(", "{", "'name'", ":", "ScheduledMeasurementStatus", ".", "RUNNING", ".", "name", ",", "'time'", ":", "datetime", ".", "utcnow", "(", ")", "}", ")", "tr...
Executes the measurement, recording the event status. :param duration: the time to run for. :return: nothing.
[ "Executes", "the", "measurement", "recording", "the", "event", "status", ".", ":", "param", "duration", ":", "the", "time", "to", "run", "for", ".", ":", "return", ":", "nothing", "." ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L163-L183
train
3ll3d00d/vibe
backend/src/recorder/resources/measurements.py
ScheduledMeasurement.calculateDelay
def calculateDelay(self, at, delay): """ Creates the delay from now til the specified start time, uses "at" if available. :param at: the start time in %a %b %d %H:%M:%S %Y format. :param delay: the delay from now til start. :return: the delay. """ if at is not Non...
python
def calculateDelay(self, at, delay): """ Creates the delay from now til the specified start time, uses "at" if available. :param at: the start time in %a %b %d %H:%M:%S %Y format. :param delay: the delay from now til start. :return: the delay. """ if at is not Non...
[ "def", "calculateDelay", "(", "self", ",", "at", ",", "delay", ")", ":", "if", "at", "is", "not", "None", ":", "return", "max", "(", "(", "datetime", ".", "strptime", "(", "at", ",", "DATETIME_FORMAT", ")", "-", "datetime", ".", "utcnow", "(", ")", ...
Creates the delay from now til the specified start time, uses "at" if available. :param at: the start time in %a %b %d %H:%M:%S %Y format. :param delay: the delay from now til start. :return: the delay.
[ "Creates", "the", "delay", "from", "now", "til", "the", "specified", "start", "time", "uses", "at", "if", "available", ".", ":", "param", "at", ":", "the", "start", "time", "in", "%a", "%b", "%d", "%H", ":", "%M", ":", "%S", "%Y", "format", ".", ":...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L185-L197
train
spacetelescope/stsci.tools
lib/stsci/tools/mputil.py
launch_and_wait
def launch_and_wait(mp_proc_list, pool_size): """ Given a list of multiprocessing.Process objects which have not yet been started, this function launches them and blocks until the last finishes. This makes sure that only <pool_size> processes are ever working at any one time (this number does not inclu...
python
def launch_and_wait(mp_proc_list, pool_size): """ Given a list of multiprocessing.Process objects which have not yet been started, this function launches them and blocks until the last finishes. This makes sure that only <pool_size> processes are ever working at any one time (this number does not inclu...
[ "def", "launch_and_wait", "(", "mp_proc_list", ",", "pool_size", ")", ":", "# Sanity check", "if", "len", "(", "mp_proc_list", ")", "<", "1", ":", "return", "# Create or own list with easy state watching", "procs", "=", "[", "]", "for", "p", "in", "mp_proc_list", ...
Given a list of multiprocessing.Process objects which have not yet been started, this function launches them and blocks until the last finishes. This makes sure that only <pool_size> processes are ever working at any one time (this number does not include the main process which called this function, si...
[ "Given", "a", "list", "of", "multiprocessing", ".", "Process", "objects", "which", "have", "not", "yet", "been", "started", "this", "function", "launches", "them", "and", "blocks", "until", "the", "last", "finishes", ".", "This", "makes", "sure", "that", "on...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/mputil.py#L36-L103
train
spacetelescope/stsci.tools
lib/stsci/tools/mputil.py
best_tile_layout
def best_tile_layout(pool_size): """ Determine and return the best layout of "tiles" for fastest overall parallel processing of a rectangular image broken up into N smaller equally-sized rectangular tiles, given as input the number of processes/chunks which can be run/worked at the same time (pool_size)...
python
def best_tile_layout(pool_size): """ Determine and return the best layout of "tiles" for fastest overall parallel processing of a rectangular image broken up into N smaller equally-sized rectangular tiles, given as input the number of processes/chunks which can be run/worked at the same time (pool_size)...
[ "def", "best_tile_layout", "(", "pool_size", ")", ":", "# Easy answer sanity-checks", "if", "pool_size", "<", "2", ":", "return", "(", "1", ",", "1", ")", "# Next, use a small mapping of hard-coded results. While we agree", "# that many of these are unlikely pool_size values, ...
Determine and return the best layout of "tiles" for fastest overall parallel processing of a rectangular image broken up into N smaller equally-sized rectangular tiles, given as input the number of processes/chunks which can be run/worked at the same time (pool_size). This attempts to return a layout w...
[ "Determine", "and", "return", "the", "best", "layout", "of", "tiles", "for", "fastest", "overall", "parallel", "processing", "of", "a", "rectangular", "image", "broken", "up", "into", "N", "smaller", "equally", "-", "sized", "rectangular", "tiles", "given", "a...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/mputil.py#L107-L160
train
3ll3d00d/vibe
backend/src/core/reactor.py
Reactor._accept
def _accept(self): """ Work loop runs forever (or until running is False) :return: """ logger.warning("Reactor " + self._name + " is starting") while self.running: try: self._completeTask() except: logger.exception("...
python
def _accept(self): """ Work loop runs forever (or until running is False) :return: """ logger.warning("Reactor " + self._name + " is starting") while self.running: try: self._completeTask() except: logger.exception("...
[ "def", "_accept", "(", "self", ")", ":", "logger", ".", "warning", "(", "\"Reactor \"", "+", "self", ".", "_name", "+", "\" is starting\"", ")", "while", "self", ".", "running", ":", "try", ":", "self", ".", "_completeTask", "(", ")", "except", ":", "l...
Work loop runs forever (or until running is False) :return:
[ "Work", "loop", "runs", "forever", "(", "or", "until", "running", "is", "False", ")", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/reactor.py#L23-L34
train
3ll3d00d/vibe
backend/src/core/reactor.py
Reactor.offer
def offer(self, requestType, *args): """ public interface to the reactor. :param requestType: :param args: :return: """ if self._funcsByRequest.get(requestType) is not None: self._workQueue.put((requestType, list(*args))) else: logg...
python
def offer(self, requestType, *args): """ public interface to the reactor. :param requestType: :param args: :return: """ if self._funcsByRequest.get(requestType) is not None: self._workQueue.put((requestType, list(*args))) else: logg...
[ "def", "offer", "(", "self", ",", "requestType", ",", "*", "args", ")", ":", "if", "self", ".", "_funcsByRequest", ".", "get", "(", "requestType", ")", "is", "not", "None", ":", "self", ".", "_workQueue", ".", "put", "(", "(", "requestType", ",", "li...
public interface to the reactor. :param requestType: :param args: :return:
[ "public", "interface", "to", "the", "reactor", ".", ":", "param", "requestType", ":", ":", "param", "args", ":", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/reactor.py#L58-L68
train
spacetelescope/stsci.tools
lib/stsci/tools/teal_bttn.py
TealActionParButton.clicked
def clicked(self): """ Called when this button is clicked. Execute code from .cfgspc """ try: from . import teal except: teal = None try: # start drilling down into the tpo to get the code tealGui = self._mainGuiObj tealGui.show...
python
def clicked(self): """ Called when this button is clicked. Execute code from .cfgspc """ try: from . import teal except: teal = None try: # start drilling down into the tpo to get the code tealGui = self._mainGuiObj tealGui.show...
[ "def", "clicked", "(", "self", ")", ":", "try", ":", "from", ".", "import", "teal", "except", ":", "teal", "=", "None", "try", ":", "# start drilling down into the tpo to get the code", "tealGui", "=", "self", ".", "_mainGuiObj", "tealGui", ".", "showStatus", ...
Called when this button is clicked. Execute code from .cfgspc
[ "Called", "when", "this", "button", "is", "clicked", ".", "Execute", "code", "from", ".", "cfgspc" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal_bttn.py#L31-L70
train
spacetelescope/stsci.tools
lib/stsci/tools/for2to3.py
ndarr2str
def ndarr2str(arr, encoding='ascii'): """ This is used to ensure that the return value of arr.tostring() is actually a string. This will prevent lots of if-checks in calling code. As of numpy v1.6.1 (in Python 3.2.3), the tostring() function still returns type 'bytes', not 'str' as it advertises. """ ...
python
def ndarr2str(arr, encoding='ascii'): """ This is used to ensure that the return value of arr.tostring() is actually a string. This will prevent lots of if-checks in calling code. As of numpy v1.6.1 (in Python 3.2.3), the tostring() function still returns type 'bytes', not 'str' as it advertises. """ ...
[ "def", "ndarr2str", "(", "arr", ",", "encoding", "=", "'ascii'", ")", ":", "# be fast, don't check - just assume 'arr' is a numpy array - the tostring", "# call will fail anyway if not", "retval", "=", "arr", ".", "tostring", "(", ")", "# would rather check \"if isinstance(retv...
This is used to ensure that the return value of arr.tostring() is actually a string. This will prevent lots of if-checks in calling code. As of numpy v1.6.1 (in Python 3.2.3), the tostring() function still returns type 'bytes', not 'str' as it advertises.
[ "This", "is", "used", "to", "ensure", "that", "the", "return", "value", "of", "arr", ".", "tostring", "()", "is", "actually", "a", "string", ".", "This", "will", "prevent", "lots", "of", "if", "-", "checks", "in", "calling", "code", ".", "As", "of", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/for2to3.py#L15-L28
train
spacetelescope/stsci.tools
lib/stsci/tools/for2to3.py
ndarr2bytes
def ndarr2bytes(arr, encoding='ascii'): """ This is used to ensure that the return value of arr.tostring() is actually a *bytes* array in PY3K. See notes in ndarr2str above. Even though we consider it a bug that numpy's tostring() function returns a bytes array in PY3K, there are actually many instanc...
python
def ndarr2bytes(arr, encoding='ascii'): """ This is used to ensure that the return value of arr.tostring() is actually a *bytes* array in PY3K. See notes in ndarr2str above. Even though we consider it a bug that numpy's tostring() function returns a bytes array in PY3K, there are actually many instanc...
[ "def", "ndarr2bytes", "(", "arr", ",", "encoding", "=", "'ascii'", ")", ":", "# be fast, don't check - just assume 'arr' is a numpy array - the tostring", "# call will fail anyway if not", "retval", "=", "arr", ".", "tostring", "(", ")", "# would rather check \"if not isinstanc...
This is used to ensure that the return value of arr.tostring() is actually a *bytes* array in PY3K. See notes in ndarr2str above. Even though we consider it a bug that numpy's tostring() function returns a bytes array in PY3K, there are actually many instances where that is what we want - bytes, not u...
[ "This", "is", "used", "to", "ensure", "that", "the", "return", "value", "of", "arr", ".", "tostring", "()", "is", "actually", "a", "*", "bytes", "*", "array", "in", "PY3K", ".", "See", "notes", "in", "ndarr2str", "above", ".", "Even", "though", "we", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/for2to3.py#L31-L50
train
spacetelescope/stsci.tools
lib/stsci/tools/for2to3.py
tobytes
def tobytes(s, encoding='ascii'): """ Convert string s to the 'bytes' type, in all Pythons, even back before Python 2.6. What 'str' means varies by PY3K or not. In Pythons before 3.0, this is technically the same as the str type in terms of the character data in memory. """ # NOTE: after we abandon...
python
def tobytes(s, encoding='ascii'): """ Convert string s to the 'bytes' type, in all Pythons, even back before Python 2.6. What 'str' means varies by PY3K or not. In Pythons before 3.0, this is technically the same as the str type in terms of the character data in memory. """ # NOTE: after we abandon...
[ "def", "tobytes", "(", "s", ",", "encoding", "=", "'ascii'", ")", ":", "# NOTE: after we abandon 2.5, we might simply instead use \"bytes(s)\"", "# NOTE: after we abandon all 2.*, del this and prepend byte strings with 'b'", "if", "PY3K", ":", "if", "isinstance", "(", "s", ",",...
Convert string s to the 'bytes' type, in all Pythons, even back before Python 2.6. What 'str' means varies by PY3K or not. In Pythons before 3.0, this is technically the same as the str type in terms of the character data in memory.
[ "Convert", "string", "s", "to", "the", "bytes", "type", "in", "all", "Pythons", "even", "back", "before", "Python", "2", ".", "6", ".", "What", "str", "means", "varies", "by", "PY3K", "or", "not", ".", "In", "Pythons", "before", "3", ".", "0", "this"...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/for2to3.py#L53-L71
train
spacetelescope/stsci.tools
lib/stsci/tools/for2to3.py
tostr
def tostr(s, encoding='ascii'): """ Convert string-like-thing s to the 'str' type, in all Pythons, even back before Python 2.6. What 'str' means varies by PY3K or not. In Pythons before 3.0, str and bytes are the same type. In Python 3+, this may require a decoding step. """ if PY3K: if isi...
python
def tostr(s, encoding='ascii'): """ Convert string-like-thing s to the 'str' type, in all Pythons, even back before Python 2.6. What 'str' means varies by PY3K or not. In Pythons before 3.0, str and bytes are the same type. In Python 3+, this may require a decoding step. """ if PY3K: if isi...
[ "def", "tostr", "(", "s", ",", "encoding", "=", "'ascii'", ")", ":", "if", "PY3K", ":", "if", "isinstance", "(", "s", ",", "str", ")", ":", "# str == unicode in PY3K", "return", "s", "else", ":", "# s is type bytes", "return", "s", ".", "decode", "(", ...
Convert string-like-thing s to the 'str' type, in all Pythons, even back before Python 2.6. What 'str' means varies by PY3K or not. In Pythons before 3.0, str and bytes are the same type. In Python 3+, this may require a decoding step.
[ "Convert", "string", "-", "like", "-", "thing", "s", "to", "the", "str", "type", "in", "all", "Pythons", "even", "back", "before", "Python", "2", ".", "6", ".", "What", "str", "means", "varies", "by", "PY3K", "or", "not", ".", "In", "Pythons", "befor...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/for2to3.py#L73-L89
train
ionelmc/python-aspectlib
src/aspectlib/contrib.py
retry
def retry(func=None, retries=5, backoff=None, exceptions=(IOError, OSError, EOFError), cleanup=None, sleep=time.sleep): """ Decorator that retries the call ``retries`` times if ``func`` raises ``exceptions``. Can use a ``backoff`` function to sleep till next retry. Example:: >>> should_fail = ...
python
def retry(func=None, retries=5, backoff=None, exceptions=(IOError, OSError, EOFError), cleanup=None, sleep=time.sleep): """ Decorator that retries the call ``retries`` times if ``func`` raises ``exceptions``. Can use a ``backoff`` function to sleep till next retry. Example:: >>> should_fail = ...
[ "def", "retry", "(", "func", "=", "None", ",", "retries", "=", "5", ",", "backoff", "=", "None", ",", "exceptions", "=", "(", "IOError", ",", "OSError", ",", "EOFError", ")", ",", "cleanup", "=", "None", ",", "sleep", "=", "time", ".", "sleep", ")"...
Decorator that retries the call ``retries`` times if ``func`` raises ``exceptions``. Can use a ``backoff`` function to sleep till next retry. Example:: >>> should_fail = lambda foo=[1,2,3]: foo and foo.pop() >>> @retry ... def flaky_func(): ... if should_fail(): ......
[ "Decorator", "that", "retries", "the", "call", "retries", "times", "if", "func", "raises", "exceptions", ".", "Can", "use", "a", "backoff", "function", "to", "sleep", "till", "next", "retry", "." ]
7dba7651ab76160b9ce66c9c11e770f7844e95ec
https://github.com/ionelmc/python-aspectlib/blob/7dba7651ab76160b9ce66c9c11e770f7844e95ec/src/aspectlib/contrib.py#L9-L60
train
3ll3d00d/vibe
backend/src/analyser/common/uploadcontroller.py
UploadController.loadSignal
def loadSignal(self, name, start=None, end=None): """ Loads the named entry from the upload cache as a signal. :param name: the name. :param start: the time to start from in HH:mm:ss.SSS format :param end: the time to end at in HH:mm:ss.SSS format. :return: the signal if ...
python
def loadSignal(self, name, start=None, end=None): """ Loads the named entry from the upload cache as a signal. :param name: the name. :param start: the time to start from in HH:mm:ss.SSS format :param end: the time to end at in HH:mm:ss.SSS format. :return: the signal if ...
[ "def", "loadSignal", "(", "self", ",", "name", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "entry", "=", "self", ".", "_getCacheEntry", "(", "name", ")", "if", "entry", "is", "not", "None", ":", "from", "analyser", ".", "common", ...
Loads the named entry from the upload cache as a signal. :param name: the name. :param start: the time to start from in HH:mm:ss.SSS format :param end: the time to end at in HH:mm:ss.SSS format. :return: the signal if the named upload exists.
[ "Loads", "the", "named", "entry", "from", "the", "upload", "cache", "as", "a", "signal", ".", ":", "param", "name", ":", "the", "name", ".", ":", "param", "start", ":", "the", "time", "to", "start", "from", "in", "HH", ":", "mm", ":", "ss", ".", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L41-L54
train
3ll3d00d/vibe
backend/src/analyser/common/uploadcontroller.py
UploadController._getCacheEntry
def _getCacheEntry(self, name): """ :param name: the name of the cache entry. :return: the entry or none. """ return next((x for x in self._uploadCache if x['name'] == name), None)
python
def _getCacheEntry(self, name): """ :param name: the name of the cache entry. :return: the entry or none. """ return next((x for x in self._uploadCache if x['name'] == name), None)
[ "def", "_getCacheEntry", "(", "self", ",", "name", ")", ":", "return", "next", "(", "(", "x", "for", "x", "in", "self", ".", "_uploadCache", "if", "x", "[", "'name'", "]", "==", "name", ")", ",", "None", ")" ]
:param name: the name of the cache entry. :return: the entry or none.
[ ":", "param", "name", ":", "the", "name", "of", "the", "cache", "entry", ".", ":", "return", ":", "the", "entry", "or", "none", "." ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L56-L61
train
3ll3d00d/vibe
backend/src/analyser/common/uploadcontroller.py
UploadController._convertTmp
def _convertTmp(self, tmpCacheEntry): """ Moves a tmp file to the upload dir, resampling it if necessary, and then deleting the tmp entries. :param tmpCacheEntry: the cache entry. :return: """ from analyser.common.signal import loadSignalFromWav tmpCacheEntry['sta...
python
def _convertTmp(self, tmpCacheEntry): """ Moves a tmp file to the upload dir, resampling it if necessary, and then deleting the tmp entries. :param tmpCacheEntry: the cache entry. :return: """ from analyser.common.signal import loadSignalFromWav tmpCacheEntry['sta...
[ "def", "_convertTmp", "(", "self", ",", "tmpCacheEntry", ")", ":", "from", "analyser", ".", "common", ".", "signal", "import", "loadSignalFromWav", "tmpCacheEntry", "[", "'status'", "]", "=", "'converting'", "logger", ".", "info", "(", "\"Loading \"", "+", "tm...
Moves a tmp file to the upload dir, resampling it if necessary, and then deleting the tmp entries. :param tmpCacheEntry: the cache entry. :return:
[ "Moves", "a", "tmp", "file", "to", "the", "upload", "dir", "resampling", "it", "if", "necessary", "and", "then", "deleting", "the", "tmp", "entries", ".", ":", "param", "tmpCacheEntry", ":", "the", "cache", "entry", ".", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L94-L121
train
3ll3d00d/vibe
backend/src/analyser/common/uploadcontroller.py
UploadController.writeChunk
def writeChunk(self, stream, filename, chunkIdx=None): """ Streams an uploaded chunk to a file. :param stream: the binary stream that contains the file. :param filename: the name of the file. :param chunkIdx: optional chunk index (for writing to a tmp dir) :return: no of...
python
def writeChunk(self, stream, filename, chunkIdx=None): """ Streams an uploaded chunk to a file. :param stream: the binary stream that contains the file. :param filename: the name of the file. :param chunkIdx: optional chunk index (for writing to a tmp dir) :return: no of...
[ "def", "writeChunk", "(", "self", ",", "stream", ",", "filename", ",", "chunkIdx", "=", "None", ")", ":", "import", "io", "more", "=", "True", "outputFileName", "=", "filename", "if", "chunkIdx", "is", "None", "else", "filename", "+", "'.'", "+", "str", ...
Streams an uploaded chunk to a file. :param stream: the binary stream that contains the file. :param filename: the name of the file. :param chunkIdx: optional chunk index (for writing to a tmp dir) :return: no of bytes written or -1 if there was an error.
[ "Streams", "an", "uploaded", "chunk", "to", "a", "file", ".", ":", "param", "stream", ":", "the", "binary", "stream", "that", "contains", "the", "file", ".", ":", "param", "filename", ":", "the", "name", "of", "the", "file", ".", ":", "param", "chunkId...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L126-L153
train
3ll3d00d/vibe
backend/src/analyser/common/uploadcontroller.py
UploadController.finalise
def finalise(self, filename, totalChunks, status): """ Completes the upload which means converting to a single 1kHz sample rate file output file. :param filename: :param totalChunks: :param status: :return: """ def getChunkIdx(x): try: ...
python
def finalise(self, filename, totalChunks, status): """ Completes the upload which means converting to a single 1kHz sample rate file output file. :param filename: :param totalChunks: :param status: :return: """ def getChunkIdx(x): try: ...
[ "def", "finalise", "(", "self", ",", "filename", ",", "totalChunks", ",", "status", ")", ":", "def", "getChunkIdx", "(", "x", ")", ":", "try", ":", "return", "int", "(", "x", ".", "suffix", "[", "1", ":", "]", ")", "except", "ValueError", ":", "ret...
Completes the upload which means converting to a single 1kHz sample rate file output file. :param filename: :param totalChunks: :param status: :return:
[ "Completes", "the", "upload", "which", "means", "converting", "to", "a", "single", "1kHz", "sample", "rate", "file", "output", "file", ".", ":", "param", "filename", ":", ":", "param", "totalChunks", ":", ":", "param", "status", ":", ":", "return", ":" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L155-L183
train
3ll3d00d/vibe
backend/src/analyser/common/uploadcontroller.py
UploadController.writeOutput
def writeOutput(self, filename, samples, srcFs, targetFs): """ Resamples the signal to the targetFs and writes it to filename. :param filename: the filename. :param signal: the signal to resample. :param targetFs: the target fs. :return: None """ import li...
python
def writeOutput(self, filename, samples, srcFs, targetFs): """ Resamples the signal to the targetFs and writes it to filename. :param filename: the filename. :param signal: the signal to resample. :param targetFs: the target fs. :return: None """ import li...
[ "def", "writeOutput", "(", "self", ",", "filename", ",", "samples", ",", "srcFs", ",", "targetFs", ")", ":", "import", "librosa", "inputLength", "=", "samples", ".", "shape", "[", "-", "1", "]", "if", "srcFs", "!=", "targetFs", ":", "if", "inputLength", ...
Resamples the signal to the targetFs and writes it to filename. :param filename: the filename. :param signal: the signal to resample. :param targetFs: the target fs. :return: None
[ "Resamples", "the", "signal", "to", "the", "targetFs", "and", "writes", "it", "to", "filename", ".", ":", "param", "filename", ":", "the", "filename", ".", ":", "param", "signal", ":", "the", "signal", "to", "resample", ".", ":", "param", "targetFs", ":"...
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L194-L219
train
3ll3d00d/vibe
backend/src/analyser/common/uploadcontroller.py
UploadController.delete
def delete(self, name): """ Deletes the named entry. :param name: the entry. :return: the deleted entry. """ i, entry = next(((i, x) for i, x in enumerate(self._uploadCache) if x['name'] == name), (None, None)) if entry is not None: logger.info("Deleti...
python
def delete(self, name): """ Deletes the named entry. :param name: the entry. :return: the deleted entry. """ i, entry = next(((i, x) for i, x in enumerate(self._uploadCache) if x['name'] == name), (None, None)) if entry is not None: logger.info("Deleti...
[ "def", "delete", "(", "self", ",", "name", ")", ":", "i", ",", "entry", "=", "next", "(", "(", "(", "i", ",", "x", ")", "for", "i", ",", "x", "in", "enumerate", "(", "self", ".", "_uploadCache", ")", "if", "x", "[", "'name'", "]", "==", "name...
Deletes the named entry. :param name: the entry. :return: the deleted entry.
[ "Deletes", "the", "named", "entry", ".", ":", "param", "name", ":", "the", "entry", ".", ":", "return", ":", "the", "deleted", "entry", "." ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L221-L235
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
eparOptionFactory
def eparOptionFactory(master, statusBar, param, defaultParam, doScroll, fieldWidths, plugIn=None, editedCallbackObj=None, helpCallbackObj=None, mainGuiObj=None, defaultsVerb="Default", bg=None, indent=False, fl...
python
def eparOptionFactory(master, statusBar, param, defaultParam, doScroll, fieldWidths, plugIn=None, editedCallbackObj=None, helpCallbackObj=None, mainGuiObj=None, defaultsVerb="Default", bg=None, indent=False, fl...
[ "def", "eparOptionFactory", "(", "master", ",", "statusBar", ",", "param", ",", "defaultParam", ",", "doScroll", ",", "fieldWidths", ",", "plugIn", "=", "None", ",", "editedCallbackObj", "=", "None", ",", "helpCallbackObj", "=", "None", ",", "mainGuiObj", "=",...
Return EparOption item of appropriate type for the parameter param
[ "Return", "EparOption", "item", "of", "appropriate", "type", "for", "the", "parameter", "param" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L910-L940
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EparOption.extraBindingsForSelectableText
def extraBindingsForSelectableText(self): """ Collect in 1 place the bindings needed for watchTextSelection() """ # See notes in watchTextSelection self.entry.bind('<FocusIn>', self.watchTextSelection, "+") self.entry.bind('<ButtonRelease-1>', self.watchTextSelection, "+") self.e...
python
def extraBindingsForSelectableText(self): """ Collect in 1 place the bindings needed for watchTextSelection() """ # See notes in watchTextSelection self.entry.bind('<FocusIn>', self.watchTextSelection, "+") self.entry.bind('<ButtonRelease-1>', self.watchTextSelection, "+") self.e...
[ "def", "extraBindingsForSelectableText", "(", "self", ")", ":", "# See notes in watchTextSelection", "self", ".", "entry", ".", "bind", "(", "'<FocusIn>'", ",", "self", ".", "watchTextSelection", ",", "\"+\"", ")", "self", ".", "entry", ".", "bind", "(", "'<Butt...
Collect in 1 place the bindings needed for watchTextSelection()
[ "Collect", "in", "1", "place", "the", "bindings", "needed", "for", "watchTextSelection", "()" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L243-L251
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EparOption.focusOut
def focusOut(self, event=None): """Clear selection (if text is selected in this widget)""" # do nothing if this isn't a text-enabled widget if not self.isSelectable: return if self.entryCheck(event) is None: # Entry value is OK # Save the last selectio...
python
def focusOut(self, event=None): """Clear selection (if text is selected in this widget)""" # do nothing if this isn't a text-enabled widget if not self.isSelectable: return if self.entryCheck(event) is None: # Entry value is OK # Save the last selectio...
[ "def", "focusOut", "(", "self", ",", "event", "=", "None", ")", ":", "# do nothing if this isn't a text-enabled widget", "if", "not", "self", ".", "isSelectable", ":", "return", "if", "self", ".", "entryCheck", "(", "event", ")", "is", "None", ":", "# Entry va...
Clear selection (if text is selected in this widget)
[ "Clear", "selection", "(", "if", "text", "is", "selected", "in", "this", "widget", ")" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L257-L281
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EparOption.watchTextSelection
def watchTextSelection(self, event=None): """ Callback used to see if there is a new text selection. In certain cases we manually add the text to the clipboard (though on most platforms the correct behavior happens automatically). """ # Note that this isn't perfect - it is a key click be...
python
def watchTextSelection(self, event=None): """ Callback used to see if there is a new text selection. In certain cases we manually add the text to the clipboard (though on most platforms the correct behavior happens automatically). """ # Note that this isn't perfect - it is a key click be...
[ "def", "watchTextSelection", "(", "self", ",", "event", "=", "None", ")", ":", "# Note that this isn't perfect - it is a key click behind when", "# selections are made via shift-arrow. If this becomes important, it", "# can likely be fixed with after().", "if", "self", ".", "entry",...
Callback used to see if there is a new text selection. In certain cases we manually add the text to the clipboard (though on most platforms the correct behavior happens automatically).
[ "Callback", "used", "to", "see", "if", "there", "is", "a", "new", "text", "selection", ".", "In", "certain", "cases", "we", "manually", "add", "the", "text", "to", "the", "clipboard", "(", "though", "on", "most", "platforms", "the", "correct", "behavior", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L283-L296
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EparOption.focusIn
def focusIn(self, event=None): """Select all text (if applicable) on taking focus""" try: # doScroll returns false if the call was ignored because the # last call also came from this widget. That avoids unwanted # scrolls and text selection when the focus moves in an...
python
def focusIn(self, event=None): """Select all text (if applicable) on taking focus""" try: # doScroll returns false if the call was ignored because the # last call also came from this widget. That avoids unwanted # scrolls and text selection when the focus moves in an...
[ "def", "focusIn", "(", "self", ",", "event", "=", "None", ")", ":", "try", ":", "# doScroll returns false if the call was ignored because the", "# last call also came from this widget. That avoids unwanted", "# scrolls and text selection when the focus moves in and out", "# of the win...
Select all text (if applicable) on taking focus
[ "Select", "all", "text", "(", "if", "applicable", ")", "on", "taking", "focus" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L302-L316
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EparOption.widgetEdited
def widgetEdited(self, event=None, val=None, action='entry', skipDups=True): """ A general method for firing any applicable triggers when a value has been set. This is meant to be easily callable from any part of this class (or its subclasses), so that it can be called as so...
python
def widgetEdited(self, event=None, val=None, action='entry', skipDups=True): """ A general method for firing any applicable triggers when a value has been set. This is meant to be easily callable from any part of this class (or its subclasses), so that it can be called as so...
[ "def", "widgetEdited", "(", "self", ",", "event", "=", "None", ",", "val", "=", "None", ",", "action", "=", "'entry'", ",", "skipDups", "=", "True", ")", ":", "# be as lightweight as possible if obj doesn't care about this stuff", "if", "not", "self", ".", "_edi...
A general method for firing any applicable triggers when a value has been set. This is meant to be easily callable from any part of this class (or its subclasses), so that it can be called as soon as need be (immed. on click?). This is smart enough to be called multiple...
[ "A", "general", "method", "for", "firing", "any", "applicable", "triggers", "when", "a", "value", "has", "been", "set", ".", "This", "is", "meant", "to", "be", "easily", "callable", "from", "any", "part", "of", "this", "class", "(", "or", "its", "subclas...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L347-L380
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EparOption.popupChoices
def popupChoices(self, event=None): """Popup right-click menu of special parameter operations Relies on browserEnabled, clearEnabled, unlearnEnabled, helpEnabled instance attributes to determine which items are available. """ # don't bother if all items are disabled if N...
python
def popupChoices(self, event=None): """Popup right-click menu of special parameter operations Relies on browserEnabled, clearEnabled, unlearnEnabled, helpEnabled instance attributes to determine which items are available. """ # don't bother if all items are disabled if N...
[ "def", "popupChoices", "(", "self", ",", "event", "=", "None", ")", ":", "# don't bother if all items are disabled", "if", "NORMAL", "not", "in", "(", "self", ".", "browserEnabled", ",", "self", ".", "clearEnabled", ",", "self", ".", "unlearnEnabled", ",", "se...
Popup right-click menu of special parameter operations Relies on browserEnabled, clearEnabled, unlearnEnabled, helpEnabled instance attributes to determine which items are available.
[ "Popup", "right", "-", "click", "menu", "of", "special", "parameter", "operations" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L392-L436
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EparOption.fileBrowser
def fileBrowser(self): """Invoke a tkinter file dialog""" if capable.OF_TKFD_IN_EPAR: fname = askopenfilename(parent=self.entry, title="Select File") else: from . import filedlg self.fd = filedlg.PersistLoadFileDialog(self.entry, "...
python
def fileBrowser(self): """Invoke a tkinter file dialog""" if capable.OF_TKFD_IN_EPAR: fname = askopenfilename(parent=self.entry, title="Select File") else: from . import filedlg self.fd = filedlg.PersistLoadFileDialog(self.entry, "...
[ "def", "fileBrowser", "(", "self", ")", ":", "if", "capable", ".", "OF_TKFD_IN_EPAR", ":", "fname", "=", "askopenfilename", "(", "parent", "=", "self", ".", "entry", ",", "title", "=", "\"Select File\"", ")", "else", ":", "from", ".", "import", "filedlg", ...
Invoke a tkinter file dialog
[ "Invoke", "a", "tkinter", "file", "dialog" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L438-L456
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EparOption.dirBrowser
def dirBrowser(self): """Invoke a tkinter directory dialog""" if capable.OF_TKFD_IN_EPAR: fname = askdirectory(parent=self.entry, title="Select Directory") else: raise NotImplementedError('Fix popupChoices() logic.') if not fname: return # canceled ...
python
def dirBrowser(self): """Invoke a tkinter directory dialog""" if capable.OF_TKFD_IN_EPAR: fname = askdirectory(parent=self.entry, title="Select Directory") else: raise NotImplementedError('Fix popupChoices() logic.') if not fname: return # canceled ...
[ "def", "dirBrowser", "(", "self", ")", ":", "if", "capable", ".", "OF_TKFD_IN_EPAR", ":", "fname", "=", "askdirectory", "(", "parent", "=", "self", ".", "entry", ",", "title", "=", "\"Select Directory\"", ")", "else", ":", "raise", "NotImplementedError", "("...
Invoke a tkinter directory dialog
[ "Invoke", "a", "tkinter", "directory", "dialog" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L458-L471
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EparOption.forceValue
def forceValue(self, newVal, noteEdited=False): """Force-set a parameter entry to the given value""" if newVal is None: newVal = "" self.choice.set(newVal) if noteEdited: self.widgetEdited(val=newVal, skipDups=False)
python
def forceValue(self, newVal, noteEdited=False): """Force-set a parameter entry to the given value""" if newVal is None: newVal = "" self.choice.set(newVal) if noteEdited: self.widgetEdited(val=newVal, skipDups=False)
[ "def", "forceValue", "(", "self", ",", "newVal", ",", "noteEdited", "=", "False", ")", ":", "if", "newVal", "is", "None", ":", "newVal", "=", "\"\"", "self", ".", "choice", ".", "set", "(", "newVal", ")", "if", "noteEdited", ":", "self", ".", "widget...
Force-set a parameter entry to the given value
[ "Force", "-", "set", "a", "parameter", "entry", "to", "the", "given", "value" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L477-L483
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EparOption.unlearnValue
def unlearnValue(self): """Unlearn a parameter value by setting it back to its default""" defaultValue = self.defaultParamInfo.get(field = "p_filename", native = 0, prompt = 0) self.choice.set(defaultValue)
python
def unlearnValue(self): """Unlearn a parameter value by setting it back to its default""" defaultValue = self.defaultParamInfo.get(field = "p_filename", native = 0, prompt = 0) self.choice.set(defaultValue)
[ "def", "unlearnValue", "(", "self", ")", ":", "defaultValue", "=", "self", ".", "defaultParamInfo", ".", "get", "(", "field", "=", "\"p_filename\"", ",", "native", "=", "0", ",", "prompt", "=", "0", ")", "self", ".", "choice", ".", "set", "(", "default...
Unlearn a parameter value by setting it back to its default
[ "Unlearn", "a", "parameter", "value", "by", "setting", "it", "back", "to", "its", "default" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L491-L495
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EparOption.setActiveState
def setActiveState(self, active): """ Use this to enable or disable (grey out) a parameter. """ st = DISABLED if active: st = NORMAL self.entry.configure(state=st) self.inputLabel.configure(state=st) self.promptLabel.configure(state=st)
python
def setActiveState(self, active): """ Use this to enable or disable (grey out) a parameter. """ st = DISABLED if active: st = NORMAL self.entry.configure(state=st) self.inputLabel.configure(state=st) self.promptLabel.configure(state=st)
[ "def", "setActiveState", "(", "self", ",", "active", ")", ":", "st", "=", "DISABLED", "if", "active", ":", "st", "=", "NORMAL", "self", ".", "entry", ".", "configure", "(", "state", "=", "st", ")", "self", ".", "inputLabel", ".", "configure", "(", "s...
Use this to enable or disable (grey out) a parameter.
[ "Use", "this", "to", "enable", "or", "disable", "(", "grey", "out", ")", "a", "parameter", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L508-L514
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EparOption.flagThisPar
def flagThisPar(self, currentVal, force): """ If this par's value is different from the default value, it is here that we flag it somehow as such. This basic version simply makes the surrounding text red (or returns it to normal). May be overridden. Leave force at False if you want to a...
python
def flagThisPar(self, currentVal, force): """ If this par's value is different from the default value, it is here that we flag it somehow as such. This basic version simply makes the surrounding text red (or returns it to normal). May be overridden. Leave force at False if you want to a...
[ "def", "flagThisPar", "(", "self", ",", "currentVal", ",", "force", ")", ":", "# Get out ASAP if we can", "if", "(", "not", "force", ")", "and", "(", "not", "self", ".", "_flagNonDefaultVals", ")", ":", "return", "# handle simple case before comparing values (quick ...
If this par's value is different from the default value, it is here that we flag it somehow as such. This basic version simply makes the surrounding text red (or returns it to normal). May be overridden. Leave force at False if you want to allow this mehtod to make smart time-saving dec...
[ "If", "this", "par", "s", "value", "is", "different", "from", "the", "default", "value", "it", "is", "here", "that", "we", "flag", "it", "somehow", "as", "such", ".", "This", "basic", "version", "simply", "makes", "the", "surrounding", "text", "red", "("...
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L516-L547
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EnumEparOption.keypress
def keypress(self, event): """Allow keys typed in widget to select items""" try: self.choice.set(self.shortcuts[event.keysym]) except KeyError: # key not found (probably a bug, since we intend to catch # only events from shortcut keys, but ignore it anyway) ...
python
def keypress(self, event): """Allow keys typed in widget to select items""" try: self.choice.set(self.shortcuts[event.keysym]) except KeyError: # key not found (probably a bug, since we intend to catch # only events from shortcut keys, but ignore it anyway) ...
[ "def", "keypress", "(", "self", ",", "event", ")", ":", "try", ":", "self", ".", "choice", ".", "set", "(", "self", ".", "shortcuts", "[", "event", ".", "keysym", "]", ")", "except", "KeyError", ":", "# key not found (probably a bug, since we intend to catch",...
Allow keys typed in widget to select items
[ "Allow", "keys", "typed", "in", "widget", "to", "select", "items" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L641-L648
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
EnumEparOption.postcmd
def postcmd(self): """Make sure proper entry is activated when menu is posted""" value = self.choice.get() try: index = self.paramInfo.choice.index(value) self.entry.menu.activate(index) except ValueError: # initial null value may not be in list ...
python
def postcmd(self): """Make sure proper entry is activated when menu is posted""" value = self.choice.get() try: index = self.paramInfo.choice.index(value) self.entry.menu.activate(index) except ValueError: # initial null value may not be in list ...
[ "def", "postcmd", "(", "self", ")", ":", "value", "=", "self", ".", "choice", ".", "get", "(", ")", "try", ":", "index", "=", "self", ".", "paramInfo", ".", "choice", ".", "index", "(", "value", ")", "self", ".", "entry", ".", "menu", ".", "activ...
Make sure proper entry is activated when menu is posted
[ "Make", "sure", "proper", "entry", "is", "activated", "when", "menu", "is", "posted" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L650-L658
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
BooleanEparOption.convertToNative
def convertToNative(self, aVal): """ Convert to native bool; interpret certain strings. """ if aVal is None: return None if isinstance(aVal, bool): return aVal # otherwise interpret strings return str(aVal).lower() in ('1','on','yes','true')
python
def convertToNative(self, aVal): """ Convert to native bool; interpret certain strings. """ if aVal is None: return None if isinstance(aVal, bool): return aVal # otherwise interpret strings return str(aVal).lower() in ('1','on','yes','true')
[ "def", "convertToNative", "(", "self", ",", "aVal", ")", ":", "if", "aVal", "is", "None", ":", "return", "None", "if", "isinstance", "(", "aVal", ",", "bool", ")", ":", "return", "aVal", "# otherwise interpret strings", "return", "str", "(", "aVal", ")", ...
Convert to native bool; interpret certain strings.
[ "Convert", "to", "native", "bool", ";", "interpret", "certain", "strings", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L674-L680
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
BooleanEparOption.toggle
def toggle(self, event=None): """Toggle value between Yes and No""" if self.choice.get() == "yes": self.rbno.select() else: self.rbyes.select() self.widgetEdited()
python
def toggle(self, event=None): """Toggle value between Yes and No""" if self.choice.get() == "yes": self.rbno.select() else: self.rbyes.select() self.widgetEdited()
[ "def", "toggle", "(", "self", ",", "event", "=", "None", ")", ":", "if", "self", ".", "choice", ".", "get", "(", ")", "==", "\"yes\"", ":", "self", ".", "rbno", ".", "select", "(", ")", "else", ":", "self", ".", "rbyes", ".", "select", "(", ")"...
Toggle value between Yes and No
[ "Toggle", "value", "between", "Yes", "and", "No" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L780-L786
train
spacetelescope/stsci.tools
lib/stsci/tools/eparoption.py
NumberEparOption.entryCheck
def entryCheck(self, event = None, repair = True): """ Ensure any INDEF entry is uppercase, before base class behavior """ valupr = self.choice.get().upper() if valupr.strip() == 'INDEF': self.choice.set(valupr) return EparOption.entryCheck(self, event, repair = repair)
python
def entryCheck(self, event = None, repair = True): """ Ensure any INDEF entry is uppercase, before base class behavior """ valupr = self.choice.get().upper() if valupr.strip() == 'INDEF': self.choice.set(valupr) return EparOption.entryCheck(self, event, repair = repair)
[ "def", "entryCheck", "(", "self", ",", "event", "=", "None", ",", "repair", "=", "True", ")", ":", "valupr", "=", "self", ".", "choice", ".", "get", "(", ")", ".", "upper", "(", ")", "if", "valupr", ".", "strip", "(", ")", "==", "'INDEF'", ":", ...
Ensure any INDEF entry is uppercase, before base class behavior
[ "Ensure", "any", "INDEF", "entry", "is", "uppercase", "before", "base", "class", "behavior" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L881-L886
train
spacetelescope/stsci.tools
lib/stsci/tools/xyinterp.py
xyinterp
def xyinterp(x,y,xval): """ :Purpose: Interpolates y based on the given xval. x and y are a pair of independent/dependent variable arrays that must be the same length. The x array must also be sorted. xval is a user-specified value. This routine looks up xval in the x array and uses that ...
python
def xyinterp(x,y,xval): """ :Purpose: Interpolates y based on the given xval. x and y are a pair of independent/dependent variable arrays that must be the same length. The x array must also be sorted. xval is a user-specified value. This routine looks up xval in the x array and uses that ...
[ "def", "xyinterp", "(", "x", ",", "y", ",", "xval", ")", ":", "#Enforce conditions on x, y, and xval:", "#x and y must correspond", "if", "len", "(", "x", ")", "!=", "len", "(", "y", ")", ":", "raise", "ValueError", "(", "\"Input arrays must be equal lengths\"", ...
:Purpose: Interpolates y based on the given xval. x and y are a pair of independent/dependent variable arrays that must be the same length. The x array must also be sorted. xval is a user-specified value. This routine looks up xval in the x array and uses that information to properly interpolate th...
[ ":", "Purpose", ":", "Interpolates", "y", "based", "on", "the", "given", "xval", "." ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/xyinterp.py#L28-L102
train
3ll3d00d/vibe
backend/src/recorder/common/mpu6050.py
mpu6050._setSampleSizeBytes
def _setSampleSizeBytes(self): """ updates the current record of the packet size per sample and the relationship between this and the fifo reads. """ self.sampleSizeBytes = self.getPacketSize() if self.sampleSizeBytes > 0: self.maxBytesPerFifoRead = (32 // self.sampl...
python
def _setSampleSizeBytes(self): """ updates the current record of the packet size per sample and the relationship between this and the fifo reads. """ self.sampleSizeBytes = self.getPacketSize() if self.sampleSizeBytes > 0: self.maxBytesPerFifoRead = (32 // self.sampl...
[ "def", "_setSampleSizeBytes", "(", "self", ")", ":", "self", ".", "sampleSizeBytes", "=", "self", ".", "getPacketSize", "(", ")", "if", "self", ".", "sampleSizeBytes", ">", "0", ":", "self", ".", "maxBytesPerFifoRead", "=", "(", "32", "//", "self", ".", ...
updates the current record of the packet size per sample and the relationship between this and the fifo reads.
[ "updates", "the", "current", "record", "of", "the", "packet", "size", "per", "sample", "and", "the", "relationship", "between", "this", "and", "the", "fifo", "reads", "." ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L265-L271
train