partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Upload.put | stores a chunk of new file, this is a nop if the file already exists.
:param filename: the filename.
:param chunkIdx: the chunk idx.
:param totalChunks: the no of chunks expected.
:return: the no of bytes written and 200 or 400 if nothing was written. | backend/src/analyser/resources/upload.py | def put(self, filename, chunkIdx, totalChunks):
"""
stores a chunk of new file, this is a nop if the file already exists.
:param filename: the filename.
:param chunkIdx: the chunk idx.
:param totalChunks: the no of chunks expected.
:return: the no of bytes written and 200... | def put(self, filename, chunkIdx, totalChunks):
"""
stores a chunk of new file, this is a nop if the file already exists.
:param filename: the filename.
:param chunkIdx: the chunk idx.
:param totalChunks: the no of chunks expected.
:return: the no of bytes written and 200... | [
"stores",
"a",
"chunk",
"of",
"new",
"file",
"this",
"is",
"a",
"nop",
"if",
"the",
"file",
"already",
"exists",
".",
":",
"param",
"filename",
":",
"the",
"filename",
".",
":",
"param",
"chunkIdx",
":",
"the",
"chunk",
"idx",
".",
":",
"param",
"tot... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/upload.py#L15-L26 | [
"def",
"put",
"(",
"self",
",",
"filename",
",",
"chunkIdx",
",",
"totalChunks",
")",
":",
"logger",
".",
"info",
"(",
"'handling chunk '",
"+",
"chunkIdx",
"+",
"' of '",
"+",
"totalChunks",
"+",
"' for '",
"+",
"filename",
")",
"import",
"flask",
"bytesW... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Uploads.delete | Deletes the named file.
:param name: the name.
:return: 200 if it was deleted, 404 if it doesn't exist or 500 for anything else. | backend/src/analyser/resources/upload.py | def delete(self, name):
"""
Deletes the named file.
:param name: the name.
:return: 200 if it was deleted, 404 if it doesn't exist or 500 for anything else.
"""
try:
result = self._uploadController.delete(name)
return None, 200 if result is not Non... | def delete(self, name):
"""
Deletes the named file.
:param name: the name.
:return: 200 if it was deleted, 404 if it doesn't exist or 500 for anything else.
"""
try:
result = self._uploadController.delete(name)
return None, 200 if result is not Non... | [
"Deletes",
"the",
"named",
"file",
".",
":",
"param",
"name",
":",
"the",
"name",
".",
":",
"return",
":",
"200",
"if",
"it",
"was",
"deleted",
"404",
"if",
"it",
"doesn",
"t",
"exist",
"or",
"500",
"for",
"anything",
"else",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/upload.py#L39-L49 | [
"def",
"delete",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"result",
"=",
"self",
".",
"_uploadController",
".",
"delete",
"(",
"name",
")",
"return",
"None",
",",
"200",
"if",
"result",
"is",
"not",
"None",
"else",
"404",
"except",
"Exception",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | UploadTarget.put | Stores a new target.
:param name: the name.
:param start: start time.
:param end: end time.
:return: | backend/src/analyser/resources/upload.py | def put(self, name, start, end):
"""
Stores a new target.
:param name: the name.
:param start: start time.
:param end: end time.
:return:
"""
entry = self._uploadController.getEntry(name)
if entry is not None:
return None, 200 if self._... | def put(self, name, start, end):
"""
Stores a new target.
:param name: the name.
:param start: start time.
:param end: end time.
:return:
"""
entry = self._uploadController.getEntry(name)
if entry is not None:
return None, 200 if self._... | [
"Stores",
"a",
"new",
"target",
".",
":",
"param",
"name",
":",
"the",
"name",
".",
":",
"param",
"start",
":",
"start",
"time",
".",
":",
"param",
"end",
":",
"end",
"time",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/upload.py#L57-L69 | [
"def",
"put",
"(",
"self",
",",
"name",
",",
"start",
",",
"end",
")",
":",
"entry",
"=",
"self",
".",
"_uploadController",
".",
"getEntry",
"(",
"name",
")",
"if",
"entry",
"is",
"not",
"None",
":",
"return",
"None",
",",
"200",
"if",
"self",
".",... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | UploadAnalyser.get | :param name:
:param start:
:param end:
:param resolution:
:param window:
:return: an analysed file. | backend/src/analyser/resources/upload.py | def get(self, name, start, end, resolution, window):
"""
:param name:
:param start:
:param end:
:param resolution:
:param window:
:return: an analysed file.
"""
logger.info(
'Analysing ' + name + ' from ' + start + ' to ' + end + ' at '... | def get(self, name, start, end, resolution, window):
"""
:param name:
:param start:
:param end:
:param resolution:
:param window:
:return: an analysed file.
"""
logger.info(
'Analysing ' + name + ' from ' + start + ' to ' + end + ' at '... | [
":",
"param",
"name",
":",
":",
"param",
"start",
":",
":",
"param",
"end",
":",
":",
"param",
"resolution",
":",
":",
"param",
"window",
":",
":",
"return",
":",
"an",
"analysed",
"file",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/upload.py#L76-L106 | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"start",
",",
"end",
",",
"resolution",
",",
"window",
")",
":",
"logger",
".",
"info",
"(",
"'Analysing '",
"+",
"name",
"+",
"' from '",
"+",
"start",
"+",
"' to '",
"+",
"end",
"+",
"' at '",
"+",
"re... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | CompleteUpload.put | Completes the specified upload.
:param filename: the filename.
:param totalChunks: the no of chunks.
:param status: the status of the upload.
:return: 200. | backend/src/analyser/resources/upload.py | def put(self, filename, totalChunks, status):
"""
Completes the specified upload.
:param filename: the filename.
:param totalChunks: the no of chunks.
:param status: the status of the upload.
:return: 200.
"""
logger.info('Completing ' + filename + ' - ' +... | def put(self, filename, totalChunks, status):
"""
Completes the specified upload.
:param filename: the filename.
:param totalChunks: the no of chunks.
:param status: the status of the upload.
:return: 200.
"""
logger.info('Completing ' + filename + ' - ' +... | [
"Completes",
"the",
"specified",
"upload",
".",
":",
"param",
"filename",
":",
"the",
"filename",
".",
":",
"param",
"totalChunks",
":",
"the",
"no",
"of",
"chunks",
".",
":",
"param",
"status",
":",
"the",
"status",
"of",
"the",
"upload",
".",
":",
"r... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/upload.py#L116-L126 | [
"def",
"put",
"(",
"self",
",",
"filename",
",",
"totalChunks",
",",
"status",
")",
":",
"logger",
".",
"info",
"(",
"'Completing '",
"+",
"filename",
"+",
"' - '",
"+",
"status",
")",
"self",
".",
"_uploadController",
".",
"finalise",
"(",
"filename",
"... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Measurement.patch | Patches the metadata associated with the new measurement, if this impacts the measurement length then a new
measurement is created otherwise it just updates it in place.
:param measurementId:
:return: | backend/src/analyser/resources/measurement.py | def patch(self, measurementId):
"""
Patches the metadata associated with the new measurement, if this impacts the measurement length then a new
measurement is created otherwise it just updates it in place.
:param measurementId:
:return:
"""
data = request.get_j... | def patch(self, measurementId):
"""
Patches the metadata associated with the new measurement, if this impacts the measurement length then a new
measurement is created otherwise it just updates it in place.
:param measurementId:
:return:
"""
data = request.get_j... | [
"Patches",
"the",
"metadata",
"associated",
"with",
"the",
"new",
"measurement",
"if",
"this",
"impacts",
"the",
"measurement",
"length",
"then",
"a",
"new",
"measurement",
"is",
"created",
"otherwise",
"it",
"just",
"updates",
"it",
"in",
"place",
".",
":",
... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L27-L44 | [
"def",
"patch",
"(",
"self",
",",
"measurementId",
")",
":",
"data",
"=",
"request",
".",
"get_json",
"(",
")",
"if",
"data",
"is",
"not",
"None",
":",
"logger",
".",
"debug",
"(",
"'Received payload for '",
"+",
"measurementId",
"+",
"' - '",
"+",
"str"... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Measurement.put | Initiates a new measurement. Accepts a json payload with the following attributes;
* duration: in seconds
* startTime OR delay: a date in YMD_HMS format or a delay in seconds
* description: some free text information about the measurement
:return: | backend/src/analyser/resources/measurement.py | def put(self, measurementId):
"""
Initiates a new measurement. Accepts a json payload with the following attributes;
* duration: in seconds
* startTime OR delay: a date in YMD_HMS format or a delay in seconds
* description: some free text information about the measurement
... | def put(self, measurementId):
"""
Initiates a new measurement. Accepts a json payload with the following attributes;
* duration: in seconds
* startTime OR delay: a date in YMD_HMS format or a delay in seconds
* description: some free text information about the measurement
... | [
"Initiates",
"a",
"new",
"measurement",
".",
"Accepts",
"a",
"json",
"payload",
"with",
"the",
"following",
"attributes",
";"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L46-L68 | [
"def",
"put",
"(",
"self",
",",
"measurementId",
")",
":",
"json",
"=",
"request",
".",
"get_json",
"(",
")",
"try",
":",
"start",
"=",
"self",
".",
"_calculateStartTime",
"(",
"json",
")",
"except",
"ValueError",
":",
"return",
"'invalid date format in requ... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Measurement._calculateStartTime | Calculates an absolute start time from the json payload. This is either the given absolute start time (+2s) or
the time in delay seconds time. If the resulting date is in the past then now is returned instead.
:param json: the payload from the UI
:return: the absolute start time. | backend/src/analyser/resources/measurement.py | def _calculateStartTime(self, json):
"""
Calculates an absolute start time from the json payload. This is either the given absolute start time (+2s) or
the time in delay seconds time. If the resulting date is in the past then now is returned instead.
:param json: the payload from the UI
... | def _calculateStartTime(self, json):
"""
Calculates an absolute start time from the json payload. This is either the given absolute start time (+2s) or
the time in delay seconds time. If the resulting date is in the past then now is returned instead.
:param json: the payload from the UI
... | [
"Calculates",
"an",
"absolute",
"start",
"time",
"from",
"the",
"json",
"payload",
".",
"This",
"is",
"either",
"the",
"given",
"absolute",
"start",
"time",
"(",
"+",
"2s",
")",
"or",
"the",
"time",
"in",
"delay",
"seconds",
"time",
".",
"If",
"the",
"... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L70-L93 | [
"def",
"_calculateStartTime",
"(",
"self",
",",
"json",
")",
":",
"start",
"=",
"json",
"[",
"'startTime'",
"]",
"if",
"'startTime'",
"in",
"json",
"else",
"None",
"delay",
"=",
"json",
"[",
"'delay'",
"]",
"if",
"'delay'",
"in",
"json",
"else",
"None",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Measurement._getAbsoluteTime | Adds the delay in seconds to the start time.
:param start:
:param delay:
:return: a datetimem for the specified point in time. | backend/src/analyser/resources/measurement.py | def _getAbsoluteTime(self, start, delay):
"""
Adds the delay in seconds to the start time.
:param start:
:param delay:
:return: a datetimem for the specified point in time.
"""
return start + datetime.timedelta(days=0, seconds=delay) | def _getAbsoluteTime(self, start, delay):
"""
Adds the delay in seconds to the start time.
:param start:
:param delay:
:return: a datetimem for the specified point in time.
"""
return start + datetime.timedelta(days=0, seconds=delay) | [
"Adds",
"the",
"delay",
"in",
"seconds",
"to",
"the",
"start",
"time",
".",
":",
"param",
"start",
":",
":",
"param",
"delay",
":",
":",
"return",
":",
"a",
"datetimem",
"for",
"the",
"specified",
"point",
"in",
"time",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L95-L102 | [
"def",
"_getAbsoluteTime",
"(",
"self",
",",
"start",
",",
"delay",
")",
":",
"return",
"start",
"+",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"0",
",",
"seconds",
"=",
"delay",
")"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Measurement.delete | Deletes the named measurement.
:return: 200 if something was deleted, 404 if the measurement doesn't exist, 500 in any other case. | backend/src/analyser/resources/measurement.py | def delete(self, measurementId):
"""
Deletes the named measurement.
:return: 200 if something was deleted, 404 if the measurement doesn't exist, 500 in any other case.
"""
message, count, deleted = self._measurementController.delete(measurementId)
if count == 0:
... | def delete(self, measurementId):
"""
Deletes the named measurement.
:return: 200 if something was deleted, 404 if the measurement doesn't exist, 500 in any other case.
"""
message, count, deleted = self._measurementController.delete(measurementId)
if count == 0:
... | [
"Deletes",
"the",
"named",
"measurement",
".",
":",
"return",
":",
"200",
"if",
"something",
"was",
"deleted",
"404",
"if",
"the",
"measurement",
"doesn",
"t",
"exist",
"500",
"in",
"any",
"other",
"case",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L105-L116 | [
"def",
"delete",
"(",
"self",
",",
"measurementId",
")",
":",
"message",
",",
"count",
",",
"deleted",
"=",
"self",
".",
"_measurementController",
".",
"delete",
"(",
"measurementId",
")",
"if",
"count",
"==",
"0",
":",
"return",
"message",
",",
"404",
"... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | InitialiseMeasurement.put | Initialises the measurement session from the given device.
:param measurementId:
:param deviceId:
:return: | backend/src/analyser/resources/measurement.py | def put(self, measurementId, deviceId):
"""
Initialises the measurement session from the given device.
:param measurementId:
:param deviceId:
:return:
"""
logger.info('Starting measurement ' + measurementId + ' for ' + deviceId)
if self._measurementControl... | def put(self, measurementId, deviceId):
"""
Initialises the measurement session from the given device.
:param measurementId:
:param deviceId:
:return:
"""
logger.info('Starting measurement ' + measurementId + ' for ' + deviceId)
if self._measurementControl... | [
"Initialises",
"the",
"measurement",
"session",
"from",
"the",
"given",
"device",
".",
":",
"param",
"measurementId",
":",
":",
"param",
"deviceId",
":",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L123-L136 | [
"def",
"put",
"(",
"self",
",",
"measurementId",
",",
"deviceId",
")",
":",
"logger",
".",
"info",
"(",
"'Starting measurement '",
"+",
"measurementId",
"+",
"' for '",
"+",
"deviceId",
")",
"if",
"self",
".",
"_measurementController",
".",
"startMeasurement",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | RecordData.put | Store a bunch of data for this measurement session.
:param measurementId:
:param deviceId:
:return: | backend/src/analyser/resources/measurement.py | def put(self, measurementId, deviceId):
"""
Store a bunch of data for this measurement session.
:param measurementId:
:param deviceId:
:return:
"""
data = request.get_json()
if data is not None:
parsedData = json.loads(data)
logger.... | def put(self, measurementId, deviceId):
"""
Store a bunch of data for this measurement session.
:param measurementId:
:param deviceId:
:return:
"""
data = request.get_json()
if data is not None:
parsedData = json.loads(data)
logger.... | [
"Store",
"a",
"bunch",
"of",
"data",
"for",
"this",
"measurement",
"session",
".",
":",
"param",
"measurementId",
":",
":",
"param",
"deviceId",
":",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L143-L162 | [
"def",
"put",
"(",
"self",
",",
"measurementId",
",",
"deviceId",
")",
":",
"data",
"=",
"request",
".",
"get_json",
"(",
")",
"if",
"data",
"is",
"not",
"None",
":",
"parsedData",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"logger",
".",
"debug",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | FailMeasurement.put | Fails the measurement for this device.
:param measurementId: the measurement name.
:param deviceId: the device name.
:return: 200 if | backend/src/analyser/resources/measurement.py | def put(self, measurementId, deviceId):
"""
Fails the measurement for this device.
:param measurementId: the measurement name.
:param deviceId: the device name.
:return: 200 if
"""
payload = request.get_json()
failureReason = json.loads(payload).get('failu... | def put(self, measurementId, deviceId):
"""
Fails the measurement for this device.
:param measurementId: the measurement name.
:param deviceId: the device name.
:return: 200 if
"""
payload = request.get_json()
failureReason = json.loads(payload).get('failu... | [
"Fails",
"the",
"measurement",
"for",
"this",
"device",
".",
":",
"param",
"measurementId",
":",
"the",
"measurement",
"name",
".",
":",
"param",
"deviceId",
":",
"the",
"device",
"name",
".",
":",
"return",
":",
"200",
"if"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurement.py#L189-L204 | [
"def",
"put",
"(",
"self",
",",
"measurementId",
",",
"deviceId",
")",
":",
"payload",
"=",
"request",
".",
"get_json",
"(",
")",
"failureReason",
"=",
"json",
".",
"loads",
"(",
"payload",
")",
".",
"get",
"(",
"'failureReason'",
")",
"if",
"payload",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | MeasurementDevice.put | Puts a new device into the device store
:param deviceId:
:return: | backend/src/analyser/resources/measurementdevices.py | def put(self, deviceId):
"""
Puts a new device into the device store
:param deviceId:
:return:
"""
device = request.get_json()
logger.debug("Received /devices/" + deviceId + " - " + str(device))
self._deviceController.accept(deviceId, device)
retur... | def put(self, deviceId):
"""
Puts a new device into the device store
:param deviceId:
:return:
"""
device = request.get_json()
logger.debug("Received /devices/" + deviceId + " - " + str(device))
self._deviceController.accept(deviceId, device)
retur... | [
"Puts",
"a",
"new",
"device",
"into",
"the",
"device",
"store",
":",
"param",
"deviceId",
":",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurementdevices.py#L32-L41 | [
"def",
"put",
"(",
"self",
",",
"deviceId",
")",
":",
"device",
"=",
"request",
".",
"get_json",
"(",
")",
"logger",
".",
"debug",
"(",
"\"Received /devices/\"",
"+",
"deviceId",
"+",
"\" - \"",
"+",
"str",
"(",
"device",
")",
")",
"self",
".",
"_devic... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | printColsAuto | Print a list of strings centered in columns. Determine the number
of columns and lines on the fly. Return the result, ready to print.
in_strings is a list/tuple/iterable of strings
min_pad is number of spaces to appear on each side of a single string (so
you will see twice this many spaces bet... | lib/stsci/tools/irafutils.py | def printColsAuto(in_strings, term_width=80, min_pad=1):
""" Print a list of strings centered in columns. Determine the number
of columns and lines on the fly. Return the result, ready to print.
in_strings is a list/tuple/iterable of strings
min_pad is number of spaces to appear on each side of a sing... | def printColsAuto(in_strings, term_width=80, min_pad=1):
""" Print a list of strings centered in columns. Determine the number
of columns and lines on the fly. Return the result, ready to print.
in_strings is a list/tuple/iterable of strings
min_pad is number of spaces to appear on each side of a sing... | [
"Print",
"a",
"list",
"of",
"strings",
"centered",
"in",
"columns",
".",
"Determine",
"the",
"number",
"of",
"columns",
"and",
"lines",
"on",
"the",
"fly",
".",
"Return",
"the",
"result",
"ready",
"to",
"print",
".",
"in_strings",
"is",
"a",
"list",
"/",... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L42-L72 | [
"def",
"printColsAuto",
"(",
"in_strings",
",",
"term_width",
"=",
"80",
",",
"min_pad",
"=",
"1",
")",
":",
"# sanity check",
"assert",
"in_strings",
"and",
"len",
"(",
"in_strings",
")",
">",
"0",
",",
"'Unexpected: '",
"+",
"repr",
"(",
"in_strings",
")... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | printCols | Print elements of list in cols columns | lib/stsci/tools/irafutils.py | def printCols(strlist,cols=5,width=80):
"""Print elements of list in cols columns"""
# This may exist somewhere in the Python standard libraries?
# Should probably rewrite this, it is pretty crude.
nlines = (len(strlist)+cols-1)//cols
line = nlines*[""]
for i in range(len(strlist)):
c... | def printCols(strlist,cols=5,width=80):
"""Print elements of list in cols columns"""
# This may exist somewhere in the Python standard libraries?
# Should probably rewrite this, it is pretty crude.
nlines = (len(strlist)+cols-1)//cols
line = nlines*[""]
for i in range(len(strlist)):
c... | [
"Print",
"elements",
"of",
"list",
"in",
"cols",
"columns"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L75-L92 | [
"def",
"printCols",
"(",
"strlist",
",",
"cols",
"=",
"5",
",",
"width",
"=",
"80",
")",
":",
"# This may exist somewhere in the Python standard libraries?",
"# Should probably rewrite this, it is pretty crude.",
"nlines",
"=",
"(",
"len",
"(",
"strlist",
")",
"+",
"c... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | stripQuotes | Strip single or double quotes off string; remove embedded quote pairs | lib/stsci/tools/irafutils.py | def stripQuotes(value):
"""Strip single or double quotes off string; remove embedded quote pairs"""
if value[:1] == '"':
value = value[1:]
if value[-1:] == '"':
value = value[:-1]
# replace "" with "
value = re.sub(_re_doubleq2, '"', value)
elif value[:1] == "'"... | def stripQuotes(value):
"""Strip single or double quotes off string; remove embedded quote pairs"""
if value[:1] == '"':
value = value[1:]
if value[-1:] == '"':
value = value[:-1]
# replace "" with "
value = re.sub(_re_doubleq2, '"', value)
elif value[:1] == "'"... | [
"Strip",
"single",
"or",
"double",
"quotes",
"off",
"string",
";",
"remove",
"embedded",
"quote",
"pairs"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L97-L113 | [
"def",
"stripQuotes",
"(",
"value",
")",
":",
"if",
"value",
"[",
":",
"1",
"]",
"==",
"'\"'",
":",
"value",
"=",
"value",
"[",
"1",
":",
"]",
"if",
"value",
"[",
"-",
"1",
":",
"]",
"==",
"'\"'",
":",
"value",
"=",
"value",
"[",
":",
"-",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | csvSplit | Take a string as input (e.g. a line in a csv text file), and break
it into tokens separated by commas while ignoring commas embedded inside
quoted sections. This is exactly what the 'csv' module is meant for, so
we *should* be using it, save that it has two bugs (described next) which
limit our use of ... | lib/stsci/tools/irafutils.py | def csvSplit(line, delim=',', allowEol=True):
""" Take a string as input (e.g. a line in a csv text file), and break
it into tokens separated by commas while ignoring commas embedded inside
quoted sections. This is exactly what the 'csv' module is meant for, so
we *should* be using it, save that it has... | def csvSplit(line, delim=',', allowEol=True):
""" Take a string as input (e.g. a line in a csv text file), and break
it into tokens separated by commas while ignoring commas embedded inside
quoted sections. This is exactly what the 'csv' module is meant for, so
we *should* be using it, save that it has... | [
"Take",
"a",
"string",
"as",
"input",
"(",
"e",
".",
"g",
".",
"a",
"line",
"in",
"a",
"csv",
"text",
"file",
")",
"and",
"break",
"it",
"into",
"tokens",
"separated",
"by",
"commas",
"while",
"ignoring",
"commas",
"embedded",
"inside",
"quoted",
"sect... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L115-L178 | [
"def",
"csvSplit",
"(",
"line",
",",
"delim",
"=",
"','",
",",
"allowEol",
"=",
"True",
")",
":",
"# Algorithm: read chars left to right, go from delimiter to delimiter,",
"# but as soon as a single/double/triple quote is hit, scan forward",
"# (ignoring all else) until its matching... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | rglob | Same thing as glob.glob, but recursively checks subdirs. | lib/stsci/tools/irafutils.py | def rglob(root, pattern):
""" Same thing as glob.glob, but recursively checks subdirs. """
# Thanks to Alex Martelli for basics on Stack Overflow
retlist = []
if None not in (pattern, root):
for base, dirs, files in os.walk(root):
goodfiles = fnmatch.filter(files, pattern)
... | def rglob(root, pattern):
""" Same thing as glob.glob, but recursively checks subdirs. """
# Thanks to Alex Martelli for basics on Stack Overflow
retlist = []
if None not in (pattern, root):
for base, dirs, files in os.walk(root):
goodfiles = fnmatch.filter(files, pattern)
... | [
"Same",
"thing",
"as",
"glob",
".",
"glob",
"but",
"recursively",
"checks",
"subdirs",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L266-L274 | [
"def",
"rglob",
"(",
"root",
",",
"pattern",
")",
":",
"# Thanks to Alex Martelli for basics on Stack Overflow",
"retlist",
"=",
"[",
"]",
"if",
"None",
"not",
"in",
"(",
"pattern",
",",
"root",
")",
":",
"for",
"base",
",",
"dirs",
",",
"files",
"in",
"os... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | setWritePrivs | Set a file named fname to be writable (or not) by user, with the
option to ignore errors. There is nothing ground-breaking here, but I
was annoyed with having to repeate this little bit of code. | lib/stsci/tools/irafutils.py | def setWritePrivs(fname, makeWritable, ignoreErrors=False):
""" Set a file named fname to be writable (or not) by user, with the
option to ignore errors. There is nothing ground-breaking here, but I
was annoyed with having to repeate this little bit of code. """
privs = os.stat(fname).st_mode
try:
... | def setWritePrivs(fname, makeWritable, ignoreErrors=False):
""" Set a file named fname to be writable (or not) by user, with the
option to ignore errors. There is nothing ground-breaking here, but I
was annoyed with having to repeate this little bit of code. """
privs = os.stat(fname).st_mode
try:
... | [
"Set",
"a",
"file",
"named",
"fname",
"to",
"be",
"writable",
"(",
"or",
"not",
")",
"by",
"user",
"with",
"the",
"option",
"to",
"ignore",
"errors",
".",
"There",
"is",
"nothing",
"ground",
"-",
"breaking",
"here",
"but",
"I",
"was",
"annoyed",
"with"... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L276-L290 | [
"def",
"setWritePrivs",
"(",
"fname",
",",
"makeWritable",
",",
"ignoreErrors",
"=",
"False",
")",
":",
"privs",
"=",
"os",
".",
"stat",
"(",
"fname",
")",
".",
"st_mode",
"try",
":",
"if",
"makeWritable",
":",
"os",
".",
"chmod",
"(",
"fname",
",",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | removeEscapes | Remove escapes from in front of quotes (which IRAF seems to
just stick in for fun sometimes.) Remove \-newline too.
If quoted is true, removes all blanks following \-newline
(which is a nasty thing IRAF does for continuations inside
quoted strings.)
XXX Should we remove \\ too? | lib/stsci/tools/irafutils.py | def removeEscapes(value, quoted=0):
"""Remove escapes from in front of quotes (which IRAF seems to
just stick in for fun sometimes.) Remove \-newline too.
If quoted is true, removes all blanks following \-newline
(which is a nasty thing IRAF does for continuations inside
quoted strings.)
XXX S... | def removeEscapes(value, quoted=0):
"""Remove escapes from in front of quotes (which IRAF seems to
just stick in for fun sometimes.) Remove \-newline too.
If quoted is true, removes all blanks following \-newline
(which is a nasty thing IRAF does for continuations inside
quoted strings.)
XXX S... | [
"Remove",
"escapes",
"from",
"in",
"front",
"of",
"quotes",
"(",
"which",
"IRAF",
"seems",
"to",
"just",
"stick",
"in",
"for",
"fun",
"sometimes",
".",
")",
"Remove",
"\\",
"-",
"newline",
"too",
".",
"If",
"quoted",
"is",
"true",
"removes",
"all",
"bl... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L293-L323 | [
"def",
"removeEscapes",
"(",
"value",
",",
"quoted",
"=",
"0",
")",
":",
"i",
"=",
"value",
".",
"find",
"(",
"r'\\\"'",
")",
"while",
"i",
">=",
"0",
":",
"value",
"=",
"value",
"[",
":",
"i",
"]",
"+",
"value",
"[",
"i",
"+",
"1",
":",
"]",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | translateName | Convert CL parameter or variable name to Python-acceptable name
Translate embedded dollar signs to 'DOLLAR'
Add 'PY' prefix to components that are Python reserved words
Add 'PY' prefix to components start with a number
If dot != 0, also replaces '.' with 'DOT' | lib/stsci/tools/irafutils.py | def translateName(s, dot=0):
"""Convert CL parameter or variable name to Python-acceptable name
Translate embedded dollar signs to 'DOLLAR'
Add 'PY' prefix to components that are Python reserved words
Add 'PY' prefix to components start with a number
If dot != 0, also replaces '.' with 'DOT'
"... | def translateName(s, dot=0):
"""Convert CL parameter or variable name to Python-acceptable name
Translate embedded dollar signs to 'DOLLAR'
Add 'PY' prefix to components that are Python reserved words
Add 'PY' prefix to components start with a number
If dot != 0, also replaces '.' with 'DOT'
"... | [
"Convert",
"CL",
"parameter",
"or",
"variable",
"name",
"to",
"Python",
"-",
"acceptable",
"name"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L329-L348 | [
"def",
"translateName",
"(",
"s",
",",
"dot",
"=",
"0",
")",
":",
"s",
"=",
"s",
".",
"replace",
"(",
"'$'",
",",
"'DOLLAR'",
")",
"sparts",
"=",
"s",
".",
"split",
"(",
"'.'",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"sparts",
")",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | init_tk_default_root | In case the _default_root value is required, you may
safely call this ahead of time to ensure that it has been
initialized. If it has already been, this is a no-op. | lib/stsci/tools/irafutils.py | def init_tk_default_root(withdraw=True):
""" In case the _default_root value is required, you may
safely call this ahead of time to ensure that it has been
initialized. If it has already been, this is a no-op.
"""
if not capable.OF_GRAPHICS:
raise RuntimeError("Cannot run this command with... | def init_tk_default_root(withdraw=True):
""" In case the _default_root value is required, you may
safely call this ahead of time to ensure that it has been
initialized. If it has already been, this is a no-op.
"""
if not capable.OF_GRAPHICS:
raise RuntimeError("Cannot run this command with... | [
"In",
"case",
"the",
"_default_root",
"value",
"is",
"required",
"you",
"may",
"safely",
"call",
"this",
"ahead",
"of",
"time",
"to",
"ensure",
"that",
"it",
"has",
"been",
"initialized",
".",
"If",
"it",
"has",
"already",
"been",
"this",
"is",
"a",
"no"... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L363-L380 | [
"def",
"init_tk_default_root",
"(",
"withdraw",
"=",
"True",
")",
":",
"if",
"not",
"capable",
".",
"OF_GRAPHICS",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot run this command without graphics\"",
")",
"if",
"not",
"TKNTR",
".",
"_default_root",
":",
"# TKNTR impor... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | tkreadline | Read a line from file while running Tk mainloop.
If the file is not line-buffered then the Tk mainloop will stop
running after one character is typed. The function will still work
but Tk widgets will stop updating. This should work OK for stdin and
other line-buffered filehandles. If file is omitted... | lib/stsci/tools/irafutils.py | def tkreadline(file=None):
"""Read a line from file while running Tk mainloop.
If the file is not line-buffered then the Tk mainloop will stop
running after one character is typed. The function will still work
but Tk widgets will stop updating. This should work OK for stdin and
other line-buffer... | def tkreadline(file=None):
"""Read a line from file while running Tk mainloop.
If the file is not line-buffered then the Tk mainloop will stop
running after one character is typed. The function will still work
but Tk widgets will stop updating. This should work OK for stdin and
other line-buffer... | [
"Read",
"a",
"line",
"from",
"file",
"while",
"running",
"Tk",
"mainloop",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L394-L430 | [
"def",
"tkreadline",
"(",
"file",
"=",
"None",
")",
":",
"if",
"file",
"is",
"None",
":",
"file",
"=",
"sys",
".",
"stdin",
"if",
"not",
"hasattr",
"(",
"file",
",",
"\"readline\"",
")",
":",
"raise",
"TypeError",
"(",
"\"file must be a filehandle with a r... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | launchBrowser | Given a URL, try to pop it up in a browser on most platforms.
brow_bin is only used on OS's where there is no "open" or "start" cmd. | lib/stsci/tools/irafutils.py | def launchBrowser(url, brow_bin='mozilla', subj=None):
""" Given a URL, try to pop it up in a browser on most platforms.
brow_bin is only used on OS's where there is no "open" or "start" cmd.
"""
if not subj: subj = url
# Tries to use webbrowser module on most OSes, unless a system command
# i... | def launchBrowser(url, brow_bin='mozilla', subj=None):
""" Given a URL, try to pop it up in a browser on most platforms.
brow_bin is only used on OS's where there is no "open" or "start" cmd.
"""
if not subj: subj = url
# Tries to use webbrowser module on most OSes, unless a system command
# i... | [
"Given",
"a",
"URL",
"try",
"to",
"pop",
"it",
"up",
"in",
"a",
"browser",
"on",
"most",
"platforms",
".",
"brow_bin",
"is",
"only",
"used",
"on",
"OS",
"s",
"where",
"there",
"is",
"no",
"open",
"or",
"start",
"cmd",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L496-L530 | [
"def",
"launchBrowser",
"(",
"url",
",",
"brow_bin",
"=",
"'mozilla'",
",",
"subj",
"=",
"None",
")",
":",
"if",
"not",
"subj",
":",
"subj",
"=",
"url",
"# Tries to use webbrowser module on most OSes, unless a system command",
"# is needed. (E.g. win, linux, sun, etc)",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | _TkRead.read | Read nbytes characters from file while running Tk mainloop | lib/stsci/tools/irafutils.py | def read(self, file, nbytes):
"""Read nbytes characters from file while running Tk mainloop"""
if not capable.OF_GRAPHICS:
raise RuntimeError("Cannot run this command without graphics")
if isinstance(file, int):
fd = file
else:
# Otherwise, assume we h... | def read(self, file, nbytes):
"""Read nbytes characters from file while running Tk mainloop"""
if not capable.OF_GRAPHICS:
raise RuntimeError("Cannot run this command without graphics")
if isinstance(file, int):
fd = file
else:
# Otherwise, assume we h... | [
"Read",
"nbytes",
"characters",
"from",
"file",
"while",
"running",
"Tk",
"mainloop"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L436-L475 | [
"def",
"read",
"(",
"self",
",",
"file",
",",
"nbytes",
")",
":",
"if",
"not",
"capable",
".",
"OF_GRAPHICS",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot run this command without graphics\"",
")",
"if",
"isinstance",
"(",
"file",
",",
"int",
")",
":",
"fd",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | _TkRead._read | Read waiting data and terminate Tk mainloop if done | lib/stsci/tools/irafutils.py | def _read(self, fd, mask):
"""Read waiting data and terminate Tk mainloop if done"""
try:
# if EOF was encountered on a tty, avoid reading again because
# it actually requests more data
if select.select([fd],[],[],0)[0]:
snew = os.read(fd, self.nbytes)... | def _read(self, fd, mask):
"""Read waiting data and terminate Tk mainloop if done"""
try:
# if EOF was encountered on a tty, avoid reading again because
# it actually requests more data
if select.select([fd],[],[],0)[0]:
snew = os.read(fd, self.nbytes)... | [
"Read",
"waiting",
"data",
"and",
"terminate",
"Tk",
"mainloop",
"if",
"done"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/irafutils.py#L478-L494 | [
"def",
"_read",
"(",
"self",
",",
"fd",
",",
"mask",
")",
":",
"try",
":",
"# if EOF was encountered on a tty, avoid reading again because",
"# it actually requests more data",
"if",
"select",
".",
"select",
"(",
"[",
"fd",
"]",
",",
"[",
"]",
",",
"[",
"]",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | loadSignalFromDelimitedFile | reads a delimited file and converts into a Signal
:param filename: string
:param timeColumnIdx: 0 indexed column number
:param dataColumnIdx: 0 indexed column number
:param delimiter: char
:return a Signal instance | backend/src/analyser/common/signal.py | def loadSignalFromDelimitedFile(filename, timeColumnIdx=0, dataColumnIdx=1, delimiter=',', skipHeader=0) -> Signal:
""" reads a delimited file and converts into a Signal
:param filename: string
:param timeColumnIdx: 0 indexed column number
:param dataColumnIdx: 0 indexed column number
:param delimit... | def loadSignalFromDelimitedFile(filename, timeColumnIdx=0, dataColumnIdx=1, delimiter=',', skipHeader=0) -> Signal:
""" reads a delimited file and converts into a Signal
:param filename: string
:param timeColumnIdx: 0 indexed column number
:param dataColumnIdx: 0 indexed column number
:param delimit... | [
"reads",
"a",
"delimited",
"file",
"and",
"converts",
"into",
"a",
"Signal",
":",
"param",
"filename",
":",
"string",
":",
"param",
"timeColumnIdx",
":",
"0",
"indexed",
"column",
"number",
":",
"param",
"dataColumnIdx",
":",
"0",
"indexed",
"column",
"numbe... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L208-L230 | [
"def",
"loadSignalFromDelimitedFile",
"(",
"filename",
",",
"timeColumnIdx",
"=",
"0",
",",
"dataColumnIdx",
"=",
"1",
",",
"delimiter",
"=",
"','",
",",
"skipHeader",
"=",
"0",
")",
"->",
"Signal",
":",
"data",
"=",
"np",
".",
"genfromtxt",
"(",
"filename... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | loadSignalFromWav | reads a wav file into a Signal and scales the input so that the sample are expressed in real world values
(as defined by the calibration signal).
:param inputSignalFile: a path to the input signal file
:param calibrationSignalFile: a path the calibration signal file
:param calibrationRealWorldValue: the... | backend/src/analyser/common/signal.py | def loadSignalFromWav(inputSignalFile, calibrationRealWorldValue=None, calibrationSignalFile=None, start=None,
end=None) -> Signal:
""" reads a wav file into a Signal and scales the input so that the sample are expressed in real world values
(as defined by the calibration signal).
:par... | def loadSignalFromWav(inputSignalFile, calibrationRealWorldValue=None, calibrationSignalFile=None, start=None,
end=None) -> Signal:
""" reads a wav file into a Signal and scales the input so that the sample are expressed in real world values
(as defined by the calibration signal).
:par... | [
"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",
... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L233-L249 | [
"def",
"loadSignalFromWav",
"(",
"inputSignalFile",
",",
"calibrationRealWorldValue",
"=",
"None",
",",
"calibrationSignalFile",
"=",
"None",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
"->",
"Signal",
":",
"inputSignal",
"=",
"readWav",
"(",
"inp... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | readWav | reads a wav file into a Signal.
:param inputSignalFile: a path to the input signal file
:param selectedChannel: the channel to read.
:param start: the time to start reading from in HH:mm:ss.SSS format.
:param end: the time to end reading from in HH:mm:ss.SSS format.
:returns: Signal. | backend/src/analyser/common/signal.py | def readWav(inputSignalFile, selectedChannel=1, start=None, end=None) -> Signal:
""" reads a wav file into a Signal.
:param inputSignalFile: a path to the input signal file
:param selectedChannel: the channel to read.
:param start: the time to start reading from in HH:mm:ss.SSS format.
:param end: t... | def readWav(inputSignalFile, selectedChannel=1, start=None, end=None) -> Signal:
""" reads a wav file into a Signal.
:param inputSignalFile: a path to the input signal file
:param selectedChannel: the channel to read.
:param start: the time to start reading from in HH:mm:ss.SSS format.
:param end: t... | [
"reads",
"a",
"wav",
"file",
"into",
"a",
"Signal",
".",
":",
"param",
"inputSignalFile",
":",
"a",
"path",
"to",
"the",
"input",
"signal",
"file",
":",
"param",
"selectedChannel",
":",
"the",
"channel",
"to",
"read",
".",
":",
"param",
"start",
":",
"... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L252-L277 | [
"def",
"readWav",
"(",
"inputSignalFile",
",",
"selectedChannel",
"=",
"1",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
"->",
"Signal",
":",
"def",
"asFrames",
"(",
"time",
",",
"fs",
")",
":",
"hours",
",",
"minutes",
",",
"seconds",
"=... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | loadTriAxisSignalFromFile | A factory method for loading a tri axis measurement from a single file.
:param filename: the file to load from.
:param timeColumnIdx: the column containing time data.
:param xIdx: the column containing x axis data.
:param yIdx: the column containing y axis data.
:param zIdx: the column containing z ... | backend/src/analyser/common/signal.py | def loadTriAxisSignalFromFile(filename, timeColumnIdx=0, xIdx=1, yIdx=2, zIdx=3, delimiter=',',
skipHeader=0) -> TriAxisSignal:
"""
A factory method for loading a tri axis measurement from a single file.
:param filename: the file to load from.
:param timeColumnIdx: the colu... | def loadTriAxisSignalFromFile(filename, timeColumnIdx=0, xIdx=1, yIdx=2, zIdx=3, delimiter=',',
skipHeader=0) -> TriAxisSignal:
"""
A factory method for loading a tri axis measurement from a single file.
:param filename: the file to load from.
:param timeColumnIdx: the colu... | [
"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",
... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L381-L400 | [
"def",
"loadTriAxisSignalFromFile",
"(",
"filename",
",",
"timeColumnIdx",
"=",
"0",
",",
"xIdx",
"=",
"1",
",",
"yIdx",
"=",
"2",
",",
"zIdx",
"=",
"3",
",",
"delimiter",
"=",
"','",
",",
"skipHeader",
"=",
"0",
")",
"->",
"TriAxisSignal",
":",
"retur... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Signal.psd | analyses the source and returns a PSD, segment is set to get ~1Hz frequency resolution
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:param mode: cq or none.
:return:
f : ndarray
Array of sample fr... | backend/src/analyser/common/signal.py | def psd(self, ref=None, segmentLengthMultiplier=1, mode=None, **kwargs):
"""
analyses the source and returns a PSD, segment is set to get ~1Hz frequency resolution
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:pa... | def psd(self, ref=None, segmentLengthMultiplier=1, mode=None, **kwargs):
"""
analyses the source and returns a PSD, segment is set to get ~1Hz frequency resolution
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:pa... | [
"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",
"... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L67-L90 | [
"def",
"psd",
"(",
"self",
",",
"ref",
"=",
"None",
",",
"segmentLengthMultiplier",
"=",
"1",
",",
"mode",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"analysisFunc",
"(",
"x",
",",
"nperseg",
",",
"*",
"*",
"kwargs",
")",
":",
"f",
",... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Signal.spectrum | analyses the source to generate the linear spectrum.
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:param mode: cq or none.
:return:
f : ndarray
Array of sample frequencies.
Pxx : ndarr... | backend/src/analyser/common/signal.py | def spectrum(self, ref=None, segmentLengthMultiplier=1, mode=None, **kwargs):
"""
analyses the source to generate the linear spectrum.
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:param mode: cq or none.
... | def spectrum(self, ref=None, segmentLengthMultiplier=1, mode=None, **kwargs):
"""
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.
... | [
"analyses",
"the",
"source",
"to",
"generate",
"the",
"linear",
"spectrum",
".",
":",
"param",
"ref",
":",
"the",
"reference",
"value",
"for",
"dB",
"purposes",
".",
":",
"param",
"segmentLengthMultiplier",
":",
"allow",
"for",
"increased",
"resolution",
".",
... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L92-L120 | [
"def",
"spectrum",
"(",
"self",
",",
"ref",
"=",
"None",
",",
"segmentLengthMultiplier",
"=",
"1",
",",
"mode",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"analysisFunc",
"(",
"x",
",",
"nperseg",
",",
"*",
"*",
"kwargs",
")",
":",
"f",... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Signal.peakSpectrum | analyses the source to generate the max values per bin per segment
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:param mode: cq or none.
:return:
f : ndarray
Array of sample frequencies.
... | backend/src/analyser/common/signal.py | def peakSpectrum(self, ref=None, segmentLengthMultiplier=1, mode=None, window='hann'):
"""
analyses the source to generate the max values per bin per segment
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:param mo... | def peakSpectrum(self, ref=None, segmentLengthMultiplier=1, mode=None, window='hann'):
"""
analyses the source to generate the max values per bin per segment
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:param mo... | [
"analyses",
"the",
"source",
"to",
"generate",
"the",
"max",
"values",
"per",
"bin",
"per",
"segment",
":",
"param",
"ref",
":",
"the",
"reference",
"value",
"for",
"dB",
"purposes",
".",
":",
"param",
"segmentLengthMultiplier",
":",
"allow",
"for",
"increas... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L122-L153 | [
"def",
"peakSpectrum",
"(",
"self",
",",
"ref",
"=",
"None",
",",
"segmentLengthMultiplier",
"=",
"1",
",",
"mode",
"=",
"None",
",",
"window",
"=",
"'hann'",
")",
":",
"def",
"analysisFunc",
"(",
"x",
",",
"nperseg",
")",
":",
"freqs",
",",
"_",
","... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Signal.spectrogram | 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.
... | backend/src/analyser/common/signal.py | def spectrogram(self, ref=None, segmentLengthMultiplier=1, window='hann'):
"""
analyses the source to generate a spectrogram
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:return:
t : ndarray
... | def spectrogram(self, ref=None, segmentLengthMultiplier=1, window='hann'):
"""
analyses the source to generate a spectrogram
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:return:
t : ndarray
... | [
"analyses",
"the",
"source",
"to",
"generate",
"a",
"spectrogram",
":",
"param",
"ref",
":",
"the",
"reference",
"value",
"for",
"dB",
"purposes",
".",
":",
"param",
"segmentLengthMultiplier",
":",
"allow",
"for",
"increased",
"resolution",
".",
":",
"return",... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L155-L177 | [
"def",
"spectrogram",
"(",
"self",
",",
"ref",
"=",
"None",
",",
"segmentLengthMultiplier",
"=",
"1",
",",
"window",
"=",
"'hann'",
")",
":",
"t",
",",
"f",
",",
"Sxx",
"=",
"signal",
".",
"spectrogram",
"(",
"self",
".",
"samples",
",",
"self",
".",... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Signal.lowPass | Creates a copy of the signal with the low pass applied, args specifed are passed through to _butter.
:return: | backend/src/analyser/common/signal.py | def lowPass(self, *args):
"""
Creates a copy of the signal with the low pass applied, args specifed are passed through to _butter.
:return:
"""
return Signal(self._butter(self.samples, 'low', *args), fs=self.fs) | def lowPass(self, *args):
"""
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) | [
"Creates",
"a",
"copy",
"of",
"the",
"signal",
"with",
"the",
"low",
"pass",
"applied",
"args",
"specifed",
"are",
"passed",
"through",
"to",
"_butter",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L179-L184 | [
"def",
"lowPass",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"Signal",
"(",
"self",
".",
"_butter",
"(",
"self",
".",
"samples",
",",
"'low'",
",",
"*",
"args",
")",
",",
"fs",
"=",
"self",
".",
"fs",
")"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Signal.highPass | Creates a copy of the signal with the high pass applied, args specifed are passed through to _butter.
:return: | backend/src/analyser/common/signal.py | def highPass(self, *args):
"""
Creates a copy of the signal with the high pass applied, args specifed are passed through to _butter.
:return:
"""
return Signal(self._butter(self.samples, 'high', *args), fs=self.fs) | def highPass(self, *args):
"""
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) | [
"Creates",
"a",
"copy",
"of",
"the",
"signal",
"with",
"the",
"high",
"pass",
"applied",
"args",
"specifed",
"are",
"passed",
"through",
"to",
"_butter",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L186-L191 | [
"def",
"highPass",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"Signal",
"(",
"self",
".",
"_butter",
"(",
"self",
".",
"samples",
",",
"'high'",
",",
"*",
"args",
")",
",",
"fs",
"=",
"self",
".",
"fs",
")"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Signal._butter | Applies a digital butterworth filter via filtfilt at the specified f3 and order. Default values are set to
correspond to apparently sensible filters that distinguish between vibration and tilt from an accelerometer.
:param data: the data to filter.
:param btype: high or low.
:param f3: ... | backend/src/analyser/common/signal.py | def _butter(self, data, btype, f3=2, order=2):
"""
Applies a digital butterworth filter via filtfilt at the specified f3 and order. Default values are set to
correspond to apparently sensible filters that distinguish between vibration and tilt from an accelerometer.
:param data: the dat... | def _butter(self, data, btype, f3=2, order=2):
"""
Applies a digital butterworth filter via filtfilt at the specified f3 and order. Default values are set to
correspond to apparently sensible filters that distinguish between vibration and tilt from an accelerometer.
:param data: the dat... | [
"Applies",
"a",
"digital",
"butterworth",
"filter",
"via",
"filtfilt",
"at",
"the",
"specified",
"f3",
"and",
"order",
".",
"Default",
"values",
"are",
"set",
"to",
"correspond",
"to",
"apparently",
"sensible",
"filters",
"that",
"distinguish",
"between",
"vibra... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L193-L205 | [
"def",
"_butter",
"(",
"self",
",",
"data",
",",
"btype",
",",
"f3",
"=",
"2",
",",
"order",
"=",
"2",
")",
":",
"b",
",",
"a",
"=",
"signal",
".",
"butter",
"(",
"order",
",",
"f3",
"/",
"(",
"0.5",
"*",
"self",
".",
"fs",
")",
",",
"btype... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | TriAxisSignal._getAnalysis | 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. | backend/src/analyser/common/signal.py | def _getAnalysis(self, axis, analysis, ref=None):
"""
gets the named analysis on the given axis and caches the result (or reads from the cache if data is available
already)
:param axis: the named axis.
:param analysis: the analysis name.
:return: the analysis tuple.
... | def _getAnalysis(self, axis, analysis, ref=None):
"""
gets the named analysis on the given axis and caches the result (or reads from the cache if data is available
already)
:param axis: the named axis.
:param analysis: the analysis name.
:return: the analysis tuple.
... | [
"gets",
"the",
"named",
"analysis",
"on",
"the",
"given",
"axis",
"and",
"caches",
"the",
"result",
"(",
"or",
"reads",
"from",
"the",
"cache",
"if",
"data",
"is",
"available",
"already",
")",
":",
"param",
"axis",
":",
"the",
"named",
"axis",
".",
":"... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L346-L378 | [
"def",
"_getAnalysis",
"(",
"self",
",",
"axis",
",",
"analysis",
",",
"ref",
"=",
"None",
")",
":",
"cache",
"=",
"self",
".",
"cache",
".",
"get",
"(",
"str",
"(",
"ref",
")",
")",
"if",
"cache",
"is",
"None",
":",
"cache",
"=",
"{",
"'x'",
"... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | legal_date | Checks if a given date is a legal positivist date | convertdate/positivist.py | def legal_date(year, month, day):
'''Checks if a given date is a legal positivist date'''
try:
assert year >= 1
assert 0 < month <= 14
assert 0 < day <= 28
if month == 14:
if isleap(year + YEAR_EPOCH - 1):
assert day <= 2
else:
... | def legal_date(year, month, day):
'''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:
... | [
"Checks",
"if",
"a",
"given",
"date",
"is",
"a",
"legal",
"positivist",
"date"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/positivist.py#L38-L53 | [
"def",
"legal_date",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"try",
":",
"assert",
"year",
">=",
"1",
"assert",
"0",
"<",
"month",
"<=",
"14",
"assert",
"0",
"<",
"day",
"<=",
"28",
"if",
"month",
"==",
"14",
":",
"if",
"isleap",
"(",
... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | to_jd | Convert a Positivist date to Julian day count. | convertdate/positivist.py | def to_jd(year, month, day):
'''Convert a Positivist date to Julian day count.'''
legal_date(year, month, day)
gyear = year + YEAR_EPOCH - 1
return (
gregorian.EPOCH - 1 + (365 * (gyear - 1)) +
floor((gyear - 1) / 4) + (-floor((gyear - 1) / 100)) +
floor((gyear - 1) / 400) + (mo... | def to_jd(year, month, day):
'''Convert a Positivist date to Julian day count.'''
legal_date(year, month, day)
gyear = year + YEAR_EPOCH - 1
return (
gregorian.EPOCH - 1 + (365 * (gyear - 1)) +
floor((gyear - 1) / 4) + (-floor((gyear - 1) / 100)) +
floor((gyear - 1) / 400) + (mo... | [
"Convert",
"a",
"Positivist",
"date",
"to",
"Julian",
"day",
"count",
"."
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/positivist.py#L56-L65 | [
"def",
"to_jd",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"legal_date",
"(",
"year",
",",
"month",
",",
"day",
")",
"gyear",
"=",
"year",
"+",
"YEAR_EPOCH",
"-",
"1",
"return",
"(",
"gregorian",
".",
"EPOCH",
"-",
"1",
"+",
"(",
"365",
"*"... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | from_jd | Convert a Julian day count to Positivist date. | convertdate/positivist.py | def from_jd(jd):
'''Convert a Julian day count to Positivist date.'''
try:
assert jd >= EPOCH
except AssertionError:
raise ValueError('Invalid Julian day')
depoch = floor(jd - 0.5) + 0.5 - gregorian.EPOCH
quadricent = floor(depoch / gregorian.INTERCALATION_CYCLE_DAYS)
dqc = dep... | def from_jd(jd):
'''Convert a Julian day count to Positivist date.'''
try:
assert jd >= EPOCH
except AssertionError:
raise ValueError('Invalid Julian day')
depoch = floor(jd - 0.5) + 0.5 - gregorian.EPOCH
quadricent = floor(depoch / gregorian.INTERCALATION_CYCLE_DAYS)
dqc = dep... | [
"Convert",
"a",
"Julian",
"day",
"count",
"to",
"Positivist",
"date",
"."
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/positivist.py#L68-L108 | [
"def",
"from_jd",
"(",
"jd",
")",
":",
"try",
":",
"assert",
"jd",
">=",
"EPOCH",
"except",
"AssertionError",
":",
"raise",
"ValueError",
"(",
"'Invalid Julian day'",
")",
"depoch",
"=",
"floor",
"(",
"jd",
"-",
"0.5",
")",
"+",
"0.5",
"-",
"gregorian",
... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | dayname | Give the name of the month and day for a given date.
Returns:
tuple month_name, day_name | convertdate/positivist.py | def dayname(year, month, day):
'''
Give the name of the month and day for a given date.
Returns:
tuple month_name, day_name
'''
legal_date(year, month, day)
yearday = (month - 1) * 28 + day
if isleap(year + YEAR_EPOCH - 1):
dname = data.day_names_leap[yearday - 1]
else... | def dayname(year, month, day):
'''
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... | [
"Give",
"the",
"name",
"of",
"the",
"month",
"and",
"day",
"for",
"a",
"given",
"date",
"."
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/positivist.py#L119-L135 | [
"def",
"dayname",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"legal_date",
"(",
"year",
",",
"month",
",",
"day",
")",
"yearday",
"=",
"(",
"month",
"-",
"1",
")",
"*",
"28",
"+",
"day",
"if",
"isleap",
"(",
"year",
"+",
"YEAR_EPOCH",
"-",
... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | Device.hasExpired | :return: true if the lastUpdateTime is more than maxAge seconds ago. | backend/src/analyser/common/devicecontroller.py | def hasExpired(self):
"""
:return: true if the lastUpdateTime is more than maxAge seconds ago.
"""
return (datetime.datetime.utcnow() - self.lastUpdateTime).total_seconds() > self.maxAgeSeconds | def hasExpired(self):
"""
:return: true if the lastUpdateTime is more than maxAge seconds ago.
"""
return (datetime.datetime.utcnow() - self.lastUpdateTime).total_seconds() > self.maxAgeSeconds | [
":",
"return",
":",
"true",
"if",
"the",
"lastUpdateTime",
"is",
"more",
"than",
"maxAge",
"seconds",
"ago",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L33-L37 | [
"def",
"hasExpired",
"(",
"self",
")",
":",
"return",
"(",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"-",
"self",
".",
"lastUpdateTime",
")",
".",
"total_seconds",
"(",
")",
">",
"self",
".",
"maxAgeSeconds"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | DeviceController.accept | Adds the named device to the store.
:param deviceId:
:param device:
:return: | backend/src/analyser/common/devicecontroller.py | def accept(self, deviceId, device):
"""
Adds the named device to the store.
:param deviceId:
:param device:
:return:
"""
storedDevice = self.devices.get(deviceId)
if storedDevice is None:
logger.info('Initialising device ' + deviceId)
... | def accept(self, deviceId, device):
"""
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)
... | [
"Adds",
"the",
"named",
"device",
"to",
"the",
"store",
".",
":",
"param",
"deviceId",
":",
":",
"param",
"device",
":",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L63-L86 | [
"def",
"accept",
"(",
"self",
",",
"deviceId",
",",
"device",
")",
":",
"storedDevice",
"=",
"self",
".",
"devices",
".",
"get",
"(",
"deviceId",
")",
"if",
"storedDevice",
"is",
"None",
":",
"logger",
".",
"info",
"(",
"'Initialising device '",
"+",
"de... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | DeviceController.getDevices | The devices in the given state or all devices is the arg is none.
:param status: the state to match against.
:return: the devices | backend/src/analyser/common/devicecontroller.py | def getDevices(self, status=None):
"""
The devices in the given state or all devices is the arg is none.
:param status: the state to match against.
:return: the devices
"""
return [d for d in self.devices.values() if status is None or d.payload.get('status') == status] | def getDevices(self, status=None):
"""
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] | [
"The",
"devices",
"in",
"the",
"given",
"state",
"or",
"all",
"devices",
"is",
"the",
"arg",
"is",
"none",
".",
":",
"param",
"status",
":",
"the",
"state",
"to",
"match",
"against",
".",
":",
"return",
":",
"the",
"devices"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L88-L94 | [
"def",
"getDevices",
"(",
"self",
",",
"status",
"=",
"None",
")",
":",
"return",
"[",
"d",
"for",
"d",
"in",
"self",
".",
"devices",
".",
"values",
"(",
")",
"if",
"status",
"is",
"None",
"or",
"d",
".",
"payload",
".",
"get",
"(",
"'status'",
"... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | DeviceController.getDevice | gets the named device.
:param id: the id.
:return: the device | backend/src/analyser/common/devicecontroller.py | def getDevice(self, id):
"""
gets the named device.
:param id: the id.
:return: the device
"""
return next(iter([d for d in self.devices.values() if d.deviceId == id]), None) | def getDevice(self, id):
"""
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) | [
"gets",
"the",
"named",
"device",
".",
":",
"param",
"id",
":",
"the",
"id",
".",
":",
"return",
":",
"the",
"device"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L96-L102 | [
"def",
"getDevice",
"(",
"self",
",",
"id",
")",
":",
"return",
"next",
"(",
"iter",
"(",
"[",
"d",
"for",
"d",
"in",
"self",
".",
"devices",
".",
"values",
"(",
")",
"if",
"d",
".",
"deviceId",
"==",
"id",
"]",
")",
",",
"None",
")"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | DeviceController._evictStaleDevices | A housekeeping function which runs in a worker thread and which evicts devices that haven't sent an update for a
while. | backend/src/analyser/common/devicecontroller.py | def _evictStaleDevices(self):
"""
A housekeeping function which runs in a worker thread and which evicts devices that haven't sent an update for a
while.
"""
while self.running:
expiredDeviceIds = [key for key, value in self.devices.items() if value.hasExpired()]
... | def _evictStaleDevices(self):
"""
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()]
... | [
"A",
"housekeeping",
"function",
"which",
"runs",
"in",
"a",
"worker",
"thread",
"and",
"which",
"evicts",
"devices",
"that",
"haven",
"t",
"sent",
"an",
"update",
"for",
"a",
"while",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L104-L116 | [
"def",
"_evictStaleDevices",
"(",
"self",
")",
":",
"while",
"self",
".",
"running",
":",
"expiredDeviceIds",
"=",
"[",
"key",
"for",
"key",
",",
"value",
"in",
"self",
".",
"devices",
".",
"items",
"(",
")",
"if",
"value",
".",
"hasExpired",
"(",
")",... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | DeviceController.scheduleMeasurement | Schedules the requested measurement session with all INITIALISED devices.
:param measurementId:
:param duration:
:param start:
:return: a dict of device vs status. | backend/src/analyser/common/devicecontroller.py | def scheduleMeasurement(self, measurementId, duration, start):
"""
Schedules the requested measurement session with all INITIALISED devices.
:param measurementId:
:param duration:
:param start:
:return: a dict of device vs status.
"""
# TODO subtract 1s fr... | def scheduleMeasurement(self, measurementId, duration, start):
"""
Schedules the requested measurement session with all INITIALISED devices.
:param measurementId:
:param duration:
:param start:
:return: a dict of device vs status.
"""
# TODO subtract 1s fr... | [
"Schedules",
"the",
"requested",
"measurement",
"session",
"with",
"all",
"INITIALISED",
"devices",
".",
":",
"param",
"measurementId",
":",
":",
"param",
"duration",
":",
":",
"param",
"start",
":",
":",
"return",
":",
"a",
"dict",
"of",
"device",
"vs",
"... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L118-L139 | [
"def",
"scheduleMeasurement",
"(",
"self",
",",
"measurementId",
",",
"duration",
",",
"start",
")",
":",
"# TODO subtract 1s from start and format",
"results",
"=",
"{",
"}",
"for",
"device",
"in",
"self",
".",
"getDevices",
"(",
"RecordingDeviceStatus",
".",
"IN... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | State.patch | Allows the UI to update parameters ensuring that all devices are kept in sync. Payload is json in TargetState
format.
:return: | backend/src/analyser/resources/state.py | def patch(self):
"""
Allows the UI to update parameters ensuring that all devices are kept in sync. Payload is json in TargetState
format.
:return:
"""
# TODO block until all devices have updated?
json = request.get_json()
logger.info("Updating target stat... | def patch(self):
"""
Allows the UI to update parameters ensuring that all devices are kept in sync. Payload is json in TargetState
format.
:return:
"""
# TODO block until all devices have updated?
json = request.get_json()
logger.info("Updating target stat... | [
"Allows",
"the",
"UI",
"to",
"update",
"parameters",
"ensuring",
"that",
"all",
"devices",
"are",
"kept",
"in",
"sync",
".",
"Payload",
"is",
"json",
"in",
"TargetState",
"format",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/state.py#L19-L29 | [
"def",
"patch",
"(",
"self",
")",
":",
"# TODO block until all devices have updated?",
"json",
"=",
"request",
".",
"get_json",
"(",
")",
"logger",
".",
"info",
"(",
"\"Updating target state with \"",
"+",
"str",
"(",
"json",
")",
")",
"self",
".",
"_targetState... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | list_parse | Parse a comma-separated list of values, or a filename (starting with @)
containing a list value on each line. | lib/stsci/tools/fitsdiff.py | def list_parse(name_list):
"""Parse a comma-separated list of values, or a filename (starting with @)
containing a list value on each line.
"""
if name_list and name_list[0] == '@':
value = name_list[1:]
if not os.path.exists(value):
log.warning('The file %s does not exist' ... | def list_parse(name_list):
"""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' ... | [
"Parse",
"a",
"comma",
"-",
"separated",
"list",
"of",
"values",
"or",
"a",
"filename",
"(",
"starting",
"with"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fitsdiff.py#L45-L61 | [
"def",
"list_parse",
"(",
"name_list",
")",
":",
"if",
"name_list",
"and",
"name_list",
"[",
"0",
"]",
"==",
"'@'",
":",
"value",
"=",
"name_list",
"[",
"1",
":",
"]",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"value",
")",
":",
"log",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | MinMatchDict._mmInit | Create the minimum match dictionary of keys | lib/stsci/tools/minmatch.py | def _mmInit(self):
"""Create the minimum match dictionary of keys"""
# cache references to speed up loop a bit
mmkeys = {}
mmkeysGet = mmkeys.setdefault
minkeylength = self.minkeylength
for key in self.data.keys():
# add abbreviations as short as minkeylength
... | def _mmInit(self):
"""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
... | [
"Create",
"the",
"minimum",
"match",
"dictionary",
"of",
"keys"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L67-L80 | [
"def",
"_mmInit",
"(",
"self",
")",
":",
"# cache references to speed up loop a bit",
"mmkeys",
"=",
"{",
"}",
"mmkeysGet",
"=",
"mmkeys",
".",
"setdefault",
"minkeylength",
"=",
"self",
".",
"minkeylength",
"for",
"key",
"in",
"self",
".",
"data",
".",
"keys"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | MinMatchDict.resolve | Hook to resolve ambiguities in selected keys | lib/stsci/tools/minmatch.py | def resolve(self, key, keylist):
"""Hook to resolve ambiguities in selected keys"""
raise AmbiguousKeyError("Ambiguous key "+ repr(key) +
", could be any of " + str(sorted(keylist))) | def resolve(self, key, keylist):
"""Hook to resolve ambiguities in selected keys"""
raise AmbiguousKeyError("Ambiguous key "+ repr(key) +
", could be any of " + str(sorted(keylist))) | [
"Hook",
"to",
"resolve",
"ambiguities",
"in",
"selected",
"keys"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L101-L104 | [
"def",
"resolve",
"(",
"self",
",",
"key",
",",
"keylist",
")",
":",
"raise",
"AmbiguousKeyError",
"(",
"\"Ambiguous key \"",
"+",
"repr",
"(",
"key",
")",
"+",
"\", could be any of \"",
"+",
"str",
"(",
"sorted",
"(",
"keylist",
")",
")",
")"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | MinMatchDict.add | 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. | lib/stsci/tools/minmatch.py | def add(self, key, item):
"""Add a new key/item pair to the dictionary. Resets an existing
key value only if this is an exact match to a known key."""
mmkeys = self.mmkeys
if mmkeys is not None and not (key in self.data):
# add abbreviations as short as minkeylength
... | def add(self, key, item):
"""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
... | [
"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",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L106-L119 | [
"def",
"add",
"(",
"self",
",",
"key",
",",
"item",
")",
":",
"mmkeys",
"=",
"self",
".",
"mmkeys",
"if",
"mmkeys",
"is",
"not",
"None",
"and",
"not",
"(",
"key",
"in",
"self",
".",
"data",
")",
":",
"# add abbreviations as short as minkeylength",
"# alw... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | MinMatchDict.get | Raises exception if key is ambiguous | lib/stsci/tools/minmatch.py | 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 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) | [
"Raises",
"exception",
"if",
"key",
"is",
"ambiguous"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L136-L140 | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"failobj",
"=",
"None",
",",
"exact",
"=",
"0",
")",
":",
"if",
"not",
"exact",
":",
"key",
"=",
"self",
".",
"getfullkey",
"(",
"key",
",",
"new",
"=",
"1",
")",
"return",
"self",
".",
"data",
".",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | MinMatchDict._has | Raises an exception if key is ambiguous | lib/stsci/tools/minmatch.py | 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 _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 | [
"Raises",
"an",
"exception",
"if",
"key",
"is",
"ambiguous"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L169-L173 | [
"def",
"_has",
"(",
"self",
",",
"key",
",",
"exact",
"=",
"0",
")",
":",
"if",
"not",
"exact",
":",
"key",
"=",
"self",
".",
"getfullkey",
"(",
"key",
",",
"new",
"=",
"1",
")",
"return",
"key",
"in",
"self",
".",
"data"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | MinMatchDict.getall | Returns a list of all the matching values for key,
containing a single entry for unambiguous matches and
multiple entries for ambiguous matches. | lib/stsci/tools/minmatch.py | 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 fai... | 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 fai... | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"matching",
"values",
"for",
"key",
"containing",
"a",
"single",
"entry",
"for",
"unambiguous",
"matches",
"and",
"multiple",
"entries",
"for",
"ambiguous",
"matches",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L195-L202 | [
"def",
"getall",
"(",
"self",
",",
"key",
",",
"failobj",
"=",
"None",
")",
":",
"if",
"self",
".",
"mmkeys",
"is",
"None",
":",
"self",
".",
"_mmInit",
"(",
")",
"k",
"=",
"self",
".",
"mmkeys",
".",
"get",
"(",
"key",
")",
"if",
"not",
"k",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | MinMatchDict.getallkeys | 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. | lib/stsci/tools/minmatch.py | 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(... | 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(... | [
"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",
... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L204-L210 | [
"def",
"getallkeys",
"(",
"self",
",",
"key",
",",
"failobj",
"=",
"None",
")",
":",
"if",
"self",
".",
"mmkeys",
"is",
"None",
":",
"self",
".",
"_mmInit",
"(",
")",
"return",
"self",
".",
"mmkeys",
".",
"get",
"(",
"key",
",",
"failobj",
")"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | QuietMinMatchDict.get | Returns failobj if key is not found or is ambiguous | lib/stsci/tools/minmatch.py | 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 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) | [
"Returns",
"failobj",
"if",
"key",
"is",
"not",
"found",
"or",
"is",
"ambiguous"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L225-L234 | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"failobj",
"=",
"None",
",",
"exact",
"=",
"0",
")",
":",
"if",
"not",
"exact",
":",
"try",
":",
"key",
"=",
"self",
".",
"getfullkey",
"(",
"key",
")",
"except",
"KeyError",
":",
"return",
"failobj",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | QuietMinMatchDict._has | Returns false if key is not found or is ambiguous | lib/stsci/tools/minmatch.py | 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 _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 | [
"Returns",
"false",
"if",
"key",
"is",
"not",
"found",
"or",
"is",
"ambiguous"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L237-L248 | [
"def",
"_has",
"(",
"self",
",",
"key",
",",
"exact",
"=",
"0",
")",
":",
"if",
"not",
"exact",
":",
"try",
":",
"key",
"=",
"self",
".",
"getfullkey",
"(",
"key",
")",
"return",
"1",
"except",
"KeyError",
":",
"return",
"0",
"else",
":",
"return... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | parFactory | 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) | lib/stsci/tools/basicpar.py | 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 inpu... | 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 inpu... | [
"parameter",
"factory",
"function"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L47-L83 | [
"def",
"parFactory",
"(",
"fields",
",",
"strict",
"=",
"0",
")",
":",
"if",
"len",
"(",
"fields",
")",
"<",
"3",
"or",
"None",
"in",
"fields",
"[",
"0",
":",
"3",
"]",
":",
"raise",
"SyntaxError",
"(",
"\"At least 3 fields must be given\"",
")",
"type... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar.setCmdline | Set cmdline flag | lib/stsci/tools/basicpar.py | 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 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 | [
"Set",
"cmdline",
"flag"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L244-L250 | [
"def",
"setCmdline",
"(",
"self",
",",
"value",
"=",
"1",
")",
":",
"# set through dictionary to avoid extra calls to __setattr__",
"if",
"value",
":",
"self",
".",
"__dict__",
"[",
"'flags'",
"]",
"=",
"self",
".",
"flags",
"|",
"_cmdlineFlag",
"else",
":",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar.setChanged | Set changed flag | lib/stsci/tools/basicpar.py | 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 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 | [
"Set",
"changed",
"flag"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L256-L262 | [
"def",
"setChanged",
"(",
"self",
",",
"value",
"=",
"1",
")",
":",
"# set through dictionary to avoid another call to __setattr__",
"if",
"value",
":",
"self",
".",
"__dict__",
"[",
"'flags'",
"]",
"=",
"self",
".",
"flags",
"|",
"_changedFlag",
"else",
":",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar.isLearned | 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. | lib/stsci/tools/basicpar.py | 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 ... | 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 ... | [
"Return",
"true",
"if",
"this",
"parameter",
"is",
"learned"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L272-L286 | [
"def",
"isLearned",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"if",
"\"l\"",
"in",
"self",
".",
"mode",
":",
"return",
"1",
"if",
"\"h\"",
"in",
"self",
".",
"mode",
":",
"return",
"0",
"if",
"\"a\"",
"in",
"self",
".",
"mode",
":",
"if",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar.getWithPrompt | Interactively prompt for parameter value | lib/stsci/tools/basicpar.py | 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... | 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... | [
"Interactively",
"prompt",
"for",
"parameter",
"value"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L296-L356 | [
"def",
"getWithPrompt",
"(",
"self",
")",
":",
"if",
"self",
".",
"prompt",
":",
"pstring",
"=",
"self",
".",
"prompt",
".",
"split",
"(",
"\"\\n\"",
")",
"[",
"0",
"]",
".",
"strip",
"(",
")",
"else",
":",
"pstring",
"=",
"self",
".",
"name",
"i... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar.get | Return value of this parameter as a string (or in native format
if native is non-zero.) | lib/stsci/tools/basicpar.py | 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
re... | 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
re... | [
"Return",
"value",
"of",
"this",
"parameter",
"as",
"a",
"string",
"(",
"or",
"in",
"native",
"format",
"if",
"native",
"is",
"non",
"-",
"zero",
".",
")"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L358-L376 | [
"def",
"get",
"(",
"self",
",",
"field",
"=",
"None",
",",
"index",
"=",
"None",
",",
"lpar",
"=",
"0",
",",
"prompt",
"=",
"1",
",",
"native",
"=",
"0",
",",
"mode",
"=",
"\"h\"",
")",
":",
"if",
"field",
"and",
"field",
"!=",
"\"p_value\"",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar.set | 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. | lib/stsci/tools/basicpar.py | 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):
"""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 ... | [
"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",
"-",
... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L378-L395 | [
"def",
"set",
"(",
"self",
",",
"value",
",",
"field",
"=",
"None",
",",
"index",
"=",
"None",
",",
"check",
"=",
"1",
")",
":",
"if",
"index",
"is",
"not",
"None",
":",
"raise",
"SyntaxError",
"(",
"\"Parameter \"",
"+",
"self",
".",
"name",
"+",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar.checkValue | 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.) | lib/stsci/tools/basicpar.py | 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.chec... | 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.chec... | [
"Check",
"and",
"convert",
"a",
"parameter",
"value",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L397-L405 | [
"def",
"checkValue",
"(",
"self",
",",
"value",
",",
"strict",
"=",
"0",
")",
":",
"v",
"=",
"self",
".",
"_coerceValue",
"(",
"value",
",",
"strict",
")",
"return",
"self",
".",
"checkOneValue",
"(",
"v",
",",
"strict",
")"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar.checkOneValue | 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. | lib/stsci/tools/basicpar.py | 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.
... | 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.
... | [
"Checks",
"a",
"single",
"value",
"to",
"see",
"if",
"it",
"is",
"in",
"range",
"or",
"choice",
"list"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L407-L434 | [
"def",
"checkOneValue",
"(",
"self",
",",
"v",
",",
"strict",
"=",
"0",
")",
":",
"if",
"v",
"in",
"[",
"None",
",",
"INDEF",
"]",
"or",
"(",
"isinstance",
"(",
"v",
",",
"str",
")",
"and",
"v",
"[",
":",
"1",
"]",
"==",
"\")\"",
")",
":",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar.dpar | 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. | lib/stsci/tools/basicpar.py | 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 == "": sv... | 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 == "": sv... | [
"Return",
"dpar",
"-",
"style",
"executable",
"assignment",
"for",
"parameter"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L436-L446 | [
"def",
"dpar",
"(",
"self",
",",
"cl",
"=",
"1",
")",
":",
"sval",
"=",
"self",
".",
"toString",
"(",
"self",
".",
"value",
",",
"quoted",
"=",
"1",
")",
"if",
"not",
"cl",
":",
"if",
"sval",
"==",
"\"\"",
":",
"sval",
"=",
"\"None\"",
"s",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar.pretty | Return pretty list description of parameter | lib/stsci/tools/basicpar.py | 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)
nam... | 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)
nam... | [
"Return",
"pretty",
"list",
"description",
"of",
"parameter"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L452-L487 | [
"def",
"pretty",
"(",
"self",
",",
"verbose",
"=",
"0",
")",
":",
"# split prompt lines and add blanks in later lines to align them",
"plines",
"=",
"self",
".",
"prompt",
".",
"split",
"(",
"'\\n'",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"plines",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar.save | 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. | lib/stsci/tools/basicpar.py | 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... | 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... | [
"Return",
".",
"par",
"format",
"string",
"for",
"this",
"parameter"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L489-L526 | [
"def",
"save",
"(",
"self",
",",
"dolist",
"=",
"0",
")",
":",
"quoted",
"=",
"not",
"dolist",
"fields",
"=",
"7",
"*",
"[",
"\"\"",
"]",
"fields",
"[",
"0",
"]",
"=",
"self",
".",
"name",
"fields",
"[",
"1",
"]",
"=",
"self",
".",
"type",
"f... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar._setChoice | Set choice parameter from string s | lib/stsci/tools/basicpar.py | 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 _setChoice(self,s,strict=0):
"""Set choice parameter from string s"""
clist = _getChoice(s,strict)
self.choice = list(map(self._coerceValue, clist))
self._setChoiceDict() | [
"Set",
"choice",
"parameter",
"from",
"string",
"s"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L615-L619 | [
"def",
"_setChoice",
"(",
"self",
",",
"s",
",",
"strict",
"=",
"0",
")",
":",
"clist",
"=",
"_getChoice",
"(",
"s",
",",
"strict",
")",
"self",
".",
"choice",
"=",
"list",
"(",
"map",
"(",
"self",
".",
"_coerceValue",
",",
"clist",
")",
")",
"se... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar._setChoiceDict | Create dictionary for choice list | lib/stsci/tools/basicpar.py | 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 _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 | [
"Create",
"dictionary",
"for",
"choice",
"list"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L621-L625 | [
"def",
"_setChoiceDict",
"(",
"self",
")",
":",
"# value is name of choice parameter (same as key)",
"self",
".",
"choiceDict",
"=",
"{",
"}",
"for",
"c",
"in",
"self",
".",
"choice",
":",
"self",
".",
"choiceDict",
"[",
"c",
"]",
"=",
"c"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar._optionalPrompt | 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. | lib/stsci/tools/basicpar.py | 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.
... | 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.
... | [
"Interactively",
"prompt",
"for",
"parameter",
"if",
"necessary"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L632-L654 | [
"def",
"_optionalPrompt",
"(",
"self",
",",
"mode",
")",
":",
"if",
"(",
"self",
".",
"mode",
"==",
"\"h\"",
")",
"or",
"(",
"self",
".",
"mode",
"==",
"\"a\"",
"and",
"mode",
"==",
"\"h\"",
")",
":",
"# hidden parameter",
"if",
"not",
"self",
".",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar._getPFilename | Get p_filename field for this parameter
Same as get for non-list params | lib/stsci/tools/basicpar.py | 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 _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) | [
"Get",
"p_filename",
"field",
"for",
"this",
"parameter"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L656-L661 | [
"def",
"_getPFilename",
"(",
"self",
",",
"native",
",",
"prompt",
")",
":",
"return",
"self",
".",
"get",
"(",
"native",
"=",
"native",
",",
"prompt",
"=",
"prompt",
")"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar._getField | Get a parameter field value | lib/stsci/tools/basicpar.py | 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):
"""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... | [
"Get",
"a",
"parameter",
"field",
"value"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L670-L720 | [
"def",
"_getField",
"(",
"self",
",",
"field",
",",
"native",
"=",
"0",
",",
"prompt",
"=",
"1",
")",
":",
"try",
":",
"# expand field name using minimum match",
"field",
"=",
"_getFieldDict",
"[",
"field",
"]",
"except",
"KeyError",
"as",
"e",
":",
"# re-... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafPar._setField | Set a parameter field value | lib/stsci/tools/basicpar.py | 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):
"""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 " ... | [
"Set",
"a",
"parameter",
"field",
"value"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L722-L752 | [
"def",
"_setField",
"(",
"self",
",",
"value",
",",
"field",
",",
"check",
"=",
"1",
")",
":",
"try",
":",
"# expand field name using minimum match",
"field",
"=",
"_setFieldDict",
"[",
"field",
"]",
"except",
"KeyError",
"as",
"e",
":",
"raise",
"SyntaxErro... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafArrayPar.save | 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. | lib/stsci/tools/basicpar.py | 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):
"""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:
... | [
"Return",
".",
"par",
"format",
"string",
"for",
"this",
"parameter"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L864-L913 | [
"def",
"save",
"(",
"self",
",",
"dolist",
"=",
"0",
")",
":",
"quoted",
"=",
"not",
"dolist",
"array_size",
"=",
"1",
"for",
"d",
"in",
"self",
".",
"shape",
":",
"array_size",
"=",
"d",
"*",
"array_size",
"ndim",
"=",
"len",
"(",
"self",
".",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafArrayPar.dpar | 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. | lib/stsci/tools/basicpar.py | 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):
"""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"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L915-L928 | [
"def",
"dpar",
"(",
"self",
",",
"cl",
"=",
"1",
")",
":",
"sval",
"=",
"list",
"(",
"map",
"(",
"self",
".",
"toString",
",",
"self",
".",
"value",
",",
"len",
"(",
"self",
".",
"value",
")",
"*",
"[",
"1",
"]",
")",
")",
"for",
"i",
"in",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafArrayPar.get | Return value of this parameter as a string (or in native format
if native is non-zero.) | lib/stsci/tools/basicpar.py | 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"):
"""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
... | [
"Return",
"value",
"of",
"this",
"parameter",
"as",
"a",
"string",
"(",
"or",
"in",
"native",
"format",
"if",
"native",
"is",
"non",
"-",
"zero",
".",
")"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L930-L960 | [
"def",
"get",
"(",
"self",
",",
"field",
"=",
"None",
",",
"index",
"=",
"None",
",",
"lpar",
"=",
"0",
",",
"prompt",
"=",
"1",
",",
"native",
"=",
"0",
",",
"mode",
"=",
"\"h\"",
")",
":",
"if",
"field",
":",
"return",
"self",
".",
"_getField... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafArrayPar.set | 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. | lib/stsci/tools/basicpar.py | 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):
"""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 ... | [
"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",
"-",
... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L962-L988 | [
"def",
"set",
"(",
"self",
",",
"value",
",",
"field",
"=",
"None",
",",
"index",
"=",
"None",
",",
"check",
"=",
"1",
")",
":",
"if",
"index",
"is",
"not",
"None",
":",
"sumindex",
"=",
"self",
".",
"_sumindex",
"(",
"index",
")",
"try",
":",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafArrayPar.checkValue | 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.) | lib/stsci/tools/basicpar.py | 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):
"""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... | [
"Check",
"and",
"convert",
"a",
"parameter",
"value",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L990-L1000 | [
"def",
"checkValue",
"(",
"self",
",",
"value",
",",
"strict",
"=",
"0",
")",
":",
"v",
"=",
"self",
".",
"_coerceValue",
"(",
"value",
",",
"strict",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"v",
")",
")",
":",
"self",
".",
"checkOneValu... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafArrayPar._sumindex | Convert tuple index to 1-D index into value | lib/stsci/tools/basicpar.py | 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):
"""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... | [
"Convert",
"tuple",
"index",
"to",
"1",
"-",
"D",
"index",
"into",
"value"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L1034-L1052 | [
"def",
"_sumindex",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"try",
":",
"ndim",
"=",
"len",
"(",
"index",
")",
"except",
"TypeError",
":",
"# turn index into a 1-tuple",
"index",
"=",
"(",
"index",
",",
")",
"ndim",
"=",
"1",
"if",
"len",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | IrafArrayPar._coerceValue | Coerce parameter to appropriate type
Should accept None or null string. Must be an array. | lib/stsci/tools/basicpar.py | 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):
"""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()
... | [
"Coerce",
"parameter",
"to",
"appropriate",
"type"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L1058-L1075 | [
"def",
"_coerceValue",
"(",
"self",
",",
"value",
",",
"strict",
"=",
"0",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"# allow single blank-separated string as input",
"value",
"=",
"value",
".",
"split",
"(",
")",
"if",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | _StringMixin._setChoiceDict | Create min-match dictionary for choice list | lib/stsci/tools/basicpar.py | 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):
"""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) | [
"Create",
"min",
"-",
"match",
"dictionary",
"for",
"choice",
"list"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L1163-L1167 | [
"def",
"_setChoiceDict",
"(",
"self",
")",
":",
"# value is full name of choice parameter",
"self",
".",
"choiceDict",
"=",
"minmatch",
".",
"MinMatchDict",
"(",
")",
"for",
"c",
"in",
"self",
".",
"choice",
":",
"self",
".",
"choiceDict",
".",
"add",
"(",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | _BooleanMixin._checkAttribs | Check initial attributes to make sure they are legal | lib/stsci/tools/basicpar.py | 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):
"""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:
... | [
"Check",
"initial",
"attributes",
"to",
"make",
"sure",
"they",
"are",
"legal"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L1234-L1254 | [
"def",
"_checkAttribs",
"(",
"self",
",",
"strict",
")",
":",
"if",
"self",
".",
"min",
":",
"warning",
"(",
"\"Minimum value not allowed for boolean-type parameter \"",
"+",
"self",
".",
"name",
",",
"strict",
")",
"self",
".",
"min",
"=",
"None",
"if",
"se... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | _RealMixin._checkAttribs | Check initial attributes to make sure they are legal | lib/stsci/tools/basicpar.py | 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):
"""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 | [
"Check",
"initial",
"attributes",
"to",
"make",
"sure",
"they",
"are",
"legal"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L1458-L1463 | [
"def",
"_checkAttribs",
"(",
"self",
",",
"strict",
")",
":",
"if",
"self",
".",
"choice",
":",
"warning",
"(",
"\"Choice values not allowed for real-type parameter \"",
"+",
"self",
".",
"name",
",",
"strict",
")",
"self",
".",
"choice",
"=",
"None"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | RecordingDevice.patch | 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... | backend/src/recorder/resources/recordingdevices.py | 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):
"""
Updates the device with the given data. Supports a json payload like
{
fs: newFs
samplesPerBatch: samplesPerBatch
gyroEnabled: true
gyroSensitivity: 500
accelerometerEnabled: true
accelerometer... | [
"Updates",
"the",
"device",
"with",
"the",
"given",
"data",
".",
"Supports",
"a",
"json",
"payload",
"like",
"{",
"fs",
":",
"newFs",
"samplesPerBatch",
":",
"samplesPerBatch",
"gyroEnabled",
":",
"true",
"gyroSensitivity",
":",
"500",
"accelerometerEnabled",
":... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/recordingdevices.py#L36-L62 | [
"def",
"patch",
"(",
"self",
",",
"deviceId",
")",
":",
"try",
":",
"device",
"=",
"self",
".",
"recordingDevices",
".",
"get",
"(",
"deviceId",
")",
"if",
"device",
".",
"status",
"==",
"RecordingDeviceStatus",
".",
"INITIALISED",
":",
"errors",
"=",
"s... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | legal_date | Check if this is a legal date in the Gregorian calendar | convertdate/gregorian.py | 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):
'''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... | [
"Check",
"if",
"this",
"is",
"a",
"legal",
"date",
"in",
"the",
"Gregorian",
"calendar"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/gregorian.py#L30-L40 | [
"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",... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | to_jd2 | Gregorian to Julian Day Count for years between 1801-2099 | convertdate/gregorian.py | 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):
'''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 = ... | [
"Gregorian",
"to",
"Julian",
"Day",
"Count",
"for",
"years",
"between",
"1801",
"-",
"2099"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/gregorian.py#L43-L58 | [
"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",
"... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | from_jd | Return Gregorian date in a (Y, M, D) tuple | convertdate/gregorian.py | 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):
'''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
... | [
"Return",
"Gregorian",
"date",
"in",
"a",
"(",
"Y",
"M",
"D",
")",
"tuple"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/gregorian.py#L80-L118 | [
"def",
"from_jd",
"(",
"jd",
")",
":",
"wjd",
"=",
"floor",
"(",
"jd",
"-",
"0.5",
")",
"+",
"0.5",
"depoch",
"=",
"wjd",
"-",
"EPOCH",
"quadricent",
"=",
"floor",
"(",
"depoch",
"/",
"INTERCALATION_CYCLE_DAYS",
")",
"dqc",
"=",
"depoch",
"%",
"INTER... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | TargetController.storeFromHinge | 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. | backend/src/analyser/common/targetcontroller.py | 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):
"""
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... | [
"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"... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetcontroller.py#L23-L35 | [
"def",
"storeFromHinge",
"(",
"self",
",",
"name",
",",
"hingePoints",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"_cache",
":",
"if",
"self",
".",
"_valid",
"(",
"hingePoints",
")",
":",
"self",
".",
"_cache",
"[",
"name",
"]",
"=",
"{",
"'... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | TargetController.storeFromWav | Stores a new item in the cache.
:param name: file name.
:param start: start time.
:param end: end time.
:return: true if stored. | backend/src/analyser/common/targetcontroller.py | 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):
"""
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
... | [
"Stores",
"a",
"new",
"item",
"in",
"the",
"cache",
".",
":",
"param",
"name",
":",
"file",
"name",
".",
":",
"param",
"start",
":",
"start",
"time",
".",
":",
"param",
"end",
":",
"end",
"time",
".",
":",
"return",
":",
"true",
"if",
"stored",
"... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetcontroller.py#L37-L62 | [
"def",
"storeFromWav",
"(",
"self",
",",
"uploadCacheEntry",
",",
"start",
",",
"end",
")",
":",
"prefix",
"=",
"uploadCacheEntry",
"[",
"'name'",
"]",
"+",
"'_'",
"+",
"start",
"+",
"'_'",
"+",
"end",
"match",
"=",
"next",
"(",
"(",
"x",
"for",
"x",... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | TargetController.delete | Deletes the named entry in the cache.
:param name: the name.
:return: true if it is deleted. | backend/src/analyser/common/targetcontroller.py | 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):
"""
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
... | [
"Deletes",
"the",
"named",
"entry",
"in",
"the",
"cache",
".",
":",
"param",
"name",
":",
"the",
"name",
".",
":",
"return",
":",
"true",
"if",
"it",
"is",
"deleted",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetcontroller.py#L64-L75 | [
"def",
"delete",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_cache",
":",
"del",
"self",
".",
"_cache",
"[",
"name",
"]",
"self",
".",
"writeCache",
"(",
")",
"# TODO clean files",
"return",
"True",
"return",
"False"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | TargetController.analyse | reads the specified file.
:param name: the name.
:return: the analysis as frequency/Pxx. | backend/src/analyser/common/targetcontroller.py | 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):
"""
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... | [
"reads",
"the",
"specified",
"file",
".",
":",
"param",
"name",
":",
"the",
"name",
".",
":",
"return",
":",
"the",
"analysis",
"as",
"frequency",
"/",
"Pxx",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetcontroller.py#L91-L130 | [
"def",
"analyse",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_cache",
":",
"target",
"=",
"self",
".",
"_cache",
"[",
"name",
"]",
"if",
"target",
"[",
"'type'",
"]",
"==",
"'wav'",
":",
"signal",
"=",
"self",
".",
"_up... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | TargetController.log_interp1d | 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. | backend/src/analyser/common/targetcontroller.py | 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'):
"""
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... | [
"Performs",
"a",
"log",
"space",
"1d",
"interpolation",
".",
":",
"param",
"xx",
":",
"the",
"x",
"values",
".",
":",
"param",
"yy",
":",
"the",
"y",
"values",
".",
":",
"param",
"kind",
":",
"the",
"type",
"of",
"interpolation",
"to",
"apply",
"(",
... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetcontroller.py#L140-L152 | [
"def",
"log_interp1d",
"(",
"self",
",",
"xx",
",",
"yy",
",",
"kind",
"=",
"'linear'",
")",
":",
"logx",
"=",
"np",
".",
"log10",
"(",
"xx",
")",
"logy",
"=",
"np",
".",
"log10",
"(",
"yy",
")",
"lin_interp",
"=",
"interp1d",
"(",
"logx",
",",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | to_jd | Retrieve the Julian date equivalent for this date | convertdate/coptic.py | 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):
"Retrieve the Julian date equivalent for this date"
return day + (month - 1) * 30 + (year - 1) * 365 + floor(year / 4) + EPOCH - 1 | [
"Retrieve",
"the",
"Julian",
"date",
"equivalent",
"for",
"this",
"date"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/coptic.py#L24-L26 | [
"def",
"to_jd",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"return",
"day",
"+",
"(",
"month",
"-",
"1",
")",
"*",
"30",
"+",
"(",
"year",
"-",
"1",
")",
"*",
"365",
"+",
"floor",
"(",
"year",
"/",
"4",
")",
"+",
"EPOCH",
"-",
"1"
] | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | from_jd | Create a new date from a Julian date. | convertdate/coptic.py | 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):
"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 | [
"Create",
"a",
"new",
"date",
"from",
"a",
"Julian",
"date",
"."
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/coptic.py#L29-L38 | [
"def",
"from_jd",
"(",
"jdc",
")",
":",
"cdc",
"=",
"floor",
"(",
"jdc",
")",
"+",
"0.5",
"-",
"EPOCH",
"year",
"=",
"floor",
"(",
"(",
"cdc",
"-",
"floor",
"(",
"(",
"cdc",
"+",
"366",
")",
"/",
"1461",
")",
")",
"/",
"365",
")",
"+",
"1",... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | troll | 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... | lib/stsci/tools/wcsutil.py | 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):
""" 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... | [
"Computes",
"the",
"roll",
"angle",
"at",
"the",
"target",
"position",
"based",
"on",
"::"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L106-L135 | [
"def",
"troll",
"(",
"roll",
",",
"dec",
",",
"v2",
",",
"v3",
")",
":",
"# Convert all angles to radians",
"_roll",
"=",
"DEGTORAD",
"(",
"roll",
")",
"_dec",
"=",
"DEGTORAD",
"(",
"dec",
")",
"_v2",
"=",
"DEGTORAD",
"(",
"v2",
"/",
"3600.",
")",
"_... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.