repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
yychen/twd97
twd97/converter.py
towgs84
def towgs84(E, N, pkm=False, presentation=None): """ Convert coordintes from TWD97 to WGS84 The east and north coordinates should be in meters and in float pkm true for Penghu, Kinmen and Matsu area You can specify one of the following presentations of the returned values: dms - A tuple wit...
python
def towgs84(E, N, pkm=False, presentation=None): """ Convert coordintes from TWD97 to WGS84 The east and north coordinates should be in meters and in float pkm true for Penghu, Kinmen and Matsu area You can specify one of the following presentations of the returned values: dms - A tuple wit...
[ "def", "towgs84", "(", "E", ",", "N", ",", "pkm", "=", "False", ",", "presentation", "=", "None", ")", ":", "_lng0", "=", "lng0pkm", "if", "pkm", "else", "lng0", "E", "/=", "1000.0", "N", "/=", "1000.0", "epsilon", "=", "(", "N", "-", "N0", ")", ...
Convert coordintes from TWD97 to WGS84 The east and north coordinates should be in meters and in float pkm true for Penghu, Kinmen and Matsu area You can specify one of the following presentations of the returned values: dms - A tuple with degrees (int), minutes (int) and seconds (float) dm...
[ "Convert", "coordintes", "from", "TWD97", "to", "WGS84" ]
2fe05dbca335be425a1f451e0ef8f210ec864de1
https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L106-L156
train
yychen/twd97
twd97/converter.py
fromwgs84
def fromwgs84(lat, lng, pkm=False): """ Convert coordintes from WGS84 to TWD97 pkm true for Penghu, Kinmen and Matsu area The latitude and longitude can be in the following formats: [+/-]DDD°MMM'SSS.SSSS" (unicode) [+/-]DDD°MMM.MMMM' (unicode) [+/-]DDD.DDDDD (string, unicode or ...
python
def fromwgs84(lat, lng, pkm=False): """ Convert coordintes from WGS84 to TWD97 pkm true for Penghu, Kinmen and Matsu area The latitude and longitude can be in the following formats: [+/-]DDD°MMM'SSS.SSSS" (unicode) [+/-]DDD°MMM.MMMM' (unicode) [+/-]DDD.DDDDD (string, unicode or ...
[ "def", "fromwgs84", "(", "lat", ",", "lng", ",", "pkm", "=", "False", ")", ":", "_lng0", "=", "lng0pkm", "if", "pkm", "else", "lng0", "lat", "=", "radians", "(", "todegdec", "(", "lat", ")", ")", "lng", "=", "radians", "(", "todegdec", "(", "lng", ...
Convert coordintes from WGS84 to TWD97 pkm true for Penghu, Kinmen and Matsu area The latitude and longitude can be in the following formats: [+/-]DDD°MMM'SSS.SSSS" (unicode) [+/-]DDD°MMM.MMMM' (unicode) [+/-]DDD.DDDDD (string, unicode or float) The returned coordinates are in meter...
[ "Convert", "coordintes", "from", "WGS84", "to", "TWD97" ]
2fe05dbca335be425a1f451e0ef8f210ec864de1
https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L158-L186
train
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.clipValue
def clipValue(self, value, minValue, maxValue): ''' Makes sure that value is within a specific range. If not, then the lower or upper bounds is returned ''' return min(max(value, minValue), maxValue)
python
def clipValue(self, value, minValue, maxValue): ''' Makes sure that value is within a specific range. If not, then the lower or upper bounds is returned ''' return min(max(value, minValue), maxValue)
[ "def", "clipValue", "(", "self", ",", "value", ",", "minValue", ",", "maxValue", ")", ":", "return", "min", "(", "max", "(", "value", ",", "minValue", ")", ",", "maxValue", ")" ]
Makes sure that value is within a specific range. If not, then the lower or upper bounds is returned
[ "Makes", "sure", "that", "value", "is", "within", "a", "specific", "range", ".", "If", "not", "then", "the", "lower", "or", "upper", "bounds", "is", "returned" ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L16-L21
train
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.getGroundResolution
def getGroundResolution(self, latitude, level): ''' returns the ground resolution for based on latitude and zoom level. ''' latitude = self.clipValue(latitude, self.min_lat, self.max_lat); mapSize = self.getMapDimensionsByZoomLevel(level) return math.cos( lati...
python
def getGroundResolution(self, latitude, level): ''' returns the ground resolution for based on latitude and zoom level. ''' latitude = self.clipValue(latitude, self.min_lat, self.max_lat); mapSize = self.getMapDimensionsByZoomLevel(level) return math.cos( lati...
[ "def", "getGroundResolution", "(", "self", ",", "latitude", ",", "level", ")", ":", "latitude", "=", "self", ".", "clipValue", "(", "latitude", ",", "self", ".", "min_lat", ",", "self", ".", "max_lat", ")", "mapSize", "=", "self", ".", "getMapDimensionsByZ...
returns the ground resolution for based on latitude and zoom level.
[ "returns", "the", "ground", "resolution", "for", "based", "on", "latitude", "and", "zoom", "level", "." ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L30-L38
train
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.getMapScale
def getMapScale(self, latitude, level, dpi=96): ''' returns the map scale on the dpi of the screen ''' dpm = dpi / 0.0254 # convert to dots per meter return self.getGroundResolution(latitude, level) * dpm
python
def getMapScale(self, latitude, level, dpi=96): ''' returns the map scale on the dpi of the screen ''' dpm = dpi / 0.0254 # convert to dots per meter return self.getGroundResolution(latitude, level) * dpm
[ "def", "getMapScale", "(", "self", ",", "latitude", ",", "level", ",", "dpi", "=", "96", ")", ":", "dpm", "=", "dpi", "/", "0.0254", "# convert to dots per meter", "return", "self", ".", "getGroundResolution", "(", "latitude", ",", "level", ")", "*", "dpm"...
returns the map scale on the dpi of the screen
[ "returns", "the", "map", "scale", "on", "the", "dpi", "of", "the", "screen" ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L40-L45
train
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.convertLatLngToPixelXY
def convertLatLngToPixelXY(self, lat, lng, level): ''' returns the x and y values of the pixel corresponding to a latitude and longitude. ''' mapSize = self.getMapDimensionsByZoomLevel(level) lat = self.clipValue(lat, self.min_lat, self.max_lat) lng = self.clipVa...
python
def convertLatLngToPixelXY(self, lat, lng, level): ''' returns the x and y values of the pixel corresponding to a latitude and longitude. ''' mapSize = self.getMapDimensionsByZoomLevel(level) lat = self.clipValue(lat, self.min_lat, self.max_lat) lng = self.clipVa...
[ "def", "convertLatLngToPixelXY", "(", "self", ",", "lat", ",", "lng", ",", "level", ")", ":", "mapSize", "=", "self", ".", "getMapDimensionsByZoomLevel", "(", "level", ")", "lat", "=", "self", ".", "clipValue", "(", "lat", ",", "self", ".", "min_lat", ",...
returns the x and y values of the pixel corresponding to a latitude and longitude.
[ "returns", "the", "x", "and", "y", "values", "of", "the", "pixel", "corresponding", "to", "a", "latitude", "and", "longitude", "." ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L47-L63
train
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.convertPixelXYToLngLat
def convertPixelXYToLngLat(self, pixelX, pixelY, level): ''' converts a pixel x, y to a latitude and longitude. ''' mapSize = self.getMapDimensionsByZoomLevel(level) x = (self.clipValue(pixelX, 0, mapSize - 1) / mapSize) - 0.5 y = 0.5 - (self.clipValue(pixelY, 0, mapSize ...
python
def convertPixelXYToLngLat(self, pixelX, pixelY, level): ''' converts a pixel x, y to a latitude and longitude. ''' mapSize = self.getMapDimensionsByZoomLevel(level) x = (self.clipValue(pixelX, 0, mapSize - 1) / mapSize) - 0.5 y = 0.5 - (self.clipValue(pixelY, 0, mapSize ...
[ "def", "convertPixelXYToLngLat", "(", "self", ",", "pixelX", ",", "pixelY", ",", "level", ")", ":", "mapSize", "=", "self", ".", "getMapDimensionsByZoomLevel", "(", "level", ")", "x", "=", "(", "self", ".", "clipValue", "(", "pixelX", ",", "0", ",", "map...
converts a pixel x, y to a latitude and longitude.
[ "converts", "a", "pixel", "x", "y", "to", "a", "latitude", "and", "longitude", "." ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L65-L76
train
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.tileXYZToQuadKey
def tileXYZToQuadKey(self, x, y, z): ''' Computes quadKey value based on tile x, y and z values. ''' quadKey = '' for i in range(z, 0, -1): digit = 0 mask = 1 << (i - 1) if (x & mask) != 0: digit += 1 if (y & mask) !...
python
def tileXYZToQuadKey(self, x, y, z): ''' Computes quadKey value based on tile x, y and z values. ''' quadKey = '' for i in range(z, 0, -1): digit = 0 mask = 1 << (i - 1) if (x & mask) != 0: digit += 1 if (y & mask) !...
[ "def", "tileXYZToQuadKey", "(", "self", ",", "x", ",", "y", ",", "z", ")", ":", "quadKey", "=", "''", "for", "i", "in", "range", "(", "z", ",", "0", ",", "-", "1", ")", ":", "digit", "=", "0", "mask", "=", "1", "<<", "(", "i", "-", "1", "...
Computes quadKey value based on tile x, y and z values.
[ "Computes", "quadKey", "value", "based", "on", "tile", "x", "y", "and", "z", "values", "." ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L92-L105
train
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.quadKeyToTileXYZ
def quadKeyToTileXYZ(self, quadKey): ''' Computes tile x, y and z values based on quadKey. ''' tileX = 0 tileY = 0 tileZ = len(quadKey) for i in range(tileZ, 0, -1): mask = 1 << (i - 1) value = quadKey[tileZ - i] if value == '...
python
def quadKeyToTileXYZ(self, quadKey): ''' Computes tile x, y and z values based on quadKey. ''' tileX = 0 tileY = 0 tileZ = len(quadKey) for i in range(tileZ, 0, -1): mask = 1 << (i - 1) value = quadKey[tileZ - i] if value == '...
[ "def", "quadKeyToTileXYZ", "(", "self", ",", "quadKey", ")", ":", "tileX", "=", "0", "tileY", "=", "0", "tileZ", "=", "len", "(", "quadKey", ")", "for", "i", "in", "range", "(", "tileZ", ",", "0", ",", "-", "1", ")", ":", "mask", "=", "1", "<<"...
Computes tile x, y and z values based on quadKey.
[ "Computes", "tile", "x", "y", "and", "z", "values", "based", "on", "quadKey", "." ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L107-L135
train
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileUtils.getTileOrigin
def getTileOrigin(self, tileX, tileY, level): ''' Returns the upper-left hand corner lat/lng for a tile ''' pixelX, pixelY = self.convertTileXYToPixelXY(tileX, tileY) lng, lat = self.convertPixelXYToLngLat(pixelX, pixelY, level) return (lat, lng)
python
def getTileOrigin(self, tileX, tileY, level): ''' Returns the upper-left hand corner lat/lng for a tile ''' pixelX, pixelY = self.convertTileXYToPixelXY(tileX, tileY) lng, lat = self.convertPixelXYToLngLat(pixelX, pixelY, level) return (lat, lng)
[ "def", "getTileOrigin", "(", "self", ",", "tileX", ",", "tileY", ",", "level", ")", ":", "pixelX", ",", "pixelY", "=", "self", ".", "convertTileXYToPixelXY", "(", "tileX", ",", "tileY", ")", "lng", ",", "lat", "=", "self", ".", "convertPixelXYToLngLat", ...
Returns the upper-left hand corner lat/lng for a tile
[ "Returns", "the", "upper", "-", "left", "hand", "corner", "lat", "/", "lng", "for", "a", "tile" ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L141-L147
train
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileFinder.getTileUrlsByLatLngExtent
def getTileUrlsByLatLngExtent(self, xmin, ymin, xmax, ymax, level): ''' Returns a list of tile urls by extent ''' # Upper-Left Tile tileXMin, tileYMin = self.tileUtils.convertLngLatToTileXY(xmin, ymax, level) ...
python
def getTileUrlsByLatLngExtent(self, xmin, ymin, xmax, ymax, level): ''' Returns a list of tile urls by extent ''' # Upper-Left Tile tileXMin, tileYMin = self.tileUtils.convertLngLatToTileXY(xmin, ymax, level) ...
[ "def", "getTileUrlsByLatLngExtent", "(", "self", ",", "xmin", ",", "ymin", ",", "xmax", ",", "ymax", ",", "level", ")", ":", "# Upper-Left Tile", "tileXMin", ",", "tileYMin", "=", "self", ".", "tileUtils", ".", "convertLngLatToTileXY", "(", "xmin", ",", "yma...
Returns a list of tile urls by extent
[ "Returns", "a", "list", "of", "tile", "urls", "by", "extent" ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L160-L178
train
Hackerfleet/hfos
modules/maps/hfos/map/TileTools.py
TileFinder.createTileUrl
def createTileUrl(self, x, y, z): ''' returns new tile url based on template ''' return self.tileTemplate.replace('{{x}}', str(x)).replace('{{y}}', str( y)).replace('{{z}}', str(z))
python
def createTileUrl(self, x, y, z): ''' returns new tile url based on template ''' return self.tileTemplate.replace('{{x}}', str(x)).replace('{{y}}', str( y)).replace('{{z}}', str(z))
[ "def", "createTileUrl", "(", "self", ",", "x", ",", "y", ",", "z", ")", ":", "return", "self", ".", "tileTemplate", ".", "replace", "(", "'{{x}}'", ",", "str", "(", "x", ")", ")", ".", "replace", "(", "'{{y}}'", ",", "str", "(", "y", ")", ")", ...
returns new tile url based on template
[ "returns", "new", "tile", "url", "based", "on", "template" ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/TileTools.py#L180-L185
train
Hackerfleet/hfos
modules/alert/hfos/alert/manager.py
Manager.referenceframe
def referenceframe(self, event): """Handles navigational reference frame updates. These are necessary to assign geo coordinates to alerts and other misc things. :param event with incoming referenceframe message """ self.log("Got a reference frame update! ", event, lvl=e...
python
def referenceframe(self, event): """Handles navigational reference frame updates. These are necessary to assign geo coordinates to alerts and other misc things. :param event with incoming referenceframe message """ self.log("Got a reference frame update! ", event, lvl=e...
[ "def", "referenceframe", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "\"Got a reference frame update! \"", ",", "event", ",", "lvl", "=", "events", ")", "self", ".", "reference_frame", "=", "event", ".", "data" ]
Handles navigational reference frame updates. These are necessary to assign geo coordinates to alerts and other misc things. :param event with incoming referenceframe message
[ "Handles", "navigational", "reference", "frame", "updates", ".", "These", "are", "necessary", "to", "assign", "geo", "coordinates", "to", "alerts", "and", "other", "misc", "things", "." ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/alert/hfos/alert/manager.py#L112-L122
train
Hackerfleet/hfos
modules/alert/hfos/alert/manager.py
Manager.userlogin
def userlogin(self, event): """Checks if an alert is ongoing and alerts the newly connected client, if so.""" client_uuid = event.clientuuid self.log(event.user, pretty=True, lvl=verbose) self.log('Adding client') self.clients[event.clientuuid] = event.user fo...
python
def userlogin(self, event): """Checks if an alert is ongoing and alerts the newly connected client, if so.""" client_uuid = event.clientuuid self.log(event.user, pretty=True, lvl=verbose) self.log('Adding client') self.clients[event.clientuuid] = event.user fo...
[ "def", "userlogin", "(", "self", ",", "event", ")", ":", "client_uuid", "=", "event", ".", "clientuuid", "self", ".", "log", "(", "event", ".", "user", ",", "pretty", "=", "True", ",", "lvl", "=", "verbose", ")", "self", ".", "log", "(", "'Adding cli...
Checks if an alert is ongoing and alerts the newly connected client, if so.
[ "Checks", "if", "an", "alert", "is", "ongoing", "and", "alerts", "the", "newly", "connected", "client", "if", "so", "." ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/alert/hfos/alert/manager.py#L153-L165
train
Hackerfleet/hfos
modules/alert/hfos/alert/manager.py
Manager.trigger
def trigger(self, event): """AlertManager event handler for incoming events :param event with incoming AlertManager message """ topic = event.data.get('topic', None) if topic is None: self.log('No alert topic to trigger', lvl=warn) return alert ...
python
def trigger(self, event): """AlertManager event handler for incoming events :param event with incoming AlertManager message """ topic = event.data.get('topic', None) if topic is None: self.log('No alert topic to trigger', lvl=warn) return alert ...
[ "def", "trigger", "(", "self", ",", "event", ")", ":", "topic", "=", "event", ".", "data", ".", "get", "(", "'topic'", ",", "None", ")", "if", "topic", "is", "None", ":", "self", ".", "log", "(", "'No alert topic to trigger'", ",", "lvl", "=", "warn"...
AlertManager event handler for incoming events :param event with incoming AlertManager message
[ "AlertManager", "event", "handler", "for", "incoming", "events" ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/alert/hfos/alert/manager.py#L207-L224
train
Hackerfleet/hfos
modules/alert/hfos/alert/manager.py
Manager.cancel
def cancel(self, event): """AlertManager event handler for incoming events :param event with incoming AlertManager message """ topic = event.data.get('topic', None) if topic is None: self.log('No alert topic to cancel', lvl=warn) return self._can...
python
def cancel(self, event): """AlertManager event handler for incoming events :param event with incoming AlertManager message """ topic = event.data.get('topic', None) if topic is None: self.log('No alert topic to cancel', lvl=warn) return self._can...
[ "def", "cancel", "(", "self", ",", "event", ")", ":", "topic", "=", "event", ".", "data", ".", "get", "(", "'topic'", ",", "None", ")", "if", "topic", "is", "None", ":", "self", ".", "log", "(", "'No alert topic to cancel'", ",", "lvl", "=", "warn", ...
AlertManager event handler for incoming events :param event with incoming AlertManager message
[ "AlertManager", "event", "handler", "for", "incoming", "events" ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/alert/hfos/alert/manager.py#L237-L247
train
Hackerfleet/hfos
hfos/tool/cli.py
cli
def cli(ctx, instance, quiet, verbose, log_level, dbhost, dbname): """Isomer Management Tool This tool supports various operations to manage isomer instances. Most of the commands are grouped. To obtain more information about the groups' available sub commands/groups, try iso [group] To disp...
python
def cli(ctx, instance, quiet, verbose, log_level, dbhost, dbname): """Isomer Management Tool This tool supports various operations to manage isomer instances. Most of the commands are grouped. To obtain more information about the groups' available sub commands/groups, try iso [group] To disp...
[ "def", "cli", "(", "ctx", ",", "instance", ",", "quiet", ",", "verbose", ",", "log_level", ",", "dbhost", ",", "dbname", ")", ":", "ctx", ".", "obj", "[", "'instance'", "]", "=", "instance", "if", "dbname", "==", "db_default", "and", "instance", "!=", ...
Isomer Management Tool This tool supports various operations to manage isomer instances. Most of the commands are grouped. To obtain more information about the groups' available sub commands/groups, try iso [group] To display details of a command or its sub groups, try iso [group] [subgroup...
[ "Isomer", "Management", "Tool" ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/cli.py#L48-L78
train
astrocatalogs/astrocats
astrocats/main.py
main
def main(): """Primary entry point for all AstroCats catalogs. From this entry point, all internal catalogs can be accessed and their public methods executed (for example: import scripts). """ from datetime import datetime # Initialize Command-Line and User-Config Settings, Log # --------...
python
def main(): """Primary entry point for all AstroCats catalogs. From this entry point, all internal catalogs can be accessed and their public methods executed (for example: import scripts). """ from datetime import datetime # Initialize Command-Line and User-Config Settings, Log # --------...
[ "def", "main", "(", ")", ":", "from", "datetime", "import", "datetime", "# Initialize Command-Line and User-Config Settings, Log", "# -----------------------------------------------------", "beg_time", "=", "datetime", ".", "now", "(", ")", "# Process command-line arguments to de...
Primary entry point for all AstroCats catalogs. From this entry point, all internal catalogs can be accessed and their public methods executed (for example: import scripts).
[ "Primary", "entry", "point", "for", "all", "AstroCats", "catalogs", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/main.py#L13-L73
train
astrocatalogs/astrocats
astrocats/main.py
setup_user_config
def setup_user_config(log): """Setup a configuration file in the user's home directory. Currently this method stores default values to a fixed configuration filename. It should be modified to run an interactive prompt session asking for parameters (or at least confirming the default ones). Argume...
python
def setup_user_config(log): """Setup a configuration file in the user's home directory. Currently this method stores default values to a fixed configuration filename. It should be modified to run an interactive prompt session asking for parameters (or at least confirming the default ones). Argume...
[ "def", "setup_user_config", "(", "log", ")", ":", "log", ".", "warning", "(", "\"AstroCats Setup\"", ")", "log", ".", "warning", "(", "\"Configure filepath: '{}'\"", ".", "format", "(", "_CONFIG_PATH", ")", ")", "# Create path to configuration file as needed", "config...
Setup a configuration file in the user's home directory. Currently this method stores default values to a fixed configuration filename. It should be modified to run an interactive prompt session asking for parameters (or at least confirming the default ones). Arguments --------- log : `loggin...
[ "Setup", "a", "configuration", "file", "in", "the", "user", "s", "home", "directory", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/main.py#L76-L113
train
astrocatalogs/astrocats
astrocats/main.py
load_user_config
def load_user_config(args, log): """Load settings from the user's confiuration file, and add them to `args`. Settings are loaded from the configuration file in the user's home directory. Those parameters are added (as attributes) to the `args` object. Arguments --------- args : `argparse....
python
def load_user_config(args, log): """Load settings from the user's confiuration file, and add them to `args`. Settings are loaded from the configuration file in the user's home directory. Those parameters are added (as attributes) to the `args` object. Arguments --------- args : `argparse....
[ "def", "load_user_config", "(", "args", ",", "log", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "_CONFIG_PATH", ")", ":", "err_str", "=", "(", "\"Configuration file does not exists ({}).\\n\"", ".", "format", "(", "_CONFIG_PATH", ")", "+", ...
Load settings from the user's confiuration file, and add them to `args`. Settings are loaded from the configuration file in the user's home directory. Those parameters are added (as attributes) to the `args` object. Arguments --------- args : `argparse.Namespace` Namespace object to w...
[ "Load", "settings", "from", "the", "user", "s", "confiuration", "file", "and", "add", "them", "to", "args", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/main.py#L116-L144
train
astrocatalogs/astrocats
astrocats/main.py
load_command_line_args
def load_command_line_args(clargs=None): """Load and parse command-line arguments. Arguments --------- args : str or None 'Faked' commandline arguments passed to `argparse`. Returns ------- args : `argparse.Namespace` object Namespace in which settings are stored - default ...
python
def load_command_line_args(clargs=None): """Load and parse command-line arguments. Arguments --------- args : str or None 'Faked' commandline arguments passed to `argparse`. Returns ------- args : `argparse.Namespace` object Namespace in which settings are stored - default ...
[ "def", "load_command_line_args", "(", "clargs", "=", "None", ")", ":", "import", "argparse", "git_vers", "=", "get_git", "(", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "'astrocats'", ",", "description", "=", "'Generate catalogs for...
Load and parse command-line arguments. Arguments --------- args : str or None 'Faked' commandline arguments passed to `argparse`. Returns ------- args : `argparse.Namespace` object Namespace in which settings are stored - default values modified by the given command-lin...
[ "Load", "and", "parse", "command", "-", "line", "arguments", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/main.py#L147-L259
train
astrocatalogs/astrocats
astrocats/main.py
load_log
def load_log(args): """Load a `logging.Logger` object. Arguments --------- args : `argparse.Namespace` object Namespace containing required settings: {`args.debug`, `args.verbose`, and `args.log_filename`}. Returns ------- log : `logging.Logger` object """ from ast...
python
def load_log(args): """Load a `logging.Logger` object. Arguments --------- args : `argparse.Namespace` object Namespace containing required settings: {`args.debug`, `args.verbose`, and `args.log_filename`}. Returns ------- log : `logging.Logger` object """ from ast...
[ "def", "load_log", "(", "args", ")", ":", "from", "astrocats", ".", "catalog", ".", "utils", "import", "logger", "# Determine verbosity ('None' means use default)", "log_stream_level", "=", "None", "if", "args", ".", "debug", ":", "log_stream_level", "=", "logger", ...
Load a `logging.Logger` object. Arguments --------- args : `argparse.Namespace` object Namespace containing required settings: {`args.debug`, `args.verbose`, and `args.log_filename`}. Returns ------- log : `logging.Logger` object
[ "Load", "a", "logging", ".", "Logger", "object", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/main.py#L262-L290
train
astrocatalogs/astrocats
compare.py
compare_dicts
def compare_dicts(old_full, new_full, old_data, new_data, depth=0): """Function compares dictionaries by key-value recursively. Old and new input data are both dictionaries """ depth = depth + 1 indent = " "*depth # Print with an indentation matching the nested-dictionary depth def my_pri...
python
def compare_dicts(old_full, new_full, old_data, new_data, depth=0): """Function compares dictionaries by key-value recursively. Old and new input data are both dictionaries """ depth = depth + 1 indent = " "*depth # Print with an indentation matching the nested-dictionary depth def my_pri...
[ "def", "compare_dicts", "(", "old_full", ",", "new_full", ",", "old_data", ",", "new_data", ",", "depth", "=", "0", ")", ":", "depth", "=", "depth", "+", "1", "indent", "=", "\" \"", "*", "depth", "# Print with an indentation matching the nested-dictionary depth"...
Function compares dictionaries by key-value recursively. Old and new input data are both dictionaries
[ "Function", "compares", "dictionaries", "by", "key", "-", "value", "recursively", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/compare.py#L99-L179
train
scivision/morecvutils
morecvutils/lineClipping.py
cohensutherland
def cohensutherland(xmin, ymax, xmax, ymin, x1, y1, x2, y2): """Clips a line to a rectangular area. This implements the Cohen-Sutherland line clipping algorithm. xmin, ymax, xmax and ymin denote the clipping area, into which the line defined by x1, y1 (start point) and x2, y2 (end point) will be c...
python
def cohensutherland(xmin, ymax, xmax, ymin, x1, y1, x2, y2): """Clips a line to a rectangular area. This implements the Cohen-Sutherland line clipping algorithm. xmin, ymax, xmax and ymin denote the clipping area, into which the line defined by x1, y1 (start point) and x2, y2 (end point) will be c...
[ "def", "cohensutherland", "(", "xmin", ",", "ymax", ",", "xmax", ",", "ymin", ",", "x1", ",", "y1", ",", "x2", ",", "y2", ")", ":", "INSIDE", ",", "LEFT", ",", "RIGHT", ",", "LOWER", ",", "UPPER", "=", "0", ",", "1", ",", "2", ",", "4", ",", ...
Clips a line to a rectangular area. This implements the Cohen-Sutherland line clipping algorithm. xmin, ymax, xmax and ymin denote the clipping area, into which the line defined by x1, y1 (start point) and x2, y2 (end point) will be clipped. If the line does not intersect with the rectangular cli...
[ "Clips", "a", "line", "to", "a", "rectangular", "area", "." ]
03cd40ec9f4d577a6bc796185c3bec4a576c4d16
https://github.com/scivision/morecvutils/blob/03cd40ec9f4d577a6bc796185c3bec4a576c4d16/morecvutils/lineClipping.py#L16-L87
train
scivision/morecvutils
morecvutils/calcOptFlow.py
setupuv
def setupuv(rc): """ Horn Schunck legacy OpenCV function requires we use these old-fashioned cv matrices, not numpy array """ if cv is not None: (r, c) = rc u = cv.CreateMat(r, c, cv.CV_32FC1) v = cv.CreateMat(r, c, cv.CV_32FC1) return (u, v) else: return [Non...
python
def setupuv(rc): """ Horn Schunck legacy OpenCV function requires we use these old-fashioned cv matrices, not numpy array """ if cv is not None: (r, c) = rc u = cv.CreateMat(r, c, cv.CV_32FC1) v = cv.CreateMat(r, c, cv.CV_32FC1) return (u, v) else: return [Non...
[ "def", "setupuv", "(", "rc", ")", ":", "if", "cv", "is", "not", "None", ":", "(", "r", ",", "c", ")", "=", "rc", "u", "=", "cv", ".", "CreateMat", "(", "r", ",", "c", ",", "cv", ".", "CV_32FC1", ")", "v", "=", "cv", ".", "CreateMat", "(", ...
Horn Schunck legacy OpenCV function requires we use these old-fashioned cv matrices, not numpy array
[ "Horn", "Schunck", "legacy", "OpenCV", "function", "requires", "we", "use", "these", "old", "-", "fashioned", "cv", "matrices", "not", "numpy", "array" ]
03cd40ec9f4d577a6bc796185c3bec4a576c4d16
https://github.com/scivision/morecvutils/blob/03cd40ec9f4d577a6bc796185c3bec4a576c4d16/morecvutils/calcOptFlow.py#L39-L49
train
astrocatalogs/astrocats
astrocats/catalog/model.py
Model._init_cat_dict
def _init_cat_dict(self, cat_dict_class, key_in_self, **kwargs): """Initialize a CatDict object, checking for errors. """ # Catch errors associated with crappy, but not unexpected data try: new_entry = cat_dict_class(self, key=key_in_self, **kwargs) except CatDictErro...
python
def _init_cat_dict(self, cat_dict_class, key_in_self, **kwargs): """Initialize a CatDict object, checking for errors. """ # Catch errors associated with crappy, but not unexpected data try: new_entry = cat_dict_class(self, key=key_in_self, **kwargs) except CatDictErro...
[ "def", "_init_cat_dict", "(", "self", ",", "cat_dict_class", ",", "key_in_self", ",", "*", "*", "kwargs", ")", ":", "# Catch errors associated with crappy, but not unexpected data", "try", ":", "new_entry", "=", "cat_dict_class", "(", "self", ",", "key", "=", "key_i...
Initialize a CatDict object, checking for errors.
[ "Initialize", "a", "CatDict", "object", "checking", "for", "errors", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/model.py#L68-L79
train
astrocatalogs/astrocats
astrocats/catalog/model.py
Model._add_cat_dict
def _add_cat_dict(self, cat_dict_class, key_in_self, check_for_dupes=True, **kwargs): """Add a CatDict to this Entry if initialization succeeds and it doesn't already exist within the Entry. """ # Try...
python
def _add_cat_dict(self, cat_dict_class, key_in_self, check_for_dupes=True, **kwargs): """Add a CatDict to this Entry if initialization succeeds and it doesn't already exist within the Entry. """ # Try...
[ "def", "_add_cat_dict", "(", "self", ",", "cat_dict_class", ",", "key_in_self", ",", "check_for_dupes", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# Try to create a new instance of this subclass of `CatDict`", "new_entry", "=", "self", ".", "_init_cat_dict", "("...
Add a CatDict to this Entry if initialization succeeds and it doesn't already exist within the Entry.
[ "Add", "a", "CatDict", "to", "this", "Entry", "if", "initialization", "succeeds", "and", "it", "doesn", "t", "already", "exist", "within", "the", "Entry", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/model.py#L81-L105
train
astrocatalogs/astrocats
astrocats/catalog/utils/tq_funcs.py
pbar
def pbar(iter, desc='', **kwargs): """Wrapper for `tqdm` progress bar. """ return tqdm( iter, desc=('<' + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + '> ' + desc), dynamic_ncols=True, **kwargs)
python
def pbar(iter, desc='', **kwargs): """Wrapper for `tqdm` progress bar. """ return tqdm( iter, desc=('<' + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + '> ' + desc), dynamic_ncols=True, **kwargs)
[ "def", "pbar", "(", "iter", ",", "desc", "=", "''", ",", "*", "*", "kwargs", ")", ":", "return", "tqdm", "(", "iter", ",", "desc", "=", "(", "'<'", "+", "str", "(", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "\"%Y-%m-%d %H:%M:%S\"", ...
Wrapper for `tqdm` progress bar.
[ "Wrapper", "for", "tqdm", "progress", "bar", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/utils/tq_funcs.py#L17-L25
train
astrocatalogs/astrocats
astrocats/catalog/utils/tq_funcs.py
pbar_strings
def pbar_strings(files, desc='', **kwargs): """Wrapper for `tqdm` progress bar which also sorts list of strings """ return tqdm( sorted(files, key=lambda s: s.lower()), desc=('<' + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + '> ' + desc), dynamic_ncols=True, ...
python
def pbar_strings(files, desc='', **kwargs): """Wrapper for `tqdm` progress bar which also sorts list of strings """ return tqdm( sorted(files, key=lambda s: s.lower()), desc=('<' + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + '> ' + desc), dynamic_ncols=True, ...
[ "def", "pbar_strings", "(", "files", ",", "desc", "=", "''", ",", "*", "*", "kwargs", ")", ":", "return", "tqdm", "(", "sorted", "(", "files", ",", "key", "=", "lambda", "s", ":", "s", ".", "lower", "(", ")", ")", ",", "desc", "=", "(", "'<'", ...
Wrapper for `tqdm` progress bar which also sorts list of strings
[ "Wrapper", "for", "tqdm", "progress", "bar", "which", "also", "sorts", "list", "of", "strings" ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/utils/tq_funcs.py#L28-L36
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
_get_task_priority
def _get_task_priority(tasks, task_priority): """Get the task `priority` corresponding to the given `task_priority`. If `task_priority` is an integer or 'None', return it. If `task_priority` is a str, return the priority of the task it matches. Otherwise, raise `ValueError`. """ if task_priorit...
python
def _get_task_priority(tasks, task_priority): """Get the task `priority` corresponding to the given `task_priority`. If `task_priority` is an integer or 'None', return it. If `task_priority` is a str, return the priority of the task it matches. Otherwise, raise `ValueError`. """ if task_priorit...
[ "def", "_get_task_priority", "(", "tasks", ",", "task_priority", ")", ":", "if", "task_priority", "is", "None", ":", "return", "None", "if", "is_integer", "(", "task_priority", ")", ":", "return", "task_priority", "if", "isinstance", "(", "task_priority", ",", ...
Get the task `priority` corresponding to the given `task_priority`. If `task_priority` is an integer or 'None', return it. If `task_priority` is a str, return the priority of the task it matches. Otherwise, raise `ValueError`.
[ "Get", "the", "task", "priority", "corresponding", "to", "the", "given", "task_priority", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L1376-L1391
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.import_data
def import_data(self): """Run all of the import tasks. This is executed by the 'scripts.main.py' when the module is run as an executable. This can also be run as a method, in which case default arguments are loaded, but can be overriden using `**kwargs`. """ tasks_list ...
python
def import_data(self): """Run all of the import tasks. This is executed by the 'scripts.main.py' when the module is run as an executable. This can also be run as a method, in which case default arguments are loaded, but can be overriden using `**kwargs`. """ tasks_list ...
[ "def", "import_data", "(", "self", ")", ":", "tasks_list", "=", "self", ".", "load_task_list", "(", ")", "warnings", ".", "filterwarnings", "(", "'ignore'", ",", "r'Warning: converting a masked element to nan.'", ")", "# FIX", "warnings", ".", "filterwarnings", "(",...
Run all of the import tasks. This is executed by the 'scripts.main.py' when the module is run as an executable. This can also be run as a method, in which case default arguments are loaded, but can be overriden using `**kwargs`.
[ "Run", "all", "of", "the", "import", "tasks", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L221-L288
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.load_task_list
def load_task_list(self): """Load the list of tasks in this catalog's 'input/tasks.json' file. A `Task` object is created for each entry, with the parameters filled in. These are placed in an OrderedDict, sorted by the `priority` parameter, with positive values and then negative values,...
python
def load_task_list(self): """Load the list of tasks in this catalog's 'input/tasks.json' file. A `Task` object is created for each entry, with the parameters filled in. These are placed in an OrderedDict, sorted by the `priority` parameter, with positive values and then negative values,...
[ "def", "load_task_list", "(", "self", ")", ":", "# In update mode, do not delete old files", "if", "self", ".", "args", ".", "update", ":", "self", ".", "log", ".", "info", "(", "\"Disabling `pre-delete` for 'update' mode.\"", ")", "self", ".", "args", ".", "delet...
Load the list of tasks in this catalog's 'input/tasks.json' file. A `Task` object is created for each entry, with the parameters filled in. These are placed in an OrderedDict, sorted by the `priority` parameter, with positive values and then negative values, e.g. [0, 2, 10, -10, -1]...
[ "Load", "the", "list", "of", "tasks", "in", "this", "catalog", "s", "input", "/", "tasks", ".", "json", "file", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L290-L406
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.add_entry
def add_entry(self, name, load=True, delete=True): """Find an existing entry in, or add a new one to, the `entries` dict. FIX: rename to `create_entry`??? Returns ------- entries : OrderedDict of Entry objects newname : str Name of matching entry found in `e...
python
def add_entry(self, name, load=True, delete=True): """Find an existing entry in, or add a new one to, the `entries` dict. FIX: rename to `create_entry`??? Returns ------- entries : OrderedDict of Entry objects newname : str Name of matching entry found in `e...
[ "def", "add_entry", "(", "self", ",", "name", ",", "load", "=", "True", ",", "delete", "=", "True", ")", ":", "newname", "=", "self", ".", "clean_entry_name", "(", "name", ")", "if", "not", "newname", ":", "raise", "(", "ValueError", "(", "'Fatal: Atte...
Find an existing entry in, or add a new one to, the `entries` dict. FIX: rename to `create_entry`??? Returns ------- entries : OrderedDict of Entry objects newname : str Name of matching entry found in `entries`, or new entry added to `entries`
[ "Find", "an", "existing", "entry", "in", "or", "add", "a", "new", "one", "to", "the", "entries", "dict", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L438-L492
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.find_entry_name_of_alias
def find_entry_name_of_alias(self, alias): """Return the first entry name with the given 'alias' included in its list of aliases. Returns ------- name of matching entry (str) or 'None' if no matches """ if alias in self.aliases: name = self.aliases[a...
python
def find_entry_name_of_alias(self, alias): """Return the first entry name with the given 'alias' included in its list of aliases. Returns ------- name of matching entry (str) or 'None' if no matches """ if alias in self.aliases: name = self.aliases[a...
[ "def", "find_entry_name_of_alias", "(", "self", ",", "alias", ")", ":", "if", "alias", "in", "self", ".", "aliases", ":", "name", "=", "self", ".", "aliases", "[", "alias", "]", "if", "name", "in", "self", ".", "entries", ":", "return", "name", "else",...
Return the first entry name with the given 'alias' included in its list of aliases. Returns ------- name of matching entry (str) or 'None' if no matches
[ "Return", "the", "first", "entry", "name", "with", "the", "given", "alias", "included", "in", "its", "list", "of", "aliases", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L517-L540
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.copy_entry_to_entry
def copy_entry_to_entry(self, fromentry, destentry, check_for_dupes=True, compare_to_existing=True): """Used by `merge_duplicates` """ self.log.info("Copy entry object '{}' to '{}'".fo...
python
def copy_entry_to_entry(self, fromentry, destentry, check_for_dupes=True, compare_to_existing=True): """Used by `merge_duplicates` """ self.log.info("Copy entry object '{}' to '{}'".fo...
[ "def", "copy_entry_to_entry", "(", "self", ",", "fromentry", ",", "destentry", ",", "check_for_dupes", "=", "True", ",", "compare_to_existing", "=", "True", ")", ":", "self", ".", "log", ".", "info", "(", "\"Copy entry object '{}' to '{}'\"", ".", "format", "(",...
Used by `merge_duplicates`
[ "Used", "by", "merge_duplicates" ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L546-L617
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.merge_duplicates
def merge_duplicates(self): """Merge and remove duplicate entries. Compares each entry ('name') in `stubs` to all later entries to check for duplicates in name or alias. If a duplicate is found, they are merged and written to file. """ if len(self.entries) == 0: ...
python
def merge_duplicates(self): """Merge and remove duplicate entries. Compares each entry ('name') in `stubs` to all later entries to check for duplicates in name or alias. If a duplicate is found, they are merged and written to file. """ if len(self.entries) == 0: ...
[ "def", "merge_duplicates", "(", "self", ")", ":", "if", "len", "(", "self", ".", "entries", ")", "==", "0", ":", "self", ".", "log", ".", "error", "(", "\"WARNING: `entries` is empty, loading stubs\"", ")", "if", "self", ".", "args", ".", "update", ":", ...
Merge and remove duplicate entries. Compares each entry ('name') in `stubs` to all later entries to check for duplicates in name or alias. If a duplicate is found, they are merged and written to file.
[ "Merge", "and", "remove", "duplicate", "entries", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L652-L746
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.load_stubs
def load_stubs(self, log_mem=False): """Load all events in their `stub` (name, alias, etc only) form. Used in `update` mode. """ # Initialize parameter related to diagnostic output of memory usage if log_mem: import psutil process = psutil.Process(os.getp...
python
def load_stubs(self, log_mem=False): """Load all events in their `stub` (name, alias, etc only) form. Used in `update` mode. """ # Initialize parameter related to diagnostic output of memory usage if log_mem: import psutil process = psutil.Process(os.getp...
[ "def", "load_stubs", "(", "self", ",", "log_mem", "=", "False", ")", ":", "# Initialize parameter related to diagnostic output of memory usage", "if", "log_mem", ":", "import", "psutil", "process", "=", "psutil", ".", "Process", "(", "os", ".", "getpid", "(", ")",...
Load all events in their `stub` (name, alias, etc only) form. Used in `update` mode.
[ "Load", "all", "events", "in", "their", "stub", "(", "name", "alias", "etc", "only", ")", "form", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L754-L851
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog._delete_entry_file
def _delete_entry_file(self, entry_name=None, entry=None): """Delete the file associated with the given entry. """ if entry_name is None and entry is None: raise RuntimeError("Either `entry_name` or `entry` must be given.") elif entry_name is not None and entry is not None: ...
python
def _delete_entry_file(self, entry_name=None, entry=None): """Delete the file associated with the given entry. """ if entry_name is None and entry is None: raise RuntimeError("Either `entry_name` or `entry` must be given.") elif entry_name is not None and entry is not None: ...
[ "def", "_delete_entry_file", "(", "self", ",", "entry_name", "=", "None", ",", "entry", "=", "None", ")", ":", "if", "entry_name", "is", "None", "and", "entry", "is", "None", ":", "raise", "RuntimeError", "(", "\"Either `entry_name` or `entry` must be given.\"", ...
Delete the file associated with the given entry.
[ "Delete", "the", "file", "associated", "with", "the", "given", "entry", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L857-L884
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.journal_entries
def journal_entries(self, clear=True, gz=False, bury=False, write_stubs=False, final=False): """Write all entries in `entries` to files, and clear. Depending on arguments and `tasks`....
python
def journal_entries(self, clear=True, gz=False, bury=False, write_stubs=False, final=False): """Write all entries in `entries` to files, and clear. Depending on arguments and `tasks`....
[ "def", "journal_entries", "(", "self", ",", "clear", "=", "True", ",", "gz", "=", "False", ",", "bury", "=", "False", ",", "write_stubs", "=", "False", ",", "final", "=", "False", ")", ":", "# if (self.current_task.priority >= 0 and", "# self.current_task...
Write all entries in `entries` to files, and clear. Depending on arguments and `tasks`. Iterates over all elements of `entries`, saving (possibly 'burying') and deleting. - If ``clear == True``, then each element of `entries` is deleted, and a `stubs` entry is added
[ "Write", "all", "entries", "in", "entries", "to", "files", "and", "clear", ".", "Depending", "on", "arguments", "and", "tasks", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L889-L945
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.set_preferred_names
def set_preferred_names(self): """Choose between each entries given name and its possible aliases for the best one. """ if len(self.entries) == 0: self.log.error("WARNING: `entries` is empty, loading stubs") self.load_stubs() task_str = self.get_current_t...
python
def set_preferred_names(self): """Choose between each entries given name and its possible aliases for the best one. """ if len(self.entries) == 0: self.log.error("WARNING: `entries` is empty, loading stubs") self.load_stubs() task_str = self.get_current_t...
[ "def", "set_preferred_names", "(", "self", ")", ":", "if", "len", "(", "self", ".", "entries", ")", "==", "0", ":", "self", ".", "log", ".", "error", "(", "\"WARNING: `entries` is empty, loading stubs\"", ")", "self", ".", "load_stubs", "(", ")", "task_str",...
Choose between each entries given name and its possible aliases for the best one.
[ "Choose", "between", "each", "entries", "given", "name", "and", "its", "possible", "aliases", "for", "the", "best", "one", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L975-L991
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog._prep_git_add_file_list
def _prep_git_add_file_list(self, repo, size_limit, fail=True, file_types=None): """Get a list of files which should be added to the given repository. Notes ----- ...
python
def _prep_git_add_file_list(self, repo, size_limit, fail=True, file_types=None): """Get a list of files which should be added to the given repository. Notes ----- ...
[ "def", "_prep_git_add_file_list", "(", "self", ",", "repo", ",", "size_limit", ",", "fail", "=", "True", ",", "file_types", "=", "None", ")", ":", "add_files", "=", "[", "]", "if", "file_types", "is", "None", ":", "file_patterns", "=", "[", "'*'", "]", ...
Get a list of files which should be added to the given repository. Notes ----- * Finds files in the *root* of the given repository path. * If `file_types` is given, only use those file types. * If an uncompressed file is above the `size_limit`, it is compressed. * If a c...
[ "Get", "a", "list", "of", "files", "which", "should", "be", "added", "to", "the", "given", "repository", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L993-L1067
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.load_url
def load_url(self, url, fname, repo=None, timeout=120, post=None, fail=False, write=True, json_sort=None, cache_only=False, archived_mode=None, ...
python
def load_url(self, url, fname, repo=None, timeout=120, post=None, fail=False, write=True, json_sort=None, cache_only=False, archived_mode=None, ...
[ "def", "load_url", "(", "self", ",", "url", ",", "fname", ",", "repo", "=", "None", ",", "timeout", "=", "120", ",", "post", "=", "None", ",", "fail", "=", "False", ",", "write", "=", "True", ",", "json_sort", "=", "None", ",", "cache_only", "=", ...
Load the given URL, or a cached-version. Load page from url or cached file, depending on the current settings. 'archived' mode applies when `args.archived` is true (from `--archived` CL argument), and when this task has `Task.archived` also set to True. 'archived' mode: ...
[ "Load", "the", "given", "URL", "or", "a", "cached", "-", "version", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L1093-L1276
train
astrocatalogs/astrocats
astrocats/catalog/catalog.py
Catalog.download_url
def download_url(self, url, timeout, fail=False, post=None, verify=True): """Download text from the given url. Returns `None` on failure. Arguments --------- self url : str URL web address to download. timeout : int Duration after which U...
python
def download_url(self, url, timeout, fail=False, post=None, verify=True): """Download text from the given url. Returns `None` on failure. Arguments --------- self url : str URL web address to download. timeout : int Duration after which U...
[ "def", "download_url", "(", "self", ",", "url", ",", "timeout", ",", "fail", "=", "False", ",", "post", "=", "None", ",", "verify", "=", "True", ")", ":", "_CODE_ERRORS", "=", "[", "500", ",", "307", ",", "404", "]", "import", "requests", "session", ...
Download text from the given url. Returns `None` on failure. Arguments --------- self url : str URL web address to download. timeout : int Duration after which URL request should terminate. fail : bool If `True`, then an error...
[ "Download", "text", "from", "the", "given", "url", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catalog.py#L1296-L1373
train
astrocatalogs/astrocats
astrocats/catalog/catdict.py
CatDict.append_sources_from
def append_sources_from(self, other): """Merge the source alias lists of two CatDicts.""" # Get aliases lists from this `CatDict` and other self_aliases = self[self._KEYS.SOURCE].split(',') other_aliases = other[self._KEYS.SOURCE].split(',') # Store alias to `self` self[...
python
def append_sources_from(self, other): """Merge the source alias lists of two CatDicts.""" # Get aliases lists from this `CatDict` and other self_aliases = self[self._KEYS.SOURCE].split(',') other_aliases = other[self._KEYS.SOURCE].split(',') # Store alias to `self` self[...
[ "def", "append_sources_from", "(", "self", ",", "other", ")", ":", "# Get aliases lists from this `CatDict` and other", "self_aliases", "=", "self", "[", "self", ".", "_KEYS", ".", "SOURCE", "]", ".", "split", "(", "','", ")", "other_aliases", "=", "other", "[",...
Merge the source alias lists of two CatDicts.
[ "Merge", "the", "source", "alias", "lists", "of", "two", "CatDicts", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/catdict.py#L202-L211
train
astrocatalogs/astrocats
astrocats/catalog/task.py
Task.current_task
def current_task(self, args): """Name of current action for progress-bar output. The specific task string is depends on the configuration via `args`. Returns ------- ctask : str String representation of this task. """ ctask = self.nice_name if self.n...
python
def current_task(self, args): """Name of current action for progress-bar output. The specific task string is depends on the configuration via `args`. Returns ------- ctask : str String representation of this task. """ ctask = self.nice_name if self.n...
[ "def", "current_task", "(", "self", ",", "args", ")", ":", "ctask", "=", "self", ".", "nice_name", "if", "self", ".", "nice_name", "is", "not", "None", "else", "self", ".", "name", "if", "args", "is", "not", "None", ":", "if", "args", ".", "update", ...
Name of current action for progress-bar output. The specific task string is depends on the configuration via `args`. Returns ------- ctask : str String representation of this task.
[ "Name", "of", "current", "action", "for", "progress", "-", "bar", "output", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/task.py#L77-L93
train
astrocatalogs/astrocats
astrocats/catalog/task.py
Task.load_archive
def load_archive(self, args): """Whether previously archived data should be loaded. """ import warnings warnings.warn("`Task.load_archive()` is deprecated! " "`Catalog.load_url` handles the same functionality.") return self.archived or args.archived
python
def load_archive(self, args): """Whether previously archived data should be loaded. """ import warnings warnings.warn("`Task.load_archive()` is deprecated! " "`Catalog.load_url` handles the same functionality.") return self.archived or args.archived
[ "def", "load_archive", "(", "self", ",", "args", ")", ":", "import", "warnings", "warnings", ".", "warn", "(", "\"`Task.load_archive()` is deprecated! \"", "\"`Catalog.load_url` handles the same functionality.\"", ")", "return", "self", ".", "archived", "or", "args", "...
Whether previously archived data should be loaded.
[ "Whether", "previously", "archived", "data", "should", "be", "loaded", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/task.py#L95-L101
train
astrocatalogs/astrocats
astrocats/catalog/gitter.py
get_sha
def get_sha(path=None, log=None, short=False, timeout=None): """Use `git rev-parse HEAD <REPO>` to get current SHA. """ # git_command = "git rev-parse HEAD {}".format(repo_name).split() # git_command = "git rev-parse HEAD".split() git_command = ["git", "rev-parse"] if short: git_command....
python
def get_sha(path=None, log=None, short=False, timeout=None): """Use `git rev-parse HEAD <REPO>` to get current SHA. """ # git_command = "git rev-parse HEAD {}".format(repo_name).split() # git_command = "git rev-parse HEAD".split() git_command = ["git", "rev-parse"] if short: git_command....
[ "def", "get_sha", "(", "path", "=", "None", ",", "log", "=", "None", ",", "short", "=", "False", ",", "timeout", "=", "None", ")", ":", "# git_command = \"git rev-parse HEAD {}\".format(repo_name).split()", "# git_command = \"git rev-parse HEAD\".split()", "git_command", ...
Use `git rev-parse HEAD <REPO>` to get current SHA.
[ "Use", "git", "rev", "-", "parse", "HEAD", "<REPO", ">", "to", "get", "current", "SHA", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L30-L56
train
astrocatalogs/astrocats
astrocats/catalog/gitter.py
git_add_commit_push_all_repos
def git_add_commit_push_all_repos(cat): """Add all files in each data repository tree, commit, push. Creates a commit message based on the current catalog version info. If either the `git add` or `git push` commands fail, an error will be raised. Currently, if `commit` fails an error *WILL NOT* be ra...
python
def git_add_commit_push_all_repos(cat): """Add all files in each data repository tree, commit, push. Creates a commit message based on the current catalog version info. If either the `git add` or `git push` commands fail, an error will be raised. Currently, if `commit` fails an error *WILL NOT* be ra...
[ "def", "git_add_commit_push_all_repos", "(", "cat", ")", ":", "log", "=", "cat", ".", "log", "log", ".", "debug", "(", "\"gitter.git_add_commit_push_all_repos()\"", ")", "# Do not commit/push private repos", "all_repos", "=", "cat", ".", "PATHS", ".", "get_all_repo_fo...
Add all files in each data repository tree, commit, push. Creates a commit message based on the current catalog version info. If either the `git add` or `git push` commands fail, an error will be raised. Currently, if `commit` fails an error *WILL NOT* be raised because the `commit` command will retu...
[ "Add", "all", "files", "in", "each", "data", "repository", "tree", "commit", "push", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L59-L117
train
astrocatalogs/astrocats
astrocats/catalog/gitter.py
git_pull_all_repos
def git_pull_all_repos(cat, strategy_recursive=True, strategy='theirs'): """Perform a 'git pull' in each data repository. > `git pull -s recursive -X theirs` """ # raise RuntimeError("THIS DOESNT WORK YET!") log = cat.log log.debug("gitter.git_pull_all_repos()") log.warning("WARNING: using ...
python
def git_pull_all_repos(cat, strategy_recursive=True, strategy='theirs'): """Perform a 'git pull' in each data repository. > `git pull -s recursive -X theirs` """ # raise RuntimeError("THIS DOESNT WORK YET!") log = cat.log log.debug("gitter.git_pull_all_repos()") log.warning("WARNING: using ...
[ "def", "git_pull_all_repos", "(", "cat", ",", "strategy_recursive", "=", "True", ",", "strategy", "=", "'theirs'", ")", ":", "# raise RuntimeError(\"THIS DOESNT WORK YET!\")", "log", "=", "cat", ".", "log", "log", ".", "debug", "(", "\"gitter.git_pull_all_repos()\"", ...
Perform a 'git pull' in each data repository. > `git pull -s recursive -X theirs`
[ "Perform", "a", "git", "pull", "in", "each", "data", "repository", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L120-L170
train
astrocatalogs/astrocats
astrocats/catalog/gitter.py
git_clone_all_repos
def git_clone_all_repos(cat): """Perform a 'git clone' for each data repository that doesnt exist. """ log = cat.log log.debug("gitter.git_clone_all_repos()") all_repos = cat.PATHS.get_all_repo_folders() out_repos = cat.PATHS.get_repo_output_folders() for repo in all_repos: log.info...
python
def git_clone_all_repos(cat): """Perform a 'git clone' for each data repository that doesnt exist. """ log = cat.log log.debug("gitter.git_clone_all_repos()") all_repos = cat.PATHS.get_all_repo_folders() out_repos = cat.PATHS.get_repo_output_folders() for repo in all_repos: log.info...
[ "def", "git_clone_all_repos", "(", "cat", ")", ":", "log", "=", "cat", ".", "log", "log", ".", "debug", "(", "\"gitter.git_clone_all_repos()\"", ")", "all_repos", "=", "cat", ".", "PATHS", ".", "get_all_repo_folders", "(", ")", "out_repos", "=", "cat", ".", ...
Perform a 'git clone' for each data repository that doesnt exist.
[ "Perform", "a", "git", "clone", "for", "each", "data", "repository", "that", "doesnt", "exist", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L173-L205
train
astrocatalogs/astrocats
astrocats/catalog/gitter.py
git_reset_all_repos
def git_reset_all_repos(cat, hard=True, origin=False, clean=True): """Perform a 'git reset' in each data repository. """ log = cat.log log.debug("gitter.git_reset_all_repos()") all_repos = cat.PATHS.get_all_repo_folders() for repo in all_repos: log.warning("Repo in: '{}'".format(repo)) ...
python
def git_reset_all_repos(cat, hard=True, origin=False, clean=True): """Perform a 'git reset' in each data repository. """ log = cat.log log.debug("gitter.git_reset_all_repos()") all_repos = cat.PATHS.get_all_repo_folders() for repo in all_repos: log.warning("Repo in: '{}'".format(repo)) ...
[ "def", "git_reset_all_repos", "(", "cat", ",", "hard", "=", "True", ",", "origin", "=", "False", ",", "clean", "=", "True", ")", ":", "log", "=", "cat", ".", "log", "log", ".", "debug", "(", "\"gitter.git_reset_all_repos()\"", ")", "all_repos", "=", "cat...
Perform a 'git reset' in each data repository.
[ "Perform", "a", "git", "reset", "in", "each", "data", "repository", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L208-L248
train
astrocatalogs/astrocats
astrocats/catalog/gitter.py
git_status_all_repos
def git_status_all_repos(cat, hard=True, origin=False, clean=True): """Perform a 'git status' in each data repository. """ log = cat.log log.debug("gitter.git_status_all_repos()") all_repos = cat.PATHS.get_all_repo_folders() for repo_name in all_repos: log.info("Repo in: '{}'".format(re...
python
def git_status_all_repos(cat, hard=True, origin=False, clean=True): """Perform a 'git status' in each data repository. """ log = cat.log log.debug("gitter.git_status_all_repos()") all_repos = cat.PATHS.get_all_repo_folders() for repo_name in all_repos: log.info("Repo in: '{}'".format(re...
[ "def", "git_status_all_repos", "(", "cat", ",", "hard", "=", "True", ",", "origin", "=", "False", ",", "clean", "=", "True", ")", ":", "log", "=", "cat", ".", "log", "log", ".", "debug", "(", "\"gitter.git_status_all_repos()\"", ")", "all_repos", "=", "c...
Perform a 'git status' in each data repository.
[ "Perform", "a", "git", "status", "in", "each", "data", "repository", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L251-L275
train
astrocatalogs/astrocats
astrocats/catalog/gitter.py
clone
def clone(repo, log, depth=1): """Given a list of repositories, make sure they're all cloned. Should be called from the subclassed `Catalog` objects, passed a list of specific repository names. Arguments --------- all_repos : list of str *Absolute* path specification of each target rep...
python
def clone(repo, log, depth=1): """Given a list of repositories, make sure they're all cloned. Should be called from the subclassed `Catalog` objects, passed a list of specific repository names. Arguments --------- all_repos : list of str *Absolute* path specification of each target rep...
[ "def", "clone", "(", "repo", ",", "log", ",", "depth", "=", "1", ")", ":", "kwargs", "=", "{", "}", "if", "depth", ">", "0", ":", "kwargs", "[", "'depth'", "]", "=", "depth", "try", ":", "repo_name", "=", "os", ".", "path", ".", "split", "(", ...
Given a list of repositories, make sure they're all cloned. Should be called from the subclassed `Catalog` objects, passed a list of specific repository names. Arguments --------- all_repos : list of str *Absolute* path specification of each target repository.
[ "Given", "a", "list", "of", "repositories", "make", "sure", "they", "re", "all", "cloned", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L278-L304
train
astrocatalogs/astrocats
astrocats/catalog/gitter.py
_call_command_in_repo
def _call_command_in_repo(comm, repo, log, fail=False, log_flag=True): """Use `subprocess` to call a command in a certain (repo) directory. Logs the output (both `stderr` and `stdout`) to the log, and checks the return codes to make sure they're valid. Raises error if not. Raises ------ excep...
python
def _call_command_in_repo(comm, repo, log, fail=False, log_flag=True): """Use `subprocess` to call a command in a certain (repo) directory. Logs the output (both `stderr` and `stdout`) to the log, and checks the return codes to make sure they're valid. Raises error if not. Raises ------ excep...
[ "def", "_call_command_in_repo", "(", "comm", ",", "repo", ",", "log", ",", "fail", "=", "False", ",", "log_flag", "=", "True", ")", ":", "if", "log_flag", ":", "log", ".", "debug", "(", "\"Running '{}'.\"", ".", "format", "(", "\" \"", ".", "join", "("...
Use `subprocess` to call a command in a certain (repo) directory. Logs the output (both `stderr` and `stdout`) to the log, and checks the return codes to make sure they're valid. Raises error if not. Raises ------ exception `subprocess.CalledProcessError`: if the command fails
[ "Use", "subprocess", "to", "call", "a", "command", "in", "a", "certain", "(", "repo", ")", "directory", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/gitter.py#L307-L335
train
astrocatalogs/astrocats
astrocats/catalog/spectrum.py
Spectrum._check
def _check(self): """Check that spectrum has legal combination of attributes.""" # Run the super method super(Spectrum, self)._check() err_str = None has_data = self._KEYS.DATA in self has_wave = self._KEYS.WAVELENGTHS in self has_flux = self._KEYS.FLUXES in self...
python
def _check(self): """Check that spectrum has legal combination of attributes.""" # Run the super method super(Spectrum, self)._check() err_str = None has_data = self._KEYS.DATA in self has_wave = self._KEYS.WAVELENGTHS in self has_flux = self._KEYS.FLUXES in self...
[ "def", "_check", "(", "self", ")", ":", "# Run the super method", "super", "(", "Spectrum", ",", "self", ")", ".", "_check", "(", ")", "err_str", "=", "None", "has_data", "=", "self", ".", "_KEYS", ".", "DATA", "in", "self", "has_wave", "=", "self", "....
Check that spectrum has legal combination of attributes.
[ "Check", "that", "spectrum", "has", "legal", "combination", "of", "attributes", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/spectrum.py#L112-L133
train
astrocatalogs/astrocats
astrocats/catalog/spectrum.py
Spectrum.is_duplicate_of
def is_duplicate_of(self, other): """Check if spectrum is duplicate of another.""" if super(Spectrum, self).is_duplicate_of(other): return True row_matches = 0 for ri, row in enumerate(self.get(self._KEYS.DATA, [])): lambda1, flux1 = tuple(row[0:2]) if...
python
def is_duplicate_of(self, other): """Check if spectrum is duplicate of another.""" if super(Spectrum, self).is_duplicate_of(other): return True row_matches = 0 for ri, row in enumerate(self.get(self._KEYS.DATA, [])): lambda1, flux1 = tuple(row[0:2]) if...
[ "def", "is_duplicate_of", "(", "self", ",", "other", ")", ":", "if", "super", "(", "Spectrum", ",", "self", ")", ".", "is_duplicate_of", "(", "other", ")", ":", "return", "True", "row_matches", "=", "0", "for", "ri", ",", "row", "in", "enumerate", "(",...
Check if spectrum is duplicate of another.
[ "Check", "if", "spectrum", "is", "duplicate", "of", "another", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/spectrum.py#L135-L158
train
astrocatalogs/astrocats
astrocats/catalog/spectrum.py
Spectrum.sort_func
def sort_func(self, key): """Logic for sorting keys in a `Spectrum` relative to one another.""" if key == self._KEYS.TIME: return 'aaa' if key == self._KEYS.DATA: return 'zzy' if key == self._KEYS.SOURCE: return 'zzz' return key
python
def sort_func(self, key): """Logic for sorting keys in a `Spectrum` relative to one another.""" if key == self._KEYS.TIME: return 'aaa' if key == self._KEYS.DATA: return 'zzy' if key == self._KEYS.SOURCE: return 'zzz' return key
[ "def", "sort_func", "(", "self", ",", "key", ")", ":", "if", "key", "==", "self", ".", "_KEYS", ".", "TIME", ":", "return", "'aaa'", "if", "key", "==", "self", ".", "_KEYS", ".", "DATA", ":", "return", "'zzy'", "if", "key", "==", "self", ".", "_K...
Logic for sorting keys in a `Spectrum` relative to one another.
[ "Logic", "for", "sorting", "keys", "in", "a", "Spectrum", "relative", "to", "one", "another", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/spectrum.py#L160-L168
train
astrocatalogs/astrocats
astrocats/catalog/quantity.py
Quantity.sort_func
def sort_func(self, key): """Sorting logic for `Quantity` objects.""" if key == self._KEYS.VALUE: return 'aaa' if key == self._KEYS.SOURCE: return 'zzz' return key
python
def sort_func(self, key): """Sorting logic for `Quantity` objects.""" if key == self._KEYS.VALUE: return 'aaa' if key == self._KEYS.SOURCE: return 'zzz' return key
[ "def", "sort_func", "(", "self", ",", "key", ")", ":", "if", "key", "==", "self", ".", "_KEYS", ".", "VALUE", ":", "return", "'aaa'", "if", "key", "==", "self", ".", "_KEYS", ".", "SOURCE", ":", "return", "'zzz'", "return", "key" ]
Sorting logic for `Quantity` objects.
[ "Sorting", "logic", "for", "Quantity", "objects", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/quantity.py#L113-L119
train
astrocatalogs/astrocats
astrocats/catalog/key.py
KeyCollection.keys
def keys(cls): """Return this class's attribute names (those not stating with '_'). Also retrieves the attributes from base classes, e.g. For: ``ENTRY(KeyCollection)``, ``ENTRY.keys()`` gives just the attributes of `ENTRY` (`KeyCollection` has no keys). For: ``SUPERNOVA(ENT...
python
def keys(cls): """Return this class's attribute names (those not stating with '_'). Also retrieves the attributes from base classes, e.g. For: ``ENTRY(KeyCollection)``, ``ENTRY.keys()`` gives just the attributes of `ENTRY` (`KeyCollection` has no keys). For: ``SUPERNOVA(ENT...
[ "def", "keys", "(", "cls", ")", ":", "if", "cls", ".", "_keys", ":", "return", "cls", ".", "_keys", "# If `_keys` is not yet defined, create it", "# ----------------------------------------", "_keys", "=", "[", "]", "# get the keys from all base-classes aswell (when this is...
Return this class's attribute names (those not stating with '_'). Also retrieves the attributes from base classes, e.g. For: ``ENTRY(KeyCollection)``, ``ENTRY.keys()`` gives just the attributes of `ENTRY` (`KeyCollection` has no keys). For: ``SUPERNOVA(ENTRY)``, ``SUPERNOVA.keys()`...
[ "Return", "this", "class", "s", "attribute", "names", "(", "those", "not", "stating", "with", "_", ")", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/key.py#L20-L54
train
astrocatalogs/astrocats
astrocats/catalog/key.py
KeyCollection.vals
def vals(cls): """Return this class's attribute values (those not stating with '_'). Returns ------- _vals : list of objects List of values of internal attributes. Order is effectiely random. """ if cls._vals: return cls._vals # If `_val...
python
def vals(cls): """Return this class's attribute values (those not stating with '_'). Returns ------- _vals : list of objects List of values of internal attributes. Order is effectiely random. """ if cls._vals: return cls._vals # If `_val...
[ "def", "vals", "(", "cls", ")", ":", "if", "cls", ".", "_vals", ":", "return", "cls", ".", "_vals", "# If `_vals` is not yet defined, create it", "# ----------------------------------------", "_vals", "=", "[", "]", "# get the keys from all base-classes aswell (when this is...
Return this class's attribute values (those not stating with '_'). Returns ------- _vals : list of objects List of values of internal attributes. Order is effectiely random.
[ "Return", "this", "class", "s", "attribute", "values", "(", "those", "not", "stating", "with", "_", ")", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/key.py#L57-L85
train
astrocatalogs/astrocats
astrocats/catalog/key.py
KeyCollection.compare_vals
def compare_vals(cls, sort=True): """Return this class's attribute values (those not stating with '_'), but only for attributes with `compare` set to `True`. Returns ------- _compare_vals : list of objects List of values of internal attributes to use when comparing ...
python
def compare_vals(cls, sort=True): """Return this class's attribute values (those not stating with '_'), but only for attributes with `compare` set to `True`. Returns ------- _compare_vals : list of objects List of values of internal attributes to use when comparing ...
[ "def", "compare_vals", "(", "cls", ",", "sort", "=", "True", ")", ":", "if", "cls", ".", "_compare_vals", ":", "return", "cls", ".", "_compare_vals", "# If `_compare_vals` is not yet defined, create it", "# ----------------------------------------", "_compare_vals", "=", ...
Return this class's attribute values (those not stating with '_'), but only for attributes with `compare` set to `True`. Returns ------- _compare_vals : list of objects List of values of internal attributes to use when comparing `CatDict` objects. Order sorted by...
[ "Return", "this", "class", "s", "attribute", "values", "(", "those", "not", "stating", "with", "_", ")", "but", "only", "for", "attributes", "with", "compare", "set", "to", "True", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/key.py#L88-L128
train
astrocatalogs/astrocats
astrocats/catalog/key.py
Key.pretty
def pretty(self): """Return a 'pretty' string representation of this `Key`. note: do not override the builtin `__str__` or `__repr__` methods! """ retval = ("Key(name={}, type={}, listable={}, compare={}, " "priority={}, kind_preference={}, " "replace...
python
def pretty(self): """Return a 'pretty' string representation of this `Key`. note: do not override the builtin `__str__` or `__repr__` methods! """ retval = ("Key(name={}, type={}, listable={}, compare={}, " "priority={}, kind_preference={}, " "replace...
[ "def", "pretty", "(", "self", ")", ":", "retval", "=", "(", "\"Key(name={}, type={}, listable={}, compare={}, \"", "\"priority={}, kind_preference={}, \"", "\"replace_better={})\"", ")", ".", "format", "(", "self", ".", "name", ",", "self", ".", "type", ",", "self", ...
Return a 'pretty' string representation of this `Key`. note: do not override the builtin `__str__` or `__repr__` methods!
[ "Return", "a", "pretty", "string", "representation", "of", "this", "Key", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/key.py#L219-L229
train
astrocatalogs/astrocats
astrocats/catalog/key.py
Key.check
def check(self, val): """Make sure given value is consistent with this `Key` specification. NOTE: if `type` is 'None', then `listable` also is *not* checked. """ # If there is no `type` requirement, everything is allowed if self.type is None: return True is_...
python
def check(self, val): """Make sure given value is consistent with this `Key` specification. NOTE: if `type` is 'None', then `listable` also is *not* checked. """ # If there is no `type` requirement, everything is allowed if self.type is None: return True is_...
[ "def", "check", "(", "self", ",", "val", ")", ":", "# If there is no `type` requirement, everything is allowed", "if", "self", ".", "type", "is", "None", ":", "return", "True", "is_list", "=", "isinstance", "(", "val", ",", "list", ")", "# If lists are not allowed...
Make sure given value is consistent with this `Key` specification. NOTE: if `type` is 'None', then `listable` also is *not* checked.
[ "Make", "sure", "given", "value", "is", "consistent", "with", "this", "Key", "specification", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/key.py#L231-L265
train
astrocatalogs/astrocats
astrocats/catalog/utils/logger.py
get_logger
def get_logger(name=None, stream_fmt=None, file_fmt=None, date_fmt=None, stream_level=None, file_level=None, tofile=None, tostr=True): """Create a standard logger object which logs to file and or stdout stream. If a logger has already been created in this session, it is returned ...
python
def get_logger(name=None, stream_fmt=None, file_fmt=None, date_fmt=None, stream_level=None, file_level=None, tofile=None, tostr=True): """Create a standard logger object which logs to file and or stdout stream. If a logger has already been created in this session, it is returned ...
[ "def", "get_logger", "(", "name", "=", "None", ",", "stream_fmt", "=", "None", ",", "file_fmt", "=", "None", ",", "date_fmt", "=", "None", ",", "stream_level", "=", "None", ",", "file_level", "=", "None", ",", "tofile", "=", "None", ",", "tostr", "=", ...
Create a standard logger object which logs to file and or stdout stream. If a logger has already been created in this session, it is returned (unless `name` is given). Arguments --------- name : str, Handle for this logger, must be distinct for a distinct logger. stream_fmt : str or `N...
[ "Create", "a", "standard", "logger", "object", "which", "logs", "to", "file", "and", "or", "stdout", "stream", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/utils/logger.py#L39-L133
train
astrocatalogs/astrocats
astrocats/catalog/utils/logger.py
log_raise
def log_raise(log, err_str, err_type=RuntimeError): """Log an error message and raise an error. Arguments --------- log : `logging.Logger` object err_str : str Error message to be logged and raised. err_type : `Exception` object Type of error to raise. """ log.error(err...
python
def log_raise(log, err_str, err_type=RuntimeError): """Log an error message and raise an error. Arguments --------- log : `logging.Logger` object err_str : str Error message to be logged and raised. err_type : `Exception` object Type of error to raise. """ log.error(err...
[ "def", "log_raise", "(", "log", ",", "err_str", ",", "err_type", "=", "RuntimeError", ")", ":", "log", ".", "error", "(", "err_str", ")", "# Make sure output is flushed", "# (happens automatically to `StreamHandlers`, but not `FileHandlers`)", "for", "handle", "in", "lo...
Log an error message and raise an error. Arguments --------- log : `logging.Logger` object err_str : str Error message to be logged and raised. err_type : `Exception` object Type of error to raise.
[ "Log", "an", "error", "message", "and", "raise", "an", "error", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/utils/logger.py#L136-L154
train
astrocatalogs/astrocats
astrocats/catalog/utils/logger.py
log_memory
def log_memory(log, pref=None, lvl=logging.DEBUG, raise_flag=True): """Log the current memory usage. """ import os import sys cyc_str = "" KB = 1024.0 if pref is not None: cyc_str += "{}: ".format(pref) # Linux returns units in Bytes; OSX in kilobytes UNIT = KB*KB if sys.pla...
python
def log_memory(log, pref=None, lvl=logging.DEBUG, raise_flag=True): """Log the current memory usage. """ import os import sys cyc_str = "" KB = 1024.0 if pref is not None: cyc_str += "{}: ".format(pref) # Linux returns units in Bytes; OSX in kilobytes UNIT = KB*KB if sys.pla...
[ "def", "log_memory", "(", "log", ",", "pref", "=", "None", ",", "lvl", "=", "logging", ".", "DEBUG", ",", "raise_flag", "=", "True", ")", ":", "import", "os", "import", "sys", "cyc_str", "=", "\"\"", "KB", "=", "1024.0", "if", "pref", "is", "not", ...
Log the current memory usage.
[ "Log", "the", "current", "memory", "usage", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/utils/logger.py#L157-L207
train
scivision/morecvutils
morecvutils/connectedComponents.py
doblob
def doblob(morphed, blobdet, img, anno=True): """ img: can be RGB (MxNx3) or gray (MxN) http://docs.opencv.org/master/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html http://docs.opencv.org/trunk/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html """ keypo...
python
def doblob(morphed, blobdet, img, anno=True): """ img: can be RGB (MxNx3) or gray (MxN) http://docs.opencv.org/master/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html http://docs.opencv.org/trunk/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html """ keypo...
[ "def", "doblob", "(", "morphed", ",", "blobdet", ",", "img", ",", "anno", "=", "True", ")", ":", "keypoints", "=", "blobdet", ".", "detect", "(", "morphed", ")", "nkey", "=", "len", "(", "keypoints", ")", "kpsize", "=", "asarray", "(", "[", "k", "....
img: can be RGB (MxNx3) or gray (MxN) http://docs.opencv.org/master/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html http://docs.opencv.org/trunk/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html
[ "img", ":", "can", "be", "RGB", "(", "MxNx3", ")", "or", "gray", "(", "MxN", ")", "http", ":", "//", "docs", ".", "opencv", ".", "org", "/", "master", "/", "modules", "/", "features2d", "/", "doc", "/", "drawing_function_of_keypoints_and_matches", ".", ...
03cd40ec9f4d577a6bc796185c3bec4a576c4d16
https://github.com/scivision/morecvutils/blob/03cd40ec9f4d577a6bc796185c3bec4a576c4d16/morecvutils/connectedComponents.py#L9-L28
train
astrocatalogs/astrocats
astrocats/catalog/argshandler.py
ArgsHandler.load_args
def load_args(self, args, clargs): """Parse arguments and return configuration settings. """ # Parse All Arguments args = self.parser.parse_args(args=clargs, namespace=args) # Print the help information if no subcommand is given # subcommand is required for operation ...
python
def load_args(self, args, clargs): """Parse arguments and return configuration settings. """ # Parse All Arguments args = self.parser.parse_args(args=clargs, namespace=args) # Print the help information if no subcommand is given # subcommand is required for operation ...
[ "def", "load_args", "(", "self", ",", "args", ",", "clargs", ")", ":", "# Parse All Arguments", "args", "=", "self", ".", "parser", ".", "parse_args", "(", "args", "=", "clargs", ",", "namespace", "=", "args", ")", "# Print the help information if no subcommand ...
Parse arguments and return configuration settings.
[ "Parse", "arguments", "and", "return", "configuration", "settings", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/argshandler.py#L56-L68
train
astrocatalogs/astrocats
astrocats/catalog/argshandler.py
ArgsHandler._setup_argparse
def _setup_argparse(self): """Create `argparse` instance, and setup with appropriate parameters. """ parser = argparse.ArgumentParser( prog='catalog', description='Parent Catalog class for astrocats.') subparsers = parser.add_subparsers( description='valid subcom...
python
def _setup_argparse(self): """Create `argparse` instance, and setup with appropriate parameters. """ parser = argparse.ArgumentParser( prog='catalog', description='Parent Catalog class for astrocats.') subparsers = parser.add_subparsers( description='valid subcom...
[ "def", "_setup_argparse", "(", "self", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "'catalog'", ",", "description", "=", "'Parent Catalog class for astrocats.'", ")", "subparsers", "=", "parser", ".", "add_subparsers", "(", "descr...
Create `argparse` instance, and setup with appropriate parameters.
[ "Create", "argparse", "instance", "and", "setup", "with", "appropriate", "parameters", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/argshandler.py#L70-L93
train
astrocatalogs/astrocats
astrocats/catalog/argshandler.py
ArgsHandler._add_parser_arguments_import
def _add_parser_arguments_import(self, subparsers): """Create parser for 'import' subcommand, and associated arguments. """ import_pars = subparsers.add_parser( "import", help="Import data.") import_pars.add_argument( '--update', '-u', dest='update', ...
python
def _add_parser_arguments_import(self, subparsers): """Create parser for 'import' subcommand, and associated arguments. """ import_pars = subparsers.add_parser( "import", help="Import data.") import_pars.add_argument( '--update', '-u', dest='update', ...
[ "def", "_add_parser_arguments_import", "(", "self", ",", "subparsers", ")", ":", "import_pars", "=", "subparsers", ".", "add_parser", "(", "\"import\"", ",", "help", "=", "\"Import data.\"", ")", "import_pars", ".", "add_argument", "(", "'--update'", ",", "'-u'", ...
Create parser for 'import' subcommand, and associated arguments.
[ "Create", "parser", "for", "import", "subcommand", "and", "associated", "arguments", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/argshandler.py#L95-L138
train
astrocatalogs/astrocats
astrocats/catalog/argshandler.py
ArgsHandler._add_parser_arguments_git
def _add_parser_arguments_git(self, subparsers): """Create a sub-parsers for git subcommands. """ subparsers.add_parser( "git-clone", help="Clone all defined data repositories if they dont exist.") subparsers.add_parser( "git-push", help="...
python
def _add_parser_arguments_git(self, subparsers): """Create a sub-parsers for git subcommands. """ subparsers.add_parser( "git-clone", help="Clone all defined data repositories if they dont exist.") subparsers.add_parser( "git-push", help="...
[ "def", "_add_parser_arguments_git", "(", "self", ",", "subparsers", ")", ":", "subparsers", ".", "add_parser", "(", "\"git-clone\"", ",", "help", "=", "\"Clone all defined data repositories if they dont exist.\"", ")", "subparsers", ".", "add_parser", "(", "\"git-push\"",...
Create a sub-parsers for git subcommands.
[ "Create", "a", "sub", "-", "parsers", "for", "git", "subcommands", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/argshandler.py#L140-L167
train
astrocatalogs/astrocats
astrocats/catalog/argshandler.py
ArgsHandler._add_parser_arguments_analyze
def _add_parser_arguments_analyze(self, subparsers): """Create a parser for the 'analyze' subcommand. """ lyze_pars = subparsers.add_parser( "analyze", help="Perform basic analysis on this catalog.") lyze_pars.add_argument( '--count', '-c', dest='coun...
python
def _add_parser_arguments_analyze(self, subparsers): """Create a parser for the 'analyze' subcommand. """ lyze_pars = subparsers.add_parser( "analyze", help="Perform basic analysis on this catalog.") lyze_pars.add_argument( '--count', '-c', dest='coun...
[ "def", "_add_parser_arguments_analyze", "(", "self", ",", "subparsers", ")", ":", "lyze_pars", "=", "subparsers", ".", "add_parser", "(", "\"analyze\"", ",", "help", "=", "\"Perform basic analysis on this catalog.\"", ")", "lyze_pars", ".", "add_argument", "(", "'--co...
Create a parser for the 'analyze' subcommand.
[ "Create", "a", "parser", "for", "the", "analyze", "subcommand", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/argshandler.py#L169-L181
train
astrocatalogs/astrocats
astrocats/catalog/utils/imports.py
compress_gz
def compress_gz(fname): """Compress the file with the given name and delete the uncompressed file. The compressed filename is simply the input filename with '.gz' appended. Arguments --------- fname : str Name of the file to compress and delete. Returns ------- comp_fname : st...
python
def compress_gz(fname): """Compress the file with the given name and delete the uncompressed file. The compressed filename is simply the input filename with '.gz' appended. Arguments --------- fname : str Name of the file to compress and delete. Returns ------- comp_fname : st...
[ "def", "compress_gz", "(", "fname", ")", ":", "import", "shutil", "import", "gzip", "comp_fname", "=", "fname", "+", "'.gz'", "with", "codecs", ".", "open", "(", "fname", ",", "'rb'", ")", "as", "f_in", ",", "gzip", ".", "open", "(", "comp_fname", ",",...
Compress the file with the given name and delete the uncompressed file. The compressed filename is simply the input filename with '.gz' appended. Arguments --------- fname : str Name of the file to compress and delete. Returns ------- comp_fname : str Name of the compresse...
[ "Compress", "the", "file", "with", "the", "given", "name", "and", "delete", "the", "uncompressed", "file", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/utils/imports.py#L37-L60
train
scivision/morecvutils
morecvutils/cv2draw.py
draw_flow
def draw_flow(img, flow, step=16, dtype=uint8): """ draws flow vectors on image this came from opencv/examples directory another way: http://docs.opencv.org/trunk/doc/py_tutorials/py_gui/py_drawing_functions/py_drawing_functions.html """ maxval = iinfo(img.dtype).max # scaleFact = 1. #arbit...
python
def draw_flow(img, flow, step=16, dtype=uint8): """ draws flow vectors on image this came from opencv/examples directory another way: http://docs.opencv.org/trunk/doc/py_tutorials/py_gui/py_drawing_functions/py_drawing_functions.html """ maxval = iinfo(img.dtype).max # scaleFact = 1. #arbit...
[ "def", "draw_flow", "(", "img", ",", "flow", ",", "step", "=", "16", ",", "dtype", "=", "uint8", ")", ":", "maxval", "=", "iinfo", "(", "img", ".", "dtype", ")", ".", "max", "# scaleFact = 1. #arbitary factor to make flow visible", "canno", "=", "(", "0", ...
draws flow vectors on image this came from opencv/examples directory another way: http://docs.opencv.org/trunk/doc/py_tutorials/py_gui/py_drawing_functions/py_drawing_functions.html
[ "draws", "flow", "vectors", "on", "image", "this", "came", "from", "opencv", "/", "examples", "directory", "another", "way", ":", "http", ":", "//", "docs", ".", "opencv", ".", "org", "/", "trunk", "/", "doc", "/", "py_tutorials", "/", "py_gui", "/", "...
03cd40ec9f4d577a6bc796185c3bec4a576c4d16
https://github.com/scivision/morecvutils/blob/03cd40ec9f4d577a6bc796185c3bec4a576c4d16/morecvutils/cv2draw.py#L7-L33
train
scivision/morecvutils
morecvutils/cv2draw.py
draw_hsv
def draw_hsv(mag, ang, dtype=uint8, fn=None): """ mag must be uint8, uint16, uint32 and 2-D ang is in radians (float) """ assert mag.shape == ang.shape assert mag.ndim == 2 maxval = iinfo(dtype).max hsv = dstack(((degrees(ang)/2).astype(dtype), # /2 to keep less than 255 ...
python
def draw_hsv(mag, ang, dtype=uint8, fn=None): """ mag must be uint8, uint16, uint32 and 2-D ang is in radians (float) """ assert mag.shape == ang.shape assert mag.ndim == 2 maxval = iinfo(dtype).max hsv = dstack(((degrees(ang)/2).astype(dtype), # /2 to keep less than 255 ...
[ "def", "draw_hsv", "(", "mag", ",", "ang", ",", "dtype", "=", "uint8", ",", "fn", "=", "None", ")", ":", "assert", "mag", ".", "shape", "==", "ang", ".", "shape", "assert", "mag", ".", "ndim", "==", "2", "maxval", "=", "iinfo", "(", "dtype", ")",...
mag must be uint8, uint16, uint32 and 2-D ang is in radians (float)
[ "mag", "must", "be", "uint8", "uint16", "uint32", "and", "2", "-", "D", "ang", "is", "in", "radians", "(", "float", ")" ]
03cd40ec9f4d577a6bc796185c3bec4a576c4d16
https://github.com/scivision/morecvutils/blob/03cd40ec9f4d577a6bc796185c3bec4a576c4d16/morecvutils/cv2draw.py#L36-L54
train
scivision/morecvutils
morecvutils/cv2draw.py
flow2magang
def flow2magang(flow, dtype=uint8): """ flow dimensions y,x,2 3-D. flow[...,0] is magnitude, flow[...,1] is angle """ fx, fy = flow[..., 0], flow[..., 1] return hypot(fx, fy).astype(dtype), arctan2(fy, fx) + pi
python
def flow2magang(flow, dtype=uint8): """ flow dimensions y,x,2 3-D. flow[...,0] is magnitude, flow[...,1] is angle """ fx, fy = flow[..., 0], flow[..., 1] return hypot(fx, fy).astype(dtype), arctan2(fy, fx) + pi
[ "def", "flow2magang", "(", "flow", ",", "dtype", "=", "uint8", ")", ":", "fx", ",", "fy", "=", "flow", "[", "...", ",", "0", "]", ",", "flow", "[", "...", ",", "1", "]", "return", "hypot", "(", "fx", ",", "fy", ")", ".", "astype", "(", "dtype...
flow dimensions y,x,2 3-D. flow[...,0] is magnitude, flow[...,1] is angle
[ "flow", "dimensions", "y", "x", "2", "3", "-", "D", ".", "flow", "[", "...", "0", "]", "is", "magnitude", "flow", "[", "...", "1", "]", "is", "angle" ]
03cd40ec9f4d577a6bc796185c3bec4a576c4d16
https://github.com/scivision/morecvutils/blob/03cd40ec9f4d577a6bc796185c3bec4a576c4d16/morecvutils/cv2draw.py#L57-L62
train
vpelletier/python-ioctl-opt
ioctl_opt/__init__.py
IOC
def IOC(dir, type, nr, size): """ dir One of IOC_NONE, IOC_WRITE, IOC_READ, or IOC_READ|IOC_WRITE. Direction is from the application's point of view, not kernel's. size (14-bits unsigned integer) Size of the buffer passed to ioctl's "arg" argument. """ assert dir <= _IOC_DIRM...
python
def IOC(dir, type, nr, size): """ dir One of IOC_NONE, IOC_WRITE, IOC_READ, or IOC_READ|IOC_WRITE. Direction is from the application's point of view, not kernel's. size (14-bits unsigned integer) Size of the buffer passed to ioctl's "arg" argument. """ assert dir <= _IOC_DIRM...
[ "def", "IOC", "(", "dir", ",", "type", ",", "nr", ",", "size", ")", ":", "assert", "dir", "<=", "_IOC_DIRMASK", ",", "dir", "assert", "type", "<=", "_IOC_TYPEMASK", ",", "type", "assert", "nr", "<=", "_IOC_NRMASK", ",", "nr", "assert", "size", "<=", ...
dir One of IOC_NONE, IOC_WRITE, IOC_READ, or IOC_READ|IOC_WRITE. Direction is from the application's point of view, not kernel's. size (14-bits unsigned integer) Size of the buffer passed to ioctl's "arg" argument.
[ "dir", "One", "of", "IOC_NONE", "IOC_WRITE", "IOC_READ", "or", "IOC_READ|IOC_WRITE", ".", "Direction", "is", "from", "the", "application", "s", "point", "of", "view", "not", "kernel", "s", ".", "size", "(", "14", "-", "bits", "unsigned", "integer", ")", "S...
29ec5029af4a7de8709c449090529c4cc63d62b0
https://github.com/vpelletier/python-ioctl-opt/blob/29ec5029af4a7de8709c449090529c4cc63d62b0/ioctl_opt/__init__.py#L50-L62
train
vpelletier/python-ioctl-opt
ioctl_opt/__init__.py
IOC_TYPECHECK
def IOC_TYPECHECK(t): """ Returns the size of given type, and check its suitability for use in an ioctl command number. """ result = ctypes.sizeof(t) assert result <= _IOC_SIZEMASK, result return result
python
def IOC_TYPECHECK(t): """ Returns the size of given type, and check its suitability for use in an ioctl command number. """ result = ctypes.sizeof(t) assert result <= _IOC_SIZEMASK, result return result
[ "def", "IOC_TYPECHECK", "(", "t", ")", ":", "result", "=", "ctypes", ".", "sizeof", "(", "t", ")", "assert", "result", "<=", "_IOC_SIZEMASK", ",", "result", "return", "result" ]
Returns the size of given type, and check its suitability for use in an ioctl command number.
[ "Returns", "the", "size", "of", "given", "type", "and", "check", "its", "suitability", "for", "use", "in", "an", "ioctl", "command", "number", "." ]
29ec5029af4a7de8709c449090529c4cc63d62b0
https://github.com/vpelletier/python-ioctl-opt/blob/29ec5029af4a7de8709c449090529c4cc63d62b0/ioctl_opt/__init__.py#L64-L71
train
vpelletier/python-ioctl-opt
ioctl_opt/__init__.py
IOR
def IOR(type, nr, size): """ An ioctl with read parameters. size (ctype type or instance) Type/structure of the argument passed to ioctl's "arg" argument. """ return IOC(IOC_READ, type, nr, IOC_TYPECHECK(size))
python
def IOR(type, nr, size): """ An ioctl with read parameters. size (ctype type or instance) Type/structure of the argument passed to ioctl's "arg" argument. """ return IOC(IOC_READ, type, nr, IOC_TYPECHECK(size))
[ "def", "IOR", "(", "type", ",", "nr", ",", "size", ")", ":", "return", "IOC", "(", "IOC_READ", ",", "type", ",", "nr", ",", "IOC_TYPECHECK", "(", "size", ")", ")" ]
An ioctl with read parameters. size (ctype type or instance) Type/structure of the argument passed to ioctl's "arg" argument.
[ "An", "ioctl", "with", "read", "parameters", "." ]
29ec5029af4a7de8709c449090529c4cc63d62b0
https://github.com/vpelletier/python-ioctl-opt/blob/29ec5029af4a7de8709c449090529c4cc63d62b0/ioctl_opt/__init__.py#L79-L86
train
vpelletier/python-ioctl-opt
ioctl_opt/__init__.py
IOW
def IOW(type, nr, size): """ An ioctl with write parameters. size (ctype type or instance) Type/structure of the argument passed to ioctl's "arg" argument. """ return IOC(IOC_WRITE, type, nr, IOC_TYPECHECK(size))
python
def IOW(type, nr, size): """ An ioctl with write parameters. size (ctype type or instance) Type/structure of the argument passed to ioctl's "arg" argument. """ return IOC(IOC_WRITE, type, nr, IOC_TYPECHECK(size))
[ "def", "IOW", "(", "type", ",", "nr", ",", "size", ")", ":", "return", "IOC", "(", "IOC_WRITE", ",", "type", ",", "nr", ",", "IOC_TYPECHECK", "(", "size", ")", ")" ]
An ioctl with write parameters. size (ctype type or instance) Type/structure of the argument passed to ioctl's "arg" argument.
[ "An", "ioctl", "with", "write", "parameters", "." ]
29ec5029af4a7de8709c449090529c4cc63d62b0
https://github.com/vpelletier/python-ioctl-opt/blob/29ec5029af4a7de8709c449090529c4cc63d62b0/ioctl_opt/__init__.py#L88-L95
train
vpelletier/python-ioctl-opt
ioctl_opt/__init__.py
IOWR
def IOWR(type, nr, size): """ An ioctl with both read an writes parameters. size (ctype type or instance) Type/structure of the argument passed to ioctl's "arg" argument. """ return IOC(IOC_READ | IOC_WRITE, type, nr, IOC_TYPECHECK(size))
python
def IOWR(type, nr, size): """ An ioctl with both read an writes parameters. size (ctype type or instance) Type/structure of the argument passed to ioctl's "arg" argument. """ return IOC(IOC_READ | IOC_WRITE, type, nr, IOC_TYPECHECK(size))
[ "def", "IOWR", "(", "type", ",", "nr", ",", "size", ")", ":", "return", "IOC", "(", "IOC_READ", "|", "IOC_WRITE", ",", "type", ",", "nr", ",", "IOC_TYPECHECK", "(", "size", ")", ")" ]
An ioctl with both read an writes parameters. size (ctype type or instance) Type/structure of the argument passed to ioctl's "arg" argument.
[ "An", "ioctl", "with", "both", "read", "an", "writes", "parameters", "." ]
29ec5029af4a7de8709c449090529c4cc63d62b0
https://github.com/vpelletier/python-ioctl-opt/blob/29ec5029af4a7de8709c449090529c4cc63d62b0/ioctl_opt/__init__.py#L97-L104
train
astrocatalogs/astrocats
astrocats/catalog/analysis.py
_get_last_dirs
def _get_last_dirs(path, num=1): """Get a path including only the trailing `num` directories. Returns ------- last_path : str """ head, tail = os.path.split(path) last_path = str(tail) for ii in range(num): head, tail = os.path.split(head) last_path = os.path.join(tail,...
python
def _get_last_dirs(path, num=1): """Get a path including only the trailing `num` directories. Returns ------- last_path : str """ head, tail = os.path.split(path) last_path = str(tail) for ii in range(num): head, tail = os.path.split(head) last_path = os.path.join(tail,...
[ "def", "_get_last_dirs", "(", "path", ",", "num", "=", "1", ")", ":", "head", ",", "tail", "=", "os", ".", "path", ".", "split", "(", "path", ")", "last_path", "=", "str", "(", "tail", ")", "for", "ii", "in", "range", "(", "num", ")", ":", "hea...
Get a path including only the trailing `num` directories. Returns ------- last_path : str
[ "Get", "a", "path", "including", "only", "the", "trailing", "num", "directories", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L169-L184
train
astrocatalogs/astrocats
astrocats/catalog/analysis.py
Analysis.analyze
def analyze(self, args): """Run the analysis routines determined from the given `args`. """ self.log.info("Running catalog analysis") if args.count: self.count() return
python
def analyze(self, args): """Run the analysis routines determined from the given `args`. """ self.log.info("Running catalog analysis") if args.count: self.count() return
[ "def", "analyze", "(", "self", ",", "args", ")", ":", "self", ".", "log", ".", "info", "(", "\"Running catalog analysis\"", ")", "if", "args", ".", "count", ":", "self", ".", "count", "(", ")", "return" ]
Run the analysis routines determined from the given `args`.
[ "Run", "the", "analysis", "routines", "determined", "from", "the", "given", "args", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L34-L42
train
astrocatalogs/astrocats
astrocats/catalog/analysis.py
Analysis.count
def count(self): """Analyze the counts of ...things. Returns ------- retvals : dict Dictionary of 'property-name: counts' pairs for further processing """ self.log.info("Running 'count'") retvals = {} # Numbers of 'tasks' num_tasks =...
python
def count(self): """Analyze the counts of ...things. Returns ------- retvals : dict Dictionary of 'property-name: counts' pairs for further processing """ self.log.info("Running 'count'") retvals = {} # Numbers of 'tasks' num_tasks =...
[ "def", "count", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Running 'count'\"", ")", "retvals", "=", "{", "}", "# Numbers of 'tasks'", "num_tasks", "=", "self", ".", "_count_tasks", "(", ")", "retvals", "[", "'num_tasks'", "]", "=", "...
Analyze the counts of ...things. Returns ------- retvals : dict Dictionary of 'property-name: counts' pairs for further processing
[ "Analyze", "the", "counts", "of", "...", "things", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L44-L64
train
astrocatalogs/astrocats
astrocats/catalog/analysis.py
Analysis._count_tasks
def _count_tasks(self): """Count the number of tasks, both in the json and directory. Returns ------- num_tasks : int The total number of all tasks included in the `tasks.json` file. """ self.log.warning("Tasks:") tasks, task_names = self.catalog._lo...
python
def _count_tasks(self): """Count the number of tasks, both in the json and directory. Returns ------- num_tasks : int The total number of all tasks included in the `tasks.json` file. """ self.log.warning("Tasks:") tasks, task_names = self.catalog._lo...
[ "def", "_count_tasks", "(", "self", ")", ":", "self", ".", "log", ".", "warning", "(", "\"Tasks:\"", ")", "tasks", ",", "task_names", "=", "self", ".", "catalog", ".", "_load_task_list_from_file", "(", ")", "# Total number of all tasks", "num_tasks", "=", "len...
Count the number of tasks, both in the json and directory. Returns ------- num_tasks : int The total number of all tasks included in the `tasks.json` file.
[ "Count", "the", "number", "of", "tasks", "both", "in", "the", "json", "and", "directory", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L66-L87
train
astrocatalogs/astrocats
astrocats/catalog/analysis.py
Analysis._count_repo_files
def _count_repo_files(self): """Count the number of files in the data repositories. `_COUNT_FILE_TYPES` are used to determine which file types are checked explicitly. `_IGNORE_FILES` determine which files are ignored in (most) counts. Returns ------- repo_files ...
python
def _count_repo_files(self): """Count the number of files in the data repositories. `_COUNT_FILE_TYPES` are used to determine which file types are checked explicitly. `_IGNORE_FILES` determine which files are ignored in (most) counts. Returns ------- repo_files ...
[ "def", "_count_repo_files", "(", "self", ")", ":", "self", ".", "log", ".", "warning", "(", "\"Files:\"", ")", "num_files", "=", "0", "repos", "=", "self", ".", "catalog", ".", "PATHS", ".", "get_all_repo_folders", "(", ")", "num_type", "=", "np", ".", ...
Count the number of files in the data repositories. `_COUNT_FILE_TYPES` are used to determine which file types are checked explicitly. `_IGNORE_FILES` determine which files are ignored in (most) counts. Returns ------- repo_files : int Total number of (non-i...
[ "Count", "the", "number", "of", "files", "in", "the", "data", "repositories", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L89-L129
train
astrocatalogs/astrocats
astrocats/catalog/analysis.py
Analysis._file_nums_str
def _file_nums_str(self, n_all, n_type, n_ign): """Construct a string showing the number of different file types. Returns ------- f_str : str """ # 'other' is the difference between all and named n_oth = n_all - np.sum(n_type) f_str = "{} Files".format(n...
python
def _file_nums_str(self, n_all, n_type, n_ign): """Construct a string showing the number of different file types. Returns ------- f_str : str """ # 'other' is the difference between all and named n_oth = n_all - np.sum(n_type) f_str = "{} Files".format(n...
[ "def", "_file_nums_str", "(", "self", ",", "n_all", ",", "n_type", ",", "n_ign", ")", ":", "# 'other' is the difference between all and named", "n_oth", "=", "n_all", "-", "np", ".", "sum", "(", "n_type", ")", "f_str", "=", "\"{} Files\"", ".", "format", "(", ...
Construct a string showing the number of different file types. Returns ------- f_str : str
[ "Construct", "a", "string", "showing", "the", "number", "of", "different", "file", "types", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L131-L147
train
astrocatalogs/astrocats
astrocats/catalog/analysis.py
Analysis._count_files_by_type
def _count_files_by_type(self, path, pattern, ignore=True): """Count files in the given path, with the given pattern. If `ignore = True`, skip files in the `_IGNORE_FILES` list. Returns ------- num_files : int """ # Get all files matching the given path and pat...
python
def _count_files_by_type(self, path, pattern, ignore=True): """Count files in the given path, with the given pattern. If `ignore = True`, skip files in the `_IGNORE_FILES` list. Returns ------- num_files : int """ # Get all files matching the given path and pat...
[ "def", "_count_files_by_type", "(", "self", ",", "path", ",", "pattern", ",", "ignore", "=", "True", ")", ":", "# Get all files matching the given path and pattern", "files", "=", "glob", "(", "os", ".", "path", ".", "join", "(", "path", ",", "pattern", ")", ...
Count files in the given path, with the given pattern. If `ignore = True`, skip files in the `_IGNORE_FILES` list. Returns ------- num_files : int
[ "Count", "files", "in", "the", "given", "path", "with", "the", "given", "pattern", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/analysis.py#L149-L166
train
astrocatalogs/astrocats
astrocats/catalog/source.py
Source.bibcode_from_url
def bibcode_from_url(cls, url): """Given a URL, try to find the ADS bibcode. Currently: only `ads` URLs will work, e.g. Returns ------- code : str or 'None' The Bibcode if found, otherwise 'None' """ try: code = url.split('/abs/') ...
python
def bibcode_from_url(cls, url): """Given a URL, try to find the ADS bibcode. Currently: only `ads` URLs will work, e.g. Returns ------- code : str or 'None' The Bibcode if found, otherwise 'None' """ try: code = url.split('/abs/') ...
[ "def", "bibcode_from_url", "(", "cls", ",", "url", ")", ":", "try", ":", "code", "=", "url", ".", "split", "(", "'/abs/'", ")", "code", "=", "code", "[", "1", "]", ".", "strip", "(", ")", "return", "code", "except", ":", "return", "None" ]
Given a URL, try to find the ADS bibcode. Currently: only `ads` URLs will work, e.g. Returns ------- code : str or 'None' The Bibcode if found, otherwise 'None'
[ "Given", "a", "URL", "try", "to", "find", "the", "ADS", "bibcode", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/source.py#L101-L117
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry._get_save_path
def _get_save_path(self, bury=False): """Return the path that this Entry should be saved to.""" filename = self.get_filename(self[self._KEYS.NAME]) # Put objects that shouldn't belong in this catalog in the boneyard if bury: outdir = self.catalog.get_repo_boneyard() ...
python
def _get_save_path(self, bury=False): """Return the path that this Entry should be saved to.""" filename = self.get_filename(self[self._KEYS.NAME]) # Put objects that shouldn't belong in this catalog in the boneyard if bury: outdir = self.catalog.get_repo_boneyard() ...
[ "def", "_get_save_path", "(", "self", ",", "bury", "=", "False", ")", ":", "filename", "=", "self", ".", "get_filename", "(", "self", "[", "self", ".", "_KEYS", ".", "NAME", "]", ")", "# Put objects that shouldn't belong in this catalog in the boneyard", "if", "...
Return the path that this Entry should be saved to.
[ "Return", "the", "path", "that", "this", "Entry", "should", "be", "saved", "to", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L173-L197
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry._ordered
def _ordered(self, odict): """Convert the object into a plain OrderedDict.""" ndict = OrderedDict() if isinstance(odict, CatDict) or isinstance(odict, Entry): key = odict.sort_func else: key = None nkeys = list(sorted(odict.keys(), key=key)) for ...
python
def _ordered(self, odict): """Convert the object into a plain OrderedDict.""" ndict = OrderedDict() if isinstance(odict, CatDict) or isinstance(odict, Entry): key = odict.sort_func else: key = None nkeys = list(sorted(odict.keys(), key=key)) for ...
[ "def", "_ordered", "(", "self", ",", "odict", ")", ":", "ndict", "=", "OrderedDict", "(", ")", "if", "isinstance", "(", "odict", ",", "CatDict", ")", "or", "isinstance", "(", "odict", ",", "Entry", ")", ":", "key", "=", "odict", ".", "sort_func", "el...
Convert the object into a plain OrderedDict.
[ "Convert", "the", "object", "into", "a", "plain", "OrderedDict", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L199-L224
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.get_hash
def get_hash(self, keys=[]): """Return a unique hash associated with the listed keys.""" if not len(keys): keys = list(self.keys()) string_rep = '' oself = self._ordered(deepcopy(self)) for key in keys: string_rep += json.dumps(oself.get(key, ''), sort_ke...
python
def get_hash(self, keys=[]): """Return a unique hash associated with the listed keys.""" if not len(keys): keys = list(self.keys()) string_rep = '' oself = self._ordered(deepcopy(self)) for key in keys: string_rep += json.dumps(oself.get(key, ''), sort_ke...
[ "def", "get_hash", "(", "self", ",", "keys", "=", "[", "]", ")", ":", "if", "not", "len", "(", "keys", ")", ":", "keys", "=", "list", "(", "self", ".", "keys", "(", ")", ")", "string_rep", "=", "''", "oself", "=", "self", ".", "_ordered", "(", ...
Return a unique hash associated with the listed keys.
[ "Return", "a", "unique", "hash", "associated", "with", "the", "listed", "keys", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L226-L236
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry._clean_quantity
def _clean_quantity(self, quantity): """Clean quantity value before it is added to entry.""" value = quantity.get(QUANTITY.VALUE, '').strip() error = quantity.get(QUANTITY.E_VALUE, '').strip() unit = quantity.get(QUANTITY.U_VALUE, '').strip() kind = quantity.get(QUANTITY.KIND, ''...
python
def _clean_quantity(self, quantity): """Clean quantity value before it is added to entry.""" value = quantity.get(QUANTITY.VALUE, '').strip() error = quantity.get(QUANTITY.E_VALUE, '').strip() unit = quantity.get(QUANTITY.U_VALUE, '').strip() kind = quantity.get(QUANTITY.KIND, ''...
[ "def", "_clean_quantity", "(", "self", ",", "quantity", ")", ":", "value", "=", "quantity", ".", "get", "(", "QUANTITY", ".", "VALUE", ",", "''", ")", ".", "strip", "(", ")", "error", "=", "quantity", ".", "get", "(", "QUANTITY", ".", "E_VALUE", ",",...
Clean quantity value before it is added to entry.
[ "Clean", "quantity", "value", "before", "it", "is", "added", "to", "entry", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L238-L267
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry._convert_odict_to_classes
def _convert_odict_to_classes(self, data, clean=False, merge=True, pop_schema=True, compare_to_existing=True, filter...
python
def _convert_odict_to_classes(self, data, clean=False, merge=True, pop_schema=True, compare_to_existing=True, filter...
[ "def", "_convert_odict_to_classes", "(", "self", ",", "data", ",", "clean", "=", "False", ",", "merge", "=", "True", ",", "pop_schema", "=", "True", ",", "compare_to_existing", "=", "True", ",", "filter_on", "=", "{", "}", ")", ":", "self", ".", "_log", ...
Convert `OrderedDict` into `Entry` or its derivative classes.
[ "Convert", "OrderedDict", "into", "Entry", "or", "its", "derivative", "classes", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L346-L485
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry._check_cat_dict_source
def _check_cat_dict_source(self, cat_dict_class, key_in_self, **kwargs): """Check that a source exists and that a quantity isn't erroneous.""" # Make sure that a source is given source = kwargs.get(cat_dict_class._KEYS.SOURCE, None) if source is None: raise CatDictError( ...
python
def _check_cat_dict_source(self, cat_dict_class, key_in_self, **kwargs): """Check that a source exists and that a quantity isn't erroneous.""" # Make sure that a source is given source = kwargs.get(cat_dict_class._KEYS.SOURCE, None) if source is None: raise CatDictError( ...
[ "def", "_check_cat_dict_source", "(", "self", ",", "cat_dict_class", ",", "key_in_self", ",", "*", "*", "kwargs", ")", ":", "# Make sure that a source is given", "source", "=", "kwargs", ".", "get", "(", "cat_dict_class", ".", "_KEYS", ".", "SOURCE", ",", "None"...
Check that a source exists and that a quantity isn't erroneous.
[ "Check", "that", "a", "source", "exists", "and", "that", "a", "quantity", "isn", "t", "erroneous", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L487-L511
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry._add_cat_dict
def _add_cat_dict(self, cat_dict_class, key_in_self, check_for_dupes=True, compare_to_existing=True, **kwargs): """Add a `CatDict` to this `Entry`. CatDict only added if initialization succeeds...
python
def _add_cat_dict(self, cat_dict_class, key_in_self, check_for_dupes=True, compare_to_existing=True, **kwargs): """Add a `CatDict` to this `Entry`. CatDict only added if initialization succeeds...
[ "def", "_add_cat_dict", "(", "self", ",", "cat_dict_class", ",", "key_in_self", ",", "check_for_dupes", "=", "True", ",", "compare_to_existing", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# Make sure that a source is given, and is valid (nor erroneous)", "if", "...
Add a `CatDict` to this `Entry`. CatDict only added if initialization succeeds and it doesn't already exist within the Entry.
[ "Add", "a", "CatDict", "to", "this", "Entry", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L525-L586
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.init_from_file
def init_from_file(cls, catalog, name=None, path=None, clean=False, merge=True, pop_schema=True, ignore_keys=[], compare_to_existing=Tru...
python
def init_from_file(cls, catalog, name=None, path=None, clean=False, merge=True, pop_schema=True, ignore_keys=[], compare_to_existing=Tru...
[ "def", "init_from_file", "(", "cls", ",", "catalog", ",", "name", "=", "None", ",", "path", "=", "None", ",", "clean", "=", "False", ",", "merge", "=", "True", ",", "pop_schema", "=", "True", ",", "ignore_keys", "=", "[", "]", ",", "compare_to_existing...
Construct a new `Entry` instance from an input file. The input file can be given explicitly by `path`, or a path will be constructed appropriately if possible. Arguments --------- catalog : `astrocats.catalog.catalog.Catalog` instance The parent catalog object of wh...
[ "Construct", "a", "new", "Entry", "instance", "from", "an", "input", "file", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L595-L678
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.add_alias
def add_alias(self, alias, source, clean=True): """Add an alias, optionally 'cleaning' the alias string. Calls the parent `catalog` method `clean_entry_name` - to apply the same name-cleaning as is applied to entry names themselves. Returns ------- alias : str ...
python
def add_alias(self, alias, source, clean=True): """Add an alias, optionally 'cleaning' the alias string. Calls the parent `catalog` method `clean_entry_name` - to apply the same name-cleaning as is applied to entry names themselves. Returns ------- alias : str ...
[ "def", "add_alias", "(", "self", ",", "alias", ",", "source", ",", "clean", "=", "True", ")", ":", "if", "clean", ":", "alias", "=", "self", ".", "catalog", ".", "clean_entry_name", "(", "alias", ")", "self", ".", "add_quantity", "(", "self", ".", "_...
Add an alias, optionally 'cleaning' the alias string. Calls the parent `catalog` method `clean_entry_name` - to apply the same name-cleaning as is applied to entry names themselves. Returns ------- alias : str The stored version of the alias (cleaned or not).
[ "Add", "an", "alias", "optionally", "cleaning", "the", "alias", "string", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L680-L695
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.add_error
def add_error(self, value, **kwargs): """Add an `Error` instance to this entry.""" kwargs.update({ERROR.VALUE: value}) self._add_cat_dict(Error, self._KEYS.ERRORS, **kwargs) return
python
def add_error(self, value, **kwargs): """Add an `Error` instance to this entry.""" kwargs.update({ERROR.VALUE: value}) self._add_cat_dict(Error, self._KEYS.ERRORS, **kwargs) return
[ "def", "add_error", "(", "self", ",", "value", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "{", "ERROR", ".", "VALUE", ":", "value", "}", ")", "self", ".", "_add_cat_dict", "(", "Error", ",", "self", ".", "_KEYS", ".", "ERRORS"...
Add an `Error` instance to this entry.
[ "Add", "an", "Error", "instance", "to", "this", "entry", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L697-L701
train
astrocatalogs/astrocats
astrocats/catalog/entry.py
Entry.add_photometry
def add_photometry(self, compare_to_existing=True, **kwargs): """Add a `Photometry` instance to this entry.""" self._add_cat_dict( Photometry, self._KEYS.PHOTOMETRY, compare_to_existing=compare_to_existing, **kwargs) return
python
def add_photometry(self, compare_to_existing=True, **kwargs): """Add a `Photometry` instance to this entry.""" self._add_cat_dict( Photometry, self._KEYS.PHOTOMETRY, compare_to_existing=compare_to_existing, **kwargs) return
[ "def", "add_photometry", "(", "self", ",", "compare_to_existing", "=", "True", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_add_cat_dict", "(", "Photometry", ",", "self", ".", "_KEYS", ".", "PHOTOMETRY", ",", "compare_to_existing", "=", "compare_to_existi...
Add a `Photometry` instance to this entry.
[ "Add", "a", "Photometry", "instance", "to", "this", "entry", "." ]
11abc3131c6366ecd23964369e55ff264add7805
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L703-L710
train