code stringlengths 1 18.2k |
|---|
n=1, axis=0).mean()), 0)) source = Signal(samples.ravel(), fs) return source |
def loadSignalFromWav(inputSignalFile, calibrationRealWorldValue=None, calibrationSignalFile=None, start=None, end=None) -> Signal: """ reads a wav file into a Signal and scales the input so that the sample are expressed in real world values (as defined by the calibration signal). :param inputSignalFile: a path to the ... |
:param bitDepth: the bit depth of the input signal, used to rescale the value to a range of +1 to -1 :returns: a Signal """ inputSignal = readWav(inputSignalFile, start=start, end=end) if calibrationSignalFile is not None: calibrationSignal = readWav(calibrationSignalFile) scalingFactor = calibrationRealWorldValue / np... |
def readWav(inputSignalFile, selectedChannel=1, start=None, end=None) -> Signal: """ reads a wav file into a Signal. :param inputSignalFile: a path to the input signal file :param selectedChannel: the channel to read. :param start: the time to start reading from in HH:mm:ss.SSS format. :param end: the time to end readi... |
= int(hours) minutes = int(minutes) seconds = float(seconds) millis = int((3600000 * hours) + (60000 * minutes) + (1000 * seconds)) return int(millis * (fs / 1000)) import soundfile as sf if start is not None or end is not None: info = sf.info(inputSignalFile) startFrame = 0 if start is None else asFrames(start, info.s... |
ys, frameRate = sf.read(inputSignalFile, start=startFrame, stop=endFrame) else: ys, frameRate = sf.read(inputSignalFile) return Signal(ys[::selectedChannel], frameRate) |
def loadTriAxisSignalFromFile(filename, timeColumnIdx=0, xIdx=1, yIdx=2, zIdx=3, delimiter=',', skipHeader=0) -> TriAxisSignal: """ A factory method for loading a tri axis measurement from a single file. :param filename: the file to load from. :param timeColumnIdx: the column containing time data. :param xIdx: the colu... |
the delimiter. :param skipHeader: how many rows of headers to skip. :return: the measurement """ return TriAxisSignal( x=loadSignalFromDelimitedFile(filename, timeColumnIdx=timeColumnIdx, dataColumnIdx=xIdx, delimiter=delimiter, skipHeader=skipHeader), y=loadSignalFromDelimitedFile(filename, timeColumnIdx=timeColumnIdx... |
def psd(self, ref=None, segmentLengthMultiplier=1, mode=None, **kwargs): """ analyses the source and returns a PSD, segment is set to get ~1Hz frequency resolution :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :param mode: cq or none. :return: f : ndarr... |
self.fs, nperseg=nperseg, detrend=False, **kwargs) if ref is not None: Pxx_den = librosa.power_to_db(Pxx_den, ref) return f, Pxx_den if mode == 'cq': return self._cq(analysisFunc, segmentLengthMultiplier) else: return analysisFunc(0, self.getSegmentLength() * segmentLengthMultiplier, **kwargs) |
def spectrum(self, ref=None, segmentLengthMultiplier=1, mode=None, **kwargs): """ analyses the source to generate the linear spectrum. :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :param mode: cq or none. :return: f : ndarray Array of sample frequencie... |
# it seems a 3dB adjustment is required to account for the change in nperseg if x > 0: Pxx_spec = Pxx_spec / (10 ** ((3 * x) / 20)) if ref is not None: Pxx_spec = librosa.amplitude_to_db(Pxx_spec, ref) return f, Pxx_spec if mode == 'cq': return self._cq(analysisFunc, segmentLengthMultiplier) else: return analysisFunc(0... |
def peakSpectrum(self, ref=None, segmentLengthMultiplier=1, mode=None, window='hann'): """ analyses the source to generate the max values per bin per segment :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :param mode: cq or none. :return: f : ndarray Arr... |
nperseg=int(nperseg), noverlap=int(nperseg // 2), detrend=False, scaling='spectrum') Pxy_max = np.sqrt(Pxy.max(axis=-1).real) if x > 0: Pxy_max = Pxy_max / (10 ** ((3 * x) / 20)) if ref is not None: Pxy_max = librosa.amplitude_to_db(Pxy_max, ref=ref) return freqs, Pxy_max if mode == 'cq': return self._cq(analysisFunc, ... |
def spectrogram(self, ref=None, segmentLengthMultiplier=1, window='hann'): """ analyses the source to generate a spectrogram :param ref: the reference value for dB purposes. :param segmentLengthMultiplier: allow for increased resolution. :return: t : ndarray Array of time slices. f : ndarray Array of sample frequencies... |
if ref is not None: Sxx = librosa.amplitude_to_db(Sxx, ref) return t, f, Sxx |
def lowPass(self, *args): """ Creates a copy of the signal with the low pass applied, args specifed are passed through to _butter. :return: """ return Signal(self._butter(self.samples, 'low', *args), fs=self.fs) |
def highPass(self, *args): """ Creates a copy of the signal with the high pass applied, args specifed are passed through to _butter. :return: """ return Signal(self._butter(self.samples, 'high', *args), fs=self.fs) |
def _butter(self, data, btype, f3=2, order=2): """ Applies a digital butterworth filter via filtfilt at the specified f3 and order. Default values are set to correspond to apparently sensible filters that distinguish between vibration and tilt from an accelerometer. :param data: the data to filter. :param btype: high o... |
filtered signal. """ b, a = signal.butter(order, f3 / (0.5 * self.fs), btype=btype) y = signal.filtfilt(b, a, data) return y |
def _getAnalysis(self, axis, analysis, ref=None): """ gets the named analysis on the given axis and caches the result (or reads from the cache if data is available already) :param axis: the named axis. :param analysis: the analysis name. :return: the analysis tuple. """ cache = self.cache.get(str(ref)) if cache is None... |
axis in cache: data = self.cache['raw'].get(axis, None) cachedAxis = cache.get(axis) if cachedAxis.get(analysis) is None: if axis == 'sum': if self._canSum(analysis): fx, Pxx = self._getAnalysis('x', analysis) fy, Pxy = self._getAnalysis('y', analysis) fz, Pxz = self._getAnalysis('z', analysis) # calculate the sum of t... |
(Pxz ** 2)) ** 0.5 if ref is not None: Psum = librosa.amplitude_to_db(Psum, ref) cachedAxis[analysis] = (fx, Psum) else: return None else: cachedAxis[analysis] = getattr(data.highPass(), analysis)(ref=ref) return cachedAxis[analysis] else: return None |
def legal_date(year, month, day): '''Checks if a given date is a legal positivist date''' try: assert year >= 1 assert 0 < month <= 14 assert 0 < day <= 28 if month == 14: if isleap(year + YEAR_EPOCH - 1): assert day <= 2 else: assert day == 1 except AssertionError: raise ValueError("Invalid Positivist date: ({}, {}, {... |
def to_jd(year, month, day): '''Convert a Positivist date to Julian day count.''' legal_date(year, month, day) gyear = year + YEAR_EPOCH - 1 return ( gregorian.EPOCH - 1 + (365 * (gyear - 1)) + floor((gyear - 1) / 4) + (-floor((gyear - 1) / 100)) + floor((gyear - 1) / 400) + (month - 1) * 28 + day ) |
def from_jd(jd): '''Convert a Julian day count to Positivist date.''' try: assert jd >= EPOCH except AssertionError: raise ValueError('Invalid Julian day') depoch = floor(jd - 0.5) + 0.5 - gregorian.EPOCH quadricent = floor(depoch / gregorian.INTERCALATION_CYCLE_DAYS) dqc = depoch % gregorian.INTERCALATION_CYCLE_DAYS c... |
gregorian.YEAR_DAYS) year = ( quadricent * gregorian.INTERCALATION_CYCLE_YEARS + cent * gregorian.LEAP_SUPPRESSION_YEARS + quad * gregorian.LEAP_CYCLE_YEARS + yindex ) if yindex == 4: yearday = 365 year = year - 1 else: yearday = ( depoch - quadricent * gregorian.INTERCALATION_CYCLE_DAYS - cent * gregorian.LEAP_SUPPRES... |
+ 1, int(yearday - (month * 28)) + 1) |
def dayname(year, month, day): ''' Give the name of the month and day for a given date. Returns: tuple month_name, day_name ''' legal_date(year, month, day) yearday = (month - 1) * 28 + day if isleap(year + YEAR_EPOCH - 1): dname = data.day_names_leap[yearday - 1] else: dname = data.day_names[yearday - 1] return MONTHS... |
def hasExpired(self): """ :return: true if the lastUpdateTime is more than maxAge seconds ago. """ return (datetime.datetime.utcnow() - self.lastUpdateTime).total_seconds() > self.maxAgeSeconds |
def accept(self, deviceId, device): """ Adds the named device to the store. :param deviceId: :param device: :return: """ storedDevice = self.devices.get(deviceId) if storedDevice is None: logger.info('Initialising device ' + deviceId) storedDevice = Device(self.maxAgeSeconds) storedDevice.deviceId = deviceId # this use... |
soon as it has handed off the data. This means delivery is only # guaranteed as long as the analyser stays up but this is not a system that sits on top of a bulletproof # message bus so unlucky :P storedDevice.dataHandler = AsyncHandler('analyser', CSVLogger('analyser', deviceId, self.dataDir)) else: logger.debug('Ping... |
has FAILED, do something? self.devices.update({deviceId: storedDevice}) self.targetStateController.updateDeviceState(storedDevice.payload) |
def getDevices(self, status=None): """ The devices in the given state or all devices is the arg is none. :param status: the state to match against. :return: the devices """ return [d for d in self.devices.values() if status is None or d.payload.get('status') == status] |
def getDevice(self, id): """ gets the named device. :param id: the id. :return: the device """ return next(iter([d for d in self.devices.values() if d.deviceId == id]), None) |
def _evictStaleDevices(self): """ A housekeeping function which runs in a worker thread and which evicts devices that haven't sent an update for a while. """ while self.running: expiredDeviceIds = [key for key, value in self.devices.items() if value.hasExpired()] for key in expiredDeviceIds: logger.warning("Device time... |
def scheduleMeasurement(self, measurementId, duration, start): """ Schedules the requested measurement session with all INITIALISED devices. :param measurementId: :param duration: :param start: :return: a dict of device vs status. """ # TODO subtract 1s from start and format results = {} for device in self.getDevices(R... |
duration, 'at': start.strftime(DATETIME_FORMAT)}) logger.info('Response for ' + measurementId + ' from ' + device.payload['serviceURL'] + ' is ' + str(resp.status_code)) results[device] = resp.status_code except Exception as e: logger.exception(e) results[device] = 500 return results |
def patch(self): """ Allows the UI to update parameters ensuring that all devices are kept in sync. Payload is json in TargetState format. :return: """ # TODO block until all devices have updated? json = request.get_json() logger.info("Updating target state with " + str(json)) self._targetStateController.updateTargetSt... |
def list_parse(name_list): """Parse a comma-separated list of values, or a filename (starting with @) containing a list value on each line. """ if name_list and name_list[0] == '@': value = name_list[1:] if not os.path.exists(value): log.warning('The file %s does not exist' % value) return try: return [v.strip() for v ... |
e)) else: return [v.strip() for v in name_list.split(',')] |
def _mmInit(self): """Create the minimum match dictionary of keys""" # cache references to speed up loop a bit mmkeys = {} mmkeysGet = mmkeys.setdefault minkeylength = self.minkeylength for key in self.data.keys(): # add abbreviations as short as minkeylength # always add at least one entry (even for key="") lenkey = l... |
def resolve(self, key, keylist): """Hook to resolve ambiguities in selected keys""" raise AmbiguousKeyError("Ambiguous key "+ repr(key) + ", could be any of " + str(sorted(keylist))) |
def add(self, key, item): """Add a new key/item pair to the dictionary. Resets an existing key value only if this is an exact match to a known key.""" mmkeys = self.mmkeys if mmkeys is not None and not (key in self.data): # add abbreviations as short as minkeylength # always add at least one entry (even for key="") len... |
# cache references to speed up loop a bit mmkeysGet = mmkeys.setdefault for i in range(start,lenkey+1): mmkeysGet(key[0:i],[]).append(key) self.data[key] = item |
def get(self, key, failobj=None, exact=0): """Raises exception if key is ambiguous""" if not exact: key = self.getfullkey(key,new=1) return self.data.get(key,failobj) |
def _has(self, key, exact=0): """Raises an exception if key is ambiguous""" if not exact: key = self.getfullkey(key,new=1) return key in self.data |
def getall(self, key, failobj=None): """Returns a list of all the matching values for key, containing a single entry for unambiguous matches and multiple entries for ambiguous matches.""" if self.mmkeys is None: self._mmInit() k = self.mmkeys.get(key) if not k: return failobj return list(map(self.data.get, k)) |
def getallkeys(self, key, failobj=None): """Returns a list of the full key names (not the items) for all the matching values for key. The list will contain a single entry for unambiguous matches and multiple entries for ambiguous matches.""" if self.mmkeys is None: self._mmInit() return self.mmkeys.get(key, failobj) |
def get(self, key, failobj=None, exact=0): """Returns failobj if key is not found or is ambiguous""" if not exact: try: key = self.getfullkey(key) except KeyError: return failobj return self.data.get(key,failobj) |
def _has(self, key, exact=0): """Returns false if key is not found or is ambiguous""" if not exact: try: key = self.getfullkey(key) return 1 except KeyError: return 0 else: return key in self.data |
def parFactory(fields, strict=0): """parameter factory function fields is a list of the comma-separated fields (as in the .par file). Each entry is a string or None (indicating that field was omitted.) Set the strict parameter to a non-zero value to do stricter parsing (to find errors in the input)""" if len(fields) < ... |
given") type = fields[1] if type in _string_types: return IrafParS(fields,strict) elif type == 'R': return StrictParR(fields,1) elif type in _real_types: return IrafParR(fields,strict) elif type == "I": return StrictParI(fields,1) elif type == "i": return IrafParI(fields,strict) elif type == "b": return IrafParB(fields... |
elif type[:1] == "a": raise SyntaxError("Cannot handle arrays of type %s" % type) else: raise SyntaxError("Cannot handle parameter type %s" % type) |
def setCmdline(self,value=1): """Set cmdline flag""" # set through dictionary to avoid extra calls to __setattr__ if value: self.__dict__['flags'] = self.flags | _cmdlineFlag else: self.__dict__['flags'] = self.flags & ~_cmdlineFlag |
def setChanged(self,value=1): """Set changed flag""" # set through dictionary to avoid another call to __setattr__ if value: self.__dict__['flags'] = self.flags | _changedFlag else: self.__dict__['flags'] = self.flags & ~_changedFlag |
def isLearned(self, mode=None): """Return true if this parameter is learned Hidden parameters are not learned; automatic parameters inherit behavior from package/cl; other parameters are learned. If mode is set, it determines how automatic parameters behave. If not set, cl.mode parameter determines behavior. """ if "l"... |
= 'ql' # that is, iraf.cl.mode if "h" in mode and "l" not in mode: return 0 return 1 |
def getWithPrompt(self): """Interactively prompt for parameter value""" if self.prompt: pstring = self.prompt.split("\n")[0].strip() else: pstring = self.name if self.choice: schoice = list(map(self.toString, self.choice)) pstring = pstring + " (" + "|".join(schoice) + ")" elif self.min not in [None, INDEF] or \ self.m... |
pstring + ":" if self.max not in [None, INDEF]: pstring = pstring + self.toString(self.max) pstring = pstring + ")" # add current value as default if self.value is not None: pstring = pstring + " (" + self.toString(self.value,quoted=1) + ")" pstring = pstring + ": " # don't redirect stdin/out unless redirected filehand... |
= sys.__stdout__ try: if sys.stdout.isatty() or not stdout.isatty(): stdout = sys.stdout except AttributeError: pass stdin = sys.__stdin__ try: if sys.stdin.isatty() or not stdin.isatty(): stdin = sys.stdin except AttributeError: pass # print prompt, suppressing both newline and following space stdout.write(pstring) st... |
value as default # check it anyway since it might not be acceptable if value == "": value = self._nullPrompt() self.set(value) # None (no value) is not acceptable value after prompt if self.value is not None: return # if not EOF, keep looping if ovalue == "": stdout.flush() raise EOFError("EOF on parameter prompt") pri... |
print(str(e)) stdout.write(pstring) stdout.flush() ovalue = irafutils.tkreadline(stdin) value = ovalue.strip() |
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 and field != "p_value": # note p_value comes back to this routine, so shortcut that case return self._getField(field,native=native,prompt=pr... |
"+self.name+" is not an array") if native: rv = self.value else: rv = self.toString(self.value) return rv |
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 within the min-max range or in th... |
array") if field: self._setField(value,field,check=check) else: if check: self.value = self.checkValue(value) else: self.value = self._coerceValue(value) self.setChanged() |
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) return self.checkOneValue(v,strict) |
def checkOneValue(self,v,strict=0): """Checks a single value to see if it is in range or choice list Allows indirection strings starting with ")". Assumes v has already been converted to right value by _coerceOneValue. Returns value if OK, or raises ValueError if not OK. """ if v in [None, INDEF] or (isinstance(v,str) ... |
treat null string as omitted value return None elif self.choice is not None and v not in self.choiceDict: schoice = list(map(self.toString, self.choice)) schoice = "|".join(schoice) raise ValueError("Parameter %s: " "value %s is not in choice list (%s)" % (self.name, str(v), schoice)) elif (self.min not in [None, INDEF... |
elif (self.max not in [None, INDEF] and v>self.max): raise ValueError("Parameter %s: " "value `%s' is greater than maximum `%s'" % (self.name, str(v), str(self.max))) return v |
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. """ sval = self.toString(self.value, quoted=1) if not cl: if sval == "": sval = "None" s = "%s = %s" % (self.name, sval) return s |
def pretty(self,verbose=0): """Return pretty list description of parameter""" # split prompt lines and add blanks in later lines to align them plines = self.prompt.split('\n') for i in range(len(plines)-1): plines[i+1] = 32*' ' + plines[i+1] plines = '\n'.join(plines) namelen = min(len(self.name), 12) pvalue = self.get... |
+ pvalue + '"' if self.mode == "h": s = "%13s = %-15s %s" % ("("+self.name[:namelen], pvalue+")", plines) else: s = "%13s = %-15s %s" % (self.name[:namelen], pvalue, plines) if not verbose: return s if self.choice is not None: s = s + "\n" + 32*" " + "|" nline = 33 for i in range(len(self.choice)): sch = str(self.choic... |
+ sch nline = nline + len(sch) + 1 if nline > 80: s = s + "\n" + 32*" " + "|" nline = 33 elif self.min not in [None, INDEF] or self.max not in [None, INDEF]: s = s + "\n" + 32*" " if self.min not in [None, INDEF]: s = s + str(self.min) + " <= " s = s |
+ self.name if self.max not in [None, INDEF]: s = s + " <= " + str(self.max) return s |
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 fields = 7*[""] fields[0] = self.name fields[1] = self.type fields[2] = self.mode fields[3] = s... |
schoice.append('') fields[4] = repr('|'.join(schoice)) elif self.min not in [None,INDEF]: fields[4] = self.toString(self.min,quoted=quoted) if self.max not in [None,INDEF]: fields[5] = self.toString(self.max,quoted=quoted) if self.prompt: if quoted: sprompt = repr(self.prompt) else: sprompt = self.prompt # prompt can h... |
break del fields[i] if dolist: return fields else: return ','.join(fields) |
def _setChoice(self,s,strict=0): """Set choice parameter from string s""" clist = _getChoice(s,strict) self.choice = list(map(self._coerceValue, clist)) self._setChoiceDict() |
def _setChoiceDict(self): """Create dictionary for choice list""" # value is name of choice parameter (same as key) self.choiceDict = {} for c in self.choice: self.choiceDict[c] = c |
def _optionalPrompt(self, mode): """Interactively prompt for parameter if necessary Prompt for value if (1) mode is hidden but value is undefined or bad, or (2) mode is query and value was not set on command line Never prompt for "u" mode parameters, which are local variables. """ if (self.mode == "h") or (self.mode ==... |
self.isLegal(): self.getWithPrompt() elif self.mode == "u": # "u" is a special mode used for local variables in CL scripts # They should never prompt under any circumstances if not self.isLegal(): raise ValueError( "Attempt to access undefined local variable `%s'" % self.name) else: # query parameter if self.isCmdline(... |
def _getPFilename(self,native,prompt): """Get p_filename field for this parameter Same as get for non-list params """ return self.get(native=native,prompt=prompt) |
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("Cannot get field " + field + " for parameter " + self.name + "\n" + str(e)) i... |
IRAF returns the filename for list parameters # when p_value is used. I consider this a bug, and it does # not appear to be used by any cl scripts or SPP programs # in either IRAF or STSDAS. It is also in conflict with # the IRAF help documentation. I am making p_value exactly # the same as just a simple CL parameter |
reference. return self.get(native=native,prompt=prompt) elif field == "p_name": return self.name elif field == "p_xtype": return self.type elif field == "p_type": return self._getPType() elif field == "p_mode": return self.mode elif field == "p_prompt": return self.prompt elif field == "p_scope": return self.scope elif... |
parameter (which is the same as the value # for non-list parameters, and is the filename for list parameters) return self._getPFilename(native,prompt) elif field == "p_maximum": if native: return self.max else: return self.toString(self.max) elif field == "p_minimum": if self.choice is not None: if native: return self.... |
else: # XXX unimplemented fields: # p_length: maximum string length in bytes -- what to do with it? raise RuntimeError("Program bug in IrafPar._getField()\n" + "Requested field " + field + " for parameter " + self.name) |
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 " + self.name + "\n" + str(e)) if field == "p_prompt": self.prompt = irafutils.rem... |
for list parameters (*imcur, *gcur, etc.) self.set(value,check=check) elif field == "p_scope": self.scope = value elif field == "p_maximum": self.max = self._coerceOneValue(value) elif field == "p_minimum": if isinstance(value,str) and '|' in value: self._setChoice(irafutils.stripQuotes(value)) else: self.min = self._c... |
= irafutils.stripQuotes(value) else: raise RuntimeError("Program bug in IrafPar._setField()" + "Requested field " + field + " for parameter " + self.name) |
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: array_size = d*array_size ndim = len(self.shape) fields = (... |
fields[3] = str(ndim) next = 4 for d in self.shape: fields[next] = str(d); next += 1 fields[next] = '1'; next += 1 nvstart = 7+2*ndim if self.choice is not None: schoice = list(map(self.toString, self.choice)) schoice.insert(0,'') schoice.append('') fields[nvstart-3] = repr('|'.join(schoice)) elif self.min not in [None... |
self.max not in [None,INDEF]: fields[nvstart-2] = self.toString(self.max,quoted=quoted) if self.prompt: if quoted: sprompt = repr(self.prompt) else: sprompt = self.prompt # prompt can have embedded newlines (which are printed) sprompt = sprompt.replace(r'\012', '\n') sprompt = sprompt.replace(r'\n', '\n') fields[nvstar... |
return ','.join(fields) |
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. """ sval = list(map(self.toString, self.value,... |
"%s = [%s]" % (self.name, ', '.join(sval)) return s |
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 #XXX should change _optionalPrompt so... |
if prompt: self._optionalPrompt(mode) if index is not None: sumindex = self._sumindex(index) try: if native: return self.value[sumindex] else: return self.toString(self.value[sumindex]) except IndexError: # should never happen raise SyntaxError("Illegal index [" + repr(sumindex) + "] for array parameter " + self.name) ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.